These are chat archives for FreeCodeCamp/HelpJavaScript

20th
Jan 2016
Christina Cook
@ctinaa
Jan 20 2016 00:01
How is everyone doing?
d wilder
@alhazen1
Jan 20 2016 00:06
@ctinaa Doin' fine! How about you?
Jessica
@jess901108
Jan 20 2016 00:06
Hi guys I'm confused what does "no repeats please "actually ask me to do? it's in advanced algorithm scripting
d wilder
@alhazen1
Jan 20 2016 00:07
@ctinaa and thanks for asking
CamperBot
@camperbot
Jan 20 2016 00:07
alhazen1 sends brownie points to @ctinaa :sparkles: :thumbsup: :sparkles:
:star: 172 | @ctinaa | http://www.freecodecamp.com/ctinaa
Christina Cook
@ctinaa
Jan 20 2016 00:07
@alhazen1 haha stuck on a problem
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; 
      break; 
    case 7:
    case 8: 
    case 9:
      count = 0;
      break;
    case 10: 
    case 'J':
    case 'Q':
    case 'K':
    case 'A': 
      count -= count;  
      break;
  }

if (count>0){
  return count +" Bet";
} else{
return count +" Hold";
  }

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2);
Anyone know why only 0 Hold works?
Blauelf
@Blauelf
Jan 20 2016 00:11
@jess901108 Count the ways to arrange the letters so you don't have the same letters touching. The individual letters should be treatet as different when counting, so "aab" has the two solutions "aba" and "aba" (with first and second a swapped)
JadeAtlas
@JadeAtlas
Jan 20 2016 00:12
@ctinaa Working through my list of to-dos for the day, how about you?
and thank you for asking ^^
CamperBot
@camperbot
Jan 20 2016 00:12
jadeatlas sends brownie points to @ctinaa :sparkles: :thumbsup: :sparkles:
:star: 173 | @ctinaa | http://www.freecodecamp.com/ctinaa
Blauelf
@Blauelf
Jan 20 2016 00:13
@ctinaa Not count += count;, but count++; or count+=1;. Same for -=, and nothing needs to be done for 7,8,9 (no change, not setting to 0)
d wilder
@alhazen1
Jan 20 2016 00:13
@ctinaa 6,7,8 reset your count to 0. SB count + 0
Christina Cook
@ctinaa
Jan 20 2016 00:14
@Blauelf am I missing a space? Is that what it is?
Steven Ni
@Steven-C-Ni
Jan 20 2016 00:14
// Setup
var processed = 0;

function process(num) {
  return (num + 3) / 5;
}

// Only change code below this line
process(7);
d wilder
@alhazen1
Jan 20 2016 00:14
@ctinaa actually you could just skip those numbers in the switch statement altogether since they don't change the count.
Jessica
@jess901108
Jan 20 2016 00:14
@Blauelf I see. Thanks !!
CamperBot
@camperbot
Jan 20 2016 00:14
jess901108 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 919 | @blauelf | http://www.freecodecamp.com/blauelf
Christina Cook
@ctinaa
Jan 20 2016 00:15
@alhazen1 what do you mean reset my count? so "count+= 0 ?
d wilder
@alhazen1
Jan 20 2016 00:16
@ctinaa count = 0 sets your count back to 0 count +=0 increments your count
Steven Ni
@Steven-C-Ni
Jan 20 2016 00:16
does anyone know how i can get processed to have a value of 2?
// Setup
var processed = 0;

function process(num) {
  return (num + 3) / 5;
}

// Only change code below this line
process(7);
Blauelf
@Blauelf
Jan 20 2016 00:16
@ctinaa a += b is the same as a = a + b. So think what makes sense here :)
count+=0; would increment count by 0 (so does not change anything), which is what 7,8,9 should do. You don't have to include that, but you can of course.
Christina Cook
@ctinaa
Jan 20 2016 00:16
@alhazen1 it doesn't work.
Steven Ni
@Steven-C-Ni
Jan 20 2016 00:16
i tried calling the process function with an argument of 7
Bakari Holmes
@bakarih
Jan 20 2016 00:17
// 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 update(id, prop, value) {
  if ((value !== "") && (collection.id.prop != "tracks"))
    {
      collection.id.prop = value;
    }
  else if ((prop == "tracks" && value !== ""))
    {
      collection.id.prop.push(value);
    }
  else if ((value === ""))
    {
      delete collection.id.prop;
    }


  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
Christina Cook
@ctinaa
Jan 20 2016 00:17
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 += 0; 
      break; 
    case 7:
    case 8: 
    case 9:
      count = 0;
      break;
    case 10: 
    case 'J':
    case 'Q':
    case 'K':
    case 'A': 
      count -= 0;  
      break;
  }

if (count>0){
  return count +" Bet";
} else if (count <= 0){
return count +" Hold";
  } else {
  return "Change Me";
  }
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2);
Bakari Holmes
@bakarih
Jan 20 2016 00:17
^^ can't figure out why I'm getting TypeError: Cannot read property 'prop' of undefined
Blauelf
@Blauelf
Jan 20 2016 00:18
@ctinaa Use count += 1; for the lower cards, and count -= 1; for the higher ones.
Bakari Holmes
@bakarih
Jan 20 2016 00:18
// 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 update(id, prop, value) {
  if ((value !== "") && (collection.id.prop != "tracks"))
    {
      collection.id.prop = value;
    }
  else if ((prop == "tracks" && value !== ""))
    {
      collection.id.prop.push(value);
    }
  else if ((value === ""))
    {
      delete collection.id.prop;
    }


  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
d wilder
@alhazen1
Jan 20 2016 00:18
@ctinaa low cards add 1 to count, high cards subtract 1 from count and middle cards do nothing to count
    case 7:
    case 8: 
    case 9:
      count +=0
Rex Schrader
@SaintPeter
Jan 20 2016 00:18
@bakarih You must use bracket notation. There IS no property of collection called either id or prop - those are variables.
Christina Cook
@ctinaa
Jan 20 2016 00:20
@alhazen1 I tried and it does nothing
Blauelf
@Blauelf
Jan 20 2016 00:21
+=0 and -=0 do about nothing, they add or subtract 0. Use 1 instead of 0 for the values that should change.
d wilder
@alhazen1
Jan 20 2016 00:21
@ctinaa should be like you had before here with 1
    case 10: 
    case 'J':
    case 'Q':
    case 'K':
    case 'A': 
      count -= 1;
Eric Saldivar
@esaldivar
Jan 20 2016 00:26
stuck on using objects for lookups
// 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("");
Christina Cook
@ctinaa
Jan 20 2016 00:27
Ohhhh!!! @Blauelf and @alhazen1 thank you! Haha finally! It took like 30 minutes for me to figure out that one
CamperBot
@camperbot
Jan 20 2016 00:27
ctinaa sends brownie points to @blauelf and @alhazen1 :sparkles: :thumbsup: :sparkles:
:star: 920 | @blauelf | http://www.freecodecamp.com/blauelf
:star: 271 | @alhazen1 | http://www.freecodecamp.com/alhazen1
Nick Maskell
@nickmask
Jan 20 2016 00:27
Hey all, can anyone help me figure out how to sum all numbers between two numbers?
Blauelf
@Blauelf
Jan 20 2016 00:27
@esaldivar result=lookup[val];
Nick Maskell
@nickmask
Jan 20 2016 00:27

var max = Math.max(sumAll);

var min = Math.min(sumAll);

function sumAll(arr) {
return arr.reduce(function(currentVal, previousVal) {
return currentVal + previousVal;
});
}

sumAll([1, 4]);

^ is where I am currently at.
Eric Saldivar
@esaldivar
Jan 20 2016 00:28
@Blauelf Thanks!
CamperBot
@camperbot
Jan 20 2016 00:28
esaldivar sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 921 | @blauelf | http://www.freecodecamp.com/blauelf
d wilder
@alhazen1
Jan 20 2016 00:28
This message was deleted
Bakari Holmes
@bakarih
Jan 20 2016 00:28
Thanks @SaintPeter !
CamperBot
@camperbot
Jan 20 2016 00:28
bakarih sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2332 | @saintpeter | http://www.freecodecamp.com/saintpeter
d wilder
@alhazen1
Jan 20 2016 00:29
@ctinaa :smile:
Blauelf
@Blauelf
Jan 20 2016 00:29
@nickmask That way, you'll need to build an array of all numbers from min to max first (both including). Or you use Gauss' formula.
Edward Barton
@Incredibl3dible
Jan 20 2016 00:29
function mutation(arr) {
  var test = arr[1].toLowerCase();
  var target = arr[0].toLowerCase();

  for(var i =0; i < test.length; i++) {
    if(target.indexOf(test[i]) < 0) {
      return false;
    }
  }
  return true;
}

mutation(["hello", "hey"]);
Can somebody help me understand this code. Algorithm challenge "Mutation"
Bakari Holmes
@bakarih
Jan 20 2016 00:30

```js
// 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 update(id, prop, value) {
if ((value !== "") && (collection[id][prop] != "tracks"))
{
collection[id][prop] = value;
}
else if ((prop == "tracks" && value !== ""))
{
collection[id][prop].push(value);
}
else if ((value === ""))
{
delete collection[id][prop];
}

return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");

```Now having issues with pushing the track name onto the array. Using bracket notation but then using dot to use the push method to add the name

All cases work except when prop == "tracks" && value !="". Is my syntax correct?
Blauelf
@Blauelf
Jan 20 2016 00:31
@bakarih The if should test prop, not collection[id][prop]
d wilder
@alhazen1
Jan 20 2016 00:32
This message was deleted
Blauelf
@Blauelf
Jan 20 2016 00:32
Return is pretty breaking itself... (instantly leaves the current function)
Edward Barton
@Incredibl3dible
Jan 20 2016 00:33
@alhazen1 I got the Bonfire right, I just can't really understand why.
Bakari Holmes
@bakarih
Jan 20 2016 00:33
Thanks @Blauelf !
CamperBot
@camperbot
Jan 20 2016 00:33
bakarih sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 922 | @blauelf | http://www.freecodecamp.com/blauelf
d wilder
@alhazen1
Jan 20 2016 00:34
@Incredibl3dible On second look that is right. What are you not understanding?
Edward Barton
@Incredibl3dible
Jan 20 2016 00:36
@alhazen1 To be honest, I looked at the Github solution page. I try my best to answer a problem but as a last resort, I review the solution and type it in manually as I try to break it down (never copy and paste). I am not understanding the breakdown of this function that makes it correct
Blauelf
@Blauelf
Jan 20 2016 00:36
@Incredibl3dible First, the strings are lowercased. Would work the same when all were uppercased.
Then it loops over the characters of the second string, and for each of these characters, checks their index in the first string. If the character is found, its index will be something >=0. If it is not in the first string, result of indexOf will be -1. In that case, we can safely leave the function returning false, as the result for other characters does not matter.
If we tested all characters and we are still running the function, all characters have been found, and we can return true.
John Barbagallo
@john-barbagallo
Jan 20 2016 00:38
Hi I'm stuck on "Stand in Line" a review mod in Javascript. Would anyone take a look at my code for me?
Edward Barton
@Incredibl3dible
Jan 20 2016 00:38
@Blauelf So in my for loop, beginning at i=0, test0 = "h". target.indexOf("h") = 0??
Blauelf
@Blauelf
Jan 20 2016 00:40
For the first iteration, yes. This is not <0, so go to next character. Here target.indexOf("e") is 1, so next character. Here target.indexOf("y") is -1, so return false.
Abdulsalam Shalash
@shalashtein
Jan 20 2016 00:40

Hi,

I'm solving the functions with parameters in jS and the output of a + b is NaN even after I tried casting ther params to iunt

int*
John Barbagallo
@john-barbagallo
Jan 20 2016 00:41

function queue(arr, item) {
// Your code here
arr.push(item);
var removed = arr.shift();
return removed; // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed.

Blauelf
@Blauelf
Jan 20 2016 00:41
@shalashtein Code, please.
Edward Barton
@Incredibl3dible
Jan 20 2016 00:41
@Blauelf Ok, I wasn't understanding that once a character wasn't found in the target string, that resulted in a value of -1 (which is <0) then returns false, thus exiting the for loop. THANK YOU!!!
CamperBot
@camperbot
Jan 20 2016 00:41
incredibl3dible sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 923 | @blauelf | http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Jan 20 2016 00:42

From the docs:

The indexOf() method returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex. Returns -1 if the value is not found.

Edward Barton
@Incredibl3dible
Jan 20 2016 00:43
@Blauelf Perfect. Thanks again!
CamperBot
@camperbot
Jan 20 2016 00:43
incredibl3dible sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: incredibl3dible already gave blauelf points
Christina Cook
@ctinaa
Jan 20 2016 00:47
// Setup
var testObj = {
  "hat": "ballcap",
  "shirt": "jersey",
  "shoes": "cleats"
};

// Only change code below this line

testObj.hatValue = "jersey";      // Change this line
testObj.shirtValue = "shirt";    // Change this line
Read the values of the properties hat and shirt of testObj using dot notation.
am I using the notation wrong?
Eric Saldivar
@esaldivar
Jan 20 2016 00:50
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
if (myObj.hasOwnProperty("gift")) {
  return "pony"; }
  else if(myObj.hasOwnProperty("pet")) 
  { return "kitten";}
  else if(myObj.hasOwnProperty("bed")) {
    return "sleigh"; }
  else if(myObj.hasOwnPropert()) {
    return "Not Found";

  } 

}
// Test your code by modifying these values
checkObj("pet");
stuck :'(
Christina Cook
@ctinaa
Jan 20 2016 00:51
@esaldivar whats the problem?
Eric Saldivar
@esaldivar
Jan 20 2016 00:51
Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".
Christina Cook
@ctinaa
Jan 20 2016 00:52
the last one is else, not else if
Eric Saldivar
@esaldivar
Jan 20 2016 00:52
all checkObj("") return only pony
Kevin
@KAlanHicks
Jan 20 2016 00:54

I am stuck on Falsy Bouncer. Up to this point my code works

function bouncer(arr) {
  var filteredArr = [];
  for (var i = 0; i < arr.length; i++){
    if (arr[i] === "" || arr[i] === false || arr[i] === 0){
      arr.splice(i, 1);
    }
  }
  return arr;
}

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

However, the moment I add in || arr[i] === undefined or null, my code doesn't remove that value and adds "" back in again or if I try to get rid of NaN, nothing happens. Can anyone help me?

Also, @ctinaa you're looking for the value of a property called "hat", the property hatValue does not exist in your object. .hat however does. Does that help?
John Barbagallo
@john-barbagallo
Jan 20 2016 01:00
@KAlanHicks how do you print an image of your code like that to post on this board?
Kevin
@KAlanHicks
Jan 20 2016 01:02
@john-barbagallo click "switch to compose mode" on the far right of the bar you enter text in. Then add
```
paste your code
```
mmacedo
@mmacedoeu
Jan 20 2016 01:03
explain format
CamperBot
@camperbot
Jan 20 2016 01:03

:point_right: code formatting [wiki]

Inline code

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

Code Block

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

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

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

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

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

