These are chat archives for FreeCodeCamp/HelpJavaScript

20th
Nov 2016
Moisés Man
@moigithub
Nov 20 2016 00:01
pretty quiet today :)
Jordan
@jordanallain
Nov 20 2016 00:01
saturday!
KyleSwanny
@KyleSwanny
Nov 20 2016 00:04
anyone here from india?
Jordan
@jordanallain
Nov 20 2016 00:05
not me
Moisés Man
@moigithub
Nov 20 2016 00:05
you!!
silver537
@silver537
Nov 20 2016 00:11
WE ARE FAM-I-LY
Nick Garcia
@NicksIdeaEngine
Nov 20 2016 00:31
Hey guys, in case it hasn't been mentioned already, Code School is free this weekend. :D
Walid Ashri
@walidashri
Nov 20 2016 00:35
@moigithub they all at school :)
@silver537 long time no c or D :p
Ian Lee
@asparism
Nov 20 2016 00:38
does anyone know why this codepen won't clearInterval properly? it's for the pomodoro clock: http://codepen.io/Asparism/pen/ENNxBP?editors=0010
Moisés Man
@moigithub
Nov 20 2016 00:41
@asparism probably the timer variable created on diff scope.. ?
var theTimer; on top... remove var keyword on ur countdown function
Ian Lee
@asparism
Nov 20 2016 00:44
i wondered about that, but they're both inside the same countDown function.
sometimes it will glitch out though and the numbers will jump around as if it's running the timer and then clearing it and then running it and then clearing it over and over again
Diane
@106Ch213
Nov 20 2016 00:53
Hi guys, can you see what's the problem with my code? I noticed that the arr only returns the first part of the argument passed onto the function but I don't know how to fix that. Right now my filtering array is always returning an empty array.
function destroyer(arr) {
  // Remove all the values

  function filter(arr){
    var fil = [];
    //var args = [];
    //args = Array.prototype.slice.call(arr);
    //return arr;

    for (i = 1; i < arr.length; i++){
      for (j = 1; j < arr[0].length; j++){
          if (arr[0][j] == arr[i]){
          fil.push(arr[i]);
          }
      }
    }
      return arr[0] !== fil;  
    //}    

  }


    return arr.filter(filter);
  }



destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Ghadir Mira
@GhadirMira
Nov 20 2016 00:57

var string = "Split me into an array";
var array = [];

// Only change code below this line.

array = string.split();

Use split to create an array of words from string and assign it to array
anyone help ?
MoNag1
@MoNag1
Nov 20 2016 00:59
@GhadirMira you need to add something in between your (). Whatever you add inside will be where split executes
basically you need to tell it where to split at
Ghadir Mira
@GhadirMira
Nov 20 2016 01:00
so what do i put?
I dont get it
You should split the string by its spaces.
MoNag1
@MoNag1
Nov 20 2016 01:01
tell it where to split, you want to split at each space so you can get seperate words @GhadirMira
Ghadir Mira
@GhadirMira
Nov 20 2016 01:01
You should split the string by its spaces.
MoNag1
@MoNag1
Nov 20 2016 01:01
so add " " in between
Ghadir Mira
@GhadirMira
Nov 20 2016 01:01
It's not working
MoNag1
@MoNag1
Nov 20 2016 01:02
array = string.split(" ");
does it look like that ^?
Ghadir Mira
@GhadirMira
Nov 20 2016 01:02
oh I missed the space
thnx^^
MoNag1
@MoNag1
Nov 20 2016 01:03
@GhadirMira anytime
Ghadir Mira
@GhadirMira
Nov 20 2016 01:03
@MoNag1 Sohkran
MoNag1
@MoNag1
Nov 20 2016 01:04
@GhadirMira 3afwan :p
Allisha
@lazershark4PrimeMinister
Nov 20 2016 01:08

Hey all, I'm working on the Basic Algorithm section: Find the Longest Word in a String. I thought it was pretty simple to solve:

function findLongestWord(str) {
var wordString = str.split(' ');
return wordString.length;
}

findLongestWord("The quick brown fox jumped over the lazy dog");

I'm trying to return the word with the longest length but I keep getting '9'...none of those words are 9 characters long. Am I missing something after .length that would tell JS to return only the longest word?

Thanks in advance
Margaret
@Margaret2
Nov 20 2016 01:08
@lazersharkPM wordString is an array, you have to loop through the array and find the length of each item in the array
Allisha
@lazershark4PrimeMinister
Nov 20 2016 01:09
ah, so I need a for loop?
Margaret
@Margaret2
Nov 20 2016 01:09
probably
Allisha
@lazershark4PrimeMinister
Nov 20 2016 01:09
one more Q
Moisés Man
@moigithub
Nov 20 2016 01:09
@106Ch213 if i recall.. u need to use the arguments object for that exercise.. there are a link on the challenge description
NITIN RAGHAV
@nitinraghav
Nov 20 2016 01:09
I just finished Weather app challenge heres the codePen. Kindly share your suggestions/comments . thanks
http://codepen.io/nitinraghav/pen/rWjwZR?editors=1010
Allisha
@lazershark4PrimeMinister
Nov 20 2016 01:09
how can I post an image of what I'm seeing instead of a basic txt version of my code?
MoNag1
@MoNag1
Nov 20 2016 01:10
@106Ch213 are you trying to loop through the arr using arr[0] and the arguments as arr[1]?
Allisha
@lazershark4PrimeMinister
Nov 20 2016 01:10
It's way easier to read when it's on the chalkboard background
Margaret
@Margaret2
Nov 20 2016 01:10
@lazersharkPM with 3 backticks on the lines before and after your code
Allisha
@lazershark4PrimeMinister
Nov 20 2016 01:11

///
function findLongestWord(str) {
var wordString = str.split(' ');
return wordString.length;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
///

\\
function findLongestWord(str) {
var wordString = str.split(' ');
return wordString.length;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
\\

Margaret
@Margaret2
Nov 20 2016 01:11
@lazersharkPM in the chat box there is a button with an m on it for markdown help, it will show you
backticks are next to the 1 on your keyboard
Allisha
@lazershark4PrimeMinister
Nov 20 2016 01:11
gotchya
function findLongestWord(str) {
  var wordString = str.split(' ');
  return wordString.length;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Margaret
@Margaret2
Nov 20 2016 01:11
:clap:
Allisha
@lazershark4PrimeMinister
Nov 20 2016 01:11
oh sweet mother of pearl. YES
@Margaret2
MoNag1
@MoNag1
Nov 20 2016 01:12
@106Ch213 you're getting an empty array because something like arr[0][j] returns nothing whatever j is
Allisha
@lazershark4PrimeMinister
Nov 20 2016 01:12
@Margaret2 and how do I give dem brownie pts?
Diane
@106Ch213
Nov 20 2016 01:12
@MoNag1 ohhh I think I get it now thanks !
CamperBot
@camperbot
Nov 20 2016 01:12
106ch213 sends brownie points to @monag1 :sparkles: :thumbsup: :sparkles:
:cookie: 340 | @monag1 |http://www.freecodecamp.com/monag1
Margaret
@Margaret2
Nov 20 2016 01:12
@lazersharkPM by typing thanks, thank you, or ty, or thx
CamperBot
@camperbot
Nov 20 2016 01:12
margaret2 sends brownie points to @lazersharkpm :sparkles: :thumbsup: :sparkles:
:cookie: 244 | @lazersharkpm |http://www.freecodecamp.com/lazersharkpm
Margaret
@Margaret2
Nov 20 2016 01:13
:D and tagging the person you want to give them to
Allisha
@lazershark4PrimeMinister
Nov 20 2016 01:13
@Margaret2 :)
:) @Margaret2
@Margaret2 :D
I'm trying Margaret but I have no game
Margaret
@Margaret2
Nov 20 2016 01:14
:joy: you have to type @Margaret2 thanks
CamperBot
@camperbot
Nov 20 2016 01:14
sorry margaret2, you can't send brownie points to yourself! :sparkles: :sparkles:
Margaret
@Margaret2
Nov 20 2016 01:14
not the smiley face
Allisha
@lazershark4PrimeMinister
Nov 20 2016 01:14
@Margaret2 thanks
CamperBot
@camperbot
Nov 20 2016 01:14
lazersharkpm sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:cookie: 488 | @margaret2 |http://www.freecodecamp.com/margaret2
Margaret
@Margaret2
Nov 20 2016 01:15
:joy: good job
Allisha
@lazershark4PrimeMinister
Nov 20 2016 01:15
Crushin it
I'll be at NASA tomorrow
Margaret
@Margaret2
Nov 20 2016 01:15
:joy: put in a good word for me when you get there
Allisha
@lazershark4PrimeMinister
Nov 20 2016 01:15
:+1:
RafaelZarate
@RafaelZarate
Nov 20 2016 01:17
How do I need to do to add an object to an array on JSON?
What*
MoNag1
@MoNag1
Nov 20 2016 01:26
@RafaelZarate send your code and challenge name?
silver537
@silver537
Nov 20 2016 01:28
@walidashri ;)
Jace
@jacebenson
Nov 20 2016 01:33
Okay, I'm having trouble with the Simon project. My issue is when the computer presses two buttons back to back of the same color, it doesn't change the class but does trigger the color. jacebenson.com/projects/simon jacebenson.com/projects/simon/custom.js
AviPeltz
@AviPeltz
Nov 20 2016 01:36
I'm stuck on Record collection can someone help me
Walid Ashri
@walidashri
Nov 20 2016 01:37
Array.prototype.numberOfOccurrences = ()=> {
var x= arguments[0];
  return this.filter((a)=> x ===a ).length;
}
why arguments undefined ?!
AviPeltz
@AviPeltz
Nov 20 2016 01:41
pleaseeee
andry91959
@andry91959
Nov 20 2016 01:44
Capture.PNG
hi im trying to do math random exercise but If I did it correctly
Walid Ashri
@walidashri
Nov 20 2016 01:46
@andry91959 change product instead of console loging
andry91959
@andry91959
Nov 20 2016 01:47
wait
wrong pic
Capture3.PNG
the system says its correct
but I think something is wrong
Walid Ashri
@walidashri
Nov 20 2016 01:49
just return the Math.random()
andry91959
@andry91959
Nov 20 2016 01:58
got it now :)
hi Im trying to understand this Idea
I mean formula
43.PNG
why do we need to plus it with one?
AviPeltz
@AviPeltz
Nov 20 2016 01:59
I got Record Collection right but can someone explain it to me?
Johnny
@JohnnyBizzel
Nov 20 2016 02:02
@AviPeltz How to set properties of Objects?
@walidashri Spoiler alert!! :O
Walid Ashri
@walidashri
Nov 20 2016 02:04

@JohnnyBizzel

I got Record Collection right but can someone explain it to me?

Ken Haduch
@khaduch
Nov 20 2016 02:07
@AviPeltz - how did you get it right if you do not understand it? Can you post your code and ask questions about what you don't understand?
Joseph
@revisualize
Nov 20 2016 02:08
@AviPeltz What's your function look like? What do you have questions about?
silver537
@silver537
Nov 20 2016 02:12
@andry91959 because Math.random() returns a value from 0 to excluding 1
so from 0 - 0.999999999999999...
and since you're using Math.floor, the ranged number will never be calculated
AviPeltz
@AviPeltz
Nov 20 2016 02:17

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

return collection;
}

