Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,605 members, 7,809,213 topics. Date: Friday, 26 April 2024 at 05:34 AM

I Bet You Cant Do This With Javascript, *check Out* - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / I Bet You Cant Do This With Javascript, *check Out* (1178 Views)

Building A Word Scramble Game With Javascript (text Based) / How To Get A User IP Address With Javascript / Hashtag Highlighting Like Twitter With Javascript (2) (3) (4)

(1) (Reply) (Go Down)

I Bet You Cant Do This With Javascript, *check Out* by Cybergenius(m): 4:01pm On Nov 01, 2014
Lets see how you know javascript!
--
Write a function that takes an argument and returns that argument

idf = identify(3);
idf() //3
Re: I Bet You Cant Do This With Javascript, *check Out* by Cybergenius(m): 4:06pm On Nov 01, 2014
My attempt

function identify(q){
return q;
}

idf = identify(2);

idf() //"TypeError: 2(value of expression idf) is not object"
Re: I Bet You Cant Do This With Javascript, *check Out* by blueyedgeek(m): 5:14pm On Nov 01, 2014
This should be pretty easy to implement.

function identify(val){
this.val = val;
return val;
}
identify(3) --> 3
identify("Tunde" ) --> "Tunde"
identify({name: "Osewa"}) --> Object {name: "Osewa"}

Re: I Bet You Cant Do This With Javascript, *check Out* by Cybergenius(m): 5:36am On Nov 02, 2014
blueyedgeek:
This should be pretty easy to implement.

function identify(val){
this.val = val;
return val;
}
identify(3) --> 3
identify("Tunde" ) --> "Tunde"
identify({name: "Osewa"}) --> Object {name: "Osewa"}


you are wrong you didn't follow the rule, where is the idf variable?

function identify(q){
return function(){
return q;
}
}

idf = identify(3);
idf() //3
Re: I Bet You Cant Do This With Javascript, *check Out* by blueyedgeek(m): 7:02am On Nov 02, 2014
Cybergenius:


you are wrong you didn't follow the rule, where is the idf variable?

function identify(q){
return function(){
return q;
}
}

idf = identify(3);
idf() //3
Oh, I'm supposed to set a variable equal to the result of calling the identify function. Why do I need to call it like a function?
Re: I Bet You Cant Do This With Javascript, *check Out* by dhtml(m): 8:29am On Nov 02, 2014
Try this:
function identify(){return arguments[0];}
alert(identify(3));
Try zat
Re: I Bet You Cant Do This With Javascript, *check Out* by bot101(m): 11:47am On Nov 02, 2014
.
Re: I Bet You Cant Do This With Javascript, *check Out* by Cybergenius(m): 5:38pm On Nov 03, 2014
blueyedgeek:
Oh, I'm supposed to set a variable equal to the result of calling the identify function. Why do I need to call it like a function?

thats the challenge
Re: I Bet You Cant Do This With Javascript, *check Out* by dhtml(m): 7:39pm On Nov 03, 2014
Your post was not clear from the begining. . .
Re: I Bet You Cant Do This With Javascript, *check Out* by cyrielo(m): 11:05am On Nov 04, 2014
baby challenge
Re: I Bet You Cant Do This With Javascript, *check Out* by Cybergenius(m): 5:04pm On Nov 04, 2014

(1) (Reply)

Offline Digital Library / Looking For An Android Developer That Knows How To Make A News App. Pay Included / Learn WebDesign Programming HTML And CSS In Awka Anambra State

(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. 11
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.