These are chat archives for FreeCodeCamp/HelpJavaScript

28th
Apr 2016
Matthew Fricker
@mattfricker
Apr 28 2016 00:02
@tuliodnw You can make arguments into a proper array by using the Array's slice method and calling it on arguments

var newArgs = [].slice.call(arguments);
Diego Mayer
@Chrono79
Apr 28 2016 00:03
@sinere you don't have to use 2 for loops
Matthew Fricker
@mattfricker
Apr 28 2016 00:03
@tuliodnw What this is doing is using the slice method present in all real arrays and then calling that function on the array-like arguments object. This call of slice received no other parameters, meaning that all items from arguments will be added to the newArgs array
Coryphaeus
@cvdeby
Apr 28 2016 00:04
@sinere If contacts[0].firstName !== firstName you return "No such contact" - it means that if first condition failed, you'll not check another contacts properties.
@sinere Please, give us contacts object too.
Ross
@AnInsaneScientist
Apr 28 2016 00:06
Is there anyway to make an 'if character is upper case' kind of statement in JS? Trying to do Caesars Cipher and I was thinking of a solution something like this:
function rot13(str) { // LBH QVQ VG!
  var decoded = [];
  var arr = str.split('');
  for (var i = 0; i < arr.length; i++) {
    if (arr[i] == /[A-Z]/) {
      decoded.push(arr.charCodeAt(arr[i]) - 13);
    }
    else {
      decoded.push(arr[i]);
    }
  }
  return String.fromCharCode(decoded);
}
Matthew Fricker
@mattfricker
Apr 28 2016 00:07
@AnInsaneScientist One way is to see if character === character.toUpperCase()
Andrew Vanboxel
@avanbox
Apr 28 2016 00:07
hey everyone.
Ross
@AnInsaneScientist
Apr 28 2016 00:07
Thanks @mattfricker
CamperBot
@camperbot
Apr 28 2016 00:07
aninsanescientist sends brownie points to @mattfricker :sparkles: :thumbsup: :sparkles:
:star: 133 | @mattfricker | http://www.freecodecamp.com/mattfricker
Matthew Fricker
@mattfricker
Apr 28 2016 00:07
@AnInsaneScientist any time
Andrew Vanboxel
@avanbox
Apr 28 2016 00:07
can someone tell me why this is an infinite loop?
for(var i=1; i<str.length; i++){
    if (str[i]===str[i].toUpperCase()&&str[i-1]===" "){
      str=str.slice(0, str[i])+"-"+str.slice(str[i]);
    }
  }
Matthew Fricker
@mattfricker
Apr 28 2016 00:09
@avanbox How do you know that it is an infinite loop?
Jason Keenan
@raavin
Apr 28 2016 00:09
Does slice mutate the original
Hideto
@hideto0118
Apr 28 2016 00:10
Can someone help me?

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

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

Matthew Fricker
@mattfricker
Apr 28 2016 00:10
@raavin Slice does not mutate
Andrew Vanboxel
@avanbox
Apr 28 2016 00:10
@mattfricker i get an erro on FCC and codepen
Matthew Fricker
@mattfricker
Apr 28 2016 00:11
@avanbox Paste the codepen link and ill debug it
D.Mills
@millsdee74
Apr 28 2016 00:11

Challenge: Replace If Else Chains with Switch. I can't figure the code out. Can anyone help, this is what I have so far..... // Only change code below this line

switch (val) {
case "bob"
answer = "Marley";
break;
case 42:
answer = "The Answer";
break;
case 1
answer = "There is no #1";
break;
case 99
answer = "Missed me by this much!";
break;
case 7
answer = "Ate Nine";
break;
}

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

// Change this value to test
chainToSwitch(7);

nabeelaa
@nabeelaa
Apr 28 2016 00:12
why is my weather app not working?? https://codepen.io/nabeela/pen/wGEdLx
Andrew Vanboxel
@avanbox
Apr 28 2016 00:12
this is not close to a final solution i just started messing around with this task.
http://codepen.io/avanbox/pen/bpKWrQ
Matthew Fricker
@mattfricker
Apr 28 2016 00:13
@avanbox I think @raavin was right that reassigning str within the loop is likely causing the issue
Desiree
@hereonpurpose
Apr 28 2016 00:14
@hideto0118 you've got the right idea w using a loop and if else logic but you don't need to use a nested loop
Andrew Vanboxel
@avanbox
Apr 28 2016 00:14
hmmm. ok. I really wanted to use string.replace anyway. ill go figure out the regex i need. Thanks @mattfricker @raavin
CamperBot
@camperbot
Apr 28 2016 00:14
avanbox sends brownie points to @mattfricker and @raavin :sparkles: :thumbsup: :sparkles:
:star: 134 | @mattfricker | http://www.freecodecamp.com/mattfricker
:star: 245 | @raavin | http://www.freecodecamp.com/raavin
Desiree
@hereonpurpose
Apr 28 2016 00:14
@hideto0118 I got help solving this one and finally 'got it' earlier today, fwiw
@hideto0118 also your test/logic for checking the prop won't work
Hideto
@hideto0118
Apr 28 2016 00:16
@hereonpurpose okay!
Let me try to fix this.
Coryphaeus
@cvdeby
Apr 28 2016 00:16
@nabeelaa You need to use function showPosition like a callback for getCurrentPosition
Desiree
@hereonpurpose
Apr 28 2016 00:16
BC you are asking if a contact's property is = to itself.
Hideto
@hideto0118
Apr 28 2016 00:19
@hereonpurpose Yea right but I couldnt come up with any idea for the property....thats why it == itself.
Desiree
@hereonpurpose
Apr 28 2016 00:20
@hideto0118 have you tried hasOwnProperty for it?
sinere
@sinere
Apr 28 2016 00:20

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

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

D.Mills
@millsdee74
Apr 28 2016 00:21

Challenge: Replace If Else Chains with Switch. I can't figure the code out. Can anyone help, this is what I have so far..... // Only change code below this line

switch (val) {
case "bob"
answer = "Marley";
break;
case 42:
answer = "The Answer";
break;
case 1
answer = "There is no #1";
break;
case 99
answer = "Missed me by this much!";
break;
case 7
answer = "Ate Nine";
break;
}

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

// Change this value to test
chainToSwitch(7);

Coryphaeus
@cvdeby
Apr 28 2016 00:21
@nabeelaa navigator and ajax both works asynchronously. So you need to call ajax inside navigator or navigator inside ajax.
Matthew Fricker
@mattfricker
Apr 28 2016 00:21
@sinere Please edit and format your code by wrapping it in tildes/js and closing tildes as described here:
help format
CamperBot
@camperbot
Apr 28 2016 00:21

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

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

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

:pencil: read more about code formatting on the FCC Wiki

Moisés Man
@moigithub
Apr 28 2016 00:21
@sinere if u check the contacts data above.. u will see its an Array of Object.. its not an array of arrays...
u only need 1 loop
sinere
@sinere
Apr 28 2016 00:22

@cvdeby The contacts details as follow:

i understand that if first condition fail it will return "no such contact"but my input should fulfill the first condition and proceed to the next for loop no?

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

// Change these values to test your function
lookUpProfile("Akira", "likes");
Sergiusz
@Wetlize
Apr 28 2016 00:23
@sinere you don't need the second loop here
Moisés Man
@moigithub
Apr 28 2016 00:23
@sinere to check IF the OBJECT have a property..u can use hasOwnProperty method
sinere
@sinere
Apr 28 2016 00:23
@moigithub thanks i'll try with one for loop again
CamperBot
@camperbot
Apr 28 2016 00:23
sinere sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 1023 | @moigithub | http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Apr 28 2016 00:25
@sinere also ur return "no contact" shouldnt be there.. else it will only check 1 or 2 contacts.. n say "no such contact"... u need to check ALL the contacts first
Matthew Fricker
@mattfricker
Apr 28 2016 00:26
This message was deleted
Hideto
@hideto0118
Apr 28 2016 00:26
@hereonpurpose No I haven't. I dont remember how hasOwnProperty works. I'll check it.
D.Mills
@millsdee74
Apr 28 2016 00:27

Challenge: Replace If Else Chains with Switch. I can't figure the code out. Can anyone help, this is what I have so far..... // Only change code below this line

switch (val) {
case "bob"
answer = "Marley";
break;
case 42:
answer = "The Answer";
break;
case 1
answer = "There is no #1";
break;
case 99
answer = "Missed me by this much!";
break;
case 7
answer = "Ate Nine";
break;
}

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

// Change this value to test
chainToSwitch(7);

Capzlock
@Capzlock
Apr 28 2016 00:27
Why isnt this working?
function testLogicalAnd(val) {
  // Only change code below this line

  if (val >= 25 && <= 50) {

      return "Yes";
    }


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

// Change this value to test
testLogicalAnd(10);
Coryphaeus
@cvdeby
Apr 28 2016 00:27
@sinere I cannot find, why it returns 'No such contact' :smile: But actually you have mistakes in solution's logic.
Moisés Man
@moigithub
Apr 28 2016 00:28

@millsdee74

var a =1;  //some values it might have
if (a===1) {  answer = "hello"  }
else if (a===2) {  answer = "world"  }

with switch

switch(a){
     case 1:
            answer = "hello";
           break;
     case 2:
             answer="world";
           break;
}
Coryphaeus
@cvdeby
Apr 28 2016 00:28
@Capzlock first condition is wrong
Capzlock
@Capzlock
Apr 28 2016 00:28
Oops nevermind. Didn't realize I needed to add val after the &&
Coryphaeus
@cvdeby
Apr 28 2016 00:29
@Capzlock (val >= 25 && val <= 50) you forgot to write second val
Capzlock
@Capzlock
Apr 28 2016 00:29
@cvdeby ty
D.Mills
@millsdee74
Apr 28 2016 00:30
@moigithub OK, let me try that format
sinere
@sinere
Apr 28 2016 00:31

hi guys i tried again with one for loop, this time the input Akira, likes do return the array of her likes, but that only works for Akira.

When i try Sherlock, likes it return no such property ;( confusing...

//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 && contacts[i][prop].hasOwnProperty)
  {
    return contacts[i][prop];
  }
  else return "No such property";    
}
return "No such contact";
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Coryphaeus
@cvdeby
Apr 28 2016 00:32
@sinere You have one more mistake in logic
Matthew Fricker
@mattfricker
Apr 28 2016 00:32
@sinere You use it by doing myObject.hasOwnProperty(myProp);
Coryphaeus
@cvdeby
Apr 28 2016 00:33
@sinere You need to separate your if condition by 2 conditions.
Matthew Fricker
@mattfricker
Apr 28 2016 00:34
@sinere And also what @cvdeby said
D.Mills
@millsdee74
Apr 28 2016 00:34
@moigithub looks like I already used that format, can yo look at the code and let me know where I went wrong?
Aparna
@Aparna-S
Apr 28 2016 00:34
hey guys.. i don't get "Word Blanks" concept

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

Desiree
@hereonpurpose
Apr 28 2016 00:35
@hideto0118 make sure you go thru the above chat too. Sinere is getting lots of tips/advice for that same problem
Coryphaeus
@cvdeby
Apr 28 2016 00:36
@sinere Try to read more about objects, because in future you'll use them everywhere. And understanding of how are they work will not the most difficult part :smile:
Desiree
@hereonpurpose
Apr 28 2016 00:36
@hideto0118 I have to go for now unfortunately.
Moisés Man
@moigithub
Apr 28 2016 00:37
@millsdee74 missing some : (semicolon)
after case value
Chris Lacaille
@ChrisL108
Apr 28 2016 00:37
How would i declare the current window.innerHeight inside a function. Can i only declare it in global scope?
Kevin Kindorf
@kkindorf
Apr 28 2016 00:38
Hey all is it me or is slasher flick incredibly easy compared to some of the other basic algorithm challenges? Did anybody else have an easy time working through that problem after chunky monkey?
Diego Mayer
@Chrono79
Apr 28 2016 00:38
@Aparna-S read the link Mad Libs first
You have to make a sentence that makes sense using the words they pass to the function and spaces and words you put to accomplish that
Matthew Fricker
@mattfricker
Apr 28 2016 00:39
@kkindorf I recall that some of them were less complicated in various orders
Hideto
@hideto0118
Apr 28 2016 00:39
@hereonpurpose Im still struggling but Im getting closer. Thank you for your help!
CamperBot
@camperbot
Apr 28 2016 00:39
hideto0118 sends brownie points to @hereonpurpose :sparkles: :thumbsup: :sparkles:
:star: 261 | @hereonpurpose | http://www.freecodecamp.com/hereonpurpose
Matthew Fricker
@mattfricker
Apr 28 2016 00:40
@hideto0118 Anything in particular that I can help with?
sinere
@sinere
Apr 28 2016 00:41
@cvdeby @mattfricker thanks so much for helping, will definitely read up more about objects
CamperBot
@camperbot
Apr 28 2016 00:41
sinere sends brownie points to @cvdeby and @mattfricker :sparkles: :thumbsup: :sparkles:
:star: 380 | @cvdeby | http://www.freecodecamp.com/cvdeby
:star: 135 | @mattfricker | http://www.freecodecamp.com/mattfricker
D.Mills
@millsdee74
Apr 28 2016 00:41
@moigithub still saying SYNTAX ERROR
Coryphaeus
@cvdeby
Apr 28 2016 00:41
@sinere You don't have problem with objects for now, it is just logic mistake)
Kevin Kindorf
@kkindorf
Apr 28 2016 00:41
@mattfricker I had to bring it up because I was surprised I was able to figure out the solution so quickly. Chunky Monkey took me a while to work through and even then I needed to search around on google to clarify things.
sinere
@sinere
Apr 28 2016 00:41
i have tried again with if conditions separated to get property and contact but now it falls back to 'no such contact'
````
Aparna
@Aparna-S
Apr 28 2016 00:42
@Chrono79 yeah i went through that game ..but how are we supposed to work on this?
sinere
@sinere
Apr 28 2016 00:42
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.hasOwnProperty(prop))
    {
      return contacts[i][prop];
    }
    else return "No such property";    
  }
  else return "No such contact";
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Sherlock", "likes");
Sherlock is in the contact list but it returned 'no such contact''
D.Mills
@millsdee74
Apr 28 2016 00:42
@moigithub got it, finally. thanks
CamperBot
@camperbot
Apr 28 2016 00:42
millsdee74 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 1024 | @moigithub | http://www.freecodecamp.com/moigithub
Matthew Fricker
@mattfricker
Apr 28 2016 00:44
@sinere With the hasOwnProperty, you want to check contacts[i] not the contacts array itself
Coryphaeus
@cvdeby
Apr 28 2016 00:44
@sinere And also you have problem with the return
Diego Mayer
@Chrono79
Apr 28 2016 00:45

@Aparna-S you can make a bigger string with smaller strings concatenating them like this:

big = small1 + " " + small2 + " someword " + small3;

In the challenge small1, etc, would be myNoun, myVerb, etc. and big, in my example would be result

Coryphaeus
@cvdeby
Apr 28 2016 00:45
@sinere Because you're checking just first contact now.
Matthew Fricker
@mattfricker
Apr 28 2016 00:46
goodnight all
Coryphaeus
@cvdeby
Apr 28 2016 00:46
@mattfricker Good Night)
@Chrono79 Hi)
Diego Mayer
@Chrono79
Apr 28 2016 00:47
@cvdeby Hi
Coryphaeus
@cvdeby
Apr 28 2016 00:48
@Chrono79 I learned regex - it was like in hell before - http://regexone.com/ )
Diego Mayer
@Chrono79
Apr 28 2016 00:50
@cvdeby good, I'll be afk for a while
Aparna
@Aparna-S
Apr 28 2016 00:50
@Chrono79 ok..what ever i code here, it doesn't run :(
Diego Mayer
@Chrono79
Apr 28 2016 00:54
@Aparna-S paste what you have here
Norvin Burrus
@ndburrus
Apr 28 2016 00:55
@sinere i think the logic in the following statement needs adjusting: if(contacts.hasOwnProperty(prop)) => i.e. which contacts item are you checking?
Aparna
@Aparna-S
Apr 28 2016 00:56

