30th
Mar 2016
ManBearPigg
@ManBearPigg
Mar 30 2016 00:01
@bitgrower What happend to your message?
bitgrower
@bitgrower
Mar 30 2016 00:02
@ManBearPigg ... slice modifies the length of arr ... the next loop iteration, arr.length gets re-evaluated ... so, since you are shortening the length of your array, arr.length is smaller ...
sorry, @ManBearPigg ... accidentally deleted ... hopefully the re-do is as good :)
...and what I was going to continue to say is .. so your loop doesn't iterate as many times as you expect ...
ManBearPigg
@ManBearPigg
Mar 30 2016 00:03
@bitgrower Doesn’t iterate as many times as you expect kind of makes sense because I threw a break; after the slice and it did return something, but only [4]
bitgrower
@bitgrower
Mar 30 2016 00:04
yeah ... you can watch what happens by putting your code in here: pythontutor.com/javascript.html
ManBearPigg
@ManBearPigg
Mar 30 2016 00:05
@bitgrower I dont get that though, because once it slices, there are no more iterations. I already have sliced the string and saved it to myArray
@bitgrower I even threw a break to make sure that it stoped once it hit the first true value
bitgrower
@bitgrower
Mar 30 2016 00:05
but slicing affects arr, @ManBearPigg
ManBearPigg
@ManBearPigg
Mar 30 2016 00:07
@bitgrower Do I even use arr once I slice?
@bitgrower My understanding is that once I slice, arr doesn’t matter anymore anyways
bitgrower @bitgrower is double-checking the mdn page for slice ...
bitgrower
@bitgrower
Mar 30 2016 00:07
arr does, because you are using its length in your loop def
(at least that's what I think is going on ... LOL ... ) tired.
ManBearPigg
@ManBearPigg
Mar 30 2016 00:09
@bitgrower Once I slice I break the loop anyways. Am I crazy here? lol
function drop(arr, func) {
var myArray = [];

// Loop through arr.
for (var i = 0; i < arr.length; i++) {
// If func returns true at arr element,
if (func(arr[i]) === true) {
// Slice arr[i] to arr.length-1
myArray = arr.slice(arr[i], arr.length);
break;
} // End of if.
} // End of i loop.
console.log(myArray);
} // End of function.

drop([1, 2, 3, 4], function(n) {return n >= 3;});
bitgrower
@bitgrower
Mar 30 2016 00:10
actually ... I'm pretty sure I'm wrong now ... LOL ... sorry ...
where do you return your results ...
ManBearPigg
@ManBearPigg
Mar 30 2016 00:10
@bitgrower It’s like a mystery problem lol
bitgrower
@bitgrower
Mar 30 2016 00:10
or are you just using console.log for now ...
ManBearPigg
@ManBearPigg
Mar 30 2016 00:10
@bitgrower I return outside of the loop, outside of if, but inside the function
@bitgrower Yeah I write the code in atom so I’m logging for now. Doesn’t work even in atom
bitgrower
@bitgrower
Mar 30 2016 00:11
hang on ... since I put my foot in my mouth and gave you incorrect info, I'll figure out what's going on ... :)
ManBearPigg
@ManBearPigg
Mar 30 2016 00:11
@bitgrower It’s not an FCC bug
@bitgrower Okkkkkkk
@bitgrower Here’s the newest clue. When I added that break, I was able to return [4]. Without the break, it returns nothing []. But it should return [3,4] as far as I can tell. And it’s not a problem with my arr.length needing to be arr.length-1 or anything like that, because slice only returns upto but not including the last param
Will
Mar 30 2016 00:12
This is the missing letters challenge. This code solves it, but i don't like it. Any ideas how to make it better/re-write it?
function fearNotLetter(str) {
var i, b, x,f;

for (i=0; i<str.length-1; i++){
b=str.charCodeAt(i);

if ((b+1) !== str.charCodeAt(i+1)) {x = String.fromCharCode(b+1); return x;} else {f=1;}

}
//console.log(str);
if (f!==1) {return x;} else {return undefined;}

}

fearNotLetter("abce");
ManBearPigg
@ManBearPigg
Mar 30 2016 00:12
@bitgrower so that’s where I’m at basically
bitgrower
@bitgrower
Mar 30 2016 00:13
@ManBearPigg -- I tend to agree ... still looking ...
but ... get the same result in pythontutor ... probably an issue with a stray syntax problem ...
ManBearPigg
@ManBearPigg
Mar 30 2016 00:14
@bitgrower True that, I’ll go over it with a fine tooth comb. It’s pretty short so it will only take a minute to check for syntax
@bitgrower I changed it to arr.slice(arr[i-1], arr.length); and that returned 3,4
@bitgrower I still failed one of the tests though lol it might be an unrelated problem tho
CamperBot
@camperbot
Mar 30 2016 00:16
manbearpigg sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Mar 30 2016 00:16
it's not that ... it's in your slice statement ... you are not "pushing" each true value into an array, but re-writing myArry over and over again ...
CamperBot
@camperbot
Mar 30 2016 00:16
:star: 943 | @bitgrower | http://www.freecodecamp.com/bitgrower
SUSHANTH PATWARI
@suzello
Mar 30 2016 00:16
function checkAdult(age) {
if (age >= 5);
return age;
}
function bouncer(arr) {
// Don't show a false ID to this bouncer.

return arr;
}

bouncer([7, "ate", "", false, 9]);
I have written the above code to complete the faulty bouncer assignment. But i have a feeling that i did not write a efficient code. Can any one tell me the use of Boolean objects in completing this challenge.
@SaintPeter
Mar 30 2016 00:16
@ManBearPigg Note that you are not adding on to the end of myArray
bitgrower
@bitgrower
Mar 30 2016 00:17
^^^ what @SaintPeter said ...
ManBearPigg
@ManBearPigg
Mar 30 2016 00:17
@SaintPeter What do you mean peter
@SaintPeter myArray is a blank array, I don’t understand add on to the end of a blank array
@SaintPeter What is the end
bitgrower
@bitgrower
Mar 30 2016 00:17
@ManBearPigg -- you are overwriting the array you are returning ... you should loop thru the array and push each value that passes onto your return array ... not just re-write myArray each time thru the loop ...
@SaintPeter
Mar 30 2016 00:18
@ManBearPigg There is a function that adds something to the end of an array.
Vik
@vvang044
Mar 30 2016 00:18
@Takumar you still around?
ManBearPigg
@ManBearPigg
Mar 30 2016 00:20
@SaintPeter Ok thanks I will keep studying this
CamperBot
@camperbot
Mar 30 2016 00:20
manbearpigg sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2732 | @saintpeter | http://www.freecodecamp.com/saintpeter
Vik
@vvang044
Mar 30 2016 00:23
ok i give up on this truncate string
PHPman
@dmitrikonnikov
Mar 30 2016 00:23
i have been banging my head against this challenge for days, i just do not get it. it is convert celcius to farenheit with js.
Vik
@vvang044
Mar 30 2016 00:24
@dmitrikonnikov hypothetical question.....do you know how to convert farenheitt to celcius?
PHPman
@dmitrikonnikov
Mar 30 2016 00:24
nej
Vik
@vvang044
Mar 30 2016 00:24
forget about the code for a min
PHPman
@dmitrikonnikov
Mar 30 2016 00:24
nope
okay
sorry typed nope a little too late
ManBearPigg
@ManBearPigg
Mar 30 2016 00:25
@bitgrower @SaintPeter Here’s the solution
function drop(arr, func) {
var myArray = [];

// Loop through arr.
for (var i = 0; i < arr.length; i++) {
// If func returns true at arr element,
if (func(arr[i]) === true) {
// Slice arr[i] to arr.length-1
myArray = arr.slice(i);
break;
} // End of if.
} // End of i loop.
console.log(myArray);
} // End of function.

drop([1, 2, 3, 4], function(n) {return n >= 3;});
Vik
@vvang044
Mar 30 2016 00:25
ok
PHPman
@dmitrikonnikov
Mar 30 2016 00:26
so what are ya sayin
bitgrower
@bitgrower
Mar 30 2016 00:26
that still doesn't look right, @ManBearPigg
Vik
@vvang044
Mar 30 2016 00:26
Celcius * 9/5 + 32 = farenheitt
@SaintPeter
Mar 30 2016 00:26
I agree
Vik
@vvang044
Mar 30 2016 00:26
thats the formula
PHPman
@dmitrikonnikov
Mar 30 2016 00:27
okay. but what do i do where it says convert?
ManBearPigg
@ManBearPigg
Mar 30 2016 00:27
@bitgrower It’s totes correct. I was accessing arr[i] which was the value at that index, but I just wanted the index number itself. Also if you omit end, it slices to the end of the function automatically
Vik
@vvang044
Mar 30 2016 00:27
all you have to do is write a variable as farenheitt and the formula
bitgrower
@bitgrower
Mar 30 2016 00:27
...but that's not what you are supposed to do, @ManBearPigg ...
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:27
Tf=tc*(9/5)+32
Tf"temp in far"
tc=temp in celcius
PHPman
@dmitrikonnikov
Mar 30 2016 00:28
so like var farenheit = (9/5) + 32; ?
bitgrower
@bitgrower
Mar 30 2016 00:28
you are to return an array containing all the values which return true from the function you've called...
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:28
@dmitrikonnikov
Vik
@vvang044
Mar 30 2016 00:28
you need to add the celcius before 9/5
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:29
Just look @ my example @dmitrikonnikov
Vik
@vvang044
Mar 30 2016 00:29
you are multiplying celcius by 9 times and divide it by 5 and then add it by 32
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:30
You're trying to make the code interchange for any value of celcius.
PHPman
@dmitrikonnikov
Mar 30 2016 00:30
so i have to define a celcius variable and farenheit variable?
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:30
Interchangeable
The celcius bar should be defined
Var*
Vik
@vvang044
Mar 30 2016 00:30
var farenheitt = celcius *.........
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:31
You define the far
Mukul Vashistha
@MukulMux
Mar 30 2016 00:31
Hi people !
PHPman
@dmitrikonnikov
Mar 30 2016 00:31
how do you get farenheit from celcius?
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:31
Listen, you're trying to make the function take in a value in Celsius and convert it
Mukul Vashistha
@MukulMux
Mar 30 2016 00:32

Could you tell me what is wrong with this piece of code line...

var myStr = "I am a \"double quoted \"string inside\"double quotes\" "; // Change this line

Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:32
The way it it does is when it calls the function, the value taken in celcius, would be converted to far*
By using the formula
PHPman
@dmitrikonnikov
Mar 30 2016 00:33
but wouldnt you have to have a celcius variable? and input a value to turn to farenheit
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:33
You do.
It's defined within the function
Vik
@vvang044
Mar 30 2016 00:34
PHPman
@dmitrikonnikov
Mar 30 2016 00:34
where?
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:34
Function blahblah(celcius)
Take that celcius
Vik
@vvang044
Mar 30 2016 00:34
function convert(celcius)
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:34
And use it
When there's something with the function
like so function name(parameter)
PHPman
@dmitrikonnikov
Mar 30 2016 00:35
like this
var fahrenheit = celcius * (9/5) + 32;
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:35
It is defined already as a var that is part of the function
Si
PHPman
@dmitrikonnikov
Mar 30 2016 00:36
now it just says farenheit not defined
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:36
Do you understand?
Is it defined within your function?
Vik
@vvang044
Mar 30 2016 00:37
PHPman
@dmitrikonnikov
Mar 30 2016 00:37
is what?
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:37
Inside the function body
Vik
@vvang044
Mar 30 2016 00:38
@dmitrikonnikov paste your code here......let us look at it
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:39
Yeah.
Type 3 back ticks" ''' " and the shift enter.
CamperBot
@camperbot
Mar 30 2016 00:40
:bulb: to format code use backticks!  more info
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:40
Then*
Then place code in between
sleh
@MarlboroGrammer
Mar 30 2016 00:41
here belong
help belong
CamperBot
@camperbot
Mar 30 2016 00:41

# Explanation:

This can be a tricky problem to understand. You need to find where in the array a number should be inserted by order, and return the index where it should go.

Vik
@vvang044
Mar 30 2016 00:43
help truncate a string
CamperBot
@camperbot
Mar 30 2016 00:43

# Explanation:

We need to reduce the length of the string or truncate it if it is longer than the given maximum lengths specified and add ... to the end. If it is not that long then we keep it as is.

PHPman
@dmitrikonnikov
Mar 30 2016 00:44

