26th
Feb 2016
alpox
@alpox
Feb 26 2016 00:03
@gsc229 It seems that you try to figure out if there is another item like the one you got as parameter in the filter function but in the for you don't test if the index is the index which the variable "item" has in the array. So your filter function will always return true.
Greg
@gsc229
Feb 26 2016 00:04
@alpox I did that because without the adding the .split, when I did joinArss.indexOf(",") it gave me the index of a comma.
Dmytro Pechunka
@simon1400
Feb 26 2016 00:04

I do not understand what the problem.
A task: Sum all the prime numbers up to and including the provided number.
function sumPrimes(num) {

var mass = [];
for(var i = 1; i <= num; i++){
mass[i - 1] = i;
}

var newMass = [];

for(var j = 0; j < mass.length; j++){
if(mass[j] % 2 === 0){
newMass.push(mass[j]);
}
}

var result = 0;
for(var a = 0; a < newMass.length; a++){
result += newMass[a];
}

return result;

}

sumPrimes(10);

Greg
@gsc229
Feb 26 2016 00:04
@alpox cool thanks!
CamperBot
@camperbot
Feb 26 2016 00:04
gsc229 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star: 56 | @alpox | http://www.freecodecamp.com/alpox
Dmytro Pechunka
@simon1400
Feb 26 2016 00:05
my result 30
it should be 17
alpox
@alpox
Feb 26 2016 00:05
@gsc229 joinAss.indexOf(",") doesnt seem to make much sense since you handle number arrays
A-Alex-A
@A-Alex-A
Feb 26 2016 00:06
@simon1400 how do you check a prime number?
Orestis Gklavas
@oglavas
Feb 26 2016 00:06
@gsc229 @alpox As I said, I would use concat() to merge the arrays
@simon1400 a prime number is one which is divisible only by 1 and itself
@simon1400 for example 1, 3,5,7. What you are checking for, is an EVEN number
Dmytro Pechunka
@simon1400
Feb 26 2016 00:08
understand!) how do I check for a prime number?
alpox
@alpox
Feb 26 2016 00:09
@oglavas Yes. Concat would be the way to go
Greg
@gsc229
Feb 26 2016 00:10
@oglavas the problem with using .concat() is that you don't know how many arrays will initially be thrown into the function. I know it says (arr1, arr2, arr3) but the exercise wants you to take on more arrays than whats just in the parameters of the function.
Orestis Gklavas
@oglavas
Feb 26 2016 00:10
@simon1400 Well, one way would be to try to divide the number you are checking with every number between 2 and num/2
@gsc229 and that's where the arguments.length property will come into play!
A-Alex-A
@A-Alex-A
Feb 26 2016 00:10
@simon1400 you can google for some algorithms or use straitforward approach - check if numbers below divides the number (or you can check only first half of the number)
Dmytro Pechunka
@simon1400
Feb 26 2016 00:11
I'm going to try now)
Orestis Gklavas
@oglavas
Feb 26 2016 00:12
Greg
@gsc229
Feb 26 2016 00:12
@oglavas okay, that's fine I could do that but that's not where I'm having trouble, I've gotten all the arrs combined into one big one fine, but where I'm having trouble is filtering out the duplicates. Thnx for the help btw
CamperBot
@camperbot
Feb 26 2016 00:12
gsc229 sends brownie points to @oglavas :sparkles: :thumbsup: :sparkles:
:star: 316 | @oglavas | http://www.freecodecamp.com/oglavas
Orestis Gklavas
@oglavas
Feb 26 2016 00:14
@gsc229 You could push the "first appearances" of each number to a second array as you loop through the first one (a quick thought, can't remember how I did it)
alpox
@alpox
Feb 26 2016 00:15
@oglavas I see that i even came around concat in my solution
Orestis Gklavas
@oglavas
Feb 26 2016 00:17
@alpox Unfortunately I can't see my solution (it appears blank). Probably because my current session is on a different PC than the one I was working with
Norman Dela Cruz
@dcnr
Feb 26 2016 00:18
@oglavas If your solution passed and you've submitted it, it should be viewable on your profile unless you've disabled it
Orestis Gklavas
@oglavas
Feb 26 2016 00:20
@dcnr @alpox OK, I'm an idiot!!! I jumped into coding without touring the site much...I was going through the map to try and see my solutions...got it now!!!
alpox
@alpox
Feb 26 2016 00:21
@oglavas It seems i had a bit more overhead than you :D
Orestis Gklavas
@oglavas
Feb 26 2016 00:23
@alpox Oh, it depends...sometimes I get moments of clarity and sometimes my solutions are absolutely crappy!
Norman Dela Cruz
@dcnr
Feb 26 2016 00:25
eh I don't like my sorted union solution too :(
alpox
@alpox
Feb 26 2016 00:27
@oglavas Well sometimes mine are too :D And code style depends on if you want clarity or performance. Your solution is perfect for performance
Gaurav Singh
@the07
Feb 26 2016 00:28
I need help, can someone tell me if this is the right way.
  $(document).ready(function() {$("#getMessage").on("click", function(){
// Only change code below this line.

$.getJSON("http://quotesondesign.com/api/3.0/api-3.0.json", function(json) {$(".message").html(JSON.stringify(json));
});

// Only change code above this line.
});

});
alpox
@alpox
Feb 26 2016 00:30
@the07 looks okay but check that there are not more elements with the class "message" applied. Otherwise they will all get the same content
@the07 You usually use id's for elements which you have to address like that
Gaurav Singh
@the07
Feb 26 2016 00:30
Nope, just one element. But this does not work. Tried it with id’s as well
Orestis Gklavas
@oglavas
Feb 26 2016 00:32
OK, everybody...I have to get to bed (2.30am already!) Good night (or afternoon, or morning, depending on location)!
alpox
@alpox
Feb 26 2016 00:32
I have 1:30 :D
good night!
@the07 Did you try to request on page-load and just log the response for that you see if you get one?
Gaurav Singh
@the07
Feb 26 2016 00:33
@alpox for some reason it does not work.
alpox
@alpox
Feb 26 2016 00:34
@the07 It seems your url may be wrong for this purpose:
Blocked loading mixed active content "http://quotesondesign.com/api/3.0/api-3.0.json"
Robert Valmassoi
@valmassoi
Feb 26 2016 00:35
Can someone review my successful code for 'Friendly Date Range' (there is no wiki for it)?
This message was deleted

function friendly(arr) {
var mo = ['January ', 'February ', 'March ', 'April ', 'May ', 'June ', 'July ', 'August ', 'September ', 'October ', 'November ', 'December '];//space after
var dateOne= arr[0].split("-");
var dateTwo= arr[1].split("-");
var yrOne=dateOne[0];
var yrTwo=dateTwo[0];
var moOne=parseInt(dateOne[1], 10);//base ten: 07 becomes 7
var moTwo=parseInt(dateTwo[1], 10);
var dayOne=parseInt(dateOne[2], 10);
var dayTwo=parseInt(dateTwo[2], 10);
var strOne="";
var strTwo="";
var days = ['1st', '2nd', '3rd'];

// ----- YEAR -----  //

if(moTwo<=moOne && yrTwo-1==yrOne && yrOne==2016){//removes years
if(moTwo==moOne && dayTwo>dayOne){
}else{
yrOne = "";
yrTwo = "";}
}
else if(yrTwo==yrOne && yrOne==2016){//removes years
yrOne = "";
yrTwo = "";

}
else if(moTwo==moOne && yrTwo-1==yrOne){//removes year Two
if(dayTwo<dayOne){
yrOne = ", "+ yrOne;
yrTwo = "";
}
if(dayTwo==dayOne){
yrOne = ", "+ yrOne;
yrTwo = ", "+ yrTwo;
}
}
else if(yrTwo==yrOne){//removes years
yrOne = ", " + yrOne;
yrTwo = "";
}
yrOne = ", " + yrOne;
yrTwo = ", " + yrTwo;
}

// ----- MONTH -----  //

moOne = mo[moOne-1];//converts to spelled out
moTwo = mo[moTwo-1];

if (moOne == moTwo && yrOne==yrTwo){//removes month two
moTwo = "";
}

// ----- DAY -----  //

if(dayOne<4){//1st 2nd 3rd 4th nth
dayOne=days[dayOne-1];
}else{
dayOne+="th";
}
if(dayTwo<4){
dayTwo=days[dayTwo-1];
}else{
dayTwo+="th";
}

// ---- COMBINE ---- //

strOne = moOne + dayOne + yrOne;
strTwo = moTwo + dayTwo + yrTwo;
if (arr[0]==arr[1]){
return [strOne];
}else{
return [strOne, strTwo];
}
}

friendly(["2017-03-01", "2017-05-05"]) ;
i just kept using if statements, I bet i could combine a few but is there a different way I was missing?
matthew3454
@matthew3454
Feb 26 2016 00:36
@alpox I almost figured it out but there is a one error left. The instructions say: palindrome("1 eye for of 1 eye.") should return false. Here is my code:
function palindrome(str) {
// Good luck!

str = str.toLowerCase().replace(/[^a-z]+/g,"");
return str === str.split("").reverse().join("")
}

palindrome("eye");
alpox
@alpox
Feb 26 2016 00:36
@the07 I see the matter. Its the usual case. You have to request with dataType = "jsonp" -> use the $.ajax request instead of$.getJSON and put the dataType: "json" into the request object.
EmilVee
@EmilVee
Feb 26 2016 00:39
Alright, so can someone give me a nudge in the right direction for the Mutations bonfire?
function mutation(arr) {
firstElement = arr[0].toLowerCase();
secondElement = arr[1].toLowerCase();

return count;
}