John Barbagallo
@john-barbagallo
Jan 20 2016 01:04
@KAlanHicks Thank you a ton!
CamperBot
@camperbot
Jan 20 2016 01:04
john-barbagallo sends brownie points to @kalanhicks :sparkles: :thumbsup: :sparkles:
:star: 261 | @kalanhicks | http://www.freecodecamp.com/kalanhicks
John Barbagallo
@john-barbagallo
Jan 20 2016 01:05
function queue(arr, item) {
  // Your code here
  arr.push(item);
  var removed = arr.shift();
  return removed;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(arr, 10)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
what am I doing wrong as I'm trying to test this "Stand in Line" function
I'm receiving a "RangeError: Maximum call stack exceeded.
Maximilian Schlosser
@maxschlosser
Jan 20 2016 01:07

I'm currently on the drop-it algorithm. The goal is to write a function that drops the first few elements of an array until the condition (func) returns true.

My test values return the correct values but the page won't accept my solution. :/ Can you see if I made an error?

function drop(arr, func) {
  while(func(arr[0]) && arr !== []){
        arr.shift();
  }
  return arr;
}

drop([1, 2, 3, 4], function(n) {return n <= 3;});
This message was deleted
Found it, sneaky ! was missing
Kevin
@KAlanHicks
Jan 20 2016 01:09
What is the goal of this one again?
@john-barbagallo
John Barbagallo
@john-barbagallo
Jan 20 2016 01:09
Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed.
Kevin
@KAlanHicks
Jan 20 2016 01:10
alright, well your shift currently has no idea what item it's meant to shift. it should be arr.shift(zeroIndexNumber)
Kevin Elser
@CoffeeCodeKevin
Jan 20 2016 01:10
Is there anyone here that can help me out with LearnYouNode? I'm on "First I/O" and I have absolutely no idea what I'm missing.
Kevin
@KAlanHicks
Jan 20 2016 01:11
Since you're after the first element in the array, which number will that be?
@keccakec Hey, nice to see you again. How far are you? I'm still stuck in the basic algorithm section
Maximilian Schlosser
@maxschlosser
Jan 20 2016 01:11
@KAlanHicks arr.shift() removes and returns the object at zeroIndex
Kevin Elser
@CoffeeCodeKevin
Jan 20 2016 01:12
@KAlanHicks You, too! I'm doing good. Finally got past algorithms and wanted to start getting a little into back end. It's kicking my ass, though.
Gil Ndjouwou
@giljuwu
Jan 20 2016 01:12
Hello, I'm pretty lost at some point in Javascript : I have no idea what "escape sequences in Strings" means and it's not clearly explained
Kevin
@KAlanHicks
Jan 20 2016 01:12
@maxschlosser Ohhh, right, that actually explains a lot of my own problems.
great! Could you help me out @keccakec ? If you scroll up you'll see where I'm having trouble.
Gil Ndjouwou
@giljuwu
Jan 20 2016 01:13
I'm in "basic javascript"
Maximilian Schlosser
@maxschlosser
Jan 20 2016 01:13
@giljuwu an escape sequence consists of the escape (usually backslash \ ) and a character that would normally have a different meaning in a string. for example, a double quotation mark " would usually end a string that begun with a double quotation mark
Kevin Elser
@CoffeeCodeKevin
Jan 20 2016 01:13
 "<Buffer 4c 65 74 73 20 67 65 74 20 73 6f 6d 65 20 62 69 7a 7a 6f 20 74 6f 20 73 68 65 27 6c 6c 20 62 65 20 72 69 67 68 74 20 61 75 73 73 69 65 20 73 61 6c 75 ... >" !=    "31"
Welp. This is the result I got vs. intended. I think I need a break from node.js for a bit before it kills me.
@KAlanHicks And sure, let me just take a look
Gil Ndjouwou
@giljuwu
Jan 20 2016 01:14
Ok @maxschlosser I get this. But what am I supposed to do when I'm asked to encode a sequence and assign it to a string? In this case the sequence is
Kevin
@KAlanHicks
Jan 20 2016 01:14
thanks! @keccakec
CamperBot
@camperbot
Jan 20 2016 01:14
kalanhicks sends brownie points to @keccakec :sparkles: :thumbsup: :sparkles:
Kevin Elser
@CoffeeCodeKevin
Jan 20 2016 01:14
@KAlanHicks You can simplify it a ton by filtering for Boolean values
CamperBot
@camperbot
Jan 20 2016 01:14
:star: 276 | @keccakec | http://www.freecodecamp.com/keccakec
Maximilian Schlosser
@maxschlosser
Jan 20 2016 01:14
@giljuwu using the escape you can still add it to your string.
var a = "String" should end here!"; //no escape, the string ends at the double quote

var a = "String\" ends here!"; //escaped, the double quote will be ignored
Kevin
@KAlanHicks
Jan 20 2016 01:15
@keccakec do I need to use .filter for that?
ulBenson
@ulbenson
Jan 20 2016 01:15
an object in array like arr=[{ first: "Romeo", last: "Montague" }]
how do I get Romeo without number
like: var str='first';
arr[i].str;
Kevin Elser
@CoffeeCodeKevin
Jan 20 2016 01:15
@KAlanHicks It took me a while to understand how booleans worked, but you can use Boolean to filter out all of those values in one filter function
@KAlanHicks That one particularly annoyed me because the page they linked on Booleans is pretty bad at explaining them so I had to look other places
Kevin
@KAlanHicks
Jan 20 2016 01:16
@keccakec Okay, could you explain filter for me? I've looked at multiple online sources and I haven't been able to make it work for me. Clearly I'm just not understanding how it works
@keccakec I believe I understand bools
Kevin Elser
@CoffeeCodeKevin
Jan 20 2016 01:17
@KAlanHicks Basically, filter will only return values of the original array into a new array that only contains values of the old array that equated to true.
Kevin
@KAlanHicks
Jan 20 2016 01:17
Wait, I just reread the booleans page. Okay, I think I see what I need to do. I assumed it was just going to talk about bools of true and false
Maximilian Schlosser
@maxschlosser
Jan 20 2016 01:18
@giljuwu If a string was created using single quotes ' all double quotes " will be ignored and vice-versa. This means you should not escape any " in this string: '<div class="container-fluid">' but have to in a string like this: "<div class=\"container-fluid\">"
Kevin Elser
@CoffeeCodeKevin
Jan 20 2016 01:18
@KAlanHicks Yeah, you just use the true/false aspect to make .filter take out all Booleans equating to false
Which results in Falsy values being removed
Kevin
@KAlanHicks
Jan 20 2016 01:20
@keccakec could you type up a line using .filter? Not the one I need, just a line so I understand how the syntax works here.
Gil Ndjouwou
@giljuwu
Jan 20 2016 01:23
Okay I get it @maxschlosser, I'm just not sure how to apply it to the present exercise.
But I will find out. Thanks a lot @maxschlosser !
CamperBot
@camperbot
Jan 20 2016 01:23
giljuwu sends brownie points to @maxschlosser :sparkles: :thumbsup: :sparkles:
:star: 297 | @maxschlosser | http://www.freecodecamp.com/maxschlosser
Kevin Elser
@CoffeeCodeKevin
Jan 20 2016 01:24

@KAlanHicks Well, outside of using things like Booleans it seems to be pretty common that you call on functions, so something like this:

function aboveThree(num) {
return num > 3;
}
var filteredFunc = [1 , 1 , 2 , 4 , 5].filter(aboveThree);

That should return just [4, 5]

Since any values that return false for it are taken out.
WHOOPS. Not strings.
Fixed
Kevin
@KAlanHicks
Jan 20 2016 01:26
Okay, thanks @keccakec . Now I just have to figure out how to resolve the items I need to true...
CamperBot
@camperbot
Jan 20 2016 01:26
kalanhicks sends brownie points to @keccakec :sparkles: :thumbsup: :sparkles:
:warning: kalanhicks already gave keccakec points
Kevin Elser
@CoffeeCodeKevin
Jan 20 2016 01:27
@KAlanHicks Over-complicating it is what got me. Just try to think of the simplest way to get the values you need.
Gil Ndjouwou
@giljuwu
Jan 20 2016 01:29
Oh my god this is driving me mad.
I hate feeling stupid like that
Kevin
@KAlanHicks
Jan 20 2016 01:30
@keccakec this returns true, shouldn't it return false?
if ("" !== false){
return "true";
or, rather, not return anything
wait, I think I figured it out
Chris Moore
@dooglus
Jan 20 2016 01:31
@KAlanHicks "" is a string, false is a boolean, so they are !==, so your return runs
Kevin
@KAlanHicks
Jan 20 2016 01:32
I just needed to change it to != apparently
Kevin Elser
@CoffeeCodeKevin
Jan 20 2016 01:32
@KAlanHicks I can say that you don't want to be using if statements at all.
At least not the way I did it.
There's likely other solutions.
Christina Cook
@ctinaa
Jan 20 2016 01:32
```

// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty("gift") === true) {
    return myObj.gift;
  } else if (myObj.hasOwnProperty("pet") === true) {
    return myObj.pet;
  } else if (myObj.hasOwnProperty("bed") === true) {
    return myObj.bed; 
  } else {
    return "Not Found";
  }

  return "Change Me!";
}

// Test your code by modifying these values
checkObj("gift");
Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".
I can only get pony because it only checks for one, so what is a way for them all to be checked? :/
Chris Moore
@dooglus
Jan 20 2016 01:34
@ctinaa you need to check for the property specified by the checkProp parameter
Christina Cook
@ctinaa
Jan 20 2016 01:35
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp) === true) {
    return myObj.hasOwnProperty;
  } else {
    return "Not Found";
  }

  return "Change Me!";
}

// Test your code by modifying these values
checkObj("gift");
Am I closer?
Chris Moore
@dooglus
Jan 20 2016 01:35
@ctinaa it might not even be one of gift, pet, or bed, so there's no use trying to list all the possible properties
@ctinaa better. you don't need to === true, hasOwnProperty itself returns a boolean
Kevin Elser
@CoffeeCodeKevin
Jan 20 2016 01:36
@dooglus Booleans haven't been explained by that point iirc
Chris Moore
@dooglus
Jan 20 2016 01:36
and you're meant to return the value of the property aren't you? so your return needs some work
@keccakec I see a true in the code... all I'm saying is that if (x === true) is equivalent to if (x) in this case
Kevin Elser
@CoffeeCodeKevin
Jan 20 2016 01:39
@dooglus I know, just wanted you to know that she may not know what you're referencing. It's good you're walking her through it in a way that doesn't just directly answer it for her. I see that often.
Kevin
@KAlanHicks
Jan 20 2016 01:39
@keccakec alright, I now have something the works for the first two examples, but not the third which I now have in my test array.
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  function filter(value){
    return value != false;
  }
  arr = arr.filter(filter);
  return arr;
}

bouncer([false, null, 0, NaN, undefined, ""]);
Chris Moore
@dooglus
Jan 20 2016 01:39
@keccakec fair enough. and yes, I understand there's little value in spoon-feeding people with answers
Kevin
@KAlanHicks
Jan 20 2016 01:40
Currently, I am getting a return of "null, null, null" with this array
which means it's not filtering out "null, undefined, or NaN"
Chris Moore
@dooglus
Jan 20 2016 01:44
@KAlanHicks that's correct - those are the three it isn't filtering. note that null != false is true
ulBenson
@ulbenson
Jan 20 2016 01:44
function where(collection, source) {
  var arr = [];
  // What'sin a name?
  var str="last";
  return collection[2].last;
}

where([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Kevin
@KAlanHicks
Jan 20 2016 01:44
@dooglus Doh! Of course. Thanks
CamperBot
@camperbot
Jan 20 2016 01:44
kalanhicks sends brownie points to @dooglus :sparkles: :thumbsup: :sparkles:
:star: 272 | @dooglus | http://www.freecodecamp.com/dooglus
Nolan A Eliason
@Naeliason
Jan 20 2016 01:45

Hey I am working on finding the length of the longest word in a string. I am getting an error 'TypeError: Cannot read property 'length' of undefined' when I run the following code: ```js
function findLongestWord(str) {
var words = str.split(" ");
var largeWord = [];
var largeWordArray = [];
for (i=0;i < words.length;i++){
if((words[i+1]).length > (words[i]).length){
largeWord = largeWordArray.push(words[i]);
}

}

return words;
}

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

```

function findLongestWord(str) {
  var words = str.split(" ");
  var largeWord = [];
  var largeWordArray = [];
  for (i=0;i < words.length;i++){
   if((words[i+1]).length > (words[i]).length){
    largeWord = largeWordArray.push(words[i]);
   } 

  }

  return words;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
ulBenson
@ulbenson
Jan 20 2016 01:45
function where(collection, source) {
  var arr = [];
  // What'sin a name?
  var str="last";
  return collection[2].last;
}

where([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
how can i replace last
use str or someother
Chris Moore
@dooglus
Jan 20 2016 01:47
@Naeliason i is looping from 0 to length-1. you can't access words[i+1], because the last time through the loop that is going past the end of the word list.
ulBenson
@ulbenson
Jan 20 2016 01:47
i mean i want use return collection[i].str
in the loop but it seems can't read collection[0].str;
Nolan A Eliason
@Naeliason
Jan 20 2016 01:48
@dooglus ok, I thought that whats the culprit, but I don't know what do instead
ulBenson
@ulbenson
Jan 20 2016 01:48
or someway to get Romeo?
kmboyle
@kmboyle
Jan 20 2016 01:49
I'm working on removing all elements from an initial array that are the same value as other arguments in the array
Kevin Elser
@CoffeeCodeKevin
Jan 20 2016 01:49
@KAlanHicks You're definitely getting closer, but I feel I should add that you can add the word Boolean itself to the filter function.
Kevin
@KAlanHicks
Jan 20 2016 01:49
@keccakec could you point me to a webpage to read on that?
Chris Moore
@dooglus
Jan 20 2016 01:50
@Naeliason what is your strategy? if you were looking for the longest word in the dictionary manually, how would you do it? describe your strategy precisely
kmboyle
@kmboyle
Jan 20 2016 01:50
I'm working on understanding argument objects and array.filter
I guess I can assign the arguments variables within the function
Chris Moore
@dooglus
Jan 20 2016 01:51
@kmboyle you can
kmboyle
@kmboyle
Jan 20 2016 01:51
but that doesn't cover the possibility of a 3rd variable from being added, and not accounted for
Kevin
@KAlanHicks
Jan 20 2016 01:51
Wait, I just made a solution that works @keccakec . Could I see yours so I get a better understanding of this?
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  function filter(value){
    if (value != null && value != false){
      return value;
    }
  }
  arr = arr.filter(filter);
  return arr;
}


bouncer([false, null, 0, NaN, undefined, ""]);
Chris Moore
@dooglus
Jan 20 2016 01:52
@KAlanHicks this is mine:
return arr.filter(function(a) { return a; });
Kevin Elser
@CoffeeCodeKevin
Jan 20 2016 01:52
@KAlanHicks Because Boolean can work as a function as seen here http://www.w3schools.com/js/js_booleans.asp, I just did this


function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var negativesOut = arr.filter(Boolean);
  return negativesOut;
}


bouncer([7, "ate", "", false, 9]);
Kevin
@KAlanHicks
Jan 20 2016 01:52
Really, it's that simple?
facepalm
Chris Moore
@dooglus
Jan 20 2016 01:53
@KAlanHicks you're overthinking it - to filter out the ones that aren't 'truthy', just return them - that's what filter does
Nolan A Eliason
@Naeliason
Jan 20 2016 01:53
@dooglus I was trying to do a comparison, starting with the first word in the array, and comparing each word to it and if the word is larger save it, but now I realize this is not working.
Kevin Elser
@CoffeeCodeKevin
Jan 20 2016 01:53
@KAlanHicks Overcomplication is definitely a killer on the algorithms. There was only one that ended up being more complicated than I originally thought and not less.
Kevin
@KAlanHicks
Jan 20 2016 01:53
Well, at least I found a solution that works without seeing someone else's. Thanks for showing me yours @dooglus @keccakec
CamperBot
@camperbot
Jan 20 2016 01:53
kalanhicks sends brownie points to @dooglus and @keccakec :sparkles: :thumbsup: :sparkles:
:warning: kalanhicks already gave dooglus points
:warning: kalanhicks already gave keccakec points
Kevin Elser
@CoffeeCodeKevin
Jan 20 2016 01:54
@KAlanHicks No problem, it's good to understand that there's multiple ways to reach almost any solution.
trois3
@trois3
Jan 20 2016 01:54

wondering what's wrong with my answer var myVar = 87;

// Only change code below this line
myVar = myVar++;

Kevin Elser
@CoffeeCodeKevin
Jan 20 2016 01:54
Time to go back to making my Simon game. Node has numbed my mind too much to continue it tonight.
d wilder
@alhazen1
Jan 20 2016 01:54
@trois3 try just myVar++;
Chris Moore
@dooglus
Jan 20 2016 01:54
@Naeliason I think it helps to think how you would do it yourself, for a long wordlist. Imagine you had to find the longest word in the dictionary. Would you compare the length of each word with the length of the next word? I don't think so
@trois3 ++ doesn't need assignment. it modifies the variable itself
kmboyle
@kmboyle
Jan 20 2016 01:55
so array.filter() creates a new array with all elements that pass the implemented test by the function
trois3
@trois3
Jan 20 2016 01:55
thanks all. that did the trick. i appreciate the explanation as well
kmboyle
@kmboyle
Jan 20 2016 01:56
so to create the test, I need to set up a function
d wilder
@alhazen1
Jan 20 2016 01:56
@kmboyle BINGO!
Nate Kimball
@natetonal
Jan 20 2016 01:56
Can someone help me with the steamroller challenge? I believe I solved it, as when I enter each of the possible test cases manually they resolve to a correct answer, but it's not clearing me for some reason. Here's the code:
var newArr = [];

function steamroller(arr) {
  // I'm a steamroller, baby
  arr.map(function clearArrs(val){
    if(Array.isArray(val)){
      val.map(clearArrs);
    } else {
      newArr.push(val);
    }
  });

  return newArr;

}

steamroller([[["a"]], [["b"]]]);
d wilder
@alhazen1
Jan 20 2016 01:56
@kmboyle that returns either true or false
kmboyle
@kmboyle
Jan 20 2016 01:57
inside the function, I create a variable, and a condition
ok, filter returns an array that passes the test
does that mean the function evaluates true?
So if i want to test if an argument is equal to a value in another argument, the function needs to test if the argument equals the value?
Then that would return true, but I want the array to exclude this argument
Christina Cook
@ctinaa
Jan 20 2016 01:59
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp)) {
    return myObj.hasOwnProperty;
  } else {
    return "Not Found";
  }

  return "Change Me!";
}

// Test your code by modifying these values
checkObj("gift");
d wilder
@alhazen1
Jan 20 2016 01:59
@kmboyle reverse the logic then so it returns false
Christina Cook
@ctinaa
Jan 20 2016 02:00
I can't figure out why the other properties arent showing
kmboyle
@kmboyle
Jan 20 2016 02:00
ok, so if the function evaluates to true, then this is false, and the filter will not reproduce this argument in the new array?
Kalu_Gansito
@TheCCancino
Jan 20 2016 02:00
Friends, I can’t make it work at all….I’ve tried with a For loop this time, which it’s almost working but the last ‘if’ is just not working
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    },
];


function lookUp(firstName, prop){
// Only change code below this line
var i=0;
  for (i=0; i < contacts.length;i++){
   if (firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop)){
     return contacts[i][prop];
   } else if (firstName === contacts[i].firstName && !contacts[i].hasOwnProperty(prop)){
     return "No such property";
   } //Up to here, both validations worked fine, but then adding the one below, caused the entire thing to fail.
    if (firstName !== contacts[i].firstName){ //Adding this last 'if' causes the code to output 'No such contact when in fact the contact does exists.
     return "No such contact";
   }
  }
// Only change code above this line
}


// Change these values to test your function
lookUp("Kristian", "likes");
d wilder
@alhazen1
Jan 20 2016 02:01
@kmboyle no, if your test evaluates to true that element gets passed to the new array
Christina Cook
@ctinaa
Jan 20 2016 02:02
just kidding got it
kmboyle
@kmboyle
Jan 20 2016 02:03
function destroyer(arr) {
   Array.prototype.slice.call(arguments);
   var i;  
  function compare (equalled){
      for (i>0; i<=argument.length; i++)
           if (arr!=argument[i]);
              return true;
        }


  return arr.filter(compare);// Remove all the values
  }

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Nate Kimball
@natetonal
Jan 20 2016 02:03
@TheCCancino did you try putting the trouble line inside of an "else" bracket at the end of your if-else if chain?
d wilder
@alhazen1
Jan 20 2016 02:04
@kmboyle Think of it like this
newArray = oldArray.filter( function(element){
   if( element === good ){ // some test
      return true;  //pass
   }
   else{
      return false; //fail
   }
});
Kalu_Gansito
@TheCCancino
Jan 20 2016 02:04
@natetonal yup, same result
kmboyle
@kmboyle
Jan 20 2016 02:04
ah
d wilder
@alhazen1
Jan 20 2016 02:04
This message was deleted
ulBenson
@ulbenson
Jan 20 2016 02:05
function where(collection, source) {
  var arr = [];
  // What's in a name?
  return arr;
}

where([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
how to get Romeo ?
Kelly C
@kmcmcurtis7
Jan 20 2016 02:05
@keccakec Would you please be so kind and point out what is wrong with my code for the Return Early Pattern for Functions? When I run the test the answer is correct, but not completing the exercise as finished.
// Setup
function abTest(a, b) {
  // Only change code below this line

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

  // Only change code above this line

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

// Change values below to test your code
abTest(2,-2);
d wilder
@alhazen1
Jan 20 2016 02:06
@kmboyle which could be shortened like this
newArray = oldArray.filter( function(element){
   return ( element === good ); //test
});
Chris Moore
@dooglus
Jan 20 2016 02:06
@ulbenson Romeo is the value of the first member of the 1st element of the array
@ulbenson so first of all, can you get { first: "Romeo", last: "Montague" }?
kmboyle
@kmboyle
Jan 20 2016 02:08
ok, so if the test is to see if one argument contains another argument, then pass/true would mean it does not, right? So I can return an array with the variables that are not equal
Nate Kimball
@natetonal
Jan 20 2016 02:08
@TheCCancino hmmm... did you try maybe something like this?
ulBenson
@ulbenson
Jan 20 2016 02:08
@dooglus I know I can get it with collection[0].first;
but it wnats us to compare so how can i compare in loop without first or last?
Nate Kimball
@natetonal
Jan 20 2016 02:08
whoops
hold that thought, that won't work.
Chris Moore
@dooglus
Jan 20 2016 02:08
@ulbenson can you link me to the question?
Kalu_Gansito
@TheCCancino
Jan 20 2016 02:08
@natetonal no, let me try
thanks
Jon
@jcmockbee
Jan 20 2016 02:09
Hi hoping someone can help these are the instructions
myStr should have the escape sequences for backslash tab tab carriage-return new-line separated by spaces
this is the code I put in var myStr= "\backslash\ \ttab\t \ttab\t \rcarriage-return\r \nnew-line\n";
Nate Kimball
@natetonal
Jan 20 2016 02:10
@TheCCancino this would work, I think:
for (i = 0; i < contacts.length; i++){
  if(firstName === contacts[i].firstName){
    if (contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    } else {
      return "No such property";
    }
  } else {
    if(i === contacts.length - 1){ return "No such contact"; }
  }
}
Jon
@jcmockbee
Jan 20 2016 02:10
it doesnt seem to be working
Nate Kimball
@natetonal
Jan 20 2016 02:10
That way, it will only return no such contact if it's reached the end of the loop without a match.
d wilder
@alhazen1
Jan 20 2016 02:11
@kmboyle It all depends on your test return ( element === good ); and which you want to keep and which you want to discard. Ultimately you want your test to be true for any elements you want to keep in you new array.
Chris Moore
@dooglus
Jan 20 2016 02:11
@ulbenson ooh, fancy. I didn't get that far yet :)
Kelly C
@kmcmcurtis7
Jan 20 2016 02:11
Would someone please be so kind and point out what is wrong with my code for the Return Early Pattern for Functions? When I run the test the answer is correct, but not completing the exercise as finished.
// Setup
function abTest(a, b) {
  // Only change code below this line

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

  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
kmboyle
@kmboyle
Jan 20 2016 02:12
@alhazen1 thanks
CamperBot
@camperbot
Jan 20 2016 02:12
kmboyle sends brownie points to @alhazen1 :sparkles: :thumbsup: :sparkles:
:star: 272 | @alhazen1 | http://www.freecodecamp.com/alhazen1
ulBenson
@ulbenson
Jan 20 2016 02:13
@dooglus okay
thank you .
CamperBot
@camperbot
Jan 20 2016 02:13
ulbenson sends brownie points to @dooglus :sparkles: :thumbsup: :sparkles:
:star: 273 | @dooglus | http://www.freecodecamp.com/dooglus
Kalu_Gansito
@TheCCancino
Jan 20 2016 02:13
@natetonal it worked!!! ᕦ( ̿ ﹏ ̿ )ᕤ but why?, I don’t get the last if….can you explain?
Fantop
@Fantop
Jan 20 2016 02:13
@jcmockbee try setting myStr to "\ \t \t \r \n"
Mark Lawrence
@ninja-ml
Jan 20 2016 02:13
I'm working on Sum All Numbers in a Range and my code works on repl.it but doesn't pass at all in Free Code Camp... can anyone see why? Thanks.
function sumAll(arr) {
  var max = Math.max.apply(Math, arr);
  var min = Math.min.apply(Math, arr);
  var newArr = [];

  for (var i = min; i <= max; i ++) {
    newArr.push(i);
  }

  var sum = newArr.reduce(function(previous, current) {
  return previous + current;
  });
  console.log(sum);
}

sumAll([1, 4]);
d wilder
@alhazen1
Jan 20 2016 02:13
@kmboyle here is example from MDN
filter
function isBigEnough(value) {
  return value >= 10;
}
var filtered = [12, 5, 8, 130, 44].filter(isBigEnough);
// filtered is [12, 130, 44]
Yosafat Ariel
@yoskakomba
Jan 20 2016 02:13
Hi guys, please need help, reviewing my code, I don't know what's wrong with my code on waypoint http://www.freecodecamp.com/challenges/nesting-for-loop
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for(var i = 0; i < arr.length; i++) {
    for(var j = 0; j < arr[i].length; j++);
      console.log(arr[i][j]);
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Kalu_Gansito
@TheCCancino
Jan 20 2016 02:13
@natetonal and boot is suggesting to chat on private!
Jon
@jcmockbee
Jan 20 2016 02:14
Ill try that now
kmboyle
@kmboyle
Jan 20 2016 02:14
Yea, I was looking at that. That's good. But I read somewhere that the arguments need to be converted to array's. Is Array.prototype.slice.call(arguments); sufficient?
Kelly C
@kmcmcurtis7
Jan 20 2016 02:15
@alhazen1 Would you be able to help me please?
d wilder
@alhazen1
Jan 20 2016 02:16
@kmboyle Yeah, filter takes arrays but you're testing an array aren't you?
Jon
@jcmockbee
Jan 20 2016 02:16
Thankyou Fantop it worked!!!!!!!!!!!!
Fantop
@Fantop
Jan 20 2016 02:16
No problem ;)
Pandarati
@Pandarati
Jan 20 2016 02:16
@yoskakomba Your code works.
d wilder
@alhazen1
Jan 20 2016 02:17
@kmcmcurtis7 maybe - what you stuck on?
kmboyle
@kmboyle
Jan 20 2016 02:17
Yea, I guess they are already arrays
d wilder
@alhazen1
Jan 20 2016 02:17
@kmboyle You're close to getting this so I don't want to spoil it by giving the solution
Yosafat Ariel
@yoskakomba
Jan 20 2016 02:17
@Pandarati but why it was saying error? is there a bug?
kmboyle
@kmboyle
Jan 20 2016 02:18
yea, I want to work it out
thanks, you gave me some good help. I'm going to work on it some more
Kelly C
@kmcmcurtis7
Jan 20 2016 02:19
@alhazen1 Nevermind. I just found another that had the same issue and it is just I have "undefined" instead of 'undefined'. I just had to ask someone for me to find the prob. Thanks!!
CamperBot
@camperbot
Jan 20 2016 02:19
kmcmcurtis7 sends brownie points to @alhazen1 :sparkles: :thumbsup: :sparkles:
:star: 273 | @alhazen1 | http://www.freecodecamp.com/alhazen1
Pandarati
@Pandarati
Jan 20 2016 02:19
@yoskakomba You might want to refresh there is no error. Well , at least not one directly related to your code. It's fine.
Christina Cook
@ctinaa
Jan 20 2016 02:19
// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line
var gloveBoxContents = myStorage.car.inside.['glove box'];
Access the myStorage JSON object to retrieve the contents of the glove box. Only use object notation for properties with a space in their name.
Eric Saldivar
@esaldivar
Jan 20 2016 02:19
need alittle help with Testing Objects for Properties
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
 if (checkObj.hasOwnProperty("gift")) {
return "pony"; } else {

}

  return "Not Found!";
}

// Test your code by modifying these values
checkObj("gift");

`
Christina Cook
@ctinaa
Jan 20 2016 02:20
@esaldivar don't check for each property. Use checkProp instead
if (checkObj.hasOwnProperty(checkProp)) {}
oh noo
Pandarati
@Pandarati
Jan 20 2016 02:21
@esaldivar You are checking the property on a text variable that was passed to the function. Check it with myObj. `myObj.hasOwnProperty("");
Christina Cook
@ctinaa
Jan 20 2016 02:21
myObj.hasOwnProperty(checkProp);
can someone help me with JSON? I don't know how to grab maps
Pandarati
@Pandarati
Jan 20 2016 02:22
@ctinaa I am stuck on the same thing. Weather App Zipline?
Christina Cook
@ctinaa
Jan 20 2016 02:22
Noo the Accesssing Nested Objects in JSON
Kelly C
@kmcmcurtis7
Jan 20 2016 02:23

@alhazen1 That didn't resolve the problem. When I run the tests, the test runs fine. However it is not moving me on to the next exercise. This is for the Return Early Pattern for Functions exercise. Here is the code:
// Setup
function abTest(a, b) {
// Only change code below this line

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

// Only change code above this line

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

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

Pandarati
@Pandarati
Jan 20 2016 02:23
@ctinaa Ok. Let me look at it
Kelly C
@kmcmcurtis7
Jan 20 2016 02:23
@alhazen1 Instructions for it is: Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
Pandarati
@Pandarati
Jan 20 2016 02:24
@kmcmcurtis7 return undefined the string? Or undefined the data type? :)
Pablo K
@pablok47
Jan 20 2016 02:25
can someone Please help with challenge "Profile Lookup"
this is my code...
function lookUp(firstName, prop){
// Only change code below this line
  if (firstName === "firstName" && prop === contacts) {
    contacts[firstName][prop] = value;
  } if (firstName !== "firstName"){
    return "No such contact";
  } else if (prop !== ""){
    return "No such property";
  }


  return contacts;
// Only change code above this line
}
Yosafat Ariel
@yoskakomba
Jan 20 2016 02:25
Hi guys, please need help reviewing error on my code
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for(var i = 0; i < arr.length; i++) {
    for(var j = 0; j < arr[i].length; j++);
      console.log(arr[i][j]);
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
var product = multiplyAll([[1,2],[3,4],[5,6]]);
Kelly C
@kmcmcurtis7
Jan 20 2016 02:25
@Pandarati It just states with a value of undefined. I would assume string, but I could be wrong.
d wilder
@alhazen1
Jan 20 2016 02:26
@kmcmcurtis7 That just means if a or if b is less than zero you return
Pandarati
@Pandarati
Jan 20 2016 02:26
@kmcmcurtis7 Try returning just undefined without the quotes
d wilder
@alhazen1
Jan 20 2016 02:26
return;
Pandarati
@Pandarati
Jan 20 2016 02:26
@ctinaa What's the name of the challenge?
Kelly C
@kmcmcurtis7
Jan 20 2016 02:27
@Pandarati Thanks! That was it. Argh! That was so simple and I made it so hard.
CamperBot
@camperbot
Jan 20 2016 02:27
kmcmcurtis7 sends brownie points to @pandarati :sparkles: :thumbsup: :sparkles:
:star: 318 | @pandarati | http://www.freecodecamp.com/pandarati
Kelly C
@kmcmcurtis7
Jan 20 2016 02:27
@alhazen1 Also thanks for the help!!
CamperBot
@camperbot
Jan 20 2016 02:27
kmcmcurtis7 sends brownie points to @alhazen1 :sparkles: :thumbsup: :sparkles:
:warning: kmcmcurtis7 already gave alhazen1 points
Eric Saldivar
@esaldivar
Jan 20 2016 02:27
myObj.hasOwnProperty(checkProp);
??? it's not returning any values
Christina Cook
@ctinaa
Jan 20 2016 02:28
// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line
var gloveBoxContents = myStorage.car.inside.['glove box']; 
return gloveBoxContents;
It says to Access the myStorage JSON object to retrieve the contents of the glove box. Only use object notation for properties with a space in their name.
d wilder
@alhazen1
Jan 20 2016 02:28
@esaldivar You might need to show more code
Christina Cook
@ctinaa
Jan 20 2016 02:28
it keeps giving me an error :(
Andrew Bales
@agbales
Jan 20 2016 02:28
@esaldivar .hasOwnProperty should return a boolean value
Pandarati
@Pandarati
Jan 20 2016 02:28
@esaldivar It returns true or false. If it has this value. Return True. If not. Return false.
Eric Saldivar
@esaldivar
Jan 20 2016 02:28
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  myObj.hasOwnProperty(checkProp);


}

// Test your code by modifying these values
checkObj("gift");
Andrew Bales
@agbales
Jan 20 2016 02:29
In this code you're checking to see if myObj has gift as a prop
this will respond yes/no
Pandarati
@Pandarati
Jan 20 2016 02:30
@ctinaa What challenge is it? I don't see any of them that use maps. I know that one uses forEach. Is that the one?
Christina Cook
@ctinaa
Jan 20 2016 02:31
Accessing Nested Objects in JSON
Eric Saldivar
@esaldivar
Jan 20 2016 02:31
i dont know how to get it to respond with it's prop if it's true
Pandarati
@Pandarati
Jan 20 2016 02:32
@ctinaa I think I know what you are stuck on. Basically when the property has a space you have to use [] notation.
Christina Cook
@ctinaa
Jan 20 2016 02:32
I did right?
``
var gloveBoxContents = myStorage.car.inside.['glove box'];
return gloveBoxContents;
@esaldivar which lesson is that
Pandarati
@Pandarati
Jan 20 2016 02:33
@ctinaa There is no . when using [] notation
Christina Cook
@ctinaa
Jan 20 2016 02:33
ohhh
Eric Saldivar
@esaldivar
Jan 20 2016 02:33
@ctinaa Testing Objects for Properties
Christina Cook
@ctinaa
Jan 20 2016 02:33
@Pandarati haha thanks!
CamperBot
@camperbot
Jan 20 2016 02:33
ctinaa sends brownie points to @pandarati :sparkles: :thumbsup: :sparkles:
:star: 319 | @pandarati | http://www.freecodecamp.com/pandarati
Yosafat Ariel
@yoskakomba
Jan 20 2016 02:33

@Pandarati, I still have error, if you don't mind reviewing my error

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

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

Thanks

CamperBot
@camperbot
Jan 20 2016 02:33
yoskakomba sends brownie points to @pandarati :sparkles: :thumbsup: :sparkles:
:star: 320 | @pandarati | http://www.freecodecamp.com/pandarati
Christina Cook
@ctinaa
Jan 20 2016 02:34
@esaldivar
function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp)===true){
    return myObj[checkProp];
  }
  else{
    return "Not Found";
  }
}
Chris Moore
@dooglus
Jan 20 2016 02:34
http://www.freecodecamp.com/challenges/sum-all-numbers-in-a-range is asking me to sum the numbers in a range, and suggests I use reduce() - I can't see how reduce() is useful. Can you?
reduce() works on an array, and I don't have an array of values to sum, just endpoints. is it suggesting I make an array, then 'reduce' it?
Pandarati
@Pandarati
Jan 20 2016 02:35
@yoskakomba You are just outputting each value now. The way you had it before was correct. Multiplying each element by product.
Eric Saldivar
@esaldivar
Jan 20 2016 02:35
@ctinna Thanks!
CamperBot
@camperbot
Jan 20 2016 02:35
esaldivar sends brownie points to @ctinna :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for ctinna
The Zohan
@TheZohan96
Jan 20 2016 02:36
stuck on waypoint Testing Objects for Properties
if(myObj.hasOwnProperty(checkProp)=== true){
return myObj.checkProp;
}
else {return "Not Found";}
whats wrong
David Williams
@DavidVWilliams
Jan 20 2016 02:36
```js
// 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");
```
I don't understand what to do with the val parameter in this function. Any help offered it appreciated.
Eric Saldivar
@esaldivar
Jan 20 2016 02:37
@TheZohan96 return myObj[checkProp];
Christina Cook
@ctinaa
Jan 20 2016 02:37
@DavidVWilliams whats the insructions
Yosafat Ariel
@yoskakomba
Jan 20 2016 02:37
@Pandarati, yes I changed back but it's still error, is it possible that I got bug?
David Williams
@DavidVWilliams
Jan 20 2016 02:37
@ctinaa Instructions
Convert the switch statement into a lookup table called lookup. Use it to lookup val and return the associated string.
Pandarati
@Pandarati
Jan 20 2016 02:38
@DavidVWilliams For this challenge, you are looping through the lookup object to see which values equals the "val" parameter that was passed.
Christina Cook
@ctinaa
Jan 20 2016 02:38
first convert it to a switch statement, then use the variable lookup to find the value and return the string associated to the value
Chris Moore
@dooglus
Jan 20 2016 02:38
@TheZohan96 when you say .checkProp you are looking for a property called checkProp, but checkProp is a variable whose value is the name of the property - so use [] instead
The Zohan
@TheZohan96
Jan 20 2016 02:38
@esaldivar thanks
CamperBot
@camperbot
Jan 20 2016 02:38
thezohan96 sends brownie points to @esaldivar :sparkles: :thumbsup: :sparkles:
:star: 216 | @esaldivar | http://www.freecodecamp.com/esaldivar
The Zohan
@TheZohan96
Jan 20 2016 02:39
@dooglus thanks
CamperBot
@camperbot
Jan 20 2016 02:39
thezohan96 sends brownie points to @dooglus :sparkles: :thumbsup: :sparkles:
:star: 275 | @dooglus | http://www.freecodecamp.com/dooglus
Pandarati
@Pandarati
Jan 20 2016 02:39
@yoskakomba The original way worked for me. It passed me on. You should be able to pass the challenge. Did you try refreshing?
matthew3454
@matthew3454
Jan 20 2016 02:40
Can someone please help me with the waypoint: Manipulate Arrays With unshift?
David Williams
@DavidVWilliams
Jan 20 2016 02:40
thanks @ctinaa, that points me in the right direction. The requirement is to convert the switch statement to a lookup table.
CamperBot
@camperbot
Jan 20 2016 02:40
davidvwilliams sends brownie points to @ctinaa :sparkles: :thumbsup: :sparkles:
:star: 186 | @ctinaa | http://www.freecodecamp.com/ctinaa
Andrew Bales
@agbales
Jan 20 2016 02:40
@matthew3454 Sure-- where are you stuck?
Christina Cook
@ctinaa
Jan 20 2016 02:40
@DavidVWilliams no problem :)
erika
@erikasf
Jan 20 2016 02:41
Hi, i'm refreshing my javascript for fun and i know how to do a forloop but i'm wondering what i'm doing wrong here. I've tried it on jsbin and jsfiddle and get the right result which is 20, anyone know why it isn't passing on the site?
// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

for (var i = 0; i < ourArr.length; i++) {
  ourTotal += ourArr[i];
}

// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line


var total = 0;
var myTotal = function(myArr){
  for(var i = 0; i <= myArr.length-1; i++){
    total += myArr[i];
  }
   console.log(total);

};
matthew3454
@matthew3454
Jan 20 2016 02:41

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

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

// Only change code below this line.
myArray.unshift('Paul');
```

Christina Cook
@ctinaa
Jan 20 2016 02:41
Have you tried debugging? @erikasf
erika
@erikasf
Jan 20 2016 02:42
and it pasted someone elses code sorry
matthew3454
@matthew3454
Jan 20 2016 02:42
This is what I'm supposed to do : myArray should now have [["Paul", 35], ["dog", 3]]).
erika
@erikasf
Jan 20 2016 02:42
yes, i have and not had anything that pops up as an error.
Jose Ceballos
@lazypepe
Jan 20 2016 02:43
hey guys quick question how do you get rid of undefined elements in a array?
Andrew Bales
@agbales
Jan 20 2016 02:43
@matthew3454 It looks like you need to pass an array into .unshift() -- right now you're just passing in 'paul'
Jose Ceballos
@lazypepe
Jan 20 2016 02:43
function rot13(str) { // LBH QVQ VG!
  var arr = [];
  var result;
  var offset =13;
  var lowerRange= 65;
  var upperRange=90;
  for(var i=0; i<str.length; i++){
    if(str.charCodeAt(i)<lowerRange || str.charCodeAt(i)>upperRange) //range from A-Z in ASCII
      arr.push(str.charCodeAt(i));
    else{
      if(str.charCodeAt(i)+offset>upperRange){
        arr.push(str.charCodeAt(i)+offset-upperRange+lowerRange-1); 
        //lowerRange-1 as to not include the letter A from the start
      }else
        arr.push(str.charCodeAt(i)+offset);
    }
    //To shift out the undefined char when instantiating the array
    //arr.shift();
    result += String.fromCharCode(arr[i]);
  }
  console.log(result);
  return result;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Pandarati
@Pandarati
Jan 20 2016 02:43
@erikasf Sometimes the site can be glitchy. Did you try refreshing in FreeCodeCamp?
matthew3454
@matthew3454
Jan 20 2016 02:43
like this?: myArray.unshift("Paul", 35); @agbales
Andrew Bales
@agbales
Jan 20 2016 02:44
@matthew3454 very close:
myArray.unshift(["Paul",35]);
erika
@erikasf
Jan 20 2016 02:44

```
// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line

var total = 0;
var myTotal = function(myArr){
for(var i = 0; i <= myArr.length-1; i++){
total += myArr[i];
}
console.log(total);

};

@Pandarati oh, well now let me try that

thanks for the suggestion

CamperBot
@camperbot
Jan 20 2016 02:44
erikasf sends brownie points to @pandarati :sparkles: :thumbsup: :sparkles:
Jose Ceballos
@lazypepe
Jan 20 2016 02:44
im trying to get rid of the undefined variable in the zero index of my array. How do i do that?
CamperBot
@camperbot
Jan 20 2016 02:44
:star: 321 | @pandarati | http://www.freecodecamp.com/pandarati
erika
@erikasf
Jan 20 2016 02:44
shoot sorry about that.. and nope, refreshing doesn't help
matthew3454
@matthew3454
Jan 20 2016 02:44
@agbales Thank you
ulBenson
@ulbenson
Jan 20 2016 02:44
@dooglus in the freecodecamp thay suggest may useless but if goto MDN to see how the methon works maybe next time you will thnak their suggestinon
matthew3454
@matthew3454
Jan 20 2016 02:44
Thank you @agbales
CamperBot
@camperbot
Jan 20 2016 02:44
matthew3454 sends brownie points to @agbales :sparkles: :thumbsup: :sparkles:
:star: 290 | @agbales | http://www.freecodecamp.com/agbales
Chris Moore
@dooglus
Jan 20 2016 02:45
@ulbenson OK, thanks
CamperBot
@camperbot
Jan 20 2016 02:45
dooglus sends brownie points to @ulbenson :sparkles: :thumbsup: :sparkles:
:star: 270 | @ulbenson | http://www.freecodecamp.com/ulbenson
Adam Yuhasz
@jayuhasz
Jan 20 2016 02:45
function reverseString(str) {
  var splitArray = str.split('');
  var revArray = splitArray.reverse();
  var joinArray = revArray.join('');
  return joinArray;
}

reverseString("Hello");
This works for reversing a string, but it seems so clunky. Is there a better way to do this?
erika
@erikasf
Jan 20 2016 02:45
well, i guess i'll just move along since it doesn't stop me from anything. just frustrating since i know it works. thanks anyways.
Pandarati
@Pandarati
Jan 20 2016 02:47
@jayuhasz This is a pretty efficient way to my knowledge.
Andrew Bales
@agbales
Jan 20 2016 02:48
@jayuhasz You're right that .reverse() would work on an array efficiently. Interesting to think about a better method for a string.
Adam Yuhasz
@jayuhasz
Jan 20 2016 02:49
ahh, I'm an idiot, I don't need to declare all that.
Andrew Bales
@agbales
Jan 20 2016 02:50
@jayuhasz Did you go with str.split('').reverse().join(''); ?
Adam Yuhasz
@jayuhasz
Jan 20 2016 02:51
@agbales yup! haha
Andrew Bales
@agbales
Jan 20 2016 02:51
:)
Still feels excessive, doesn't it? But makes sense.
CanGumby
@CanGumby
Jan 20 2016 02:51
Anyone do the "Profile Lookup" challenge? I'm super confused on where to even start with this one.
Andrew Bales
@agbales
Jan 20 2016 02:51
@CanGumby Yes, where are ya at on it?
Pandarati
@Pandarati
Jan 20 2016 02:52
wiki profile lookup
CamperBot
@camperbot
Jan 20 2016 02:52

:point_right: checkpoint profile lookup [wiki]

Checkpoint: Profile Lookup

Instructions

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

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

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

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

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

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

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

:pencil: read more about checkpoint profile lookup on the FCC Wiki

CanGumby
@CanGumby
Jan 20 2016 02:52
I'm having trouble starting it to be honest. I'll check out that wiki though.
Andrew Bales
@agbales
Jan 20 2016 02:53
@CanGumby Okay, if you get stick give me a shout.
Adam Yuhasz
@jayuhasz
Jan 20 2016 02:53
@agbales yeah, I feel there's gotta be a more generalist way not using the in-baked functions. I have visions of a sort of for loop counting down and "pushing" to an array then joining that.
Pablo K
@pablok47
Jan 20 2016 02:53
@agbales I am having trouble with Profile Lookup as well
this is my code...
function lookUp(firstName, prop){
// Only change code below this line
  if (firstName === "firstName" && prop === contacts) {
    contacts[firstName][prop] = value;
  } if (firstName !== "firstName"){
    return "No such contact";
  } else if (prop !== ""){
    return "No such property";
  }


  return contacts;
// Only change code above this line
}
Andrew Bales
@agbales
Jan 20 2016 02:54
@pablok47 So, you'll want to loop through ALL of your contacts to see if the first name matches, right? Perhaps star with a for loop?
*start
Pablo K
@pablok47
Jan 20 2016 02:55
got it
thanks @agbales
CamperBot
@camperbot
Jan 20 2016 02:55
pablok47 sends brownie points to @agbales :sparkles: :thumbsup: :sparkles:
:star: 291 | @agbales | http://www.freecodecamp.com/agbales
Eric Saldivar
@esaldivar
Jan 20 2016 02:56
Having trouble with accessing nested arrays in JSON
// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

var secondTree = myPlants.trees[1]; // Change this line
Damon
@drbree82
Jan 20 2016 02:57
Why is the jQuery section so limited?
It leaves a lot out
Christina Cook
@ctinaa
Jan 20 2016 02:57
myPlants1.list1;
@esaldivar
oh man
Jose Ceballos
@lazypepe
Jan 20 2016 02:57

hey can anyone help me? I'm having trouble getting rid of an undefined value in my array. ```js
function rot13(str) { // LBH QVQ VG!
var arr = [];
var result;
var offset =13;
var lowerRange= 65;
var upperRange=90;
for(var i=0; i<str.length; i++){ if(str.charCodeAt(i)<lowerRange || str.charCodeAt(i)>upperRange) //range from A-Z in ASCII
arr.push(str.charCodeAt(i));
else{
if(str.charCodeAt(i)+offset>upperRange){
arr.push(str.charCodeAt(i)+offset-upperRange+lowerRange-1);
//lowerRange-1 as to not include the letter A from the start
}else
arr.push(str.charCodeAt(i)+offset);
}
//To shift out the undefined char when instantiating the array
//if(i===0)
// arr.shift();
result += String.fromCharCode(arr[i]);
}
console.log(result);
return result;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

```

Christina Cook
@ctinaa
Jan 20 2016 02:57
myPlants[1].list[1];
Jose Ceballos
@lazypepe
Jan 20 2016 02:58
function rot13(str) { // LBH QVQ VG!
  var arr = [];
  var result;
  var offset =13;
  var lowerRange= 65;
  var upperRange=90;
  for(var i=0; i<str.length; i++){
    if(str.charCodeAt(i)<lowerRange || str.charCodeAt(i)>upperRange) //range from A-Z in ASCII
      arr.push(str.charCodeAt(i));
    else{
      if(str.charCodeAt(i)+offset>upperRange){
        arr.push(str.charCodeAt(i)+offset-upperRange+lowerRange-1); 
        //lowerRange-1 as to not include the letter A from the start
      }else
        arr.push(str.charCodeAt(i)+offset);
    }
    //To shift out the undefined char when instantiating the array
    //if(i===0)
    //  arr.shift();
    result += String.fromCharCode(arr[i]);
  }
  console.log(result);
  return result;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Eric Saldivar
@esaldivar
Jan 20 2016 02:58
@ctinaa Thanks!
CamperBot
@camperbot
Jan 20 2016 02:58
esaldivar sends brownie points to @ctinaa :sparkles: :thumbsup: :sparkles:
:star: 188 | @ctinaa | http://www.freecodecamp.com/ctinaa
The Zohan
@TheZohan96
Jan 20 2016 02:58
having trouble on accesing nested obj in Json
var gloveBoxContents = myStorage.car.inside.glovebox; gives a correct statement
but the code has to be in dot n bracket notation
but using bracket notation the compiler gives an error
var gloveBoxContents=myStorage["car"].inside["glovebox"];
error shows ['car'] is better writtn in dot notation
Christina Cook
@ctinaa
Jan 20 2016 02:59
@TheZohan96
var gloveBoxContents = myStorage.car.inside["glovebox"];
?
I don't remember the actual code. you need to post that @TheZohan96
Andrew Bales
@agbales
Jan 20 2016 02:59
@jayuhasz So, just for fun I tried to write that reversing loop. It's pretty long and ridiculous, but hey :)
function reverse(str) {

  var reverseString = [];

  for (var i = 0; i < str.length; i++) {
      reverseString.push(str[i]);
  }

  return reverseString.reverse().join();
}

reverse("alongstring");
d wilder
@alhazen1
Jan 20 2016 02:59
@TheZohan96 I think that warning is a suggestion, not an error mesage
Christina Cook
@ctinaa
Jan 20 2016 03:00
Anyone on Record Collection?
Eric Saldivar
@esaldivar
Jan 20 2016 03:00
i just arrived on that challenge
Andrew Bales
@agbales
Jan 20 2016 03:00
@ctinaa I could help on that, too. Did it recently.
The Zohan
@TheZohan96
Jan 20 2016 03:00
@alhazen1 bt it doesnt compile inspite of all other paramters being ok
Adam Yuhasz
@jayuhasz
Jan 20 2016 03:00

@agbales ```js
function reverseString(str) {
var x = "";
for (var i = str.length - 1; i >= 0; i--)
x += str[i];
return x;
}

reverseString("Hello");
```
I arrived at something similar haha!

Jose Ceballos
@lazypepe
Jan 20 2016 03:00
@agbales did you get an undefined variable from pushing onto an empty array??
Adam Yuhasz
@jayuhasz
Jan 20 2016 03:01
function reverseString(str) {
  var x = "";
  for (var i = str.length - 1; i >= 0; i--)
    x += str[i];
  return x;
}

reverseString("Hello");
The Zohan
@TheZohan96
Jan 20 2016 03:01
@ctinaa yep tried this seems to be a prob somewhere
Christina Cook
@ctinaa
Jan 20 2016 03:01
@TheZohan96 can you post the code?
// 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 update(id, prop, value) {
  if (value !== "" && prop !== "tracks")
      {

      } else if (prop == "tracks" && value !=="") {
        value.push(); 
      } else {
        delete prop;
      }

  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
Andrew Bales
@agbales
Jan 20 2016 03:02
@lazypepe Seems to work fine-- fills the array and then in the return reverses and joins it.
Christina Cook
@ctinaa
Jan 20 2016 03:02
Am I on the right track? I'm confused about how to delete prop
Andrew Bales
@agbales
Jan 20 2016 03:02
@jayuhasz :)
Adam Yuhasz
@jayuhasz
Jan 20 2016 03:02
@agbales interesting, seems like you mixed for loops and baked in functions when I tried for just lazily pushing letters around haha
The Zohan
@TheZohan96
Jan 20 2016 03:03
@ctinaa I'm nt sure I know how u guys post a screenshot kind thing here
Andrew Bales
@agbales
Jan 20 2016 03:03
@ctinaa You're getting there. With your first "else if", remove prop == "tracks"..
Adam Yuhasz
@jayuhasz
Jan 20 2016 03:04
@TheZohan96 copy as pretty code
Delinda
@DelindaFrazier
Jan 20 2016 03:04
Stuck on wordblanks challenge, I do not understand what they want to see. I created a sentence with the given variables.
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line

"My " + "hairy " myAdjective + " " + myNoun + " " + myVerb + " " + myAdverb;
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Jose Ceballos
@lazypepe
Jan 20 2016 03:04
@agbales hmm then I'm totally confused my code gives me an undefined value. Which i had assumed came from pushing onto an empty array.
Christina Cook
@ctinaa
Jan 20 2016 03:05
@DelindaFrazier it's alittle glitchy. Just add more words
Andrew Bales
@agbales
Jan 20 2016 03:05
@lazypepe Hm. Did you try the more direct method we were showing before (if you're looking for a working solution)? Mostly we're just looking at other ways to complete it now.
The Zohan
@TheZohan96
Jan 20 2016 03:05

// Setup
var myStorage = {
"car": {
"inside": {
"glovebox": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line

var gloveBoxContents=myStorage.car.inside["glovebox"]; // Change this line

Christina Cook
@ctinaa
Jan 20 2016 03:05
@agbales thanks! alright
CamperBot
@camperbot
Jan 20 2016 03:05
ctinaa sends brownie points to @agbales :sparkles: :thumbsup: :sparkles:
:star: 292 | @agbales | http://www.freecodecamp.com/agbales
The Zohan
@TheZohan96
Jan 20 2016 03:05
@ctinaa here
Andrew Bales
@agbales
Jan 20 2016 03:05
@ctinaa :)
Christina Cook
@ctinaa
Jan 20 2016 03:06
@agbales wait why? it says : f value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop.
Delinda
@DelindaFrazier
Jan 20 2016 03:06
@ctinaa thanks!
CamperBot
@camperbot
Jan 20 2016 03:06
:star: 189 | @ctinaa | http://www.freecodecamp.com/ctinaa
delindafrazier sends brownie points to @ctinaa :sparkles: :thumbsup: :sparkles:
Adam Yuhasz
@jayuhasz
Jan 20 2016 03:06
@DelindaFrazier you are trying to return result without first declaring result into anything
Christina Cook
@ctinaa
Jan 20 2016 03:06
@TheZohan96

var gloveBoxContents = myStorage.car.inside['glove box'];
Jose Ceballos
@lazypepe
Jan 20 2016 03:07
@agbales I'm on a different challenge. but I used the same method for pushing onto my array so I was curious as to your results. I guess theres something else thats messing up my code.
Adam Yuhasz
@jayuhasz
Jan 20 2016 03:07
@DelindaFrazier you will need to declare result to be equal to your code
Josh Lumley
@JWLumley
Jan 20 2016 03:07
I am completely lost on Golf Code, can anyone point me in the right direction?
Andrew Bales
@agbales
Jan 20 2016 03:07
@ctinaa So, the progression of your logic has value !== "" & prop equaling tracks. For the next statement, it would be redundant, it seems. Does that make sense?
Also, I can send you a DM if you'd like to look over more code?
@lazypepe Interesting. Shoot me the code?
or challenge?
Jose Ceballos
@lazypepe
Jan 20 2016 03:08
function rot13(str) { // LBH QVQ VG!
  var arr = [];
  var result;
  var offset =13;
  var lowerRange= 65;
  var upperRange=90;
  for(var i=0; i<str.length; i++){
    if(str.charCodeAt(i)<lowerRange || str.charCodeAt(i)>upperRange) //range from A-Z in ASCII
      arr.push(str.charCodeAt(i));
    else{
      if(str.charCodeAt(i)+offset>upperRange){
        arr.push(str.charCodeAt(i)+offset-upperRange+lowerRange-1); 
        //lowerRange-1 as to not include the letter A from the start
      }else
        arr.push(str.charCodeAt(i)+offset);
    }
    //To shift out the undefined char when instantiating the array
    //if(i===0)
    //  arr.shift();
    result += String.fromCharCode(arr[i]);
  }
  console.log(result);
  return result;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Christina Cook
@ctinaa
Jan 20 2016 03:08
@agbales i think it's fine. Thanks!c:)
CamperBot
@camperbot
Jan 20 2016 03:08
ctinaa sends brownie points to @agbales :sparkles: :thumbsup: :sparkles:
Andrew Bales
@agbales
Jan 20 2016 03:08
@JWLumley Do you have a start or want a starting tip..?
CamperBot
@camperbot
Jan 20 2016 03:08
:warning: ctinaa already gave agbales points
Josh Lumley
@JWLumley
Jan 20 2016 03:09
@agbales I'm looking for a starting tip, I've tried doing it as an if else statement but I'm lost.
Jose Ceballos
@lazypepe
Jan 20 2016 03:09
my result looks like so undefinedFREE CODE CAMP
i can't seem to get rid of the undefined
k-strouse
@k-strouse
Jan 20 2016 03:10
Ok so made my way through all of the JScript waypoints and found myself constantly having to google the answer...most of the time derived from other people's code.
Andrew Bales
@agbales
Jan 20 2016 03:10
@JWLumley You'll probably want a string of if / else if statements that compare the strokes to par
k-strouse
@k-strouse
Jan 20 2016 03:10
should I run through them again?
Adam Yuhasz
@jayuhasz
Jan 20 2016 03:10
@lazypepe try initializing result as = ''
k-strouse
@k-strouse
Jan 20 2016 03:11
Any other resources for help, or just move on to the bonfires?
CamperBot
@camperbot
Jan 20 2016 03:11
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Josh Lumley
@JWLumley
Jan 20 2016 03:11
@agbales thanks I'll try it again and send the code if it doesn't work to see where I'm going wrong.
CamperBot
@camperbot
Jan 20 2016 03:11
jwlumley sends brownie points to @agbales :sparkles: :thumbsup: :sparkles:
:star: 293 | @agbales | http://www.freecodecamp.com/agbales
Jose Ceballos
@lazypepe
Jan 20 2016 03:11
@jayuhasz I cant or i wont be able to use the push function. It only works on arrays.
Andrew Bales
@agbales
Jan 20 2016 03:12
@JWLumley Sounds good!
Delinda
@DelindaFrazier
Jan 20 2016 03:12
@jayuhasz I still don't understand.
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = bob;
  // Your code below this line
  var bob = "My " + "hairy " myAdjective + " is" + myNoun + " dumb" + myVerb + " stupid " + myAdverb;
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("cat", "little", "hit", "slowly");
Andrew Bales
@agbales
Jan 20 2016 03:12
Hey, @lazypepe -- what's the name of this Q?
Adam Yuhasz
@jayuhasz
Jan 20 2016 03:13
@DelindaFrazier you modified the code above the line. var result should not be equal to anything.
The Zohan
@TheZohan96
Jan 20 2016 03:13
@ctinaa yhnx
yjhnx
thnx i mean
Andrew Bales
@agbales
Jan 20 2016 03:13
@lazypepe I do see that var result isn't assigned to either an empty string or array...
Christina Cook
@ctinaa
Jan 20 2016 03:14
@TheZohan96 no problem :)
Delinda
@DelindaFrazier
Jan 20 2016 03:14
@jayuhasz ok so how do I assign my sentence to result?
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  var bob = "My " + "hairy " myAdjective + " is" + myNoun + " dumb" + myVerb + " stupid " + myAdverb;
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("cat", "little", "hit", "slowly");
Adam Yuhasz
@jayuhasz
Jan 20 2016 03:14
@DelindaFrazier replace 'var bob' with 'result'
mmacedo
@mmacedoeu
Jan 20 2016 03:14
hey guys almost there with my pomodoro clock:
http://codepen.io/mmacedoeu/pen/jWaVdq
Chris Moore
@dooglus
Jan 20 2016 03:15
@DelindaFrazier or just return 'my' + 'hairy' + ...
Adam Yuhasz
@jayuhasz
Jan 20 2016 03:15
@dooglus technically she needs to not modify that line for that waypoint
Fidel Severino
@fidelscodes
Jan 20 2016 03:16
@DelindaFrazier you're also missing a + after your string "hairy"
hello everyone
Chris Moore
@dooglus
Jan 20 2016 03:16
@jayuhasz good point. I was forgetting that. what's the difference between a waypoint and a bonfire? The lingo has me confused - I don't think I've seen it explained anywhere
Abdulsalam Shalash
@shalashtein
Jan 20 2016 03:17

@Blauelf

// Example
function ourFunction(a, b) {
console.log(a - b);
}
ourFunction(10, 5); // Outputs 5

// Only change code below this line.
function myFunction(a, b){
console.log(a + b);
}

myFunction();

// Example
function ourFunction(a, b) {
  console.log(a - b);
}
ourFunction(10, 5); // Outputs 5

// Only change code below this line.
function myFunction(a, b){
  console.log(a + b);
}

myFunction();
Adam Yuhasz
@jayuhasz
Jan 20 2016 03:17
@dooglus I have no idea honestly, I've just been calling everything a waypoint.
Eric Saldivar
@esaldivar
Jan 20 2016 03:17
I am stuck on records collection:
// 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 update(id, prop, value) {
if (value !=="" && prop !== "tracks") {}
  else if (prop ==="tracks" && value !=="")
    value.push();

  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
Christina Cook
@ctinaa
Jan 20 2016 03:18
@esaldivar hey! lol I'm stuck on the same one as you now
mine is very close to yours
function update(id, prop, value) {
  if (value !== "" && prop !== "tracks")
      {

      } else if (value !=="") {
        value.push(); 
      } else {
        delete prop;
      }

  return collection;
}
Josh Lumley
@JWLumley
Jan 20 2016 03:19
Hopefully someone can help
function golfScore(par, strokes) {
  // Only change code below this line
  if (1) {
    return "Hole-in-one!";
  } else if (par <= -2) {
    return "Eagle";
  } else if (par -1) {
    return "Birdie";
  } else if (par) {
    return "Par";
  } else if (par +1) {
    return "Bogey";
  } else if (par +2) {
    return "Double Bogey";
  } else if (par>= +3) {
    return "Go Home!";
  }

  return "Change Me";
  // Only change code above this line
}
Delinda
@DelindaFrazier
Jan 20 2016 03:19
@fidelscodes thanks, missed that.
CamperBot
@camperbot
Jan 20 2016 03:19
delindafrazier sends brownie points to @fidelscodes :sparkles: :thumbsup: :sparkles:
:star: 400 | @fidelscodes | http://www.freecodecamp.com/fidelscodes
Christina Cook
@ctinaa
Jan 20 2016 03:20
@JWLumley you need to make all of them with the word strokes. like (strokes == par -1)
Josh Lumley
@JWLumley
Jan 20 2016 03:20
@ctinaa Thanks, I'll try that. New there was something missing
CamperBot
@camperbot
Jan 20 2016 03:20
jwlumley sends brownie points to @ctinaa :sparkles: :thumbsup: :sparkles:
Andrew Bales
@agbales
Jan 20 2016 03:20
@ctinaa Your set of conditions (the if, else if, else) look good!
CamperBot
@camperbot
Jan 20 2016 03:20
:star: 190 | @ctinaa | http://www.freecodecamp.com/ctinaa
Fidel Severino
@fidelscodes
Jan 20 2016 03:21
@dooglus waypoints are where they introduce and explain syntax and concepts. Bonfires are algorithm challenges that will require you to combine what you've learnt so far. For the bonfires they also point you in the direction of methods and properties that may come in helpful for solving the challenge
hope that explains it lol
Christina Cook
@ctinaa
Jan 20 2016 03:21
// 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 update(id, prop, value) {
  if (value !== "" && prop !== "tracks")
      {

      } else if (value !=="") {
        value.push(); 
      } else {
        delete prop;
      }

  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
I'm missing something :( I don't know what
Delinda
@DelindaFrazier
Jan 20 2016 03:21
I am still receiving the error, "Expected an assignment or function call and instead saw an expression." What does that mean?
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  "My " + "hairy " + myAdjective + " is" + myNoun + " dumb" + myVerb + " stupid " + myAdverb + "geez!";
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("cat", "little", "hit", "slowly");
Andrew Bales
@agbales
Jan 20 2016 03:22
@ctinaa For the first if you want to push the value of that particular id/prop, right?
Christina Cook
@ctinaa
Jan 20 2016 03:22
@agbales yeah idk how to access the id / prop
@DelindaFrazier you might want to refresh. What is the output you're getting at the moment?
Fidel Severino
@fidelscodes
Jan 20 2016 03:23
@DelindaFrazier you need to assign that long string to result before you return result
Andrew Bales
@agbales
Jan 20 2016 03:24
@ctinaa Here's how you go about referencing that
collection[id][prop].push(value);
Delinda
@DelindaFrazier
Jan 20 2016 03:24
@cctina no output. consol.log is blank.
Andrew Bales
@agbales
Jan 20 2016 03:25
That should help you with the syntax for the other statements.
Christina Cook
@ctinaa
Jan 20 2016 03:25
@DelindaFrazier I think @fidelscodes is right. You need to add result =
@agbales thanks! So whenever I need to access a JSON object, I use brackets to get further into the collection?
CamperBot
@camperbot
Jan 20 2016 03:26
ctinaa sends brownie points to @agbales :sparkles: :thumbsup: :sparkles:
:warning: ctinaa already gave agbales points
Delinda
@DelindaFrazier
Jan 20 2016 03:26
@fidelscodes and @ctinaa that did it. thank you. I have never see a variable assigned an empty string before (var result = ""). What is that about?
CamperBot
@camperbot
Jan 20 2016 03:26
:warning: delindafrazier already gave fidelscodes points
:warning: delindafrazier already gave ctinaa points
delindafrazier sends brownie points to @fidelscodes and @ctinaa :sparkles: :thumbsup: :sparkles:
Andrew Bales
@agbales
Jan 20 2016 03:26
@ctinaa Right-- here you're referencing the values pushed in for [id] or [prop], etc.
Christina Cook
@ctinaa
Jan 20 2016 03:28
@DelindaFrazier it's just to show it's blank in the beginning. That way you can add your own stuff by assigning the variable with details.
Fidel Severino
@fidelscodes
Jan 20 2016 03:28
@ctinaa JSON is object notation, so you can access them with dot notation or bracket notation. The difference is that when you use dot notation, you have to make sure the object has that property (if you're looking to access it) because otherwise you're creating that property
Christina Cook
@ctinaa
Jan 20 2016 03:29
@fidelscodes can you elaborate what you mean by "make sure the object has that property?".
@fidelscodes in other words, you end up accidentally creating an object if you use dot notation? So is bracket safer?
Andrew Bales
@agbales
Jan 20 2016 03:30
@ctinaa In this case .album is defined for each object. You can use dot notation (as I just did)
Christina Cook
@ctinaa
Jan 20 2016 03:30
@agbales where? I don't see dot notation. i only saw the bracket notation
Michael Martin
@MikeASNT
Jan 20 2016 03:30
Quick question, I have a variable total, which is within in a function. I want to have it coded so that it either chooses total (if the function is run more than once) or 0 (if total does not have a value)
Andrew Bales
@agbales
Jan 20 2016 03:30
Sorry, I mean in that sentence :)
Michael Martin
@MikeASNT
Jan 20 2016 03:31
IS that possible?
Andrew Bales
@agbales
Jan 20 2016 03:31
@ctinaa In the code for that problem, I use [prop] because we don't know if "album" or "tracks" (etc.) will be passed in.
@MikeASNT If someone can't answer that right away, perhaps post the code and we can take a look?
Christina Cook
@ctinaa
Jan 20 2016 03:33
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) {
  if (value !== "" && prop !== "tracks")
      {
         collection[id][prop].push(value); 
      } else if (value !=="") {
        collection[id][prop] = value; 
      } else {
        delete collection[id][prop];
      }
  return collection;
}
Why does it say "Cannot read property 'push' of undefined
Michael Martin
@MikeASNT
Jan 20 2016 03:34
agbales, basically it'd be an iterary selection (or however you say the first word)
But I got it to work by making total outside of the function
Andrew Bales
@agbales
Jan 20 2016 03:35
@ctinaa I'm not sure it answers that push issue-- but I notice that your prop !== "tracks". In that first if, I'd think you want the property to match if you're going to push the value.
@MikeASNT Great!
Michael Martin
@MikeASNT
Jan 20 2016 03:35
I mean it doesn't answer my question but as far as solving the issue I did so
it'd be like
I dunno
10 ? 0
Christina Cook
@ctinaa
Jan 20 2016 03:36
@agbales GOT IT yes you were right <3
Andrew Bales
@agbales
Jan 20 2016 03:36
Yay!
Glad it's working!
Fidel Severino
@fidelscodes
Jan 20 2016 03:37
@MikeASNT what are you trying to accomplish? For the variable total to have value of either 10 or 0?
Good job @ctinaa
Eric Saldivar
@esaldivar
Jan 20 2016 03:39

with every new challenge I gain a new ulcer:

// Example
var ourArray = [];

for (var i = 0; i < 5; i++) {
  ourArray.push(i);
}

// Setup
var myArray = [];

// Only change code below this line.

for ([initialization=0]; [condition=i<5]; [final-expression]);

I'm having trouble with the final expresion i think

Fidel Severino
@fidelscodes
Jan 20 2016 03:41
@esaldivar what is it asking you to do? I'm assuming push() numbers 0-5 to myArray?
Eric Saldivar
@esaldivar
Jan 20 2016 03:42
@fidelscodes yes
Fidel Severino
@fidelscodes
Jan 20 2016 03:42
you need to look at the example for loop they give you on top
Eric Saldivar
@esaldivar
Jan 20 2016 03:42
im seeing that
Fidel Severino
@fidelscodes
Jan 20 2016 03:42
you don't need the brackets
Gagandeep Singh
@Guggu
Jan 20 2016 03:43

// Setup
var a ;
var b = 5;

// Only change code below this line.

var a = 7;
var b = a;

hey guys pls help me in this code
Eric Saldivar
@esaldivar
Jan 20 2016 03:43
for (var i = 0, i < 5, i++) {
  myArray.push(i);
}
doesn't seem to work
Kyle Roach
@iRoachie
Jan 20 2016 03:43
@Guggu what challenge are you on?
Fidel Severino
@fidelscodes
Jan 20 2016 03:44
just the way they use i as the variable and iterator, you can use any letter or word (j is a common one after i) @esaldivar
Gagandeep Singh
@Guggu
Jan 20 2016 03:44
Storing Values with the Equal Operator iam on this challenge
Fidel Severino
@fidelscodes
Jan 20 2016 03:44
@esaldivar you cannot use i again because it's already being used inside of that function
just change i to another letter or word
Michael Martin
@MikeASNT
Jan 20 2016 03:46
@fidelscodes I'm trying to accomplish if the function is run multiple times, that total is to have the previous value and that if the function is run for the first time, to have a value of 0
Christina Cook
@ctinaa
Jan 20 2016 03:47
@esaldivar I can't get that one either -_-
// Only change code below this line.
for (var i = 0; i<=10; i +=1 ){
  oddNum = myArray.push(i);
}
Kyle Roach
@iRoachie
Jan 20 2016 03:47
@Guggu It looks right to me. Can you paste your link here?
eeflores
@eeflores
Jan 20 2016 03:47
@Guggu take the var keyword away on the 3rd and 4th line
Shaun Yap
@shaunyap
Jan 20 2016 03:47
@Guggu for the second set of code, I believe you need to remove the 2 "var"s
Luciano Britis
@LucianoBritis
Jan 20 2016 03:48
I need help.
Shaun Yap
@shaunyap
Jan 20 2016 03:48
@Guggu that's because the variables are already initialized earlier, and you are just assigning them the new values. :)
Kyle Roach
@iRoachie
Jan 20 2016 03:48
@iRoachie Oh sorry. You use the var, when you’re creating new variables
Gaege Root
@GaegeRoot
Jan 20 2016 03:48
What’s good my dudes and dudettes?
Fidel Severino
@fidelscodes
Jan 20 2016 03:48
@MikeASNT just initialize total to 0 and then you can change it inside the function
Luciano Britis
@LucianoBritis
Jan 20 2016 03:48
this waypoint Return Early Pattern for Functions
eeflores
@eeflores
Jan 20 2016 03:48
@LucianoBritis what's up?
Luciano Britis
@LucianoBritis
Jan 20 2016 03:49

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

}

else {
return abTest();
}

// Only change code above this line

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

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

sciand6
@sciand6
Jan 20 2016 03:49
// Setup
function phoneticLookup(val) {
  var result = "";

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

  };


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

// Change this value to test
phoneticLookup("charlie");
Only "foxtrot" equals "Frank"
Christina Cook
@ctinaa
Jan 20 2016 03:49
@sciand6 you need to make it a switch statement right?
sciand6
@sciand6
Jan 20 2016 03:49
I needed to convert a switch statement into a lookup table
Luciano Britis
@LucianoBritis
Jan 20 2016 03:49
I can not return undefined
eeflores
@eeflores
Jan 20 2016 03:49
@LucianoBritis have 2 separate tests in the if statement: if(a < 0 || b < 0)
@LucianoBritis you don't need the else.
@LucianoBritis if the if statement is true, you can just use return; in that block
d wilder
@alhazen1
Jan 20 2016 03:51
@LucianoBritis return; with nothing else is the same as returning undefined
Eric Saldivar
@esaldivar
Jan 20 2016 03:52
@ctinaa tweak your numbers, it worked for me
Christina Cook
@ctinaa
Jan 20 2016 03:52
var myArray = [];

// Only change code below this line.
for (var i = 1; i<=9; i++ ){
  myArray.push(i*2 +1);
}
Why does this go past 9 all thetime?
eeflores
@eeflores
Jan 20 2016 03:52
@sciand6 just return lookup[val];
Gagandeep Singh
@Guggu
Jan 20 2016 03:53
guys that's a link of my challenge
Gordon Davidescu
@gordondavidescu
Jan 20 2016 03:53
hey all
eeflores
@eeflores
Jan 20 2016 03:53
hello @gordondavidescu
Gordon Davidescu
@gordondavidescu
Jan 20 2016 03:53
drop it, the challenge
my code works for some things
but not others
function drop(arr, func) {
  // Drop them elements.
  for (i=0;i<=arr.length;i++)
    {

      if (func(arr[i])===true)
        {
          break;
        }

      if (func(arr[i])===false)
        {
          arr.shift();
        }

    }

  return arr;
}

drop([1, 2, 3, 4], function(n) {return n >= 3;})
eeflores
@eeflores
Jan 20 2016 03:54
@ctinaa the i var will end at 10 when the for exits
Shaun Yap
@shaunyap
Jan 20 2016 03:54
@Guggu did our earlier solutions not work?
Kyle Roach
@iRoachie
Jan 20 2016 03:54
@Guggu b is suppose to = 2. You changed the valuue above the line
Luciano Britis
@LucianoBritis
Jan 20 2016 03:54
I did. Thank campersif ( a < 0 || b < 0 ) {
return undefined;
}
sciand6
@sciand6
Jan 20 2016 03:54
Thank's I knew I was missing something small
Kyle Roach
@iRoachie
Jan 20 2016 03:54
@Guggu You werent suppose to change above that line
Christina Cook
@ctinaa
Jan 20 2016 03:54
@eeflores what? it doesnt end. It stops at 21
eeflores
@eeflores
Jan 20 2016 03:54
@gordondavidescu for range test is i < arr.length;
Susan
@SusanGrattan
Jan 20 2016 03:55
Anyone have a hint for Sorted Union? I don't know where to start...
Gordon Davidescu
@gordondavidescu
Jan 20 2016 03:55
@eeflores yes, should it not be?
eeflores
@eeflores
Jan 20 2016 03:55
@gordondavidescu your code has i <= arr.length
Gagandeep Singh
@Guggu
Jan 20 2016 03:55
yup you are right @iRoachie will try again
eeflores
@eeflores
Jan 20 2016 03:56
@ctinaa hmmm ... it looks like the last element that will be pushed onto the array should be 19
Gordon Davidescu
@gordondavidescu
Jan 20 2016 03:56
@eeflores is there something it should be instead?
eeflores
@eeflores
Jan 20 2016 03:57
@gordondavidescu
your code: i <= arr.length
suggestion: i < arr.length (no equals)
Christina Cook
@ctinaa
Jan 20 2016 03:57
@eeflores I figured it out. It's because i is the number of times it's looping, not the number it stops at
eeflores
@eeflores
Jan 20 2016 03:58
@ctinaa ok good stuff
Gordon Davidescu
@gordondavidescu
Jan 20 2016 03:58
I did that too @eeflores and it still returns the same :o:
func(2) should return false for >=3, not true
edburdett
@edburdett
Jan 20 2016 03:59
Hi all! I'm working on the JSON waypoints (Basic JS, not JSON APIs) and there is one thing I absolutely can't get through my thick skull. I don't know when to use quotation marks like strings or when to omit them. I've been using trial and error and it's getting kinda old.
eeflores
@eeflores
Jan 20 2016 04:00
@gordondavidescu had a look at my solution - my test was for n < 3
hello @edburdett
Gagandeep Singh
@Guggu
Jan 20 2016 04:01
thanks @iRoachie it works :)
CamperBot
@camperbot
Jan 20 2016 04:01
guggu sends brownie points to @iroachie :sparkles: :thumbsup: :sparkles:
:star: 329 | @iroachie | http://www.freecodecamp.com/iroachie
Kyle Roach
@iRoachie
Jan 20 2016 04:01
@Guggu Awesome!
DJ Bondoc
@DJBondoc
Jan 20 2016 04:01
did anyone have an issue with the Basic JavaScript: Using Objects for Lookups exercise?
edburdett
@edburdett
Jan 20 2016 04:01
also having trouble deciding between dot notation and bracket notation
DJ Bondoc
@DJBondoc
Jan 20 2016 04:01
I don't know what i'm doing wrong
Shaun Yap
@shaunyap
Jan 20 2016 04:02
@gordondavidescu maybe for the second if statement you changed it to 'else if' instead? that might be the reason your code is not being executed proeprly
Gordon Davidescu
@gordondavidescu
Jan 20 2016 04:02
no, that was how i had it in the first place
(alas)
eeflores
@eeflores
Jan 20 2016 04:03
@edburdett dot notation is used to access a specific member of an object - blah.one refers to member "one" of object "blah".
@edburdett if I have:
var something = "test";
var b = object[something]; // would get object.test
edburdett
@edburdett
Jan 20 2016 04:05
@eeflores thanks I think that will help some
CamperBot
@camperbot
Jan 20 2016 04:05
edburdett sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 428 | @eeflores | http://www.freecodecamp.com/eeflores
Gagandeep Singh
@Guggu
Jan 20 2016 04:05
@iroachie :sparkles: :thumbsup: :sparkles:
eeflores
@eeflores
Jan 20 2016 04:05
k
Saiduk
@Saiduk
Jan 20 2016 04:05
Why can't I get this to work? I've tried a million different things. Link to problem for reference: http://www.freecodecamp.com/challenges/record-collection
function update(id, prop, value) {
  for(id in collection) {
    if(value !== "" && prop !== "tracks") {
      collection[id][prop] = value;
    }
  }

  return collection;
}
Gordon Davidescu
@gordondavidescu
Jan 20 2016 04:05
drop([1, 2, 3, 7, 4], function(n) {return n > 3;}) should return [7, 4].
that worked
others did not work
how can some work and others not
eeflores
@eeflores
Jan 20 2016 04:06
@gordondavidescu try function(n){return n < 3;})
Gordon Davidescu
@gordondavidescu
Jan 20 2016 04:08
I ran your code @eeflores and it is also not working, weirdly
which is weird
Kyle Roach
@iRoachie
Jan 20 2016 04:08
@Saiduk Hey you only did one part
Gordon Davidescu
@gordondavidescu
Jan 20 2016 04:08
and it's beautiful because it's so short
Kyle Roach
@iRoachie
Jan 20 2016 04:08

@Saiduk next you have to do an if statement for

If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.

eeflores
@eeflores
Jan 20 2016 04:09
@gordondavidescu your for loop - dunno how arr.length will be affected when you shift elements off it - for may be affected
Gordon Davidescu
@gordondavidescu
Jan 20 2016 04:10
interesting
eeflores
@eeflores
Jan 20 2016 04:10
@gordondavidescu the thing is as you shift elements off the array you'll really always want to be testing arr[0]
Gordon Davidescu
@gordondavidescu
Jan 20 2016 04:11
oh!
I understand what you mean now
yes
Wilson Heres
@hereswilson
Jan 20 2016 04:11
I'm really close here. How do I fix the .fromCharCode?
function rot13(str) { // LBH QVQ VG!
 var coded = str.split("");
 var decoded;
  var re = /[\W_]/g;
   for(i= 0; i<coded.length; i++){
     var number;
     if(re.test(coded[i]) !== true){
       number=coded[i].charCodeAt();
       if(number < 78){
         number= number+13;
       }
       else{
         number=number-13;
       }
      coded[i]=number;

     }
     decoded=coded[i].fromCharCode();
   }

  return decoded;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Chris Trumbull
@tbullcoder
Jan 20 2016 04:12
Help please. Instructions are "Remove all elements from the initial array (1st argument) that are of the same value as the succeeding arguments." The return on my code is [1,1,2,3]
CamperBot
@camperbot
Jan 20 2016 04:12
no wiki entry for: please instructions are remove all elements from the initial array 1st argument that are of the same value as the succeeding arguments the return on my code is 1123
Wilson Heres
@hereswilson
Jan 20 2016 04:12
I'm getting that it's not a function
eeflores
@eeflores
Jan 20 2016 04:12
@hereswilson you'll need to test that the code is within range of 'A' and 'Z'
thekid2103
@thekid2103
Jan 20 2016 04:13
Selecting from many options with Switch Statements
Chris Trumbull
@tbullcoder
Jan 20 2016 04:13
oops.
``
Gordon Davidescu
@gordondavidescu
Jan 20 2016 04:13
@eeflores that works perfectly for everything except one
Saiduk
@Saiduk
Jan 20 2016 04:14
@iRoachie yeah, I was testing the code in pieces to isolate things
eeflores
@eeflores
Jan 20 2016 04:14
@gordondavidescu you try n < 3?
Gordon Davidescu
@gordondavidescu
Jan 20 2016 04:14
you're not going to believe what worked
Saiduk
@Saiduk
Jan 20 2016 04:15
@iRoachie I removed the for loop and that part passed, but seems like it would be needed for something
Chris Trumbull
@tbullcoder
Jan 20 2016 04:15
```
Wilson Heres
@hereswilson
Jan 20 2016 04:15
@eeflores aren't I doing that with the regex?
Gordon Davidescu
@gordondavidescu
Jan 20 2016 04:15
changing it to i=arr.length
thanks @eeflores
CamperBot
@camperbot
Jan 20 2016 04:15
gordondavidescu sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 429 | @eeflores | http://www.freecodecamp.com/eeflores
eeflores
@eeflores
Jan 20 2016 04:16
@gordondavidescu yw
@hereswilson your regex is getting the A-Z chars right?
Wilson Heres
@hereswilson
Jan 20 2016 04:16
@eeflores yes and only those characters will be ciphered
eeflores
@eeflores
Jan 20 2016 04:17
@hereswilson then you convert the char code to a number. If you have char 'C' and you subtract 13, you'll be out of range - have to add 26
Chris Trumbull
@tbullcoder
Jan 20 2016 04:17
Help with my code please.
function destroyer(arr) {

  var args = Array.prototype.slice.call(arguments);  // puts arguments in an array [[1,2,3,1,2,3],2,3]]

  arr2 =  args[0]; 

  arr3 = args.slice(1);

for (var i = 0; i < arr2.length; i++) {
    for (var j = 0; j < arr3.length; j++) {
        if (arr2[i] == arr3[j]) {arr2.splice(i, i+1)
          ; return arr2;
}
}
}


}  
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
CamperBot
@camperbot
Jan 20 2016 04:17
no wiki entry for: with my code please function destroyerarr var args arrayprototypeslicecallarguments puts arguments in an array 12312323 arr2 args0 arr3 argsslice1 for var i 0 i arr2length i for var j 0 j arr3length j if arr2i arr3j arr2splicei i1 return arr2 destroyer1 2 3 1 2 3 2 3
eeflores
@eeflores
Jan 20 2016 04:17
@hereswilson vice versa if you have char 'Z' and add 13, you'll have to subtract 26
Wilson Heres
@hereswilson
Jan 20 2016 04:19
@eeflores I accounted for that....if it's below 78(or N) then it adds 13 , otherwise it will subtract 13. That part works. My problem is once I have the array of numbers, how do I get them back to characters?
Eric Saldivar
@esaldivar
Jan 20 2016 04:19
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i=0; i < arr.length; i++) {
  for (var j=0; j < arr[i].length; j++) {
    for (var k=0; k < arr[j].length; k++) {
    console.log(product[i][j][k]);
  }}
}
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
having some real trouble with nesting for loops
eeflores
@eeflores
Jan 20 2016 04:20
@hereswilson String.fromCharCode()
@hereswilson sorry looking over your code again ...
Wilson Heres
@hereswilson
Jan 20 2016 04:21
@eeflores yes, that's not working. Does it have to be a string or does an array work?
eeflores
@eeflores
Jan 20 2016 04:22
@hereswilson charCodeAt takes a param
string offset
@hereswilson sorry that should work ...
Wilson Heres
@hereswilson
Jan 20 2016 04:23
@eeflores hmmm, but charCodeAt doesn't? what do you mean by string offset?
eeflores
@eeflores
Jan 20 2016 04:24
@hereswilson the charCodeAt param defaults to 0, which should work
@hereswilson however the return value is only being assigned one char
Wilson Heres
@hereswilson
Jan 20 2016 04:24
@eeflores yeah, charCodeAt works just fine
eeflores
@eeflores
Jan 20 2016 04:25
@hereswilson you'll have to recombine the split string array
d wilder
@alhazen1
Jan 20 2016 04:26
@hereswilson two changes - works but you lost all spaces
function rot13(str) { // LBH QVQ VG!
 var coded = str.split("");
 var decoded = "";  //<--initialize!
  var re = /[\W_]/g;
   for(i= 0; i<coded.length; i++){
     var number;
     if(re.test(coded[i]) !== true){
       number=coded[i].charCodeAt();
       if(number < 78){
         number= number+13;
       }
       else{
         number=number-13;
       }
      coded[i]=number;
//alert(coded[i]);
     }
     decoded+=String.fromCharCode(coded[i]);// <--
     //alert(decoded);
   }

  return decoded;
}
Wilson Heres
@hereswilson
Jan 20 2016 04:26
@eeflores well wouldn't that just be a bunch of numbers?
eeflores
@eeflores
Jan 20 2016 04:27
@hereswilson do coded[i] = String.fromCharCode(number)
Wilson Heres
@hereswilson
Jan 20 2016 04:27
@alhazen1 gotta have those spaces
d wilder
@alhazen1
Jan 20 2016 04:28
@hereswilson and punctuation
maybe your first if needs an else that passes those to string without decoding
Wilson Heres
@hereswilson
Jan 20 2016 04:28
ok seems I'm not as close as I thought I was..
d wilder
@alhazen1
Jan 20 2016 04:30
@hereswilson No, you are real close. this is output I got from the code i posted above with two changes (see comments in code) --> FREECODECAMP
Tracy Mazelin
@tracymazelin
Jan 20 2016 04:30
@esaldivar you only need two nested loops for that to work
eeflores
@eeflores
Jan 20 2016 04:30
@hereswilson
function rot13(str) { // LBH QVQ VG!
 var coded = str.split("");
 var decoded = "";  //<--initialize!
  var re = /[\W_]/g;
   for(i= 0; i<coded.length; i++){
     var number;
     if(re.test(coded[i]) !== true){
       number=coded[i].charCodeAt();
       if(number < 78){
         number= number+13;
       }
       else{
         number=number-13;
       }
      coded[i]=String.fromCharCode(number);

     }
   }

  return coded.join("");
}
Wilson Heres
@hereswilson
Jan 20 2016 04:31
thanks @eeflores
CamperBot
@camperbot
Jan 20 2016 04:31
hereswilson sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 430 | @eeflores | http://www.freecodecamp.com/eeflores
eeflores
@eeflores
Jan 20 2016 04:31
@hereswilson does it work?
Wilson Heres
@hereswilson
Jan 20 2016 04:31
thanks @alhazen1
CamperBot
@camperbot
Jan 20 2016 04:31
hereswilson sends brownie points to @alhazen1 :sparkles: :thumbsup: :sparkles:
:star: 274 | @alhazen1 | http://www.freecodecamp.com/alhazen1
Wilson Heres
@hereswilson
Jan 20 2016 04:32
YES!
eeflores
@eeflores
Jan 20 2016 04:32
good job
letstalklocal
@letstalklocal
Jan 20 2016 04:32
hi everyone...first timer here
Wilson Heres
@hereswilson
Jan 20 2016 04:32
Time to build some front end projects. Thanks again!
eeflores
@eeflores
Jan 20 2016 04:32
hello @letstalklocal
letstalklocal
@letstalklocal
Jan 20 2016 04:32
hi @eeflores
need help on the profile lookup challeng
eeflores
@eeflores
Jan 20 2016 04:33
@letstalklocal go on ...
letstalklocal
@letstalklocal
Jan 20 2016 04:34

function lookUp(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) { //Start of Loop

if
    ( firstName == contacts[i].firstName && contacts[i].hasOwnProperty( prop )) {   
    return contacts[i][prop];
  } else  if (contacts[i].hasOwnProperty( prop ) === false && firstName == contacts[i].firstName){
    return "No such property";
  } else if  ( firstName !== contacts[i].firstName){
        return "No such contact";
  }  

}
//End of Loop

// Only change code above this line
}

returns No Such contact
eeflores
@eeflores
Jan 20 2016 04:35
@letstalklocal put the "No such contact" after the for loop
@letstalklocal it will cause the fail when contacts[0].firstName doesn't match the firstName param to the function
letstalklocal
@letstalklocal
Jan 20 2016 04:38
thanks @eeflores can you show me what you mean
CamperBot
@camperbot
Jan 20 2016 04:38
letstalklocal sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 431 | @eeflores | http://www.freecodecamp.com/eeflores
Chris Moore
@dooglus
Jan 20 2016 04:38
what's the best way to make a copy of an array?
eeflores
@eeflores
Jan 20 2016 04:39
@letstalklocal
function lookUp(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) { //Start of Loop
  if( firstName == contacts[i].firstName && contacts[i].hasOwnProperty( prop )) {   
    return contacts[i][prop];
  } else  if (contacts[i].hasOwnProperty( prop ) === false && firstName == contacts[i].firstName){
    return "No such property";
  }  
}
//End of Loop
return "No such contact";
// Only change code above this line
}
Chris Moore
@dooglus
Jan 20 2016 04:40
@drbree82 thanks
Damon
@drbree82
Jan 20 2016 04:40
Don't thank me, thank Google
d wilder
@alhazen1
Jan 20 2016 04:41
@Google thanks!
CamperBot
@camperbot
Jan 20 2016 04:41
alhazen1 sends brownie points to @google :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for google
d wilder
@alhazen1
Jan 20 2016 04:41
OK - I tried
Chris Moore
@dooglus
Jan 20 2016 04:43
@google, thanks
CamperBot
@camperbot
Jan 20 2016 04:43
dooglus sends brownie points to @google :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for google
Herman Fassett
@HermanFassett
Jan 20 2016 04:43
@DuckDuckGo thanks
Damon
@drbree82
Jan 20 2016 04:44
Google is so humble
All she asks for is your private info and metadata
nothing else
Christina Cook
@ctinaa
Jan 20 2016 04:46
@drbree82 lool
Ryan
@ryanfristoe
Jan 20 2016 04:55
can someone help me figure out this waypoint
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber;       // Change this Line
var player = testObj;   // Change this Line
supposed to use bracket notation to lookup 16 in testObj
im at a loss
eeflores
@eeflores
Jan 20 2016 04:56
@ryanfristoe assign the value 16 to playerNumber
@ryanfristoe an example:
var a = 10;
var b = testObject[a];
Ryan
@ryanfristoe
Jan 20 2016 04:59
ok, thanks @eeflores
CamperBot
@camperbot
Jan 20 2016 04:59
ryanfristoe sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 432 | @eeflores | http://www.freecodecamp.com/eeflores
eeflores
@eeflores
Jan 20 2016 04:59
yw
Ryan
@ryanfristoe
Jan 20 2016 04:59
once i assign the player number, how do i assign player?
how does that relationship work?
this is what i have so far, pr your advice
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj[16];       // Change this Line
var player = testObj;   // Change this Line
eeflores
@eeflores
Jan 20 2016 05:00
@ryanfristoe just var playerNumber = 16;
@ryanfristoe then use the playerNumber var as a bracketed parameter to testObj
Ryan
@ryanfristoe
Jan 20 2016 05:03
@eeflores thank you, that did the ttrick
CamperBot
@camperbot
Jan 20 2016 05:03
ryanfristoe sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:warning: ryanfristoe already gave eeflores points
eeflores
@eeflores
Jan 20 2016 05:03
@ryanfristoe yw
NainaPS
@Navyya
Jan 20 2016 05:13
var myStr = "This is the start." + "This is the end." what is wrong with this code???
Rex Schrader
@SaintPeter
Jan 20 2016 05:14
@Navyya Missing a space after the . at the end of the first string
NainaPS
@Navyya
Jan 20 2016 05:14
Build myStr from the strings "This is the start. " and "This is the end." using the + operator.
Caleb
@Landenyr
Jan 20 2016 05:15
Do you have a semicolon on the end of the line @Navyya ?
NainaPS
@Navyya
Jan 20 2016 05:16
@Landenyr yes !var myStr = "This is the start." + "This is the end. ";
this is my code
Thomas McQuarry
@tmcquarry
Jan 20 2016 05:16
I don't understand the "Convert Celsius to Fahrenheit" problem. How can I get all the expected results at the same time?
NainaPS
@Navyya
Jan 20 2016 05:17
yes! @tmcquarry you have to create an eq for Celsius the given way
@SaintPeter I tried its yet not successful

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

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

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

Thomas McQuarry
@tmcquarry
Jan 20 2016 05:20
Thanks @Navyya , that helps.
CamperBot
@camperbot
Jan 20 2016 05:20
tmcquarry sends brownie points to @navyya :sparkles: :thumbsup: :sparkles:
:star: 11 | @navyya | http://www.freecodecamp.com/navyya
NainaPS
@Navyya
Jan 20 2016 05:21
:smile:
@SaintPeter It worked
:clap:
Chris Moore
@dooglus
Jan 20 2016 05:28
I'm having trouble with the 'steamroller' waypoint. My code works if I run it in node, but seems to crash the in-browser interpreter:
function steamroller(arr) {
  ret = [];
  for (i = 0; i < arr.length; i++) {
    var elt = arr[i];
    if (Array.isArray(elt))
      ret = ret.concat(steamroller(elt));
    else
      ret.push(elt);
  }

  return ret;
}

steamroller([1, [2], [3, [[4]]]]);
see anything wrong with it? it looks OK to me
eeflores
@eeflores
Jan 20 2016 05:32
@dooglus tried refreshing the browser?
looks OK to me
Chris Moore
@dooglus
Jan 20 2016 05:32
@eeflores I had to kill multiple tabs to get them to start responding again - seems like an infinite recursion
@eeflores did you try my code as a solution to http://www.freecodecamp.com/challenges/steamroller ?
eeflores
@eeflores
Jan 20 2016 05:35
@dooglus killed my window too
Chris Moore
@dooglus
Jan 20 2016 05:37
weird, huh? I tried restarting the browser, but it still kills the tab
I've used recursive functions in some other waypoints and it has worked fine.
eeflores
@eeflores
Jan 20 2016 05:38
@dooglus I've got my solution as a recursive function and it works ... I'm not using concat though
but that should work ...
@dooglus also I don't have a specific var that is used when testing array elements like your elt
Chris Moore
@dooglus
Jan 20 2016 05:40
I didn't either at first. I did that to see if it mattered
also, how are you sticking the results from the recursive calls together without concat()?
eeflores
@eeflores
Jan 20 2016 05:42
the not-efficient way of iterating
Chris Moore
@dooglus
Jan 20 2016 05:42
loop-and-push?
eeflores
@eeflores
Jan 20 2016 05:42
yep
@dooglus aaaah ret is global!
@dooglus at the beginning of the function do var ret = [];
Chris Moore
@dooglus
Jan 20 2016 05:44
well spotted! :)
I mean: thanks, @eeflores
eeflores
@eeflores
Jan 20 2016 05:44
all good @dooglus
Chris Moore
@dooglus
Jan 20 2016 05:45
no bot here?
eeflores
@eeflores
Jan 20 2016 05:45
meh
Chris Moore
@dooglus
Jan 20 2016 05:47
I added the var and it still crashes the tab
eeflores
@eeflores
Jan 20 2016 05:48
dang it
@dooglus i is also global
Sarah
@Phumphie
Jan 20 2016 05:48
Hello, I am working on the convert celsius to farhenheit and I am a bit confused about what to do after declaring the variable, this is the code I am trying but I get "RangeError: Maximmum call stack size exceeded"
var farhenheit = farhenheit
convert(celsius *= 9/5 + 32)
Chris Moore
@dooglus
Jan 20 2016 05:49
@eeflores Party on, Wayne! :)
eeflores
@eeflores
Jan 20 2016 05:49
@dooglus party on!
Chris Moore
@dooglus
Jan 20 2016 05:49
the editor used to bitch at me if I used undeclared variables. I wonder why it stopped
NainaPS
@Navyya
Jan 20 2016 05:50
Can anyone help for the wordBlank assignment?
eeflores
@eeflores
Jan 20 2016 05:50
@Phumphie can I see moreof your code?
Christina Cook
@ctinaa
Jan 20 2016 05:51
anyone know how to start this?
eeflores
@eeflores
Jan 20 2016 05:51
@Phumphie maybe don't assign farhenheit to farhenheit
Christina Cook
@ctinaa
Jan 20 2016 05:51
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line


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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr
@Phumphie sometimes that happens. You need to refresh the page.
Sarah
@Phumphie
Jan 20 2016 05:52

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

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

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