function convert(celsius) {
// Only change code below this line
var fahrenheit = celcius * (9/5) + 32;

// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

// Change the inputs below to test your code
convert(30);

Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:45
Misspelled Celsius
Vik
@vvang044
Mar 30 2016 00:46
celsius
and remove the brackets around 9/5
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:46
Lol
PHPman
@dmitrikonnikov
Mar 30 2016 00:46
thank you @HecticHiccups @vvang044
CamperBot
@camperbot
Mar 30 2016 00:46
dmitrikonnikov sends brownie points to @hectichiccups and @vvang044 :sparkles: :thumbsup: :sparkles:
:star: 260 | @vvang044 | http://www.freecodecamp.com/vvang044
:star: 216 | @hectichiccups | http://www.freecodecamp.com/hectichiccups
Vik
@vvang044
Mar 30 2016 00:47
one down....few more to go.....good luck coding @dmitrikonnikov
PHPman
@dmitrikonnikov
Mar 30 2016 00:47
thanks. where are you in the map?
Vik
@vvang044
Mar 30 2016 00:47
truncate a string
PHPman
@dmitrikonnikov
Mar 30 2016 00:48
is that in js?
Vik
@vvang044
Mar 30 2016 00:48
algorithms
its called algorithm scripting.....beginners i believe
basic not beginners
PHPman
@dmitrikonnikov
Mar 30 2016 00:49
cool. i have a buddy who made it to advanced algorithm scripting.
Vik
@vvang044
Mar 30 2016 00:49
so will you one day
PHPman
@dmitrikonnikov
Mar 30 2016 00:50
hopefully. the js seems like it will take a long time
i breezed through html css bootstrap etc
Vik
@vvang044
Mar 30 2016 00:52
for me its really difficult its not something i went to school for.....so everything i learnt so far is self taught.....so it takes me longer....and you need sh*t load of patience and not to give up
i get frustrated superfast.....
PHPman
@dmitrikonnikov
Mar 30 2016 00:52
same here
i am also trying to learn php
if you just miss a semi colon or some stupid thing like that all your code is messed up
sleh
@MarlboroGrammer
Mar 30 2016 00:54
yeah
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:54
I'm actually a cs major.
sleh
@MarlboroGrammer
Mar 30 2016 00:54
why does this js take long time
i mean by far we learned enough about it
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:54
So things i learn her are some what a refresher.
sleh
@MarlboroGrammer
Mar 30 2016 00:54
should focus more on jquery
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:54
Here*
PHPman
@dmitrikonnikov
Mar 30 2016 00:54
i always hear i should learn the jquery library
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:55
@MarlboroGrammer its quintessential to programming fundamentals.
But I agree there should be more jQuery.
Chris Dalton
@manwithgills
Mar 30 2016 00:56
@moigithub Are you able to assist me with another bonfire?
Elbert Cortez
@trip16661
Mar 30 2016 00:56
Guys i have almost everything done but it still don't work with one parameter
sleh
@MarlboroGrammer
Mar 30 2016 00:56
function rot13(str) { // LBH QVQ VG!
var aux = '';
var array = Array.prototype.slice.call(str);
for(var i = 0 ; i < array.length; i++){
if(array[i]!==' '){
aux = str.charCodeAt(i);
array[i] = String.fromCharCode(aux-13);
}
}
str = array.join('');
return str;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
can anyone help me with this?
Vik
@vvang044
Mar 30 2016 00:56
whatever you do....do not stop.....keep the momentum.....i was away for three weeks.....feels like i missed out a lot
Elbert Cortez
@trip16661
Mar 30 2016 00:57
function mutation(arr) {

var randomVar = arr[1].toUpperCase().split("");
var theCheckingOne = arr[0].toUpperCase();
var checking = 0;

for (var a = 0; (a < randomVar.length) && (checking = -1); a++){
checking = theCheckingOne.indexOf(randomVar[a]);

}
if(checking >= 0){
return true;
}else{

return false;
}

}

mutation(["hello", "hey"]);
does anyone knows?
acording to the chalenge everything is correct except for
greg
@wearenotgroot
Mar 30 2016 00:57
@MarlboroGrammer why are you slicing the argument?
Jesus Arteaga
@HecticHiccups
Mar 30 2016 00:57
@vvang044 consistency is key.
sleh
@MarlboroGrammer
Mar 30 2016 00:57
@wearenotgroot i am not, i am turning str into an array because it's read only
Elbert Cortez
@trip16661
Mar 30 2016 00:57
"hello", "neo" arguments not returning to false
greg
@wearenotgroot
Mar 30 2016 00:57
@MarlboroGrammer just use split
Micah Bales
@micahbales
Mar 30 2016 00:58
Hello! I'm working on the "Search and Replace" algorithm challenge, and I'm a little stuck. Any ideas?
Here's my code:
function myReplace(str, before, after) {
if (before.charAt(0) === before.charAt(0).toUpperCase) {
return str.replace(before, after.charAt(0).toUpperCase + after.substring(1));
} else {
return str.replace(before, after);
}

}

myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
Brandon Lee
@brandonlee781
Mar 30 2016 00:58
So I have an interesting problem, that's sort of related to Javascript. I'm in the middle of the fibonnaci challenge, but it seems I've programmed an infinite loop, which also seems to be eternally tied to my account because every time the page loads it runs the script again and the tab locks up and I'm unable to do anything. Any thoughts on how to fix this?
Micah Bales
@micahbales
Mar 30 2016 00:59
@brandonlee781 Are you willing to start over?
Brandon Lee
@brandonlee781
Mar 30 2016 00:59
From the beginning of the challenge? SUre
Jesus Arteaga
@HecticHiccups
Mar 30 2016 01:00
Micah Bales
@micahbales
Mar 30 2016 01:00
@brandonlee781 OK, then just go to the original address of the challenge (not the address that contains your answer), and start over. The first time you run your code, it will write over your old code.
@brandonlee781 Does that make sense?
The way FCC stores your answer is in a super-long URL. If you go to the original URL, you won't see your saved code.
Brandon Lee
@brandonlee781
Mar 30 2016 01:01
@micahbales I understand what you mean, but all I'm entering is freecodecamp.com. So is my browser hiding the rest of the url?
sleh
@MarlboroGrammer
Mar 30 2016 01:01
nned
heeeelp
Micah Bales
@micahbales
Mar 30 2016 01:03
@brandonlee781 It shouldn't be. Try manually typing in the address and see what happens.
Chris
@MrChristofferson
Mar 30 2016 01:03
@MarlboroGrammer What's up?
Micah Bales
@micahbales
Mar 30 2016 01:03
@brandonlee781 Oh, wait, you mean you're getting an infinite loop on the home page??
Brandon Lee
@brandonlee781
Mar 30 2016 01:04
@micahbales Yeah. Like I go to freecodecamp.com, it immediately loads up the last challenge I was working on, and about a second after the page begins to load it locks up and I'm unable to do anything with it.
Micah Bales
@micahbales
Mar 30 2016 01:04
Ok, but it shows a URL that is longer at that point, right?
Brandon Lee
@brandonlee781
Mar 30 2016 01:05
My old code is still there.
sleh
@MarlboroGrammer
Mar 30 2016 01:05
@MrChristofferson  
@MrChristofferson
@MrChristofferson
function rot13(str) { // LBH QVQ VG!
var aux = '';
var array = str.split('');
for(var i = 0 ; i < array.length; i++){
if(array[i]!==' '){
aux = str.charCodeAt(i);
array[i] = String.fromCharCode(aux-13);
}
}
return array.join('');
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Micah Bales
@micahbales
Mar 30 2016 01:05
@brandonlee781 Have you tried logging out, going to the page, and then logging in?
samamsam
@samsamam
Mar 30 2016 01:06
hi @Takumar i got the below but it still is not working
//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUp(firstName, prop)
{
// Only change code below this line
var x;
var y;
var z  = false;

for(x = 0;x < 4;x++)
{

for(y in contacts)
{

if((firstName === contacts[x].firstName) && (prop === y[x]))

{
return contacts.y;
}

if(prop !== y[x])
{
return "No such property";
}

if(firstName !== contacts[x].firstName)
{
z = true;
}
}

}

if(z)
{
return "No such contact";
}

// Only change code above this line

}

// Change these values to test your function
lookUp("Akira", "likes");
Micah Bales
@micahbales
Mar 30 2016 01:06
@brandonlee781 I don't understand why your code would show without the lengthier URL.
Brandon Lee
@brandonlee781
Mar 30 2016 01:06
@micahbales Me neither, in fact I just logged out and the code is still there causing issues.
I cleared my cache, I've restarted and turned off everything multiple times. No luck.
Micah Bales
@micahbales
Mar 30 2016 01:07
@brandonlee781 Now that is bizarre. And I was just about to recommend clearing cache...
different browser?
Erik Villoria
@kire73
Mar 30 2016 01:08
function findLongestWord(str) {
var exp = str.split(" ");
var holder = str.split(" ");
var word = 0;
var length = 0;
var nextword = 0;
var nextlength = 0;

for ( i=0; i < holder.length; i++) {
word = exp[i];
length = word.length;
nextword = exp[i+1];
nextlength = nextword.length;
if (length < nextlength) {
delete exp[i];
} else if (length > nextlength) {
delete exp[i+1];
}
}

return exp;
}
says : Cannot read property 'length' of undefined,
but I can't tell which length is undefined or why
Brandon Lee
@brandonlee781
Mar 30 2016 01:08
@micahbales Unfortunately I'm on a chromebook, so my options are limited. Maybe it's cookie issue? Let me clear those really quick.
Micah Bales
@micahbales
Mar 30 2016 01:08
@brandonlee781 That might be it.
sleh
@MarlboroGrammer
Mar 30 2016 01:08
HELP
CamperBot
@camperbot
Mar 30 2016 01:08

### Basic Commands:

• find TOPIC find all entries about topic. ex: find js
• wiki TOPIC show contents of topic page
• thanks @username send brownie points to another user
• about @username shows info on that user
• Algorithm BONFIRENAME info on a Algorithm

:speech_balloon: meet CamperBot in this room!

Brandon Lee
@brandonlee781
Mar 30 2016 01:09
@micahbales That did the trick. Thanks for helping me through that!
CamperBot
@camperbot
Mar 30 2016 01:09
brandonlee781 sends brownie points to @micahbales :sparkles: :thumbsup: :sparkles:
:star: 362 | @micahbales | http://www.freecodecamp.com/micahbales
Micah Bales
@micahbales
Mar 30 2016 01:09
@brandonlee781 No worries. Glad to help! :)
nothing worse than an infinite loop!
sleh
@MarlboroGrammer
Mar 30 2016 01:10
help caesar
CamperBot
@camperbot
Mar 30 2016 01:10

## :point_right: algorithm caesars cipher [wiki]

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program. :busts_in_silhouette: Write your own code. :memo:

# :checkered_flag: Problem Explanation:

• You need to write a function, which will take string encoded with
Caesar cipher as a parameter and decode it.
• The one used here is ROT13 where the value of the letter is
shifted by 13 places.
e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
• You have to shift it back 13 positions, such that 'N' ↔ 'A'.
Brandon Lee
@brandonlee781
Mar 30 2016 01:10
Well, having to sign in to ALL of my accounts again might be slightly worse...let's say it's a tie.
samamsam
@samsamam
Mar 30 2016 01:12
hi coders i have got this code but for some reason it is not working help is appreciated thanks
//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUp(firstName, prop)
{
// Only change code below this line
if(firstName === contacts.firstName && prop === contacts[prop])

{
return firstName;
}
if (firstName != contacts.firstName)
{
return ("No such contacts");
}
if(prop !== contacts[prop])
{
return "No such property";
}
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUp(firstName, prop)
{
// Only change code below this line
var x;
var y;
var z  = false;

for(x = 0;x < 4;x++)
{

for(y in contacts)
{

if((firstName === contacts[x].firstName) && (prop === y[x]))

{
return contacts.y;
}

if(prop !== y[x])
{
return "No such property";
}

if(firstName !== contacts[x].firstName)
{
z = true;
}
}

}

if(z)
{
return "No such contact";
}

// Only change code above this line

}

// Change these values to test your function
lookUp("Akira", "likes");
Erik Villoria
@kire73
Mar 30 2016 01:15
@samsamam first, take out all the extra white space so you don't have to scroll so much to see your code. second, don't show us the whole thing, only what you're having trouble with. third, tell us what youre having trouble with
Micah Bales
@micahbales
Mar 30 2016 01:19
Howdy folks. I'm working on the "Search and Replace" challenge, and I'm a little stuck. Can you help? Here's my code:
function myReplace(str, before, after) {

strArr = str.split(' ');
for (i = 0; i < strArr.length; i += 1) {
if (strArr[i] === before) {
strArr.splice(i, 1, after);
}
}

str = strArr.join(' ');

return str;

}

myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
samamsam
@samsamam
Mar 30 2016 01:19
@kire73 Iam having trouble with the logic of this part of the code in this section of the code
for(x = 0;x < 4;x++)
{

for(y in contacts)
{

if((firstName === contacts[x].firstName) && (prop === y[x]))

{
return contacts.y;
}

if(prop !== y[x])
{
return "No such property";
}

if(firstName !== contacts[x].firstName)
{
z = true;
}
}
@kire73 y[x] should give the property itself ? and contacts.y should give the value of property y ?
Elbert Cortez
@trip16661
Mar 30 2016 01:22
function mutation(arr) {

var randomVar = arr[1].toUpperCase().split("");
var theCheckingOne = arr[0].toUpperCase();
var checking = 0;

for (var a = 0; (a < randomVar.length) && (checking = -1); a++){
checking = theCheckingOne.indexOf(randomVar[a]);

}
if(checking >= 0){
return true;
}else{

return false;
}

}

mutation(["hello", "hey"]);
can i have a little help?
everything matches excepts for "mutation(["hello", "neo"]) should return false."
Elbert Cortez
@trip16661
Mar 30 2016 01:30
can i get a bit of help?
Erik Villoria
@kire73
Mar 30 2016 01:30
@samsamam Honestly I am not the best person to ask but i will try. I solved this problem in a completely different way earlier.
samamsam
@samsamam
Mar 30 2016 01:31
@kire73 sure
Micah Bales
@micahbales
Mar 30 2016 01:31
Hello! I'm working on the Search and Replace algorithm challenge and I'm feeling a bit stuck. It's easy enough to replace "before" with "after" (str.replace(before,after);), but I can't figure out how to deal with the capitalization issues. Is there an obvious solution to this I'm missing? Do I need to use regex? Here's the original challenge page: https://www.freecodecamp.com/challenges/search-and-replace
Nicolas May
@hynso
Mar 30 2016 01:31
How do you disable some the FCC tests? I'm trying to debug an algorithm that requires recursion and I can't see the test cases that are most useful...
Erik Villoria
@kire73
Mar 30 2016 01:35
@samsamam what kind of error are you getting? im not sure about the usage of in as a condition in your for statement
samamsam
@samsamam
Mar 30 2016 01:37
@kire73 im getting the output No such property
@kire73 and there is crosses in all of the below
"Kristian", "lastName" should return "Vos"
"Sherlock", "likes" should return ["Intriguing Cases", "Violin"]
"Harry","likes" should return an array
"Bob", "number" should return "No such contact"
@kire73 its the profile lookup exercise in Code Camp
Lawrence Eagles
@lawrenceagles
Mar 30 2016 01:38

Hello guys, please I need help with the record collection exercise: Here is my code. function update(id, prop, value) {

if(value !== "" & prop !== "tracks"){
collection.id[value] = prop;
} else if ( prop === "tracks" & value !== "") {
collection[id].tracks.push(value);
} else{
if(value === ""){
var assign = value;
delete collection[assign];
}
}

Vik
@vvang044
Mar 30 2016 01:41
@lawrenceagles why dont you just write two if statements and else.....which will be easier than if, else if......
try it on a piece of paper
Elbert Cortez
@trip16661
Mar 30 2016 01:42
function mutation(arr) {

var randomVar = arr[1].toUpperCase().split("");
var theCheckingOne = arr[0].toUpperCase();
var checking = 0;

for (var a = 0; (a < randomVar.length) && (checking = -1); a++){
checking = theCheckingOne.indexOf(randomVar[a]);

}
if(checking >= 0){
return true;
}else{

return false;
}

}

mutation(["hello", "hey"]);
can i get some help?
Erik Villoria
@kire73
Mar 30 2016 01:46
@samsamam I only used one variable to increment through the index. instead of declaring y or z, use hasOwnProp() to check each object for its properties, and return the values of true or false
also, keep in mind that if using a for statement, when you return it will end the loop. try using a while statement so it will increment through each object, then return with an if statement
Zabe Sangary
@zabesangary
Mar 30 2016 01:50
website is offline?
Vik
@vvang044
Mar 30 2016 01:50
super slow
Zabe Sangary
@zabesangary
Mar 30 2016 01:51
can't get it
ah now is okay
Erik Villoria
@kire73
Mar 30 2016 01:55
how can i delete from an array and also update its length and such. I want to be able to access array[ i + 1 ] in a loop after deleting an item from the array, which is sometimes i + 1
samamsam
@samsamam
Mar 30 2016 01:57
@kire73 but how can i output the values when I am returning true or false because in the question it says to output the values
Erik Villoria
@kire73
Mar 30 2016 01:59
if ( contacts[i].hasOwnProperty(prop) ) {
return contacts[i][prop];
} else return "No such property";
where i is your variable that increments
you ditch dot notation when using consecutive variables to access array indexes. brackets only @samsamam
Rahul Nayak
@pragyes31
Mar 30 2016 02:05
Hello People
Moisés Man
@moigithub
Mar 30 2016 02:05
@trip16661
&& (checking = -1); comparation symbol == or ===
1 = means assigment
Rahul Nayak
@pragyes31
Mar 30 2016 02:05
for the palindrome bonfire assigment, i cleared all test cases but one
one of the test cases says : "palindrome("1 eye for of 1 eye.") should return false."
it should return true right?
Moisés Man
@moigithub
Mar 30 2016 02:07
no.. false is ok
cuz the number
Vik
@vvang044
Mar 30 2016 02:09
 function truncate(str, num) {

if (str.length <= num){
return str;
}
if (num <= 3){
return str.substring(0,num) + "...";
}
return str.substring(0,num-3) + "...";
}
}
why is my code not working
Rahul Nayak
@pragyes31
Mar 30 2016 02:09
i have removed all non alpha numeic character using regex. That's what the problem statement says @moigithub
Moisés Man
@moigithub
Mar 30 2016 02:10
welll if u removed the numbers u did wrong.. cuz its part of "alpha + numeric"
Rahul Nayak
@pragyes31
Mar 30 2016 02:11
ohh shit!! thank you @moigithub
CamperBot
@camperbot
Mar 30 2016 02:11
pragyes31 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
Rahul Nayak
@pragyes31
Mar 30 2016 02:11
got it now
CamperBot
@camperbot
Mar 30 2016 02:11
:star: 796 | @moigithub | http://www.freecodecamp.com/moigithub
Eric Murta
@murtinha
Mar 30 2016 02:11
guys whats an enumerable object? and how this object.keys works?
Vik
@vvang044
Mar 30 2016 02:12
@murtinha ^^^ can you check why my code isnt working?
@moigithub i meant
Kyle Morton
@kmorton1988
Mar 30 2016 02:14
@vvang044 shouldn't it be the substr() method?
Vik
@vvang044
Mar 30 2016 02:17
yes
but i am telling where to start and end
Elbert Cortez
@trip16661
Mar 30 2016 02:19
function mutation(arr) {

var randomVar = arr[1].toUpperCase().split("");
var theCheckingOne = arr[0].toUpperCase();
var checking = 0;

for (var a = 0; (a < randomVar.length) && (checking = -1); a++){
checking = theCheckingOne.indexOf(randomVar[a]);

}
if(checking >= 0){
return true;
}else{

return false;
}

}

mutation(["hello", "hey"]);
can anyone help me? D:
samamsam
@samsamam
Mar 30 2016 02:21

@kire73 im getting weird error
this code is not working

if(firstName !== contacts[x].firstName)
{
z = true;
}
x = x = 1;
}

 if(z)
{
return "No such contact";
} 

 to return no such contact also it satisfies this
"Harry","likes" should return an array but not the other conditions

@kire73
 if(firstName !== contacts[x].firstName)
{
z = true;
}
x = x = 1;
}

if(z)
{
return "No such contact";
}
Daniel Dwyer
@DanielDwyer
Mar 30 2016 02:22
I need help please! I tried to write a JavaScript love letter to my gf, but it is not working at all. Here is the link: http://jsbin.com/munucu/edit?js,console,output Please Help! I want to give it to her tonight.
Edgar Sánchez
@garosan
Mar 30 2016 02:26
Hi guys! I'm a Little bit stucked on the 'Stand in line' challenge...
Ramana Venkata
@vramana
Mar 30 2016 02:33
@pmacodekid What have you tried so far??
Vik
@vvang044
Mar 30 2016 02:37
Edgar Sánchez
@garosan
Mar 30 2016 02:37
@vramana Hi, well first of all I tried to follow the instructions one by one:
So, the instructions are: Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed.

My code is as follows

function queue(arr, item) {
testArr.push(item);
var removed = testArr.shift();

return removed; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

Elbert Cortez
@trip16661
Mar 30 2016 02:39
function mutation(arr) {

var randomVar = arr[1].toUpperCase().split("");
var theCheckingOne = arr[0].toUpperCase();
var checking = 0;

for (var a = 0; (a < randomVar.length) && (checking = -1); a++){
checking = theCheckingOne.indexOf(randomVar[a]);

}
if(checking >= 0){
return true;
}else{

return false;
}

}

mutation(["hello", "hey"]);
D:
Edgar Sánchez
@garosan
Mar 30 2016 02:39
I'm really sorry I don't find a way to format the code, I'm at a very old and restrictive computer at work :(
Elbert Cortez
@trip16661
Mar 30 2016 02:40
js
and at the end of your code 
after js shift + enter then your code
Edgar Sánchez
@garosan
Mar 30 2016 02:40
@trip16661 thnxs
CamperBot
@camperbot
Mar 30 2016 02:40
pmacodekid sends brownie points to @trip16661 :sparkles: :thumbsup: :sparkles:
:star: 259 | @trip16661 | http://www.freecodecamp.com/trip16661
Elbert Cortez
@trip16661
Mar 30 2016 02:41
control enter to send it
once you are really done
Vik
@vvang044
Mar 30 2016 02:42
well all re new and old when it comes to coding....so welcome to the club @pmacodekid
Erik Villoria
@kire73
Mar 30 2016 02:43
@samsamam you need a condition for your if statement. z isnt enough
Vik
@vvang044
Mar 30 2016 02:43
help truncate a string
CamperBot
@camperbot
Mar 30 2016 02:43

# Explanation:

We need to reduce the length of the string or truncate it if it is longer than the given maximum lengths specified and add ... to the end. If it is not that long then we keep it as is.

escapeplan4
@escapeplan4
Mar 30 2016 02:44
what's wrong with this code?
Edgar Sánchez
@garosan
Mar 30 2016 02:46
Thanxs vvang044
Elbert Cortez
@trip16661
Mar 30 2016 02:46
function mutation(arr) {

var randomVar = arr[1].toUpperCase().split("");
var theCheckingOne = arr[0].toUpperCase();
var checking = 0;

for (var a = 0; (a < randomVar.length) && (checking = -1); a++){
checking = theCheckingOne.indexOf(randomVar[a]);

}
if(checking >= 0){
return true;
}else{

return false;
}

}

mutation(["hello", "hey"]);
I can seem to make it work
i trully don't know what im doing wrong
DJ
@qualitymanifest
Mar 30 2016 02:51
@trip16661 think about what you're doing with checking
checking = theCheckingOne.indexOf(randomVar[a]); here, checking changes with each part of the loop
but you need to see if each part of randomVar is present in theCheckingOne
so you need a counter variable
and after the for loop is done, see if the counter variable is equal to the length of the second string
Vik
@vvang044
Mar 30 2016 02:54
@escapeplan4 paste your code with 3 of these and with 3 of these ....paste your code inbetween
DJ
@qualitymanifest
Mar 30 2016 02:54
at least, that's my impression from a quick look at the code. let me test it out
Vik
@vvang044
Mar 30 2016 02:54
"'
Edgar Sánchez
@garosan
Mar 30 2016 02:55
function queue(arr, item) {
testArr.push(item);
var removed = testArr.shift();

return removed;  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
DJ
@qualitymanifest
Mar 30 2016 02:56
@trip16661 yeah. so here's your only failing test. https://repl.it/CAce i just put a console.log for checking. hit the run button. it's -1 the first time around, because 'n' isn't in 'hello'. but it's >=0 at the end, because 'o' is the last part of the loop and that is present in "hello"
Elbert Cortez
@trip16661
Mar 30 2016 02:57
but shouldn't t return false
if it´s -1
and stop the loop
escapeplan4
@escapeplan4
Mar 30 2016 02:59
This message was deleted
@vvang044 what should I do I don't get it?
abtak mustapha
@mustapha88
Mar 30 2016 03:01
@vvang044
ttry this mybye help yu

function truncateString(str, num) {
if(num <= 3){
str = str.slice(0, num);
str += "...";

}

else if(str.length > num){
str = str.slice(0,num-3);
str += "...";
}

return str;

}

Vik
@vvang044
Mar 30 2016 03:02
nice to see another code....apart from mine
abtak mustapha
@mustapha88
Mar 30 2016 03:03
yu try it
Vik
@vvang044
Mar 30 2016 03:03
i did this
abtak mustapha
@mustapha88
Mar 30 2016 03:03
help to understand
CamperBot
@camperbot
Mar 30 2016 03:03
no wiki entry for: to understand
abtak mustapha
@mustapha88
Mar 30 2016 03:03
just refresh the page
Vik
@vvang044
Mar 30 2016 03:04
unction truncateString(str, num) {
// Clear out that junk in your trunk

if (str.length <= num){

return str;
}

if (num <= 3){

return str.substring(0,num) + "...";
}

return str.substring(0,num-3) + "...";

}
i did....instead of if, else if....i used two if statements
DJ
@qualitymanifest
Mar 30 2016 03:04
@trip16661 yes - that makes sense. but that's your code that i put in the link there, and you're not returning false inside the loop, so the loop runs the whole way through and your if/else statement is only comparing the last part of the loop
if any part of arr[0].indexOf(arr[1][i]) returns -1 (substitute your variable names for arr[0] and arr[1] there), you should return false then, inside the loop. if the loop makes it all the way through, you can return true since that means that all parts of the second string are in the first string
Edgar Sánchez
@garosan
Mar 30 2016 03:09
Guys, I found the problem, I was understanding I had to push and remove from testArr, instead of from arr.
https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Checkpoint-Stand-In-Line This document explained it all, this FreeCodeCamp thing keeps getting sweeter!!! :smile: :clap:
Joshua
@joshuaken
Mar 30 2016 03:13
hello
Ollie
@ogough
Mar 30 2016 03:19

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i < arr.length; i++) {
for (var j=0; j < arr[i].lenth; j++) {
product *= arr[i][j];
}
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Why is this wrong
??
Coy Sanders
@coymeetsworld
Mar 30 2016 03:20
length is spelled wrong @ogough
in 2nd for loop
Nicole S.
@nicolesteck
Mar 30 2016 03:21

What is going wrong here?

function myTest(val) {
// Only change code below this line
switch (val) {
case"a":
break;
case"b":
break;
case"c":
break;
default:
break;
}

// Only change code above this line
}

// Change this value to test
myTest(a);

escapeplan4
@escapeplan4
Mar 30 2016 03:21
@pmacodekid why you post it ? is there an error in the code? i tried use it with splice() but it didn't worked out just shift made it
Nicole S.
@nicolesteck
Mar 30 2016 03:21
I'm receiving the error "ReferenceError: a is not defined"
Coy Sanders
@coymeetsworld
Mar 30 2016 03:22
@nicolesteck you need to put a in quotes
or else its going to think its a variable, and since you didn't define it you get that error
Nicole S.
@nicolesteck
Mar 30 2016 03:23
Every time, it's something super-simple with the syntax. Thank you @coymeetsworld !
CamperBot
@camperbot
Mar 30 2016 03:23
nicolesteck sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 424 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Mar 30 2016 03:23
:) @nicolesteck
Elbert Cortez
@trip16661
Mar 30 2016 03:26
@qualitymanifest thanks
DJ
@qualitymanifest
Mar 30 2016 03:26
@trip16661 yw
Trilok reddy
@Trilokreddy007
Mar 30 2016 03:42
has anyone solved Local Scope and Functions ?
NormalWare
@Centuriom
Mar 30 2016 03:44
This message was deleted
$.getJSON("api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}"); Is this the correct way to call that API ? DJ @qualitymanifest Mar 30 2016 03:53 @Centuriom are lat and lon variables you have? NormalWare @Centuriom Mar 30 2016 03:53 Yes Matt Green @mattxgreen Mar 30 2016 03:54 @Centuriom you'll need to concatenate the lat/lon vars, and assign a callback DJ @qualitymanifest Mar 30 2016 03:54 really, best thing to do would be to paste a link to your codepen so we can see what's going on. but i'm assuming that those are variables. in which case the way to do it would be 'url.com/stuff' + variable + 'more URL stuff' + variable + 'end of URL' Eric Murta @murtinha Mar 30 2016 03:54 function where(collection, source) { var arr = []; // What's in a name? collection.filter(function(value){ var count=0; if(value.hasOwnProperty(Object.keys(source))&& value[Object.keys(source)]==source[[Object.keys(source)]]){ arr[count]=value; count++; } }); return arr; } where([{ "a": 1 }, { "a": 1 }, { "a": 1, "b": 2 }], { "a": 1 }) why my code is only displaying { "a": 1, "b": 2 } ? DJ @qualitymanifest Mar 30 2016 03:55 mattxgreen's advice is solid too Matt Green @mattxgreen Mar 30 2016 03:56 @Centuriom it'll look like this (ish): $.getJSON("api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+lon, function(dataReturned){
//do stuff
});
DJ
@qualitymanifest
Mar 30 2016 03:58
pretty sure the end of your URL will need to include &callback=?
Rex Smith Jr.
@rsmith731
Mar 30 2016 03:59
can anyone help me with the “Stand In Line” exercise?
DJ
@qualitymanifest
Mar 30 2016 04:00
Rex Smith Jr.
@rsmith731
Mar 30 2016 04:00
function queue(arr, item) {

return item;  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
@qualitymanifest not really sure what its asking me to do
DJ
@qualitymanifest
Mar 30 2016 04:01
@rsmith731 you need to add item onto the end of arr and return the first part of arr, right?
NormalWare
@Centuriom
Mar 30 2016 04:01
@mattxgreen @qualitymanifest Thanks !
CamperBot
@camperbot
Mar 30 2016 04:01
centuriom sends brownie points to @mattxgreen and @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1125 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
:star: 414 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
V Arun Kumar
@arunvkumr
Mar 30 2016 04:01
@rsmith731 you need to insert an element at the end of arr and remove the first elem of array and return the removed value..
escapeplan4
@escapeplan4
Mar 30 2016 04:02
@rsmith731 use shifit and push method
Rex Smith Jr.
@rsmith731
Mar 30 2016 04:02
@qualitymanifest yes
DJ
@qualitymanifest
Mar 30 2016 04:03
@rsmith731 so, you push item into arr, and return arr.shift
Erik Villoria
@kire73
Mar 30 2016 04:03
trying to use shift and its giving typeerror ....shift is not a function?
DJ
@qualitymanifest
Mar 30 2016 04:03
Eric Murta
@murtinha
Mar 30 2016 04:03
function where(collection, source) {
var arr = [];
// What's in a name?

collection.filter(function(value){
var count=0;
if(value.hasOwnProperty(Object.keys(source))&& value[Object.keys(source)]==source[[Object.keys(source)]]){
arr[count]=value;
count++;
}

});

return arr;

}
where([{ "a": 1 }, { "a": 1 }, { "a": 1, "b": 2 }], { "a": 1 })
why my code is only displaying { "a": 1, "b": 2 } ?
Rex Smith Jr.
@rsmith731
Mar 30 2016 04:03
@arunkumrv @qualitymanifest thanks!!!
CamperBot
@camperbot
Mar 30 2016 04:03
rsmith731 sends brownie points to @arunkumrv and @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1126 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
:star: 406 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Erik Villoria
@kire73
Mar 30 2016 04:03
function titleCase(str) {

str = str.split(" ");

for (i = 2; i < str.length; i++) {
var word = str[i];
var letter = word[0];
letter = letter.toUpperCase();
word.shift();
word.unshift(letter);
str[i] = word;
return str[i];
}

str = str.join(" ");
return str;
}
DJ
@qualitymanifest
Mar 30 2016 04:05
@kire73 after you split it, str is still an array of strings. shift and unshift are methods used on arrays, which won't work on strings since they're immutable
V Arun Kumar
@arunvkumr
Mar 30 2016 04:05
@kire73 shift works with array not with strings... to use shift with strings, convert string into array and then join it back.
Erik Villoria
@kire73
Mar 30 2016 04:05
@qualitymanifest @arunkumrv thank you makes sense
CamperBot
@camperbot
Mar 30 2016 04:05
kire73 sends brownie points to @qualitymanifest and @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 1127 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
:star: 407 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Ulises Rangel
@urangel
Mar 30 2016 04:06
@kire73 you need to create your i variable for (var i = 2; etc...
Erik Villoria
@kire73
Mar 30 2016 04:07
I've had some confusion with converting types in java, any good references?
@urangel just using that value to test
Emil Aasa
@emilaasa
Mar 30 2016 04:07
If anyone has questions on scope, closures or the this keyword today I’ll be happy to answer, it will help me cement a course I’m working thru now.
Eric Murta
@murtinha
Mar 30 2016 04:08
function where(collection, source) {
var arr = [];
// What's in a name?

collection.filter(function(value){
var count=0;
if(value.hasOwnProperty(Object.keys(source))&& value[Object.keys(source)]==source[[Object.keys(source)]]){
arr[count]=value;
count++;
}

});

return arr;

}
where([{ "a": 1 }, { "a": 1 }, { "a": 1, "b": 2 }], { "a": 1 })
why my code is only displaying { "a": 1, "b": 2 } ?
Emil Aasa
@emilaasa
Mar 30 2016 04:09
V Arun Kumar
@arunvkumr
Mar 30 2016 04:09
@kire73 check out, split and join functions.. the split function works on strings and returns a array of letters if you specify the breaker(delimiter) as "". and join function joins the array of letters into string.. both the function needs delimiter, which tells the function from where to seperate the words.
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/split
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join
Erik Villoria
@kire73
Mar 30 2016 04:11
@arunkumrv yeah I got it!
@emilaasa started learning in C so not used to not having to convert types like string int and char, sometimes i forget about having to convert to arrays
Emil Aasa
@emilaasa
Mar 30 2016 04:11
ah you mean javascript
Erik Villoria
@kire73
Mar 30 2016 04:11
yup
Emil Aasa
@emilaasa
Mar 30 2016 04:12
Jesus Arteaga
@HecticHiccups
Mar 30 2016 04:13
CamperBot
@camperbot
Mar 30 2016 04:13
:star: 324 | @emilaasa | http://www.freecodecamp.com/emilaasa
Emil Aasa
@emilaasa
Mar 30 2016 04:13
@kire73 on that site you can read about data type conversion in javascript
Erik Villoria
@kire73
Mar 30 2016 04:14
@arunkumrv @emilaasa thank you!
CamperBot
@camperbot
Mar 30 2016 04:14
kire73 sends brownie points to @emilaasa :sparkles: :thumbsup: :sparkles:
:star: 325 | @emilaasa | http://www.freecodecamp.com/emilaasa
Emil Aasa
@emilaasa
Mar 30 2016 04:14
But it’s pretty much automatic =)
NormalWare
@Centuriom
Mar 30 2016 04:14
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {

var lat = position.coords.latitude;
var lon = position.coords.longitude;

$.getJSON("api.openweathermap.org/data/2.5/weather?lat={"+lat+"}&lon={"+lon+"}",function(json){$("#data").html(json);

});

});

}
What's wrong with the code ?
Emil Aasa
@emilaasa
Mar 30 2016 04:14
If you would like some types there’s always http://www.typescriptlang.org/
V Arun Kumar
@arunvkumr
Mar 30 2016 04:15
DJ
@qualitymanifest
Mar 30 2016 04:15
@Centuriom paste the link to your codepen... always more useful than pasting code snippets. but your getJSON url is still messed up
you don't need the {} around the variables
and i think you need an API key
NormalWare
@Centuriom
Mar 30 2016 04:16
DJ
@qualitymanifest
Mar 30 2016 04:16
NormalWare
@Centuriom
Mar 30 2016 04:18
Kyle Morton
@kmorton1988
Mar 30 2016 04:18
@Centuriom You don't use the {} brackets in the lat and lon entries. you forgo them when using the actual latitude and logitute. should just be "lat=21&lon=173"
NormalWare
@Centuriom
Mar 30 2016 04:18
That's some high tech stuff right there
@kmorton1988 I changed that =D
Kyle Morton
@kmorton1988
Mar 30 2016 04:19
@Centuriom yeah, I'm working on the same task. I've been trying to wrap my head around API calls and storing json data for a week.
lol.
V Arun Kumar
@arunvkumr
Mar 30 2016 04:19
@Centuriom and you need API key to access the weather object.. register in openweathermap it's free and they will give you the API key(APP id).
NormalWare
@Centuriom
Mar 30 2016 04:20
@kmorton1988 haha dude don't scare me
@arunkumrv I need to include the API key in my code ?
Kyle Morton
@kmorton1988
Mar 30 2016 04:20
yeah, it'd be used by appending &appid=LONGASSCODEHERE
V Arun Kumar
@arunvkumr
Mar 30 2016 04:20
@Centuriom yes.. without that i don't think it would work.
DJ
@qualitymanifest
Mar 30 2016 04:21
@Centuriom it's not too complicated, just sign up, get your free API key, and add &APPID=yourKeyNumber to the end of the URL
Nicole S.
@nicolesteck
Mar 30 2016 04:21
Hi all, not looking for the answer but rather for some help with how to go about figuring out the answer to this myself...
Kyle Morton
@kmorton1988
Mar 30 2016 04:21
hmm. I think I might have to parseInt() on the longitude and latitude to use that method...
NormalWare
@Centuriom
Mar 30 2016 04:22
@qualitymanifest Thanks i'll do that
CamperBot
@camperbot
Mar 30 2016 04:22
centuriom sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:warning: centuriom already gave qualitymanifest points
V Arun Kumar
@arunvkumr
Mar 30 2016 04:22
After adding API key(appid) it looks something like..
http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + long + &appid=971b9e5s4f98f81b886fbandk72632d92
DJ
@qualitymanifest
Mar 30 2016 04:22
@kmorton1988 nah you don't have to round it
Kyle Morton
@kmorton1988
Mar 30 2016 04:22
really?
Nicole S.
@nicolesteck
Mar 30 2016 04:22