mutation(["hello", "hell"]);
matthew3454
@matthew3454
Feb 26 2016 00:39
I used a string extension approach for my code above.
Gaurav Singh
@the07
Feb 26 2016 00:39
@alpox Thanks I will try doing that.
CamperBot
@camperbot
Feb 26 2016 00:39
the07 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star: 57 | @alpox | http://www.freecodecamp.com/alpox
alpox
@alpox
Feb 26 2016 00:40
@matthew3454 numbers have to be included, as well as letters. Don't replace them and you're fine
matthew3454
@matthew3454
Feb 26 2016 00:41
@alpox Do you mean the previous regular expresions I was using as arguments?
alpox
@alpox
Feb 26 2016 00:42
@matthew3454 Sorry, i cannot follow you. What is with arguments?
matthew3454
@matthew3454
Feb 26 2016 00:43
The feeling is mutual. Could you just type me the code that I'm missing?
alpox
@alpox
Feb 26 2016 00:43
@EmilVee The beginning is fine. Try now to look up if every letter in the secondElement is included in the firstElement
daiwik
@daiwik
Feb 26 2016 00:43
$("document").ready(function(){ var longitude = 0; var latitude = 0; var apiLink = ""; function getCoords(){ navigator.geolocation.getCurrentPosition(function(position){ longitude = position.coords.longitude; latitude = position.coords.latitude; apiLink = "http://api.openweathermap.org/data/2.5/weather?lat=" + latitude + "&lon=" + longitude + "&appid=" + "bc17c49f463c04276781b5f2c35e82a8"; console.log("apiLink"); }); }$.getJSON(apiLink,function(){
console.log("succes");
})
$.getJSON( "example.json", function() { console.log( "success" ); }) .done(function() { console.log( "second success" ); }) .fail(function() { console.log( "error" ); }); }); I am always getting error can anyonehelp matthew3454 @matthew3454 Feb 26 2016 00:43 function palindrome(str) { // Good luck! str = str.toLowerCase().replace(/[^a-z]+/g,""); return str === str.split("").reverse().join(""); } palindrome("eye"); alpox @alpox Feb 26 2016 00:44 @matthew3454 I'm not going to solve things for you :-) But now in your regexp you are replacing everything which is not a lowercase-letter. But you should not return uppercase or numbers Norman Dela Cruz @dcnr Feb 26 2016 00:44 @matthew3454 by doing /[^a-z]+/ you also removed the numbers. You're only supposed to remove punctuation and spaces. Moisés Man @moigithub Feb 26 2016 00:44 @EmilVee u need to check if every char from first word is on second.. ie. hello::: h is on "hell" e is on "hell" l is on "hell" o is on "hell" <-- this fail so if at least one fail.. then ur function should return false.. cuz not ALL char from first is on second matthew3454 @matthew3454 Feb 26 2016 00:45 @dcnr okay. What should I do instead? \w? Norman Dela Cruz @dcnr Feb 26 2016 00:45 @matthew3454 you should modify your regex pattern so it doesn't remove numbers too alpox @alpox Feb 26 2016 00:45 @daiwik I suppose your variable "apiLink" is not defined when you make the request. you set it in the async function getCurrentPosition, which gets executed AFTER all the setup below it. matthew3454 @matthew3454 Feb 26 2016 00:46 okay. alpox @alpox Feb 26 2016 00:46 @matthew3454 no. read the parts in the MDN for [], [^] etc. @matthew3454 [^xyz], [^a-c]: A negated or complemented character set. That is, it matches anything that is not enclosed in the brackets. You can specify a range of characters by using a hyphen, but if the hyphen appears as the first or last character enclosed in the square brackets it is taken as a literal hyphen to be included in the character set as a normal character. matthew3454 @matthew3454 Feb 26 2016 00:48 @alpox alright thanks CamperBot @camperbot Feb 26 2016 00:48 matthew3454 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles: :star: 58 | @alpox | http://www.freecodecamp.com/alpox daiwik @daiwik Feb 26 2016 00:48 @alpox you are awesome thanks :D CamperBot @camperbot Feb 26 2016 00:48 daiwik sends brownie points to @alpox :sparkles: :thumbsup: :sparkles: :star: 59 | @alpox | http://www.freecodecamp.com/alpox alpox @alpox Feb 26 2016 00:48 You're all welcome :-) Eric @Code-Eric Feb 26 2016 00:48 function queue(arr, item) { // Your code here arr.push(item); arr.shift(item); arr.unshift(); return item; // Change this line } // Test Setup var testArr = [1,2,3,4,5]; how do i return the original item back? help unshift CamperBot @camperbot Feb 26 2016 00:49 ## :point_right: challenge manipulate arrays with unshift() [wiki] # Manipulate Arrays With unshift() myArray.unshift('Paul'); Basically you call unshift and pass what was deleted. alpox @alpox Feb 26 2016 00:49 @Code-Eric better take a look at arr.shift() Norman Dela Cruz @dcnr Feb 26 2016 00:50 @matthew3454 This is actually fine .replace(/[^a-z]+/g,"") you just have to account for the number range too. Did you make the [^a-z] part yourself? Eric @Code-Eric Feb 26 2016 00:50 @alpox it isnt supposed to be item? alpox @alpox Feb 26 2016 00:50 @Code-Eric Array.shift() "The shift() method removes the first element from an array and returns that element. This method changes the length of the array." Richard Corbett @reacorbett Feb 26 2016 00:52 function findLongestWord(str) { var array = str.split(" "); for(index = 0; index < array.length; index++){ arr = array[index].length; } return arr; } findLongestWord("The quick brown fox jumped over the lazy dog"); return arr; gives me the length of the last word in my array. but I need the length of the longest word in my array. can someone push me in the right direction? alpox @alpox Feb 26 2016 00:52 @reacorbett make a variable in which you can store the length and test it for if its bigger as the current in loop I have the feeling that i'm the only one here answering questions :D but i wanted to go to bed! Richard Corbett @reacorbett Feb 26 2016 00:53 @alpox go to bed. Eric @Code-Eric Feb 26 2016 00:54 @alpox Im sorry I honestly dont get the significance of that. Is there anything I should go back to understand more? Or any other way you have of helping me? alpox @alpox Feb 26 2016 00:55 @Code-Eric If the link i gave you doesnt help you, you should go back in the map and find something about how to use and call functions :-) Eric @Code-Eric Feb 26 2016 00:58 @alpox Thank you! I understood what i was missing with that last link! CamperBot @camperbot Feb 26 2016 00:58 code-eric sends brownie points to @alpox :sparkles: :thumbsup: :sparkles: :star: 60 | @alpox | http://www.freecodecamp.com/alpox alpox @alpox Feb 26 2016 00:58 @Code-Eric Great! :D So that was it for me. I'm out! Have a good time :-) Paul Brown @paulbwd Feb 26 2016 01:06 can anyone help me with seek and destroy please? Richard Corbett @reacorbett Feb 26 2016 01:13 @alpox. I FINALLY GOT IT!!!!!!!!!! Thanks CamperBot @camperbot Feb 26 2016 01:13 reacorbett sends brownie points to @alpox :sparkles: :thumbsup: :sparkles: :star: 61 | @alpox | http://www.freecodecamp.com/alpox Paul Brown @paulbwd Feb 26 2016 01:15 does anyone know how i can access the arguments array in a filter? Moisés Man @moigithub Feb 26 2016 01:20 @paulbwd post ur code ? Paul Brown @paulbwd Feb 26 2016 01:20 hi @moigithub function destroyer(arr) { // Remove all the values var myArray = arr.filter(function(num){ return num !== 2 && num !== 3; }); return myArray; } destroyer([1, 2, 3, 1, 2, 3], 2, 3); i just dont understand how i can access the arguments array to replace the static numbers i have in there to test the function at the moment Moisés Man @moigithub Feb 26 2016 01:21 @paulbwd every function has its own copy of arguments OBJect u access it like an array.. Dustin @Key-Banger Feb 26 2016 01:21 @paulbwd you can access each argument by just using it. Paul Brown @paulbwd Feb 26 2016 01:22 thats what i mean tho, the filter has its own function? Norman Dela Cruz @dcnr Feb 26 2016 01:22 @paulbwd if you want to use destroyer's arguments (inside filter), you would have to assign it another name/convert it/whatever as long as it's not named arguments Moisés Man @moigithub Feb 26 2016 01:22 so arguments[0] will return [1, 2, 3, 1, 2, 3] arguments[1] will return 2 arguments[2] will retur 3 Paul Brown @paulbwd Feb 26 2016 01:23 where does arguments[2] come from Dustin @Key-Banger Feb 26 2016 01:23 @paulbwd function destroyer(arr,a,b,c) { a = 2; b = 3; } destroyer([1, 2, 3, 1, 2, 3], 2, 3); Moisés Man @moigithub Feb 26 2016 01:23 @paulbwd arguments is an object ... comes with javascript Paul Brown @paulbwd Feb 26 2016 01:23 yes but the function only has 2 arguments or was you just paraphrasing lol Norman Dela Cruz @dcnr Feb 26 2016 01:24 @paulbwd it has 3 because of this destroyer([1, 2, 3, 1, 2, 3], 2, 3); ^ ^ ^ arguments 0 1 2 Moisés Man @moigithub Feb 26 2016 01:24 argumetns object contains a copy of whatever list of data u pass to ur funciton... even if not declared on the function header Paul Brown @paulbwd Feb 26 2016 01:25 I see so am i far off it? Moisés Man @moigithub Feb 26 2016 01:26 so.. if u have a function example.... function hello() { // <-- without arguments on the () console.log(arguments); } // test call hello("one","2","three","4","five"); it will still output the list below.. (on the call ) Paul Brown @paulbwd Feb 26 2016 01:29 so will i need to make a new array that holds any arguments above 0 and thanks @moigithub and @dcnr for the pointers so far CamperBot @camperbot Feb 26 2016 01:30 paulbwd sends brownie points to @moigithub and @dcnr :sparkles: :thumbsup: :sparkles: :star: 669 | @moigithub | http://www.freecodecamp.com/moigithub :star: 729 | @dcnr | http://www.freecodecamp.com/dcnr Dustin @Key-Banger Feb 26 2016 01:32 @paulbwd without giving it all away, you don't really need to use the index of the argument to use it. return num !== a Sam Ringleman @theRingleman Feb 26 2016 01:32 @dcnr function lookUp(firstName, prop){ // Only change code below this line var contact = false; var property = false; for(var i = 0; i < contacts.length; i++){ if(firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop)){ return contacts[i][prop]; }else if(firstName === contacts[i].firstName){ contact = "true"; }else if(contacts[i][prop] === prop){ property = "true"; } } if(!contact){ return "No such contact"; } if(!property){ return "No such property"; } // Only change code above this line } @dncr I finally got it!!! Norman Dela Cruz @dcnr Feb 26 2016 01:32 @paulbwd since each function has its own arguments object, you would need to alias or turn your arguments object into an array so you can access it inside another (inner) function @theRingleman nice! That's one way to do it :D congratulations! Sam Ringleman @theRingleman Feb 26 2016 01:33 @dcnr Thank you sir I appreciate your help!! CamperBot @camperbot Feb 26 2016 01:33 theringleman sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles: :star: 730 | @dcnr | http://www.freecodecamp.com/dcnr Paul Brown @paulbwd Feb 26 2016 01:34 @dcnr yeah thats what i was hinting at @Key-Banger I have no idea what you mean by that :S Richard Corbett @reacorbett Feb 26 2016 01:37 How long until this becomes easier?? Norman Dela Cruz @dcnr Feb 26 2016 01:37 you're welcome, thank you too! @theRingleman CamperBot @camperbot Feb 26 2016 01:37 dcnr sends brownie points to @theringleman :sparkles: :thumbsup: :sparkles: :star: 233 | @theringleman | http://www.freecodecamp.com/theringleman Norman Dela Cruz @dcnr Feb 26 2016 01:38 @reacorbett if it becomes easier, you have to find a way to make it harder again Dustin @Key-Banger Feb 26 2016 01:38 @paulbwd function destroyer(arr,a,b,c) { // Remove all the values var myArray = arr.filter(function(num){ return num !== a; }); return myArray; } destroyer([1, 2, 3, 1, 2, 3], 2, 3); does that make a little more sense? Paul Brown @paulbwd Feb 26 2016 01:43 ah yeah, I see what you mean now, I wondered why arr just held the first array thanks @Key-Banger CamperBot @camperbot Feb 26 2016 01:43 paulbwd sends brownie points to @key-banger :sparkles: :thumbsup: :sparkles: :star: 316 | @key-banger | http://www.freecodecamp.com/key-banger Paul Brown @paulbwd Feb 26 2016 01:44 so a, b, c would be the other arguments that i need to test for Dustin @Key-Banger Feb 26 2016 01:44 @paulbwd here is a better visual like what @dcnr said earlier about arguments. function destroyer(arr,a,b,c) { } destroyer([3, 5, 1, 2, 2], 2, 3, 5); ^ ^ ^ ^ arr a b c Paul Brown @paulbwd Feb 26 2016 01:45 yeah I get it now, thanks a lot guys im sure ill get it done now before i go to bed lol its quite obvious really, i was just thinking the whole thing was being passed into the arr parameter, which of course it isnt at all Dustin @Key-Banger Feb 26 2016 01:47 @paulbwd you'll get it for sure now. Maybe even get another challenge done. ;) Paul Brown @paulbwd Feb 26 2016 01:47 function destroyer(arr, a, b, c) { // Remove all the values myArgs = arguments; var myArray = arr.filter(function(num){ return num !== a && num !== b && num !== c; }); return myArray; } destroyer([1, 2, 3, 1, 2, 3], 2, 3); sorted :D ooops some left over code in there, ill whip that out but im happy now lol Norman Dela Cruz @dcnr Feb 26 2016 01:50 @paulbwd while that works, you changed destroyer's signature by adding more parameters! It would be better if you restrict yourself to what's given to you and learn to use the arguments object :P @paulbwd because you can't always change a function's argument list, say for example you're working with other's code, or using a library, or some such Paul Brown @paulbwd Feb 26 2016 01:51 yeah, I was about to crack it the other way too ;) but I learned a lot in that last 20 mins for my own future code writing so thanks guys much appreciated Norman Dela Cruz @dcnr Feb 26 2016 01:53 awesome! :D Dustin @Key-Banger Feb 26 2016 01:53 @dcnr I'm interested in knowing what you mean. Something using arguments.length and iterating through? Paul Brown @paulbwd Feb 26 2016 01:54 night guys Dustin @Key-Banger Feb 26 2016 01:54 Good night. Norman Dela Cruz @dcnr Feb 26 2016 01:56 @Key-Banger you can look at my solution :D It's basically just converting the arguments object to an array named args, then using filter on arr and removing the items that should be removed given by args mlutso @mlutso Feb 26 2016 01:57 Hi. What's wrong in my code? i have error :"TypeError:Attempted to assign to readonly property." var collection = { 2548: { album: "Slippery When Wet", artist: "Bon Jovi", tracks: [ "Let It Rock", "You Give Love a Bad Name" ] }, 2468: { album: "1999", artist: "Prince", tracks: [ "1999", "Little Red Corvette" ] }, 1245: { artist: "Robert Palmer", tracks: [ ] }, 5439: { album: "ABBA Gold" } }; var collectionCopy = JSON.parse(JSON.stringify(collection)); function update(id, prop, value) { if (prop === "tracks" && value !== "") { collection[id][prop].push(value); } else if (value !== ""){ collection[id][prop] = value; } else { delete collection[id][prop]; } return collection; } update(5440, "artist", "ABBA"); Norman Dela Cruz @dcnr Feb 26 2016 01:58 @mlutso you can format your code by doing js <paste code here>  Those are 3 backquotes, the key above tab, left of 1, and below esc. You can create a new line by shift+enter so to format it'll be: js (shift+enter)(paste code)(shift+enter)  Dustin @Key-Banger Feb 26 2016 01:58 @dcnr I'll check it out for sure. Thanks! CamperBot @camperbot Feb 26 2016 01:58 key-banger sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles: :star: 731 | @dcnr | http://www.freecodecamp.com/dcnr Richard Corbett @reacorbett Feb 26 2016 01:58 on the "Title Case a Sentence" challenge, should i be using regular expressions? Norman Dela Cruz @dcnr Feb 26 2016 01:59 @mlutso your code passes for me, maybe try a browser refresh? @reacorbett you can, but it's up to you! Devin @devblanchard Feb 26 2016 01:59 so i am trying to figure out this golf code exercise out. i think i am right in assuming i need to chain several if/else if statements, but I am struggling to properly define the conditions. i thought they looked right, but it only works for the hole in one. any idea where i can get a better understanding of how i could write it? Norman Dela Cruz @dcnr Feb 26 2016 02:00 @devblanchard hi will you post your code? you can format your code by doing js <paste code here>  Those are 3 backquotes, the key above tab, left of 1, and below esc. You can create a new line by shift+enter so to format it'll be: js (shift+enter)(paste code)(shift+enter)  Devin @devblanchard Feb 26 2016 02:01 i have been trying different things so give me a second to get back to what i thought should work. Eric @Code-Eric Feb 26 2016 02:01 I have been stuck on this for far too long, help!!!! function queue(arr, item) { // Your code here arr.shift(); arr.push(item); return r; // Change this line prompt:Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed. honestly, SOS. Brian @sludge256 Feb 26 2016 02:02 what does return r; do? Collin @collinferry Feb 26 2016 02:02 Any reason why the following wouldn't work to ask, "is the first letter in this string upper case?" if (str.charAt(0) == str.charAt(0).toUpperCase()) {}; Eric @Code-Eric Feb 26 2016 02:03 oh, that was my bad, its supposed to be return item Norman Dela Cruz @dcnr Feb 26 2016 02:03 @sludge256 is that an avocado?! Brian @sludge256 Feb 26 2016 02:03 Yes or a screaming green egg take your pick Collin @collinferry Feb 26 2016 02:03 @sludge256 I choose avocados because they're the most superior fruit Eric @Code-Eric Feb 26 2016 02:03 i forgot to change that back. I am stuck on trying to get it to retun the element of the array that was removed Norman Dela Cruz @dcnr Feb 26 2016 02:04 I love avocados with condensed milk Brian @sludge256 Feb 26 2016 02:04 So arr.shift(); will remove the first element of an array and it will also return that element Eric @Code-Eric Feb 26 2016 02:04 yes Brian @sludge256 Feb 26 2016 02:04 but you're not assigning it to a variable so it "disappears" Eric @Code-Eric Feb 26 2016 02:05 ahh mlutso @mlutso Feb 26 2016 02:05 @dcnr i tried to refresh. it's not help. which browser you use? i use Safari on Mac OS. maybe it's depend somehow? Eric @Code-Eric Feb 26 2016 02:06 im pretty sure I tried that but its not working function queue(arr, item) { // Your code here arr.shift(); arr.push(item); var disappear = arr.shift(); return disappear; // Change this line } or am i doing something incorrectly? Moisés Man @moigithub Feb 26 2016 02:07 u "shifting" 2 times @Code-Eric Norman Dela Cruz @dcnr Feb 26 2016 02:07 @mlutso hmm I'm on linux but it works on Firefox and Chrome for me, maybe you can RESET then refresh then just paste your function again? function update(id, prop, value) { if (prop === "tracks" && value !== "") { collection[id][prop].push(value); } else if (value !== "") { collection[id][prop] = value; } else { delete collection[id][prop]; } return collection; } your solution works for me Devin @devblanchard Feb 26 2016 02:08 function golfScore(par, strokes) { // Only change code below this line if (1) { return "Hole-in-one!"; } else if (par-2) { return "Eagle"; } else if (par-1) { return "Birdie"; } else if (par) { return "Par"; } else if (par) { return "Bogey"; } else if (par+2) { return "Double Bogey"; } else return "Go Home!"; // Only change code above this line } // Change these values to test golfScore(5, 4); I can't seem to wrap my head around how variables can work with the conditions. Brian @sludge256 Feb 26 2016 02:08 You'll want to compare the two variables against each other Norman Dela Cruz @dcnr Feb 26 2016 02:09 @devblanchard you're supposed to compare strokes with par according to the table given Eric @Code-Eric Feb 26 2016 02:09 @moigithub how do i unshift it then mlutso @mlutso Feb 26 2016 02:09 @dcnr thanks. it's work CamperBot @camperbot Feb 26 2016 02:09 mlutso sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles: :star: 732 | @dcnr | http://www.freecodecamp.com/dcnr Norman Dela Cruz @dcnr Feb 26 2016 02:09 nice! thanks too @mlutso Moisés Man @moigithub Feb 26 2016 02:10 remove first shift statement should work @Code-Eric so on ur code.. u only have 1 shift and 1 push Devin @devblanchard Feb 26 2016 02:10 ok. i have been trying to do that a few different ways because it makes sense that i need to, but they haven't been working so far. i will keep working towards that. thanks @dcnr @sludge256 CamperBot @camperbot Feb 26 2016 02:10 devblanchard sends brownie points to @dcnr and @sludge256 :sparkles: :thumbsup: :sparkles: :star: 1654 | @sludge256 | http://www.freecodecamp.com/sludge256 :star: 733 | @dcnr | http://www.freecodecamp.com/dcnr Eric @Code-Eric Feb 26 2016 02:10 thank you very very much @moigithub CamperBot @camperbot Feb 26 2016 02:10 code-eric sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles: :star: 670 | @moigithub | http://www.freecodecamp.com/moigithub Brian @sludge256 Feb 26 2016 02:10 @collinferry seems to work https://repl.it/BqZn/0 Norman Dela Cruz @dcnr Feb 26 2016 02:10 good luck! and thanks too @devblanchard CamperBot @camperbot Feb 26 2016 02:10 dcnr sends brownie points to @devblanchard :sparkles: :thumbsup: :sparkles: :star: 201 | @devblanchard | http://www.freecodecamp.com/devblanchard Collin @collinferry Feb 26 2016 02:12 @sludge256 great resource, thank you sir CamperBot @camperbot Feb 26 2016 02:12 collinferry sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles: :star: 1655 | @sludge256 | http://www.freecodecamp.com/sludge256 tia @tvdeleon24 Feb 26 2016 02:14 hey guys. need some help with "adding default option in switch statements" here is my code. not sure what i'm doing wrong. sorry i couldn't screen shot. blahfunction myTest(val) { var answer = ""; // Only change code below this line switch(val){ case "a": answer = "apple"; break; } switch(val){ case "b": answer = "bird"; break; } switch(val){ case "c": answer = "cat"; break; } switch (val){ case "d": break; default: answer = "stuff"; } switch (val){ case 4: break; default: answer = "stuff"; } } // Change this value to test myTest(4); Brian @sludge256 Feb 26 2016 02:18 You're not returning anything David Jones @Finesse-One Feb 26 2016 02:20 Hello everyone I have a problem with one of my if else statement for the golf challenge. Everything seems to be right except for golfScore(4,5) which return "Bogey". If someone can point me in the right direction I would really appreciate it thanks. js function golfScore(par, strokes) { // Only change code below this line if(strokes == 1){ return "Hole-in-one!"; } else if(strokes <= 2 && par <= 5){ return "Eagle"; } else if(strokes <= 3 && par <= 4){ return "Birdie"; } else if(strokes <= 5 && par <= 5){ return "Par"; } else if(strokes == 5 && par == 4 ){ return "Bogey"; } else if(strokes <= 6 && par <= 4){ return "Double Bogey"; } else if( strokes <= 9 && par <= 9){ return "Go Home!"; } return "Change Me"; // Only change code above this line } // Change these values to test golfScore(4 ,5);  tia @tvdeleon24 Feb 26 2016 02:23 @sludge256 you are so right! must have accidentally deleted it. I inserted return answer; where it belongs. but now my a, b and c and returning "stuff". are* Brian @sludge256 Feb 26 2016 02:25 @Finesse-One You should be comparing strokes and par against each other not against numbers @tvdeleon24 You only need one switch statement that encompasses all the cases David Jones @Finesse-One Feb 26 2016 02:26 well it seem to be working out so far but except for the one I have mentioned. cannelflow @cannelflow Feb 26 2016 02:27 @sludge256 is right compare par against each other @Finesse-One @Finesse-One how you decided value of par and stroke David Jones @Finesse-One Feb 26 2016 02:29 The logic I was thinking was if I was playing Gold, I would consider the amount of strokes it would take me to get to a particular hole. Then I would compare the par to see if I went over par or under par. cannelflow @cannelflow Feb 26 2016 02:32 @Finesse-One like if you pass golfScore(5, 4); par is 4 stroke is 5 and then let code decide David Jones @Finesse-One Feb 26 2016 02:32 Remember this is just my reasoning, I could be totally wrong altogether. cannelflow @cannelflow Feb 26 2016 02:32 @Finesse-One np @Finesse-One so you have to compare par and strokes against each other David Jones @Finesse-One Feb 26 2016 02:33 yes. cannelflow @cannelflow Feb 26 2016 02:33 @Finesse-One and in your case you are comparing them against separate number tia @tvdeleon24 Feb 26 2016 02:33 @sludge256 thanks for the help! that helped me solved that. yay! CamperBot @camperbot Feb 26 2016 02:33 tvdeleon24 sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles: :star: 1658 | @sludge256 | http://www.freecodecamp.com/sludge256 David Jones @Finesse-One Feb 26 2016 02:34 yes. As you mention above that I have compare par and strokes against each other, can you give me an example of this so I can understand better thanks. cannelflow @cannelflow Feb 26 2016 02:38 first condition is strokes==1 then it says like strokes<=par-2 like that and pls mention name while chat so that ppl can get notified @Finesse-One David Jones @Finesse-One Feb 26 2016 02:40 okay cannelflow @cannelflow Feb 26 2016 02:44 @Finesse-One worked? David Jones @Finesse-One Feb 26 2016 02:45 @cannelflow I @cannelflow I am working as you speak. cannelflow @cannelflow Feb 26 2016 02:45 @Finesse-One :+1: Vincent Lingle-Munos @valmunos Feb 26 2016 02:53 hey can someone explain this to me? I'm working on the Exact Change algorithm, and it's doing something really weird on one of the tests. Here's my code: function drawer(price, cash, cid) { var change = cash - price; var increment = [0.01, 0.05, 0.10, 0.25, 1.00, 5.00, 10.00, 20.00, 100.00]; var bills = 0; var count = 0; var ledger = []; for (i = 8; i >= 0; i--) { if (change >= increment[i] && cid[i][1] > 0) { bills = cid[i][1]/increment[i]; count = bills; while (count > 0 && change > 0) { change = change - increment[i]; if (change < 0) { change = change + increment[i]; break; } count = count - 1; } ledger.push([cid[i][0], (bills-count)*increment[i]]); } } // Here is your change, ma'am. return ledger; } drawer(3.26, 100.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]); Change "return ledger" to "return change" to see what I mean Richard Corbett @reacorbett Feb 26 2016 02:57 what does /\S*\/ do? /\S*/ bitgrower @bitgrower Feb 26 2016 03:01 @reacorbett ... I'm sure one of these resources will tell you ... more accurately than my fragile memory ... help regex CamperBot @camperbot Feb 26 2016 03:01 ## :point_right: js regex resources [wiki] Links to useful RegEx resources. See also: :clipboard: Tutorials | :syringe: Testing | :soccer: Games | :newspaper: Blogs | :package: Software Richard Corbett @reacorbett Feb 26 2016 03:02 @bitgrower I found info on it, I just don't understand it. bitgrower @bitgrower Feb 26 2016 03:02 what's the info you found say about it ? That sounds like a place to start ... Devin @devblanchard Feb 26 2016 03:03 thanks @munishtayal you helped me by helping someone earlier CamperBot @camperbot Feb 26 2016 03:03 devblanchard sends brownie points to @munishtayal :sparkles: :thumbsup: :sparkles: :star: 324 | @munishtayal | http://www.freecodecamp.com/munishtayal Yaoming Jiang @yao4ming Feb 26 2016 03:04 \s stands for non-whitespace character, * means zero or more sorry i meant \S bitgrower @bitgrower Feb 26 2016 03:06 have you played around on any of the regex tester sites, @reacorbett ? They can help give you a good visual as to what will be matched ... also the regexone.com tutorial is quite good ... Richard Corbett @reacorbett Feb 26 2016 03:07 I will have to check that out. thanks @bitgrower CamperBot @camperbot Feb 26 2016 03:07 reacorbett sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles: :star: 644 | @bitgrower | http://www.freecodecamp.com/bitgrower Richard Corbett @reacorbett Feb 26 2016 03:13 @bitgrower that is pretty cool. I think i will be playing with that for the rest of the night. David Jones @Finesse-One Feb 26 2016 03:32 @cannelflow I finally got it! Thanks for pointing me in the right direction I really appreciate it. CamperBot @camperbot Feb 26 2016 03:32 finesse-one sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles: :star: 829 | @cannelflow | http://www.freecodecamp.com/cannelflow Vik @vvang044 Feb 26 2016 03:37 hey guys can anyone help me with "condese arrays with reduce" *condense Devin @devblanchard Feb 26 2016 03:38 thanks @rphares for helping me indirectly by helping some earlier CamperBot @camperbot Feb 26 2016 03:38 devblanchard sends brownie points to @rphares :sparkles: :thumbsup: :sparkles: :star: 2972 | @rphares | http://www.freecodecamp.com/rphares Vik @vvang044 Feb 26 2016 03:39 hey @rphares akulaggarwal @akulaggarwal Feb 26 2016 03:41 hey guys, i just had a quick question. i had thought that completing all the algorithm questions was required to obtain the front end dev cert. but i dont see an asterisk next to the "advanced" section, only on the coding challenges i have left. i intend on doing the adv algo challenges either way, but can anyone confirm either way? akulaggarwal @akulaggarwal Feb 26 2016 03:46 or maybe i should be asking on one of the other ones? like FCC Help? scottmike0 @scottmike0 Feb 26 2016 03:47 i believe they are required akulaggarwal @akulaggarwal Feb 26 2016 03:48 ahh i think i just got my answer. on the certificate page: "This challenge will give you your verified Front End Development Certificate. Before we issue your certificate, we must verify that you have completed all of our basic and intermediate algorithm scripting challenges, and all our basic, intermediate, and advanced front end development projects." scottmike0 @scottmike0 Feb 26 2016 03:48 @akulaggarwal ye the advanced and intermediate algorithms dont seem to be required i mean advanced algorithims* not intermediate rphares @rphares Feb 26 2016 04:03 @devblanchard -- hahah, anytime! Glad to have helped :blush: Wiya @vvang044 , on time no see~ :blush: How're you doing? demipixel @demipixel Feb 26 2016 04:03 I've been doing js for years and I can't get past the second algorithm What is going on Vik @vvang044 Feb 26 2016 04:04 lol.....yep iknow......trying to work full time and code full....is a challenge but im stuck here as usuall here is the code var array = [4,5,6,7,8]; var singleVal = 0; // Only change code below this line. var singleVal = array.reduce(function(previousVal, currentVal){ return previousVal + currentVal; },0); singleVal = array; rphares @rphares Feb 26 2016 04:05 which challenge? Vik @vvang044 Feb 26 2016 04:05 "condense arrays with reduce" i need to sum all the values in the array and assign that to singleVal demipixel @demipixel Feb 26 2016 04:06 declaring singleVal twice, assigning it 3 times rphares @rphares Feb 26 2016 04:06 to start, was var singleVal there at the beginning? not meant to change above the line... demipixel @demipixel Feb 26 2016 04:06 I assume the goal is to get the sum of the array in singleVal? rphares @rphares Feb 26 2016 04:06 or below the line... Vik @vvang044 Feb 26 2016 04:06 thats true @demipixel Eric Meling @Gnilemcire Feb 26 2016 04:07 Help Accessing Nested Arrays in JSON CamperBot @camperbot Feb 26 2016 04:07 ## :point_right: challenge accessing nested arrays in json [wiki] # Challenge: Accessing Nested Arrays in JSON As we have seen in earlier examples, JSON objects can contain both nested objects and nested arrays. Similar to accessing nested objects, Array bracket notation can be chained to access nested arrays. Here is an example of how to access a nested array: js var ourPets = { "cats": [ "Meowzer", "Fluffy", "Kit-Cat" ], "dogs": [ "Spot", "Bowser", "Frankie" ] }; ourPets.cats[1]; // "Fluffy" :pencil: read more about challenge accessing nested arrays in json on the FCC Wiki Vik @vvang044 Feb 26 2016 04:07 i need to sum all the values in array and assign it to singleVal demipixel @demipixel Feb 26 2016 04:08 What's the last line for Vik @vvang044 Feb 26 2016 04:08 thats the instruction Abhishek Kumar @abhishekKumar1 Feb 26 2016 04:09 @vvang044 remove that line rphares @rphares Feb 26 2016 04:09 @vvang044 , try copying the middle bit-- where you use .reduce in var singleVal and saving it in your editor, and then reset the code it looks like you've changed a bit at the top and bottom that you weren't meant to Abhishek Kumar @abhishekKumar1 Feb 26 2016 04:09 you r getting the answer and then assigning it back to the array demipixel @demipixel Feb 26 2016 04:10 function palindrome(str) { str = str.toLowerCase().replace(/[^a-z0-9]/g, ''); return str.slice(0,Math.floor(str.length/2)) == str.slice(Math.ceil(str.length/2), str.length); } palindrome("eye"); Abhishek Kumar @abhishekKumar1 Feb 26 2016 04:10 @vvang044 just remove the last line and you will get the solution demipixel @demipixel Feb 26 2016 04:10 The website isn't syntax highlighting my regexp which is why I think it's failing Does it want me to do new RegExp()? Vik @vvang044 Feb 26 2016 04:11 ha i got the yayyy!!! rphares @rphares Feb 26 2016 04:12 congrats! Vik @vvang044 Feb 26 2016 04:12 but, help me out here...... the instructions says to assign the value to array Abhishek Kumar @abhishekKumar1 Feb 26 2016 04:13 @vvang044 "Use the reduce method to sum all the values in array and assign it to singleVal." that's what instruction said so you used .reduceon array and given the value back to the singleVal demipixel @demipixel Feb 26 2016 04:14 @rphares Any suggestions for mine? Vik @vvang044 Feb 26 2016 04:15 oh demipixel @demipixel Feb 26 2016 04:15 Annnnnnd I just screwed myself over Vik @vvang044 Feb 26 2016 04:15 yeah me tooo rphares @rphares Feb 26 2016 04:15 @demipixel ?? demipixel @demipixel Feb 26 2016 04:15 Typed print() in my code and now it opens up the print window every time I try to cancel it eval() much? Raghuram @Raghuram1994 Feb 26 2016 04:16 function lookUp(firstName, prop){ // Only change code below this line if(firstName===contacts.firstName&&prop===firstName){ return contacts.firstName; } else if(contacts[firstName]!==firstName){ return "No such contact"; } else if(prop!==contacts){ return "No such property"; } //only" No such contact is working" rphares @rphares Feb 26 2016 04:16 @demipixel , explain auto CamperBot @camperbot Feb 26 2016 04:16 ## :point_right: disable code auto run [wiki] By default, the Free Code Camp site automatically loads and runs your last recorded solution. If you have accidentally created an infinite loop or other irrecoverable error or simply don't trust the code, you can disable code auto-run by putting the following in your URL: run=disabled #### Example: URL: http://www.freecodecamp.com/challenges/Algorithm-meet-Algorithm#?solution=function%20meetBonfire(argument) No-Run URL: http://www.freecodecamp.com/challenges/Algorithm-meet-Algorithm#?run=disabled&solution=function%20meetBonfire(argument) rphares @rphares Feb 26 2016 04:16 that should help you address that :) If it doesn't work, holler-- CamperBot @camperbot Feb 26 2016 04:16 holler back! rphares @rphares Feb 26 2016 04:16 there is another way, but it'll clear your code, so this way is the best if it works :) demipixel @demipixel Feb 26 2016 04:17 Alright The other issue was actually with my code :P Is there a way to log? Vik @vvang044 Feb 26 2016 04:18 @Raghuram1994 is that all the code or did you just copied and pasted it demipixel @demipixel Feb 26 2016 04:18 without throwing an error Abhishek Kumar @abhishekKumar1 Feb 26 2016 04:18 @demipixel you code it allright but think what are you returning Vik @vvang044 Feb 26 2016 04:18 @abhishekKumar1 thank you for explaining CamperBot @camperbot Feb 26 2016 04:18 vvang044 sends brownie points to @abhishekkumar1 :sparkles: :thumbsup: :sparkles: demipixel @demipixel Feb 26 2016 04:18 a bool CamperBot @camperbot Feb 26 2016 04:18 :star: 357 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1 Abhishek Kumar @abhishekKumar1 Feb 26 2016 04:19 @demipixel in the funcion say i pass "I am ma I" Brian @sludge256 Feb 26 2016 04:19 @demipixel is your return statement comparing the first half of the string with the second half of the string? Abhishek Kumar @abhishekKumar1 Feb 26 2016 04:19 then after regex your str becomes "iammai" Raghuram @Raghuram1994 Feb 26 2016 04:19 no its not all the code its "Profile lookup" in javascript @vvang044 demipixel @demipixel Feb 26 2016 04:19 oh Forgot to reverse I'm dumb Still would be nice to know how to log Abhishek Kumar @abhishekKumar1 Feb 26 2016 04:20 then you are using bool on iam==mai so it will return false demipixel @demipixel Feb 26 2016 04:20 Yeah, I fixed it :P Oh, Console.log with a capital c Vik @vvang044 Feb 26 2016 04:21 @Raghuram1994 can you paste your code here Raghuram @Raghuram1994 Feb 26 2016 04:22 //Setup var contacts = [ { "firstName": "Akira", "lastName": "Laine", "number": "0543236543", "likes": ["Pizza", "Coding", "Brownie Points"] }, { "firstName": "Harry", "lastName": "Potter", "number": "0994372684", "likes": ["Hogwarts", "Magic", "Hagrid"] }, { "firstName": "Sherlock", "lastName": "Holmes", "number": "0487345643", "likes": ["Intriguing Cases", "Violin"] }, { "firstName": "Kristian", "lastName": "Vos", "number": "unknown", "likes": ["Javascript", "Gaming", "Foxes"] } ]; function lookUp(firstName, prop){ // Only change code below this line if(firstName===contacts.firstName&&prop===firstName){ return contacts.firstName; } else if(contacts[firstName]!==firstName){ return "No such contact"; } else if(prop!==contacts){ return "No such property"; } } // Only change code above this line // Change these values to test your function lookUp("Akira", "likes"); @vvang044 Vik @vvang044 Feb 26 2016 04:24 what i did in that exercise was write two "if" statements and else instead of else if.... Raghuram @Raghuram1994 Feb 26 2016 04:26 can you paste that code here? @vvang044 demipixel @demipixel Feb 26 2016 04:27 We should inform more people to use js Vik @vvang044 Feb 26 2016 04:27 let me give you a hint than giving you the code.....so you know its about understanding the code rather than copy paste why dont you write a for statement first then write a if statement and if statement write else and two return's if my explanation helps demipixel @demipixel Feb 26 2016 04:28 booooooo Vik @vvang044 Feb 26 2016 04:28 we are here to learn right....? Brian @sludge256 Feb 26 2016 04:28 @demipixel figured out your code? demipixel @demipixel Feb 26 2016 04:28 No Stupid edge case makes my code less clean function repeat(str, num) { return num > 0 ? [,...Array(num)].join(str) : ''; } repeat("abc", 3); Brian @sludge256 Feb 26 2016 04:29 Your return statement isn't counting the middle letter if it's an odd number of letters demipixel @demipixel Feb 26 2016 04:29 Oh that was like 5 problems ago Brian @sludge256 Feb 26 2016 04:29 ah ok :P demipixel @demipixel Feb 26 2016 04:29 @sludge256 That doesn't matter Brian @sludge256 Feb 26 2016 04:29 I've been room hopping demipixel @demipixel Feb 26 2016 04:29 You can ignore the middle letter Because the middle letter will always equal itself Brian @sludge256 Feb 26 2016 04:30 You're right what was the issue then I didn't finish looking through it demipixel @demipixel Feb 26 2016 04:30 I forgot to reverse the second slice haha Brian @sludge256 Feb 26 2016 04:30 ah Vik @vvang044 Feb 26 2016 04:35 @rphares how far are you in coding? demipixel @demipixel Feb 26 2016 04:37 lol function slasher(arr, howMany) { return arr.slice(howMany, arr.length); } slasher([1, 2, 3], 2); That was hard /s Brian @sludge256 Feb 26 2016 04:38 Yes :+1: Many people complain about all the code they have to write for that one ;) demipixel @demipixel Feb 26 2016 04:38 Bothers me that they capitalize the c in console.log Brian @sludge256 Feb 26 2016 04:40 it works lowercased demipixel @demipixel Feb 26 2016 04:40 I'm saying it might be misleading for newbies Brian @sludge256 Feb 26 2016 04:40 Which challenge is it capitalized? Vik @vvang044 Feb 26 2016 04:40 like me demipixel @demipixel Feb 26 2016 04:41 All of them I've seen so far I skipped ahead to stuff on the map that had an astericks sooo... Basic Algorithm Scripting Brian @sludge256 Feb 26 2016 04:41 oh You want to submit an issue on the repo? It's an easy fix demipixel @demipixel Feb 26 2016 04:42 Sure Brian @sludge256 Feb 26 2016 04:42 @demipixel thanks :+1: CamperBot @camperbot Feb 26 2016 04:42 sludge256 sends brownie points to @demipixel :sparkles: :thumbsup: :sparkles: :star: 17 | @demipixel | http://www.freecodecamp.com/demipixel demipixel @demipixel Feb 26 2016 04:51 uuuuhhhh where([10, 20, 30, 40, 50], 35) should return 3. Okay... My code contains: where([10, 20, 30, 40, 50], 35); And outputs 3 Sumeet Batheja @bathejasumeet Feb 26 2016 04:52 Hiya all demipixel @demipixel Feb 26 2016 04:52 Hey, long time no see Sumeet Batheja @bathejasumeet Feb 26 2016 04:53 @demipixel How are you doing? demipixel @demipixel Feb 26 2016 04:53 Poorly See above for details Brian @sludge256 Feb 26 2016 04:53 What's your code? Sumeet Batheja @bathejasumeet Feb 26 2016 04:53 ok sure demipixel @demipixel Feb 26 2016 04:53 function where(arr, num) { for (var i in arr) { if (arr[i] > num) return i; } return arr.length; } where([10, 20, 30, 40, 50], 35); Sumeet Batheja @bathejasumeet Feb 26 2016 04:53 what is expected output? demipixel @demipixel Feb 26 2016 04:53 3 CamperBot @camperbot Feb 26 2016 04:53 ## :point_right: challenge get json with the jquery getjson method [wiki] # Get JSON with the jQuery getJSON Method Application Programming Interfaces - are tools that computers use to communicate with one another. Most web APIs transfer data in a format called JSON. JSON stands for JavaScript Object Notation. JSON is nothing more than object properties and their current values, sandwiched between a { and a }. These properties and their values are often referred to as "key-value pairs". Here is a sample of what it looks like. $.getJSON("/json/cats.json", function(json) {

\$(".message").html(JSON.stringify(json));

});
Sumeet Batheja
@bathejasumeet
Feb 26 2016 04:54
what are you trying to accomplish?
Brian
@sludge256
Feb 26 2016 04:54
lol what
camperbot chiming in
demipixel
@demipixel
Feb 26 2016 04:54
He just wants to help
Expected output: 3
Output: 3
It might be mad because I'm not using .sort()
Brian
@sludge256
Feb 26 2016 04:55
I don't think it matters
Davinw
@Davinw
Feb 26 2016 04:55
@demipixel It looks like your code is intended to find the index position in an array of the first value bigger than second provided parameter, what's the exercise?
Brian
@sludge256
Feb 26 2016 04:55
"tests": [
"assert(where([10, 20, 30, 40, 50], 35) === 3, 'message: <code>where([10, 20, 30, 40, 50], 35)</code> should return <code>3</code>.');",
"assert(where([10, 20, 30, 40, 50], 30) === 2, 'message: <code>where([10, 20, 30, 40, 50], 30)</code> should return <code>2</code>.');",
"assert(where([40, 60], 50) === 1, 'message: <code>where([40, 60], 50)</code> should return <code>1</code>.');",
"assert(where([3, 10, 5], 3) === 0, 'message: <code>where([3, 10, 5], 3)</code> should return <code>0</code>.');",
"assert(where([5, 3, 20, 3], 5) === 2, 'message: <code>where([5, 3, 20, 3], 5)</code> should return <code>2</code>.');",
"assert(where([2, 20, 10], 19) === 2, 'message: <code>where([2, 20, 10], 19)</code> should return <code>2</code>.');",
"assert(where([2, 5, 10], 15) === 3, 'message: <code>where([2, 5, 10], 15)</code> should return <code>3</code>.');"
]
it only checks the output
demipixel
@demipixel
Feb 26 2016 04:56
@Davinw Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted.
Davinw
@Davinw
Feb 26 2016 04:57
@demipixel well if you haven't sorted the array first, the rest of the tests that @sludge256 linked wouldn't pass with your existing code
demipixel
@demipixel
Feb 26 2016 04:57
function where(arr, num) {
arr = arr.sort();
for (var i in arr) {
if (arr[i] > num) return i;
}
return arr.length;
}

