Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,320 members, 7,808,073 topics. Date: Thursday, 25 April 2024 at 06:43 AM

Challenge For Javascript Beginners/intermidiate - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Challenge For Javascript Beginners/intermidiate (4022 Views)

Recommend A Good Course On UDEMY For Javascript / Whatsapp Group For Javascript Developers / Learn And Get The Source Code For Javascript Type Writer Code (2) (3) (4)

(1) (2) (3) (Reply) (Go Down)

Challenge For Javascript Beginners/intermidiate by Jaddo19(m): 4:05pm On Sep 13, 2017
I would post a question u guys should try ur best to answer..if u cant i would drop the solution.....others are welcome to drop questions....



Note:dont drop a question u dont have answer to

1 Like

Re: Challenge For Javascript Beginners/intermidiate by Jaddo19(m): 4:08pm On Sep 13, 2017
Question 1:
Write a function that checks if a variable has been defined.
Re: Challenge For Javascript Beginners/intermidiate by Alexanda07(m): 6:10pm On Sep 13, 2017
Jaddo19:
Question 1:
Write a function that checks if a variable has been defined.

A defined variable in JS is one that has a value. If there is no value, its means JS will consider it as undefined..

function checkUndefined(x){
if (typeof(x) === 'undefined') {
return "Value is undefined";
else{
return "Value is defined";
}
}

console.log(checkUndefined(x)); // Just type any letter in the alphabet not defined with a value.

3 Likes

Re: Challenge For Javascript Beginners/intermidiate by Jaddo19(m): 7:17pm On Sep 13, 2017
Alexanda07:


A defined variable in JS is one that has a value. If there is no value, its means JS will consider it as undefined..

function checkUndefined(x){
if (typeof(x) === 'undefined') {
return "Value is undefined";
else{
return "Value is defined";
}
}

console.log(checkUndefined(x)); // Just type any letter in the alphabet not defined with a value.
Nice one...my solution was without typeof....all the same
Re: Challenge For Javascript Beginners/intermidiate by nerdshed: 10:30am On Sep 14, 2017
function checkVar(word) {

if (typeof word === 'undefined'){
return "Variable not defined";
}
}
Re: Challenge For Javascript Beginners/intermidiate by Jaddo19(m): 2:08pm On Sep 14, 2017
nerdshed:
function checkVar(word) {

if (typeof word === 'undefined'){
return "Variable not defined";
}
}
Nice....
Re: Challenge For Javascript Beginners/intermidiate by Jaddo19(m): 2:16pm On Sep 14, 2017
My solution....

var num=45;
function isset(x){
if(x=="undefined" ){
return ' not defined';
}else{
return 'defined';
}
}
isset(num);
Re: Challenge For Javascript Beginners/intermidiate by Jaddo19(m): 2:20pm On Sep 14, 2017
Challenge 2.
LOOPING A TRIANGLE
write a loop that makes 7 calls to console.log to output the following
#
##
###
####
#####
######
#######
Re: Challenge For Javascript Beginners/intermidiate by Alexanda07(m): 5:26pm On Sep 14, 2017
Jaddo19:
Challenge 2.
LOOPING A TRIANGLE
write a loop that makes 7 calls to console.log to output the following
#
##
###
####
#####
######
#######

var item = '#' ;

for (let count=0; count<7; count++) {
console.log(item);
item+='#';
}



OR



var item = '#' ;
var count = 0;

while (count<7){
console.log(item);
item+='#' ;
count++;
}
Re: Challenge For Javascript Beginners/intermidiate by Jaddo19(m): 6:58pm On Sep 14, 2017
Alexanda07:


var item = '#' ;

for (let count=0; count&lt;7; count++) {
console.log(item);
item+='#';
}



OR



var item = '#' ;
var count = 0;

while (count&lt;7){
console.log(item);
item+='#' ;
count++;
}
I avnt run that code buh am really not sure it is gonna work
Re: Challenge For Javascript Beginners/intermidiate by Jaddo19(m): 7:01pm On Sep 14, 2017
The # is to output 7 times...so why incrementing it again...think harder bro u are close to d answer
Re: Challenge For Javascript Beginners/intermidiate by Alexanda07(m): 7:56pm On Sep 14, 2017
Jaddo19:
The # is to output 7 times...so why incrementing it again...think harder bro u are close to d answer

Like you said, you have not run it. So you dont conclude without checking out. But I have checked it out both of them and it run perfectly...

1 Like

Re: Challenge For Javascript Beginners/intermidiate by Alexanda07(m): 7:57pm On Sep 14, 2017
Jaddo19:
The # is to output 7 times...so why incrementing it again...think harder bro u are close to d answer

As a new programmer like you, Its all about and thinking and more PRACTICE and not theory and assumptions like you are looking at it now.
Re: Challenge For Javascript Beginners/intermidiate by Jaddo19(m): 9:05pm On Sep 14, 2017
Alexanda07:


As a new programmer like you, Its all about and thinking and more PRACTICE and not theory and assumptions like you are looking at it now.
I was wrong....i didnt check d code properly also didnt run... Am sorry

1 Like

Re: Challenge For Javascript Beginners/intermidiate by nsimageorge(m): 6:38pm On Sep 17, 2017
Jaddo19:
Challenge 2.
LOOPING A TRIANGLE
write a loop that makes 7 calls to console.log to output the following
#
##
###
####
#####
######
#######

var x;
for (x = "#"; x.length <= 7; x += "#" )
console.log(x);
Re: Challenge For Javascript Beginners/intermidiate by Olumyco(m): 12:31pm On Sep 18, 2017
Jaddo19:
Challenge 2.
LOOPING A TRIANGLE
write a loop that makes 7 calls to console.log to output the following
#
##
###
####
#####
######
#######

function triHashes(a) {
if (a.length <= 7) {
console.log(a);
return triHashes(a + '#');
}
}

triHashes('#');
Re: Challenge For Javascript Beginners/intermidiate by Nastydroid(m): 1:44pm On Sep 19, 2017
Olumyco:

function triHashes(a) { if (a.length <= 7) { console.log(a); return triHashes(a + '#'); } }
triHashes('#');

alert 'Only for intermediate'
Re: Challenge For Javascript Beginners/intermidiate by Jaddo19(m): 8:45am On Sep 20, 2017
Nice one guys.....i Av been busy lately....everyone is welcome to drop a challenge
Re: Challenge For Javascript Beginners/intermidiate by Jaddo19(m): 2:03pm On Sep 20, 2017
Lemme drop this simple one so beginners can participate.
.
Challenge 3.

Write a function that works just like console.log
Re: Challenge For Javascript Beginners/intermidiate by Kodejuice: 8:23pm On Sep 20, 2017
Jaddo19:
Lemme drop this simple one so beginners can participate.
.
Challenge 3.

Write a function that works just like console.log


console.log = (...a) => console.error(...a);


LoL smiley

1 Like

Re: Challenge For Javascript Beginners/intermidiate by Jaddo19(m): 9:52pm On Sep 20, 2017
Kodejuice:



console.log = (...a) =&gt; console.error(...a);


LoL smiley
Eeehmm
Re: Challenge For Javascript Beginners/intermidiate by Jaddo19(m): 12:38pm On Sep 22, 2017
Since no one has a solution to d challenge should I drop d answer nii
Re: Challenge For Javascript Beginners/intermidiate by modash(m): 6:41pm On Sep 22, 2017
Jaddo19:
Since no one has a solution to d challenge should I drop d answer nii

Gimme 24 more hours am trying to get the solution
Re: Challenge For Javascript Beginners/intermidiate by liliian(f): 7:13pm On Sep 22, 2017
smiley
Re: Challenge For Javascript Beginners/intermidiate by modash(m): 7:32pm On Sep 22, 2017
console.log("#"wink
console.log("##"wink
console.log("###"wink
console.log("####"wink
console.log("#####"wink
console.log("######"wink
console.log("#######"wink

// Using Repeat Method
for(var i = 1; i < 8; i++){
console.log("#".repeat(i))
}
Re: Challenge For Javascript Beginners/intermidiate by modash(m): 7:36pm On Sep 22, 2017
modash:
console.log("#"wink
console.log("##"wink
console.log("###"wink
console.log("####"wink
console.log("#####"wink
console.log("######"wink
console.log("#######"wink

// Using Repeat Method
for(var i = 1; i < 8; i++){
console.log("#".repeat(i))
}

please share your method as well
Re: Challenge For Javascript Beginners/intermidiate by modash(m): 7:46pm On Sep 22, 2017
Jaddo19:
Since no one has a solution to d challenge should I drop d answer nii
all the solutions given to your second problem work
all of them
Re: Challenge For Javascript Beginners/intermidiate by modash(m): 7:51pm On Sep 22, 2017
var repeatt = "#"
for(var i = 1; i < 8; i++){ console.log(repeatt); repeatt += "#"}
Re: Challenge For Javascript Beginners/intermidiate by nsimageorge(m): 7:59pm On Sep 22, 2017
Jaddo19:
Lemme drop this simple one so beginners can participate.
.
Challenge 3.

Write a function that works just like console.log

Sigh!! How else do you want to write on js console without the console object
There is no other way to get a function that works just like console.log without referring to the console object.

Please post the answer, maybe I might be wrong, I am willing to learn something new...
Re: Challenge For Javascript Beginners/intermidiate by Jaddo19(m): 8:14pm On Sep 22, 2017
modash:

all the solutions given to your second problem work
all of them
I did not test all d codes buh I would drop my own solution so those who got it wrong can correct them selves
Re: Challenge For Javascript Beginners/intermidiate by Jaddo19(m): 8:17pm On Sep 22, 2017
Solution to challenge 3:
 function print(x){
return x;
}
let add=2+2;
Print(add);
Re: Challenge For Javascript Beginners/intermidiate by nsimageorge(m): 8:19pm On Sep 22, 2017
Jaddo19:
Solution to challenge 3:
 function print(x){
return x;
}
let add=2+2;
Print(add);

This function would not write on the console.

(1) (2) (3) (Reply)

Who Knows Python? / Shopwithscrip: Logs Available And How To Use / The Javascript Thread

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 26
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.