In the Return Early Pattern for Functions waypoint (included below), I've tried a number of different methods and just have nowhere to start. Any hint or suggestion for where to start thinking about next steps would be appreciated!

When a return statement is reached, the execution of the current function stops and control returns to the calling location.

Example

function myFun() {
console.log("Hello");
return "World";
console.log("byebye")
}
myFun();
The above outputs "Hello" to the console, returns "World", but "byebye" is never output, because the function exits at the return statement.

Instructions
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.

Hint
Remember that undefined is a keyword, not a string.)

Kyle Morton
@kmorton1988
Mar 30 2016 04:23
you have to make it a string, @arunkumrv at the end there.
V Arun Kumar
@arunvkumr
Mar 30 2016 04:25
@kmorton1988 not necessarily.. the api key will be hardcoded in the code. you are not getting the key from some external source..
Kyle Morton
@kmorton1988
Mar 30 2016 04:25
@arunkumrv I know, but as you have it written, it's going to assume it's trying to find the value of a variable called &appid=971b9e5s4f98f81b886fbandk72632d92
you'd have to wrap that last bit in quotes just the same as the rest of the url bits that aren't assigned by variables.
V Arun Kumar
@arunvkumr
Mar 30 2016 04:26
@kmorton1988 i just copied the link.. i left out the starting and ending quote.
James Oakwood
@michaeljcaboose
Mar 30 2016 04:27
@nicolesteck so you want to check those values a,b right?
Nicole S.
@nicolesteck
Mar 30 2016 04:27
Correct
Kyle Morton
@kmorton1988
Mar 30 2016 04:27
ahh, i see, nvm.
V Arun Kumar
@arunvkumr
Mar 30 2016 04:27
"http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + long + "&appid=971b9e5s4f98f81b886fbandk72632d92"
@kmorton1988 thanks for point out. :grinning:
CamperBot
@camperbot
Mar 30 2016 04:27
arunkumrv sends brownie points to @kmorton1988 :sparkles: :thumbsup: :sparkles:
:star: 298 | @kmorton1988 | http://www.freecodecamp.com/kmorton1988
James Oakwood
@michaeljcaboose
Mar 30 2016 04:27
@nicolesteck have you used if statements yet?
Nicole S.
@nicolesteck
Mar 30 2016 04:28
Yep
Kyle Morton
@kmorton1988
Mar 30 2016 04:28
lol. no problem :P
Nicole S.
@nicolesteck
Mar 30 2016 04:28
If/else, if/else if,
and after those, switch
James Oakwood
@michaeljcaboose
Mar 30 2016 04:28
@nicolesteck there ya go. all you need is one if statement to check if either is less then 0
Nicole S.
@nicolesteck
Mar 30 2016 04:29
How do I get the data to show as undefined? Or "if-->return"?
James Oakwood
@michaeljcaboose
Mar 30 2016 04:29
so example: if(chicken === crossRoad){ return otherSide;}
Nicole S.
@nicolesteck
Mar 30 2016 04:29
Lol
Excellent thank you @michaeljcaboose
CamperBot
@camperbot
Mar 30 2016 04:29
nicolesteck sends brownie points to @michaeljcaboose :sparkles: :thumbsup: :sparkles:
:star: 279 | @michaeljcaboose | http://www.freecodecamp.com/michaeljcaboose
James Oakwood
@michaeljcaboose
Mar 30 2016 04:30
@nicolesteck so whenever the complier sees a return function, it will automatically exit that scope, in that case, the function abTest
@nicolesteck you're welcome!
V Arun Kumar
@arunvkumr
Mar 30 2016 04:30
@nicolesteck if you read the instructions once again..
Instructions
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
Kyle Morton
@kmorton1988
Mar 30 2016 04:33
oh ok.
Andrews
@frempongandrews
Mar 30 2016 04:33
Hi guys issue with the challenge "Title Case a Sentence"
V Arun Kumar
@arunvkumr
Mar 30 2016 04:34
Andrews
@frempongandrews
Mar 30 2016 04:35

 (shift+enter for line break)