where([10, 20, 30, 40, 50], 35);
Doesn't work either
Still outputs 3
Davinw
@Davinw
Feb 26 2016 04:58
@demipixel isn't 3 supposed to be the expected answer though?
demipixel
@demipixel
Feb 26 2016 04:58
Yep
Oh
Oh yeah
It's because it's javascript
heh, fixed
Davinw
@Davinw
Feb 26 2016 05:00
@demipixel so what was the issue then?
demipixel
@demipixel
Feb 26 2016 05:00
I forgot
Sumeet Batheja
@bathejasumeet
Feb 26 2016 05:00
:D @demipixel . I have completely lost you
demipixel
@demipixel
Feb 26 2016 05:00
for (var i in ....) {
typeof i == 'string'
}
Since it was using triple equals, it was comparing a number to a string
and returned a fail
Sumeet Batheja
@bathejasumeet
Feb 26 2016 05:00
ok
demipixel
@demipixel
Feb 26 2016 05:00
function where(arr, num) {
arr = arr.sort();
for (var i in arr) {
if (arr[i] > num) return parseInt(i);
}
return arr.length;
}

where([10, 20, 30, 40, 50], 35);
Fixes it
Sumeet Batheja
@bathejasumeet
Feb 26 2016 05:00
you prevented type coercion by using ===
rphares
@rphares
Feb 26 2016 05:01
not far, @vvang044 :)
(sorry, stepped away)
Davinw
@Davinw
Feb 26 2016 05:01
@demipixel ah gotcha
Sumeet Batheja
@bathejasumeet
Feb 26 2016 05:01
@demipixel , just food for thought
don't use for in loops with objects other than array without the hasOwnProperty method
demipixel
@demipixel
Feb 26 2016 05:02
Yeahhhh, well
Sumeet Batheja
@bathejasumeet
Feb 26 2016 05:02
you would end up traversing the prototype chain
demipixel
@demipixel
Feb 26 2016 05:02
I'm trying to do this "50 hour" section in an hour
Sumeet Batheja
@bathejasumeet
Feb 26 2016 05:02
Good Day guys... I am off. have a great day
demipixel
@demipixel
Feb 26 2016 05:02
So I'm not making a ton of clean code :P
Eric
@Code-Eric
Feb 26 2016 05:02
for some reason it wont even consider the else if
anyone have a clue?
Davinw
@Davinw
Feb 26 2016 05:03
@demipixel According to MDN, for...in loops shouldn't be used with Arrays when the index order is important, lol. :) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in
Eric
@Code-Eric
Feb 26 2016 05:03
demipixel
@demipixel
Feb 26 2016 05:03
@Code-Eric if statements aren't really methods/functions
Which means they don't take paramaters, what are you attempting to achieve with par > 0, 1?
Davinw
@Davinw
Feb 26 2016 05:04
@Code-Eric You aren't using the "strokes" parameter in your comparisons...
Vik
@vvang044
Feb 26 2016 05:04
oh ye.....that means you are miles away
i didnt finish my first build a personal page portfolio....lol
demipixel
@demipixel
Feb 26 2016 05:05
there should be Number.within(min, max) which return a boolean like this
Eric
@Code-Eric
Feb 26 2016 05:05
Oh okay i thought that with parameters that the input was (param1,param2)
so you just put whatever value
Brian
@sludge256
Feb 26 2016 05:05
there's two parameters for the function
demipixel
@demipixel
Feb 26 2016 05:05
You have to say: par > 0 and par < 2
Brian
@sludge256
Feb 26 2016 05:05
but those are passed in at the bottom
demipixel
@demipixel
Feb 26 2016 05:05
There's no shortcut :/
Or strokes or whatever it was
Eric
@Code-Eric
Feb 26 2016 05:06
so i dont use if function
Brian
@sludge256
Feb 26 2016 05:06
You would
Eric
@Code-Eric
Feb 26 2016 05:06
okay so i just have to declare the parameter range
Davinw
@Davinw
Feb 26 2016 05:06
@Code-Eric You need to compare strokes to par
Eric
@Code-Eric
Feb 26 2016 05:06
using par and strokes
when you say compare do you mean as in: (par > 0 and par < 2, strokes>0 and strokes < 2)
Davinw
@Davinw
Feb 26 2016 05:08
@Code-Eric no
@Code-Eric you need to compare strokes TO par
for instance:
if(strokes > par) { return "You were over par!";]
if(strokes > par) {return "You were over par!"; }
Eric
@Code-Eric
Feb 26 2016 05:11
okay thanks @Davinw
CamperBot
@camperbot
Feb 26 2016 05:11
code-eric sends brownie points to @davinw :sparkles: :thumbsup: :sparkles:
:star: 229 | @davinw | http://www.freecodecamp.com/davinw
Davinw
@Davinw
Feb 26 2016 05:11
@Code-Eric np!
Rekha Gupta
@codingclass
Feb 26 2016 05:11
in JavaScript How do you access a property value nested in an array .
Vik
@vvang044
Feb 26 2016 05:12
what is the exercise called @codingclass
Rekha Gupta
@codingclass
Feb 26 2016 05:12

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