@eeflores
function convert(celsius) {
// Only change code below this line
var farhenheit = farhenheit
convert(celsius *= 9/5 + 32)
// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}
// Change the inputs below to test your code
convert(30);
NainaPS
@Navyya
Jan 20 2016 05:53
@Phumphie

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

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

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

eeflores
@eeflores
Jan 20 2016 05:53
@ctinaa the test cases are 2d arrays?
NainaPS
@Navyya
Jan 20 2016 05:53
this is the solution
eeflores
@eeflores
Jan 20 2016 05:54
@Phumphie you'll want to assign the conversion to var fahrenheit
Sarah
@Phumphie
Jan 20 2016 05:54
@Navyya Ah that makes so much sense! ok - I was trying to create two different variables, that was my problem. Thank you for your help!
CamperBot
@camperbot
Jan 20 2016 05:54
phumphie sends brownie points to @navyya :sparkles: :thumbsup: :sparkles:
eeflores
@eeflores
Jan 20 2016 05:54
oh, @Navyya has it
CamperBot
@camperbot
Jan 20 2016 05:54
:star: 12 | @navyya | http://www.freecodecamp.com/navyya
Sarah
@Phumphie
Jan 20 2016 05:55
Thanks to you too @eeflores
CamperBot
@camperbot
Jan 20 2016 05:55
phumphie sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 438 | @eeflores | http://www.freecodecamp.com/eeflores
NainaPS
@Navyya
Jan 20 2016 05:55
@Phumphie we need to create a single var defining as an eq....
eeflores
@eeflores
Jan 20 2016 05:55
@ctinaa a for loop to iterate over the outer arrays, and a for loop to iterate through the inner arrays
NainaPS
@Navyya
Jan 20 2016 05:56
can anyone help for wordBlank ??????
eeflores
@eeflores
Jan 20 2016 05:56
@Navyya looking into it ...
NainaPS
@Navyya
Jan 20 2016 05:56
@eeflores alright ...:)
eeflores
@eeflores
Jan 20 2016 05:56
@Navyya what seems to be the problem?
@Navyya I basically took the parameters to the function and concatenated them together with spaces in between
NainaPS
@Navyya
Jan 20 2016 05:59
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  var result = "myNoun " + "myAdjective" + "myVerb" + "myAdverb";

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
I did this which is not the expected one...
eeflores
@eeflores
Jan 20 2016 06:00
@Navyya take the quotes off the variable names
@Navyya something like myNoun + " " + myAdjective etc
NainaPS
@Navyya
Jan 20 2016 06:02
ok ok @eeflores
@eeflores :sparkles:
eeflores
@eeflores
Jan 20 2016 06:05
well done @Navyya ?
NainaPS
@Navyya
Jan 20 2016 06:07
Thanks To u @eeflores :)
CamperBot
@camperbot
Jan 20 2016 06:07
navyya sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 439 | @eeflores | http://www.freecodecamp.com/eeflores
Deepak Dwivedi
@deepakdubey2624
Jan 20 2016 06:15
var myStr ="\' \t \t \c \n";
what i am doing wrong?
escape sequences in strings
Herman Fassett
@HermanFassett
Jan 20 2016 06:17
This message was deleted
Deepak Dwivedi
@deepakdubey2624
Jan 20 2016 06:17
okat thanks @HermanFassett !
CamperBot
@camperbot
Jan 20 2016 06:17
deepakdubey2624 sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star: 1403 | @hermanfassett | http://www.freecodecamp.com/hermanfassett
Herman Fassett
@HermanFassett
Jan 20 2016 06:18
@deepakdubey2624 wait my bad
@deepakdubey2624 what you're missing is it should be backslash, not single quote so \\
Deepak Dwivedi
@deepakdubey2624
Jan 20 2016 06:18
okay!
Herman Fassett
@HermanFassett
Jan 20 2016 06:18
Ignore my previous comment
fluffystub
@RakshithNM
Jan 20 2016 06:22