nvm I get it now
Walid Ashri
@walidashri
Nov 20 2016 02:20
Ouch :(
Ken Haduch
@khaduch
Nov 20 2016 02:28
@AviPeltz - it's good that it works, the code could be cleaned up a little. There might be cases that aren't covered in the testing that wouldn't pass work.
Walid Ashri
@walidashri
Nov 20 2016 02:32
Array.prototype.numberOfOccurrences = ()=> {
var x= arguments[0];
  return this.filter((a)=> x ===a ).length;
}
why arguments undefined ?!
Johnny
@JohnnyBizzel
Nov 20 2016 02:43
Moisés Man
@moigithub
Nov 20 2016 02:57
Walid Ashri
@walidashri
Nov 20 2016 02:59
@JohnnyBizzel @moigithub thanks still trying to get hang of arrow function
CamperBot
@camperbot
Nov 20 2016 02:59
walidashri sends brownie points to @johnnybizzel and @moigithub :sparkles: :thumbsup: :sparkles:
:cookie: 835 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
:star2: 2206 | @moigithub |http://www.freecodecamp.com/moigithub
lalith77
@lalith77
Nov 20 2016 03:05
For anyone who finished the react projects. How did you guys learn react since there are no exercises on FCC yet?
Abhisek Pattnaik
@abhisekp
Nov 20 2016 03:06
@walidashri you may use restparam
Andrew weinrich
@ambitiouscoder10
Nov 20 2016 03:06
Hey guys I'm having trouble with escape sequences in strings.
var myStr; //"FirstLine \n SecondLine \ \r ThirdLine"
@lalith77 i've not finished any react projs but the official docs are awesome! :sparkles:
lalith77
@lalith77
Nov 20 2016 03:08
@abhisekp ok. was hoping for something more than just the documentation.
Abhisek Pattnaik
@abhisekp
Nov 20 2016 03:09
@lalith77 there is tutorial + docs
lalith77
@lalith77
Nov 20 2016 03:10
@abhisekp @moigithub thanks guys
CamperBot
@camperbot
Nov 20 2016 03:10
lalith77 sends brownie points to @abhisekp and @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2207 | @moigithub |http://www.freecodecamp.com/moigithub
:star2: 3163 | @abhisekp |http://www.freecodecamp.com/abhisekp
Moisés Man
@moigithub
Nov 20 2016 03:11
@ambitiouscoder10 u need to ASSIGN the string to myStr variable.. using = (not ; )
also remove all spaces.. and missing a set of backslash.. reread the instructions
Johnny
@JohnnyBizzel
Nov 20 2016 03:18
@walidashri If you are not bothered about arguments, this will do the job:
Object.defineProperty(Array.prototype, 'numberOfOccurrences', {
    enumerable: false,  // this will make it not iterable
    writable: true,
    value: function(testVal) {
       // code to count occurences of element in array
       var count = 0;
       for(var i = 0; i< this.length; i++) {
          if (testVal == this[i]) count++; 
        }
        return count;
    }
});
// Array.prototype. = function(el) { return el > 2; }

var myArr = [2,2,4,6,34,5,7,5,3,2,5,33,1];
console.log(myArr.numberOfOccurrences(5));
andry91959
@andry91959
Nov 20 2016 03:18
can someone explain me about whitespace please?
Andrew weinrich
@ambitiouscoder10
Nov 20 2016 03:19
@Moises Man thanks dude
CamperBot
@camperbot
Nov 20 2016 03:19
ambitiouscoder10 sends brownie points to @moises :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for moises
Kurt
@recnepstruk
Nov 20 2016 03:20
@andry91959 it’s nothing
Johnny
@JohnnyBizzel
Nov 20 2016 03:21
@andry91959 It space characters in general. eg [ ]<-
andry91959
@andry91959
Nov 20 2016 03:21
@recnepstruk so what is nonwhitespace?
andry91959
@andry91959
Nov 20 2016 03:23
wait so non-whitespace is the space available after all the whitespace?
James
@jbonds08
Nov 20 2016 03:32
Hello
so I am trying to figure out this equation for Celsius to Fahrenheit but I am a little confuse. Can someone help me
????
MoNag1
@MoNag1
Nov 20 2016 03:33
@jbonds08 send your code first
Jack
@jh0l
Nov 20 2016 03:37
why isn't there a 50 dollar note in the exact change challenge?
Elifaz Filho
@Elifaz
Nov 20 2016 03:44
Anybody familiar with axios in here?
Stanley Su
@cuddlycuddles
Nov 20 2016 03:46
@jbonds08 Yeah sure, send your code :)
Elifaz Filho
@Elifaz
Nov 20 2016 03:47
axios anybody?
I’m having issues receiving a file from an axios request and have been the whole day trying to figure this out with no luck..
Pablo Varela
@slowold
Nov 20 2016 03:59
hey guys, quick question
Vittoria Towery
@VittoriaTowery
Nov 20 2016 03:59
I need help... >.>
var myStr = "First line. \n\t\tSecond Line. \r\t\tThird line.//";
Pablo Varela
@slowold
Nov 20 2016 04:00
has anybody else had to use the // noprotect flag for the Sum All Primes challenge?
Vittoria Towery
@VittoriaTowery
Nov 20 2016 04:00
i can't figure out the way this code is supposed to be formatted... it's confusing the crap outta me.
Pablo Varela
@slowold
Nov 20 2016 04:01
@VittoriaTowery what's the context?
Diane
@106Ch213
Nov 20 2016 04:01
Hello guys, I am on the ceaser cipher challenge. My last problem is that my array of values that I used to convert my entry back to strings gives "null" when the input characters aren't in the wanted interval whilst I want the array to be left unchanged when this happens. I can't figure out why, been stuck on it for a while T.T Here is my code :
function rot13(str) { // LBH QVQ VG!

  var arrOfIndexes = [];
  var decoded = "";

  for (i = 0; i < str.length; i++){

    if (str.charCodeAt(i) < 90 - 13 && str.charCodeAt(i) >= 65){

      arrOfIndexes[i] = str.charCodeAt(i) + 13;      
    } else if (str.charCodeAt(i) > 90 - 13 && str.charCodeAt(i) <= 90){
      arrOfIndexes[i] = str.charCodeAt(i) - 13;
    } else {
      arrOfIndexes[i] = arrOfIndexes[i];
    }
  }

  //tests
   //return arrOfIndexes;
  //________________________

  decoded = String.fromCharCode.apply(null,arrOfIndexes);

  return decoded;
}

// Change the inputs below to test
rot13("LBH QVQ VG");
Vittoria Towery
@VittoriaTowery
Nov 20 2016 04:01

escape sequences in strings.
Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine
\SecondLine\
ThirdLine
You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Pablo Varela
@slowold
Nov 20 2016 04:02
@VittoriaTowery to escape the \ just write it twice, like this \\
no need to use \t
Vittoria Towery
@VittoriaTowery
Nov 20 2016 04:03
alright. let me try that.
Pablo Varela
@slowold
Nov 20 2016 04:04
@VittoriaTowery also I don't think the '//' at the end will work
Vittoria Towery
@VittoriaTowery
Nov 20 2016 04:04
i removed it and the // at the end of it and it's still not working. -.-
Pablo Varela
@slowold
Nov 20 2016 04:05
did you swap the \ts for \\s?
Stanley Su
@cuddlycuddles
Nov 20 2016 04:05
@AviPeltz Hey could you explain your code for the record collection? I'm stuck :(
Vittoria Towery
@VittoriaTowery
Nov 20 2016 04:05
Yup.. apparently I'm still missing "myStr should have encoded text with the proper escape sequences and no spacing."
Pablo Varela
@slowold
Nov 20 2016 04:06
also look out for the \r (carriage return) that you placed, and where
Stanley Su
@cuddlycuddles
Nov 20 2016 04:06
@VittoriaTowery Send your entire code, I might be able to help :)
Vittoria Towery
@VittoriaTowery
Nov 20 2016 04:06
I'm gonna try an rewrite it again.. gimme a sec.
Moisés Man
@moigithub
Nov 20 2016 04:07
no spaces and should be Line.. with uppercase L
text should be EXACTLY as instruction says
Cr
@craigpope
Nov 20 2016 04:07
Hello... I'm stuck. Can someone help? I'm on "Increment a Number with JavaScript" and I'm supposed to increment using the i++ format, and my code looks like this
var myVar = 87;
// Only change code below this line
myVar = myVar++;
but I'm having no luck.
Pablo Varela
@slowold
Nov 20 2016 04:07
@106Ch213 I don't think it works like that
Moisés Man
@moigithub
Nov 20 2016 04:08
on the example code.. it says...
i++
NOT i = i++ <-- wrong (this does something else )
@craigpope
Pablo Varela
@slowold
Nov 20 2016 04:08
characters out of range will return null
what I did is skip them
Diane
@106Ch213
Nov 20 2016 04:09
@slowold how did you skip them?
Vittoria Towery
@VittoriaTowery
Nov 20 2016 04:09
@craigpope myVar++ is all you need
Jessica Dingus
@jdice226
Nov 20 2016 04:09
blob
Vittoria Towery
@VittoriaTowery
Nov 20 2016 04:09
Well, I
am stuck.
Jessica Dingus
@jdice226
Nov 20 2016 04:10
I need help getting this to pass for the Using Objects for Lookup challenge
Pablo Varela
@slowold
Nov 20 2016 04:10
@106Ch213 at the start of the cicle i used a regEx
Jessica Dingus
@jdice226
Nov 20 2016 04:11

// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
val = {
"alpha":"Adams",
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank",
"":undefined,
};

// Only change code above this line
return result;
}

// Change this value to test
phoneticLookup("charlie"); // If anyone can't read the photo.

Stanley Su
@cuddlycuddles
Nov 20 2016 04:11
@jdice226 Try to use the gitter formatting to put the code here (through (code)) instead of through an image.
Also, you don't need to define undefined.
Pablo Varela
@slowold
Nov 20 2016 04:11
and applied it to current char with charAt(i).match(regex)
Moisés Man
@moigithub
Nov 20 2016 04:11
val is ur argument variable (declared on the function)
soo if u call phoneticLookup("charlie") val value would be "charlie"@jdice226
if on ur code u set to another value ... ie val= something u replacing its value.. u should NOT do that
Stanley Su
@cuddlycuddles
Nov 20 2016 04:12
@jdice226 you haven't done anything with result, which is what the function returns. Make it so the function searches through your lookup table and then returns the result.
Diane
@106Ch213
Nov 20 2016 04:12
@slowold hmm I see, wanted to know if there's a way to make this work with number testing so I'll look a bit more, otherwise I'll try your method thanks
CamperBot
@camperbot
Nov 20 2016 04:12
106ch213 sends brownie points to @slowold :sparkles: :thumbsup: :sparkles:
:cookie: 326 | @slowold |http://www.freecodecamp.com/slowold
Moisés Man
@moigithub
Nov 20 2016 04:13
u should USE another variable name for ur object..
then combine that object + val variable to get the value of one specific object element (dot or bracket notation)
ie.. if u call phoneticLookup("charlie" ) <--- should return "Chicago" @jdice226
Jessica Dingus
@jdice226
Nov 20 2016 04:13
@cuddlycuddles The return statement is after the //Only change code above this line comment
Vittoria Towery
@VittoriaTowery
Nov 20 2016 04:13

i finally figured it out. thanks guys.
it was-

var myStr = "FirstLine\n\SecondLine\\rThirdLine";

Moisés Man
@moigithub
Nov 20 2016 04:14
:+1: @VittoriaTowery
Pablo Varela
@slowold
Nov 20 2016 04:14
@106Ch213 :+1:
Stanley Su
@cuddlycuddles
Nov 20 2016 04:14
@jdice226 Sorry, what I meant was to define what result would be. In the code you sent earlier, result is still undefined.
Pablo Varela
@slowold
Nov 20 2016 04:16
@106Ch213 also I don't see much use in using an array of indexes of the string, when you can just use an array of the letters
consider that
Jessica Dingus
@jdice226
Nov 20 2016 04:16
@cuddlycuddles Well first I tried it without the val = only the { lookup table } but that didn't work also im not sure how to use the gitter code formatting
Moisés Man
@moigithub
Nov 20 2016 04:17
wonder if u read what i wrote above ? @jdice226
first thing.. on ur code.. is NOT replace val value....
second thing is review object access notation.. dot or/and bracket
Stanley Su
@cuddlycuddles
Nov 20 2016 04:17
@jdice226 You should use the lookup table. Shouldn't make val the object.
@jdice226 In the bottom right of your chat input area, there is a gitter markdown help button. It'll show you how to paste in code.
Jessica Dingus
@jdice226
Nov 20 2016 04:19
@moigithub I don't understand what you're trying to say because if charlie is the value input then it needs to return Chicago
Stanley Su
@cuddlycuddles
Nov 20 2016 04:19
@jdice226 It says to "Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.". So the object should be:
var lookup = {
//alpha bravo etc.
};
Moisés Man
@moigithub
Nov 20 2016 04:20

if u have this object

var person = {
  name: 'Joe',
  age: 11
}

how do u get 'Joe'

Cr
@craigpope
Nov 20 2016 04:20
@VittoriaTowery Thank you!!
CamperBot
@camperbot
Nov 20 2016 04:20
craigpope sends brownie points to @vittoriatowery :sparkles: :thumbsup: :sparkles:
:cookie: 147 | @vittoriatowery |http://www.freecodecamp.com/vittoriatowery
Joseph
@revisualize
Nov 20 2016 04:20
la la la la
Jessica Dingus
@jdice226
Nov 20 2016 04:22
@moigithub you would have functionName(name) @cuddlycuddles when i do that now I still get an error on the last };
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
   var lookup = {
    "alpha":"Adams",
    "bravo":"Boston",
    "charlie":"Chicago",
    "delta":"Denver",
    "echo":"Easy",
    "foxtrot":"Frank",
    "":
    };


  // Only change code above this line
  return result;
}

// Change this value to test
phoneticLookup("charlie");
Moisés Man
@moigithub
Nov 20 2016 04:23
u need to use object access notation.. (few exercises before that one i think )
person.name <-- will give u Joe
or
person["name"]
Stanley Su
@cuddlycuddles
Nov 20 2016 04:23
@jdice226 What's wrong is that alpha, bravo etc should be green. You made it a string. It should be just alpha, not "alpha".
Jessica Dingus
@jdice226
Nov 20 2016 04:24
Oh ok
Stanley Su
@cuddlycuddles
Nov 20 2016 04:24
@jdice226 You also don't need to do undefined, which is the last thing in your object. And make sure you define result later on.
Joseph
@revisualize
Nov 20 2016 04:26
Hello.
@jdice226 Your function has declared and initialized the variable result to "". You are not modifying result and your function is returning result. Ergo, you're returning "". You need to modify result to be the value of the property from the object that you created.
Jessica Dingus
@jdice226
Nov 20 2016 04:26
@cuddlycuddles how do I define result without changing the code or having "leaking" variable?
Stanley Su
@cuddlycuddles
Nov 20 2016 04:27

@jdice226 Do something like:

result =  xyz

So then return result; actually does something

Sourajyoti
@Sourajyoti
Nov 20 2016 04:27

//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 lookUpProfile(firstName, prop){
// Only change code below this line
for (i=0; i<contacts.length; i++)
{
if (contacts[i].firstName===firstName){
for (j=0; j<contacts[i].length; j++){
if (contacts[i][j]===prop){return contacts[i][j];}
else {return "No such property";}
}
}
else {return "No such contact";}
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "address");

Jessica Dingus
@jdice226
Nov 20 2016 04:27
@revisualize isn't that what the phoneticLookup() line is for
Sourajyoti
@Sourajyoti
Nov 20 2016 04:28
help!!!
it returns "no suh contat"
Stanley Su
@cuddlycuddles
Nov 20 2016 04:28
@jdice226 No, the phoneticLookup() line means that you are using the phoneticLookup function, and whatever is inside the brackets is your value that you want to search for.
Joseph
@revisualize
Nov 20 2016 04:30
@jdice226 That is the function call.
Jessica Dingus
@jdice226
Nov 20 2016 04:31

// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
   var lookup = {
    alpha:"Adams",
    bravo:"Boston",
    charlie:"Chicago",
    delta:"Denver",
    echo:"Easy",
    foxtrot:"Frank",

    };

   result = phoneticLookup(val); //This is what I added to "define result" ???
  // Only change code above this line
  return result;
}

// Change this value to test
phoneticLookup("charlie");
Joseph
@revisualize
Nov 20 2016 04:31
@jdice226 You're making the function call again. You're not accessing the object.
Sourajyoti
@Sourajyoti
Nov 20 2016 04:31
how do i post js code here?
Abhisek Pattnaik
@abhisekp
Nov 20 2016 04:32
@moigithub thanks for the react/redux link :D
CamperBot
@camperbot
Nov 20 2016 04:32
abhisekp sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2208 | @moigithub |http://www.freecodecamp.com/moigithub
Sourajyoti
@Sourajyoti
Nov 20 2016 04:32
like @jdice226 did?
Stanley Su
@cuddlycuddles
Nov 20 2016 04:32
@Sourajyoti Use "" without the quotation marks. Then put your code in. Then end your code with "" but without the quotation marks.
Joseph
@revisualize
Nov 20 2016 04:32

How to do code block format:
```js [SHIFT+ENTER]
// your code here
``` [CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

...
You can also do inline code formatting:
A string of text with a `variable` or `other bit of code`.
Output:
A string of text with a variable or other bit of code.

Stanley Su
@cuddlycuddles
Nov 20 2016 04:32
@Sourajyoti Fuck that turned out wrong. In the chat input area, which is where you type to send a message, at the bottom right there is a markdown help button. Use that and it'll tell you.
Jessica Dingus
@jdice226
Nov 20 2016 04:33
@Sourajyoti theres an m in the bottom right corner that s called mark down replace var code with your code
Joseph
@revisualize
Nov 20 2016 04:33
@jdice226 Do you know what I said?
Abhisek Pattnaik
@abhisekp
Nov 20 2016 04:33
M!
taipo1
@taipo1
Nov 20 2016 04:34
can i fade between a div toggle in jquery ?
MoNag1
@MoNag1
Nov 20 2016 04:34
**M**:arrow_down:
Abhisek Pattnaik
@abhisekp
Nov 20 2016 04:34
lol
Sourajyoti
@Sourajyoti
Nov 20 2016 04:35
okay... i think i got it... thanks guys @cuddlycuddles , @jdice226, @revisualize
CamperBot
@camperbot
Nov 20 2016 04:35
sourajyoti sends brownie points to @cuddlycuddles and @jdice226 and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 207 | @jdice226 |http://www.freecodecamp.com/jdice226
:star2: 2368 | @revisualize |http://www.freecodecamp.com/revisualize
:cookie: 214 | @cuddlycuddles |http://www.freecodecamp.com/cuddlycuddles
Stanley Su
@cuddlycuddles
Nov 20 2016 04:35
@jdice226
``` 

// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
   var lookup = {
    alpha:"Adams",
    bravo:"Boston",
    charlie:"Chicago",
    delta:"Denver",
    echo:"Easy",
    foxtrot:"Frank",
    };

   result = phoneticLookup(val); // this is wrong. The result is a value in the lookup table. 
  // Only change code above this line
  return result;
}

// Change this value to test
phoneticLookup("charlie");
MoNag1
@MoNag1
Nov 20 2016 04:35
lol that doesnt work
Abhisek Pattnaik
@abhisekp
Nov 20 2016 04:35
@taipo1 you mean transition animation? sure
taipo1
@taipo1
Nov 20 2016 04:36
@abhisekp i have a toggle class in my css wich includes transition:2s; but when i toggle the div with a .click function it instantly switches without a transition
Abhisek Pattnaik
@abhisekp
Nov 20 2016 04:36
@taipo1 use the complete callback http://devdocs.io/jquery/fadeout
Sourajyoti
@Sourajyoti
Nov 20 2016 04:36
//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 lookUpProfile(firstName, prop){
for (i=0; i<contacts.length; i++)
{
  if (contacts[i].firstName===firstName){
    for (j=0; j<contacts[i].length; j++){
      if (contacts[i][j]===prop){return contacts[i][j];}
      else {return "No such property";}
    }
  }
  else {return "No such contact";}
}
}
lookUpProfile("Akira", "address");
need some help... this code returns "No such contact"
Joseph
@revisualize
Nov 20 2016 04:37
@Sourajyoti Let's say you were at a big business event and throughout the event you got handed 200 business cards. Now, I walk up to you at the end and ask you.. Do you have a Business Card for "Jane Smith"? Now you loop look through your stack of 200 business cards. When would you tell me that you didn't have a business card for Jane?
@Sourajyoti Also. Objects don't have lengths.
Sourajyoti
@Sourajyoti
Nov 20 2016 04:38
are the business cards sorted alphabetically? if so, i dont need to need to browse every card
ohh
Abhisek Pattnaik
@abhisekp
Nov 20 2016 04:38
@taipo1 would be nice if you could show a demo in http://jsbin.com :heartpulse: or http://codepen.io
Joseph
@revisualize
Nov 20 2016 04:39
@Sourajyoti It's a thought question. Let's say they aren't sorted. Because your contacts array isn't sorted.
Sourajyoti
@Sourajyoti
Nov 20 2016 04:40
@revisualize then i guess i'll have to look through the stack entirely and if i dont have a business card for one "Jane Smith" i would inform you
Joseph
@revisualize
Nov 20 2016 04:40
@Sourajyoti Great. Why doesn't your function do that?
@Sourajyoti If the first firstName doesn't match you're doing an else.
Sourajyoti
@Sourajyoti
Nov 20 2016 04:46
@revisualize contacts[i].firstName will return "Akira", "Harry", "Sherlock" and "Christian" respectively at the end of the for loop. when i write return contacts[i].firstName; before entering the for loop with the 'j' variable, it returns the first name "Akira" as contacts[0].firstName is "Akira" then it also satisfies the if statement that follows but it isn't entering the loop.
Joseph
@revisualize
Nov 20 2016 04:47
@Sourajyoti Let's do this.
var num = 7;
var a = 1;
if (a == num) {
    return "Happy";
} else { 
    return "Sad";
}
What gets returned?
Sourajyoti
@Sourajyoti
Nov 20 2016 04:48
@revisualize Sad
Joseph
@revisualize
Nov 20 2016 04:48
Great.
If you're looking for "Sherlock" and the contacts[0].firstName is Akira ... What happens?
Look at your code.
taipo1
@taipo1
Nov 20 2016 04:49
@abhisekp do you get what i am trying to achieve ?
Joseph
@revisualize
Nov 20 2016 04:49
@Sourajyoti Do you realize that return statements cause functions to completely HALT?
Abhisek Pattnaik
@abhisekp
Nov 20 2016 04:49
@taipo1 looking at it
Joseph
@revisualize
Nov 20 2016 04:50
@Sourajyoti You need to change what you're doing slightly.
CamperBot
@camperbot
Nov 20 2016 04:50
no wiki entry for: whit this onehttpswwwfreecodecampcomchallengesescape-sequences-in-stringssolution0avar20mystr3d22firstline5cn5c5csecondline5c5c5crthirdline223b0a0a0a
Sourajyoti
@Sourajyoti
Nov 20 2016 04:50
@revisualize but i am looking for "Akira" and still it says "No such contact"
Joseph
@revisualize
Nov 20 2016 04:50
@Sourajyoti First off... Objects don't have .lengths. So, you don't need the second for loop.
Sourajyoti
@Sourajyoti
Nov 20 2016 04:51
@revisualize okay
Abhisek Pattnaik
@abhisekp
Nov 20 2016 04:52
@taipo1 i'm sorry! i didn't quite get it. Could you please elaborate what you want to achieve?
@joehesse what is an escape sequence?
Sourajyoti
@Sourajyoti
Nov 20 2016 04:53
@revisualize i still dont know what to do... it would be really helpful if you can direct me in the right direction... i understand what ur saying but i dont know how to go about doing it
taipo1
@taipo1
Nov 20 2016 04:53
i want the gradient background to fade in when you click the button instead of instantly switching
Joseph
@revisualize
Nov 20 2016 04:53
@Sourajyoti What is your current function?
@joehesse FirstLine is not the same as firstline
Ken Haduch
@khaduch
Nov 20 2016 04:54
@joehesse - it looks like the main thing that you have to fix is the spelling of the other words FirstLine instead of firstline, etc.
Abhisek Pattnaik
@abhisekp
Nov 20 2016 04:54
@joehesse Escape sequence helps you write some special character which have some special meaning.
e.g. In the string "My name is\nJohanna", the \n character has special meaning.
\n means a newline
My name is
Johanna
Joseph
@revisualize
Nov 20 2016 04:54
@joehesse SecondLine is not the same as secondline
MoNag1
@MoNag1
Nov 20 2016 04:54
@joehesse you need to capitalize the appropriate letters
Joseph
@revisualize
Nov 20 2016 04:54
@joehesse thirdline is not the same as ThirdLine
Sourajyoti
@Sourajyoti
Nov 20 2016 04:54
@revisualize lookUpProfile
Joseph
@revisualize
Nov 20 2016 04:55
@Sourajyoti Show me your code.
I need to see your code.
Abhisek Pattnaik
@abhisekp
Nov 20 2016 04:55
@taipo1 understood
Joseph
@revisualize
Nov 20 2016 04:55
@Sourajyoti Help me help you.
What is your current function?
Show me your current function.
I am NOT a mind reader.
Sourajyoti
@Sourajyoti
Nov 20 2016 04:56
@revisualize its a javascript challenge that i'm stuck with
//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 lookUpProfile(firstName, prop){
// Only change code below this line
for (i=0; i<contacts.length; i++)
{
  if (contacts[i].firstName===firstName){
    for (j=0; j<contacts[i].length; j++){
      if (contacts[i][j]===prop){return contacts[i][j];}
      else {return "No such property";}
    }
  }
  else {return "No such contact";}
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "address");
this is the code
Joseph
@revisualize
Nov 20 2016 04:56
@Sourajyoti You haven't made any changes to your code.
Sourajyoti
@Sourajyoti
Nov 20 2016 04:56
@revisualize i dont know how to go about it :/
Joseph
@revisualize
Nov 20 2016 04:57
@Sourajyoti You don't know how to remove the second for loop because Objects don't have .lengths?
@Sourajyoti Let me show you how to remove a for loop.
for (i=0; i<contacts.length; i++)
{
  if (contacts[i].firstName===firstName){
       if (contacts[i][j]===prop){return contacts[i][j];}
       else {return "No such property";}
   }
  else {return "No such contact";}
}
Done.
Sourajyoti
@Sourajyoti
Nov 20 2016 04:58
@revisualize then how will i loop through object elements?
Joseph
@revisualize
Nov 20 2016 04:58
@Sourajyoti For that lesson you don't need to.
Megan
@megan32
Nov 20 2016 04:59
Word Blanks mad lib building...uhhh wtf?? Anyone know how to make this work?
/collapse-all
johanna
@joehesse
Nov 20 2016 05:00
@abhisekp @MoNag1 @revisualize thanx i always forget to capitalize
CamperBot
@camperbot
Nov 20 2016 05:00
joehesse sends brownie points to @abhisekp and @monag1 and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 343 | @monag1 |http://www.freecodecamp.com/monag1
:star2: 2369 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 3165 | @abhisekp |http://www.freecodecamp.com/abhisekp
Sourajyoti
@Sourajyoti
Nov 20 2016 05:01
@revisualize thanks for the help
CamperBot
@camperbot
Nov 20 2016 05:01
sourajyoti sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: sourajyoti already gave revisualize points
Megan
@megan32
Nov 20 2016 05:01
I'm not sure how that link was supposed to help, it says the same thing as the directions in freecodecamp...what am I missing?
Joseph
@revisualize
Nov 20 2016 05:02
@meganvieno You're supposed to create a string from the variables parameters
Megan
@megan32
Nov 20 2016 05:02
this: var myStr = "There was a " + myNoun + " in the cafe!" + " It was so" + myAdjective + " and quickly " + myAdverb + myVerb + "."; ?
Joseph
@revisualize
Nov 20 2016 05:03
@meganvieno The last two words are written likethis
@meganvieno So is the somyAdjective
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:03
@meganvieno here: result += "I, the " + myAdjective + " " + myNoun + " " + myVerb + " " + myAdverb;
can anyone help me with falsy bouncer. I am stuck.
Megan
@megan32
Nov 20 2016 05:04
so you're supposed to add a result into the code section??
Joseph
@revisualize
Nov 20 2016 05:04
@Sourajyoti I'm still here. I'm still willing to help. We just need to fix your logic and then fix your code.
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:04
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  function find(val) {
  if(typeof val === 'string' && val.length === 0) {
       return true; 
    } else if(typeof val === 'number' && val !== 0) {
      return true;
    } else if(typeof val === 'boolean' && val === true) {
      return true;
    }
  }

  return arr.filter(find);
}
Joseph
@revisualize
Nov 20 2016 05:05
@meganvieno Yes. You're supposed to modify result. As per the instructions.
@relentless-coder You know.. The built in Boolean() object does what you're trying to build.
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:05
@meganvieno you need to use concatenation to join function parameters, with your own strings. I used "I", "the", "".. to form a sensible sentence.
MoNag1
@MoNag1
Nov 20 2016 05:06
@meganvieno make sure all your parameters are separated by strings, include appropriate spaces like after the word "so" then you need to return the variable that you just created
Abhisek Pattnaik
@abhisekp
Nov 20 2016 05:07
@taipo1 colors can be animated using transition but bg gradient can be animated using animation property
Megan
@megan32
Nov 20 2016 05:07
...I'm just going to go bang my head against a wall. This doesn't make any sense. Thanks anyway
Joseph
@revisualize
Nov 20 2016 05:08
@meganvieno How can we help.
Megan
@megan32
Nov 20 2016 05:08
no idea
Abhisek Pattnaik
@abhisekp
Nov 20 2016 05:08
using keyframes. bg image supports discrete animations @taipo1
Joseph
@revisualize
Nov 20 2016 05:08
@meganvieno Do you see my examples in the instructions that I posted?
Abhisek Pattnaik
@abhisekp
Nov 20 2016 05:08
lol
Joseph
@revisualize
Nov 20 2016 05:08

@meganvieno Look:
Parameters are variables that represent the values that get passed into your function from the function call.
https://cs.wellesley.edu/~cs110/lectures/L16/images/function-anatomy.png
Notice how the variables level and score in the function definition addScore are called parameters.
However, when we invoke the function like in:
addScore(3, 10) or addScore(6, 20)
the values are called arguments. Here is an important lesson:
You define a function with parameters, you call a function with arguments.
Another example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.
Other important things to remember:
* A function can have zero parameters. You still have to use the parentheses to define it.
* A function might have no return statements. In this case we say that the function returns undefined.

Abhisek Pattnaik
@abhisekp
Nov 20 2016 05:08

How can we help?
no idea

:D

taipo1
@taipo1
Nov 20 2016 05:08
@abhisekp okey ! so i should replace the transition propperty with the animation propperty
Joseph
@revisualize
Nov 20 2016 05:08
@meganvieno I wrote my second example that way on purpose.
taipo1
@taipo1
Nov 20 2016 05:09
thnx alot i will look into it ! @abhisekp
CamperBot
@camperbot
Nov 20 2016 05:09
taipo1 sends brownie points to @abhisekp :sparkles: :thumbsup: :sparkles:
:star2: 3166 | @abhisekp |http://www.freecodecamp.com/abhisekp
MoNag1
@MoNag1
Nov 20 2016 05:09
lol @revisualize you find the best resources
Joseph
@revisualize
Nov 20 2016 05:09
@meganvieno Your string is fine. You're just assigning it to the wrong variable. And you're missing a few spaces.
@MoNag1 I don't find them. I curate them and make them
MoNag1
@MoNag1
Nov 20 2016 05:11
@revisualize wow pretty cool, I find them useful so ty :smile:
CamperBot
@camperbot
Nov 20 2016 05:11
monag1 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2370 | @revisualize |http://www.freecodecamp.com/revisualize
James Moore
@James-N-M
Nov 20 2016 05:11
Hey guys im on Seek and Destroy
Abhisek Pattnaik
@abhisekp
Nov 20 2016 05:11
@revisualize hmm... so... you're a mind reader :innocent:
;)
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:11
@meganvieno can you explain what is it that you can't understand? Because your code looks fine, so where are you facing the problem?
James Moore
@James-N-M
Nov 20 2016 05:11
function destroyer(arr) {
  // Remove all the values
  var args = Array.from(arguments);
  for(var i = 0 ; i < args.length; i++)
  {
    arr.filter(args[i]); 
  }
  return arr; 
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Joseph
@revisualize
Nov 20 2016 05:11
@abhisekp Up. I read minds.
James Moore
@James-N-M
Nov 20 2016 05:11
I think its still not viewing args as a array
if anyone knows whats up get at me
Megan
@megan32
Nov 20 2016 05:13
@relentless-coder all of it. This is like a sick joke. I'm putting spaces all over the place, keep changing the organge word, nothing is making it happy
Joseph
@revisualize
Nov 20 2016 05:13
@meganvieno You're like this " " close to solving your challenge.
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:13
@meganvieno are you getting any error? If yes, please post it here. Or whatever result you are getting. post it here.
Ken Haduch
@khaduch
Nov 20 2016 05:14
@James-N-M - there is one thing that you might try - instead of starting at 0 in the args, try to start at 1, since args[0] would be your input array? I mean, initialize your loop variable to i = 1
Megan
@megan32
Nov 20 2016 05:14
I mean this is the kindest way, but everyone's explanation may as well be written in Klingon because it makes no sense. How do people do this??
The black box just shows nothign
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:15
@meganvieno are you returning the result?
James Moore
@James-N-M
Nov 20 2016 05:15
@khaduch Thanks dude ill give it a go
CamperBot
@camperbot
Nov 20 2016 05:15
james-n-m sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1951 | @khaduch |http://www.freecodecamp.com/khaduch
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:15
@meganvieno
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line

  result += "I, the " + myAdjective + " " + myNoun + " " + myVerb + " " + myAdverb;

  // Your code above this line
  return result;
}
Megan
@megan32
Nov 20 2016 05:15
am i "returning the result" -WTF does that mean????
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:16
@meganvieno wow. lots of "WTFs". calm down. :smile: just compare your code with mine.
Megan
@megan32
Nov 20 2016 05:16
Are you kidding me?! That's it "result +="
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:17
yes. shorter way of typing result = result + something.something
Megan
@megan32
Nov 20 2016 05:17
@relentless-coder Thank you! is there like a book we are supposed to be reading along with freecodecamp? How do you know this stuff?
CamperBot
@camperbot
Nov 20 2016 05:17
meganvieno sends brownie points to @relentless-coder :sparkles: :thumbsup: :sparkles:
:cookie: 252 | @relentless-coder |http://www.freecodecamp.com/relentless-coder
Ken Haduch
@khaduch
Nov 20 2016 05:17
@James-N-M - another thing, I just noticed - when you call arr.filter(), you have to pass a function to it as a callback function to actually do the filtering. So your args[i] is failing there, because that is not a function.
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:18
@meganvieno well, if you've been following the fcc track from the beginning, then you must have come across it.
If you want a book, try Beginning Javascript.
Endy
@pisangGoreng
Nov 20 2016 05:19

Hello everyone, i have 1 probem in here. im trying to finish javascript challenges Counting Cards.

the function will increment or decrement var count value.
this is my code, & not work.

var count = 0;

function cc(card) {
// Only change code below this line
if ( card == 2 || card == 3 || card == 4 || card == 5 || card == 6 ) {
count += 1;
} else if ( card == 7 || card == 8 || card == 9 ) {
count += 0;
} else {
count -= 1;
}

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

any suggest or clue for me guys?
thx

Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:21
@pisanggoreng why do you have "count" in quotes?
Megan
@megan32
Nov 20 2016 05:21
@relentless-coder thanks for the book suggestion. I'll check it out. I have no background in this and just feel like there is this huge "you should already know this" assumption
CamperBot
@camperbot
Nov 20 2016 05:21
meganvieno sends brownie points to @relentless-coder :sparkles: :thumbsup: :sparkles:
:warning: meganvieno already gave relentless-coder points
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:21
@pisanggoreng it is a variable. it should be return count
Ian Lee
@asparism
Nov 20 2016 05:21
Does anyone know why the barShrink function won't work when called by the countDown function in this codepen? http://codepen.io/Asparism/pen/ENNxBP?editors=0010
James Moore
@James-N-M
Nov 20 2016 05:21

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

function destroy(value)
{
  var shouldI = true; 
   var args = Array.from(arguments);
   for(var i = 1; i < args.length; i++)
   {
     if(value == args[i])
     {
       shouldI = false;
       break;
     }
   }

  if(shouldI)
  {
      return value; 
  }

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
@khaduch New code
@khaduch <
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:22
@meganvieno even I didn't know anything 3 months ago. So it's cool. You'll get the hang of it.
Endy
@pisangGoreng
Nov 20 2016 05:22
@pisanggoreng it is a variable. it should be return count i already change return count, but when run test, the count still 0
Megan
@megan32
Nov 20 2016 05:23
thanks...I hope so, I really enjoy it so far, but Javascript is just blowing my mind
James Moore
@James-N-M
Nov 20 2016 05:24
I feel like javascript isnt the language to learn first, Maybe try some C tutorials or somthing a little more barebones @meganvieno
Thats what we start with in university @meganvieno I know everyone has there own views but I feel like starting with something with a few less bells and whistles is good, even though in reality when you really get into C is extremely powerful
Megan
@megan32
Nov 20 2016 05:25
so it's still not working...
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:25
@meganvieno could you post the complete code?
@meganvieno post it between a pair of three backticks( `)
MoNag1
@MoNag1
Nov 20 2016 05:26
@James-N-M I don't think your arguments are showing up in args
Megan
@megan32
Nov 20 2016 05:26
"post it between" -what do you mean?
oh got it
Nicola Scaramuzzo
@muzzotech
Nov 20 2016 05:26