function titleCase(str) {

     //string to lowercase
var low = str.toLowerCase();

//split words string

var words = low.split(" ");

//get length of string(words)

var len = words.length;

//iterate each word by using length in for loop

for (i = 0; i <= len-1; i++){
//getting first letter to uppercase
var firstLet = words[i].substring(0,1).toUpperCase();
//getting rest of letters
var rest = words[i].substring(1);
var sentence = firstLet + rest;
console.log(sentence);

}

return;

}

titleCase("I'm a little tea pot and I like dancing");



@arunkumrv posted. It returns the sentence with the first letter in uppercase however I can't understand why it doesn't pass the challenge.
Eric Murta
@murtinha
Mar 30 2016 04:37
function where(collection, source) {
var arr = [];
// What's in a name?

arr= collection.filter(function(value){

if(value.hasOwnProperty(Object.keys(source))){
return value[Object.keys(source)]==source[[Object.keys(source)]];
}

});

return arr;

}

where([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 }) ;
I'm on where art thou challenge and I'm having problems with hasOwnProperty, its not recognizing because object source has more then one property...
V Arun Kumar
@arunvkumr
Mar 30 2016 04:39
@frempongandrews you ae supposed to return a string with titlecase.. but your sentence value changes everytime in the iteration.
define sentence as empty string before for loop and inside loop. append sentence variable to every word and add a space after that.
Nicole S.
@nicolesteck
Mar 30 2016 04:40
welll.. @michaeljcaboose it's not working. The issue is, I think, with getting to Undefined instead of Null
Andrews
@frempongandrews
Mar 30 2016 04:41
@arunkumrv ehm I'm confused.
James Oakwood
@michaeljcaboose
Mar 30 2016 04:41
@nicolesteck you can just type undefined
undefined is it's own type of variable
so return undefined
V Arun Kumar
@arunvkumr
Mar 30 2016 04:41
something like..
var sentence = "";
for(i.....){
//some statements.
sentence = sentence + firstLet + rest + " ";// this can also be written as
//sentence += firstLet + rest + " ";
}
Nicole S.
@nicolesteck
Mar 30 2016 04:41

not working...

// Setup
function abTest(a, b) {
// Only change code below this line

if ("a"<0 || "b"<0) {
return undefined;

}

// Only change code above this line

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(2,-2);

James Oakwood
@michaeljcaboose
Mar 30 2016 04:42
@nicolesteck ah
if ("a"<0 || "b"<0) is where the issue is
remove the double quotes and it should run
Nicole S.
@nicolesteck
Mar 30 2016 04:43
OK, that worked (and thank you!), but now I'm really confused. Those are strings, aren't they?
James Oakwood
@michaeljcaboose
Mar 30 2016 04:44
@nicolesteck nope, those are variables. when you called abTest(2,-2); they were assigned into the function as a and b, respectivly
Nicole S.
@nicolesteck
Mar 30 2016 04:45
OK. So even with the FCC, I'm still confused -- anyone have additional resources they recommend? I've tried google, some youtube videos, online primers... suggested additional reading greatly appreciated! :)
James Oakwood
@michaeljcaboose
Mar 30 2016 04:46
what are you looking for specifically, just extra reference or something exact?
Nicole S.
@nicolesteck
Mar 30 2016 04:46
a general overview, since I don't feel like I'm gaining mastery of the material using just FCC.
V Arun Kumar
@arunvkumr
Mar 30 2016 04:46
@nicolesteck checkout jsforcats.com
goodm0urning
@goodm0urning
Mar 30 2016 04:47
Can someone help me with javascript? I'm supposed to create a variable 'fahrenheit' and assign it the corresponding temperature or something?