function findLongestWord(str,separator) {

  var splitString = str.split(separator);

  var lengthArray = splitString.map(splitString.length);


  var largest = Math.max.apply(lengthArray);


  return largest ;
}

findLongestWord("The quick brown fox jumped over the lazy dog",' ');
please help
bonfire :
Find the Longest Word in a String
CamperBot
@camperbot
Jan 20 2016 06:22

:fire:Bonfire: Find the Longest Word in a String :link:

function findLongestWord(str) {
  return str.length;
}

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

Return the length of the longest word in the provided sentence.

more info:  bf details | bf links | hint

Herman Fassett
@HermanFassett
Jan 20 2016 06:23
@RakshithNM what is this doing?:
splitString.map(splitString.length);
fluffystub
@RakshithNM
Jan 20 2016 06:24
that finds the length of each word in splitString and maps it to the array lengthArray @HermanFassett
help
Find the Longest Word in a String
CamperBot
@camperbot
Jan 20 2016 06:25

:point_right: bonfire find the longest word in a string [wiki]

Explanation:

You have to go through each word and figure out which one is the longest and return not the word, but how many characters it has.

:pencil: read more about bonfire find the longest word in a string on the FCC Wiki

Herman Fassett
@HermanFassett
Jan 20 2016 06:26
@RakshithNM you need a callback function, you can't just have a number. Also you'll want to explicitly define the separator since the fcc tests won't incorporate that parameter
For instance just do var splitString = str.split(" ");
fluffystub
@RakshithNM
Jan 20 2016 06:27
@HermanFassett
 var i=0;
  var lengthArray = splitString.map(splitString[i].length);