function lookUp(firstName, prop){

profile lookup
Vik
@vvang044
Feb 26 2016 05:13
oh the profile lookup
and can you paste your within these .....code.....
Preetam Kajal Rout
@preetamkajalrout
Feb 26 2016 05:14
@codingclass :
contacts[0].likes // ["Pizza, "Coding", "Brownie Points"]
Vik
@vvang044
Feb 26 2016 05:15

use those
Rekha Gupta
@codingclass
Feb 26 2016 05:15

function lookUp(firstName, prop){
// Only change code below this line
var name = firstName;
// var conName = contacts[name];
var conProp = contacts[0].hasOwnProperty(prop);
// var conProp =contacts[conInfo];
// console.log("hi");

for (var i=0; i<4; i++)
// for(var j=0;j<4; j++)
{
// return( i +" hi");
// var conProp =contacts[i][conInfo];

if (contacts[i].firstName === name & contacts[i].hasOwnProperty(prop) === true)
{
// return(contacts[i].prop + " hi 2");
return contacts[i].prop;
}
else if (contacts[i].firstName !== name)
{
// return( contacts[i].firstName + contacts[i] +" hi 3");
return "No such contact";
}
else if (contacts[i].conInfo !== prop)
{
// return( contacts[i].firstName + contacts[i].conProp +" hi 2");
return "No such Property";
}
console.log("hi");
}
// Only change code above this line
}

Vik
@vvang044
Feb 26 2016 05:15
at the beginning and at the end
demipixel
@demipixel
Feb 26 2016 05:16
Welp, done with the algorithms
Davinw
@Davinw
Feb 26 2016 05:18
@codingclass you need to use a double ampersand for the "logical and" in your if statement
Vik
@vvang044
Feb 26 2016 05:18
if (contacts[i].firstName === name & contacts[i].hasOwnProperty(prop) === true).....should have two &&
Davinw
@Davinw
Feb 26 2016 05:19
@codingclass also, from a style perspective, you can shorten "contacts[i].hasOwnProperty(prop) === true" to just "contacts[i].hasOwnProperty(prop)" An if statement always implicitly checks for true/false if no other direction is given
demipixel
@demipixel
Feb 26 2016 05:20
I mean, technically single &s work, right?
cause true & true == 1 and false & true == 0
Rekha Gupta
@codingclass
Feb 26 2016 05:20
No error msg with single &
demipixel
@demipixel
Feb 26 2016 05:21
@codingclass It's best practice to use two
The single is a weird hack :P
Davinw
@Davinw
Feb 26 2016 05:21
@codingclass strictly speaking the single & is a different operator than &&, and basically is never used
Rekha Gupta
@codingclass
Feb 26 2016 05:22
still cannot acces property value

We have an array of objects representing different people in our contacts lists.

A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you.

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

problem
Vik
@vvang044
Feb 26 2016 05:24
@codingclass code just threw me off.....
have to tried something along these lines....writing two if statement and another if statement within and an else.....and oh just one for statement?
*you
Davinw
@Davinw
Feb 26 2016 05:28
@codingclass this line is incorrect: "return contacts[i].prop;"
Andrew Dutton
@andrew-dutton
Feb 26 2016 05:28
So.... just checking that I am not the only one who does the bonfires and then checks the wiki after successfully completing them to find that mine is an essay compared to a few perfect simple statements?? ;)
Davinw
@Davinw
Feb 26 2016 05:28
@Davinw need to use bracket notation when using a variable for a property name. so "return contacts[i][prop]; will work
@AndreWaroux Ever try the site codewars? That is rampant there :)
Andrew Dutton
@andrew-dutton
Feb 26 2016 05:30
@Davinw actually I did take a look the other day... i don't think I'm quite ready... i was stumped on question two :P
Davinw
@Davinw
Feb 26 2016 05:30
@codingclass Sorry this message was intended for you, I sent it to myself instead because I'm smart like that!:
need to use bracket notation when using a variable for a property name. so "return contacts[i][prop]; will work
Rekha Gupta
@codingclass
Feb 26 2016 05:33
@Davinw thanks ,that worked !!!
CamperBot
@camperbot
Feb 26 2016 05:33
codingclass sends brownie points to @davinw :sparkles: :thumbsup: :sparkles:
:star: 230 | @davinw | http://www.freecodecamp.com/davinw
Davinw
@Davinw
Feb 26 2016 05:33
@AndreWaroux Well they have the various difficulty levels, but yeah, there are some knockout problems in there, especially the lower levels, some of those problems are practically a contract
@codingclass yw!
Vik
@vvang044
Feb 26 2016 05:35
sorry where are these bonfires which are referring to?
Zippo Yap
@zippo-yap
Feb 26 2016 05:37
@AndreWaroux I feel the same >< my codes always seem so long. I've only gotten up to returning the largest number in an array
@vvang044 Basic Algorithm Scripting section - they're also referred to as bonfires
Vik
@vvang044
Feb 26 2016 05:38
gotcha
so that is going to be my first bonfire
Ryan Price
@rsprice
Feb 26 2016 05:50
Anyone need help with anything currently?
Brian
@sludge256
Feb 26 2016 05:52
Which companies should I invest in?
:D
Enron?
Ryan Price
@rsprice
Feb 26 2016 05:54
lol
Vik
@vvang044
Feb 26 2016 05:54
yea
Markus Kiili
@Masd925
Feb 26 2016 05:54
@rsprice Tell me something that makes me start the portfolio exercise.
Ryan Price
@rsprice
Feb 26 2016 05:54
@Masd925 there is no wrong way to do it :)
@Masd925 that will give you some direction :P
Vik
@vvang044
Feb 26 2016 05:55
"split strings with split"......how to do that?
demipixel
@demipixel
Feb 26 2016 05:56
stringVar.split("splitString")
Ryan Price
@rsprice
Feb 26 2016 05:56
or just 'hello, world'.split(' ')
Markus Kiili
@Masd925
Feb 26 2016 05:56
@vvang044 str.split("") will split characters to an array and str.split(" "); will split the string on the spaces.
demipixel
@demipixel
Feb 26 2016 05:56
@rsprice Do API problems get checked automatically or manually or at all?
Ryan Price
@rsprice
Feb 26 2016 05:57
@demipixel which API are you referring to?
demipixel
@demipixel
Feb 26 2016 05:57
the API problems
"API Projects"
Vik
@vvang044
Feb 26 2016 05:57
var string = "Split me into an array";
var array = [];