function convert(celsius) {
// Only change code below this line

// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

// Change the inputs below to test your code
convert(30);

function convert(celsius) {
// Only change code below this line

// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

// Change the inputs below to test your code
convert(30);
Andrews
@frempongandrews
Mar 30 2016 04:48
@arunkumrv okay. I've tried but apparently this returns on single word at every iteration.
goodm0urning
@goodm0urning
Mar 30 2016 04:48
I don't know how functions work, and it kind of just threw me into this
V Arun Kumar
@arunvkumr
Mar 30 2016 04:48
@frempongandrews repost your code. lets have a look
James Oakwood
@michaeljcaboose
Mar 30 2016 04:48
all freebees
V Arun Kumar
@arunvkumr
Mar 30 2016 04:50
@goodm0urning yes you need to create a variable Fahrenheit and then convert the Celsius passed to function into Fahrenheit, using formula
$Fahrenheit = Celsius * 9/5 + 32$.
goodm0urning
@goodm0urning
Mar 30 2016 04:51
so just like: var fahrenheit = celcius*9/5+32; ?
Andrews
@frempongandrews
Mar 30 2016 04:51

 (shift+enter for line break)
function titleCase(str) {

//string to lowercase
var low = str.toLowerCase();

//split words string

var words = low.split(" ");

//get length of string(words)

var len = words.length;

//iterate each word by using length in for loop
var sentence = "";

for (i = 0; i <= len-1; i++){
//getting first letter to uppercase
var firstLet = words[i].substring(0,1).toUpperCase();
//getting rest of letters
var rest = words[i].substring(1);
sentence = firstLet + rest + " ";
console.log(sentence);

}

return;

}

titleCase("I'm a little tea pot and I like dancing");


@arunkumrv done.
V Arun Kumar
@arunvkumr
Mar 30 2016 04:52
@frempongandrews :point_up: March 30, 2016 10:11 AM take a look at the sentence variable inside
Andrews
@frempongandrews
Mar 30 2016 04:53
OPS! wait let me see
@arunkumrv OPS! wait let me see
V Arun Kumar
@arunvkumr
Mar 30 2016 04:55
you need to concatenate.. the current word with the previous word
@frempongandrews for that you can use either
sentence = sentence + firstLet + rest + " "; //<- here + is importat to do the concatenation.
or
sentence += firstLet + rest + " "; //<- this is short form of the above line. :point_up_2:
Andrews
@frempongandrews
Mar 30 2016 05:00
@arunkumrv yeah just corrected. This was sooooo subtle. I'll need to go over it again. Thank you, really appreciated!
CamperBot
@camperbot
Mar 30 2016 05:00
frempongandrews sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 408 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
goodm0urning
@goodm0urning
Mar 30 2016 05:02
Anyone care to help me tackle this fahrenheit thing?
Alex Rose
@thelyricalrose
Mar 30 2016 05:03
@goodm0urning Sure thing! Whats troubling you?
goodm0urning
@goodm0urning
Mar 30 2016 05:03
Can someone help me with javascript? I'm supposed to create a variable 'fahrenheit' and assign it the corresponding temperature or something?
function convert(celcius) {
// Only change code below this line
var fahrenheit = convert(30)*9/2+32;

// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

// Change the inputs below to test your code
convert(30);
That's what I have right now
Chris
@MrChristofferson
Mar 30 2016 05:04
@goodm0urning, your function is an infinite loop :grin:
goodm0urning
@goodm0urning
Mar 30 2016 05:05
freecodecamp never went over functions before throwing this at me, so I'm a little stuck :/
V Arun Kumar
@arunvkumr
Mar 30 2016 05:05
@goodm0urning convert(30) is the function name.. and calling it again will make it in never ending recursive. you need the value in the function arguments which is stored in celsius.
Chris
@MrChristofferson
Mar 30 2016 05:05
Yep ^
goodm0urning
@goodm0urning
Mar 30 2016 05:06
so IN the function just do something like: var fahrenheit = convert*9/5+32; ?
V Arun Kumar
@arunvkumr
Mar 30 2016 05:06
@goodm0urning an i think the formula is not right. you sure it is 9/2?
goodm0urning
@goodm0urning
Mar 30 2016 05:07
it's 9/5
I typoed that!
Alex Rose
@thelyricalrose
Mar 30 2016 05:07
@goodm0urning I think you may want to be using celcius instead of convert
goodm0urning
@goodm0urning
Mar 30 2016 05:07
ah, okay, is that because it's the variable in the function name?
thank you @MrChristofferson @arunkumrv @thelyricalrose ! it works!
CamperBot
@camperbot
Mar 30 2016 05:08
goodm0urning sends brownie points to @mrchristofferson and @arunkumrv and @thelyricalrose :sparkles: :thumbsup: :sparkles:
:star: 274 | @thelyricalrose | http://www.freecodecamp.com/thelyricalrose
:star: 409 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
:star: 62 | @mrchristofferson | http://www.freecodecamp.com/mrchristofferson
Chris
@MrChristofferson
Mar 30 2016 05:08
@goodm0urning yayyyyy :grin:
V Arun Kumar
@arunvkumr
Mar 30 2016 05:08
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions
goodm0urning
@goodm0urning
Mar 30 2016 05:09
Alex Rose
@thelyricalrose
Mar 30 2016 05:09

the function declaration looks like function(var1, var2, etc)

So if you look at where the function is declared you can see what variables it is taking

in this case you have convert(celcius) so convert(30) will assign 30 to the variable celcius within the function

Andrews
@frempongandrews
Mar 30 2016 05:09
@arunkumrv uhm back again ;) seem not to be passing the challenge anyway
Alex Rose
@thelyricalrose
Mar 30 2016 05:09
@goodm0urning Glad to hear you got it working! Just make sure you understand something before moving on to make sure your base is solid
V Arun Kumar
@arunvkumr
Mar 30 2016 05:09
@frempongandrews i think because of the extra space at the end.. :grinning:
@frempongandrews post your code.. did you return the sentence?
Kyle Morton
@kmorton1988
Mar 30 2016 05:11
God I'm so done with this project :/
I've been fine with every single one so far, but this one just has me stumped.
Alex Rose
@thelyricalrose
Mar 30 2016 05:11
@kmorton1988 Which project?
Kyle Morton
@kmorton1988
Mar 30 2016 05:11
Weather Display
V Arun Kumar
@arunvkumr
Mar 30 2016 05:11
@kmorton1988 what are you working on?
Kyle Morton
@kmorton1988
Mar 30 2016 05:12
I can't figure out how to use geolocation, and I can't figure out how to store an API json response into a useable object.
it sucks.
Alex Rose
@thelyricalrose
Mar 30 2016 05:12
@kmorton1988 That's a bit beyond me :grin:
Kyle Morton
@kmorton1988
Mar 30 2016 05:12
Yeah, me too.
@thelyricalrose
Matt Green
@mattxgreen
Mar 30 2016 05:13
@kmorton1988 I can help
@kmorton1988 we gotta move fast though, I need some sleep here soon
Kyle Morton
@kmorton1988
Mar 30 2016 05:14
would love any help you can provide, @mattxgreen haha ok, no worries.
Matt Green
@mattxgreen
Mar 30 2016 05:14
you got code?
Kyle Morton
@kmorton1988
Mar 30 2016 05:14
My biggest two struggles are 1: Storing lat and long to a global variable.
Matt Green
@mattxgreen
Mar 30 2016 05:14
or a pen?
Kyle Morton
@kmorton1988
Mar 30 2016 05:14
no, I just nuked it lol.
deleted all my javascript cause it wasn't working.
and 2: storing a json API response into a usable object.
once I get those two I feel like I can get the rest.
Matt Green
@mattxgreen
Mar 30 2016 05:15
you don't necessarily need it in a global, you can also pass it around
Kyle Morton
@kmorton1988
Mar 30 2016 05:15
how so?
Matt Green
@mattxgreen
Mar 30 2016 05:15
ok, what are you going to use for geolocation?
Kyle Morton
@kmorton1988
Mar 30 2016 05:15
HTML5 geolocation stuffs.
navigator.geolocation.getCurrentPosition()
Matt Green
@mattxgreen
Mar 30 2016 05:16
ok, I believe that's navigator
yep
Kyle Morton
@kmorton1988
Mar 30 2016 05:16
but that asks for a function to be passed.
why does it need a function?
V Arun Kumar
@arunvkumr
Mar 30 2016 05:16
@kmorton1988 been there.. you actually can't store the values into global because navigator is asynchronous
Matt Green
@mattxgreen
Mar 30 2016 05:16
@kmorton1988 @arunkumrv is right
Kyle Morton
@kmorton1988
Mar 30 2016 05:16
I see.
hmm.
Matt Green
@mattxgreen
Mar 30 2016 05:17
@kmorton1988 for this project you will probably finish with nested callbacks
V Arun Kumar
@arunvkumr
Mar 30 2016 05:17
@kmorton1988 you can call another function which you will call from navigator and pass the value of lat and long to the calling function.. yup as @mattxgreen said nested callbacks.
Kyle Morton
@kmorton1988
Mar 30 2016 05:18
ok, so the "function" that you pass to navigator then performs actions on the data passed to it from navigator?
would I be be able to then assign the value of lon and lat to a variable in the second function?
Matt Green
@mattxgreen
Mar 30 2016 05:19
you can do an anonymous function inline, or you can declare a function outside, and call that one
Kyle Morton
@kmorton1988
Mar 30 2016 05:19
or would i then have to pass it to yet another function that changes the HTML of the document?
Matt Green
@mattxgreen
Mar 30 2016 05:19
Let's just do it all inline for the sake of making it work
Kyle Morton
@kmorton1988
Mar 30 2016 05:19
I tried the anonymous function method, but was unsure of what to actually do with it and what variables to call.
Matt Green
@mattxgreen
Mar 30 2016 05:19
you can refactor later
Kyle Morton
@kmorton1988
Mar 30 2016 05:19
ok, so let me try something
Matt Green
@mattxgreen
Mar 30 2016 05:20
structure is like this:
navigator.geolocation.getCurrentPosition(function(positionObj){
})
Kyle Morton
@kmorton1988
Mar 30 2016 05:20
navigator.geolocation.getCurrentPosition(function() {
//what do I do here?
});
the positionObj, is that declared somewhere?
Matt Green
@mattxgreen
Mar 30 2016 05:21
no, that is passed in from getCurrentPosition
Andrews
@frempongandrews
Mar 30 2016 05:21
@arunkumrv yes it did return the sentence. wait I'll post it now
Matt Green
@mattxgreen
Mar 30 2016 05:21
you can name it whatever you want, it's just an argument
Kyle Morton
@kmorton1988
Mar 30 2016 05:21
ok...then you use positionObj.coords.latitude?
etc?
Matt Green
@mattxgreen
Mar 30 2016 05:21
yep
Andrews
@frempongandrews
Mar 30 2016 05:22
 
Kyle Morton
@kmorton1988
Mar 30 2016 05:22
ok, that makes more sense. THen within that anonymous function, can I call a JSON object? or can I assign variables in that anon function that I can use outside that function?
Matt Green
@mattxgreen
Mar 30 2016 05:22
so then you make your ajax request with the lat/long
Kyle Morton
@kmorton1988
Mar 30 2016 05:22
there's another thing I wasn't sure I needed or not. Is an ajax request required when dealing iwth a json object?
Matt Green
@mattxgreen
Mar 30 2016 05:23
INSIDE that callback, and you will then be creating another callback.
Kyle Morton
@kmorton1988
Mar 30 2016 05:23
oh jesus.
callbackception
Matt Green
@mattxgreen
Mar 30 2016 05:23
So, getJSON is an ajax request... it's just a shortcut method
if you read the docs you will see
Andrews
@frempongandrews
Mar 30 2016 05:24

 (shift+enter for line break)
function titleCase(str) {

//string to lowercase
var low = str.toLowerCase();

//split words string

var words = low.split(" ");

//get length of string(words)

var len = words.length;

//iterate each word by using length in for loop
var sentence = "";

for (i = 0; i <= len-1; i++){
//getting first letter to uppercase
var firstLet = words[i].substring(0,1).toUpperCase();
//getting rest of letters
var rest = words[i].substring(1);
sentence += firstLet + rest + " ";

}

return sentence;

}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");



Robert Richey
@0x0936
Mar 30 2016 05:24
create a function that does the API call, then call that function passing in lat and lon as arguments
Kyle Morton
@kmorton1988
Mar 30 2016 05:25
navigator.geolocation.getCurrentPosition(function() {
jQuery.getJSON( URLTOJSON, callbackFunction()) {

}
});
what's the data and success options? are they required?
nope. they aren't
V Arun Kumar
@arunvkumr
Mar 30 2016 05:26
@frempongandrews there is space at the end of the sentence.. that's why it's not accepted..
what you can do is.. change the condition of i loop to i < len - 1 and in return statement concat the last word with firstletter uppercase and rest as it is.
Kyle Morton
@kmorton1988
Mar 30 2016 05:26
probably not needed when calling to get the weather info.
Robert Richey
@0x0936
Mar 30 2016 05:27
data is optional, success is your callback with the response
Matt Green
@mattxgreen
Mar 30 2016 05:27
@kmorton1988
navigator.geolocation.getCurrentPosition(function() {
$.getJSON( URLTOJSON,function(jsonData){ // now I have my json }); }); Kyle Morton @kmorton1988 Mar 30 2016 05:27 OH! so then inside of the second function, I can access stuff and do stuff? Matt Green @mattxgreen Mar 30 2016 05:28 now you see and$ is the shortcut for JQuery
Kyle Morton
@kmorton1988
Mar 30 2016 05:28
so that's where I would want to make changes to the HTML.
so $.getJSON is equal to jquery.getJSON? Matt Green @mattxgreen Mar 30 2016 05:28 It very well could be ;) the same Kyle Morton @kmorton1988 Mar 30 2016 05:29 ok. that's a start. th anks @mattxgreen thanks @mattxgreen CamperBot @camperbot Mar 30 2016 05:29 kmorton1988 sends brownie points to @mattxgreen :sparkles: :thumbsup: :sparkles: :star: 415 | @mattxgreen | http://www.freecodecamp.com/mattxgreen Kyle Morton @kmorton1988 Mar 30 2016 05:29 and thanks @0x0936 CamperBot @camperbot Mar 30 2016 05:29 kmorton1988 sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles: :star: 1255 | @0x0936 | http://www.freecodecamp.com/0x0936 Robert Richey @0x0936 Mar 30 2016 05:29 :+1: V Arun Kumar @arunvkumr Mar 30 2016 05:31 @frempongandrews something like.. for (i = 0; i < len-1; i++){ //<- len - 1 not len. //other statements } //this statement is to append the last word into the sentence. return sentence+words[words.length-1][0].toUpperCase()+words[words.length-1].substr(1); Matt Green @mattxgreen Mar 30 2016 05:31 @frempongandrews here's your code back: var words = str.toLowerCase().split(" "), sentence = ""; for (i = 0; i < words.length ; i++){ sentence += words[i].substring(0,1).toUpperCase()+words[i].substring(1);+ " "; } return sentence; Andrews @frempongandrews Mar 30 2016 05:34 @arunkumrv uhm I don't think I get the return statement part Matt Green @mattxgreen Mar 30 2016 05:34 @frempongandrews @arunkumrv Are you guys trying to eliminate the final " " Kyle Morton @kmorton1988 Mar 30 2016 05:34 yes yes yes yes yes yes yes yes!!!! omg this is perfect! V Arun Kumar @arunvkumr Mar 30 2016 05:35 @mattxgreen yup. Matt Green @mattxgreen Mar 30 2016 05:35 @arunkumrv @frempongandrews don't build a string as you go. Modify the array elements in place, then .join() them with a " " @kmorton1988 glad you made progress. past my bedtime Kyle Morton @kmorton1988 Mar 30 2016 05:37 goodnight, thanks again. You helped me understand what was going on. Greatly appreciated :) Matt Green @mattxgreen Mar 30 2016 05:37 sure thing V Arun Kumar @arunvkumr Mar 30 2016 05:38 @frempongandrews before the return sentence; statement.. your sentence is "Here Is My Handle Here Is " with a space at the end. so now you just need to add the last word in the sentence variable and words[words.length-1][0].toUpperCase() adds the last word's first char in upper case and words[words.length-1].substr(1) adds the rest of the word starting from index 1. @frempongandrews so finally you get "Here Is My Handle Here Is My Spout" without space at end. :smiley: Andrews @frempongandrews Mar 30 2016 05:41 @arunkumrv Oh that's genius! going over it now. Thanks a lot! CamperBot @camperbot Mar 30 2016 05:41 frempongandrews sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles: :warning: frempongandrews already gave arunkumrv points V Arun Kumar @arunvkumr Mar 30 2016 05:42 @frempongandrews you're welcome :smile: Matt Green @mattxgreen Mar 30 2016 05:44 @frempongandrews @arunkumrv I think this is simpler: return sentence.replace(/\$/,'');
that'll remove your space at the end of the sentance
Noah Guillory
@slokomisu
Mar 30 2016 05:48
Hey, I'm having some trouble with the Profile Lookup. I'm passing every test except the last one which should return "No such property" but instead it's returning "No such contact". What am I doing wrong?+
function lookUp(firstName, prop){
// Only change code below this line
var value = "";
for (var i=0; i < contacts.length; i++){
if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
} else if (contacts[i].firstName !== firstName){
value =  "No such contact";
} else if (!contacts[i].hasOwnProperty(prop)){
value = "No such property";
}

}

return value;

// Only change code above this line
}
V Arun Kumar
@arunvkumr
Mar 30 2016 05:50

@mattxgreen ya that's simpler and you can finish the entire code in one or two line...

function titleCase(str) {
return str.toLowerCase().split(" ").map(function(word){
return word[0].toUpperCase()+word.substr(1);
}).join(" ");
}
titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");

but that's not the point. he is new here and he is doing title case string and i don't think he reached the regexp challenge still and i wanted him to understand how it works underneath.

Zach
@Moose1551
Mar 30 2016 05:50
Am I anywhere close to being correct with the "Testing Objects for Properties" section of Basic javaScript?
var myObj = {
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
return "pony";
} if (myObj.hasOwnProperty("pet")) {
return "kitten";
} else {
}}

// Test your code by modifying these values
checkObj("gift");
V Arun Kumar
@arunvkumr
Mar 30 2016 05:54
@slokomisu return no such property if the contact exist and he doesn't have the property, you have to check for firstname too.. and moveout the no such contact out of loop that's making your loop break at 1st or 2nd iteration.
Elbert Cortez
@trip16661
Mar 30 2016 05:55
function bouncer(arr) {
return the === true;
});
}