@Chrono79 function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

result = myNoun + "is" + myAdjective + " to " + myVerb + "that" + myAdverb ;
// Your code above this line
return result;
}

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

Moisés Man
@moigithub
Apr 28 2016 00:57
@Aparna-S missingsome ??
dogisbig to ranthatquickly
Diego Mayer
@Chrono79
Apr 28 2016 00:57
@Aparna-S you are missing some spaces between words
try changing "is" to " is " and so on
it doesn't make too much sense, but it's a start
try to get this if you can: My big dog ran very quickly
Aparna
@Aparna-S
Apr 28 2016 01:00
got it..it works now! :)
Norvin Burrus
@ndburrus
Apr 28 2016 01:03
Kudos to you @Aparna-S :smile:
Diego Mayer
@Chrono79
Apr 28 2016 01:03
@Aparna-S Good
Aparna
@Aparna-S
Apr 28 2016 01:05
thank you guys!! :smile:
Diego Mayer
@Chrono79
Apr 28 2016 01:05
no problem
Chuck Redd
@cred3
Apr 28 2016 01:13

Hi , I am unable to pass this challenge with switch statement. I used the below code but I don't know what's the problem:function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val){
case 1:
answer =" alpha";
break;
case 2:
answer = " beta";
break;
case 3:
answer = " gamma";
break;

   case 4:
   answer = " delta";
  break;

}

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