how about now?
Herman Fassett
@HermanFassett
Jan 20 2016 06:28
No, you need a function, something like
var lengthArray = splitString.map(function(val) { 
    return // what do you want?
});

Oh and math.max works a little differently, you need

var largest = Math.max.apply(null, lengthArray);

or whatever even

var largest = Math.max.apply(0, lengthArray);
Unless you es6 it
Dylan Pagillo
@DylanNeil
Jan 20 2016 06:29
Been stuck on waypoint: Testing Objects for properties for a bit now, here is what I have
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here

  if(myObj.hasOwnProperty[checkProp] === true){
    return myObj[checkProp];
  }
  return "Not Found";
}

// Test your code by modifying these values
checkObj("gift");
Herman Fassett
@HermanFassett
Jan 20 2016 06:30
@DylanNeil hasOwnProperty is a function so you should use parentheses, not brackets
for instance obj.hasOwnProperty(prop)
Miguel
@Miguel12321
Jan 20 2016 06:31
I got the correct answer for Return Early Pattern for Functions but I think I did it wrong. can someone help me
fluffystub
@RakshithNM
Jan 20 2016 06:31
@HermanFassett could you explain why are the null and 0 used
Miguel
@Miguel12321
Jan 20 2016 06:31
  if (a<0){
    return "undefine";
  }
  if (b<0){
    return "undefine";
  }