I'm stuck on Validate US Telephone Numbers.
code

function telephoneCheck(str) {
  // Good luck!
  var re = / _\W/g;
  var newStr = str.replace(re, '');
  if(newStr.length === 10){
    return true;
  } else if (newStr[0] === '1' && newStr.length === 11){
    return true;
  } else {
    return false;
  }
}



telephoneCheck("555-555-5555");

All statements come up false.
Help.

Endy
@pisangGoreng
Nov 20 2016 05:27

@relentless-coder i already change return count, but when run test, the count still 0

var count = 0;

function cc(card) {
// Only change code below this line
if ( card == 2 || card == 3 || card == 4 || card == 5 || card == 6 ) {
count += 1;
} else if ( card == 7 || card == 8 || card == 9 ) {
count += 0;
} else {
count -= 1;
}

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Joseph
@revisualize
Nov 20 2016 05:27
@pisanggoreng You're not returning the string.
Taranveer Bains
@tearingItUp786
Nov 20 2016 05:28
^
Megan
@megan32
Nov 20 2016 05:28
@relentless-coder (((result += "There was a " + myNoun + " in the cafe! " + " It was so " + myAdjective + " and " + myAdverb + myVerb + "."; )))
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:29
@meganvieno i meant the complete code. Whatever is in your code section, post it here.
Winter S. Ndolo
@xulenvirp
Nov 20 2016 05:29
hey whatsup guys
Joseph
@revisualize
Nov 20 2016 05:29
@meganvieno You're still missing a space between myAdverb and myVerb
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:30
and it was a pair of three backticks, which are `. You'd find on the left of "1" key.
Megan
@megan32
Nov 20 2016 05:30
@revisualize Thanks I just figured out how to get one in. I had one before but the orange word wasn't right. When I re-wrote I forgot it.
CamperBot
@camperbot
Nov 20 2016 05:30
meganvieno sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2371 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Nov 20 2016 05:30

How to do code block format:
```js [SHIFT+ENTER]
// your code here
``` [CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

...
You can also do inline code formatting:
A string of text with a `variable` or `other bit of code`.
Output:
A string of text with a variable or other bit of code.

yoojuu
@yoojuu
Nov 20 2016 05:30
Screen Shot 2016-11-20 at 12.30.16 AM.png
What am I doing wrong here?
Winter S. Ndolo
@xulenvirp
Nov 20 2016 05:31
anyone who knows how to write the greater than sign in this code?
function testGreaterThan(val) {
  if (val) {  // Change this line
    return "Over 100";
  }
Joseph
@revisualize
Nov 20 2016 05:31
@yoojuu you're using testArr and you're not returning the element that was removed. You're returning an array.
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:31
@pisanggoreng . Okay, the actual question asks you to return "hold" or "bet".
yoojuu
@yoojuu
Nov 20 2016 05:31
So should I be returning arr and using item?
Taranveer Bains
@tearingItUp786
Nov 20 2016 05:32
misred that lol@yoojuu
Winter S. Ndolo
@xulenvirp
Nov 20 2016 05:32
please, anyone can help
Joseph
@revisualize
Nov 20 2016 05:32
@yoojuu No. You're supposed to be returning the element that was removed from the arr
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:32
@xulenvirp if(val > 100)
Nicola Scaramuzzo
@muzzotech
Nov 20 2016 05:32
any help with my problem? I imagine it has to do with the regex or the str.replace statement
Winter S. Ndolo
@xulenvirp
Nov 20 2016 05:32
thanks @relentless-coder
CamperBot
@camperbot
Nov 20 2016 05:32
xulenvirp sends brownie points to @relentless-coder :sparkles: :thumbsup: :sparkles:
:cookie: 253 | @relentless-coder |http://www.freecodecamp.com/relentless-coder
MoNag1
@MoNag1
Nov 20 2016 05:32
@yoojuu you should be using arr instead of testArr. Your parameter is arr and not testArr
Endy
@pisangGoreng
Nov 20 2016 05:33
@relentless-coder yeah.. but, i mean.. why when i run the code, var count its still 0.
yoojuu
@yoojuu
Nov 20 2016 05:35
@relentless-coder oh by returning the removed element I should just return arr.shift();
@relentless-coder right?
Ken Haduch
@khaduch
Nov 20 2016 05:36
@James-N-M - I'm going to be signing off, late here... but I don't think that you have access to the arguments from the call to destroyer in your destroy function. You would have to grab the arguments in the first call, and make them available to your callback function - if you read the MDN documentation on the filter method, you will see an optional argument that you can pass, which can subsequently be accessed within your callback using the this variable - check that out, I think that that is what I used for that one?
Nicola Scaramuzzo
@muzzotech
Nov 20 2016 05:36
@pisanggoreng I think it has to do with returning the count outside of the function, but I could be wrong
I would use a switch/case instead of the function
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:37
@yoojuu @revisualize replied to your query, not me. :)
Nicola Scaramuzzo
@muzzotech
Nov 20 2016 05:37
Also, I would get rid of the count +=0 statement as there is no reason for it as it doesn't drive the count up or down.
yoojuu
@yoojuu
Nov 20 2016 05:38
@relentless-coder oops my bad :P
@revisualize the code works! Thanks
CamperBot
@camperbot
Nov 20 2016 05:38
yoojuu sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2372 | @revisualize |http://www.freecodecamp.com/revisualize
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:40
@pisanggoreng because your test series are 2,3,7,K,A.
if you do the calculation the count would be 0
Nicola Scaramuzzo
@muzzotech
Nov 20 2016 05:40

I'm just going to post this again. I'm stuck on Validate US Telephone Numbers.
code

function telephoneCheck(str) {
  // Good luck!
  var re = / _\W/g;
  var newStr = str.replace(re, '');
  if(newStr.length === 10){
    return true;
  } else if (newStr[0] === '1' && newStr.length === 11){
    return true;
  } else {
    return false;
  }
}



telephoneCheck("555-555-5555");

All statements come up false.
Help.

I imagine it has to do with the regex or the str.replace statement, but I don't where to go from there
Ayush Bahuguna
@relentless-coder
Nov 20 2016 05:41
@pisanggoreng +1 for 2 and 3. and -1 for K and A. so total would be 0
@muzzotech try testing your regex statement. I can, but I shouldn't be. use browser console, and test your regex.
Taranveer Bains
@tearingItUp786
Nov 20 2016 05:44
@muzzotech I use this to help me visualize my regexs: https://jex.im/regulex/#!embed=false&flags=&re=%5E(a%7Cb)*%3F%24
James Moore
@James-N-M
Nov 20 2016 05:44

function destroyer(arr) {
  // Remove all the value
  var array = []; 
  for(var i = 0 ; i < arr.length; i++)
  {
    for(var j = 1 ; j < arguments.length; j++)
    {
      if(arr[i] == arguments[j])
      {
         arr[i] = null; 
      }
    }
  }

  for(var x = 0 ; x < arr.length; x++)
  {
    if(arr[x] !== null)
    {
      array.push(arr[x]); 
    }
  }


  return array; 
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
my Solution. didnt use filter cause it wasnt doing what i wanted lol
Ryan Ledford
@rledford
Nov 20 2016 05:47
@muzzotech youre replacing all your 'not word' matches
@muzzotech either filter all digits \d or remove all not digits \D
Nicola Scaramuzzo
@muzzotech
Nov 20 2016 05:51
@rledford I changed my regex to include all non-word characters which worked for almost all of them, but I'm having issues with "-1 (757) 622-7382" as it replaces the '-'. So confused.
Ryan Ledford
@rledford
Nov 20 2016 05:52
your regex above is looking for _ not -
you have an underscore in the regex not a dash which might help you figure it out
@muzzotech
Abhisek Pattnaik
@abhisekp
Nov 20 2016 05:55
@James-N-M hmm... i guess you're either C/C++ programmer? ;)
i inferred that from your bracket style
Allman style source code format
grdseime
@grdseime
Nov 20 2016 05:57
@revisualize that chart is a great resource. Ty!
CamperBot
@camperbot
Nov 20 2016 05:57
grdseime sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2373 | @revisualize |http://www.freecodecamp.com/revisualize
Ryan Ledford
@rledford
Nov 20 2016 06:00
@muzzotech my solution to the validate phone numbers algo is a bit long-winded, it was a long time ago. just to explain with out giving any answers, I used two separate regex (probably didn't need to) one was used to pull out all the digits to get a 'base' to make sure there were the correct number of digits, then I used a second one that checked for all digits and parenths. if they were in the right places and such for i would mark it as valid. There's an easier more concise way but I just figured I'd share my thought process on it at the time (months ago).
Jim Wallace
@reoski
Nov 20 2016 06:09
"return early pattern" is getting me
anyone complete it already?
Jackson Holiday Wheeler
@jhwheeler
Nov 20 2016 06:10
hey everyone
anyone know what's wrong here?
var array = [1, 12, 21, 2];
array.sort(function(a, b) {
return a + b;
});
supposed to sort the array from largest to smallest
Jim Wallace
@reoski
Nov 20 2016 06:12
@jhwheeler did you define your function?
Ryan Ledford
@rledford
Nov 20 2016 06:13
@jhwheeler if you want to know which one is bigger you subtract one from the other and return it. negative value would mean a is less than b and the other way around
jovmassimiliano
@jovmassimiliano
Nov 20 2016 06:13
hello guys, i want to ask about retrieve data from json by using ajax. currently i'm create simple form and i want to retrieve data from my own json file in my local project folder. should i using localhost to retrieve the data or could directly just using my json file directory?
Ryan Ledford
@rledford
Nov 20 2016 06:13
youre adding so you always get positive number (for that particular array of numbers) returned which means that a is always greater than b according to the logic of the sort function
Jackson Holiday Wheeler
@jhwheeler
Nov 20 2016 06:14
@reoski and @rledford Thanks for the help, I will try to figure it out. Would I need an if else statement to do this?
CamperBot
@camperbot
Nov 20 2016 06:14
jhwheeler sends brownie points to @reoski and @rledford :sparkles: :thumbsup: :sparkles:
:cookie: 197 | @reoski |http://www.freecodecamp.com/reoski
:cookie: 391 | @rledford |http://www.freecodecamp.com/rledford
Jim Wallace
@reoski
Nov 20 2016 06:14
@rledford what did you do for "return early pattern" when it expects an undefined value?
@jhwheeler what is the name of the lesson you are doing so I can get the full picture?
Ryan Ledford
@rledford
Nov 20 2016 06:14
@reoski i didnt mention any and return early pattern??
Jackson Holiday Wheeler
@jhwheeler
Nov 20 2016 06:14
The lesson is Sort Arrays witht sort
"Sort Arrays with sort" @reoski
Thank you!
Jim Wallace
@reoski
Nov 20 2016 06:15
@rledford sorry, I was asking about the lesson named "return early pattern"
Endy
@pisangGoreng
Nov 20 2016 06:15
@relentless-coder i see, ok i will check again. ths sir :)
Ryan Ledford
@rledford
Nov 20 2016 06:16
@reoski oh not sure i remember what the return early pattern challenge was
Endy
@pisangGoreng
Nov 20 2016 06:16
@muzzotech i see, ok i will check mu code again. thsx for u attension sir :smile: )
Nicola Scaramuzzo
@muzzotech
Nov 20 2016 06:20

I got closer

function telephoneCheck(str) {
  // Good luck!

  var re = /\D/g;
  var newStr = str.replace(re, '');
  if(newStr.length === 10){
    return true;
  } else if (newStr[0] === '1' && newStr.length === 11){
      return true;
  } else if (str[0] === re){
      return false;
  } else {
      return false;
  }
}



telephoneCheck("555-555-5555");

Unfortunately the following numbers are not turning up false.

-1 (757) 622-7382
(6505552368)
1 555)555-5555
555)-555-5555
(555-555-5555
(555)5(55?)-5555

How do I check for those?

Jim Wallace
@reoski
Nov 20 2016 06:20
@jhwheeler I took a look at it , but I am not even there yet :worried: sorry dude!
Will
@Will-is-Coding
Nov 20 2016 06:24
@muzzotech Try http://www.regexr.com/ for a quick place to fiddle with regular expressions. https://regexone.com/ to learn in depth
Walid Ashri
@walidashri
Nov 20 2016 06:25
@JohnnyBizzel thanks got as simple as this :)
Array.prototype.numberOfOccurrences = function (){
var x= arguments[0];
  return this.filter((a)=> x ===a ).length;
}
CamperBot
@camperbot
Nov 20 2016 06:25
walidashri sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 836 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Ogundele Olumide
@Lumexralph
Nov 20 2016 06:29
@jovmassimiliano i'll suggest using local host
@jovmassimiliano because the scheme of the urel matters, try both and see which works, you never know
tommy
@tommygebru
Nov 20 2016 06:41
I could use a hint for Sorted Union Challenge https://www.freecodecamp.com/challenges/sorted-union#
I tried using arguments and loops but it didnt seem logical when accounting for the length of the arrays
CamperBot
@camperbot
Nov 20 2016 06:41
Set a bonfire to talk about with bonfire name
Allisha
@lazershark4PrimeMinister
Nov 20 2016 06:44
Anyone still on the line?
tommy
@tommygebru
Nov 20 2016 06:45
online?
Allisha
@lazershark4PrimeMinister
Nov 20 2016 06:45
yeah
tommy
@tommygebru
Nov 20 2016 06:45
that depends
if you have a question
Allisha
@lazershark4PrimeMinister
Nov 20 2016 06:45
I'm having some trouble with challenge: Find the Longest Word in a String under the Basic Algorithim section
tommy
@tommygebru
Nov 20 2016 06:45
where are you having trouble/
Allisha
@lazershark4PrimeMinister
Nov 20 2016 06:45
function findLongestWord(str) {
  var wordString = str.split(' ');  
  return wordString.length;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
I keep returning '9'
tommy
@tommygebru
Nov 20 2016 06:46
that should be correct
9 is the length of Wordstring
Allisha
@lazershark4PrimeMinister
Nov 20 2016 06:46
but the longest word is 6 characters long. Someone had suggested a for loop earlier but I don't see how that would help
tommy
@tommygebru
Nov 20 2016 06:46
wordstring is now an array
of words
Allisha
@lazershark4PrimeMinister
Nov 20 2016 06:47
ah
so it's reading the literal 'wordString'
tommy
@tommygebru
Nov 20 2016 06:47
try return wordstring;
Allisha
@lazershark4PrimeMinister
Nov 20 2016 06:47
duh
tommy
@tommygebru
Nov 20 2016 06:47
no
try return wordstring;
you always want to know what you are returning, i recommend using console.log();
Walid Ashri
@walidashri
Nov 20 2016 06:48
@lazersharkPM u just split the string into words need to iterate through and find longest word
tommy
@tommygebru
Nov 20 2016 06:48
really often because if you use return; it will exit the function too quickly
@walidashri have you done Sorted Union?
@lazersharkPM keep going you are nearly there!
Allisha
@lazershark4PrimeMinister
Nov 20 2016 06:49
so instead of return wordstring I want console.log(wordstring); ?
Ogundele Olumide
@Lumexralph
Nov 20 2016 06:49
@lazersharkPM you need to iterate through the split str, check for the length of each and comapre against the strings length and return the one with highest length value
tommy
@tommygebru
Nov 20 2016 06:49
yes that will tell you what your code is evaluating based on where the console.log statement is located in your function
Łukasz Sobek
@lukaszsobek
Nov 20 2016 06:50

hmm, whats wrong with this solution?

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

farenheit = celsius * 9/5 + 32;

// Only change code above this line
return fahrenheit;
}

// Change the inputs below to test your code
convertToF(60);

Ogundele Olumide
@Lumexralph
Nov 20 2016 06:50
@lazersharkPM if log wordString to the console it will return the length of the array
@lukaszsobek there's a typo
Walid Ashri
@walidashri
Nov 20 2016 06:50
@tommygebru u need array from args but keep in mind it's multidimensional one
Ogundele Olumide
@Lumexralph
Nov 20 2016 06:50
@lukaszsobek farenheit = celsius * 9/5 + 32; fahrenheit
Łukasz Sobek
@lukaszsobek
Nov 20 2016 06:50
@Lumexralph lulz
@Lumexralph thanks :)
CamperBot
@camperbot
Nov 20 2016 06:51
lukaszsobek sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 472 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Nov 20 2016 06:51
@lukaszsobek :+1:
tommy
@tommygebru
Nov 20 2016 06:51
yeah I need to be able to add all the [i][j] but I cant seem to get how without getting a bug
for example how do i get it too loop each i? if the range is i<arguments.length.... there is a limitation there!
Allisha
@lazershark4PrimeMinister
Nov 20 2016 06:53
okay, cool. I've inserted the console.log(); so now I'm returning each string as an array. Now I just need to count each array and return the longest one... This would be were I use an if statement?
Ogundele Olumide
@Lumexralph
Nov 20 2016 06:53
@tommygebru use forEach array method
Walid Ashri
@walidashri
Nov 20 2016 06:54
@tommygebru done this ?
walidashri @walidashri gtg Happy code
Choo Ze Yuan
@Raikonen
Nov 20 2016 06:55
hi guys need some help with my record collection challenge
function updateRecords(id, prop, value) {

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

  return collection;
}
it returns a typeerror: cannot convert undefined or null to object
Ogundele Olumide
@Lumexralph
Nov 20 2016 06:56
@lazersharkPM you need to keep track of the length of each array, that means you might thinking of having a variable there, every time there's a check of the string length, check if the count variable tracking the length is greater if not update the variable then return it after your loop is done
tommy
@tommygebru
Nov 20 2016 06:56
@Lumexralph @walidashri thanks!
CamperBot
@camperbot
Nov 20 2016 06:56
tommygebru sends brownie points to @lumexralph and @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 663 | @walidashri |http://www.freecodecamp.com/walidashri
:cookie: 473 | @lumexralph |http://www.freecodecamp.com/lumexralph
Allisha
@lazershark4PrimeMinister
Nov 20 2016 06:57
@Lumexralph thanks. I get what you're saying, I just need to do some research as to how to do that
CamperBot
@camperbot
Nov 20 2016 06:57
lazersharkpm sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 474 | @lumexralph |http://www.freecodecamp.com/lumexralph
Allisha
@lazershark4PrimeMinister
Nov 20 2016 06:57
cheers
Ogundele Olumide
@Lumexralph
Nov 20 2016 06:57
@Raikonen the way you accessed your collection object with id is wrong...id is not a valid identifier in collection object, it's a variable so use [] method
@lazersharkPM all the best
@Raikonen collection[id][prop]
viviz
@zhiwuwu
Nov 20 2016 07:14

why this code can't passed the test in -"Golf Code"
function golfScore(par, strokes) {
// Only change code below this line
if(strokes == 1){
return "Hole-in-onel";
}else if(strokes<=par-2 ){
return "Eagle";
}else if(strokes == par -1){
return "Birdie";
}else if(strokes == par){
return "Par";
}else if(strokes == par + 1){
return "Bogey";
}else if(strokes == par + 2){
return "Double Bogey";
}

return "Go Home!";
// Only change code above this line
}

Joseph
@revisualize
Nov 20 2016 07:15
@zhiwuwu onel" Should be a !
AKASH GUNJAL
@AKASH888
Nov 20 2016 07:15
:thumbsup:
Joseph
@revisualize
Nov 20 2016 07:15
@Raikonen Dot Notation is a String Literal. Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation.
viviz
@zhiwuwu
Nov 20 2016 07:20
@revisualize
The same can not ,but it can run in console just can't passed the test if(strokes == 1)
Joseph
@revisualize
Nov 20 2016 07:20
@zhiwuwu Because it should be Hole-in-one! .. You have an l at the end.
@zhiwuwu I just used your code to complete the challenge by making that one correction.
Adetayo Timilehin
@Sprimage
Nov 20 2016 07:24
Hi all
Please is anyone up ?
I need help serving static files with express server
Heres my code
//loading node modules to script server side
var express = require('express');
var http = require('http');
var mysql = require('mysql');
var fs = require('fs');
var app = express(); 
var path = require('path');

var home = path.dirname(__dirname);
app.use(express.static('public'));

app.get('/', function(request, response){

console.log(home);
    response.sendFile(home + '/login.html', function(err){
        if (err) {
            response.send('No file found!');
        }

        else{
            console.log('File sent!');
        }
    })
});

/*
app.get('/styles/style.css', function(request, response){
    response.sendFile(home + '/styles/style.css');
});
**/

app.listen(8000, function(){
        console.log("xxxxge is running at localhost:8000");
        });
viviz
@zhiwuwu
Nov 20 2016 07:26
I add the ! .. maybe i used the Chinese version of the site have a bug.
@revisualize
Joseph
@revisualize
Nov 20 2016 07:26
@zhiwuwu Show me your code?
@zhiwuwu Did you remove the l?
@zhiwuwu does it say one! or onel!? Because it should be return "Hole-in-one!";
viviz
@zhiwuwu
Nov 20 2016 07:28
@revisualize thanks I was too careless
CamperBot
@camperbot
Nov 20 2016 07:28
zhiwuwu sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2374 | @revisualize |http://www.freecodecamp.com/revisualize
Adetayo Timilehin
@Sprimage
Nov 20 2016 07:31
hi
Ayush Bahuguna
@relentless-coder
Nov 20 2016 07:39
hello @Sprimage . how are you? :)
Adetayo Timilehin
@Sprimage
Nov 20 2016 07:39
im ok
//loading node modules to script server side
var express = require('express');
var http = require('http');
var mysql = require('mysql');
var fs = require('fs');
var app = express(); 
var path = require('path');

var home = path.dirname(__dirname);
app.use(express.static('public'));

app.get('/', function(request, response){

console.log(home);
    response.sendFile(home + '/login.html', function(err){
        if (err) {
            response.send('No file found!');
        }

        else{
            console.log('File sent!');
        }
    })
});

/*
app.get('/styles/style.css', function(request, response){
    response.sendFile(home + '/styles/style.css');
});
**/

app.listen(8000, function(){
        console.log("xxxxge is running at localhost:8000");
        });
brandonminkim
@brandonminkim
Nov 20 2016 07:43
Hello. Does anyone know if there is an error on "Manipulate Arrays With unshift"?
Ogundele Olumide
@Lumexralph
Nov 20 2016 07:45
@brandonminkim how?
brandonminkim
@brandonminkim
Nov 20 2016 07:45

// Example
var ourArray = ["Stimpson", "J", "cat"];
ourArray.shift(); // ourArray now equals ["J", "cat"]
ourArray.unshift("Happy");
// ourArray now equals ["Happy", "J", "cat"]

// Setup
var myArray = [["John", 23], ["dog", 3]];
myArray.shift();

// Only change code below this line.
myArray.unshift(["paul",35]);

Stanley Su
@cuddlycuddles
Nov 20 2016 07:47
@brandonminkim There shouldn't be. Also paste code properly, it'll tell you how in the markdown help button in the bottom right of the chat input area.
Ogundele Olumide
@Lumexralph
Nov 20 2016 07:48
@brandonminkim what are you to do from the instruction?
Stanley Su
@cuddlycuddles
Nov 20 2016 07:48

Help!

function lookUpProfile(firstName, prop){
// Only change code below this line
if (contacts.hasOwnProperty(firstName)) {
  if (contacts[firstName][prop]) {
    return contacts[firstName][prop];
  } else {
    return "No such property";
  }
    return "No such contact";
  }

// Only change code above this line
}

What am I doing wrong?

CamperBot
@camperbot
Nov 20 2016 07:48
no wiki entry for: function lookupprofilefirstname prop only change code below this lineif contactshasownpropertyfirstname if contactsfirstnameprop return contactsfirstnameprop else return no such property return no such contact only change code above this linewhat am i doing wrong
brandonminkim
@brandonminkim
Nov 20 2016 07:48
@Lumexralph my output has to be myArray should now have [["Paul", 35], ["dog", 3]].
and it is
Ogundele Olumide
@Lumexralph
Nov 20 2016 07:49
@cuddlycuddles is contacts an array or object?
brandonminkim
@brandonminkim
Nov 20 2016 07:49
but gives me an error;
Stanley Su
@cuddlycuddles
Nov 20 2016 07:49
@Lumexralph Contacts is an array.
Ogundele Olumide
@Lumexralph
Nov 20 2016 07:49
@brandonminkim your paul is is in lower case, it should be ["Paul"]
brandonminkim
@brandonminkim
Nov 20 2016 07:50
@Lumexralph oh! you are right! Thank you!!! I was going crazy!
CamperBot
@camperbot
Nov 20 2016 07:50
brandonminkim sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 475 | @lumexralph |http://www.freecodecamp.com/lumexralph
Stanley Su
@cuddlycuddles
Nov 20 2016 07:50
@brandonminkim
//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 lookUpProfile(firstName, prop){
// Only change code below this line
if (contacts.hasOwnProperty(firstName)) {
  if (contacts[firstName][prop]) {
    return contacts[firstName][prop];
  } else {
    return "No such property";
  }
    return "No such contact";
  }
return contacts;
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Ogundele Olumide
@Lumexralph
Nov 20 2016 07:51
@cuddlycuddles you're not iterating though the contacts to get each object, you need a loop to go through the elements of contacts
@brandonminkim :smile:
Stanley Su
@cuddlycuddles
Nov 20 2016 07:51
@Lumexralph thanks, I'll be back if i need more help <3
CamperBot
@camperbot
Nov 20 2016 07:51
cuddlycuddles sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 476 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Nov 20 2016 07:51
@cuddlycuddles :+1:
NITIN RAGHAV
@nitinraghav
Nov 20 2016 07:53

I am trying to add a thumbnail to my portfolio page:

<div class="row">
          <div class="col-xs-12 col-sm-6 col-md-4 ">
            <a class="thumbnail" href="https://codepen.io/nitinraghav/pen/zKjqWx"><img src="C:\Users\NITIN\Desktop\capture.JPG" alt="Tribute Page">Tribute Page</a>
          </div>

can someone help me with this?

Ogundele Olumide
@Lumexralph
Nov 20 2016 07:54
@nitinraghav are you working on your pc or online editor like codepen?
i think your picture format should be capture.jpg or png whatever case applies
aman65682
@aman65682
Nov 20 2016 08:05
@nitinraghav codepen wont access pictures stored on your computer. Upload it to a photo sharing site like imgur and then use that link.
brandonminkim
@brandonminkim
Nov 20 2016 08:06
var code = "formatted";
testing
NITIN RAGHAV
@nitinraghav
Nov 20 2016 08:09
@Lumexralph @aman65682 i tried uploading it to photobucket, dropbox and google drive all 3 dint work, seems like i am missing something:
<div class="col-xs-12 col-sm-6 col-md-4 ">
            <a class="thumbnail" href="https://codepen.io/nitinraghav/pen/zKjqWx"><img src="https://drive.google.com/file/d/0B5dJ11BUUOWtdHYxS25ldlNCUTg/view?usp=sharing" alt="Tribute Page">Tribute Page</a>
          </div>
aman65682
@aman65682
Nov 20 2016 08:11
@nitinraghav these do not work because you have signed in with your account and cant be shared like this easily. try imgur, it worked for me
NITIN RAGHAV
@nitinraghav
Nov 20 2016 08:14
@aman65682 imgur dint work out either
aman65682
@aman65682
Nov 20 2016 08:18
@nitinraghav can u give imgur link ?
brandonminkim
@brandonminkim
Nov 20 2016 08:21
testing
LydaTech
@lydatech
Nov 20 2016 08:22
you cant use imgur in codepen
brandonminkim
@brandonminkim
Nov 20 2016 08:22
testing
function functionWithArgs(a,b) {
  console.log(a+b);
}

functionWithArgs(1,7);
NITIN RAGHAV
@nitinraghav
Nov 20 2016 08:23
@aman65682 heres imgur link: http://imgur.com/4St78L9
LydaTech
@lydatech
Nov 20 2016 08:25
One option is to use https://postimage.org/ for image hosting. you cant use imgur in codepen it isnt supported
NITIN RAGHAV
@nitinraghav
Nov 20 2016 08:25
@aman65682 @lydatech thanks guys.. i tried cloudinary and it worked.
CamperBot
@camperbot
Nov 20 2016 08:25
nitinraghav sends brownie points to @aman65682 and @lydatech :sparkles: :thumbsup: :sparkles:
:cookie: 171 | @aman65682 |http://www.freecodecamp.com/aman65682
:star2: 1490 | @lydatech |http://www.freecodecamp.com/lydatech
aman65682
@aman65682
Nov 20 2016 08:27
@nitinraghav btw "http://i.imgur.com/4St78L9.jpg". this link will work for your image on imgur. you have to click on image on imgur and select copy image link and use that link
Vijith Nair
@wizelmagnifico
Nov 20 2016 08:29

Instructions
Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine
\SecondLine\
ThirdLine
You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

can some1 help me with this pls?
Ghulam Shabir
@ghulamshabir
Nov 20 2016 08:30
@wizelmagnifico what have you tried ?
Vijith Nair
@wizelmagnifico
Nov 20 2016 08:31
var myStr = "FirstLine\n\SecondLine\n\ThirdLine\r";
something like this
NITIN RAGHAV
@nitinraghav
Nov 20 2016 08:32
@aman65682 ya u right imgur worked too this time
Ghulam Shabir
@ghulamshabir
Nov 20 2016 08:32
@wizelmagnifico should \\\r after SecondLine
@wizelmagnifico remove \r in the last of string
aman65682
@aman65682
Nov 20 2016 08:34
@wizelmagnifico
var myStr = "FirstLine\n\SecondLine\\rThirdLine";
Vijith Nair
@wizelmagnifico
Nov 20 2016 08:35
var myStr = "FirstLine\n\SecondLine\ThirdLine\r"
i tried this
Ghulam Shabir
@ghulamshabir
Nov 20 2016 08:36
@wizelmagnifico \r should not in the end of string. it should be SecondLine\\\r
aman65682
@aman65682
Nov 20 2016 08:36
@wizelmagnifico put \r before the thirdLine.
Vijith Nair
@wizelmagnifico
Nov 20 2016 08:36
myStr should have encoded text with the proper escape sequences and no spacing.
this is the only error m gettin
aman65682
@aman65682
Nov 20 2016 08:37
@wizelmagnifico did you try my code ?it should work
Vijith Nair
@wizelmagnifico
Nov 20 2016 08:37
yeah i tried
but it didn't
aman65682
@aman65682
Nov 20 2016 08:38
"FirstLine\n\SecondLine\\rThirdLine
actually use one more \ with r
before r
like \\r
"FirstLine\n\\SecondLine\\\rThirdLine
like this
Vijith Nair
@wizelmagnifico
Nov 20 2016 08:39
thnx it worked
Mike Haslam
@Ongomobile
Nov 20 2016 08:42

Hello I was wondering if someone could help me with refactoring my code the app basically tallies a quantity on a press of button then multiplies by a value and displays total for all in a span. I know this may be easier in jQuery, but I am doing this in vanilla JS to learn to understand Vanilla JS more.

Here is a Plunker http://plnkr.co/edit/Npckf3PjFqNRejO3AgSD

What I need help with is my tallyForBtnSelected method starting on line 27 in script.js. I am eventually going to add values to buttons array dynamically instead being hard coded. Any ideas?

Thanks Mike

Chris
@Cbhansen
Nov 20 2016 08:44
i need help!
Jean Baptiste Kwizera
@jbkwizera
Nov 20 2016 08:44
can someone here help me understand what I am getting wrong. I need to check the presence of firstName and prop. If they are both present, return the value of prop. If only firstName is present, return No such property. If neither is present, return No such contact.

//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 lookUpProfile(firstName, prop){
// Only change code below this line
  for(var i = 0; i < contacts.length; i++) {
    if(contacts[i].firstName == firstName) {
      if(contacts[i].hasOwnProperty(prop)) {
        console.log(contacts[i].prop);
      }
      else{
        console.log("No such property");
      }
    } 
    else{
      console.log("No such contact");
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Bob", "likes");
Ivar
@good1uck
Nov 20 2016 08:51

function truncateString(str, num) {
  // Clear out that junk in your trunk
  if(str.length>num){
     if(num<=3){
       return str.substr(0,num)+"...";
     } 
    return str.substr(0,num-3)+"...";
  }
  return str;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
hello ,can this code be simplified further?
Ghulam Shabir
@ghulamshabir
Nov 20 2016 08:52
@good1uck no, its simplest
Kingdom Isaac
@kingisaac95
Nov 20 2016 08:52
Hi, am having issues understanding the fcc nesting for loops quiz. Can anyone help me get a clearer understanding of multi-dimensional arrays?
Ghulam Shabir
@ghulamshabir
Nov 20 2016 08:54
@kingisaac95 outer loop iterates over the containing array and inner loop iterates over each sub-array on each iteration of outer loop
@kingisaac95 inner loop completes all the iterations in each single iteration of outer loop
Kingdom Isaac
@kingisaac95
Nov 20 2016 08:57
here's my code
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i < arr.lenght; i++) {
for (var j=0; j < arr[i].lenght; j++) {
product *= arr[i][j];
}
}
// Only change code above this line
return product;
}
Ghulam Shabir
@ghulamshabir
Nov 20 2016 08:58
@kingisaac95 you have a typo in second loop
Kingdom Isaac
@kingisaac95
Nov 20 2016 08:58
Oh gosh!!! I just realize my mistake
Ghulam Shabir
@ghulamshabir
Nov 20 2016 08:59
actually in both loops
Kingdom Isaac
@kingisaac95
Nov 20 2016 08:59
I typed lenght instead of length
Ghulam Shabir
@ghulamshabir
Nov 20 2016 08:59
ye I told you first lol
Vijith Nair
@wizelmagnifico
Nov 20 2016 08:59

We will now use our knowledge of strings to build a "Mad Libs" style word game we're calling "Word Blanks". You will create an (optionally humorous) "Fill in the Blanks" style sentence.

You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.

You will also need to use additional strings, which will not change, and must be in between all of the provided words. The output should be a complete sentence.

We have provided a framework for testing your results with different words. The tests will run your function with several different inputs to make sure all of the provided words appear in the output, as well as your extra strings.

Kingdom Isaac
@kingisaac95
Nov 20 2016 08:59
Thanks guys. Coming here just helped ;me realize my mistakes
Vijith Nair
@wizelmagnifico
Nov 20 2016 09:00
this is my instruction
Ghulam Shabir
@ghulamshabir
Nov 20 2016 09:00
@kingisaac95 mention @name for thanking so I get a brownie
Vijith Nair
@wizelmagnifico
Nov 20 2016 09:00

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

Kingdom Isaac
@kingisaac95
Nov 20 2016 09:00
@ghulamshabir Thanks bro
CamperBot
@camperbot
Nov 20 2016 09:00
kingisaac95 sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1084 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Vijith Nair
@wizelmagnifico
Nov 20 2016 09:00
nd this is what they have given me
can nybody help?
Ghulam Shabir
@ghulamshabir
Nov 20 2016 09:01
@wizelmagnifico build a new string from those variables (parameters) using + putting a string of word from your madlibs or just space between each pair of words
Vijith Nair
@wizelmagnifico
Nov 20 2016 09:02
what m I supposed to do?
i dont get it.. @ghulamshabir
Łukasz Sobek
@lukaszsobek
Nov 20 2016 09:02
@wizelmagnifico incorporate the variables so they make a sentence
Ghulam Shabir
@ghulamshabir
Nov 20 2016 09:03
@wizelmagnifico for example your output should be big dog ran quicky instead of bigdogranquickly
Łukasz Sobek
@lukaszsobek
Nov 20 2016 09:03
so var1 + " " + var 2 + " " + var3;
Vijith Nair
@wizelmagnifico
Nov 20 2016 09:03
should i create a new string?
Łukasz Sobek
@lukaszsobek
Nov 20 2016 09:03
yep
by combining the elements
into a sentence
Chris
@capozzic1
Nov 20 2016 09:04
Hello, I have a question

,,, function sumFibs(num) {
//first 2 are 1,1
//find all fibonacci numbers under num
var fib = [1,1]
var lastN = fib[fib.length - 1];
fib.push(2);

console.log(fib);
console.log(lastN);
}

sumFibs(); ,,,

shoudn't lastN produce 2 in the console ?
it produces 1 right now
Łukasz Sobek
@lukaszsobek
Nov 20 2016 09:05
Help pls, something is not working here
var count = 0;

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

  switch (card) {

    case "2": 
    case "3": 
    case "4": 
    case "5": 
    case "6":
      count++;
      break;

    case "10": 
    case "J": 
    case "Q": 
    case "K": 
    case "A":
      count--;
      break;  

  }


  if (count > 0) {   message = "Bet";
  } else {           message = "Hold";
  }


  return count + " " + message;
  // Only change code above this line
}
KorabeL448
@KorabeL448
Nov 20 2016 09:05
Hello guys Could you help me? What's wrong with that?
 function titleCase(str) {
  var strLow = str.toLowerCase();
  var array2 = [];
  array = strLow.split(" ");

 for (i = 0; i < array.length; i++) {

   array2[i] = array[i].toUpperCase();
   array[i].charAt(0) = array2[i].charAt(0);
    }
  return array;
}
titleCase("I'm a little tea pot");
Ghulam Shabir
@ghulamshabir
Nov 20 2016 09:06
@wizelmagnifico review this lesson https://www.freecodecamp.com/challenges/concatenating-strings-with-plus-operator, your challenge has variables instead of string literals in this case
Łukasz Sobek
@lukaszsobek
Nov 20 2016 09:06
@capozzic1 use the ``` for code (the key above TAB)
Chris
@capozzic1
Nov 20 2016 09:07

``` function sumFibs(num) {
//first 2 are 1,1
//find all fibonacci numbers under num
var fib = [1,1]
var lastN = fib[fib.length - 1];
fib.push(2);

console.log(fib);
console.log(lastN);
}

sumFibs(); ```

Łukasz Sobek
@lukaszsobek
Nov 20 2016 09:08
in new lines :)
Chris
@capozzic1
Nov 20 2016 09:08
function sumFibs(num) {
  //first 2 are 1,1
  //find all fibonacci numbers under num
    var fib = [1,1]
  var lastN = fib[fib.length - 1];
  fib.push(2);

  console.log(fib);
  console.log(lastN);

}