// Change this value to test
caseInSwitch(2);

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val){
case 1:
answer =" alpha";
break;
case 2:
answer = " beta";
break;
case 3:
answer = " gamma";
break;

   case 4:
   answer = " delta";
  break;     

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

// Change this value to test
caseInSwitch(2);

Diego Mayer
@Chrono79
Apr 28 2016 01:15

@cred3 delete space after the first quote

"alpha", not " alpha"

and the same with the others

Chuck Redd
@cred3
Apr 28 2016 01:16
@Chrono79 Thank you!
CamperBot
@camperbot
Apr 28 2016 01:16
cred3 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 531 | @chrono79 | http://www.freecodecamp.com/chrono79
D.Mills
@millsdee74
Apr 28 2016 01:16
@bugron thanks for the tip with Return Early Pattern for Functions
CamperBot
@camperbot
Apr 28 2016 01:16
millsdee74 sends brownie points to @bugron :sparkles: :thumbsup: :sparkles:
:star: 1463 | @bugron | http://www.freecodecamp.com/bugron
Randall Wyatt
@RandallWy
Apr 28 2016 01:19
function sequentialSizes(val) {
  var answer = "";
  // Only change code below this line
  switch(val) {
    case 1:
    case 2:
    case 3:
      result = "Low";
      break;
    case 4:
    case 5:
    case 6:
      result = "Mid";
      break;
    case 7:
    case 8:
    case 9:
      result = "High";
      break;
}


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

// Change this value to test
sequentialSizes(3);
CamperBot
@camperbot
Apr 28 2016 01:19
:bulb: to format code use backticks! ``` more info
Randall Wyatt
@RandallWy
Apr 28 2016 01:19
whats wrong with my code?
Diego Mayer
@Chrono79
Apr 28 2016 01:20
@RandallWy it's returning answer, not result
Norvin Burrus
@ndburrus
Apr 28 2016 01:21
@RandallWy you asked it to return answer... :smile:
Randall Wyatt
@RandallWy
Apr 28 2016 01:21
it said to change the code above that line so i was just following the rules. lol
Norvin Burrus
@ndburrus
Apr 28 2016 01:22
@RandallWy i.e.: "return answerr;"
Diego Mayer
@Chrono79
Apr 28 2016 01:22
@RandallWy you don't have to change what's returning, you have to change, inside your switch, result for answer
Norvin Burrus
@ndburrus
Apr 28 2016 01:22
@RandallWy "answer*"
bjk116
@bjk116
Apr 28 2016 01:29
I'm working on capitalizing each word in a string and I'm not sure why my code isn't working
function titleCase(str) {
  str.toLowerCase();
  var words=str.split(" ");

  for(i=0;i<words.length;i++){
    words[i].charAt(0).toUpperCase();
  }

  str=words.join(" ");

  return str;
}
Moisés Man
@moigithub
Apr 28 2016 01:30
wiki immutable @bjk116
CamperBot
@camperbot
Apr 28 2016 01:30
no wiki entry for: immutable @bjk116
Moisés Man
@moigithub
Apr 28 2016 01:30
wiki immutable
CamperBot
@camperbot
Apr 28 2016 01:30

:point_right: js immutable [wiki]

Immutable means unchangeable i.e. you can't change.

Javascript has lots of immutable types e.g. string primitive type. Try this in your console.

s = "red";
console.log(s[1]); //→ "e"
s[1] = "x";
console.log(s) //→ "red"

the s didn't change! WAT!

:pencil: read more about js immutable on the FCC Wiki

Diego Mayer
@Chrono79
Apr 28 2016 01:30
@bjk116 you have to rebuild each word as the first letter capitalized + the rest of the word letters
bjk116
@bjk116
Apr 28 2016 01:32
right duh ok I got that now
I don't get why the last two tests are failing now
Moisés Man
@moigithub
Apr 28 2016 01:32
problably cuz tolowercase ??
bjk116
@bjk116
Apr 28 2016 01:32
  for(i=0;i<words.length;i++){
    words[i]=words[i].charAt(0).toUpperCase()+words[i].slice(1);
  }

  str=words.join(" ");

  return str;
well i just turn the whole string to lower case at first then go word by word capitalizing
Moisés Man
@moigithub
Apr 28 2016 01:33
where ? u turn the whole string to lower ?
bjk116
@bjk116
Apr 28 2016 01:33
I don't get why "sHoRt AnD sToUt" doens't pass the test
function titleCase(str) {
  str.toLowerCase();
  var words=str.split(" ");

  for(i=0;i<words.length;i++){
    words[i]=words[i].charAt(0).toUpperCase()+words[i].slice(1);
  }

  str=words.join(" ");

  return str;
}
Moisés Man
@moigithub
Apr 28 2016 01:34
tolowercase return a new string
bjk116
@bjk116
Apr 28 2016 01:34
thats the whole func
Moisés Man
@moigithub
Apr 28 2016 01:34
it do not modify the original
Diego Mayer
@Chrono79
Apr 28 2016 01:34
@bjk116 str = str.toLowerCase();
bjk116
@bjk116
Apr 28 2016 01:35
oy vey
thanks @Chrono79 and @moigithub
CamperBot
@camperbot
Apr 28 2016 01:35
bjk116 sends brownie points to @chrono79 and @moigithub :sparkles: :thumbsup: :sparkles:
:star: 1027 | @moigithub | http://www.freecodecamp.com/moigithub
:star: 532 | @chrono79 | http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Apr 28 2016 01:35
or var words=str.toLowerCase().split(" ");
bjk116
@bjk116
Apr 28 2016 01:36
true to save a line. thanks I got it now!
Chuck Redd
@cred3
Apr 28 2016 01:36
Nothing really showing up, the code just can't pass. I don't know why
Diego Mayer
@Chrono79
Apr 28 2016 01:36
@cred3 what are you talking about?
Reza Jafar
@Reza7865
Apr 28 2016 01:39
hey guys
Chuck Redd
@cred3
Apr 28 2016 01:39
this is what showing us near stuff - " Expected an assignment or function call but instead saw an expression." this error is seen between the string "stuff"
Reza Jafar
@Reza7865
Apr 28 2016 01:40
could someone help me with a JS Challenge
Norvin Burrus
@ndburrus
Apr 28 2016 01:40
@Reza7865 ....which one?
Diego Mayer
@Chrono79
Apr 28 2016 01:40
@cred3 paste full code
Reza Jafar
@Reza7865
Apr 28 2016 01:41
Screen Shot 2016-04-27 at 6.39.28 PM
oops
Chuck Redd
@cred3
Apr 28 2016 01:41

@Chrono79 function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch(val){
case 1:
answer = "apple";
break;
case 2:
answer = "bird";
break;
case 3:
answer = "cat";
break;

default :  "stuff";

}

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

// Change this value to test
switchOfStuff(4);

Reza Jafar
@Reza7865
Apr 28 2016 01:42
@ndburrus Counting Cards Challenge
Norvin Burrus
@ndburrus
Apr 28 2016 01:42
@cred3 which challenge is that?
@Reza7865 can u paste what you've got?
bjk116
@bjk116
Apr 28 2016 01:42
Is there a way to see what your code is actually evaluating to?
Chuck Redd
@cred3
Apr 28 2016 01:43
@ndburrus adding default option in switch statement
Diego Mayer
@Chrono79
Apr 28 2016 01:43
@cred3 try
default: 
answer = "stuff";
Reza Jafar
@Reza7865
Apr 28 2016 01:43

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 = count + 1;
break;
case 7:
case 8:
case 9:
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count = count - 1;
break;
}

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

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

Screen Shot 2016-04-27 at 6.39.28 PM.png
@Reza7865 you're not evaluating count value, only returning it
Norvin Burrus
@ndburrus
Apr 28 2016 01:45
@Reza7865 ...you need a statement evaluating where the count is, and what action to return...
Chuck Redd
@cred3
Apr 28 2016 01:45
@Chrono79 I tried that already still not working.
Stanley
@stanleyyylau
Apr 28 2016 01:45
can anyone give me a hint on "Exact Change"
bjk116
@bjk116
Apr 28 2016 01:45
great link thanks @Chrono79
CamperBot
@camperbot
Apr 28 2016 01:45
bjk116 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: bjk116 already gave chrono79 points
Stanley
@stanleyyylau
Apr 28 2016 01:45
after calculation of the change, how can I show them in bills or coins values from high to low
Diego Mayer
@Chrono79
Apr 28 2016 01:46
@cred3 the values should be letters, not numbers
Stanley
@stanleyyylau
Apr 28 2016 01:46
i just need a hint, i have no clue how it's done
Diego Mayer
@Chrono79
Apr 28 2016 01:46
@cred3
Instructions
Write a switch statement to set answer for the following conditions:
"a" - "apple"
"b" - "bird"
"c" - "cat"
default - "stuff"
Randall Wyatt
@RandallWy
Apr 28 2016 01:46
// Example
function ourFunction(ourMin, ourMax) {

  return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
}

ourFunction(1, 9);

// Only change code below this line.

function randomRange (myMin, myMax) {

  return Math.floor(Math.random() * (myMax-myMin + 1)) + min; // Change this line

}

// Change these values to test your function
var myRandom = randomRange(5, 15);
i cant seem to figure out how to define the max/ min. Is that a normal definition?
Boris
@boris-in-london
Apr 28 2016 01:46

@stanleyyylau
Hint: 1

Is easier to handle if you will have to close the register or if you will not have enough money to complete the transaction if you know beforehand how much money is on your register. For this it would be recommended to have a function get the information assigned to a variable.

Chuck Redd
@cred3
Apr 28 2016 01:47
@Chrono79 when I put letter this show up "ReferenceError d is not defined"
Norvin Burrus
@ndburrus
Apr 28 2016 01:47
@chuck why aren't you using letters: a, b, & c for the cases?
@RandallWy which challenge is that?
Diego Mayer
@Chrono79
Apr 28 2016 01:48
@cred3 because you are putting a and you should use "a", and so on
a, b, c are var names, "a", "b", "c" are strings
Randall Wyatt
@RandallWy
Apr 28 2016 01:48
Generate Random Whole Numbers within a Range
Norvin Burrus
@ndburrus
Apr 28 2016 01:49
@RandallWy use the variable names given in the challenge!
Randall Wyatt
@RandallWy
Apr 28 2016 01:50
for the min= myMin... correct?
Chuck Redd
@cred3
Apr 28 2016 01:50
@Chrono79 I just did. Still the same
Diego Mayer
@Chrono79
Apr 28 2016 01:51
@RandallWy your param names aren't the same names inside your function
@cred3 paste your code again
Randall Wyatt
@RandallWy
Apr 28 2016 01:52
// Example
function ourFunction(ourMin, ourMax) {

  return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
}

ourFunction(1, 9);

// Only change code below this line.

function randomRange (myMin, myMax) {

  return Math.floor(Math.random() * (myMax-myMin + 1)) + min; // Change this line

}

// Change these values to test your function
var myRandom = randomRange(5, 15);
am I still off?
Norvin Burrus
@ndburrus
Apr 28 2016 01:52
@cred3
js
<function switchOfStuff(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case "a":
      answer = "apple";
      break;
    case "b":
      answer = "bird";
      break;
    case "c":
      answer = "cat";  
      break;
    default:
      answer = "stuff";
  } 


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

// Change this value to test
switchOfStuff(1);>
Diego Mayer
@Chrono79
Apr 28 2016 01:52
@RandallWy change the last min
Randall Wyatt
@RandallWy
Apr 28 2016 01:53
ok. thanks guys!! I am almost finished with javascript.
Stanley
@stanleyyylau
Apr 28 2016 01:53
@boris-in-london great, thanks, I'll start by identifying these two situations where the register have to closed or not enough funds, and see what will happen
CamperBot
@camperbot
Apr 28 2016 01:53
stanleyyylau sends brownie points to @boris-in-london :sparkles: :thumbsup: :sparkles:
:star: 331 | @boris-in-london | http://www.freecodecamp.com/boris-in-london
Chuck Redd
@cred3
Apr 28 2016 01:53
@ndburrus Thanks.
CamperBot
@camperbot
Apr 28 2016 01:53
cred3 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star: 262 | @ndburrus | http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Apr 28 2016 01:53
@RandallWy
js
<  return Math.floor(Math.random() * (myMax - myMin + 1)) + myMin; // Change this line>
@RandallWy check the above statement....
@cred3 Kudos to you Chuck!! :smile:
Boris
@boris-in-london
Apr 28 2016 01:55

@stanleyyylau
Hint: 2

Life is easier when you get to know the value of each currency type in the register instead of how much money is composed of that particular currency. So be sure to watch out for that. ;)

Mike Olie
@SwiftMike
Apr 28 2016 01:57
Hey, i got a question with returning boolean values from function
all i got is function isLess(a, b) {
2
// Fix this code
3
return a === b;
4
}
5

6
// Change these values to test
7
isLess(15, 10);
8
function isLess(a, b) {
2
// Fix this code
3
return a === b;
4
}
5

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

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

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

my bad
Diego Mayer
@Chrono79
Apr 28 2016 01:57
@FreshSteak return a === b; would be ok if the function is called isEqual
You have to use another comparison operator
Mike Olie
@SwiftMike
Apr 28 2016 01:58
@Chrono79 facts.. so what do i do? i don't know how to work that out
which one?
Norvin Burrus
@ndburrus
Apr 28 2016 01:58
@FreshSteak ok, wow, i think you're overthinking this... just compare a to b...
Diego Mayer
@Chrono79
Apr 28 2016 01:58
<
Mike Olie
@SwiftMike
Apr 28 2016 01:59
i am overthinking this lol I'm here so y'all can help me chiill
Norvin Burrus
@ndburrus
Apr 28 2016 02:00
@FreshSteak
js
<function isLess(a, b) {
  // Fix this code
  return (a < b);
}

// Change these values to test
isLess(10, 15);>
@FreshSteak ....simply one short line of code.... :+1:
Reza Jafar
@Reza7865
Apr 28 2016 02:02
@Chrono79 @ndburrus The count works but how can I get it to print "Hold" or "Bet"
Screen Shot 2016-04-27 at 6.39.28 PM.png
Diego Mayer
@Chrono79
Apr 28 2016 02:04
@Reza7865 make an if/else evaluating count
Norvin Burrus
@ndburrus
Apr 28 2016 02:04
@Reza7865 you might consider a return statement
Mike Olie
@SwiftMike
Apr 28 2016 02:04
lmao @ndburrus
thanks
Norvin Burrus
@ndburrus
Apr 28 2016 02:05
@FreshSteak ...that post looked painful.... :+1:
@FreshSteak does t make sense?
@FreshSteak ...does it make sense?
@Reza7865 how are you doing?
Rob
@PGFracing
Apr 28 2016 02:06
function convertToF(celsius) {
  // Only change code below this line

  var fahrenheit = 9/5 + 32;
  // Only change code above this line
  return fahrenheit;
}

// Change the inputs below to test your code
convertToF(30);
convertToF(-30);
Diego Mayer
@Chrono79
Apr 28 2016 02:07
@PGFracing you're not using celsius in your formula
Reza Jafar
@Reza7865
Apr 28 2016 02:07
@ndburrus trying to think of a solution, dont seem to be getting anywhere
Norvin Burrus
@ndburrus
Apr 28 2016 02:07
@reza...just a moment
Diego Mayer
@Chrono79
Apr 28 2016 02:07
help Counting Cards
CamperBot
@camperbot
Apr 28 2016 02:07

:point_right: checkpoint counting cards [wiki]

Checkpoint: Counting Cards

About Blackjack

In the casino game Blackjack, a player can gain an advantage over the house by keeping track of the relative number of high and low cards remaining in the deck. This is called Card Counting.

Having more high cards remaining in the deck favors the player. Each card is assigned a value according to the table below. When the count is positive, the player should bet high. When the count is zero or negative, the player should bet low.

Value Cards
+1 2, 3, 4, 5, 6
0 7, 8, 9
-1 10, 'J', 'Q', 'K','A'

Instructions

You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.

Example Output:

:pencil: read more about checkpoint counting cards on the FCC Wiki

Norvin Burrus
@ndburrus
Apr 28 2016 02:08
@PGFracing you need to use celsius in your formula....
Rob
@PGFracing
Apr 28 2016 02:08
got it thank you @ndburrus
CamperBot
@camperbot
Apr 28 2016 02:08
pgfracing sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star: 263 | @ndburrus | http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Apr 28 2016 02:08
@PGFracing anytime, best to you! :+1:
Reza Jafar
@Reza7865
Apr 28 2016 02:08
DAMNIT i was so close! lol thanks @ndburrus and @Chrono79
CamperBot
@camperbot
Apr 28 2016 02:08
reza7865 sends brownie points to @ndburrus and @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 264 | @ndburrus | http://www.freecodecamp.com/ndburrus
:star: 533 | @chrono79 | http://www.freecodecamp.com/chrono79
Norvin Burrus
@ndburrus
Apr 28 2016 02:09
@Reza7865 ...did you try a return statement?
Reza Jafar
@Reza7865
Apr 28 2016 02:09
yeah I got it now :)
Diego Mayer
@Chrono79
Apr 28 2016 02:09
@ndburrus I think he did
Norvin Burrus
@ndburrus
Apr 28 2016 02:09
@Reza7865 id on fire!! :fire:
@Reza7865 is*
Reza Jafar
@Reza7865
Apr 28 2016 02:10
I didnt think of putting the return statement in a if/else evaluation
Norvin Burrus
@ndburrus
Apr 28 2016 02:10
@Reza7865 ...it came to you, kudos!!
...be back in a few minutes...
Rob
@PGFracing
Apr 28 2016 02:13
var myStr = "I am a \"double quoted\" string inside \"double quotes"\";
not working appears the same as the example from what I can tell
Diego Mayer
@Chrono79
Apr 28 2016 02:14
@PGFracing challenge name?
Rob
@PGFracing
Apr 28 2016 02:14
Escaping Literal Quotes in Strings
Diego Mayer
@Chrono79
Apr 28 2016 02:15
@PGFracing your last escape is wrong
var myStr = "I am a \"double quoted\" string inside \"double quotes\"";
Rob
@PGFracing
Apr 28 2016 02:16
that was it the example shows the backslash on the other side of the quote though
Orsini
@jrorsini
Apr 28 2016 02:16

Hi guys! I'm in trouble with my code regarding the Chunky Monkey. and I don't know how to move ahead from here

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var arrGrp = [];
  var arrSubGrp = [];
  for(var i = 0; i <= ((arr.length/size+1)); i+=size) {
    arrSubGrp = arr.slice(i,i+size);
    arrGrp.push(arrSubGrp);
  }
  if(arr.length % size !== 0){

  }
  return arrGrp;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4);

Can someone help me out on what I should think about next?

Diego Mayer
@Chrono79
Apr 28 2016 02:19
@jrorsini why i <= ((arr.length/size+1))
why 2 arrays? <- this one, do as you wish
Orsini
@jrorsini
Apr 28 2016 02:20
@Chrono79 because I've got this i+=size in my iterating process, I must calculate how many times this would fit in my array.
My concern
Diego Mayer
@Chrono79
Apr 28 2016 02:21
@jrorsini I mean why <= and not < only
Orsini
@jrorsini
Apr 28 2016 02:21
Oh
Because if I don't put "=" it won't add the before last sub group array
As an example
Oh wait
No actually you're right
Like I thought this would return me [["a", "b"], instead of [["a", "b"], ["c", "d"]].
But it actually works without it
@Chrono79 thanks for the notice
CamperBot
@camperbot
Apr 28 2016 02:23
jrorsini sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 534 | @chrono79 | http://www.freecodecamp.com/chrono79
Norvin Burrus
@ndburrus
Apr 28 2016 02:25
@PGFracing I think your last "\" is in the wrong position...
Rob
@PGFracing
Apr 28 2016 02:25
yep you said that got that one squared away :)
Diego Mayer
@Chrono79
Apr 28 2016 02:26
@ndburrus that's what I said, but I suspect I'm the invisible man now :(
Norvin Burrus
@ndburrus
Apr 28 2016 02:26
@PGFracing can u post again?
@Chrono79 ...there is a lot of chatter... :smile:
@PGFracing I think you have an extra "
Diego Mayer
@Chrono79
Apr 28 2016 02:28
@ndburrus no, the " count is ok
And I suspect he passed that challenge now
Norvin Burrus
@ndburrus
Apr 28 2016 02:29
@Chrono79 which challenge is this again?
Eric Murta
@murtinha
Apr 28 2016 02:29
Guys why my CE bottom not working? I need it do delete the last number of the array...
http://codepen.io/murtinha/pen/vGzvwY?editors=0010
Diego Mayer
@Chrono79
Apr 28 2016 02:29
Escaping Literal Quotes in Strings
Norvin Burrus
@ndburrus
Apr 28 2016 02:31

@PGFracing Is this what you have now?

js
<

var myStr = "I am a \"double quoted\" string inside \"double quotes"\";
>
```

Rob
@PGFracing
Apr 28 2016 02:32
not sure got the green so moved on about four things past that now, just moved the back slash inside the quote which is different then the example
Norvin Burrus
@ndburrus
Apr 28 2016 02:32
js
<
var myStr = "I am a \"double quoted\" string inside \"double quotes"\";>
```
@rob...ok
@PGFracing ...ok...
Diego Mayer
@Chrono79
Apr 28 2016 02:37
@murtinha first thing, it's $('.clean1') you forgot the dot
Eric Murta
@murtinha
Apr 28 2016 02:37
@Chrono79 Yeah, changed that but there are more wrong things..
Diego Mayer
@Chrono79
Apr 28 2016 02:37
@murtinha yes, it's join("") and if you convert separa to string, later you cant push more numbers to it
Eric Murta
@murtinha
Apr 28 2016 02:38
@Chrono79 also changed that
actually that one
Suren VB
@surenz298
Apr 28 2016 02:39
Hi - I am on my personal portfolio zipline - I have completed the HTML and CSS part of it- but I am just not sure how to go about the js part of it - would appreciate some pointers
Norvin Burrus
@ndburrus
Apr 28 2016 02:41
@PGFracing I think the example code was correct... I don't see an error....
js
<var sampleStr = "Alan said, \"Peter is learning JavaScript\".";>
Diego Mayer
@Chrono79
Apr 28 2016 02:41
@murtinha you are mixing things there
do a console.log before applying pop and join, you'll see separa is not an array
Alex Rose
@thelyricalrose
Apr 28 2016 02:41
@surenz298 You don't have to use JS in your first portfolio
What are you trying to do with it?
Eric Murta
@murtinha
Apr 28 2016 02:42
@Chrono79 like what?
Suren VB
@surenz298
Apr 28 2016 02:42
@murtinha - I am trying to make the hamburger menu - show up the actual nav header
when clicked
Alex Rose
@thelyricalrose
Apr 28 2016 02:44
@surenz298 I don't think you need javascript for that
let me find the resources I used for that
Suren VB
@surenz298
Apr 28 2016 02:45
Would really appreciate that @thelyricalrose
Diego Mayer
@Chrono79
Apr 28 2016 02:45

@murtinha

// Numeros
    $('.numb').on("click",function(){     
numbers=$(this).data('number');     $('#result').val($('#result').val()+numbers);
separa.push(numbers);    

    });

and fix join, it doesn't modify your array

Alex Rose
@thelyricalrose
Apr 28 2016 02:46
@thelyricalrose Heres the method I used https://www.youtube.com/watch?v=qpWlaOeGZ_4
@surenz298
whoops, wrong name
Diego Mayer
@Chrono79
Apr 28 2016 02:46
@murtinha
    //Botão CE
    $('.clean1').on("click",function(){
      separa.pop();
         $("#result").val(separa.join(""));
                   });
Alex Rose
@thelyricalrose
Apr 28 2016 02:47
But the video will probably explain better than I can with text
Stanley
@stanleyyylau
Apr 28 2016 02:47
@boris-in-london ````
function checkCashRegister(price, cash, cid) {
  // Here is your change, ma'am.
  var change;  
  change=cash-price;

  //let's get the total amount in register
  var totalCid=getTotalAmount(cid);

  //first two if identifies whether the account will have to close or having insufficient funds
  if(change==totalCid){
    return "Closed";
  }else if(change>totalCid){
    return "Insufficient Funds";
  }

}//end function



function getTotalAmount(cid){
  var totalAmount=0;
  for(var i=0;i<cid.length;i++){
    totalAmount+=cid[i][1];
  }
  return totalAmount;
}


// Example cash-in-drawer array:
// [["PENNY", 1.01],
// ["NICKEL", 2.05],
// ["DIME", 3.10],
// ["QUARTER", 4.25],
// ["ONE", 90.00],
// ["FIVE", 55.00],
// ["TEN", 20.00],
// ["TWENTY", 60.00],
// ["ONE HUNDRED", 100.00]]

checkCashRegister(19.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
Suren VB
@surenz298
Apr 28 2016 02:47
Thnx @thelyricalrose - will give it a try
CamperBot
@camperbot
Apr 28 2016 02:47
:star: 297 | @thelyricalrose | http://www.freecodecamp.com/thelyricalrose
surenz298 sends brownie points to @thelyricalrose :sparkles: :thumbsup: :sparkles:
Eric Murta
@murtinha
Apr 28 2016 02:48
@Chrono79 ohhh shit man, I forgot the first separa= ... thanks dude!
CamperBot
@camperbot
Apr 28 2016 02:48
murtinha sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 535 | @chrono79 | http://www.freecodecamp.com/chrono79
Stanley
@stanleyyylau
Apr 28 2016 02:48
now writing the hint2
Alex Rose
@thelyricalrose
Apr 28 2016 02:48
@surenz298 holler if you have more questions
CamperBot
@camperbot
Apr 28 2016 02:48
holler back!
Suren VB
@surenz298
Apr 28 2016 02:48
Sure @thelyricalrose
Drew Stonebraker
@drstonebraker
Apr 28 2016 02:49

on challenge 272: Remove all elements from the initial argument (an array) that are of the same value as subsequent optional arguments.

My initial code didn't work:

function destroyer(arr) {
  // Remove all the values

  function notArg(val) {
    return val !== arguments[i]; 
  }

  for (i=1; i < arguments.length; i++) {
    arr = arr.filter(notArg);
  }
  console.log(arr);
  return arr;
}

but all I had to do to get it to work was add

var argsArr = Array.from(arguments);

and use my new argsArr array instead of arguments. I understand (from the MDN page on the arguments object) that arguments is not a true array, but the page says it is array-like, has a .length property, and the values can be referred to using array bracket notation, so I'm wondering why my initial code didn't work. is it simply that the .filter() method isn't available to the arguments object?

Bobby McDonald
@BobbyMcWho
Apr 28 2016 02:50
Can someone take a look at this and guide me towards why this isn't working like intended?
oh wait
Diego Mayer
@Chrono79
Apr 28 2016 02:51
@Stoney229 inside your inner function arguments is not the same
each function has its own arguments
SuryaKavutarapu
@SuryaKavutarapu
Apr 28 2016 02:51
var myStr = " \ \t \t \r \n "; // Change this line
guys I'm stuck over here in question no 155. any help??
Diego Mayer
@Chrono79
Apr 28 2016 02:52
@SuryaKavutarapu missing a \ you have to escape backlash
EricOber
@EricOber
Apr 28 2016 02:53
hello can someone help me? with my code
// 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");
it wont work
SuryaKavutarapu
@SuryaKavutarapu
Apr 28 2016 02:53
var myStr = " \ \ \t \t \r \n "; nothing works still error
Diego Mayer
@Chrono79
Apr 28 2016 02:53
@Am3ricanPaladin caps maybe?
EricOber
@EricOber
Apr 28 2016 02:54
hmmm maybe lets see
Drew Stonebraker
@drstonebraker
Apr 28 2016 02:54

@Chrono79 ah that makes sense thank you. (i just realized i wasn't even calling .filter on arguments anyway).

is there a more efficient way to do it than to create a new array? is there a way to access the arguments object of the parent function within notArg()?

CamperBot
@camperbot
Apr 28 2016 02:54
stoney229 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 536 | @chrono79 | http://www.freecodecamp.com/chrono79
EricOber
@EricOber
Apr 28 2016 02:55
@Chrono79 nope still not working
Kyle B.
@manbearkyle
Apr 28 2016 02:55
Hey guys, working on Record Collection checkpoint (246) and not exactly looking for final solution answer, but really wanting to just get a quick code critique on my first line to make sure I'm even close to being on the right path...
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
    if (collection[id][prop][value] !=="" && collection[id][prop] !=="tracks") {
       collection[id][prop] = "songs"; 
    }

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


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Diego Mayer
@Chrono79
Apr 28 2016 02:55
@SuryaKavutarapu var myStr = "\\ \t \t \r \n";
V Arun Kumar
@arunvkumr
Apr 28 2016 02:56
@SuryaKavutarapu there is a space between your fist \ and second \ remove it . it should be like \\ not \ \.
EricOber
@EricOber
Apr 28 2016 02:56
mine says "SyntaxError: Unexpected token {
Diego Mayer
@Chrono79
Apr 28 2016 02:56
@Am3ricanPaladin it's "alpha", "bravo", and so on
and you define an object like this:
myObj = {
...
};
EricOber
@EricOber
Apr 28 2016 02:56
with the "
SuryaKavutarapu
@SuryaKavutarapu
Apr 28 2016 02:56
thank you @arunkumrv @Chrono79
CamperBot
@camperbot
Apr 28 2016 02:56
suryakavutarapu sends brownie points to @arunkumrv and @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 526 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
:star: 537 | @chrono79 | http://www.freecodecamp.com/chrono79
EricOber
@EricOber
Apr 28 2016 02:57
// 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"
    undefined

  }

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

// Change this value to test
phoneticLookup("charlie");
still not working
V Arun Kumar
@arunvkumr
Apr 28 2016 02:58
@Am3ricanPaladin it should be var lookup = { ... not var lookup { ... you have to assign the object to Lookup.
Diego Mayer
@Chrono79
Apr 28 2016 02:58
@Am3ricanPaladin read above, one more thing, where are you setting result value?
UtkarshShukla7
@UtkarshShukla7
Apr 28 2016 02:58
@manbearkyle you are forgetting a condition and you have to use value argument
EricOber
@EricOber
Apr 28 2016 02:59
where?
96street
@96street
Apr 28 2016 03:00
How do I remove the empty array at the start of this API? http://rest.learncode.academy/api/learncode/friends
$(function() {

  var $orders = $('#orders');
  var $name = $('#name');
  var $drink = $('#drink');

  var orderTemplate = "" +
  "<li>" +
  "<p><strong>Name:</strong> {{name}}</p>" +
  "<p><strong>Drink:</strong> {{drink}}</p>" +
  "<button data-id='{{id}}' class='remove'>X</button>" +
  "</li>";

  function addOrder(order) {
      $orders.append(Mustache.render(orderTemplate, order));
  }

  $.ajax({
    type:'GET',
    url: 'http://rest.learncode.academy/api/learncode/friends',
    success: function(orders) {
      $.each(orders, function(i, order) {
            addOrder(order);
        }); 
    },
    error: function() {
      alert('Orders not loading');
    }
  });

  $('#addOrder').on('click', function() {

      var order = {
        name: $name.val(),
        drink: $drink.val(),
      };

      $.ajax({
          type: 'POST',
          url: 'http://rest.learncode.academy/api/learncode/friends',
          data: order,
          success: function(newOrder) {
              addOrder(newOrder);
          },
           error: function() {
          alert('Your order could not be posted');
        }
      });

  });


  $orders.delegate('.remove', 'click', function() {


    var $li = $(this).closest('li');
    $.ajax({
        type: 'DELETE',
        url: 'http://rest.learncode.academy/api/learncode/friends/' + $(this).attr('data-id'),
        success: function() {
          $li.remove();
        }
    });

  });



});
Diego Mayer
@Chrono79
Apr 28 2016 03:00
@arunkumrv here if you paste 2 backslashes without setting it as code, you only see one, so that's why he typed it like that
96street
@96street
Apr 28 2016 03:01
I've just made this small ajax program on mustache.js but not sure how to remove the empty array http://codepen.io/anon/pen/ONBNGz
SuryaKavutarapu
@SuryaKavutarapu
Apr 28 2016 03:01
guys, How do you write that code in editor mode in chat box.?
Diego Mayer
@Chrono79
Apr 28 2016 03:01
This message was deleted
CamperBot
@camperbot
Apr 28 2016 03:01

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

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

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

:pencil: read more about code formatting on the FCC Wiki

Diego Mayer
@Chrono79
Apr 28 2016 03:01
@SuryaKavutarapu like this
SuryaKavutarapu
@SuryaKavutarapu
Apr 28 2016 03:02
thank you @Chrono79
CamperBot
@camperbot
Apr 28 2016 03:02
suryakavutarapu sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: suryakavutarapu already gave chrono79 points
Frank XC
@tenkdayz
Apr 28 2016 03:02
why isnt this working?
  $("#mastermind").click(function(){
    $(this).css("background","#fff");
  });
V Arun Kumar
@arunvkumr
Apr 28 2016 03:03
@Chrono79 Ah.. ok. i didn't notice that
EricOber
@EricOber
Apr 28 2016 03:03
thanks anyways @Chrono79 i dont really understand how to do this. I guess im hitting the learning curve right now.
CamperBot
@camperbot
Apr 28 2016 03:03
am3ricanpaladin sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 538 | @chrono79 | http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Apr 28 2016 03:03
@arunkumrv Me neither at first, the I realized it was like that
@Am3ricanPaladin
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var  lookup =  { // missing = here
    "alpha": "Adams",
    "bravo": "Boston",
    "charlie": "Chicago",
    "delta": "Denver",
    "echo": "Easy",
    "foxtrot": "Frank"   //that undefined doesn't go here


  }; // missing ;
  result = lookup[val]; // use bracket notation to use a var name as an object property name  

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

// Change this value to test
phoneticLookup("charlie");
Kyle B.
@manbearkyle
Apr 28 2016 03:06
@UtkarshShukla7 should I be writing arguments for each [id], [prop], [value] before entering the conditions?
V Arun Kumar
@arunvkumr
Apr 28 2016 03:06
@manbearkyle yes you are close.. :smile: . in if and else-if conditions you have to check for the values that are passed to the function not with the object values.updateRecords and based on those values you have to either set or update, push and delete the value.
and you are missing one if-else for delete value..
Diego Mayer
@Chrono79
Apr 28 2016 03:07
@Am3ricanPaladin review past challenges if you don't remember how to do something, it'll help you
Drew Stonebraker
@drstonebraker
Apr 28 2016 03:07
is there a way to pass the arguments object from one function into a child function?
Diego Mayer
@Chrono79
Apr 28 2016 03:08
@Stoney229 try converting it to an array first, and use that array
you could try not converting it and using a var with a different name too, don't know if it works, but you can test it
Drew Stonebraker
@drstonebraker
Apr 28 2016 03:09
okay, tyvm@
@Chrono79 thank you
CamperBot
@camperbot
Apr 28 2016 03:09
stoney229 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: stoney229 already gave chrono79 points
V Arun Kumar
@arunvkumr
Apr 28 2016 03:09
@Stoney229 assign the value of argument object to another variable and then use that variable in child function.
Norvin Burrus
@ndburrus
Apr 28 2016 03:09
@manbearkyle I think the logic of the following statement needs review
js
<collection[id][prop] = "songs"; >
UtkarshShukla7
@UtkarshShukla7
Apr 28 2016 03:10
@manbearkyle you just have to assign value instead of "songs"
Norvin Burrus
@ndburrus
Apr 28 2016 03:11
@manbearkyle ...said another way - your if/else statement/s sre being driven by value...
UtkarshShukla7
@UtkarshShukla7
Apr 28 2016 03:12
@manbearkyle and don't forget the delete condition
Norvin Burrus
@ndburrus
Apr 28 2016 03:14
@manbearkyle ...yep, and, what @UtkarshShukla7 said....
Suren VB
@surenz298
Apr 28 2016 03:14
Hi - just not sure what’s wrong with this navbar setup - it does expand the hamburger menu in mobile view
UtkarshShukla7
@UtkarshShukla7
Apr 28 2016 03:17
@surenz298 you have written
<button type="button" class="navbar-toggle" data-toggle="collape" data-target=".collapse">
see that data-toggle it should be collapse
Robin D
@goosenoose
Apr 28 2016 03:18

```function golfScore(par, strokes) {
// Only change code below this line
if (strokes >= par + 3) {
return "Go Home!";
} else if (strokes >= par + 2) {
return "Double Bogey";
} else if (strokes >= par + 1) {
return "Bogey";
} else if (strokes == par && strokes != 1) {
return "Par";
} else if (strokes == par - 1) {
return "Birdie";
} else if (strokes <= par - 2 && strokes > 1) {
return "Eagle";
} else if (strokes == 1 && par !== 0) {
return "Hole-in-one!";
} else {
return "Are you playing golf?";
}
// Only change code above this line
}

// Change these values to test
golfScore(1, 1);
``` is it better to go from biggest to smallest or smallest to biggest with problesm like this?

function golfScore(par, strokes) {
  // Only change code below this line
  if  (strokes >= par + 3) {
    return "Go Home!";
  } else if (strokes >= par + 2) {
    return "Double Bogey";
  } else if (strokes >= par + 1) {
    return "Bogey";
  } else if (strokes == par && strokes != 1) {
    return "Par";
  } else if (strokes == par - 1) {
    return "Birdie";
  } else if (strokes <= par - 2 && strokes > 1) {
    return "Eagle";
  } else if (strokes == 1 && par !== 0) {
    return "Hole-in-one!";
  } else {
    return "Are you playing golf?";
  }
    // Only change code above this line
}

// Change these values to test
golfScore(1, 1);
Dylan
@dhcodes
Apr 28 2016 03:19
@goosenoose I'm not sure it matters
Norvin Burrus
@ndburrus
Apr 28 2016 03:19
@goosenoose it's personal preference. as long as the logic is valid...
Robin D
@goosenoose
Apr 28 2016 03:19
copy, thanks. was just making sure i wasn't violating a best practice
Dylan
@dhcodes
Apr 28 2016 03:19
@goosenoose what matters with if statements is making sure that whatever you do in your if statement doesn't make a later if statement true when it shouldn't be
then order matters
Robin D
@goosenoose
Apr 28 2016 03:20
thanks @ndburrus @dhcodes
CamperBot
@camperbot
Apr 28 2016 03:20
goosenoose sends brownie points to @ndburrus and @dhcodes :sparkles: :thumbsup: :sparkles:
:star: 267 | @ndburrus | http://www.freecodecamp.com/ndburrus
:star: 697 | @dhcodes | http://www.freecodecamp.com/dhcodes
Dylan
@dhcodes
Apr 28 2016 03:20
welcome
Robin D
@goosenoose
Apr 28 2016 03:20
:)
Norvin Burrus
@ndburrus
Apr 28 2016 03:20
@goosenoose you're on fire now!! :fire:
Kyle B.
@manbearkyle
Apr 28 2016 03:20
@ndburrus @UtkarshShukla7 @arunkumrv ok here is my delete condition added. I'm really drawing blanks on assigning the values after the conditions are stated :worried:
function updateRecords(id, prop, value) {
    if (collection[id][prop][value] !=="" && collection[id][prop] !=="tracks") {
       updateRecords[id][prop] = "songs"; 
    }

    else if (collection[id][prop] == "tracks" && collection[id][prop][value] ==="") {
        upDateRecords[id][prop][value].push("songs");
    }

    else if (collection[id][prop][value] ==="") {
        delete updateRecords[id][prop];
    }


  return collection;
}
Diego Mayer
@Chrono79
Apr 28 2016 03:20
@goosenoose you have added conditions there, not needed
par and strokes will always be numeric and positive.
par will never be 0 by definition
UtkarshShukla7
@UtkarshShukla7
Apr 28 2016 03:21
@manbearkyle updateRecords[id][prop] = value;
Kyle B.
@manbearkyle
Apr 28 2016 03:21
ah that's right just recall you said that earlier :smile:
UtkarshShukla7
@UtkarshShukla7
Apr 28 2016 03:22
np
@manbearkyle and check your delete condition again
Robin D
@goosenoose
Apr 28 2016 03:23
@Chrono79 ah.. i was debugging an issue where (1,1) wasn't working. turns out it was because i didn't have a != 1 condition for "par" (strokes == par)
thanks for the catch
thanks @Chrono79
CamperBot
@camperbot
Apr 28 2016 03:24
goosenoose sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 539 | @chrono79 | http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Apr 28 2016 03:24
@goosenoose no problem
Norvin Burrus
@ndburrus
Apr 28 2016 03:24
@manbearkyle ...why is the function UpdateRecords being used within the (same) function updateRecords?
UtkarshShukla7
@UtkarshShukla7
Apr 28 2016 03:25
@ndburrus nice catch
Norvin Burrus
@ndburrus
Apr 28 2016 03:25
@manbearkyle loop within a loop within a loop.... :)
Kyle B.
@manbearkyle
Apr 28 2016 03:26
it's symbolic of how my brain is functioning at the moment :smile:
Norvin Burrus
@ndburrus
Apr 28 2016 03:26
:clap:
UtkarshShukla7
@UtkarshShukla7
Apr 28 2016 03:26
and even it has typo in someplaces @manbearkyle
Diego Mayer
@Chrono79
Apr 28 2016 03:26
@ndburrus it's an autodestructable function too with the delete statement ;)
UtkarshShukla7
@UtkarshShukla7
Apr 28 2016 03:27
you should be more careful :smile:
Dennis Niemeijer
@daniemeijer
Apr 28 2016 03:29
was on a roll until #183 stand in line, now no idea how to proceed. anyone who can help?
Norvin Burrus
@ndburrus
Apr 28 2016 03:29
@manbearkyle hmmmm.... are you sure you want to push on songs?
Diego Mayer
@Chrono79
Apr 28 2016 03:29
help stand in line
CamperBot
@camperbot
Apr 28 2016 03:29

:point_right: checkpoint stand in line [wiki]

Checkpoint: Stand In Line

About queues

In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.

Instructions

Write a function nextInLine which takes an "array" and an "item" as arguments.

Add the item onto the end of the array, then remove the first element of the array.

The nextInLine function should return the element that was removed.

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

:pencil: read more about checkpoint stand in line on the FCC Wiki

Diego Mayer
@Chrono79
Apr 28 2016 03:30
@daniemeijer I'll tell you 4 array methods, you have to use 2 of them, push, pop, shift, unshift
Norvin Burrus
@ndburrus
Apr 28 2016 03:30
@Chrono79 what have you got?
Diego Mayer
@Chrono79
Apr 28 2016 03:31
@ndburrus don't know what are you talking about
Norvin Burrus
@ndburrus
Apr 28 2016 03:31
@Chrono79 ...oh, thought you had a question...
Dennis Niemeijer
@daniemeijer
Apr 28 2016 03:32
@Chrono79 I was thinking along those lines. but so far it all was pretty easy. guess it's a step up.
Norvin Burrus
@ndburrus
Apr 28 2016 03:32
@UtkarshShukla7 i didnt see any typos.... youve got a good eye - do tell...
Diego Mayer
@Chrono79
Apr 28 2016 03:34
@daniemeijer if you come up with some code, not matters if it doesn't work, paste it and we'll see what's wrong
Dennis Niemeijer
@daniemeijer
Apr 28 2016 03:35
@Chrono79 thanks, i'll try to figure something out
CamperBot
@camperbot
Apr 28 2016 03:35
daniemeijer sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 540 | @chrono79 | http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Apr 28 2016 03:35
@daniemeijer that's the spirit ;)
V Arun Kumar
@arunvkumr
Apr 28 2016 03:36
@manbearkyle you don't have to check for values and prop of the collection object. you have to check for the values that are passed to the function. not collecton[id][prop] it should be only prop and same goes for values.
Kyle B.
@manbearkyle
Apr 28 2016 03:40
@arunkumrv more like this?
function updateRecords(id, prop, value) {
    if ([value] !=="" && [prop] !=="tracks") {
       prop = value; 
    }

    else if ([prop] == "tracks" && [value] ==="") {
        prop.value.push();
    }

    else if ([value] ==="") {
        delete [prop];
    }


  return collection;
}
Diego Mayer
@Chrono79
Apr 28 2016 03:41
@manbearkyle unwanted [] detected
Prabhat Singh
@forceawakened
Apr 28 2016 03:41

function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr.filter(function(ele){
if(ele !== false && ele !== "" && ele !== 0 && ele !== undefined && ele !== null && !isNaN(ele)){
return true;
}
return false;
});
}

why is my function for removing false values not working?

V Arun Kumar
@arunvkumr
Apr 28 2016 03:41
@manbearkyle close.. remove those [] in the if else statements and inside the conditions you need to work with collection object. so prop = value should be collection[id][prop] = value;
same goes for the else-if statements..
Prabhat Singh
@forceawakened
Apr 28 2016 03:44
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  return arr.filter(function(ele){
    if(ele !== false && ele !== "" && ele !== 0 && ele !== undefined && ele !== null && !isNaN(ele)){
      return true;
    }
    return false;
  });
}

bouncer(["a", "b", "c"]);
why is my function for removing false values not working?
Diego Mayer
@Chrono79
Apr 28 2016 03:44
@forceawakened
!isNaN(ele) <- I suspect this is the culprit
but you're overthinking your solution, instead of asking for all the false values you can use !!ele or Boolean(ele)
V Arun Kumar
@arunvkumr
Apr 28 2016 03:45
@forceawakened for which cases it's not working? and have a look at Boolean Objects.
Avi
@AviralGarg1993
Apr 28 2016 03:45

// Declare your variable here
var myGlobal=10;

function fun1() {
// Assign 5 to oopsGlobal Here
oopsGlobal = 5;
}

// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}

Norvin Burrus
@ndburrus
Apr 28 2016 03:46
@manbearkyle also, be more specific in identifying which* prop value/s you'd like to make assignments to. :)
Avi
@AviralGarg1993
Apr 28 2016 03:46
why do we not need to put var before oopsGlobal declaration inside fun1?
Prabhat Singh
@forceawakened
Apr 28 2016 03:46
@Chrono79 no it is not returning non-empty strings e.g. for ["a", "b", 5] it returns [5] only
Diego Mayer
@Chrono79
Apr 28 2016 03:48
@forceawakened have you tried isNaN("a");? it returns true
So when you use it like that it makes your condition false and it's filtered
Prabhat Singh
@forceawakened
Apr 28 2016 03:50
@Chrono79 yes you are right....so what should i do?
V Arun Kumar
@arunvkumr
Apr 28 2016 03:51
@forceawakened isNaN() is the problem.. here for "a" returns true because it is not a number and for NaN also it return true because that is also not a number. Have a look at boolean objects. that would help you out or the default if statement removes all the falsy booleans as well try working with that
Prabhat Singh
@forceawakened
Apr 28 2016 03:51
@Chrono79 got it thanks
CamperBot
@camperbot
Apr 28 2016 03:51
forceawakened sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 541 | @chrono79 | http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Apr 28 2016 03:51
no problem
it's late, see ya, and don't code if your brain is already in the bed and you're not ;) Like mine is right now
Kyle B.
@manbearkyle
Apr 28 2016 03:55
@arunkumrv @ndburrus @UtkarshShukla7 ok guys we're getting closer :smile: 2/4 results have been achieved...
function updateRecords(id, prop, value) {
    if (value !=="" && prop !=="tracks") {
       collection[id][prop] = value; 
    }

    else if (prop == "tracks" && value ==="") {
        collection[id][prop][value].push("Addicted to Love");
    }

    else if (value ==="") {
        delete collection[id][prop];
    }


  return collection;
}
UtkarshShukla7
@UtkarshShukla7
Apr 28 2016 03:55
@manbearkyle collection[id][prop].push(value);
V Arun Kumar
@arunvkumr
Apr 28 2016 03:55
@manbearkyle don't hardcode the push value. just push the value thati is passed to you by function.
UtkarshShukla7
@UtkarshShukla7
Apr 28 2016 03:58
@ndburrus the typo was in this line :smile:
   else if (collection[id][prop] == "tracks" && collection[id][prop][value] ==="") {
        upDateRecords[id][prop][value].push("songs");//updateRecords
Norvin Burrus
@ndburrus
Apr 28 2016 03:58
@manbearkyle logic check: else if (prop == "tracks" && value ==="")
bb in a few
@UtkarshShukla7 ill look at it...
UtkarshShukla7
@UtkarshShukla7
Apr 28 2016 04:00
ok
Avi
@AviralGarg1993
Apr 28 2016 04:02
how are you folks copying the code here?
Paul Borawski
@iAmNawa
Apr 28 2016 04:02
@TheAviralGarg type three backticks and then enter
V Arun Kumar
@arunvkumr
Apr 28 2016 04:02
wiki format
CamperBot
@camperbot
Apr 28 2016 04:02

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

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

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

:pencil: read more about code formatting on the FCC Wiki

Paul Borawski
@iAmNawa
Apr 28 2016 04:02
Then command enter to paste
V Arun Kumar
@arunvkumr
Apr 28 2016 04:02
:point_up: April 28, 2016 9:32 AM @TheAviralGarg
Vivienne Sales
@Natto278
Apr 28 2016 04:03
@TheAviralGarg I highlight my code, press <cntl><c>, then go to this site and click <cntl><p>.
Avi
@AviralGarg1993
Apr 28 2016 04:04
thanks
Chris Cullen
@123xylem
Apr 28 2016 04:04
help Title Case a Sentence
CamperBot
@camperbot
Apr 28 2016 04:04

:point_right: algorithm title case a sentence [wiki]

Explanation:

We have to return a sentence with camel case. This means that the first letter will always be in uppercase and the rest lowercase.

:pencil: read more about algorithm title case a sentence on the FCC Wiki

Avi
@AviralGarg1993
Apr 28 2016 04:04
// Declare your variable here
var myGlobal=10;

function fun1() {
  // Assign 5 to oopsGlobal Here
  oopsGlobal = 5;
}

// Only change code above this line
function fun2() {
  var output = "";
  if (typeof myGlobal != "undefined") {
    output += "myGlobal: " + myGlobal;
  }
  if (typeof oopsGlobal != "undefined") {
    output += " oopsGlobal: " + oopsGlobal;
  }
  console.log(output);
}
why is var not required before oopsGlobal declaration in fun1()
Kyle B.
@manbearkyle
Apr 28 2016 04:08
@ndburrus @UtkarshShukla7 @arunkumrv I completed the checkpoint! :smile: thanks guys for sticking it out with me :clap: :clap: :clap:
CamperBot
@camperbot
Apr 28 2016 04:08
manbearkyle sends brownie points to @ndburrus and @utkarshshukla7 and @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 272 | @ndburrus | http://www.freecodecamp.com/ndburrus
:star: 399 | @utkarshshukla7 | http://www.freecodecamp.com/utkarshshukla7
:star: 527 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
UtkarshShukla7
@UtkarshShukla7
Apr 28 2016 04:09
@manbearkyle np
SuryaKavutarapu
@SuryaKavutarapu
Apr 28 2016 04:10
This message was deleted
V Arun Kumar
@arunvkumr
Apr 28 2016 04:11
@TheAviralGarg when you don't declare the variable with var it becomes a global variable. which can be accessed anywhere in the code. In your code the fun1 has the oopsGlobal variable so to make it global the fun1 should be called, if you don't call it oopsGlobal will just stay undefined.
EricOber
@EricOber
Apr 28 2016 04:18
// Setup
function phoneticLookup(val) {
  var result = "";

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

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

// Change this value to test
phoneticLookup("charlie");
help?
CamperBot
@camperbot
Apr 28 2016 04:18

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

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

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Samuel Cupidon
@Zerazera
Apr 28 2016 04:19
Hi all, looking for feedback on my Pomodoro timer. http://codepen.io/Zeratul/full/aNKYZL/
Chris Cullen
@123xylem
Apr 28 2016 04:19
function titleCase(str) {
str=  str.toLowerCase();
  str = str.split(" ");
  var cap = "";
  for(i=0;i<=str.length;i++){
    cap = str[i].charAt(0).toUpperCase();
  }

return cap
  ;
}

titleCase("I'm a little tea pot");
Can someone tell me why it says .str is undefined so cant use charAt on it???
V Arun Kumar
@arunvkumr
Apr 28 2016 04:20
@Am3ricanPaladin use the val that is passed to function to get the value from object lookup. using bracket notation.
Chris Cullen
@123xylem
Apr 28 2016 04:20
TypeError: Cannot read property 'charAt' of undefined
EricOber
@EricOber
Apr 28 2016 04:20
like how?
i need to see it to understand
SuryaKavutarapu
@SuryaKavutarapu
Apr 28 2016 04:22
can anybody help
EricOber
@EricOber
Apr 28 2016 04:23
thanks @arunkumrv
CamperBot
@camperbot
Apr 28 2016 04:23
am3ricanpaladin sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 528 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Apr 28 2016 04:23
@123xylem i<=str.length index values starts from 0 to length - 1. you are checking for one extra value i.e. length which doesn't exist that's why you get undefined and Strings are immutable, you can't change one specific char in the string. however you can manupilute to get new strings or change the entire string.
Avi
@AviralGarg1993
Apr 28 2016 04:23
thanks @arunkumrv
CamperBot
@camperbot
Apr 28 2016 04:23
theaviralgarg sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 529 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Apr 28 2016 04:24
@Am3ricanPaladin you got it?
SuryaKavutarapu
@SuryaKavutarapu
Apr 28 2016 04:25
 function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  arr.shift(0);
  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
can anybody help?
Joseph
@revisualize
Apr 28 2016 04:26
@Am3ricanPaladin Did you get help with your lookup?
Norvin Burrus
@ndburrus
Apr 28 2016 04:26
@sury which challenge?
Joseph
@revisualize
Apr 28 2016 04:26
@SuryaKavutarapu Why are you modifying the array but returning the item?
V Arun Kumar
@arunvkumr
Apr 28 2016 04:28
@SuryaKavutarapu You're close... the push function looks solid. The shift() doesn't take any argument it always removes the first elem of the array. and returns the removed element. so store the value that is returned into a variable and return it or simply return it with shift function.
Norvin Burrus
@ndburrus
Apr 28 2016 04:28
@SuryaKavutarapu did u change a variable name that was given?
SuryaKavutarapu
@SuryaKavutarapu
Apr 28 2016 04:28
@ndburrus challenge no 184
EricOber
@EricOber
Apr 28 2016 04:29
@revisualize i still dont undertand
// Setup
function phoneticLookup(val) {
  var result = "";

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

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

// Change this value to test
phoneticLookup("charlie");
Joseph
@revisualize
Apr 28 2016 04:29
@Am3ricanPaladin You're not modifying result.
SuryaKavutarapu
@SuryaKavutarapu
Apr 28 2016 04:29
function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  item= arr.shift();
  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
EricOber
@EricOber
Apr 28 2016 04:30
?
Joseph
@revisualize
Apr 28 2016 04:30
@Am3ricanPaladin What is result?
EricOber
@EricOber
Apr 28 2016 04:30
Instructions
Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.
Norvin Burrus
@ndburrus
Apr 28 2016 04:30
@SuryaKavutarapu also, i believe it is desired to return the removed item, not the item given...
Joseph
@revisualize
Apr 28 2016 04:31
@Am3ricanPaladin You start with var result = ""; and you just return result; you don't DO anything with it.
@SuryaKavutarapu Are you not going to answer my question?
SuryaKavutarapu
@SuryaKavutarapu
Apr 28 2016 04:31
guys I'm done
V Arun Kumar
@arunvkumr
Apr 28 2016 04:31
@SuryaKavutarapu looks good. Any problems with the challenge?
EricOber
@EricOber
Apr 28 2016 04:31
hmm
I have these chellenges to fulfill phoneticLookup("alpha") should equal "Adams"
phoneticLookup("bravo") should equal "Boston"
phoneticLookup("charlie") should equal "Chicago"
phoneticLookup("delta") should equal "Denver"
phoneticLookup("echo") should equal "Easy"
phoneticLookup("foxtrot") should equal "Frank"
phoneticLookup("") should equal undefined
You should not use case, switch, or if statements
Joseph
@revisualize
Apr 28 2016 04:32
@Am3ricanPaladin Correct.
@Am3ricanPaladin So, you want to return result;
How do you assign something to result?
Norvin Burrus
@ndburrus
Apr 28 2016 04:32
@Am3ricanPaladin which challenge?
Joseph
@revisualize
Apr 28 2016 04:33
@Am3ricanPaladin You just need to assign a value to result
EricOber
@EricOber
Apr 28 2016 04:33
how do i assign something to result
this is the "Using Objects for Lookups" challenge
Joseph
@revisualize
Apr 28 2016 04:33

@Am3ricanPaladin Here is some test code.

var name = "";

How do I make name to be Joseph?

SuryaKavutarapu
@SuryaKavutarapu
Apr 28 2016 04:34
@revisualize thanks joseph im modifying array then I reailise the item was returning so I changed my code
CamperBot
@camperbot
Apr 28 2016 04:34
suryakavutarapu sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star: 1013 | @revisualize | http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Apr 28 2016 04:34
@SuryaKavutarapu Did you solve the challenge?
EricOber
@EricOber
Apr 28 2016 04:35
hmmm damn still confused
Joseph
@revisualize
Apr 28 2016 04:35
@Am3ricanPaladin Are you serious?
EricOber
@EricOber
Apr 28 2016 04:35
yes
Joseph
@revisualize
Apr 28 2016 04:35
@Am3ricanPaladin You don't know how to reassign a variable?
var name = "";
name = "Joseph";
EricOber
@EricOber
Apr 28 2016 04:36
its been a couple days since i picked this up again
Norvin Burrus
@ndburrus
Apr 28 2016 04:36
@Am3ricanPaladin ok, why don't you use your object (variable) to lookup the result?
SuryaKavutarapu
@SuryaKavutarapu
Apr 28 2016 04:36
@arunkumrv @revisualize @ndburrus thank you guys for your help @revisualize yes I completed my challenge
CamperBot
@camperbot
Apr 28 2016 04:36
suryakavutarapu sends brownie points to @arunkumrv and @revisualize and @ndburrus :sparkles: :thumbsup: :sparkles:
:star: 273 | @ndburrus | http://www.freecodecamp.com/ndburrus
:warning: suryakavutarapu already gave revisualize points
:star: 530 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Joseph
@revisualize
Apr 28 2016 04:36
@ndburrus I'm trying to understand why they aren't modifying the result variable in the first place.
Norvin Burrus
@ndburrus
Apr 28 2016 04:37
@SuryaKavutarapu Kudos to you!!! :+1:
Joseph
@revisualize
Apr 28 2016 04:37
function name (val) {
 var fname = "";
  fname = val;
  return fname;
}
Chris Cullen
@123xylem
Apr 28 2016 04:37
@arunkumrv Hey, So I didnt quite catch why it doesnt go through all str[elements] up to the length of str?
Shouldnt it iterate through whole str array?
if i do i<=str.length -1 etc it gives me a 1 word solution but I wonder why it wont iterate throough all of them
EricOber
@EricOber
Apr 28 2016 04:38
so where in my code do i put that?
// Setup
function phoneticLookup(val) {
  var result = "";

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



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

// Change this value to test
phoneticLookup("charlie");
Norvin Burrus
@ndburrus
Apr 28 2016 04:38
@revisualize how do you know that? you defined result and simply asked for it back (i.e. no change was made)!
Joseph
@revisualize
Apr 28 2016 04:39
@Am3ricanPaladin
// Setup
function phoneticLookup(val) {
  var result = "";

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


  result = "";  // fix this to use your Object.


  // Only change code above this line
  return result;
}
Norvin Burrus
@ndburrus
Apr 28 2016 04:40
@revisualize you have
js
<var result = "";
result = "";>
EricOber
@EricOber
Apr 28 2016 04:40
ooooh! i thought return result at the bottom had that covered
Joseph
@revisualize
Apr 28 2016 04:40
@Am3ricanPaladin No. You have to modify result.
EricOber
@EricOber
Apr 28 2016 04:40
thank you @revisualize and @ndburrus
CamperBot
@camperbot
Apr 28 2016 04:40
am3ricanpaladin sends brownie points to @revisualize and @ndburrus :sparkles: :thumbsup: :sparkles:
:star: 274 | @ndburrus | http://www.freecodecamp.com/ndburrus
:star: 1014 | @revisualize | http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Apr 28 2016 04:41
@ndburrus I'm trying to assist someone.
Norvin Burrus
@ndburrus
Apr 28 2016 04:41
@revisualize ...and Joseph is off to the races!!! :fire:
henrywashere
@henrywashere
Apr 28 2016 04:41

need help with this exercise!
Instructions
Write a switch statement to set answer for the following conditions:
"a" - "apple"
"b" - "bird"
"c" - "cat"
default - "stuff"

switch (val) {

  case a:
   answer = "apple";
   break;

  case b:
   answer = "bird";
   break;

  case c:
   answer = "cat";
   break;

  default:
      answer = "stuff";
      break;
}

didnt go through

Norvin Burrus
@ndburrus
Apr 28 2016 04:41
@revisualize ...sorry, wrong name
@Am3ricanPaladin Kudos!
Joseph
@revisualize
Apr 28 2016 04:42
@henrywashere That doesn't work?
henrywashere
@henrywashere
Apr 28 2016 04:42
yeah
Joseph
@revisualize
Apr 28 2016 04:42
@henrywashere remove the break at the end.
henrywashere
@henrywashere
Apr 28 2016 04:42
it says "a is not defined"
Joseph
@revisualize
Apr 28 2016 04:43
@henrywashere because it needs to be "a".
not a
henrywashere
@henrywashere
Apr 28 2016 04:43
oh it has to be i quotation marks?
in**
Joseph
@revisualize
Apr 28 2016 04:43
@henrywashere How do you make String Literals in JavaScript?
You put text in "s
henrywashere
@henrywashere
Apr 28 2016 04:44
quotation marks lol
Norvin Burrus
@ndburrus
Apr 28 2016 04:44
@henrywashere define the cases exactly as shown in the challenge...
henrywashere
@henrywashere
Apr 28 2016 04:45
yesss that worked
thanks @revisualize
CamperBot
@camperbot
Apr 28 2016 04:45
henrywashere sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star: 1015 | @revisualize | http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Apr 28 2016 04:45
@henrywashere :+1:
Mary
@mapruter
Apr 28 2016 04:45

I'm trying to do the "Increment a number with JS" and I don't seem to be able to follow instruction 2 which is:
myVar = myVar should be changed.

this is the code I have:

var myVar = 87;

// Only change code below this line
var myVar = 88;
var myVar = myVar++;
Norvin Burrus
@ndburrus
Apr 28 2016 04:46
@mapruter ...why the two vr statements?
@mapruter two*
@mapruter var*
Mary
@mapruter
Apr 28 2016 04:47
myVar should equal 88
myVar = myVar should be changed
Use the ++ operator
Do not change code above the line
Norvin Burrus
@ndburrus
Apr 28 2016 04:48
@mapruter yes, that's true, but don't give the answer to the code... have the code give it to you!
@mapruter hint: delete one of those statements...
@mapruter ...and then press Run tests
Mary
@mapruter
Apr 28 2016 04:49
when i delete the first one, it tells me now i'm missing both myVar should equal to 88 and myVar = myVar is missing
V Arun Kumar
@arunvkumr
Apr 28 2016 04:49
@mapruter initially myVar is 87. you have to increment myVar. that's all.
Joseph
@revisualize
Apr 28 2016 04:49
@mapruter There are multiple ways t increment a variable.
V Arun Kumar
@arunvkumr
Apr 28 2016 04:50
you don't need to declare myVar again after var myVar = 87 and also you don't need any assignments either.
Joseph
@revisualize
Apr 28 2016 04:50
@mapruter You can do
var num = 1;
Norvin Burrus
@ndburrus
Apr 28 2016 04:50
@mapruter oops, delete all var's, no assignments necessary...
Joseph
@revisualize
Apr 28 2016 04:51

Then you can do

num = num + 1;

or

num += 1;

or you can do

num++
Norvin Burrus
@ndburrus
Apr 28 2016 04:51
the ++ does all the work - it increments a value by one all by it's lonesome...
Joseph
@revisualize
Apr 28 2016 04:51
@mapruter All of those produce the same reults.
Carly
@cbogsin
Apr 28 2016 04:51
Hi all, I'm struggling with the counting cards exercise...not sure where I'm going wrong
Joseph
@revisualize
Apr 28 2016 04:52
@cbogsin Show code.
Norvin Burrus
@ndburrus
Apr 28 2016 04:52
@cbogsin Hi Carly, can u post ur code?
Carly
@cbogsin
Apr 28 2016 04:52
Sorry this is my first time in the chat room, how do I post the code?
Norvin Burrus
@ndburrus
Apr 28 2016 04:52
@mapruter got it?
Joseph
@revisualize
Apr 28 2016 04:52
help format
CamperBot
@camperbot
Apr 28 2016 04:52

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

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

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

:pencil: read more about code formatting on the FCC Wiki

Carly
@cbogsin
Apr 28 2016 04:52
Thanks!
Joseph
@revisualize
Apr 28 2016 04:52
example:
```
// code
```
Mary
@mapruter
Apr 28 2016 04:53
i tried this and it still tells me the top two directions aren't done
var myVar = 87;

// Only change code below this line
myVar = myVar++;
Norvin Burrus
@ndburrus
Apr 28 2016 04:53
@mapruter ...the assignment is not needed...
Carly
@cbogsin
Apr 28 2016 04:53
function cc(card) {
  // Only change code below this line

  var decision;

  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count = count++;
      break;
    case 7:
    case 8:
    case 9:
      count = count;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count = count--;
      break;
  }

  if (count <= 0) {
   decision = (count + " Hold");
  }
  else  {
   decision = (count + " Bet");
}
  return (count + decision);

  // Only change code above this line
}
whoops forgot to copy the
Norvin Burrus
@ndburrus
Apr 28 2016 04:54
@mapruter myVar++ does all the work...
V Arun Kumar
@arunvkumr
Apr 28 2016 04:54
@mapruter you don't need to assign myVar++ to myVar. myVar++ is same as
myVar = myVar + 1;
Carly
@cbogsin
Apr 28 2016 04:54
var count = 0;
at the beginning
Mary
@mapruter
Apr 28 2016 04:54
oooooh @m3lv0n . thanks
CamperBot
@camperbot
Apr 28 2016 04:54
mapruter sends brownie points to @m3lv0n :sparkles: :thumbsup: :sparkles:
:star: 230 | @m3lv0n | http://www.freecodecamp.com/m3lv0n
Joseph
@revisualize
Apr 28 2016 04:54
@cbogsin count = count++; doesn't work that way.
Mary
@mapruter
Apr 28 2016 04:54
gotcha @arunkumrv . it makes sense now. thanks
CamperBot
@camperbot
Apr 28 2016 04:54
mapruter sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 531 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Mary
@mapruter
Apr 28 2016 04:55
thanks @revisualize , that makes sense now.
CamperBot
@camperbot
Apr 28 2016 04:55
mapruter sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star: 1016 | @revisualize | http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Apr 28 2016 04:55
This message was deleted
@mapruter :D
Mary
@mapruter
Apr 28 2016 04:55
it is but for some reason it didn't click when i first read it @revisualize
Josselin Milon
@Gjloss
Apr 28 2016 04:56
@dagman A late one, but another thanks for your help!
CamperBot
@camperbot
Apr 28 2016 04:56
gjloss sends brownie points to @dagman :sparkles: :thumbsup: :sparkles:
:star: 453 | @dagman | http://www.freecodecamp.com/dagman
Carly
@cbogsin
Apr 28 2016 04:56
Oh, do I just say count++; without the count = ?
Mary
@mapruter
Apr 28 2016 04:56
i wasn't seeing that there was no equal @revisualize . i've just finished spending like 5 hours on my portfolio project today so it might be time for me to call it a quits on coding.
Joseph
@revisualize
Apr 28 2016 04:56
@cbogsin Correct.
Mary
@mapruter
Apr 28 2016 04:56
yeah no count= needed for count++
Joseph
@revisualize
Apr 28 2016 04:57
@mapruter pomodoro
V Arun Kumar
@arunvkumr
Apr 28 2016 04:57
@cbogsin you can remove case for 7, 8, 9 , assigning count to count is same as count. and you are returning (count + decision). and decision is count + string so you are returning count + count + string.
Carly
@cbogsin
Apr 28 2016 04:57
Hmm okay I made that change but it still isn't working
Norvin Burrus
@ndburrus
Apr 28 2016 04:57
@cbogsin check the logic in these statements
js
<decision = (count + " Hold");
decision = (count + " Bet");
return (count + decision);>
Carly
@cbogsin
Apr 28 2016 04:57
Oh!
Mary
@mapruter
Apr 28 2016 04:58
the technique @revisualize ?
Carly
@cbogsin
Apr 28 2016 04:58
That did the trick! thank you so much!
Joseph
@revisualize
Apr 28 2016 04:58
@mapruter Correct.
Norvin Burrus
@ndburrus
Apr 28 2016 04:58
@cbogsin ...got it?
Carly
@cbogsin
Apr 28 2016 04:58
Yep :)
Mary
@mapruter
Apr 28 2016 04:58
watching a video now. thanks!
Norvin Burrus
@ndburrus
Apr 28 2016 04:58
@cbogsin kudos to you! :+1:
Carly
@cbogsin
Apr 28 2016 04:58
thanks @arunkumrv and @ndburrus, super helpful
CamperBot
@camperbot
Apr 28 2016 04:58
cbogsin sends brownie points to @arunkumrv and @ndburrus :sparkles: :thumbsup: :sparkles:
:star: 275 | @ndburrus | http://www.freecodecamp.com/ndburrus
:star: 532 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Norvin Burrus
@ndburrus
Apr 28 2016 04:59
@mapruter ....did u get it?
Joseph
@revisualize
Apr 28 2016 04:59
@mapruter https://www.coursera.org/learn/learning-how-to-learn/
It pretty much talks all about using the Pomo and repetition. To help with memory and learning.
Carly
@cbogsin
Apr 28 2016 04:59
oh and thanks @revisualize too :)
CamperBot
@camperbot
Apr 28 2016 04:59
cbogsin sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star: 1017 | @revisualize | http://www.freecodecamp.com/revisualize
Mary
@mapruter
Apr 28 2016 04:59
i did @ndburrus , thanks
CamperBot
@camperbot
Apr 28 2016 04:59
mapruter sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star: 276 | @ndburrus | http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Apr 28 2016 05:00
@mapruter Super!!! :sparkles:
Joseph
@revisualize
Apr 28 2016 05:03
:clock10: :zzz: :zzz: :sailboat: :zzz: :ocean: :zzz: :sailboat: :dolphin: :zzz: :fish: :sailboat: :sunrise: :whale2: :zzz: :sailboat: :ocean: :tropical_fish: :whale2: :ocean: :dolphin: :sunrise: :ocean: :zzz:
:v:
SBeard
@etacalpha
Apr 28 2016 05:10
function mutation(arr) { var x = arr.splice(1).toString().toLowerCase().split(" "); for (var i=0; i<=arr.length; i++){ if ( arr.toString().toLowerCase().split(" ").indexOf(x[i])===0){ return true; } else { return false; } } } mutation(["floor", "for"]);
any suggestions
V Arun Kumar
@arunvkumr
Apr 28 2016 05:15
@etacalpha format your code. using 3 backticks.
wiki format
CamperBot
@camperbot
Apr 28 2016 05:15

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

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

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

:pencil: read more about code formatting on the FCC Wiki

Emma Clark
@sapphirestone
Apr 28 2016 05:17
Hi guys I'm having trouble with the Using Objects for Lookups exercise. Can anyone see the error in my code?
SBeard
@etacalpha
Apr 28 2016 05:17
This message was deleted
D.Mills
@millsdee74
Apr 28 2016 05:17
@storbeck thanks you for ....... Accessing Objects Properties with the Dot Operator Dec 30, 2015 View solution
Accessing Objects Properties with Bracket Notation Dec 30, 2015 View solution
Accessing Objects Properties with Variables Dec 30, 2015 View solution
CamperBot
@camperbot
Apr 28 2016 05:17
millsdee74 sends brownie points to @storbeck :sparkles: :thumbsup: :sparkles:
:star: 1595 | @storbeck | http://www.freecodecamp.com/storbeck
Emma Clark
@sapphirestone
Apr 28 2016 05:17
// 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");`
SBeard
@etacalpha
Apr 28 2016 05:18
js function mutation(arr) {
 var x = arr.splice(1).toString().toLowerCase().split(" ");
  for (var i=0; i<=arr.length; i++){   
    if ( arr.toString().toLowerCase().split(" ").indexOf(x[i])===0){
    return true;
} else {
    return false;
    }
  }
}
mutation(["floor", "for"]);
Stuck on "Mutations"
Norvin Burrus
@ndburrus
Apr 28 2016 05:20
@sapphirestone ...use the force, um, i mean use the lookup variable
@sapphirestone ...the var result is assigned. then it is requested.... (no change is being/was made)
@sapphirestone it may be useful to examine this code closely....
js
<return result;>
Norvin Burrus
@ndburrus
Apr 28 2016 05:25
@sapphirestone ...somehow, the llokup object/variable needs to relate to the desired result...
@sapphirestone lookup*
revisualize @revisualize giggles and walks away.
Emma Clark
@sapphirestone
Apr 28 2016 05:27
@ndburrus this fixed it: result = lookup[val]; thanks Norvin
CamperBot
@camperbot
Apr 28 2016 05:27
sapphirestone sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star: 279 | @ndburrus | http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Apr 28 2016 05:27
Wonderful!!! :sparkles:
@sapphirestone
Emma Clark
@sapphirestone
Apr 28 2016 05:29
It must seem so simple but I am still struggling on some of the basic javascript exercises!
Neel Shah
@neelshah22
Apr 28 2016 05:29
blob
Norvin Burrus
@ndburrus
Apr 28 2016 05:29
@sapphirestone - shhh....u got this!
Neel Shah
@neelshah22
Apr 28 2016 05:29
can anyone give me hint on this
Norvin Burrus
@ndburrus
Apr 28 2016 05:29
@neelshah22 which challenge?
Neel Shah
@neelshah22
Apr 28 2016 05:30
Adding a default option in Switch statements
i already added it
but I am not able to satisfy condition
Write a switch statement to set answer for the following conditions:
"a" - "apple"
"b" - "bird"
"c" - "cat"
default - "stuff"
Norvin Burrus
@ndburrus
Apr 28 2016 05:31
@neelshah22 it may be helpful to use the cases exactly as defined in the challenge
@neelshah22 hint: letters vs numbers?
Neel Shah
@neelshah22
Apr 28 2016 05:32
if i use case a then also it gives erroe
error*
Norvin Burrus
@ndburrus
Apr 28 2016 05:33
@neelshah22 ...would you like to buy a string?
Neel Shah
@neelshah22
Apr 28 2016 05:33
that a is not define
and if I define a,b,c, then also it gives error
cannelflow
@cannelflow
Apr 28 2016 05:33
This message was deleted
Norvin Burrus
@ndburrus
Apr 28 2016 05:34
@neelshah22 ...yes, but what about "a", "b", etc..
@neelshah22 ...for the cases
Neel Shah
@neelshah22
Apr 28 2016 05:35
thank you
sir
Norvin Burrus
@ndburrus
Apr 28 2016 05:35
@neelshah22 Cheers! :+1:
Neel Shah
@neelshah22
Apr 28 2016 05:36
sometimes I feel i am so stupid
thanks again @ndburrus
CamperBot
@camperbot
Apr 28 2016 05:36
neelshah22 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star: 280 | @ndburrus | http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Apr 28 2016 05:37
@neelshah22 you're just showing us the ikie doke.... we knew you were bluffing.... :sparkles:
@neelshah22 okie*
SBeard
@etacalpha
Apr 28 2016 05:38
Does anyone have any suggestions?
jsfunction mutation(arr) {
 var x = arr.splice(1).toString().toLowerCase().split(" ");
  for (var i=0; i<=arr.length; i++){   
    if ( arr.toString().toLowerCase().split(" ").indexOf(x[i],0)===0){
    return true;
} else {
    return false;
    }
  }
}
mutation(["floor", "for"]);
Norvin Burrus
@ndburrus
Apr 28 2016 05:39
@neelshah22 you can get help for posting code
help paste code
CamperBot
@camperbot
Apr 28 2016 05:39
no wiki entry for: paste code
Norvin Burrus
@ndburrus
Apr 28 2016 05:39
help post code
CamperBot
@camperbot
Apr 28 2016 05:39
Neel Shah
@neelshah22
Apr 28 2016 05:39
ok
Norvin Burrus
@ndburrus
Apr 28 2016 05:39
@neelshah22 screenshots are tough to read... :)
Markus Kiili
@Masd925
Apr 28 2016 05:40
@etacalpha You can get the strings with less work by:
var first = arr[0].toLowerCase();
var second = arr[1].toLowerCase();
Then just loop the second string characters and use indexOf to check if the character is found on the first string.
Norvin Burrus
@ndburrus
Apr 28 2016 05:42
@Masd925 ...i got tired just looking at that code....
kmo1
@kmo1
Apr 28 2016 05:42
is it possible to add an extra parameter to an .every() call?
Markus Kiili
@Masd925
Apr 28 2016 05:44
@kmo1 Parameters are callback function and optional thisArg (value of this inside callback function.)
Norvin Burrus
@ndburrus
Apr 28 2016 05:44

@kmo1
The every() method tests whether all elements in the array pass the test implemented by the provided function.

SyntaxEDIT
arr.every(callback[, thisArg])
Parameters
callback
Function to test for each element, taking three arguments:
currentValue (required)
The current element being processed in the array.
index (optional)
The index of the current element being processed in the array.
array (optional)
The array every was called upon.
thisArg
Optional. Value to use as this when executing callback.

kmo1
@kmo1
Apr 28 2016 05:44
@Masd925 I'm trying to compare a short array and a long array. I want to know if every element in the short array exists in the long array
I assumed .every was the way to go
Markus Kiili
@Masd925
Apr 28 2016 05:45
@kmo1 Yes, .every() is good.
kmo1
@kmo1
Apr 28 2016 05:45
I can check to see if every element in short array passes some simple condition(ie element > 5) but I can't compare to see if every element in short array is in the long array
Markus Kiili
@Masd925
Apr 28 2016 05:45
@kmo1 Use indexOf.
kmo1
@kmo1
Apr 28 2016 05:46
I wanted to do something like function isInArray(element, index, array) { return longArray.indexOf(element) >= 0; }
whoops
function isInArray(element, index, array) {
  return longArray.indexOf(element) >= 0;
}
shortArray.every(isInArray);
but I don't want to hard code in longArray because I want to reuse this against many shortArrays and many longArrays
what I had in mind was something like:
function checkArrays(shortArray, longArray){
  return shortArray.every(isInArray, longArray);
}
any thoughts @Masd925
Markus Kiili
@Masd925
Apr 28 2016 05:49
@kmo1 You can make a function like that yes.
kmo1
@kmo1
Apr 28 2016 05:49
I can add the longArray to the .every() method?
SBeard
@etacalpha
Apr 28 2016 05:50
@Masd925 thank you, it looks a lot better now.
CamperBot
@camperbot
Apr 28 2016 05:50
etacalpha sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1427 | @masd925 | http://www.freecodecamp.com/masd925
kmo1
@kmo1
Apr 28 2016 05:51
@Masd925 I'm getting the error that longArray is undefined
Markus Kiili
@Masd925
Apr 28 2016 05:53
@kmo1 Like this:
function check (arr1,arr2) {
    return arr1.every(function(elem){
        return arr2.indexOf(elem)>-1;    
    });
}
kmo1
@kmo1
Apr 28 2016 05:54
ahh, I see
I'll give that a shot
so rather than two separate functions you just combine them
Markus Kiili
@Masd925
Apr 28 2016 05:55
@kmo1 If you only use the callback function once and it doesn't get too complicated, you can just use an anonymous function.
kmo1
@kmo1
Apr 28 2016 05:55
great
I appreciate the help
dheerajahuja000
@dheerajahuja000
Apr 28 2016 06:18
i'm working on a project can anyone help me
i'm trying to download a file from hadoop file system using javascript
Eldar Tinjić
@EldarT90
Apr 28 2016 06:38
i need help with my JS calculator
96street
@96street
Apr 28 2016 06:47

What's the difference between:

$("div").delegate("p", "click", function(){
    $("p").css("background-color", "pink");
});

&

$("div p").on("click", function(){
    $("p").css("background-color", "pink");
});
Chris Cullen
@123xylem
Apr 28 2016 06:58
So Im trying to replace the first letter of each element in an array.. THis tells me str.replace is not a function for some reason though... Any help?
function titleCase(str) {
str=  str.toLowerCase();
  str = str.split(" ");
str=  str.replace([0][1], function rep(x){return x.toUpperCase();});
 return str  ; 


}

titleCase("I'm a little tea pot");
Eldar Tinjić
@EldarT90
Apr 28 2016 06:59
@123xylem you split the string
after that its an array and not string anymore
Chris Cullen
@123xylem
Apr 28 2016 06:59
yea... but isnt that array called str still?
@EldarT90
Eldar Tinjić
@EldarT90
Apr 28 2016 07:00
@123xylem str.replace works only on strings
Chris Cullen
@123xylem
Apr 28 2016 07:00
Ahh..
Eldar Tinjić
@EldarT90
Apr 28 2016 07:00
@123xylem and not in that format
Chris Cullen
@123xylem
Apr 28 2016 07:00
@EldarT90 thanks... il have to look into it another way
CamperBot
@camperbot
Apr 28 2016 07:00
123xylem sends brownie points to @eldart90 :sparkles: :thumbsup: :sparkles:
:star: 327 | @eldart90 | http://www.freecodecamp.com/eldart90
Coy Sanders
@coymeetsworld
Apr 28 2016 07:01
first argument of replace is looking for a regex or a substring @123xylem
not sure what [0][1] is
Chris Cullen
@123xylem
Apr 28 2016 07:01
@coymeetsworld right. I was using it on an array
Didnt know it only works on strings
Coy Sanders
@coymeetsworld
Apr 28 2016 07:02
yeah there is no Array.replace function
you can either iterate through the array, or more elegant way would be using the Array.map function
Eldar Tinjić
@EldarT90
Apr 28 2016 07:04
need help with bug fixing in my JS calculator project
Chris Cullen
@123xylem
Apr 28 2016 07:05
@coymeetsworld yea I was thinking .mapping it to look at the first char of every elemetn.. could I change the elements like that?
Coy Sanders
@coymeetsworld
Apr 28 2016 07:06
yes
Frank XC
@tenkdayz
Apr 28 2016 07:06
is there a way to select/find every element that is not $(this)? in jquery.
Coy Sanders
@coymeetsworld
Apr 28 2016 07:08
arr.map won't change the array in place though @123xylem, you'll have to assign it back to arr, i.e.
arr = arr.map(function(.....))
Chris Cullen
@123xylem
Apr 28 2016 07:09
@coymeetsworld Yup... just trying to figure out the wording of it now so it does what I want
ahh I can just write a big function in it?
V1ad1m1r
@V1ad1m1r
Apr 28 2016 07:11
@pompek that solved it :) thanks!
CamperBot
@camperbot
Apr 28 2016 07:11
v1ad1m1r sends brownie points to @pompek :sparkles: :thumbsup: :sparkles:
:star: 362 | @pompek | http://www.freecodecamp.com/pompek
Eldar Tinjić
@EldarT90
Apr 28 2016 07:12
need help with bug fixing JS calculator, tnx
Chris Cullen
@123xylem
Apr 28 2016 07:14
help format
CamperBot
@camperbot
Apr 28 2016 07:14

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

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

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