d wilder
@alhazen1
Jan 20 2016 06:32
@Miguel12321 just return; will return undefined.
Miguel
@Miguel12321
Jan 20 2016 06:33
@alhazen1 oh ok thank you it worked
CamperBot
@camperbot
Jan 20 2016 06:33
miguel12321 sends brownie points to @alhazen1 :sparkles: :thumbsup: :sparkles:
:star: 275 | @alhazen1 | http://www.freecodecamp.com/alhazen1
Dylan Pagillo
@DylanNeil
Jan 20 2016 06:33
@HermanFassett Thank You! that worked! such a silly mistake, I appreciate it
CamperBot
@camperbot
Jan 20 2016 06:33
dylanneil sends brownie points to @hermanfassett :sparkles: :thumbsup: :sparkles:
:star: 1405 | @hermanfassett | http://www.freecodecamp.com/hermanfassett
d wilder
@alhazen1
Jan 20 2016 06:33
@Miguel12321 you're welcome
Herman Fassett
@HermanFassett
Jan 20 2016 06:35
Glad I could help @DylanNeil
Emma Clark
@sapphirestone
Jan 20 2016 06:37
Hey! I'm having trouble with the Word Blanks exercise, can anyone offer me advise?

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

result = "The "+ myNoun + myAdjective + myVerb + myAdverb + " through the forest" ;
// Your code above this line
return result;
}

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