sumFibs();
yay!
Łukasz Sobek
@lukaszsobek
Nov 20 2016 09:08
thumbsUp
Chris
@capozzic1
Nov 20 2016 09:08
@lukaszsobek thanks alot
CamperBot
@camperbot
Nov 20 2016 09:08
capozzic1 sends brownie points to @lukaszsobek :sparkles: :thumbsup: :sparkles:
:cookie: 161 | @lukaszsobek |http://www.freecodecamp.com/lukaszsobek
Łukasz Sobek
@lukaszsobek
Nov 20 2016 09:09
yw
Chris
@capozzic1
Nov 20 2016 09:09
im trying to just capture the last number of the array for fib right now. but it lastN keeps putting "1" to the console
instead of "2"
Ghulam Shabir
@ghulamshabir
Nov 20 2016 09:09
@KorabeL448 array2[i] = array[i].toUpperCase(); here use strLow[i]`instead of array2 and convert case of first letter not entire word like this strLow[i][0].toUpperCase(), and also contcatenate remaining letters of each word using slice/substring
Vijith Nair
@wizelmagnifico
Nov 20 2016 09:10

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result = "My " + "big " + "dog "+ "ran " + "quickly ";

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

is this wat u guys meant
??
KorabeL448
@KorabeL448
Nov 20 2016 09:10
@ghulamshabir i understand thank you
CamperBot
@camperbot
Nov 20 2016 09:10
korabel448 sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1085 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Nov 20 2016 09:11
@wizelmagnifico use parameters myNoun etc instead of "dog" etc
Stanley Su
@cuddlycuddles
Nov 20 2016 09:11
@lukaszsobek For the card code:
You haven't done anything to specify what happens when you get 7, 8, or 9. Even though nothing happens, the count should increase or decrease by 0.
Also, search up what a ternary operator is. You will need it for the final return statement.
Vijith Nair
@wizelmagnifico
Nov 20 2016 09:11
k
Johnny
@JohnnyBizzel
Nov 20 2016 09:12
@walidashri Ah. I thought that wasn't working for you. * you said arguments undefined?
hongwutian
@hongwutian
Nov 20 2016 09:12
HI i'm learning basic javascript lesson: stand in line. Anyone knows how to determine array has anything in it
Walid Ashri
@walidashri
Nov 20 2016 09:13
@KorabeL448 array[i].charAt(0) = array2[i].charAt(0); changing strings?
Vijith Nair
@wizelmagnifico
Nov 20 2016 09:13
how do i put space?
Walid Ashri
@walidashri
Nov 20 2016 09:13
@JohnnyBizzel yes won't work with arrows :) thanks
Ghulam Shabir
@ghulamshabir
Nov 20 2016 09:14
@wizelmagnifico you can use either words from madlibs with space as you did with "my "or simply +" "+
KorabeL448
@KorabeL448
Nov 20 2016 09:15
@walidashri no
it doesn't work
Walid Ashri
@walidashri
Nov 20 2016 09:16
@KorabeL448 yes cause you are trying to change string it's immutable remember :)
Ivar
@good1uck
Nov 20 2016 09:16
@ghulamshabir ok
Łukasz Sobek
@lukaszsobek
Nov 20 2016 09:16
will do, thanks @cuddlycuddles
CamperBot
@camperbot
Nov 20 2016 09:16
lukaszsobek sends brownie points to @cuddlycuddles :sparkles: :thumbsup: :sparkles:
:cookie: 222 | @cuddlycuddles |http://www.freecodecamp.com/cuddlycuddles
KorabeL448
@KorabeL448
Nov 20 2016 09:18
@walidashri I see now thx
CamperBot
@camperbot
Nov 20 2016 09:18
korabel448 sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 664 | @walidashri |http://www.freecodecamp.com/walidashri
Walid Ashri
@walidashri
Nov 20 2016 09:20
@KorabeL448 use this str = str[0] + str.substring(1)
Ghulam Shabir
@ghulamshabir
Nov 20 2016 09:21
@walidashri @KorabeL448 if you want substring from an index to end of string then second argument is not necessary
Walid Ashri
@walidashri
Nov 20 2016 09:22
@ghulamshabir ah yes thanks
CamperBot
@camperbot
Nov 20 2016 09:22
walidashri sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1086 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Nov 20 2016 09:23
@walidashri :smile:
Cengiz Gonen
@cgonen
Nov 20 2016 09:26
```
function countBs(string) {
var hoofd = String(string);
var x = 0;
while (hoofd.charAt(x) < hoofd.length) {
  x =+ 1;
  if (hoofd.chatAt(x) == "B")
  return string += 1;

  else x += 1;
};
};
console.log(countBs("nooBhoB"));
it just seems so logic... x)
but i'm doing something wrong. Syntax is off.. anyone notices something?
Ghulam Shabir
@ghulamshabir
Nov 20 2016 09:29
@attilay you are comparing a letter to a number hoofd.charAt(x) returns first letter how it can greater be than .length ? may be its unicode ?
Łukasz Sobek
@lukaszsobek
Nov 20 2016 09:29
string.length
Cengiz Gonen
@cgonen
Nov 20 2016 09:30
Err.... hmm.. brb!
Łukasz Sobek
@lukaszsobek
Nov 20 2016 09:33
still stuck with this. the variable count is not being increased even though it is declared outside the function and reused in global scope inside the function
var count = 0;

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

  switch (card) {

    case "2": 
    case "3": 
    case "4": 
    case "5": 
    case "6":
      count++;
      break;

    case "10": 
    case "J": 
    case "Q": 
    case "K": 
    case "A":
      count--;
      break; 

  }


  if (count > 0) { message = "Bet"; } else { message = "Hold"; }


  return count + " " + message;
  // Only change code above this line
}
Ghulam Shabir
@ghulamshabir
Nov 20 2016 09:34
@lukaszsobek "2" and 2 are two different values, use numbers without quotes
Łukasz Sobek
@lukaszsobek
Nov 20 2016 09:34
lol, thanks XD facepalm @ghulamshabir
CamperBot
@camperbot
Nov 20 2016 09:34
lukaszsobek sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1087 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Stanley Su
@cuddlycuddles
Nov 20 2016 09:34
@lukaszsobek for the numbers in your switch cases, you don't need quotes.
@lukaszsobek Also I don't know if your thing will work, because you haven't defined message.
REAPERkato
@REAPERkato
Nov 20 2016 09:35
Set myName to a string equal to your name and build myStr with myName between the strings "My name is " and " and I am swell!"
Ghulam Shabir
@ghulamshabir
Nov 20 2016 09:35
@cuddlycuddles @lukaszsobek he got a nudge now he gonna do it
Łukasz Sobek
@lukaszsobek
Nov 20 2016 09:35
@cuddlycuddles I have in the if statement, although not the thing of beauty it coverrs all possibilities
REAPERkato
@REAPERkato
Nov 20 2016 09:35
i put my name in middle and wont work still
Mike Haslam
@Ongomobile
Nov 20 2016 09:35
@jbkwizera You almost had it you did not return prop try this in your second if statement return statement return contacts[i][prop]; ps I found the error by using the debugger in javascript console I did put it in a plunker but you can do same thing in browser learning to use the debugger is very helpful
Anthony Drane
@Antiaccess
Nov 20 2016 09:37
Can anyone tell me why my elements aren't centered? https://codepen.io/antiaccess/pen/wogRwp
Ghulam Shabir
@ghulamshabir
Nov 20 2016 09:37
@REAPERkato are you using quotes around myName ?
Jean Baptiste Kwizera
@jbkwizera
Nov 20 2016 09:37
thanks @Ongomobile I finally found my way around it.
CamperBot
@camperbot
Nov 20 2016 09:37
jbkwizera sends brownie points to @ongomobile :sparkles: :thumbsup: :sparkles:
:cookie: 302 | @ongomobile |http://www.freecodecamp.com/ongomobile
Stanley Su
@cuddlycuddles
Nov 20 2016 09:40
@Ongomobile When should we use bracket notation or dot notation? Why doesn't contacts[i].prop work?
Ivar
@good1uck
Nov 20 2016 09:42

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var len=arr.length;
  var arr2=[];
    for(var i=0;i<arr.length;i+=size){
      arr2.push(arr.slice(i,i+size));
    }