:pencil: read more about code formatting on the FCC Wiki

Chris Cullen
@123xylem
Apr 28 2016 07:15
function titleCase(str) {
str=  str.toLowerCase();
  str = str.split(" ");

 var newStr = str.map(function(x){ for(i=0; i<str.length; i++){
   newStr =str[0][0].toUpperCase;
 }  });
 return newStr  ; 
}

titleCase("I'm a little tea pot");
Any idea why this is producing null null null null
?
THat should give me newStr with the old str first letters replaced with caps
Coy Sanders
@coymeetsworld
Apr 28 2016 07:18
you don't need a for loop inside the map function
might be a little confusing because str is now an array, but arr.map will iterate through each element in the array for you, without the need of a loop

might want to read the documentation on it to get a better idea of what's happening:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

Chris Cullen
@123xylem
Apr 28 2016 07:20
ah ok thanks will do
Nabeel Kondotty
@nabeelk
Apr 28 2016 07:21

https://www.freecodecamp.com/challenges/stand-in-line

I got stuck here. Any simple docs to explain how this works?

kirbyedy
@kirbyedy
Apr 28 2016 07:23
@nabeelk you have to use shift and push methods
Nabeel Kondotty
@nabeelk
Apr 28 2016 07:23
@kirbyedy Thanks
CamperBot
@camperbot
Apr 28 2016 07:23
nabeelk sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 930 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
kirbyedy
@kirbyedy
Apr 28 2016 07:24
with push() you will add the item to your array, and with shift() you will remove the first element from your array
Nabeel Kondotty
@nabeelk
Apr 28 2016 07:25
Sure :)
I was getting confused.
Eldar Tinjić
@EldarT90
Apr 28 2016 07:26
need help with bugs in my JS calculator, tnx
Adam Nemeth
@adam-nmth
Apr 28 2016 07:26
help make a person
CamperBot
@camperbot
Apr 28 2016 07:26

