₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,119 members, 8,420,458 topics. Date: Thursday, 04 June 2026 at 08:17 PM

Toggle theme

Challenge For Javascript Beginners/intermidiate - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingChallenge For Javascript Beginners/intermidiate (5089 Views)

1 2 3 Reply (Go Down)

Challenge For Javascript Beginners/intermidiate by Jaddo19(op):
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
Re: Challenge For Javascript Beginners/intermidiate by Jaddo19(op): 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.
Re: Challenge For Javascript Beginners/intermidiate by Jaddo19(op): 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(op): 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(op):
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(op): 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):
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(op): 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(op): 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...
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(op): 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
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(op): 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(op): 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
Re: Challenge For Javascript Beginners/intermidiate by Jaddo19(op): 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(op): 12:38pm On Sep 22, 2017
Since no one has a solution to d challenge should I drop d answer niihuh
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 niihuh
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 niihuh
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 objecthuh
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(op): 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(op): 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

Introduction To Airtable For Javascript DevelopersWhatsapp Group For Javascript DevelopersLearn And Get The Source Code For Javascript Type Writer Code234

To Be a Whiz In Cybersecurity, Where Do I Start?Do You Need Help In Writing Your Project/ Documentation (chapters 1-5)?Business Objects Connectivity To Oracle Rdb Database Issue