/*
  for(;i<arr.length;i++){
      var tarr=[];
    tarr.push(arr[i]);
    arr2.push(tarr);      
  }
  return arr2;
  */
  return arr2;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4);
hello,can this code be simplified further?
Ghulam Shabir
@ghulamshabir
Nov 20 2016 09:44
@good1uck only you can remove len
Ivar
@good1uck
Nov 20 2016 09:46
@ghulamshabir oh yea,i forget it :)
Mike Haslam
@Ongomobile
Nov 20 2016 09:53
@cuddlycuddles I would believe that[prop] in this case refers to property you want to return from contacts array and .firstName for example in if statement is checking if true and not returning the value
I going out now hope you all have a good day!
Stanley Su
@cuddlycuddles
Nov 20 2016 09:54
@Ongomobile Thanks, have a good day as well :) wtf it's 8:53PM here in Australia haha
CamperBot
@camperbot
Nov 20 2016 09:54
cuddlycuddles sends brownie points to @ongomobile :sparkles: :thumbsup: :sparkles:
:cookie: 303 | @ongomobile |http://www.freecodecamp.com/ongomobile
Anthony Drane
@Antiaccess
Nov 20 2016 09:54
Can anyone here tell me where I'm going wrong centering elements for the simon game https://codepen.io/antiaccess/pen/wogRwp
need help please
MoaadGit
@MoaadGit
Nov 20 2016 10:05
how you would guys do this? =>Remove all falsy values from an array.