:point_right: algorithm make a person [wiki]

Explanation:

When I started the program I figured I just had to create the six functions mentioned in the details. However, it was not that simple. Creating them as a function was not the right way, I had to create them in a different way to make them a key.

There is also a tricky part as you need six keys no more or less, so at first I had the variable that store the original name as a key too which was wrong.

As for the usage of array, that is optional, you could also create new variable to hold the separated string if you wish but an array is easier to deal with as strings are immutable.

Read the instructions carefully, it is always a good hint in itself to run the code and check what the test results were so you know what to expect but do not fixate yourself on that. Once you understand what you need to do, this problem is very easy and straightforward.

:pencil: read more about algorithm make a person on the FCC Wiki

Nabeel Kondotty
@nabeelk
Apr 28 2016 07:32
@kirbyedy I finished that challenge
Your hint was clear :clap:
Can someone help?
Markus Kiili
@Masd925
Apr 28 2016 07:41
@imnotlammy A simple for loop through contacts array and two nested if clauses inside the loop block is the easiest structure. Using .reduce() is also an option, but rarely seen.
Igor
@ess3nt
Apr 28 2016 07:53
@imnotlammy https://www.freecodecamp.com/challenges/profile-lookup#?solution=%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%2F%2F%20%20var%20i%20%3D%200%3B%0A%0A%2F%2F%20%20while%20(i%20%3C%20contacts.length)%20%7B%0A%2F%2F%20%20%20%20if%20(firstName%20%3D%3D%20contacts%5Bi%5D.firstName%0A%20%20%20%20for(var%20i%20%3D%200%3B%20i%20%3C%20contacts.length%3B%20i%2B%2B)%7B%0A%0A%20%20%20%20%20if(contacts%5Bi%5D%5BfirstName%5D%20%3D%3D%20prop)%7B%0A%20%20%20%20%20%20%20%20return%20true%3B%0A%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%0A%20%20%20%20return%20%22No%20such%20contact%22%3B%0A%7D%0AlookUpProfile(%22firstName%22%2C%20%22Harry%22)%3B%0A%0A%0A%2F**%0A%20*%20Created%20by%20Igor%20on%2028.04.16.%0A%20*%2F%0A
96street
@96street
Apr 28 2016 07:57
How does FCC make the green fade on new posts?
Elbert Cortez
@trip16661
Apr 28 2016 07:58
function checkCashRegister(price, cash, cid) {

  var moneyDeno = [
    { name: 'ONE HUNDRED', val: 100.00},
    { name: 'TWENTY', val: 20.00},
    { name: 'TEN', val: 10.00},
    { name: 'FIVE', val: 5.00},
    { name: 'ONE', val: 1.00},
    { name: 'QUARTER', val: 0.25},
    { name: 'DIME', val: 0.10},
    { name: 'NICKEL', val: 0.05},
    { name: 'PENNY', val: 0.01}
  ];
  var change = cash - price;
  var a = 0;
  var cashIn = cid.reduce(function(denomination,array){
    denomination.push({
      name:array[0],
      amount:array[1]
    });
    return denomination;  
  },[]).reverse();
  var totalInBox = cashIn.reduce(function(starting, denomination){
    return starting += denomination.amount;
  },0).toFixed(2);

  if (totalInBox < change) {
    return "Insufficient Funds";
  }
  if (totalInBox === 0) {
    return "Closed";
  }

  var resultChange = moneyDeno.reduce(function(arr,denoType){
    var value = 0;
    while (denoType.val <= change && cashIn[a].amount > 0) {
      change -= denoType.val;
      value += denoType.val;
      cashIn[a].amount -= denoType.val;
      change = change.toFixed(2);
    } 
    a++;
    if(value > 0){
      arr.push([ denoType.name,value ]);
    }
    return arr;
  },[]);
if (resultChange[0][1] < change){
  return "Insufficient Funds";
}

  // Here is your change, ma'am.
  return resultChange;
}