Brian
@sludge256
Jan 20 2016 06:38
@sapphirestone add spaces between the words/variables
Miguel
@Miguel12321
Jan 20 2016 06:39
Can someone explain Counting Cards I don't understand it
Salad
@Saladg
Jan 20 2016 06:40
Hello guys,
anyone with an idea of how to correct this error:
palindrome("0_0 (: /-\ :) 0-0") should return true.
palindrome("0_0 (: /-\ :) 0-0") should return true.
Emma Clark
@sapphirestone
Jan 20 2016 06:42
That worked, I tried adding spaces before though, don't know why it didn't work the first time. Thanks @sludge256!
CamperBot
@camperbot
Jan 20 2016 06:42
sapphirestone sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
Herman Fassett
@HermanFassett
Jan 20 2016 06:42
@Saladg make sure you're removing _ so the test is on 0000
CamperBot
@camperbot
Jan 20 2016 06:42
:star: 911 | @sludge256 | http://www.freecodecamp.com/sludge256
Salad
@Saladg
Jan 20 2016 06:42

I have removed:
function palindrome(str) {
// Good luck!
str=str.toLowerCase();
for(var i=0;i<str.length;i++)
{
str=str.replace(' ','');
str=str.replace(',','');
str=str.replace('.','');
str=str.replace('/','');
str=str.replace('(','');
str=str.replace(')','');
str=str.replace('_','');
str=str.replace(' -','');
str=str.replace('','');
}
var copy=str.split('').reverse().join('');
if(copy===str)
{
return true;
}
else{
return false;
}
}