// Only change code below this line.

array = string.split()
so that is incorrect.....
Ryan Price
@rsprice
Feb 26 2016 05:58
@demipixel I guess it depends on what issue you're having, and which API you're using. Sorry, you'll have to be a little bit more specific for me!
Markus Kiili
@Masd925
Feb 26 2016 05:59
@vvang044 That puts the whole string into the first array element.
demipixel
@demipixel
Feb 26 2016 05:59
I'm not using any api haha
The Backend API Projects that you need to complete to get your certificate
Those aren't like traditional problems which can't be checked automagically
Ryan Price
@rsprice
Feb 26 2016 06:01
or how you receive credit for them if I'm understanding you correctly
demipixel
@demipixel
Feb 26 2016 06:01
Yes
Ryan Price
@rsprice
Feb 26 2016 06:01
@demipixel I'm actually not 100% sure when they get checked
Zippo Yap
@zippo-yap
Feb 26 2016 06:02
@vvang044 you need to specify a parameter to split each bit by.
Tony
@Rogers187
Feb 26 2016 06:08
What am I not seeing?? Returning Boolean Values from Functions

function isLess(a, b) {
// Fix this code
return a === b;
}

// Change these values to test
isLess(10, 15);

Got it
Ryan Price
@rsprice
Feb 26 2016 06:11
@Rogers187 that was fast!
Ryan Price
@rsprice
Feb 26 2016 06:16
Can anyone tell me if my stream is currently working? https://www.twitch.tv/rp_dev/
You guys/girls can ask questions and I'll walk you through stuff via screen share
demipixel
@demipixel
Feb 26 2016 06:17
My question is why I have to do all of these API projects
It's nearly taking me more time to create the repos and make them live on my server than it is to code :S
Ryan Price
@rsprice
Feb 26 2016 06:17
@demipixel for science!
demipixel
@demipixel
Feb 26 2016 06:18
Can I get the backend certificate for hacking into the NSA with CSS
Oh, I guess you guys want node.js cause backend
Ryan Price
@rsprice
Feb 26 2016 06:19
@demipixel probably
Ankit Panwar
@coderNoob
Feb 26 2016 06:22
@rsprice It's working.
Ryan Price
@rsprice
Feb 26 2016 06:23
@coderNoob :) thanks for the head's up
CamperBot
@camperbot
Feb 26 2016 06:23
rsprice sends brownie points to @codernoob :sparkles: :thumbsup: :sparkles:
:star: 340 | @codernoob | http://www.freecodecamp.com/codernoob
Shahriar raju
@Rajudevo
Feb 26 2016 06:24
hello
Ryan Price
@rsprice
Feb 26 2016 06:26
@Rajudevo hello!
Sloth
@RMo-Sloth
Feb 26 2016 06:26
@rsprice yup it is.
Ryan Price
@rsprice
Feb 26 2016 06:26
@RobMo thanks!
CamperBot
@camperbot
Feb 26 2016 06:26
rsprice sends brownie points to @robmo :sparkles: :thumbsup: :sparkles:
:star: 287 | @robmo | http://www.freecodecamp.com/robmo
Shahriar raju
@Rajudevo
Feb 26 2016 06:27
i am stuck on 162 wordBlanks function @rsprice
??
Ryan Price
@rsprice
Feb 26 2016 06:29
I can talk you through it
@Rajudevo can you see/hear my stream or do you want me to walk you through it on here?
Shahriar raju
@Rajudevo
Feb 26 2016 06:32
ya i can but my net is slow so on here will be great
Ryan Price
@rsprice
Feb 26 2016 06:32
@Rajudevo Ok, can you show me what you've got so far?
Shahriar raju
@Rajudevo
Feb 26 2016 06:35
nothing actually
don't know that to do
Ryan Price
@rsprice
Feb 26 2016 06:37
@Rajudevo ok, well it looks like what they want you to do is return a concatenated string using all of those parameters that you're given. Does that make sense?
@Rajudevo It probably also helps if you know what a "mad lib" is :P are you familiar?
Wes
@weslez
Feb 26 2016 06:37
This message was deleted
Working on 'Check for Palindromes'. Logically, this code should work, but I can't figure out what I'm missing. Any clues?
function palindrome(str) {
var lowerCase = str.toLowerCase();
var noSpaces = lowerCase.replace(/[^A-Za-z]/g, "");
var arr1 = noSpaces.split("");
var arr2 = arr1.reverse();

if (arr1 === arr2) {
return true;
} else if (arr1 !== arr2) {
return false;
}

}