checkCashRegister(19.50, 20.00, [["PENNY", 0.50], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]);
a little help for this poor kid D:
I'm not returning Closed when there is no money left in the drawer
Eldar Tinjić
@EldarT90
Apr 28 2016 08:02
need help with bugs in JS calculator tnx
maksymkv25
@maksymkv25
Apr 28 2016 08:09
var myStr= \backslash \ttab \ttab \rcarriage-return \nnew-line;
how can i did Escape Sequences in Strings?
Sameer Shamsudeen
@sameershamsudheen
Apr 28 2016 08:15

hello i was doing Where do I belong, here is my code,

function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  arr.sort();
  var index=0;
  for(var i=0; i<arr.length; i++){
    if(arr[i]===num || arr[i+1]===num){
      index=i;
    }
    else if(num > arr[i] || arr[i+1] < num){
      index=i+1;
    }
  }
  return index;
}
getIndexToIns([3, 10, 5], 3);

I need to clear two more errors, this input getIndexToIns([3, 10, 5], 3); should return 0 , it is now return 1. what is the error in this code

charazn
@charazn
Apr 28 2016 08:30
Hi, I couldn’t get my Random Quote Machine to work, using http://forismatic.com/en/api/ Here’s my code. Should not need extra css or js file. Can someone explain why the js doesn’t work? I followed the docs on forismatic and also the JSON APIs and AJAX lesson, and it should work! I must be missing something… Please help.
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Random Quote Machine</title>
    <!-- Latest Bootstrap compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css">
    <link rel="stylesheet" href="/main.css" media="screen" title="no title" charset="utf-8">
  </head>

  <body>
    <div class="container text-center">
      <div class="col-md-8 col-md-offset-2 col-xs-12 quotebox">
        <h1>FreeCodeCamp Random Quote Machine</h1>
        <button id="getQuote" class="btn btn-primary" type="button" name="button"><i class="fa fa-quote-left" aria-hidden="true"></i>
           Quote <i class="fa fa-quote-right" aria-hidden="true"></i></button>
        <button class="btn btn-info" type="button" name="button"><i class="fa fa-twitter" aria-hidden="true"></i>
 Quote</button>
        <div id="quote"></div>
      </div>
    </div>

    <!-- Latest Bootstrap compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
    <!-- jQuery minified -->
    <script src="https://code.jquery.com/jquery-2.2.3.min.js" integrity="sha256-a23g1Nt4dtEYOj7bR+vTu7+T8VP13humZFBJNIYoEJo=" crossorigin="anonymous"></script>
    <script>
      $(document).ready(function() {
        $("#getQuote").on("click", function() {
          $.post("http://api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=json&lang=en", function(json) {
            $("#quote").html(JSON.stringify(json));
          });
        });
      });
    </script>
  </body>