bouncer([7, "ate", "", false, 9]);
am i doing anything wrong?
V Arun Kumar
@arunvkumr
Mar 30 2016 05:56
@Moose1551 don't hardcode the statements.. you are not using checkProp anywhere in your code..
Elbert Cortez
@trip16661
Mar 30 2016 05:56
it suppose to filter truthy elements
but's it's returning an empty array
V Arun Kumar
@arunvkumr
Mar 30 2016 05:57
help bouncer
CamperBot
@camperbot
Mar 30 2016 05:57

# Problem Explanation:

Remove all falsy values from an array.

V Arun Kumar
@arunvkumr
Mar 30 2016 05:58
@trip16661 thats because return the === true is always returning false..
CamperBot
@camperbot
Mar 30 2016 05:58
arunkumrv sends brownie points to @trip16661 :sparkles: :thumbsup: :sparkles:
:star: 261 | @trip16661 | http://www.freecodecamp.com/trip16661
Elbert Cortez
@trip16661
Mar 30 2016 06:01
so how can i select falsy values?
V Arun Kumar
@arunvkumr
Mar 30 2016 06:01
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean
it's much easier and simpler with boolean objects @trip16661
Zach
@Moose1551
Mar 30 2016 06:06
like this @arunkumrv ?
// Setup
var myObj = {
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
return checkProp = "pony";

// Test your code by modifying these values
checkObj("gift");
Kyle Morton
@kmorton1988
Mar 30 2016 06:07
if(itemThatIsFalsy){
//this will never run, as the item is falsy
} else if (!itemThatIsFalsy) {
//this will run every time, as NOT falsy is truthy
}
Srinivas
@sriducati
Mar 30 2016 06:15
anybody here to help me with tutorial?
explain quote
CamperBot
@camperbot
Mar 30 2016 06:15

# Escaping Literal Quotes in Strings

In JavaScript, you can escape a quote from considering it as an end of string quote by placing a backslash \ in front of the quote.

"Alan said, \"Peter is learning JavaScript\"."

This signals JavaScript that the following quote is not the end of the string, but should instead appear inside the string.

However another option is to alternate quotation marks if possible. 'Alan said, "Peter is learning JavaScript"' this would also work.

Srinivas
@sriducati
Mar 30 2016 06:15
Confirm the Ending
anybody here to help me with "Confirm the Ending
"
Confirm the Ending
Ramana Venkata
@vramana
Mar 30 2016 06:17
@sriducati What have you tried ??
Srinivas
@sriducati
Mar 30 2016 06:17

function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
var new_ar = str.split(" ");
return new_ar[new_ar.length-1]===target;

}

confirmEnding("Bastian", "n");

Ramana Venkata
@vramana
Mar 30 2016 06:17
Have you read the hint ??
Srinivas
@sriducati
Mar 30 2016 06:17

'
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
var new_ar = str.split(" ");
return new_ar[new_ar.length-1]===target;

}

confirmEnding("Bastian", "n");'

its working for sentance.. but not for string
ya

"
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
var new_ar = str.split(" ");
return new_ar[new_ar.length-1]===target;

}

confirmEnding("Bastian", "n");

"

Ramana Venkata
@vramana
Mar 30 2016 06:19
@sriducati Why you are spliting it using a whitespace? That is the source of problem in your code. Words won't have spaces in between them so it won't work for them.
Have you read about String.substr() ??
Clare Dickerson
@claredickerson
Mar 30 2016 06:20
i could not for the life of me get multidimensional arrays AND THEN THEY CLICKED. YAS. I'M BACK IN THE GAME. whew. it was even simple, i think the way it was written just threw me off. oh, coding, you ol' devil.
Srinivas
@sriducati
Mar 30 2016 06:20
if i dont split it.. how does it work for sentance?>
Zach
@Moose1551
Mar 30 2016 06:21

I'm trying not to gripe too much, but is there any reason why freecodecamp provides such horrible pseudo code for the later tutorials in Basic javaScript?
For example, this:

var myObj = {
top: "hat",
bottom: "pants"
};
myObj.hasOwnProperty("top");    // true
myObj.hasOwnProperty("middle"); // false

is no where near the same as the solution:

function checkObj(checkProp) {
if (myObj.hasOwnProperty(checkProp)) {
return myObj[checkProp];
}
Ramana Venkata
@vramana
Mar 30 2016 06:21
@sriducati Read about String.substr() and then try once again. You will get it.
Zach
@Moose1551
Mar 30 2016 06:22
I tried to avoid looking up the solution for about 5 hours. Read several different sites, and nothing came close to providing literature on this specific problem. Infuriating.
Srinivas
@sriducati
Mar 30 2016 06:22
k let me try
DJ
@qualitymanifest
Mar 30 2016 06:24
This message was deleted
Srinivas
@sriducati
Mar 30 2016 06:25
got it ;)
Markus Kiili
@Masd925
Mar 30 2016 06:26
@Moose1551 You can also tell your findings on https://gitter.im/FreeCodeCamp/CurriculumDevelopment
Ramana Venkata
@vramana
Mar 30 2016 06:30
@Moose1551 Your problem has a very specific scenario in mind where as the concept is not tied any particular problem. Your task in these challenges is to combine the concepts and solve it.

@esmeetu
Mar 30 2016 06:32
function titleCase(str) {
var arr = str.toLowerCase().trim().split(' ');
arr.map(function(d) {
var darr = d.split('');
darr[0] = darr[0].toUpperCase();
return darr.join('');
});
return arr.join(' ');
}

titleCase("I'm a little tea pot");
arr.map does nothing. Why?
Ramana Venkata
@vramana
Mar 30 2016 06:33
@esmeetu I think you need read about Array.map usage once more. If you don't get it, ask again.

@esmeetu
Mar 30 2016 06:34
@vramana ok. Thanks...
CamperBot
@camperbot
Mar 30 2016 06:34
esmeetu sends brownie points to @vramana :sparkles: :thumbsup: :sparkles:
:star: 238 | @vramana | http://www.freecodecamp.com/vramana
Markus Kiili
@Masd925
Mar 30 2016 06:38
@esmeetu You just need to add : arr=arr.map(function(d) {... because map returns a new array.

@esmeetu
Mar 30 2016 06:43
@Masd925 yeah. I will be careful next time. Thank you. :D
CamperBot
@camperbot
Mar 30 2016 06:43
esmeetu sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1254 | @masd925 | http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Mar 30 2016 06:46
@esmeetu You can also simplify it some:
function titleCase(str) {
return str.split(' ').map(function(val){
return val.charAt(0).toUpperCase() + val.substr(1).toLowerCase();
}).join(' ');
}

@esmeetu
Mar 30 2016 06:51
@Masd925 it looks better, and more methods more simplifier.
Shanto
@MohsinulKabir
Mar 30 2016 07:01
hello guys,need a help
function x(value){
return value!=="" && value!==false && value!==null && value!==undefined && value!==0;
}
arr=arr.filter(x);
return arr;
this piece of code is returning a null value, but I don't want that...
Mar 30 2016 07:07
function lookUp(firstName, prop){
// Only change code below this line

for (i=0; i< contacts.lenth; i++){

if (contacts[i].firstName == firstName) {

if (contacts[i][prop] == prop){

return contacts[i][prop];}

return "No such property"; }
}

return "No such contact";

}

// Only change code above this line

// Change these values to test your function
lookUp("Akira", "address");
Having some trouble with this one.
trying to check if there is a first name match, and then if the property exists, and if so for both return the property.
Markus Kiili
@Masd925
Mar 30 2016 07:10
@MohsinulKabir You are most probably not removing NaN (shows as null in FCC console).
Coy Sanders
@coymeetsworld
Mar 30 2016 07:10
you need to use hasOwnProperty() to see if the object has the property, not == @V1ad1m1r
Mar 30 2016 07:15
function lookUp(firstName, prop){
// Only change code below this line

for (i=0; i< contacts.lenth; i++){

if (contacts[i].hasOwnProperty(firstName)) {

if (contacts[i].hasOwnProperty(prop)){

return contacts[i][prop];}

return "No such property"; }
}

return "No such contact";
like so?
Coy Sanders
@coymeetsworld
Mar 30 2016 07:16
length is spelled wrong in your for loop
and you don't change the firstName part
Mar 30 2016 07:17
sorry, this particular exercise has me feeling really dumb. what do you mean dont change the first name?
Coy Sanders
@coymeetsworld
Mar 30 2016 07:17
what you had before with firstname is fine, so change that back
what youre doing is iterating through the array of objects (contacts)
and you only want to deal with the object whose firstName is the one you pass into the function, so you need to do the == comparison there
Mar 30 2016 07:20
AH! because hasOwnProperty will just check if there is something assigned to firstName instead?
Coy Sanders
@coymeetsworld
Mar 30 2016 07:20
it will only check if there is a property named firstName in the object
which all the objects have already anyways in this example, but more importantly you're trying to find a specific firstName, so thats why you need to use the double equals comparison operator
Mar 30 2016 07:21
so that the names match exactly. ok. cool.
Coy Sanders
@coymeetsworld
Mar 30 2016 07:21
and once you match it, then you're trying to see if that object has the property prop, and you do that with the hasOwnProperty function
Mar 30 2016 07:22
ok. that makes sense.
Coy Sanders
@coymeetsworld
Mar 30 2016 07:24
yeah, you were on the right track though just had to change one thing
Mar 30 2016 07:24
Man going into this task, i felt like I had skipped a few. Took me a minute to even figure out where to start.
still trying to get the "no such contact" section to work.
excuse me... "no such property". Contact is working fine.
Coy Sanders
@coymeetsworld
Mar 30 2016 07:27
code?
Mar 30 2016 07:28
lmao. I just got it. I had a random ; chilling on a line.
Coy Sanders
@coymeetsworld
Mar 30 2016 07:28
thought it looked fine minus the things i said
ah ok
Mar 30 2016 07:28
its always the tiny things.
:)
Coy Sanders
@coymeetsworld
Mar 30 2016 07:29
yep usually lol
Mar 30 2016 07:29
Thanks for the help man. ON TO THE NEXT ONE!!!
Coy Sanders
@coymeetsworld
Mar 30 2016 07:30
np gl
Azamat Kukenov
@azamat89
Mar 30 2016 07:30
Make Object Properties Private need help??
Sanaa
@SanaaJalil
Mar 30 2016 07:38
@revisualize :Yes I solved my issue , thank you
CamperBot
@camperbot
Mar 30 2016 07:38
sanaajalil sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star: 805 | @revisualize | http://www.freecodecamp.com/revisualize
Sanaa
@SanaaJalil
Mar 30 2016 07:38
@revisualize thanks
CamperBot
@camperbot
Mar 30 2016 07:38
sanaajalil sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: sanaajalil already gave revisualize points
Sanaa
@SanaaJalil
Mar 30 2016 07:39
Hello everyone
I need help in this challange Using Objects for Lookups
Aleksander Gębicki
@Takumar
Mar 30 2016 07:40
Sanaa
@SanaaJalil
Mar 30 2016 07:51
@Takumar sorry i need help in this challange
Introducing JavaScript Object Notation JSON
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
];
Aleksander Gębicki
@Takumar
Mar 30 2016 07:52
@SanaaJalil notice that myMusic is an array, so you have to add another element after comma to this array, so it will look like this:
var myMusic = [
{},
{}
];
Sanaa
@SanaaJalil
Mar 30 2016 07:53
@Takumar Add a new album to the myMusic JSON object. Add artist and title strings, release_year number, and a formats array of strings.
Aleksander Gębicki
@Takumar
Mar 30 2016 07:53
@SanaaJalil yes and new album is the second object (element) in your array, your array will have two objects inside.
Blauelf
@Blauelf
Mar 30 2016 07:54
like
var myMusic = [
{
// first object
},
{
// second object
}
];
Sanaa
@SanaaJalil
Mar 30 2016 07:54
I cant do this myMusic.artist="sanaa";
Blauelf
@Blauelf
Mar 30 2016 07:54
Do a second object like the first one.
JulieAlary
@JulieAlary
Mar 30 2016 07:54
Sorry but i don't know what i have to do in this exercise... can you help me? Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
Sanaa
@SanaaJalil
Mar 30 2016 07:54
Ok i understand now
Aleksander Gębicki
@Takumar
Mar 30 2016 07:54
@SanaaJalil myMusic is an array, so you add second element to it.
Olawale Akinseye
@brainyfarm
Mar 30 2016 07:55
@JulieAlary
Did you see the table?
JulieAlary
@JulieAlary
Mar 30 2016 07:55
@brainyfarm the table?
Blauelf
@Blauelf
Mar 30 2016 07:55
@JulieAlary If you were to escape "form-feed backspace" it would be var myStr = "\f \b"; (note the space between escape sequences for this task)
Sanaa
@SanaaJalil
Mar 30 2016 07:55
@Takumar @Blauelf thanks alot
CamperBot
@camperbot
Mar 30 2016 07:55
sanaajalil sends brownie points to @takumar and @blauelf :sparkles: :thumbsup: :sparkles:
Aleksander Gębicki
@Takumar
Mar 30 2016 07:55
@SanaaJalil sorry, I have to leave now - good luck!
CamperBot
@camperbot
Mar 30 2016 07:55
:star: 2906 | @takumar | http://www.freecodecamp.com/takumar
:star: 1473 | @blauelf | http://www.freecodecamp.com/blauelf
Olawale Akinseye
@brainyfarm
Mar 30 2016 07:56
@JulieAlary
Code and Output.
JulieAlary
@JulieAlary
Mar 30 2016 07:56
i do that : var myStr = '\ "backslash" \t "tab" \t "tab" \r "carriage-return" \n "new-line"';
Olawale Akinseye
@brainyfarm
Mar 30 2016 07:56
For example, to escape a new-line in a string, you would do \n
@JulieAlary
Nice, now you should delete all the output from your string.
You want only the code.
JulieAlary
@JulieAlary
Mar 30 2016 08:02
@brainyfarm i try but i'm not understand what i have to do....(i'm french and i have a bad english...)
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:03
Don't worry @JulieAlary.
How is it now?
Blauelf
@Blauelf
Mar 30 2016 08:03

@JulieAlary Only the escape sequences, like I wrote (\f is sequence for form-feed, \b sequence for backspace):

@JulieAlary If you were to escape "form-feed backspace" it would be var myStr = "\f \b"; (note the space between escape sequences for this task)

Olawale Akinseye
@brainyfarm
Mar 30 2016 08:06

For example if I am to escape single quote, double quote and backslash
I would do:

var myStr = " \' \" \\ "