palindrome("eye");

@sludge256
indra1383
@indra1383
Jan 20 2016 06:43
find Using Objects for Lookups
CamperBot
@camperbot
Jan 20 2016 06:43

find using objects for lookups

:zero: waypoint using objects for lookups

Herman Fassett
@HermanFassett
Jan 20 2016 06:45
@Saladg you also need to remove -
Miguel
@Miguel12321
Jan 20 2016 06:46
  if (2,3,4,5,6){
  return "5 Bet";
} 
if (7,8,9){
  return "0 Hold";
}
  if (10,"J","Q","K"){
    return "-5 Hold";
  }
  if (3,2,"A",10){
    return "-1 Hold it";
  }
this is what I have
Salad
@Saladg
Jan 20 2016 06:46
It's also removed @sludge256 , the problem seems to be "\", but if i do '\', '' there is an error generated
Caleb
@Landenyr
Jan 20 2016 06:46

@RakshithNM The array.map needs to callback to a function. So something like this:

  var lengthArray = splitString.map(function(index) {
    return index.length;
  });

And then adding the 0 or null in the Math.max function as was already stated and it should work.

Brian
@sludge256
Jan 20 2016 06:47
I am not @HermanFassett
Herman Fassett
@HermanFassett
Jan 20 2016 06:47
:P
Miguel
@Miguel12321
Jan 20 2016 06:48
This message was deleted
This message was deleted
  if (2,3,4,5,6){
  return "5 Bet";
} 
 else if (7,8,9){
  return "0 Hold";
}
 else if (10,"J","Q","K"){
    return "-5 Hold";
  }
  else if (3,2,"A",10){
    return "-1 Hold it";
  }
d wilder
@alhazen1
Jan 20 2016 06:50
@Miguel12321 I think you are supposed to use switch to solve that one
glianyi
@glianyi
Jan 20 2016 06:50
@Miguel12321 use switch case
Miguel
@Miguel12321
Jan 20 2016 06:52
@alhazen1 @glianyi like Switch(2,3,4,5,6) case "5 Bet":
glianyi
@glianyi
Jan 20 2016 06:53
@Miguel12321 switch(val){case 2:3,4,5,6}
Miguel
@Miguel12321
Jan 20 2016 06:56
  switch (card){
    case 2,3,4,5,6:
      return "5 Bet"
     break;
 }
@glianyi like this?
d wilder
@alhazen1
Jan 20 2016 06:56
@Miguel12321 Actually you can use if statements but I used switch
Miguel
@Miguel12321
Jan 20 2016 06:57
@alhazen1 so is this fine?
d wilder
@alhazen1
Jan 20 2016 06:57
no, each test case in switch needs its own line
glianyi
@glianyi
Jan 20 2016 06:58
@Miguel12321 switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
break;
}
d wilder
@alhazen1
Jan 20 2016 06:59
@Miguel12321 you might want to go back and look at switch exercise
Miguel
@Miguel12321
Jan 20 2016 06:59
@alhazen1 @glianyi like this
  switch (card){
case 2:
case 3:
case 4:
case 5:
    case 6:
      return "5 Bet"
     break;
 }
d wilder
@alhazen1
Jan 20 2016 07:00
@Miguel12321 Yes! but you'll need to think about that return statement. That is not what they're asking
Brian
@sludge256
Jan 20 2016 07:02
@Saladg you passed yet?
Miguel
@Miguel12321
Jan 20 2016 07:02
@alhazen1 I don't understand that part. is it answer?
Brian
@sludge256
Jan 20 2016 07:02
your code was also not replacing :
d wilder
@alhazen1
Jan 20 2016 07:03
@Miguel12321 you need a running total or count. Low cards add one to the count and high cards subtract one. Depending on how close to 0 you are helps you decide if you should bet
Miguel
@Miguel12321
Jan 20 2016 07:05
@alhazen1 oh ok I get it thanks