</html>
Marc Schöni
@marcschoeni
Apr 28 2016 08:32
@charazn what for an editor use u?
charazn
@charazn
Apr 28 2016 08:32
Atom
kirbyedy
@kirbyedy
Apr 28 2016 08:33
@charazn for start try to load jquery before the bootstrap
charazn
@charazn
Apr 28 2016 08:33
Nope it doesn’t work
i’m working on my local machine. perhaps I’ll try pasting into codepen.
Eldar Tinjić
@EldarT90
Apr 28 2016 08:35
need help with JS calculator bugs, tnx
charazn
@charazn
Apr 28 2016 08:36
Pasting into codepen doesn’t work...
the doer
@ewathedoer
Apr 28 2016 08:47
@charazn how do you do it?
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 28 2016 08:47
guys need help on below code
```js
(function () {
    var xmlns = "http://www.w3.org/2000/svg";
    var isMoveRight = true;
    var isMoveUp;
    var isMoveLeft;
    var isMoveDown;
    var isUpDownDisable = true;
    var isLeftRightDisable = false;
    var isRequireNewFood = true;

    // game area object and create platform for game
    var myGameArea = {
        svg: document.createElementNS(xmlns, "svg"),
        start: function () {

            // append the svg area to body
            document.body.insertBefore(this.svg, document.body.childNodes[0]);

            // set the reload game area time to sea continue change in game area
            this.interval = setInterval(updateGameArea, 20);

            // added event listener for snake movement and this functionality require for hole game area so added in game area
            document.body.addEventListener('keydown', function (e) {
                var keyStrokeCode = e.keyCode;
                if (keyStrokeCode === 37) {
                    if (isLeftRightDisable) {
                        isLeftRightDisable = !isLeftRightDisable;
                        isUpDownDisable = true;
                        isMoveLeft = true;
                        isMoveDown = isMoveRight = isMoveUp = false;
                    }
                } else if (keyStrokeCode === 38) {
                    if (isUpDownDisable) {
                        isUpDownDisable = !isUpDownDisable;
                        isLeftRightDisable = true;
                        isMoveUp = true;
                        isMoveDown = isMoveLeft = isMoveRight = false;
                    }
                } else if (keyStrokeCode === 39) {
                    if (isLeftRightDisable) {
                        isLeftRightDisable = !isLeftRightDisable;
                        isUpDownDisable = true;
                        isMoveRight = true;
                        isMoveDown = isMoveUp = isMoveLeft = false;
                    }
                } else if (keyStrokeCode === 40) {
                    if (isUpDownDisable) {
                        isUpDownDisable = !isUpDownDisable;
                        isLeftRightDisable = true;
                        isMoveDown = true;
                        isMoveUp = isMoveLeft = isMoveRight = false;
                    }
                }
            });
        },

        // stop the game area reloading so it will give steady frame
        stopGame: function () {
            clearInterval(this.interval);
        },

        foodLocation : {},

        newFood : function () {
            var randomX = Math.abs(Math.floor(Math.random() * (600 + 50) - 50));
            var randomY = Math.abs(Math.floor(Math.random() * (400 + 50) - 50));
            this.foodLocation = {"x": randomX, "y" : randomY};
        }

    };

    // creating rectangle in svg (snake and food)
    function component(shape, width, height, color, x, y, idName) {

        // create shapes fo snake and food
        var elem = document.createElementNS(xmlns, shape);
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;

        this.update = function () {
            elem.setAttributeNS(null, "x", this.x);
            elem.setAttributeNS(null, "y", this.y);
            elem.setAttributeNS(null, "width", this.width);
            elem.setAttributeNS(null, "height", this.height);
            elem.setAttributeNS(null, "fill", color);
            elem.setAttributeNS(null, "id", idName);
            document.getElementsByTagName('svg')[0].appendChild(elem);
        };


        // provide movement to the snake
        this.move = function () {
            if (isMoveRight) {
                myGamePiece.x += 3;
            } else if (isMoveLeft) {
                myGamePiece.x -= 3;
            } else if (isMoveUp) {
                myGamePiece.y -= 3;
            } else if (isMoveDown) {
                myGamePiece.y += 3;
            }

        };
concatenate this code also
 // snake crash with border then stop the game
        this.crashWithBorder = function () {
            this.bottomSide = this.y + this.height;
            this.rightSide = this.x + this.width;
            if ((this.x <= 0) || (this.rightSide >= 800) || (this.y <= 0) || (this.bottomSide >= 500)) {
                alert("Game Over");
                return true;
            }
        };

       //check if food eaten by snake or not
        this.foodCollect = function (myGamePiece) {
            var snakeTop = myGamePiece.y;
            var snakeLeft = myGamePiece.x;
            var snakeBottom = myGamePiece.y + myGamePiece.height;
            var snakeRight = myGamePiece.x + myGamePiece.width;
            this.foodWidth = this.x + this.width;
            this.foodHeight = this.y + this.height;

            if ((this.x <= snakeRight) && (this.foodWidth >= snakeLeft) && (this.y <= snakeBottom) && (this.foodHeight >= snakeTop)) {
                  var element = document.getElementById("snakeFood");
                  element.parentNode.removeChild(element);
                  myGameArea.newFood();
            }
        };

    }

    function updateGameArea() {
        if (myGamePiece.crashWithBorder()) {
            myGameArea.stopGame();
        } else {
            snakeFood.update();
            snakeFood.foodCollect(myGamePiece);
            myGamePiece.move();
            myGamePiece.update();
        }
    }

    myGameArea.newFood();
    var myGamePiece = new component("rect", 10, 10, "red", 120, 120, "snake");
    var snakeFood = new component("rect", 10, 10, "blue", myGameArea.foodLocation.x, myGameArea.foodLocation.y, "snakeFood");

    myGameArea.start();

})();
i am building snake game
need to create random snake food
but not working
if any have solution help me
Arend Groot Bleumink
@arendgb
Apr 28 2016 08:57
function nextInLine(arr, item) {
  // Your code here



  return item;  // Change this line
}

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

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

The tasks are:
nextInLine([], 1) should return 1
nextInLine(angular/angular.io#1192, 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10

I have no idea what to do, can anyone help me with this?

HazyHotDog
@HazyHotDog
Apr 28 2016 09:00
@arendgb Hey, im totally at the same position as you, I too got confused because of not enough info about what to do ;D
Patiently awaiting an answer
kirbyedy
@kirbyedy
Apr 28 2016 09:00
@charazn link your pen here
Arend Groot Bleumink
@arendgb
Apr 28 2016 09:01
@HazyHotDog yes, it has so little information :worried:
Elbert Cortez
@trip16661
Apr 28 2016 09:07
function checkCashRegister(price, cash, cid) {

  var moneyDeno = [
    { name: 'ONE HUNDRED', val: 100.00},
    { name: 'TWENTY', val: 20.00},
    { name: 'TEN', val: 10.00},
    { name: 'FIVE', val: 5.00},
    { name: 'ONE', val: 1.00},
    { name: 'QUARTER', val: 0.25},
    { name: 'DIME', val: 0.10},
    { name: 'NICKEL', val: 0.05},
    { name: 'PENNY', val: 0.01}
  ];
  var change = (cash - price).toFixed(2);
  var a = 0;
  var cashIn = cid.reduce(function(denomination,array){
    denomination.push({
      name:array[0],
      amount:array[1]
    });
    return denomination;  
  },[]).reverse();
  var totalInBox = cashIn.reduce(function(starting, denomination){
    return starting += denomination.amount;
  },0).toFixed(2);
  //here
  if (totalInBox < change) {
    return "Insufficient Funds";
  }
  //<-here
  if (totalInBox === change) {
    return "Closed";
  }

  var resultChange = moneyDeno.reduce(function(arr,denoType){
    var value = 0;
    while (denoType.val <= change && cashIn[a].amount > 0) {
      change -= denoType.val;
      value += denoType.val;
      cashIn[a].amount -= denoType.val;
      change = change.toFixed(2);
    } 
    a++;
    if(value > 0){
      arr.push([ denoType.name,value ]);
    }
    return arr;
  },[]);
if (resultChange[0][1] < change){
  return "Insufficient Funds";
}

  // Here is your change, ma'am.
  return resultChange;
}

checkCashRegister(3.26, 100.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
this situation is not working D: and i know where it doesnt work but im not sure why
HazyHotDog
@HazyHotDog
Apr 28 2016 09:42
holy sh.. I actually did it @arendgb, you still need that solution?
Hint: It calls back to the .push() and .shift() array modifications
CamperBot
@camperbot
Apr 28 2016 09:43
Set a bonfire to talk about with bonfire name
Arend Groot Bleumink
@arendgb
Apr 28 2016 09:43
@HazyHotDog yes, that would be great. I figured some out
HazyHotDog
@HazyHotDog
Apr 28 2016 09:44
Okay, so basicly the info about the challenge is not really logic: 1) It says: "Write a function nextInLine which takes an array (arr) and a number (item) as arguments.", but it is already present in the code in the first line
then all you have to do is add 3 lines:
 // Your code here
  arr.push(item);
  item = arr.shift();
  return item;  // Change this line
}
Arend Groot Bleumink
@arendgb
Apr 28 2016 09:46
@HazyHotDog Great Thanks! I understand it know :)
CamperBot
@camperbot
Apr 28 2016 09:46
arendgb sends brownie points to @hazyhotdog :sparkles: :thumbsup: :sparkles:
:star: 192 | @hazyhotdog | http://www.freecodecamp.com/hazyhotdog
HazyHotDog
@HazyHotDog
Apr 28 2016 09:47
No probs! This was quite the investigation :D
Rimsf9
@Rimsf9
Apr 28 2016 09:47
having problem in profile lookup chapter..
charazn
@charazn
Apr 28 2016 09:48
@ewathedoer @kirbyedy Here’s my pen. http://codepen.io/charazn/pen/VaEmPY
the doer
@ewathedoer
Apr 28 2016 09:49
well @charazn it does not work for me, I mean there are no quotes
no js yet
charazn
@charazn
Apr 28 2016 09:49
that’s why i’m asking for advice here
the doer
@ewathedoer
Apr 28 2016 09:50
so what’s your exact question?
kirbyedy
@kirbyedy
Apr 28 2016 09:51
@charazn $.post <-- you have to use $.getJSON
charazn
@charazn
Apr 28 2016 09:52
@kirbyedy I tried that already. It’s now also updated in my pen. Try it. Still doesn’t work.
kirbyedy
@kirbyedy
Apr 28 2016 09:52
@charazn and also your call is not quite good
try this:
http://api.forismatic.com/api/1.0/?method=getQuote&format=jsonp&lang=en&jsonp=?
charazn
@charazn
Apr 28 2016 09:53
why jsonp? the forismatic docs say json is one of the format too
kirbyedy
@kirbyedy
Apr 28 2016 09:54
No 'Access-Control-Allow-Origin' header
cross domain access
so you have to use the callback
JavaScript Object Notation with Padding (JSONP in short) is a way of performing cross-domain requests by exploiting the fact that script tags in HTML pages can load code coming from a different origin.
charazn
@charazn
Apr 28 2016 09:56
ok, it works. so in this case, which is my callback function?
this one? function(json) {
$("#quote").html(JSON.stringify(json));
Ankur sharma
@ankur1163
Apr 28 2016 09:57
need quick help
var arr = [
  [1,2], [3,4], [5,6]
];
for (var i=0; i < arr.length; i++) {
  for (var j=0; j < arr[i].length; j++) {
    console.log(arr[i][j]);
  }
}
can someone tell me whats the meaning of arr[i].length
kirbyedy
@kirbyedy
Apr 28 2016 09:58
@ankur1163 how would this work ?
var j=0; j < arr[i].length; j++ you cant have here both j and i
Stephen James
@sjames1958gm
Apr 28 2016 09:58
@ankur1163 it is the length of the individual elements of arr
Ankur sharma
@ankur1163
Apr 28 2016 09:59
i copied it straight from free code camp, this isnt my code
Coryphaeus
@cvdeby
Apr 28 2016 09:59
@ankur1163 It is 2D arrays runner.
Stephen James
@sjames1958gm
Apr 28 2016 09:59
where arr.length is 3 arr[i].length in this case would be 2 each time.
if arr = [[1, 2,3], [1,2,3,4],[1,2,3,4,5]] arr[i].length would be 3, 4, 5 when i was 0, 1,2 respectively
Ankur sharma
@ankur1163
Apr 28 2016 10:01
ahh
I got it
Coryphaeus
@cvdeby
Apr 28 2016 10:01
@ankur1163 It is useful, when you need to check each one value in 2D-array. And it looks like a timer)
Ankur sharma
@ankur1163
Apr 28 2016 10:01
so arr.length is how many elemnts we have in array
and arr[i] is when we are going into each elements
Stephen James
@sjames1958gm
Apr 28 2016 10:01
@ankur1163 yes
Ankur sharma
@ankur1163
Apr 28 2016 10:02
ahh got it
thanks @sjames1958gm
CamperBot
@camperbot
Apr 28 2016 10:02
ankur1163 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 830 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Ankur sharma
@ankur1163
Apr 28 2016 10:02
thanks @cvdeby
CamperBot
@camperbot
Apr 28 2016 10:02
ankur1163 sends brownie points to @cvdeby :sparkles: :thumbsup: :sparkles:
:star: 381 | @cvdeby | http://www.freecodecamp.com/cvdeby
charazn
@charazn
Apr 28 2016 10:03
@kirbyedy Thanks. Article is well written. Last question. Since the format=jsonp is already specified, 1. what is the &jsonp=? for? 2. why =?
CamperBot
@camperbot
Apr 28 2016 10:03
charazn sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 932 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
Lisa
@aGirlWhoCodes
Apr 28 2016 10:04
Hi guys! hope you can help me. have been busy with it for a while.. I need to repeat a string a given number of times. I was trying to repeat that string with the following code: else { for (var n = 0; n < num; n++) { outputstr.push(str(num[n])); }
charazn
@charazn
Apr 28 2016 10:06
@aGirlWhoCodes str.repeat(num)
Dardan Demiri
@dardandemiri
Apr 28 2016 10:06
Hi everyone
what do you think what's wrong with this code
  function sumPrimes(num) {

      function isPrime(n) {
          if (n < 2) return false;
          for (var i = 2; i < n; i++) {
              if (n % i === 0)
                  return false;
          }
          return true;
      }

      var allPrimes = [];
      for (var i = 0; i < num; i++) {
          allPrimes.push(isPrime(i));
      }

      function add(a, b) {
          return a + b;
      }

      var result = allPrimes.reduce(add, 0);



    return result;
  }

  sumPrimes(10); // should return 17
Lisa
@aGirlWhoCodes
Apr 28 2016 10:07
@charazn Thanks a lot I will try that!
CamperBot
@camperbot
Apr 28 2016 10:07
agirlwhocodes sends brownie points to @charazn :sparkles: :thumbsup: :sparkles:
:star: 282 | @charazn | http://www.freecodecamp.com/charazn
charazn
@charazn
Apr 28 2016 10:09
@aGirlWhoCodes The MDN resource, good to quickly read through: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat
Dardan Demiri
@dardandemiri
Apr 28 2016 10:09
I changed the return true to return n
Now it works for sumPrimes(10) but not for 977
Lisa
@aGirlWhoCodes
Apr 28 2016 10:15
@charazn Thanx again! I see the repeat method is exactly what I need!
CamperBot
@camperbot
Apr 28 2016 10:15
agirlwhocodes sends brownie points to @charazn :sparkles: :thumbsup: :sparkles:
:warning: agirlwhocodes already gave charazn points
Dardan Demiri
@dardandemiri
Apr 28 2016 10:15
Thaks All, I found the mistakes
:D
Samuel Cupidon
@Zerazera
Apr 28 2016 10:18
This message was deleted
Edriany
@Edriany
Apr 28 2016 10:36
thanks @leftynaut for your help with Checkpoint: Record Collection
CamperBot
@camperbot
Apr 28 2016 10:36
edriany sends brownie points to @leftynaut :sparkles: :thumbsup: :sparkles:
:star: 495 | @leftynaut | http://www.freecodecamp.com/leftynaut
Elizabeth Fine
@elizabethfinedev
Apr 28 2016 10:48
hey guys, whats the best way to break up a long array into smaller arrays?
basically i want to take my array and i want to break it up so that each item is its own array
Stephen James
@sjames1958gm
Apr 28 2016 10:50
@BananaHavana Do the smaller arrays go in a new array as well?
Brendan Kinahan
@BKinahan
Apr 28 2016 10:52
@BananaHavana you could use .map() with a callback function that returns the input value as an array. You'll end up with an array full of arrays
Stephen James
@sjames1958gm
Apr 28 2016 10:53
@BKinahan :+1:
SBeard
@etacalpha
Apr 28 2016 10:55
What am I missing?
js function destroyer(arr) {
  if ( arr[0] == arguments[1] | arr == arguments[2]){
    return false;
  }
return arr.filter(function(destroyer){

  return destroyer;
}); 
                  } 



destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Alex
@alexstelmakh
Apr 28 2016 10:55
Hey guys! I'm not quite understand what required in this challenge.https://www.freecodecamp.com/challenges/factorialize-a-number
I'm not ask for ready solution, but maybe somebody has faced with this before?
Elizabeth Fine
@elizabethfinedev
Apr 28 2016 10:56
@sjames1958gm Yes they will go into a new array
okay ill give it a try, thanks @BKinahan
CamperBot
@camperbot
Apr 28 2016 10:56
bananahavana sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1397 | @bkinahan | http://www.freecodecamp.com/bkinahan
Elizabeth Fine
@elizabethfinedev
Apr 28 2016 10:57
thanks @sjames1958gm
CamperBot
@camperbot
Apr 28 2016 10:57
bananahavana sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 831 |