₦airaland Forum

Welcome, Guest: Join Nairaland / LOGIN! / Trending / Recent / New
Stats: 1,884,827 members, 3,815,097 topics. Date: Tuesday, 26 September 2017 at 06:44 AM

Challenge For Javascript Beginners/intermidiate - Programming - Nairaland

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

Weekend Challenge For Practice: RLE Encoding / 100 Days Android Developer Challenge For Beginners / New Bucketjs Library For Javascript Released (1) (2) (3) (4)

(0) (1) (Reply) (Go Down)

Challenge For Javascript Beginners/intermidiate by Jaddo19(m): 4:05pm On Sep 13
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
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
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.

2 Likes

Re: Challenge For Javascript Beginners/intermidiate by Jaddo19(m): 7:17pm On Sep 13
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
smiley
Re: Challenge For Javascript Beginners/intermidiate by modash(m): 7:32pm On Sep 22
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
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
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
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
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
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
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
Jaddo19:
Solution to challenge 3:
 function print(x){
return x;
}
let add=2+2;
Print(add);

This function would not write on the console.

(0) (1) (Reply)

Assistance Needed With Oracle 10g Xe / Nigerian Crime Fighting Apps Win Global Award / Ifiok Nkem Gives Away His Joomla Extension Development Course For FREEE

Viewing this topic: Jaddo19(m)

(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: (0) (1) (2) (3) (4) (5) (6) (7) (8) (9)

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