JulieAlary
@JulieAlary
Mar 30 2016 08:06
@Blauelf @brainyfarm i do that.... var myStr = "\ \t \t \r \n ";
Blauelf
@Blauelf
Mar 30 2016 08:07
You should not have a trailing space.
var myStr = "\\ \t \t \r \n"; would be without.
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:07
Delete the space after \n @JulieAlary
CamperBot
@camperbot
Mar 30 2016 08:07
brainyfarm sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1475 | @blauelf | http://www.freecodecamp.com/blauelf
JulieAlary
@JulieAlary
Mar 30 2016 08:08
@brainyfarm @Blauelf i do...
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:08
JulieAlary
@JulieAlary
Mar 30 2016 08:08
@brainyfarm var myStr = "\ \t' \t \r \n";
Blauelf
@Blauelf
Mar 30 2016 08:08
@JulieAlary There's an extra ' that does not belong in the code
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:09
@JulieAlary
Do you see you have ' after \t ?
JulieAlary
@JulieAlary
Mar 30 2016 08:10
@Blauelf @brainyfarm aha.... i'm stupid sometimes.... thanks very much!!! i don't understand why the have to do as that, but it's done!!!
CamperBot
@camperbot
Mar 30 2016 08:10
juliealary sends brownie points to @blauelf and @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1476 | @blauelf | http://www.freecodecamp.com/blauelf
:star: 1706 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:11
yay!!! @JulieAlary and happy coding
Language barrier should not stop you, keep flying :D
JulieAlary
@JulieAlary
Mar 30 2016 08:13
@brainyfarm :smile: i'm in the sky now!!
Francisco Franco
@frenktico
Mar 30 2016 08:14
:(
crying
:'(
function convert(celsius) {
// Only change code below this line

var farenheit *= (9/5) +32;
// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

// Change the inputs below to test your code
convert(30);
how am I SUPPOSED to know something at this point I have no logical thinknig on it, can ayone explain?
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:15
@frenktico
var farenheit *= (9/5) + 32;
Look at this line again :point_up:
Francisco Franco
@frenktico
Mar 30 2016 08:16
I'm the one who wrote this :(
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:16
Something is missing.
Francisco Franco
@frenktico
Mar 30 2016 08:16
hmmm
okay I see that one letter was missing and it now is corrected
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:17
Where is the celsius variable @frenktico ?
Francisco Franco
@frenktico
Mar 30 2016 08:18

The exercise Convert Celsius to Fahrenheit says:

To test your learning you will create a solution "from scratch". Place your code between the indicated lines and it will be tested against multiple test cases.

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.

You are given a variable celsius representing a temperature in Celsius. Create a variable fahrenheit and apply the algorithm to assign it the corresponding temperature in Fahrenheit.

Olawale Akinseye
@brainyfarm
Mar 30 2016 08:19
You are supposed to do the conversion on the celsius variable @frenktico but you are not using that celsius value in your conversion formula.
Francisco Franco
@frenktico
Mar 30 2016 08:20
I'm too dumb to understand javascript logical :'(
I added the var celsius = 30;
with and without parenthesis
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:22
@frenktico
var fahrenheit = celsius * 9/5 + 32;
Francisco Franco
@frenktico
Mar 30 2016 08:22
the previous exercises just showed me how to calculate
oh JEZZ thank @brainyfarm
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:23
@frenktico
Besides, you also had a wrong variable name.
Francisco Franco
@frenktico
Mar 30 2016 08:23
yes
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:23
You fixed it now @frenktico ?
Francisco Franco
@frenktico
Mar 30 2016 08:23
I'm afraid as hell to learn javascript I'm not that enthusiatic on it.
Yes I did thanks to you typing the code to me :/
function convert(celsius) {
// Only change code below this line

var fahrenheit = celsius * 9/5 +32;

// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

// Change the inputs below to test your code
convert(30);
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:25

@frenktico
I think that is normal, we are usually very bad at a lot of things until we practice and practice and practice.

Happy Coding man!

Francisco Franco
@frenktico
Mar 30 2016 08:25
Thanks @brainyfarm I will try to cheer up
CamperBot
@camperbot
Mar 30 2016 08:25
frenktico sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1707 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
JScapin
@JScapin
Mar 30 2016 08:27
Hello everybody ! Does Someone could help me with the openweathermap API ? I dont understand how to get the id of a city by is latitude and longitude
Blair Yacishyn
@YacYac
Mar 30 2016 08:28
I'm working on Symetric Difference. I'm trying to solve it with recursion, but it always crashes on the second call. Any pointers?
function filterDupes(element,index,array) {
if (array.indexOf(element) === index) {
return true;
} else {
return false;
}
}

function filterSym(element,index,array) {
var numOfElement = 0;

array.forEach(function(e){
if (element === e) {
numOfElement++;
}
});

if (numOfElement === 1) {
return true;
} else {
return false;
}
}

function sym() {
//  console.log(arguments);
var args = Array.prototype.slice.call(arguments);
var argsObj = {};
var arr1 = args.shift();
arr1 = arr1.filter(filterDupes);
//  console.log(arr1);

var arr2 = args.shift();
arr2 = arr2.filter(filterDupes);
//  console.log(arr2);

var compArr = [];
arr1.forEach(function(e){
compArr.push(e);
});
arr2.forEach(function(e){
compArr.push(e);
});

compArr = compArr.filter(filterSym);
args.unshift(compArr);

args.forEach(function(element,index,array){
argsObj[index] = element;
});

if (args.length > 1) {
return sym(argsObj);
} else {
console.log(args[0]);
return args[0];
}
//  console.log(argsObj);
}
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:28
You mean geolocation @JScapin ?
dkennell
@dkennell
Mar 30 2016 08:29
Hey, everyone. I'm working on the Seek and Destroy challenge. I can't really figure out how a function that only takes one parameter can accept more than one argument. What does that parameter even refer to, then? All of the arguments? Or just the first one?
function destroyer(arr) {
// Remove all the values
return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:30
@dkennell
Do you know about the arguments object?
JScapin
@JScapin
Mar 30 2016 08:31
@brainyfarm yes i manage to get lat and lon but after i dont know how to use getJSON with the data wich is returned
dkennell
@dkennell
Mar 30 2016 08:32
@brainyfarm Yeah, but I feel like my problems are more basic than that. I still don't even know what arr means, if the function can accept those extra arguments.
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:32
@JScapin
Could you share that part of your code?
dkennell
@dkennell
Mar 30 2016 08:32
@brainyfarm For example,seeing as there's one one parameter, is arguments[0] and arr[0] the same thing?
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:33
@dkennell
They are not @dkennell
arguments consists of everything passed it while arr is just the first argument which is an array.
JScapin
@JScapin
Mar 30 2016 08:34
i warn you : it is a noob code :D
dkennell
@dkennell
Mar 30 2016 08:35
@brainyfarm Thank you, that's exactly what I was trying to find out. :)
CamperBot
@camperbot
Mar 30 2016 08:35
dkennell sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1709 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:35
Happy coding man @dkennell :D
Blauelf
@Blauelf
Mar 30 2016 08:36
@dkennell arguments is an array-like object that has indexed all arguments passed to the function (whether or not those match the number of named parameters). So arguments[0] always refers to the first argument (in your case this is also accessible as arr). Use arguments.length for figuring out how many arguments were passed. And inner functions have their own arguments object that hides that of the outer function (unless they are ES6 arrow functions).
Vivienne Sales
@Natto278
Mar 30 2016 08:37
@JScapin I'm not at that exercise, yet. Latitudes are the numbers north and south of the equator. Longitudes specify the east-west position of a place. Here's a website explaining the differences between latitude and longitude: https://www.maptools.com/tutorials/lat_lon/definitions
Abdullah Hoosen
@abdullahhoosen
Mar 30 2016 08:37
thanks @leftynaut for your help with Checkpoint: Counting Cards
CamperBot
@camperbot
Mar 30 2016 08:37
abdullahhoosen sends brownie points to @leftynaut :sparkles: :thumbsup: :sparkles:
:star: 462 | @leftynaut | http://www.freecodecamp.com/leftynaut
JScapin
@JScapin
Mar 30 2016 08:39
@Natto278 thanks but i know what are lat and lon but i would like help to how exploit the data return by the api request
CamperBot
@camperbot
Mar 30 2016 08:39
jscapin sends brownie points to @natto278 :sparkles: :thumbsup: :sparkles:
:star: 185 | @natto278 | http://www.freecodecamp.com/natto278
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:39
@JScapin
JScapin
@JScapin
Mar 30 2016 08:41
@brainyfarm I dont know I dont manage to know it because I dont know how to use the data which is return by getJSON(UrlofMyApiwithlatandlong, function(data){
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:41
@JScapin
$.getJSON not getJSON. JScapin @JScapin Mar 30 2016 08:42 @brainyfarm thanks for beginning :D but after how to access the datas of the object CamperBot @camperbot Mar 30 2016 08:42 jscapin sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles: :star: 1710 | @brainyfarm | http://www.freecodecamp.com/brainyfarm Olawale Akinseye @brainyfarm Mar 30 2016 08:43 @JScapin Fix your code and confirm the call was successful first. JScapin @JScapin Mar 30 2016 08:43 Do you agree that {"coord":{"lon":139,"lat":35},} "coord" is a propriety of the object ? Olawale Akinseye @brainyfarm Mar 30 2016 08:44 Yes I agree @JScapin and your json object is not properly formed :P JScapin @JScapin Mar 30 2016 08:46 @brainyfarm do you mean that >>$.getJSON(UrlofAPI, function(data){
var cityID = data.coord << is wrong ?
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:46
No @JScapin , I was referring to the example you used. LOL
Vivienne Sales
@Natto278
Mar 30 2016 08:47
@frenktico I was just comparing your code for converting Celsius to Fahrenheit to mine. Here are two hints: A) You need to create variable ID for fahrenheit. B) You need to add () for the following code: var fahrenehit = celsius * + 32. You need to figure out where to put the ().
JScapin
@JScapin
Mar 30 2016 08:47
@brainyfarm the API tell that it is the object return by the request ..
kirbyedy
@kirbyedy
Mar 30 2016 08:48
@JScapin your api is not quite right... somewhere...
dkennell
@dkennell
Mar 30 2016 08:48
@Blauelf Okay, thanks.
CamperBot
@camperbot
Mar 30 2016 08:48
dkennell sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
Vivienne Sales
@Natto278
Mar 30 2016 08:48
@frenktico If you think the Convert Celsius to Fahrenheit challenge is tough, wait till you get to the Stand in Line challenge!
CamperBot
@camperbot
Mar 30 2016 08:48
:star: 1478 | @blauelf | http://www.freecodecamp.com/blauelf
Fatah N
@fatahn
Mar 30 2016 08:49
hey guys. I get this error TypeError: string is not a function. When I test the code below. Its a codewars.com kata. What am I missing?Thank you
var createIterator = function (func, n) {
// TODO: Write code here to return a function
// that executes *func*, *n* times on a supplied input
var a = func;
if(n === 1){
a;
}
else
for(var i = 2; i <= n; i++){
a = func(a);

}
return a;
};
JScapin
@JScapin
Mar 30 2016 08:49
@kirbyedy i dont know where i am wrong :/
dkennell
@dkennell
Mar 30 2016 08:51
Okay, so I've been working on this Seek and Destroy challenge for a while now, and I can't figure out where I'm going wrong. The current error I keep getting is false is not a function. Any ideas?
function filtervals(arr, arg) {
if (arr.indexOf(arg) == -1) {
return true;
}
else {return false;}
}

function destroyer(arr) {
// Remove all the values
for (i = 1; i < arguments.length; i++) {
arr.filter(filtervals(arr,arguments[i]));
}
return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Olawale Akinseye
@brainyfarm
Mar 30 2016 08:51
Add an http:// to your url @JScapin .
kirbyedy
@kirbyedy
Mar 30 2016 08:52
@JScapin to get the city you should call data.name
Markus Kiili
@Masd925
Mar 30 2016 08:53
@dkennell Filter callback function possible parameters are (element, index,array).
kirbyedy
@kirbyedy
Mar 30 2016 08:54
@JScapin also try to avoid that math.round for location
dkennell
@dkennell
Mar 30 2016 08:55
@Masd925 I thought it took a function as its parameter.
JScapin
@JScapin
Mar 30 2016 08:56
yes for location it what I was doing to have entire number, @kirbyedy and the data.name doesnt work
Markus Kiili
@Masd925
Mar 30 2016 08:56
@dkennell Filter method takes a function as an argument. This callback function can have 1-3 parameters.
kirbyedy
@kirbyedy
Mar 30 2016 08:56
check the image @JScapin
Markus Kiili
@Masd925
Mar 30 2016 08:57
@dkennell The usage should be arr.filter(filtervals); The callback function is not invoked with ().
JScapin
@JScapin
Mar 30 2016 08:58
@kirbyedy i do what you tell me but it doesnt work
dkennell
@dkennell
Mar 30 2016 08:58
@Okay, so does this challenge use only one of them? Or both?
Markus Kiili
@Masd925
Mar 30 2016 08:59
@dkennell You only need the first parameter which is the array element being iterated. function(elem){return ...}
@dkennell That callback tells filter how to filter one arbitrary array element elem.
Fatah N
@fatahn
Mar 30 2016 09:01
@dkennell I think you are looping through the whole arr when you only need to loop only through the first array in the argument. because arguments1 is [1, 2, 3, 1, 2, 3] your case.
Markus Kiili
@Masd925
Mar 30 2016 09:02
@dkennell It is also better to filter only once and put the loop inside the callback function.
JScapin
@JScapin
Mar 30 2016 09:02
@kirbyedy could you go to my codepen and check that i really well done what you say ?
kirbyedy
@kirbyedy
Mar 30 2016 09:02
I removed that rounding thing
and you did not have the http//: in the url
dkennell
@dkennell
Mar 30 2016 09:03
@Masd925 Man, I'm so lost, it's embarrassing. What's a callback function?
Hsin Chih Wang
@hsinwang5
Mar 30 2016 09:04
@dkennell The function provided to Array.filter needs to be constructed a certain way. Filtervals(element), where element is the current index being processed
JScapin
@JScapin
Mar 30 2016 09:04
i include it in var myApiUrl " "http://api...."
Markus Kiili
@Masd925
Mar 30 2016 09:04
@dkennell It means that we can make a function object and pass it into a function (filter method here). Filter takes the passed function and passes array elements into it under the hood. If the return value is true (or truthy) filter keeps the element.
Abdullah Hoosen
@abdullahhoosen
Mar 30 2016 09:05

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj[]; // Change this Line
var player = testObj[16]; // Change this Line

can someone help me with playerNumber please?
Islam Ibakaev
@dagman
Mar 30 2016 09:06
have just finished my responsive, weather app made with Angular.js. What do you think about it guys? http://codepen.io/dagman/pen/BKddGL?editors=1010
Hsin Chih Wang
@hsinwang5
Mar 30 2016 09:07
@dkennell filtervals(element) {//stuff you want to do to each element of arr, which should return true or false to arr.filter to let it know whether to filter that specific element}
dkennell
@dkennell
Mar 30 2016 09:07
@Masd925 Oh..... so this is why we don't need to include parameters in the function object....
Markus Kiili
@Masd925
Mar 30 2016 09:08
@dkennell You use parameters on the callback function declaration (to define the function), but you pass just the function (name) to the filter method.
JScapin
@JScapin
Mar 30 2016 09:09
OH i get it i think but the city is not very good
it is a little far from where I am exacty
dkennell
@dkennell
Mar 30 2016 09:11
@Masd925 So how does the filter function know which parameters to pass to the callback function? Does it even need to be inside of a loop?
Markus Kiili
@Masd925
Mar 30 2016 09:12
@dkennell Filter will pass element being iterated to the first parameter and index to the second and the array to the third, if the parameters exist.
@dkennell You can just return the filtered array and loop the arguments >=1 inside the callback function.
JScapin
@JScapin
Mar 30 2016 09:13
@kirbyedy thanks, i Think with good will i could manage :)
CamperBot
@camperbot
Mar 30 2016 09:14
jscapin sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 771 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
Markus Kiili
@Masd925
Mar 30 2016 09:16
@dkennell Here is an example of filter usage:
var arr = ["cat","dog","pig"];

var func = function (elem) {   // remove cat
return elem!=="cat";
}

arr.filter(func); // returns [ 'dog', 'pig' ]
Pavan Kulkarni
@pavankrcr
Mar 30 2016 09:18

Emil Aasa
@emilaasa
Mar 30 2016 09:18
@dkennell a callback function is a function that is passed along as a parameter to another function, and then used inside that function.
dkennell
@dkennell
Mar 30 2016 09:19
@Okay, interesting.... so you don't even't need any kind of indexOf stuff there.
Pavan Kulkarni
@pavankrcr
Mar 30 2016 09:19
pasting code here
Markus Kiili
@Masd925
Mar 30 2016 09:20
@dkennell You can loop arguments inside the callback or first turn arguments into an array and use indexOf on it inside the callback.
@dkennell Remember that the callback function has its own arguments object, so you have to store destroyers arguments or the arguments array into a variable in order to use it inside the callback.
kirbyedy
@kirbyedy
Mar 30 2016 09:21
@JScapin remove this myArr.push(Math.round(position.coords.longitude)); and just use var longitude = position.coords.longitude
JScapin
@JScapin
Mar 30 2016 09:27
@kirbyedy I manage :) and i keep the Math.round for precision and its work ! and i also manage to put the icon on my page :) I know the code is not very clean yet but it's work : look : http://codepen.io/Skap1/full/eZWbQb/
kirbyedy
@kirbyedy
Mar 30 2016 09:29
@JScapin :thumbsup:
JScapin
@JScapin
Mar 30 2016 09:29
@kirbyedy thanks you to have helped me going the good way
CamperBot
@camperbot
Mar 30 2016 09:29
jscapin sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:warning: jscapin already gave kirbyedy points
Markus Kiili
@Masd925
Mar 30 2016 09:34
@dkennell Did you pass out ;)
dkennell
@dkennell
Mar 30 2016 09:35
@Masd925 Haha, no, not yet, thanks for asking. I'm just trying to get this information into my skull.
CamperBot
@camperbot
Mar 30 2016 09:35
dkennell sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1255 | @masd925 | http://www.freecodecamp.com/masd925
dkennell
@dkennell
Mar 30 2016 09:36
Haha, oops. Oh well, I was definitely going to give them to you anyway.
This message was deleted
@Masd925 So, let's say I decide to make my loop in the callback function. What would my parameters be? Just..... element and array? With elements being arguments in the original function?
Markus Kiili
@Masd925
Mar 30 2016 09:44
@dkennell In the loop inside the callback, you should loop the destroyers arguments from index 1.
@dkennell The callback function needs only one parameter elem.
dkennell
@dkennell
Mar 30 2016 09:46
@Masd925 So then, this challenge needs a loop in both functions?
Markus Kiili
@Masd925
Mar 30 2016 09:46
@dkennell Only inside callback.
@dkennell Filter method automatically iterates arr elements.
dkennell
@dkennell
Mar 30 2016 09:50
@Masd925 Okay, I think that's what I really needed to understand.
Vivienne Sales
@Natto278
Mar 30 2016 09:56

I've changed my code for the Stand in Line challenge. This time I get items #2 and #3 correct, but now items #1 and #4 are wrong. What's wrong with my code now? function queue(arr, item) {
arr.push();
arr.shift();

return arrayAnswer; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(testArr, 6); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

dkennell
@dkennell
Mar 30 2016 09:56
@Masd925 So how can I access the arguments of destroyer while I'm in the callback function?
This is what I'm working with right now:
function filtervals(element) {
if (element !== arr) {
return true;
}
else {return false;}
}

function destroyer(arr) {
// Remove all the values
arr.filter(filtervals);
}
return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
JScapin
@JScapin
Mar 30 2016 09:57
Hi again ! Someone could tell me a few to understand how i can know if a button is checked ?
Markus Kiili
@Masd925
Mar 30 2016 09:57
@dkennell For example by doing var args=arguments; Then use args inside the callback.
@dkennell Filter returns a new array so just: return arr.filter(...
dkennell
@dkennell
Mar 30 2016 09:59
@Masd925 Man, I have to go to work. Thanks so much for all of the help, I'll let you know how it goes!
CamperBot
@camperbot
Mar 30 2016 09:59
dkennell sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: dkennell already gave masd925 points
dkennell
@dkennell
Mar 30 2016 10:00
Take care for now, everyone!
Markus Kiili
@Masd925
Mar 30 2016 10:00
@dkennell You're wellcome.
Bayarjargal Jargalsaikha
@JBayaraa22
Mar 30 2016 10:09
Hello guys

function bouncer(arr) {
// Don't show a false ID to this bouncer.
arr = arr.filter(isFalsy);
return arr;
}
function isFalsy(value)
{
var x = null;
if(value===false || value===NaN || value===undefined || value===""|| value===0||value===x)
return false;

return true;

}

bouncer([false, null, 0, NaN, undefined, ""]);

it cant eliminate NULL value what is the problem>
NPeyralans
@NPeyralans
Mar 30 2016 10:12
I'm not able to return any of the values for any contact past the first contact. Anybody know why?
function lookUp(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++){
if (contacts[i].firstName==firstName) {
if(contacts[i].hasOwnProperty(prop)){
} else {
return "No such property";
}
} else {
return "No such contact";
}
}
// Only change code above this line
}
Meerimay
@futcomen
Mar 30 2016 10:12
hi guys, i need help with Escap squnces, what should i do? can somebody expain me?
Markus Kiili
@Masd925
Mar 30 2016 10:12
@JBayaraa22 It is the NaN that is not removed, because NaN===NaN is false. NaN shows as null in FCC console.
NPeyralans
@NPeyralans
Mar 30 2016 10:14
@futcomen Basically there is a need for the computer to have certain symbols to do certain things like put a tab, go to the next line ect.. but there needs to be a way that you can type that symbol in a string without the computer reading it as a string so you have to tell the computer "hey - this is not part of my string, I actually want you to insert a tab" so you have to "escape" that symbol (the t) with a \
Bayarjargal Jargalsaikha
@JBayaraa22
Mar 30 2016 10:14
@Masd925 So what is the solution of this issue?
Meerimay
@futcomen
Mar 30 2016 10:15
@NPeyralans so i need to write there string also?
Markus Kiili
@Masd925
Mar 30 2016 10:15
@JBayaraa22 You can make a separate test for NaN with value!==value
Bayarjargal Jargalsaikha
@JBayaraa22
Mar 30 2016 10:16
@Masd925 Thank you so much ! It works .
CamperBot
@camperbot
Mar 30 2016 10:16
jbayaraa22 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1256 | @masd925 | http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Mar 30 2016 10:18
@JBayaraa22 Your isFalsy is actually an implementation of built-in Boolean function. Try putting Boolean in the place of isFalsy on the filter method.
Bayarjargal Jargalsaikha
@JBayaraa22
Mar 30 2016 10:19
Just like this?
JulieAlary
@JulieAlary
Mar 30 2016 10:19

hello!! i don't understand what i'm supposed to do in this exercice "Stand in Line" function queue(arr, item) {

return item; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

Bayarjargal Jargalsaikha
@JBayaraa22
Mar 30 2016 10:20
@Masd925 arr.filter(if(value!==""||value!==false));
is that right?
Markus Kiili
@Masd925
Mar 30 2016 10:20
@JBayaraa22 I mean arr=arr.filter(Boolean);
NPeyralans
@NPeyralans
Mar 30 2016 10:21
@futcomen Basically if you want the computer to do one of those special tasks, like insert a tab or a new line, etc, you have to tell the computer ( with a \ ) that hey, this "t" means I want a tab, not a literal "t". So like this is a regular string var myName = "mat"; but if I want a tab after I write the string "ma" then do this: var myName = "ma\t"; and the output will be "ma "
Markus Kiili
@Masd925
Mar 30 2016 10:21
@JBayaraa22 Boolean does the same as your own isFalsy.
Bayarjargal Jargalsaikha
@JBayaraa22
Mar 30 2016 10:21
Oh i see
Thank you!
Markus Kiili
@Masd925
Mar 30 2016 10:21
@JBayaraa22 You're wellcome.
NPeyralans
@NPeyralans
Mar 30 2016 10:22
Anybody know why I'm not getting past the first iteration:
function lookUp(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++){
if (contacts[i].firstName==firstName) {
if(contacts[i].hasOwnProperty(prop)){
} else {
return "No such property";
}
} else {
return "No such contact";
}
}
// Only change code above this line
}
Meerimay
@futcomen
Mar 30 2016 10:22
@NPeyralans thank you, i will try now again)))
CamperBot
@camperbot
Mar 30 2016 10:22
futcomen sends brownie points to @npeyralans :sparkles: :thumbsup: :sparkles:
:star: 230 | @npeyralans | http://www.freecodecamp.com/npeyralans
Kenni Gandira Alamsyah
@kenniga
Mar 30 2016 10:23
Hello guys! Nice to see you again fellas!
Is anyone online's here?
NPeyralans
@NPeyralans
Mar 30 2016 10:23
yup
Francisco Franco
@frenktico
Mar 30 2016 10:24
@Natto278 I'm a mess and I will review the previous steps of this map I just started by the way thanks for the motivational way to say that's going to be easier hahahaha
CamperBot
@camperbot
Mar 30 2016 10:24
frenktico sends brownie points to @natto278 :sparkles: :thumbsup: :sparkles:
:star: 186 | @natto278 | http://www.freecodecamp.com/natto278
C. Groot
@ClawdStrife
Mar 30 2016 10:25
can anyone explain switch statements to me?
Kenni Gandira Alamsyah
@kenniga
Mar 30 2016 10:25
Francisco Franco
@frenktico
Mar 30 2016 10:26
at this moment I just started reviewing a bit of HTML and CSS to fix and feel better about coding because I got upset due to the lack of info on the previous details. Not enough info or I'm really dumb at it (I believe that sadly might be the second option).
Vivienne Sales
@Natto278
Mar 30 2016 10:28
You're not dumb, @frenktico. It's just that JavaScript is a totally different ballgame compared to HTML and CSS.
NPeyralans
@NPeyralans
Mar 30 2016 10:30
@ClawdStrife a switch is basically a way that you can do many if statements at one time: it goes like this, you use the "switch" keyword and then in the parenthesis you put the variable that you want to test. After that you use the keyword "case" followed by what you want to know if the first variable is, that way you don't have to do a bunch of if statements. Heres an example: switch(var1) { case "one": console.log("var1 is equal to one"); break;
case "two": console.log("var1 is equal to two"); break;
} So here you want to know if var 1 is equal to "one" or "two" and you don't have to do if (var1 == "one"){ console.log("var1 is equal to one"); } etc...
Francisco Franco
@frenktico
Mar 30 2016 10:30
but that makes me feel bad about not being able to simply understand a piece of it. Really I felt badd and had to stop for minutes but instead of quitting I decided to build few more sites in HTML and CSS to practice before returning to JS. I will keep moving on this is just the beginning I know.
Meerimay
@futcomen
Mar 30 2016 10:30
var myStr;
output
myStr="mom\my";
@NPeyralans why it doesn't work?
Francisco Franco
@frenktico
Mar 30 2016 10:31
For some reason I'm not comfortable learning this language. I gotta overcome this obstacle.
Bill
@W8sconsin
Mar 30 2016 10:31
Could someone help me with the profile lookup exercise?
Brendan Kinahan
@BKinahan
Mar 30 2016 10:31
@ClawdStrife first a switch is given an expression, switch(expression) and evaluates it. The expression could be a variable, or some operation (such as myVar - 5*otherVar). Based on the value of the expression, if it matches one of the cases in the switch, the statements associated with that case are executed. That's the basics of it anyway.
Bill
@W8sconsin
Mar 30 2016 10:32
function lookUp(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++){
if (firstName == contacts.firstName){
return contacts[firstName][prop];
}
}
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
Meerimay
@futcomen
Mar 30 2016 10:32
var myStr;
myStr ="mom\my"; @NPeyralans
NPeyralans
@NPeyralans
Mar 30 2016 10:32
@futcomen what are you trying to do? it looks likes your just trying to write the string "mom my" and if that's the case there is no need for an escape
Bill
@W8sconsin
Mar 30 2016 10:32
I get nothing when I run this, and I'm not sure what I've set up wrong
C. Groot
@ClawdStrife
Mar 30 2016 10:32
@NPeyralans and @BKinahan thanks! I'll give it another try
CamperBot
@camperbot
Mar 30 2016 10:32
clawdstrife sends brownie points to @npeyralans and @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1190 | @bkinahan | http://www.freecodecamp.com/bkinahan
:star: 231 | @npeyralans | http://www.freecodecamp.com/npeyralans
Brendan Kinahan
@BKinahan
Mar 30 2016 10:33
@W8sconsin looks like you're off to a good start; you don't get any output at all?
NPeyralans
@NPeyralans
Mar 30 2016 10:33
@W8sconsin how did you paste that code in the forum?
Brendan Kinahan
@BKinahan
Mar 30 2016 10:33
@W8sconsin is the contacts array still intact above your function?
Meerimay
@futcomen
Mar 30 2016 10:34
i can't understand how to use that escape sequences( @NPeyralans
Bill
@W8sconsin
Mar 30 2016 10:34
@NPeyralans 
NPeyralans
@NPeyralans
Mar 30 2016 10:34
@futcomen What are you trying to do?
Kutayberk Sungur
@KSungur
Mar 30 2016 10:34
Hi, I'm stuck at Title case a Sentence challenge. Can any one help?