`
function bouncer(arr) {
// Don't show a false ID to this bouncer.
var filtered = arr.filter(function(value){

return value!==0&&value!==false&&value!==""&&value!==null&&value!==undefined&&value!==0&&Number.isNaN(value)===false;

});

return filtered;
}

bouncer([7, "ate", "", false, 9,NaN]);
`

do you think this is good code?
tha1ae
@tha1ae
Nov 20 2016 10:07

var count = 0;

function cc(card) {
  // Only change code below this line
 if(card==6){
   return "5 Bet";}

  else if(card==9){
     return "0 Hold";}

  else if(card=="A"){
    return "-5 Hold";
  }

  else if (card==7){
    return "1 Bet";
  }

  else if (card==10){
    return "1 Bet";
  }

  else if (card=="K")
    {
      return "-1 Hold";
    }
  else if(card=="A"||card==8)
  {
    return "-1 Hold";
  }
Guys i cant figure out to get the card sequence 3,7,Q,8,A to display "-1 Hold" with out "-5 Hold"
Mike Haslam
@Ongomobile
Nov 20 2016 10:07
@cuddlycuddles I am in Thailand
Stanley Su
@cuddlycuddles
Nov 20 2016 10:08
@tha1ae That code is completely off. Don't worry about the examples, because the count could've already been -4 because the game had gone on for a while.
By the way, you should use a switch rather than if else.
tha1ae
@tha1ae
Nov 20 2016 10:11
ok i try it again thanks
Mateusz Kadlubowski
@xeho91
Nov 20 2016 10:16
Anyone knows why challenge "Sum All Odd Fibonacci Numbers" keeps crashing?
Ghulam Shabir
@ghulamshabir
Nov 20 2016 10:19
@MoaadGit you could have returned just value and filter would take care of boolean evaluations
@xeho91 infinite loop ?
Mateusz Kadlubowski
@xeho91
Nov 20 2016 10:20
@ghulamshabir Yeah I thought it might be infinite loop, but there isn't any loop :(
Mateusz Kadlubowski
@xeho91
Nov 20 2016 10:22
@ghulamshabir Thanks!
CamperBot
@camperbot
Nov 20 2016 10:22
xeho91 sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1088 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Mateusz Kadlubowski
@xeho91
Nov 20 2016 10:24

@ghulamshabir So I rewrote the code to test what's the problem:


function sumFibs(num) {

  var fibonacciNumbers = [];

  for (var i = 0; i <= num; i++) {

    fibonacciNumbers.push(i);
  }

  return fibonacciNumbers;
}

sumFibs(4);

Do you see an infinite loop there? Because when I run it - it crashes.

Ivar
@good1uck
Nov 20 2016 10:26

function mutation(arr) {
  for(var i=0;i<arr[1].length;i++){
    if(arr[0].toLowerCase().indexOf(arr[1][i].toLowerCase())==-1){
      return false;
    }
  }
  return true;
}

mutation(["hello", "hey"]);
hello, can this code be simplified further?
Ayush Bahuguna
@relentless-coder
Nov 20 2016 10:30
in the seek and destroy challenge, the function contains just the the arr parameter. How am I supposed to refer to the arguements?
Ghulam Shabir
@ghulamshabir
Nov 20 2016 10:30
@relentless-coder arguments object
@relentless-coder function (arguments[0], arguments[1], arguments[2])
Ayush Bahuguna
@relentless-coder
Nov 20 2016 10:35
@heroiczero thank you
CamperBot
@camperbot
Nov 20 2016 10:35
relentless-coder sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:cookie: 406 | @heroiczero |http://www.freecodecamp.com/heroiczero
AlBMyName
@IshmaRey-Hool
Nov 20 2016 10:35

Hi I'm doing...
https://www.freecodecamp.com/challenges/show-the-local-weather

This is my CodePen link...
http://codepen.io/Ishma-Reyhool/pen/WGXqdO

My problem is that I don't know how to get data from the Open Weather API.

MoaadGit
@MoaadGit
Nov 20 2016 10:37
@ghulamshabir eplaint more please?
Ghulam Shabir
@ghulamshabir
Nov 20 2016 10:38
@MoaadGit
arr.filter(function(value) {
  return value;
}
MoaadGit
@MoaadGit
Nov 20 2016 10:40
that wont work
you filtered nothing here
Markus Kiili
@Masd925
Nov 20 2016 10:45
@MoaadGit It works.
Because filter method has automatic coercion to type Boolean, so that filters falsy values out.
Winter S. Ndolo
@xulenvirp
Nov 20 2016 10:47
hey guys, who knows has done this challange?
"Logical Order in If Else Statements"
Markus Kiili
@Masd925
Nov 20 2016 10:48
@xulenvirp Yes.
Winter S. Ndolo
@xulenvirp
Nov 20 2016 10:50
@Masd925 how do i use this?
foo(0) // "Less than one"
bar(0) // "Less than two"
Markus Kiili
@Masd925
Nov 20 2016 10:50
@xulenvirp Those are just example calls to the example functions.
You need to change the logic of the if-else structure so that it returns those three strings correctly.
MoaadGit
@MoaadGit
Nov 20 2016 10:54
@Masd925 tried it and didnt work
Winter S. Ndolo
@xulenvirp
Nov 20 2016 10:55
@Masd925 just send me your code , i dont get you hahaahah
MoaadGit
@MoaadGit
Nov 20 2016 10:55
Help here:
CamperBot
@camperbot
Nov 20 2016 10:55
no wiki entry for: here
MoaadGit
@MoaadGit
Nov 20 2016 10:55
Remove all elements from the initial array that are of the same value as these arguments.

`
function destroyer(arr) {

console.log(arguments.length);
var filterd=arr.filter(function(value){

  for(var i=1;i<arguments.length;i++){

    if(value===arguments[i]){

      break;
    }
    else if(i===arguments.length-1){
      return value;
    }
  }

});

return filterd;
}

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

Stanley Su
@cuddlycuddles
Nov 20 2016 10:55

@xulenvirp Like Masd925 said, those are just examples>
But I think in that challenge, it's just better to put the if statement with the lower condition first, then higher conditions. Because if it's:

if (x < 2) {
return "x is less than 2";
} else if (x < 1) {
return "x is less than 1";
}

So even if you put 0 into the function, it'll say that x is less than two, but even though that's true, it's not as accurate as x is less than one.

Markus Kiili
@Masd925
Nov 20 2016 10:56
@MoaadGit It needs the return statement:
Ghulam Shabir
@ghulamshabir
Nov 20 2016 10:56
@MoaadGit why break ? you should let the loop finish
Markus Kiili
@Masd925
Nov 20 2016 10:56
function bouncer(arr) { 
  return arr.filter(function(value){
    return value;
  });                 
}
Winter S. Ndolo
@xulenvirp
Nov 20 2016 10:58
@cuddlycuddles then give me a sample i can use for all this to fit using { foo and boo}
function orderMyLogic(val) {
  if (val < 10) {
    return "Less than 10";
  } else if (val < 5) {
    return "Less than 5";
  } else {
    return "Greater than or equal to 10";
  }
}

// Change this value to test
orderMyLogic(7);
WKhaw
@vickyhaw94
Nov 20 2016 10:58
function updateRecords(id, prop, value) {
      if((collection[id].hasOwnProperty(prop) === false)){
          if(prop === "tracks"){
          collection[id][prop] = [];
          collection[id][prop].push(value);
          }
          else{
            collection[id][prop].push(value);
          }
      }
      else if((prop === "tracks") && (value !== "")){
        collection[id][prop].push(value);
      }
      else if(value === ""){
        delete collection[id][prop];
      }


  return collection;
}
currently doing the record collection challenge, can anyone help to point me out where get wrong ? I feel like already fullfill all the requirement but cant pass the challenge
Any help will be appreciate !!
MoaadGit
@MoaadGit
Nov 20 2016 10:59
thanks @Masd925
CamperBot
@camperbot
Nov 20 2016 10:59
moaadgit sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2959 | @masd925 |http://www.freecodecamp.com/masd925
MoaadGit
@MoaadGit
Nov 20 2016 10:59
that filter removed all the the falsy values
its is by defaults removes them?
Stanley Su
@cuddlycuddles
Nov 20 2016 10:59
@xulenvirp the (val < 5) if statement should be above the (val < 10) if statement.
heroiczero
@heroiczero
Nov 20 2016 11:00
@vickyhaw94 if collection doesn't have a prop, can you collection[id][prop].push(value); you can only push array
Ghulam Shabir
@ghulamshabir
Nov 20 2016 11:01
@MoaadGit filter returns new array skipping the elements for which its callback returns false
Markus Kiili
@Masd925
Nov 20 2016 11:01
@MoaadGit Filter passes each array element to the callback and keeps those that return a truthy value. By just returning the function parameter from the callback makes filter keep the truthy elements.
MoaadGit
@MoaadGit
Nov 20 2016 11:01
yeh thanks
Winter S. Ndolo
@xulenvirp
Nov 20 2016 11:01
so this is what it should look like?
foo(0) // "Less than 5"
bar(0) // "Less than 10"
Ghulam Shabir
@ghulamshabir
Nov 20 2016 11:02
@MoaadGit mention @name for thankings
Winter S. Ndolo
@xulenvirp
Nov 20 2016 11:02
@cuddlycuddles
MoaadGit
@MoaadGit
Nov 20 2016 11:02
@ghulamshabir i did break because no need to continue
Stanley Su
@cuddlycuddles
Nov 20 2016 11:02
@xulenvirp Send me the entire code, I don't understand. The foo and bar is just an example, you don't need to worry about it.
MoaadGit
@MoaadGit
Nov 20 2016 11:03
if the value equal the argument i dont need that value
WKhaw
@vickyhaw94
Nov 20 2016 11:03

@heroiczero hi, you seems right what should i do should be

collection[id][prop] = value;

right? because it dont have prop so cant push the value to the prop which doesnt exists

Ghulam Shabir
@ghulamshabir
Nov 20 2016 11:03
@MoaadGit there is need to continue to match for all the elements in arguemnts
WKhaw
@vickyhaw94
Nov 20 2016 11:03
@heroiczero Thanks you!!
CamperBot
@camperbot
Nov 20 2016 11:03
vickyhaw94 sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:cookie: 407 | @heroiczero |http://www.freecodecamp.com/heroiczero
heroiczero
@heroiczero
Nov 20 2016 11:03
@vickyhaw94 :+1:
Stanley Su
@cuddlycuddles
Nov 20 2016 11:04
Goodnight :smile:
bahaa aldin
@bahaa-al-deen
Nov 20 2016 11:05
@sjames1958gm thanks
CamperBot
@camperbot
Nov 20 2016 11:05
bahaazidan sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4441 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Fabio Di Pane
@saylos
Nov 20 2016 11:05

hi guys, I'm trying to understand how .replace ad regular expressions work..if I run this:

function palindrome(str) {
  // Good luck!
  var oldStr = str;

  var lowerStr = oldStr.toLowerCase();
  var cleanedStr = lowerStr.replace(/[a-b\W]/g, "")

  return cleanedStr;
}



palindrome("eye_ Eye#");

I get "eyeeye"..how can I get rid of "" ?

_
hellboy81
@hellboy81
Nov 20 2016 11:05
Hi
heroiczero
@heroiczero