palindrome("not a palindrome");
demipixel
@demipixel
Feb 26 2016 06:38
@weslez You can only compare strings with ==
[1,2] != [1,2] because they're different arrays
Different strings, though, are alright
So you'll want str1 == str2
Shahriar raju
@Rajudevo
Feb 26 2016 06:40
no i'm not . can you please show me the result
@rsprice
Wes
@weslez
Feb 26 2016 06:40
Exactly what I was looking for @demipixel. Can you tell me at what point the string "not a palindrome" got changed into an array? Was it the .split command?
demipixel
@demipixel
Feb 26 2016 06:41
Yes
Ryan Price
@rsprice
Feb 26 2016 06:41
@weslez yep!
demipixel
@demipixel
Feb 26 2016 06:42
120 WPM ninja'd
Ryan Price
@rsprice
Feb 26 2016 06:42
@Rajudevo I think it would be better if I don't just give you the answer. Is the prompt confusing you?
Wes
@weslez
Feb 26 2016 06:42
And it took me waaaay to long to figure this out, but .reverse won't work on strings...only arrays correct?
demipixel
@demipixel
Feb 26 2016 06:42
@weslez yes
cannelflow
@cannelflow
Feb 26 2016 06:42
Shahriar raju
@Rajudevo
Feb 26 2016 06:44
example @cannelflow
Ryan Price
@rsprice
Feb 26 2016 06:44
^
@Rajudevo word + word + word + word
Wes
@weslez
Feb 26 2016 06:45
Last clue (maybe) @demipixel & @rsprice : Is my best path forward to figure out how to convert my .split and .reversed arrays back into strings in order to compare them (maybe using .join somewhere) or should I be looking at how to write a loop to compare the two arrays?
Marina
@chandra90
Feb 26 2016 06:45
Please help! How to do this? the task :You will need to use string operators to build a new string, result, using the provided variables.
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");
cannelflow
@cannelflow
Feb 26 2016 06:45
@chandra90
demipixel
@demipixel
Feb 26 2016 06:46
@weslez You can only reverse an array
Marina
@chandra90
Feb 26 2016 06:46
@cannelflow how??
cannelflow
@cannelflow
Feb 26 2016 06:46
inside function
demipixel
@demipixel
Feb 26 2016 06:46
But there are methods to convert to an array from a string and to a string from an array
cannelflow
@cannelflow
Feb 26 2016 06:47
@chandra90 if you want to concat two word in a sentence hello & world then it is like "hello"+"world"
Marina
@chandra90
Feb 26 2016 06:49
@cannelflow I got how to concat it . Should I write :var="My noun+my Ajective+ect"?
cannelflow
@cannelflow
Feb 26 2016 06:50
@chandra90 you defined var result there so make it equals result
function wordBlanks(A,B,C,D) {
var result = "";
// Your code below this line

so if you concat A,B,C,D here it bascically gives
// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly"); <==== this value
@Rajudevo
@mqasim13
Feb 26 2016 06:52
Hi I am having problems with the card counting excercise... I reason that I should use a switch to tally up the count for all cards, and then use an if-else statement to determine if I need to "hold" or "bet"... But this doesn't seem to be working for me.. Any help would be much appreciated
Ryan Price
@rsprice
Feb 26 2016 06:53
@mqasim13 can you show us what you've got so far?
cannelflow
@cannelflow
Feb 26 2016 06:53
@mqasim13 can you show your code
Marina
@chandra90
Feb 26 2016 06:56
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
// Your code above this line
return result;
}
@mqasim13
Feb 26 2016 06:56
@ rsprice @cannelflow
'''
CamperBot
@camperbot
Feb 26 2016 06:57
:bulb: to format code use backticks!  more info
@mqasim13
Feb 26 2016 06:57
This message was deleted
whoops don't know how to show a snippet
V Arun Kumar
@arunvkumr
Feb 26 2016 06:57
@chandra90 remove " from result
@mqasim13 help format
help format
CamperBot
@camperbot
Feb 26 2016 06:57

## :point_right: code formatting [wiki]

### Inline code

This an inline <paste code here> code formatting with a single backtick() at start and end around the code.

### Code Block

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 ⏎]

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

Marina
@chandra90
Feb 26 2016 06:58
@arunkumrv and?
@mqasim13
Feb 26 2016 06:58
function cc(card) {
// Only change code below this line
var count = 0;
switch(card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count += 1;
break;
case 7:
case 8:
case 9:
count = count;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count -= 1;
break;
}
if (count > 0) {
return count + "Bet";
}
else {
return count + "Hold";
}

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

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');\
there we go :)
V Arun Kumar
@arunvkumr
Feb 26 2016 06:58
@chandra90 and adding a space betten words will do it
@mqasim13
Feb 26 2016 06:59
I realize that the last return ( the "change me") needs to be removed, but even then I'm having issues with the code
V Arun Kumar
@arunvkumr
Feb 26 2016 06:59
@chandra90 something like c = a + " " + b;
cannelflow
@cannelflow
Feb 26 2016 06:59
@chandra90 you need spacing like myNoun +" " + myNoun
@mqasim13
Feb 26 2016 06:59
@rsprice @cannelflow any help?
cannelflow
@cannelflow
Feb 26 2016 07:00
and myNoun is variable not string @chandra90 so cannot do "myNoun"
demipixel
@demipixel
Feb 26 2016 07:00
Stop counting cards, that's not allowed in most casinos
Marina
@chandra90
Feb 26 2016 07:00
@cannelflow 
V Arun Kumar
@arunvkumr
Feb 26 2016 07:01
@mqasim13 there is \ at end of your code, is that in your original code?
Marina
@chandra90
Feb 26 2016 07:01
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
// Your code above this line
return result;
}
cannelflow
@cannelflow
Feb 26 2016 07:01
@mqasim13 cannot find your code ?
Mihai Lita
@atryx
Feb 26 2016 07:01
hello
@mqasim13
Feb 26 2016 07:01
This message was deleted
cannelflow
@cannelflow
Feb 26 2016 07:01
@chandra90 myNoun +" " + myNoun
V Arun Kumar
@arunvkumr
Feb 26 2016 07:01
@chandra90 myNoun is a variable you have to use without quotes(""). if you use it with quotes it makes it a string.
Mihai Lita
@atryx
Feb 26 2016 07:02
function bouncer(arr) {
// Don't show a false ID to this bouncer.
var arr2 = [];
for ( i = 0 ; i < arr.length; i++ ) {
switch (arr[i]) {
case false:
case null:
case 0:
case "":
case undefined:
case NaN:
break;
default:
arr2.push(arr[i]);
}
}
return arr2;
}
cannelflow
@cannelflow
Feb 26 2016 07:02
:point_up: February 26, 2016 12:30 PM @chandra90
Mihai Lita
@atryx
Feb 26 2016 07:02
can some1 help me with Falsy Bouncer?
V Arun Kumar
@arunvkumr
Feb 26 2016 07:03
@chandra90 result = mynoun + " "+ myadjective is different from result = "mynoun" + " "+ "myadjective"
@mqasim13
Feb 26 2016 07:03
This message was deleted
DJ
@qualitymanifest
Feb 26 2016 07:03
@mqasim13 get rid of var count = 0;. you don't want to reset count like that. then, add a space before the words returned like " Bet" instead of "Bet"
Marina
@chandra90
Feb 26 2016 07:03
@cannelflow and what about other variables?
@mqasim13
Feb 26 2016 07:04
@qualitymanifest thanks that fixed it
CamperBot
@camperbot
Feb 26 2016 07:04
mqasim13 sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
cannelflow
@cannelflow
Feb 26 2016 07:04
@chandra90 yes do like myNoun +" " + myadj+" "+my...
@mqasim13
Feb 26 2016 07:04
thanks a lot
CamperBot
@camperbot
Feb 26 2016 07:04
:star: 1004 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
V Arun Kumar
@arunvkumr
Feb 26 2016 07:04
@atryx you have to use boolean object. its much easier than what you have done. you can read more about it here..
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean
Markus Kiili
@Masd925
Feb 26 2016 07:04
@atryx NaN is special because NaN===NaN is false.
Mihai Lita
@atryx
Feb 26 2016 07:05
@Masd925 the problem is not there, at least not in the test
it only fails the "" test
Marina
@chandra90
Feb 26 2016 07:05
result= myNoun + "myAdjective" + "myVerb"+ "myAdverb"
Like this? @cannelflow
Markus Kiili
@Masd925
Feb 26 2016 07:06
@atryx It fails to remove NaN.
DJ
@qualitymanifest
Feb 26 2016 07:06
@atryx @Masd925 is right
V Arun Kumar
@arunvkumr
Feb 26 2016 07:06
@chandra90 you are close. just remove the quotes for all the variables. and a little space betten words.
Mihai Lita
@atryx
Feb 26 2016 07:07
but even if I try with IsNaN()
it still doesn't work
Markus Kiili
@Masd925
Feb 26 2016 07:07
@atryx bouncer([false, null, 0, NaN, undefined, ""]); // returns [NaN]
@atryx You can test NaN separately with value===value. NaN is the only value that gives false. If you wan't to use isNaN, you have to do: typeof value==='number' && isNaN(value)
Marina
@chandra90
Feb 26 2016 07:07
result= myNoun +  myAdjective +  myVerb +  myAdverb;
cannelflow
@cannelflow
Feb 26 2016 07:08
@chandra90 good now you need to give spacing
Marina
@chandra90
Feb 26 2016 07:08
@cannelflow how?
V Arun Kumar
@arunvkumr
Feb 26 2016 07:08
@chandra90 yes you are getting some output but there needs small space between words.
like a = a + " " + b;
Mihai Lita
@atryx
Feb 26 2016 07:08
@Masd925 the above bouncer returns: [null]
Markus Kiili
@Masd925
Feb 26 2016 07:09
@atryx It is NaN. FCC console shows it as null.
Mihai Lita
@atryx
Feb 26 2016 07:09
I see
Shahriar raju
@Rajudevo
Feb 26 2016 07:09
@cannelflow still not passed so please give the full result screenshoot
V Arun Kumar
@arunvkumr
Feb 26 2016 07:09
@atryx the challenge wants you to use boolean object. try with it
cannelflow
@cannelflow
Feb 26 2016 07:09
now printing like dogbig @chandra90 you need to do like dog big so do like a+" "+b
Mihai Lita
@atryx
Feb 26 2016 07:10
@arunkumrv will try, tks
CamperBot
@camperbot
Feb 26 2016 07:10
atryx sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 288 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Ankit Panwar
@coderNoob
Feb 26 2016 07:10

I'm doing the symmetric difference bf and I've extracted the unique elements from two arrays

function sym(args) {

args = Array.prototype.slice.call(arguments);
function SD(array1, array2){
return array1.filter(function(element){
return array2.indexOf(element)<0;
});
}
return SD(args[0], args[1]).concat(SD(args[1],args[0]));
}

sym([1, 2, 3], [5, 2, 1, 4]);

How do I iterate over n number of arrays?

V Arun Kumar
@arunvkumr
Feb 26 2016 07:10
@atryx you're welcome. just for reference you can read about it here..
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean
cannelflow
@cannelflow
Feb 26 2016 07:11
@chandra90 worked ?
can you help @Rajudevo
can you paste your code @Rajudevo
Markus Kiili
@Masd925
Feb 26 2016 07:12
@coderNoob If you know how to do it with two arrays, you can use .reduce to do it to variable number of arrays.
function sym(args) {
args=Array.prototype.slice.call(arguments);
return args.reduce(function(prev, curr){
return ???; <- SymmDiff of two arrays prev and curr here.
}, []);
}
Marina
@chandra90
Feb 26 2016 07:13
@cannelflow how to do spaces?
cannelflow
@cannelflow
Feb 26 2016 07:15
@chandra90 you did like result= myNoun + myAdjective + myVerb + myAdverb; do like result= myNoun + " "+myAdjective + " "+ myVerb + ""+ myAdverb;@Rajudevo
that will give spacing
V Arun Kumar
@arunvkumr
Feb 26 2016 07:15
@chandra90 result= myNoun + myAdjective + myVerb + myAdverb; this code is concatenating all the words and to add space you just need to add the space between this values. somthing like
result= myNoun + " " + myAdjective + " " + myVerb + " " + myAdverb;
Shahriar raju
@Rajudevo
Feb 26 2016 07:16

var result = "";
// Your code below this line

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("cat", "little", "hit", "slowly");

V Arun Kumar
@arunvkumr
Feb 26 2016 07:16
oh there you go... as @cannelflow said
@Rajudevo give 1 space between the quotes."" ->> " "
Shahriar raju
@Rajudevo
Feb 26 2016 07:17
ya i am done thanks all
cannelflow
@cannelflow
Feb 26 2016 07:17
@Rajudevo gr8 just ass spacing by +" "+
V Arun Kumar
@arunvkumr
Feb 26 2016 07:17
@Rajudevo you're welcome :smiley:
Marina
@chandra90
Feb 26 2016 07:17
@cannelflow Thank you very much!
CamperBot
@camperbot
Feb 26 2016 07:17
chandra90 sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
:star: 831 | @cannelflow | http://www.freecodecamp.com/cannelflow
cannelflow
@cannelflow
Feb 26 2016 07:18
@chandra90 @Rajudevo :+1:
Ankit Panwar
@coderNoob
Feb 26 2016 07:22

@Masd925 I don't understand how the reduce() is working. It has returned me all the elements combined and even repeated multiple times. Like 3 appears once but it returned me an array with two 3s in it.

function sym(args) {

args = Array.prototype.slice.call(arguments);
function SD(array1, array2){
return array1.filter(function(element){
return array2.indexOf(element)<0;
});
}
function unique(array1, array2){
return SD(array1, array2).concat(array2, array1);
}
var final = args.reduce(function(prev, curr){
return unique(prev, curr);
});
return final;
}

sym([1, 2, 3], [5, 2, 1, 4]);

output
[ 3, 5, 2, 1, 4, 1, 2, 3 ]

Robert Uivarosi
@URobert
Feb 26 2016 07:27
@vankatal Thanks!
CamperBot
@camperbot
Feb 26 2016 07:27
urobert sends brownie points to @vankatal :sparkles: :thumbsup: :sparkles:
:star: 288 | @vankatal | http://www.freecodecamp.com/vankatal
Markus Kiili
@Masd925
Feb 26 2016 07:27
@coderNoob Your unique function is not still doing the symmdiff of two arrays.
unique([1, 2, 3], [5, 2, 1, 4]); // returns [ 3, 5, 2, 1, 4, 1, 2, 3 ]
Should return [3,5,4]
Try .concat(SD(array2, array1))
Ankit Panwar
@coderNoob
Feb 26 2016 07:30
@Masd925 It worked. I missed the SD in concat
@Masd925 Thanks.
CamperBot
@camperbot
Feb 26 2016 07:31
codernoob sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1071 | @masd925 | http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Feb 26 2016 07:32
@coderNoob You are still not removing repeating elements from individual arrays before concating.
Ankit Panwar
@coderNoob
Feb 26 2016 07:32
@Masd925 This algo is frustrating and confusing.
Robert Uivarosi
@URobert
Feb 26 2016 07:32
@coderNoob did you come up with that nice thin implementation ?
Ankit Panwar
@coderNoob
Feb 26 2016 07:32
@URobert Pretty much
there was a lot of help on gitter.
Robert Uivarosi
@URobert
Feb 26 2016 07:33
I came up with a 40 lines version :))
I made it quite explicit, so it is easier to navigate (that's just how I ended up building it)
@coderNoob did you get it working?
Marina
@chandra90
Feb 26 2016 07:35
// Setup
var myArray = [1,2,3];

// Only change code below this line.
ourArray[0] = 3;
Why does not work? the task:Modify the data stored at index 0 of myArray to a value of 3.
DJ
@qualitymanifest
Feb 26 2016 07:36
@chandra90 you need to change myArray[0], but you're changing ourArray[0]
Rita Alfonso
@alfonsotech
Feb 26 2016 07:36
@chandra90 You have two different arrays, two dif fnames
Marina
@chandra90
Feb 26 2016 07:37
@qualitymanifest oops
Rita Alfonso
@alfonsotech
Feb 26 2016 07:37
hello everyone. happy coding
Marina
@chandra90
Feb 26 2016 07:37
@alfonsotech same to you! Thanks
CamperBot
@camperbot
Feb 26 2016 07:37
chandra90 sends brownie points to @alfonsotech :sparkles: :thumbsup: :sparkles:
:star: 306 | @alfonsotech | http://www.freecodecamp.com/alfonsotech
Rita Alfonso
@alfonsotech
Feb 26 2016 07:37
thanks @chandra90
CamperBot
@camperbot
Feb 26 2016 07:37
alfonsotech sends brownie points to @chandra90 :sparkles: :thumbsup: :sparkles:
:star: 181 | @chandra90 | http://www.freecodecamp.com/chandra90
Ankit Panwar
@coderNoob
Feb 26 2016 07:40
@URobert Not yet.
Robert Uivarosi
@URobert
Feb 26 2016 07:41
@coderNoob Here is my part of code dealing with duplicats
   for  (var u in tempResult){
if(resultwithUniques.indexOf(tempResult[u]) === -1){
resultwithUniques.push(tempResult[u]);
}
}
however I don't think that is your only problem
Ankit Panwar
@coderNoob
Feb 26 2016 07:46
@URobert Thanks. It's done.
CamperBot
@camperbot
Feb 26 2016 07:46
codernoob sends brownie points to @urobert :sparkles: :thumbsup: :sparkles:
:star: 627 | @urobert | http://www.freecodecamp.com/urobert
Robert Uivarosi
@URobert
Feb 26 2016 07:47
@coderNoob yw. That's the only part you changed ?
Ankit Panwar
@coderNoob
Feb 26 2016 07:47
@URobert Yup
function sym(args) {

args = Array.prototype.slice.call(arguments);
function SD(array1, array2){
return array1.filter(function(element){
return array2.indexOf(element)<0;
});
}
function unique(array1, array2){
return SD(array1, array2).concat(SD(array2, array1));
}
var final = args.reduce(function(prev, curr){
return unique(prev, curr);
});

var resultwithUniques=[];

for(var u in final){
if(resultwithUniques.indexOf(final[u]) === -1){
resultwithUniques.push(final[u]);
}
}

return resultwithUniques;
}

sym([1, 1, 2, 5], [2, 2, 3, 5], [3, 4, 5, 5]);
Markus Kiili
@Masd925
Feb 26 2016 07:48
@coderNoob You should not use for...in loop on iterating over array indices.
Robert Uivarosi
@URobert
Feb 26 2016 07:48
@Masd925 why?
Ankit Panwar
@coderNoob
Feb 26 2016 07:48
@Masd925 Why not? It's always the first thing that comes to my mind when I need to iterate over anything.
bhagwant
@sagit2002
Feb 26 2016 07:49

XY

var gear = 0;

this.setGear = function() {
return gear;
};

this.getGear = function() {
return gear;
};

var gear = 0;

this.setGear = function() {
return gear;
};

this.getGear = function() {
return gear;
};


What is wrong with the above code
Markus Kiili
@Masd925
Feb 26 2016 07:50
@URobert It is slower because it goes up the prototype chain looking for properties, the index order is not guaranteed to be in order and on real projects some libraries might add properties to arrays which would break your code. Also for...in handles holes differently from for loop.
Ankit Panwar
@coderNoob
Feb 26 2016 07:51
@Masd925 So we should instead use for(var = someValue; i<someOtherValue; i++)?
Markus Kiili
@Masd925
Feb 26 2016 07:51
@coderNoob For loop is the correct way.
Robert Uivarosi
@URobert
Feb 26 2016 07:51
   for  (var u = 0; u < tempResult.length; u++){
if(resultwithUniques.indexOf(tempResult[u]) === -1){
resultwithUniques.push(tempResult[u]);
}
}
then ? :D
Ankit Panwar
@coderNoob
Feb 26 2016 07:51
@Masd925 Okay thanks. I'll try to keep that in mind.
CamperBot
@camperbot
Feb 26 2016 07:51
codernoob sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: codernoob already gave masd925 points
bhagwant
@sagit2002
Feb 26 2016 07:52

Robert Uivarosi
@URobert
Feb 26 2016 07:52
@Masd925 thanks for that. I very rarely use for in... mostly going standard. Thanks
CamperBot
@camperbot
Feb 26 2016 07:52
urobert sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1072 | @masd925 | http://www.freecodecamp.com/masd925
bhagwant
@sagit2002
Feb 26 2016 07:52
js
Michael Poutre
@M1kep
Feb 26 2016 07:53
Is there anybody here who can please trey to help me with this stupid steamrololer ting
bhagwant
@sagit2002
Feb 26 2016 07:53

var gear = 0;

this.setGear = function() {
return gear;
};

this.getGear = function() {
return gear;
};

Michael Poutre
@M1kep
Feb 26 2016 07:53
I just keep crashing my browser,. but In my head the code makes sense
bhagwant
@sagit2002
Feb 26 2016 07:53
what is wrong with above code
Markus Kiili
@Masd925
Feb 26 2016 07:53
@sagit2002 setGear should set the gear with = operator. Therefore you need a parameter on setGear.
Michael Poutre
@M1kep
Feb 26 2016 07:53
well @sagit2002 setGear just returns gear rather than chaning it
function steamroller(arr) {
newArray = [];
for (a = 0; a < arr.length; a++) {
if (Array.isArray(arr[a])) {
newArray.push(steamroller(arr[a]));
} else {
newArray.push(arr[a]);
}
}
return newArray;
}

steamroller([1, [2], [3, [[4]]]]);
somebody
bhagwant
@sagit2002
Feb 26 2016 07:55
@Masd925 Thanks a lot buddy
CamperBot
@camperbot
Feb 26 2016 07:55
sagit2002 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1074 | @masd925 | http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Feb 26 2016 07:57
@M1kep Try concating steamrolled elements to result. That way it picks the elements from inner arrays.
Shahriar raju
@Rajudevo
Feb 26 2016 07:57
167 multi-dimensional array, someone help plz
demipixel
@demipixel
Feb 26 2016 07:58
167 dimensions?
Because if so that's amazing
We should graph that
We can use my handy dandy 167D Graphing Engine
Shahriar raju
@Rajudevo
Feb 26 2016 07:59
myData = 8 is the task but i don't understand
demipixel
@demipixel
Feb 26 2016 07:59
Shahriar raju
@Rajudevo
Feb 26 2016 08:00
step no 167 @demipixel
demipixel
@demipixel
Feb 26 2016 08:00
OOOHH
I thought the array had 167 dimensions
That makes more sense now
Alright
Access MultiDimensional Arrays With Indexes ?
Shahriar raju
@Rajudevo
Feb 26 2016 08:01
ya
demipixel
@demipixel
Feb 26 2016 08:01
Sweet, alright
So right now we have
[[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]]
Instead of imaging these each as arrays, just think of them as elements
Shahriar raju
@Rajudevo
Feb 26 2016 08:02
ya
demipixel
@demipixel
Feb 26 2016 08:02
[A, B, C, D]
A is [1,2,3]
B is [4,5,6]
etc
Now, which of these is "8" in?
Shahriar raju
@Rajudevo
Feb 26 2016 08:03
c
demipixel
@demipixel
Feb 26 2016 08:03
Right
Michael Poutre
@M1kep
Feb 26 2016 08:03
@Masd925 I think thats what im already doing by pushing th result to newArray and returing it to the preview call to steamroller
demipixel
@demipixel
Feb 26 2016 08:03
And what index is that at
Shahriar raju
@Rajudevo
Feb 26 2016 08:03
2
demipixel
@demipixel
Feb 26 2016 08:03
Okay, so
myArray[2] will actually give us [7,8,9]
What index is 8 at there
Shahriar raju
@Rajudevo
Feb 26 2016 08:04
ok let me try
demipixel
@demipixel
Feb 26 2016 08:04
Sweet
Michael Poutre
@M1kep
Feb 26 2016 08:04
But its still not working and io have zero clue as to way
why
Mihai Lita
@atryx
Feb 26 2016 08:05
function bouncer(arr) {
// Don't show a false ID to this bouncer.
var arr2 = [];
var x = new Boolean();
for ( i = 0 ; i < arr.length; i++ ) {
x = arr[i];
if ( x ) {
arr2.push(arr[i]);
}
}
return arr2;
}
my code is working fine for the Falsy Bouncer problem
but I didn't use Array.filter
Markus Kiili
@Masd925
Feb 26 2016 08:05
@M1kep Result of steamroller call is always an array, so you are pushing arrays to your result instead of numbers.
demipixel
@demipixel
Feb 26 2016 08:06
I didn't even know new Boolean() was a thing
Markus Kiili
@Masd925
Feb 26 2016 08:06
@atryx No reason to use new Boolean() ever.
demipixel
@demipixel
Feb 26 2016 08:06
@atryx You don't have to use filter if you don't want to
I can teach you how if you'd like, though
Mihai Lita
@atryx
Feb 26 2016 08:07
@demipixel sure, would love it
Shahriar raju
@Rajudevo
Feb 26 2016 08:07

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 = myArray[2];
not worrking @demipixel

Mihai Lita
@atryx
Feb 26 2016 08:07
@Masd925 what should I use?
Michael Poutre
@M1kep
Feb 26 2016 08:07
@Masd925 not even for:
bonfire boo who
CamperBot
@camperbot
Feb 26 2016 08:07

function boo(bool) {
// What is the new fad diet for ghost developers? The Boolean.
return bool;
}

boo(null);

Check if a value is classified as a boolean primitive. Return true or false.

more info:  bf details | bf links | hint

Markus Kiili
@Masd925
Feb 26 2016 08:07
@atryx var x;
demipixel
@demipixel
Feb 26 2016 08:07
@Rajudevo myArray[2] contains [7,8,9]
Michael Poutre
@M1kep
Feb 26 2016 08:07
bf details
CamperBot
@camperbot
Feb 26 2016 08:07

function boo(bool) {
// What is the new fad diet for ghost developers? The Boolean.
return bool;
}

boo(null);
Check if a value is classified as a boolean primitive. Return true or false.
Boolean primitives are true and false.
Remember to use RSAP if you get stuck. Try to pair program. Write your own code.
demipixel
@demipixel
Feb 26 2016 08:08
We only want "8"
So how do we get a value from an array?
@atryx Alright, so
Michael Poutre
@M1kep
Feb 26 2016 08:08
nvm im a tard
that was the first way i did it
butit didnt work
demipixel
@demipixel
Feb 26 2016 08:08
Do you know what filter does is the first thing?
Michael Poutre
@M1kep
Feb 26 2016 08:08
back to this stupid steamroller
Mihai Lita
@atryx
Feb 26 2016 08:08
@Masd925 in that case, I don't need x at all
Markus Kiili
@Masd925
Feb 26 2016 08:08
@M1kep Boolean object (created with new) and Boolean function are two different things. You use Boolean function yes.
Mihai Lita
@atryx
Feb 26 2016 08:09
function bouncer(arr) {
// Don't show a false ID to this bouncer.
var arr2 = [];
for ( i = 0 ; i < arr.length; i++ ) {
if ( arr[i] ) {
arr2.push(arr[i]);
}
}
return arr2;
}
demipixel
@demipixel
Feb 26 2016 08:09
@atryx Sweet, okay, so
Filter literally does exactly that
Shahriar raju
@Rajudevo
Feb 26 2016 08:09
got it [2][1] @demipixel
Michael Poutre
@M1kep
Feb 26 2016 08:09
Hrrrrm
demipixel
@demipixel
Feb 26 2016 08:10
The paramater is a function that passes the element. If you return true, it stays in the array. If you return false, it gets kicked out
Mihai Lita
@atryx
Feb 26 2016 08:10
ok
demipixel
@demipixel
Feb 26 2016 08:10
@Rajudevo Sweet, man
Markus Kiili
@Masd925
Feb 26 2016 08:12
@M1kep String, Number, and Boolean objects are wrapper objects for using methods on corresponding primitive values. It is better not to create them yourselves. Only leads to problems if you do.
Michael Poutre
@M1kep
Feb 26 2016 08:14
UGH this steamroller thing is irrataiing me
ANd Ill make sure to stay away from using new Boolean and shiz niz
So not like Java :P
Markus Kiili
@Masd925
Feb 26 2016 08:14
@M1kep It works if you concat instead of push.
Nick Robson
@nickrobson
Feb 26 2016 08:15
@M1kep You should never be using new Boolean(true) in Java, anyway.
ismail norri
@ismailnorri
Feb 26 2016 08:15

Storing Values with the Equal Operator
In JavaScript, you can store a value in a variable with the assignment or equal (=) operator.

myVariable = 5;

Assigns the Number value 5 to myVariable.

Assignment always goes from right to left. Everything to the right of the = operator is resolved before the value is assigned to the variable to the left of the operator.

myVar = 5;
myNum = myVar;
Assigns 5 to myVar and then resolves myVar to 5 again and assigns it to myNum.

Instructions
Assign the value 7 to variable a.

Assign the contents of a to variable b.

// Setup
var a;
var b = 2;
var myVariable = 5;
var myVar = 5 ;
var myNum = 5 ;
var a = 7;
var b
var a = b ;

// Only change code below this line

Michael Poutre
@M1kep
Feb 26 2016 08:15
Well new Boolean(true); no, but stuff like new String() is what came to minmd
For some reasoin
Bartosz
@CataciD
Feb 26 2016 08:16
help format
CamperBot
@camperbot
Feb 26 2016 08:16

## :point_right: code formatting [wiki]

### Inline code

This an inline <paste code here> code formatting with a single backtick() at start and end around the code.

### Code Block

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 ⏎]

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

Michael Poutre
@M1kep
Feb 26 2016 08:16
lol
Bartosz
@CataciD
Feb 26 2016 08:16
use this if you're pasting code
Markus Kiili
@Masd925
Feb 26 2016 08:16
@M1kep That is different because strings are objects in java.
ismail norri
@ismailnorri
Feb 26 2016 08:16

// Setup
var a;
var b = 2;
var myVariable = 5;
var myVar = 5 ;
var myNum = 5 ;
var a = 7;
var b
var a = b ;

// Only change code below this line

Bartosz
@CataciD
Feb 26 2016 08:16
> // Setup
var a;
var b = 2;
var myVariable = 5;
var myVar = 5 ;
var myNum = 5 ;
var a = 7;
var b
var a = b ;

// Only change code below this line
ismail norri
@ismailnorri
Feb 26 2016 08:16
can you corect lease
Michael Poutre
@M1kep
Feb 26 2016 08:17
@Masd925 concat still crashes my browswer
Bartosz
@CataciD
Feb 26 2016 08:17
holy damn
ok do you understand what VAR means?
var means "I DECLARE"
if you declare once you don't do it again for that thing
Michael Poutre
@M1kep
Feb 26 2016 08:17
Erm..... and the "only change code BELOW this line"
Bartosz
@CataciD
Feb 26 2016 08:17
kind of
some people don't even read ; x
demipixel
@demipixel
Feb 26 2016 08:18
Bartosz
@CataciD
Feb 26 2016 08:18
especially in coding : ^ ) @demipixel
Michael Poutre
@M1kep
Feb 26 2016 08:18
Sigh, waiting for my browswer to respon
demipixel
@demipixel
Feb 26 2016 08:19
@CataciD So, where are ya in the whole free camp thing
Bartosz
@CataciD
Feb 26 2016 08:19
2 more projects and im done with front end
Michael Poutre
@M1kep
Feb 26 2016 08:19
CamperBot
@camperbot
Feb 26 2016 08:19
:star: 338 | @catacid | http://www.freecodecamp.com/catacid
Bartosz
@CataciD
Feb 26 2016 08:19
im half way though both
demipixel
@demipixel
Feb 26 2016 08:20
@CataciD like front-end certificate? :D
Bartosz
@CataciD
Feb 26 2016 08:20
ye
i need to make the tic tac toe game
and the simon game
and i have the cert
demipixel
@demipixel
Feb 26 2016 08:20
Sweet man
Bartosz
@CataciD
Feb 26 2016 08:20
yeah too k like 2 months
Michael Poutre
@M1kep
Feb 26 2016 08:20
I can do these algorithms and what not for the most part but the projects throw me off, especially the portfolio
Bartosz
@CataciD
Feb 26 2016 08:20
tho to be fair i didnt code every day
demipixel
@demipixel
Feb 26 2016 08:20
would you say the time they say it takes is approximately how long it took?
Michael Poutre
@M1kep
Feb 26 2016 08:21
cause im not very good at presentation stuff
demipixel
@demipixel
Feb 26 2016 08:21
i.e. If it said 50 hours did it take about that long?
Bartosz
@CataciD
Feb 26 2016 08:21
so far its been like 11 days each month
@demipixel that depends really
Robert Uivarosi
@URobert
Feb 26 2016 08:21
@CataciD gl. I know tic tac toe was simplified. If you want an extra challenge, try to make the AI unbeatable ;
Bartosz
@CataciD
Feb 26 2016 08:21
URobert the AI is either unbeatable or draw
afaik
kirbyedy
@kirbyedy
Feb 26 2016 08:22
they changed that
Bartosz
@CataciD
Feb 26 2016 08:22
@demipixel some of those 200h really took a lot of time
kirbyedy
@kirbyedy
Feb 26 2016 08:22
does not have to be unbeatable
Bartosz
@CataciD
Feb 26 2016 08:22
did they @kirbyedy ?
well then that kills the fun out of programming an AI now doesnt it ?
kirbyedy
@kirbyedy
Feb 26 2016 08:22
yea, I think, let me double check that
Robert Uivarosi
@URobert
Feb 26 2016 08:22
@CataciD it is a pain in the * :))
Bartosz
@CataciD
Feb 26 2016 08:22
i mean i started the challange when it was still in the intermediate
not in the advanced section :P
L Yeh
@PhotoGeek1
Feb 26 2016 08:23

Need help on the Chunky Monkey basic Algorithm

I'm getting an error message I don't understand:
"TypeError: Cannot set property '0' of undefined"

code:

function chunk(arr, size) {
// Break it up.

// create final array to store answer
var finalArray = [];

for (i=0; i<Math.ceil(arr.length/size); i++) { // # rows need to create
for (j=0; j<size; j++) {    // # columns
finalArray[i][j] = arr[i];
}

}
return finalArray;

}

chunk(["a", "b", "c", "d"], 2);

Can someone please look over what I have?

kirbyedy
@kirbyedy
Feb 26 2016 08:23
yep, does not say anything about unbeatable
Michael Poutre
@M1kep
Feb 26 2016 08:23
This is pissing me off. I still cant even figure out why its crashing my browser, proably has somehting to do with calling the function within the function
Robert Uivarosi
@URobert
Feb 26 2016 08:23
@CataciD if you want to make it more "fun" you can add extra functionality, and make it with multiple difficulty levels, so you can pick a level where you can actually win
Bartosz
@CataciD
Feb 26 2016 08:24
@URobert yeah i know, but to be fair all i want is to get to the certificate checkmark so i can get on with the next thing
i want to do everything
thats available in fcc
i've learned so much only by doing like 2 weeks coding per month
Michael Poutre
@M1kep
Feb 26 2016 08:24
This is retarted. I"m going to bed before I throw my computer out the windws
Bartosz
@CataciD
Feb 26 2016 08:25
lol wait
whats the task cause i dont remember
Michael Poutre
@M1kep
Feb 26 2016 08:25
The steamroller
bonfire steamroller
CamperBot
@camperbot
Feb 26 2016 08:25

function steamroller(arr) {
// I'm a steamroller, baby
return arr;
}

steamroller([1, [2], [3, [[4]]]]);

Flatten a nested array. You must account for varying levels of nesting.

more info:  bf details | bf links | hint

Michael Poutre
@M1kep
Feb 26 2016 08:26
I tried concat like @Masd925 said
Bartosz
@CataciD
Feb 26 2016 08:26
that was a tough one
Michael Poutre
@M1kep
Feb 26 2016 08:26
and its still crashing
Bartosz
@CataciD
Feb 26 2016 08:26
wait
Michael Poutre
@M1kep
Feb 26 2016 08:26
function steamroller(arr) {
newArray = [];
console.log(arr);
console.log("Length:  " + arr.length);
for (a = 0; a < arr.length; a++) {
if (Array.isArray(arr[a])) {
newArray.concat(steamroller(arr[a]));
} else {
newArray.concat(arr[a]);
}
}
return newArray;
}
console.log("Final Array:");
console.log(steamroller([[["a"]], [["b"]]]));
Bartosz
@CataciD
Feb 26 2016 08:26
aw shit i did it my own logic really
i made some if statements checking if theres a next level
basically
if the table inside this table had the length of 1
Michael Poutre
@M1kep
Feb 26 2016 08:27
Like I could write it to pass the tests buyt that doesnt pass the realworld test
Bartosz
@CataciD
Feb 26 2016 08:27
that meant i can extract the number
etc
to be fair
you're supposed to pass the test
nothing else
youll worry about the realworld when you're using this for real things
:P
still try and not use specific values etc
demipixel
@demipixel
Feb 26 2016 08:28
Trying to figure out whether I should try and get these certificates so I can do this non-profit thing and get the coding interview training
Bartosz
@CataciD
Feb 26 2016 08:28
im tempted to show you my solution but its not a good idea
@demipixel what's there to figure out? :P
demipixel
@demipixel
Feb 26 2016 08:28
Well
Bartosz
@CataciD
Feb 26 2016 08:29
"do i want free knowledge?"
;D
demipixel
@demipixel
Feb 26 2016 08:29
I'm guessing it'll be like 20 hours to get the certificates for each
idk if I should sink the time
*20 hours for all
Nick Robson
@nickrobson
Feb 26 2016 08:29
@demipixel It'll take longer than that :)
demipixel
@demipixel
Feb 26 2016 08:29
I mean
If I'm actually paying attention and not helping people here
Nick Robson
@nickrobson
Feb 26 2016 08:30
It'll take that long for each set of challenges, but then you need to do the frontend/backend projects.
demipixel
@demipixel
Feb 26 2016 08:30
It takes me like 20min at most to do those backend projects
Robert Uivarosi
@URobert
Feb 26 2016 08:30
@demipixel 20 min?
demipixel
@demipixel
Feb 26 2016 08:30
And those are the only things really required for the certificate
Robert Uivarosi
@URobert
Feb 26 2016 08:30
@demipixel hahah
demipixel
@demipixel
Feb 26 2016 08:30
@URobert Yeah I've almost done 3
The API Projects
kirbyedy
@kirbyedy
Feb 26 2016 08:30
can we see them ?
demipixel
@demipixel
Feb 26 2016 08:30
Haven't looked at the Dynamic Web ones yet
Robert Uivarosi
@URobert
Feb 26 2016 08:30
@demipixel I bet they look like ** , no offence
demipixel
@demipixel
Feb 26 2016 08:30
Um
They output JSON
Nick Robson
@nickrobson
Feb 26 2016 08:31
They really should teach nodejs with CoffeeScript.
demipixel
@demipixel
Feb 26 2016 08:31
It's a backend project, of course they look like shit
I save my CSS for frontend
Robert Uivarosi
@URobert
Feb 26 2016 08:31
@demipixel did you do the timer in 20 min too ?
Nick Robson
@nickrobson
Feb 26 2016 08:31
CoffeeScript is best script.
demipixel
@demipixel
Feb 26 2016 08:31
@URobert I've done the first three, chill out
Robert Uivarosi
@URobert
Feb 26 2016 08:31
@demipixel oh, you're talking about backend projects. sorry
demipixel
@demipixel
Feb 26 2016 08:31
Might take me 100 hours on the next
Bartosz
@CataciD
Feb 26 2016 08:31
@demipixel yeah but to be fair, im doing EVERYTHING
just doing projects wont show you mistakes and chokes will be much harder
Robert Uivarosi
@URobert
Feb 26 2016 08:32
@CataciD was talking about front end projects
demipixel
@demipixel
Feb 26 2016 08:32
@CataciD To be fair, I've had over 5 years of experience programming already, sooo
Bartosz
@CataciD
Feb 26 2016 08:32
@demipixel that was what I was going to ask for
demipixel
@demipixel
Feb 26 2016 08:32
Yeah, I think I've just already put in a lot of these hours elsewhere
kirbyedy
@kirbyedy
Feb 26 2016 08:32
@demipixel why do you need the certificate then ?
Bartosz
@CataciD
Feb 26 2016 08:32
@demipixel this is a usefull place but to an extend
@demipixel its more for people starting out or like me, that know something but not really enough to do anything with it
demipixel
@demipixel
Feb 26 2016 08:33
Because working with a non-profit, I don't know... What else do you add to your Resumé?
Bartosz
@CataciD
Feb 26 2016 08:33
so if you want to work for nonprofits
do it
whats the problem
either here
or just advertise yourself on the net/paper
demipixel
@demipixel
Feb 26 2016 08:33
Also getting practice coding interviews would be nice
Bartosz
@CataciD
Feb 26 2016 08:33
and youll get there
kirbyedy
@kirbyedy
Feb 26 2016 08:33
well after 5 years of programming if you dont have any project to show to your future employer... then you are in problem
demipixel
@demipixel
Feb 26 2016 08:33
Meh, I've done some freelances, not that big though
@kirbyedy I do but personal open source projects don't say as much as working with an actual company
Markus Kiili
@Masd925
Feb 26 2016 08:34
@M1kep You can avoid the infinite loop by checking arrayness first:
function steamroller(arr) {
if (!Array.isArray(arr)) return arr;

result = [];

for (var i=0; i<arr.length; i++) {
result = result.concat(steamroller(arr[i]));
}

return result;
}
kirbyedy
@kirbyedy
Feb 26 2016 08:34
look, the certificate does not prove much, just that you went through some course
but if your employer sees you actually have some project done
Bartosz
@CataciD
Feb 26 2016 08:35
@kirbyedy well it actually does
thing with coding is
"you coded this" is an achievement
cause a lot of people code
kirbyedy
@kirbyedy
Feb 26 2016 08:35
and you can discuss with him your code, that is the real thing
Bartosz
@CataciD
Feb 26 2016 08:35
but do not make or finish anything
kirbyedy
@kirbyedy
Feb 26 2016 08:35
yes, but a lot of people do copy/paste coding ;)
demipixel
@demipixel
Feb 26 2016 08:35
@kirbyedy I'd love to be able to say "I've done these projects but I've also worked here here and here" and also be able to nail interviews
Bartosz
@CataciD
Feb 26 2016 08:35
@kirbyedy then it goes to shit
yeah that
Michael Poutre
@M1kep
Feb 26 2016 08:36
@CataciD see what I mean, I can morph it to fit the tests, but if it has more then 3 deep array then it wont work
function steamroller(arr) {
newArray = [];
for(x = 0; x < arr.length; x++) {
if(Array.isArray(arr[x])) {
for(y = 0; y < arr[x].length; y++) {
if(Array.isArray(arr[x][y])) {
for(z = 0; z < arr[x][y].length; z++) {
newArray = newArray.concat(arr[x][y][z]);
}
} else {
newArray = newArray.concat(arr[x][y]);
}
}
} else {
newArray = newArray.concat(arr[x]);
}
}
return newArray;
}

steamroller([1, [2], [3, [[4]]]]);`
demipixel
@demipixel
Feb 26 2016 08:36
Certificates seem more like personal achievements and FCC steps than they are things to brag about on a resumé
kirbyedy
@kirbyedy
Feb 26 2016 08:36
yes
Bartosz
@CataciD
Feb 26 2016 08:36
@M1kep make it check how deep it goes
you can always do while
and check for the type
if the contents of arr[0] is an array
check further
take a variable
make it arr[0]
if contents of that var is an array
then change it to arr[0] whats inside
and so on
is not an array
until the type of data in that slot
then extract and begin going back up
that was the logic i followed
demipixel
@demipixel
Feb 26 2016 08:38
@kirbyedy So you recommend sticking around to help people but look elsewhere for actually getting interview help + working experience?
Michael Poutre
@M1kep
Feb 26 2016 08:38
@demipixel I feel if you make it to the non profit part youll have plenty of stuff in your portfolio
especially if you complete the non profit stuffs
Bartosz
@CataciD
Feb 26 2016 08:38
@demipixel yeah, I've heard from one academic teacher that helping people with simple things actually makes you a better coder cause you start to notice those things in a blast
also yeah, the nonprofit part is the most valuable here
Robert Uivarosi
@URobert
Feb 26 2016 08:39
@CataciD +1
demipixel
@demipixel
Feb 26 2016 08:39
Bartosz
@CataciD
Feb 26 2016 08:39
for me I really like being here, i never used the chat ealier when i started
but now i notice things i did wrong even if it passed the tests
demipixel
@demipixel
Feb 26 2016 08:39
Because I would need to get all these certificates to get to the nonprofit thing
Robert Uivarosi
@URobert
Feb 26 2016 08:40
@CataciD helping people can help you be a better coder... and you can brag on an interview that you have helped x nr of people debug their code
Bartosz
@CataciD
Feb 26 2016 08:40
cause i've seen 10 different approaches to every bonfire and challange
kirbyedy
@kirbyedy
Feb 26 2016 08:40
@demipixel no, go with the non-profit
and do at least one project on your own
whatever you like
Bartosz
@CataciD
Feb 26 2016 08:40
@demipixel 1 question, do you want those non profits?
demipixel
@demipixel
Feb 26 2016 08:40
want?
Bartosz
@CataciD
Feb 26 2016 08:40
cause you said those certs take you like 20h... wtf thats like half of a work week
whats that to a coder
i mean cmon
20h is like one toilet sitting
: ^ )
kirbyedy
@kirbyedy
Feb 26 2016 08:41
but seriously after5 years of coding you should have couple of decent project behind you
Bartosz
@CataciD
Feb 26 2016 08:41
but for real, its like 4 hours
daily
and you're done in a week
thats really not a lot
demipixel
@demipixel
Feb 26 2016 08:41
@kirbyedy I do
Michael Poutre
@M1kep
Feb 26 2016 08:41
Idk what kind of toilet sitting you've been doing @CataciD
kirbyedy
@kirbyedy
Feb 26 2016 08:41
ok, can we see them ?
Bartosz
@CataciD
Feb 26 2016 08:41
@M1kep meme sitting : ^ )
demipixel
@demipixel
Feb 26 2016 08:41
Small or Big?
Michael Poutre
@M1kep
Feb 26 2016 08:41
kirbyedy
@kirbyedy
Feb 26 2016 08:41
whatever you think is your best project
Bartosz
@CataciD
Feb 26 2016 08:42
whelp
and im just sitting here
my biggest project being the fucking calculator in codepen.io : ^ )
WHELP
kirbyedy
@kirbyedy
Feb 26 2016 08:42
well you have to start somewhere :D