function titleCase(str) {
str = str.toLowerCase().split("");
for (var i = 0;i<str.length;i++){
str[i] = str[i].split("");
str[i][0] = str[i][0].toUpperCase();
str[i] = str[i].join("");
}
return str.join("");
}

titleCase("I'm a little tea pot");

Meerimay
@futcomen
Mar 30 2016 10:34
myStr should have the escape sequences for backslash tab tab carriage-return new-line separated by spaces @NPeyralans
Bill
@W8sconsin
Mar 30 2016 10:34
@BKinahan I'll show you the complete code
Brendan Kinahan
@BKinahan
Mar 30 2016 10:35
@NPeyralans
js
like this

Bill
@W8sconsin
Mar 30 2016 10:35
//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUp(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++){
if (firstName == contacts.firstName){
return contacts[firstName][prop];
}
}
// Only change code above this line
}

// Change these values to test your function
lookUp("Akira", "likes");
Brendan Kinahan
@BKinahan
Mar 30 2016 10:37
@W8sconsin Oh, I see the error now, you're looping through contacts with the variable i as an iterator, but there's no use of i within the loop
Bill
@W8sconsin
Mar 30 2016 10:38
you're right
NPeyralans
@NPeyralans
Mar 30 2016 10:38
@futcomen heres an example that is similar: var myString = "\t \t \n"; that will give you two tabs and a new line. Here's another one: var myOtherString = "First line\n Second line"; That will give you "First line
Second line"
Brendan Kinahan
@BKinahan
Mar 30 2016 10:39
@W8sconsin additionally you correctly use dot notation with .firstName in the if statement, but then the use of bracket notation in the return statement will cause a different value to be used: the value of the function's firstName` variable (and "Akira" is not a property name, but a value)
Meerimay
@futcomen
Mar 30 2016 10:39
@NPeyralans thank you, now i will try again)
CamperBot
@camperbot
Mar 30 2016 10:39
futcomen sends brownie points to @npeyralans :sparkles: :thumbsup: :sparkles:
:warning: futcomen already gave npeyralans points
Blauelf
@Blauelf
Mar 30 2016 10:39
@KSungur Your outer split and join should have " ", not "", as you are splitting into words.
samamsam
@samsamam
Mar 30 2016 10:41
@kire73 thanks anyway
CamperBot
@camperbot
Mar 30 2016 10:41
samsamam sends brownie points to @kire73 :sparkles: :thumbsup: :sparkles:
:star: 257 | @kire73 | http://www.freecodecamp.com/kire73
NPeyralans
@NPeyralans
Mar 30 2016 10:41
Anybody know why I am only getting results for the first contact in list contacts?
'''
function lookUp(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++){
if (contacts[i].firstName==firstName) {
if(contacts[i].hasOwnProperty(prop)){