These are chat archives for FreeCodeCamp/HelpJavaScript

16th
Jan 2017
James Shore
@Jimbobmahooley
Jan 16 2017 00:01
@khaduch Yeah okay thanks, I think @sjames1958gm was right and I'll need to do slice and concatenation I was forgetting I don't need another loop my first will do it I think.
CamperBot
@camperbot
Jan 16 2017 00:01
jimbobmahooley sends brownie points to @khaduch and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2284 | @khaduch |http://www.freecodecamp.com/khaduch
:star2: 5348 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Suraj
@suraj-davariya
Jan 16 2017 00:04
Please help me out in this lesson. Please guide me

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


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

  for(var j=0;  j < contacts[i].length ; j++ ){
    if(contacts[i].firstname==firstName){
      if(contacts[i][j]==prop){
        return contacts.firstName.prop; 
      }
      else{
        return "No such property";
      }
    }
    else{
      return "No such contacts";
    }



  }

}
// Only change code above this line
}

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

** Profile Lookup

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

A lookUpProfile 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" **

Moisés Man
@moigithub
Jan 16 2017 00:07
u need to review how to access array elements
how to access object properties
and how to check object properties (hasOwnProperty method)
@suraj-davariya
Suraj
@suraj-davariya
Jan 16 2017 00:08
@moigithub Thanks i really appreciate <3
CamperBot
@camperbot
Jan 16 2017 00:08
suraj-davariya sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2511 | @moigithub |http://www.freecodecamp.com/moigithub
Suraj
@suraj-davariya
Jan 16 2017 00:08
:+1: * @moigithub
Greg Duncan
@GregatGit
Jan 16 2017 00:23
@suraj-davariya you very first line of the for loop has if and else - both have a return stament - so not matter what happens it won't loop past that first if/else statement
@suraj-davariya it should loop through the every object then it can return "No such contact" - and "No such contacts" has a typo
Jaydeep Kataria
@jaydeepk3
Jan 16 2017 00:30
help me to solve this ..
CamperBot
@camperbot
Jan 16 2017 00:30
no wiki entry for: me to solve this
Jaydeep Kataria
@jaydeepk3
Jan 16 2017 00:30
Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable
Johnny
@JohnnyBizzel
Jan 16 2017 00:32
@jaydeepk3 lookup[val] or something?
Jaydeep Kataria
@jaydeepk3
Jan 16 2017 00:33
yes
@JohnnyBizzel
Suraj
@suraj-davariya
Jan 16 2017 00:34
@GregatGit thanks bro :+1:
CamperBot
@camperbot
Jan 16 2017 00:34
suraj-davariya sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 825 | @gregatgit |http://www.freecodecamp.com/gregatgit
Greg Duncan
@GregatGit
Jan 16 2017 00:34
@suraj-davariya np!
Bigyan Karki
@bigyankarki
Jan 16 2017 00:35
hey everyone !
can someone tell me how to ignore case and special symbols from a string
Yoel Trujillo
@y0el22
Jan 16 2017 00:36

hi guys i need some help with check for palindrome chellenge

i got this:


function palindrome(str) {
 var stri = str.replace(/[^a-zA-Z0-9]/g, '');
 var stri1 = str.toLowerCase();
 var stri2 = stri1.split("");
 var stri3 = stri2.reverse();
 var striFinal = stri3.join("");

  if(striFinal === str){
    return true;
  }else {return false;}

}



palindrome("eye");

what is wrong here?

Can someone help me on this challenge? I have no idea
Stephen James
@sjames1958gm
Jan 16 2017 00:39
@y0el22 You are comparing to the original string not he the modified string. Also you toLowerCase should be on stri
miner_paul
@aeselden92
Jan 16 2017 00:39
having trouble returning the count variable in the card counting challenge
Stephen James
@sjames1958gm
Jan 16 2017 00:40
@troutman21 You should have learned 4 array functions here you use 2 add to end and remove from front of an array.
Insdei the function use arr and item
miner_paul
@aeselden92
Jan 16 2017 00:40
blob
Stephen James
@sjames1958gm
Jan 16 2017 00:40
@aeselden92 show the code?
miner_paul
@aeselden92
Jan 16 2017 00:40
Says count should be displayed in a string
not sure how to do that
Yoel Trujillo
@y0el22
Jan 16 2017 00:41
@sjames1958gm let me se!
Stephen James
@sjames1958gm
Jan 16 2017 00:41
@aeselden92 your cases are not correct then you need return count + string
miner_paul
@aeselden92
Jan 16 2017 00:41
thanks @sjames1958gm
CamperBot
@camperbot
Jan 16 2017 00:41
aeselden92 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5349 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Phil Seidel
@psbyron3
Jan 16 2017 00:41
@troutman21
Phillip Troutman
@troutman21
Jan 16 2017 00:41
this is going to be accomplished with the .pop(), .shift(), .unshift() those functions right? @sjames1958gm
miner_paul
@aeselden92
Jan 16 2017 00:41
I totally forgot about combining with addition
Phil Seidel
@psbyron3
Jan 16 2017 00:42
There's two steps here.. A queue works like any line
YES!
So the first item in is the first item out.
You want to be able to push in an item to the end of the line. and then return the front of the line @troutman21
Phillip Troutman
@troutman21
Jan 16 2017 00:43
Hmm ok. Im still really fuzzy on functions in general so ill keep playing with it.
Phil Seidel
@psbyron3
Jan 16 2017 00:43
What about functions? Just in genereal or is there something specifically stumping you
Yoel Trujillo
@y0el22
Jan 16 2017 00:43
@sjames1958gm how can i compare the modified one?
Phil Seidel
@psbyron3
Jan 16 2017 00:43
general**
Yoel Trujillo
@y0el22
Jan 16 2017 00:43
equal to what?
Jor
@joreyesl
Jan 16 2017 00:45
@troutman21
they want you to add num to the end of the array, then remove the first item in the array and return it. Which 2 functions will we need? .push() .pop() .shift() .unshift()
Phillip Troutman
@troutman21
Jan 16 2017 00:45
Just general i think. Im having a hard time with arguments and parameters @psbyron3
Phil Seidel
@psbyron3
Jan 16 2017 00:46
So parameters are the placeholder words that go between the parens
```
function hello(parameter1, anotherParam) {
    //run code here
}
Arguments are what you plug in when you call that function @troutman21
Phillip Troutman
@troutman21
Jan 16 2017 00:47
ok and how do you build the function properly? do you still use the param names?
Phil Seidel
@psbyron3
Jan 16 2017 00:47
function add (param1, param2) {
     return param1 + param2
}

add(2,3) <----- The two arguments
Phillip Troutman
@troutman21
Jan 16 2017 00:47
@psbyron3
ok that helps ..
miner_paul
@aeselden92
Jan 16 2017 00:48
@sjames1958gm any hint on how I should change the case?
Phil Seidel
@psbyron3
Jan 16 2017 00:49
parameters names are irrelevant. They are merely a placeholder, I could have said banana and orange instead of param1 and param2. It doesn't matter to the computer. BUT you should always use descriptive parameters and function names so that other people who read your code can understand what's going on. @troutman21
Phillip Troutman
@troutman21
Jan 16 2017 00:51
ok im understanding more now . for this specific challenge it wants me to use a array and a item (number) ... is that going to look like [1,2,3], 4. something like that right ?
Brad Hain
@Bhain1431
Jan 16 2017 00:51

Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
// Only change code below this line

var remainder;

Phillip Troutman
@troutman21
Jan 16 2017 00:51
@psbyron3
Bigyan Karki
@bigyankarki
Jan 16 2017 00:52

function palindrome(str) {

  var singledLetter = [];
  var reversedLetter = "";
  var appendLetter = "";

  var replaced = str.replace(/\d+/g, "");
  var finalStr = replaced.toLowerCase();


  for (var i = 0; i < finalStr.length; i++) {
    singledLetter = finalStr.split("");
    reversedLetter = singledLetter.reverse();
    appendLetter = reversedLetter.join("");
  }
    if (appendLetter == finalStr) {
      return true;
    } 
  else {
    return false;
  }
  }



palindrome("Eye");
how too remove symbols too/
Brad Hain
@Bhain1431
Jan 16 2017 00:53
they didnt say how to type this answer ?
Phil Seidel
@psbyron3
Jan 16 2017 00:54
@troutman21 Yes, so the challenges will already have the test cases, I thought I remember seeing one at the bottom.
Brad Hain
@Bhain1431
Jan 16 2017 00:54
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
Phil Seidel
@psbyron3
Jan 16 2017 00:54
But what you want to do is push the item into the input array and then return the first element in the array. @troutman21
Phillip Troutman
@troutman21
Jan 16 2017 00:57
hmm alright. This is making my brain hurt. lol im going to keep going. Java is tough lol
@psbyron3 thanks for your help.
CamperBot
@camperbot
Jan 16 2017 00:57
troutman21 sends brownie points to @psbyron3 :sparkles: :thumbsup: :sparkles:
:cookie: 34 | @psbyron3 |http://www.freecodecamp.com/psbyron3
Frank V. Adames
@fadam00
Jan 16 2017 00:57
Hi all, I've been having problems with the Profile Lookup exercise since yesterday and I'm stumped and out of ideas.... here what I got

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


function lookUpProfile(firstName, prop){
// Only change code below this line
var result = "";
var i = 0;

while(i < contacts.length){


  if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop) === true){
    result = contacts[i][prop];

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

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

// Change these values to test your function
lookUpProfile("Akira", "likes");
Could anybody lend a helping hand?
miner_paul
@aeselden92
Jan 16 2017 00:58
fixed my case but still having problems
Jor
@joreyesl
Jan 16 2017 00:59
@bigyankarki try /[^\w]/gi
miner_paul
@aeselden92
Jan 16 2017 00:59
blob
Bigyan Karki
@bigyankarki
Jan 16 2017 01:04
@joreyesl can you please explain how that works?
still the cocde is note working for _eye
Jor
@joreyesl
Jan 16 2017 01:06
@bigyankarki /[^A-Za-z]/gi
Moisés Man
@moigithub
Jan 16 2017 01:06
keep numbers too @joreyesl
Jor
@joreyesl
Jan 16 2017 01:07
[^A-Za-z0-9]/gi ?
Bigyan Karki
@bigyankarki
Jan 16 2017 01:07
@joreyesl i replaced the number with D+
"1 eye for of 1 eye.
code is not true for this number
i mean string
Phillip Troutman
@troutman21
Jan 16 2017 01:09
to remove the first element of array i use the .shift()function right ? @psbyron3
Jor
@joreyesl
Jan 16 2017 01:09
@troutman21 yes
Moisés Man
@moigithub
Jan 16 2017 01:09
IF u use i flag no need to specify upper and lower case
(case insensitive flag )
Phillip Troutman
@troutman21
Jan 16 2017 01:09
how do i return an item that i shif t off?
@joreyesl
Jor
@joreyesl
Jan 16 2017 01:09
return arr.shift();
Phillip Troutman
@troutman21
Jan 16 2017 01:10
hmmm ok. Thank you. @joreyesl
CamperBot
@camperbot
Jan 16 2017 01:10
troutman21 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 202 | @joreyesl |http://www.freecodecamp.com/joreyesl
Jor
@joreyesl
Jan 16 2017 01:10
or to understand better
var item = arr.shift();
return item;
@bigyankarki whats the name of the challenge? I'll see what I did
Stephen James
@sjames1958gm
Jan 16 2017 01:12
@bigyankarki YOu can do /\W|_/g which will replace all non-word characters and _
Bigyan Karki
@bigyankarki
Jan 16 2017 01:13
check for palindroms
Stephen James
@sjames1958gm
Jan 16 2017 01:14
@fadam00 Your code will set result to the last value of i
You can return directly from inside the loop when you match the first name
Phillip Troutman
@troutman21
Jan 16 2017 01:16

function nextInLine(arr, item) {
var arr= arr.push(item);
var arr= arr.shift();
// Your code here

return arr.shift(); // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
so i know im still off but im not sure how to code what im thinking lol... any help ? @joreyesl @psbyron3

Wayne Watanabe
@WayneWatanabe
Jan 16 2017 01:17
Global vs Local Scope in Functions isn't working UGH
Jor
@joreyesl
Jan 16 2017 01:17
@troutman21 yea you are .shift() twice
Stephen James
@sjames1958gm
Jan 16 2017 01:17
@troutman21 arr.push returns a number (the new array length) so you lose the array
Then you are shifting twice - you should only shift onece
Bigyan Karki
@bigyankarki
Jan 16 2017 01:18
@joreyesl can you check your code
Stephen James
@sjames1958gm
Jan 16 2017 01:18
@troutman21 If you do return arr.shift(); then you are removing and returing the value
Wayne Watanabe
@WayneWatanabe
Jan 16 2017 01:20

// Setup
var outerWear = "T-Shirt";

function myOutfit() {
// Only change code below this line
var myOutfit = "sweater";
// Only change code above this line
return outerWear;
}

myOutfit();

Stephen James
@sjames1958gm
Jan 16 2017 01:21
@WayneWatanabe The name of the added variable inside the function should match the return
Phillip Troutman
@troutman21
Jan 16 2017 01:26
Finally got it ! thanks everyone @joreyesl @sjames1958gm
CamperBot
@camperbot
Jan 16 2017 01:26
troutman21 sends brownie points to @joreyesl and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: troutman21 already gave joreyesl points
:star2: 5350 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Krzysztof Burka
@kazcor
Jan 16 2017 01:26
hey guys!
Stephen James
@sjames1958gm
Jan 16 2017 01:27
@troutman21 :+1:
@kazcor Hello
Krzysztof Burka
@kazcor
Jan 16 2017 01:27

function palindrome(str) {
  var pal=str.toLowerCase();
  pal=pal.split("");
  pal=pal.reverse();
  pal=pal.join("");
  pal=pal.replace(/[ -`]/g, "");
  pal=pal.replace(/[:-@]/g, "");
  pal=pal.replace(/" "/g,"");
  str=str.toLowerCase();
  str=str.replace(/[ -`]/g, "");
  str=str.replace(/" "/g,"");
  str=str.toLowerCase();
  if(pal===str){return true;}
  else{return false;}
}



palindrome("1 eye for of 1 eye.");
Ted Martin
@etmartinkazoo
Jan 16 2017 01:27
Why is it necessary in "Accessing Nested Objects" lesson for the answer to use the dot notation twice and then the bracket?
Krzysztof Burka
@kazcor
Jan 16 2017 01:27
how come this sentence is supposed to return false?
Stephen James
@sjames1958gm
Jan 16 2017 01:28
@kazcor because you don't remove numbers or letters
@etmartinkazoo Because you have to use brackets if the property has a space
Krzysztof Burka
@kazcor
Jan 16 2017 01:28
thank you! @sjames1958gm
CamperBot
@camperbot
Jan 16 2017 01:28
kazcor sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5351 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Ted Martin
@etmartinkazoo
Jan 16 2017 01:29
So it is just a simple reason... Always the case! Thanks!
Stephen James
@sjames1958gm
Jan 16 2017 01:29
@kazcor You should remove the extra characters before split reverse/ join then you only replace once
@etmartinkazoo :)
grantknaver
@grantknaver
Jan 16 2017 01:31
can someone explain what this tid bit of code is doing?
mexmanny
@mexmanny
Jan 16 2017 01:31
hi all
Proyash
@PROYASH
Jan 16 2017 01:31

// Setup
function phoneticLookup(val) {
var result = "";
var lookup = {
"alpha": "Adams",
"bravo":"Boston",
"charlie": "Chicago",
"echo": "Easy",
"foxtrot": "Frank",
"" : "undefined"
};
result =lookup.val;
// Only change code above this line
return result;
}

// Change this value to test
phoneticLookup("echo");

grantknaver
@grantknaver
Jan 16 2017 01:31
function bin_to_dec(bstr) { 
    return parseInt((bstr + '')
    .replace(/[^01]/gi, ''), 2);
}
mexmanny
@mexmanny
Jan 16 2017 01:31
wanted to see if someone could help me to understand the difference between
Proyash
@PROYASH
Jan 16 2017 01:31
someone help
Jor
@joreyesl
Jan 16 2017 01:31
@bigyankarki sorry got sidetracked, Yea str.replace(/\W|_/g, "") should do what you need
Proyash
@PROYASH
Jan 16 2017 01:31
not running
mexmanny
@mexmanny
Jan 16 2017 01:31
{return myObj[checkProp];} and return myObj.checkProp?
what would be the difference
Rob McKinnon
@rwmckinnon
Jan 16 2017 01:32
Hey there, can someone help me out with a simple problem?
Bigyan Karki
@bigyankarki
Jan 16 2017 01:33

function palindrome(str) {

  var singledLetter = [];
  var reversedLetter = "";
  var appendLetter = "";

  var replaced = str.replace(/\d+/g, "");
  var replaced1 = replaced.replace(/\W|_/g, "");
  var finalStr = replaced1.toLowerCase();


  for (var i = 0; i < finalStr.length; i++) {
    singledLetter = finalStr.split("");
    reversedLetter = singledLetter.reverse();
    appendLetter = reversedLetter.join("");
  }
    if (appendLetter == finalStr) {
      return true;
    } 
  else {
    return false;
  }
  }



palindrome("Eye");

function palindrome(str) {

  var singledLetter = [];
  var reversedLetter = "";
  var appendLetter = "";

  var replaced = str.replace(/\d+/g, "");
  var replaced1 = replaced.replace(/\W|_/g, "");
  var finalStr = replaced1.toLowerCase();


  for (var i = 0; i < finalStr.length; i++) {
    singledLetter = finalStr.split("");
    reversedLetter = singledLetter.reverse();
    appendLetter = reversedLetter.join("");
  }
    if (appendLetter == finalStr) {
      return true;
    } 
  else {
    return false;
  }
  }



palindrome("Eye");
this is the code
Jor
@joreyesl
Jan 16 2017 01:34
@bigyankarki you dont need a loop to reverse. you can have those 3 lines by themselves
grantknaver
@grantknaver
Jan 16 2017 01:34
any idea guys
Rob McKinnon
@rwmckinnon
Jan 16 2017 01:34
trying to solve this problem, but I don't think I have enough info. idea is to add a second level to the array myMusic:
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
]; myMusic[1] = [
{
"artist": "the bad plus",
"title": "these are the vistas",
"release_year": 2003,
"formats": [
"CD",
"LP"
],
"gold": true
}
];
Jor
@joreyesl
Jan 16 2017 01:35
@rwmckinnon you can put your code between ``` for readability
Rob McKinnon
@rwmckinnon
Jan 16 2017 01:36
@joreyesl How's that? Just tick marks at the top and bottom?
Jor
@joreyesl
Jan 16 2017 01:36
@rwmckinnon yes
Frank V. Adames
@fadam00
Jan 16 2017 01:36
@rwmckinnon delete "myMusic[1]"
Rob McKinnon
@rwmckinnon
Jan 16 2017 01:36

var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  // Add record here 
]; myMusic[1] = [
  {
    "artist": "the bad plus",
    "title": "these are the vistas",
    "release_year": 2003,
    "formats": [
      "CD",
      "LP" 
    ],
    "gold": true
  }
];
Frank V. Adames
@fadam00
Jan 16 2017 01:36
You're not declaring another variable, you're only adding an object to the array.
Jor
@joreyesl
Jan 16 2017 01:36
@rwmckinnon :thumbsup:
CoryCMyers
@CoryCMyers
Jan 16 2017 01:36
I am confused, what did I do wrong here?
Dan Couper
@DanCouper
Jan 16 2017 01:37
You literally just need to add you other album object to the myMusic array
Frank V. Adames
@fadam00
Jan 16 2017 01:37
So delete the whole line right after //Add record here and put a comma there
Dan Couper
@DanCouper
Jan 16 2017 01:38
var myMusic = [ { existing album here }, { your album here }]
Evan Kalvis
@evan17gr
Jan 16 2017 01:38
@evan17gr
i ve tried many apis but they only work if i open the page via http and not https which is the default. Anyone know how to fix this?
https://codepen.io/evan17gr/pen/qRENOO
CoryCMyers
@CoryCMyers
Jan 16 2017 01:38
What am I doing wrong here?
Rob McKinnon
@rwmckinnon
Jan 16 2017 01:39
@fadam00 @joreyesl Super! Thanks for that, this was the first time I really got stuck and it was bugging me
CamperBot
@camperbot
Jan 16 2017 01:39
rwmckinnon sends brownie points to @fadam00 and @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 226 | @fadam00 |http://www.freecodecamp.com/fadam00
:cookie: 203 | @joreyesl |http://www.freecodecamp.com/joreyesl
Frank V. Adames
@fadam00
Jan 16 2017 01:39
@rwmckinnon , it's exactly as @DanCouper said
CoryCMyers
@CoryCMyers
Jan 16 2017 01:39
function switchOfStuff(val) {
  var answer = "";
  // Only change code below this line
switch (val) {
  case a:
    answer = "apple";
      break;
  case b:
    answer = "bird";
      break;
  case c:
    answer = "cat";
      break;
  default:
    answer = "stuff";

}



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

// Change this value to test
switchOfStuff(a);
Frank V. Adames
@fadam00
Jan 16 2017 01:39
You're welcome
CoryCMyers
@CoryCMyers
Jan 16 2017 01:39
There finally let me send that. Guess I was missing cntrl-enter
Frank V. Adames
@fadam00
Jan 16 2017 01:39
@sjames1958gm Hey! sorry I just read your message. Wouldn't a return break the loop immediately? That's why I'm using a variable instead
grantknaver
@grantknaver
Jan 16 2017 01:40
What does the 2 in this mean?
miner_paul
@aeselden92
Jan 16 2017 01:40
Im very struck and dont think my code is wrong.Help
grantknaver
@grantknaver
Jan 16 2017 01:40
```
function bin_to_dec(bstr) { 
    return parseInt((bstr + '')
    .replace(/[^01]/gi, ''), 2);
}
```
miner_paul
@aeselden92
Jan 16 2017 01:40
blob
Ive been stuck on this for awhile im sure its a silly syntax thing
Dan Couper
@DanCouper
Jan 16 2017 01:41
no spaces on ++
they aren't attached to anything at the minute
Needs to be count++
Not count ++
miner_paul
@aeselden92
Jan 16 2017 01:42
got it @DanCouper it was the extra space in bet
Dan Couper
@DanCouper
Jan 16 2017 01:44
:+1: there's the -- as well. Unary operators need to be attached to the thing they're operating on (there's a good argument to be made that they're confusing, so if you want to be explicit, you can use count = count + 1 )
miner_paul
@aeselden92
Jan 16 2017 01:45
@DanCouper Thank you for the advice!
CamperBot
@camperbot
Jan 16 2017 01:45
aeselden92 sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 445 | @dancouper |http://www.freecodecamp.com/dancouper
kevinliu6102
@kevinliu6102
Jan 16 2017 01:46
@grantknaver the returned integer is specified to be base '2', or binary
Labinot
@mrlabinotjaha
Jan 16 2017 01:46
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  switch(val) {
    case "alpha": 
      result = "Adams";
      break;
    case "bravo": 
      result = "Boston";
      break;
    case "charlie": 
      result = "Chicago";
      break;
    case "delta": 
      result = "Denver";
      break;
    case "echo": 
      result = "Easy";
      break;
    case "foxtrot": 
      result = "Frank";
  }

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

// Change this value to test
phoneticLookup("charlie");
can someone help me with this
grantknaver
@grantknaver
Jan 16 2017 01:47
@kevinliu6102 thanks
CamperBot
@camperbot
Jan 16 2017 01:47
grantknaver sends brownie points to @kevinliu6102 :sparkles: :thumbsup: :sparkles:
:cookie: 292 | @kevinliu6102 |http://www.freecodecamp.com/kevinliu6102
Jor
@joreyesl
Jan 16 2017 01:48
@mrlabinotjaha whats the error? looks alright to me
Francisco Chavez
@thetruefrank
Jan 16 2017 01:49
has someone done the stand in line challenge?
Labinot
@mrlabinotjaha
Jan 16 2017 01:49
@joreyesl that's the question itself i didnt write anything
CoryCMyers
@CoryCMyers
Jan 16 2017 01:49
@thetruefrank Whats up?
Jor
@joreyesl
Jan 16 2017 01:49
whats the challenge name? i'll check it out
Labinot
@mrlabinotjaha
Jan 16 2017 01:49
jor i wrote you on private
Francisco Chavez
@thetruefrank
Jan 16 2017 01:49
its called stand in line
Labinot
@mrlabinotjaha
Jan 16 2017 01:50
check pls
CoryCMyers
@CoryCMyers
Jan 16 2017 01:50
@joreyesl Was that whats the challenge name for me?
grantknaver
@grantknaver
Jan 16 2017 01:51
@kevinliu6102 shouldn't this thank convert binary to decimal...
CamperBot
@camperbot
Jan 16 2017 01:51
grantknaver sends brownie points to @kevinliu6102 :sparkles: :thumbsup: :sparkles:
:warning: grantknaver already gave kevinliu6102 points
grantknaver
@grantknaver
Jan 16 2017 01:51
parseInt('01000001')
or parseInt('01000001', 10);\
forget the slash
Dan Couper
@DanCouper
Jan 16 2017 01:54
@grantknaver what @kevinliu6102 said, but to add to make it maybe clearer, parseInt takes two arguments, a string (with a number in) that you want to parse, and a radix value (the base). Default is base 10, decimal, so parseInt('25') will return you 25, as will parseInt('25', 10). Note there are some caveats, you have to be careful with parseInt, I'd read the docs at MDN. Also if you want to go the other way, number to string in some base (like decimal number to binary), toString takes a single argument that lets you specify base - (25).toString(2) would be '11001'
Suraj
@suraj-davariya
Jan 16 2017 01:55

Hello May I please know : Why the value of 'i' isnt increasing ?


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


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


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


}
// Only change code above this line
}
// Change these values to test your function
lookUpProfile("Harry", "number");

Output : No such contact

Dan Couper
@DanCouper
Jan 16 2017 01:56
You are returning
So
grantknaver
@grantknaver
Jan 16 2017 01:56
didn't know that about toString(), but I knew the rest
Sarthak Khanna
@khannasarthak
Jan 16 2017 01:56
@suraj-davariya the return statement exits the function
Suraj
@suraj-davariya
Jan 16 2017 01:56
ohh i got you
what should i use then ? :(
Sarthak Khanna
@khannasarthak
Jan 16 2017 01:57
```tempvar = 'value to return'
Dan Couper
@DanCouper
Jan 16 2017 01:57
Assign it to a variable, return after loop finished
grantknaver
@grantknaver
Jan 16 2017 01:57
thanks. Just trying to figure out how to turn binary into decimal
kevinliu6102
@kevinliu6102
Jan 16 2017 01:57
@grantknaver the second input should be 2, because your first input is a binary number
Suraj
@suraj-davariya
Jan 16 2017 01:58
Thanks @DanCouper @grantknaver @khannasarthak :)
CamperBot
@camperbot
Jan 16 2017 01:58
suraj-davariya sends brownie points to @dancouper and @grantknaver and @khannasarthak :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for grantknaver
:cookie: 446 | @dancouper |http://www.freecodecamp.com/dancouper
:cookie: 124 | @khannasarthak |http://www.freecodecamp.com/khannasarthak
Suraj
@suraj-davariya
Jan 16 2017 01:58
thanks @DanCouper
CamperBot
@camperbot
Jan 16 2017 01:58
suraj-davariya sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:warning: suraj-davariya already gave dancouper points
CoryCMyers
@CoryCMyers
Jan 16 2017 01:59
Am I doing something wrong or phrasing my question incorrectly?
When I like the code I am using and trying to get the answer worked out?
Suraj
@suraj-davariya
Jan 16 2017 02:00
@khannasarthak @DanCouper @grantknaver Guys i cant find such cantacts still!!!
Sarthak Khanna
@khannasarthak
Jan 16 2017 02:01
try and use console.logs to see where your algo fails first.
Once you find a particular case, try and work around it :)
Dan Couper
@DanCouper
Jan 16 2017 02:01
@CoryCMyers does that function not take a string rather than a variable
Suraj
@suraj-davariya
Jan 16 2017 02:02
actually @khannasarthak its leading me out of the loop :fearful:
Frank V. Adames
@fadam00
Jan 16 2017 02:02
@suraj-davariya I JUST solved it, and I had a very similar format to the one you have now
Dan Couper
@DanCouper
Jan 16 2017 02:02
@CoryCMyers 'a' 'b' 'c' not a b c? The latter three would be variables, not strings
grantknaver
@grantknaver
Jan 16 2017 02:02
hmm I need to understand parseInt better. I thought the second argument changed the first the base of the first argument
Frank V. Adames
@fadam00
Jan 16 2017 02:03
For the first if statement, the nested one, try adding else if, instead of just plain else @suraj-davariya
Sarthak Khanna
@khannasarthak
Jan 16 2017 02:03
@suraj-davariya hint : break
Frank V. Adames
@fadam00
Jan 16 2017 02:03
for the else if add a condition to return a value if contacts[i].hasOwnProperty turns out to be false
CoryCMyers
@CoryCMyers
Jan 16 2017 02:03
@DanCouper Would github be the right place for a bug report? Once I removed the qoutes from the alpha and sent it, it said A was not defined but all the rest were, then I put them back in place and it said everythign was correct. Before that it was saying none of them were defined
grantknaver
@grantknaver
Jan 16 2017 02:04
@suraj-davariya what do you need
CoryCMyers
@CoryCMyers
Jan 16 2017 02:04
@DanCouper Actually, I was looking at the wrong tab one second
Sarthak Khanna
@khannasarthak
Jan 16 2017 02:04
@CoryCMyers what challenge is this?
CoryCMyers
@CoryCMyers
Jan 16 2017 02:05
@khannasarthak Adding a default option in a switch statement.
Suraj
@suraj-davariya
Jan 16 2017 02:06
yeah @fadam00 will try that out now..
@khannasarthak break :thi
CoryCMyers
@CoryCMyers
Jan 16 2017 02:06
@DanCouper When I change a b c to strings it still is telling me a is not defined
Dan Couper
@DanCouper
Jan 16 2017 02:06
@grantknaver ah, no. It takes a number in string form of some kind (like '2' or '1101' or 'fff000') as the first argument, then you specify what the radix is in the second argument, and it gives you what the decimal version of that number is (or what it thinks it is...)
@CoryCMyers you've changed the test case as well
Right at the bottom
grantknaver
@grantknaver
Jan 16 2017 02:07
so the point of parseInt is to generate a decimal number?
Dan Couper
@DanCouper
Jan 16 2017 02:08
Yup, its point is to parse a number out of a string
Like parseInt('the price is £4', 10) should be 4
Sarthak Khanna
@khannasarthak
Jan 16 2017 02:09
@CoryCMyers case 'a':
make sure the case is a string ('a','string') not a variable (a,b,variable) .
and
switchOfStuff('a');
grantknaver
@grantknaver
Jan 16 2017 02:09
that is why decimal is the default
CoryCMyers
@CoryCMyers
Jan 16 2017 02:11
@DanCouper @khannasarthak I was able to get it, thank you. Why did it not work correctly when I tried strings for the first time though? It kept telling me a was undefined. I generally do one portion and test it to see if some of the variables go through.
CamperBot
@camperbot
Jan 16 2017 02:11
corycmyers sends brownie points to @dancouper and @khannasarthak :sparkles: :thumbsup: :sparkles:
:cookie: 447 | @dancouper |http://www.freecodecamp.com/dancouper
:cookie: 126 | @khannasarthak |http://www.freecodecamp.com/khannasarthak
Evan Kalvis
@evan17gr
Jan 16 2017 02:12
can someone pls help me, my api works when the page is opened via http but not with https which is the default.Does anyone know how to fix this?http://codepen.io/evan17gr/pen/qRENOO
Sarthak Khanna
@khannasarthak
Jan 16 2017 02:13
@CoryCMyers maybe because the function call was a variable and the cases were strings? I can't be sure unless I have a look at the code you had earlier.
Dan Couper
@DanCouper
Jan 16 2017 02:13
@CoryCMyers not sure, I assume a syntax error somewhere else; it has to take strings, else the test will fail
CoryCMyers
@CoryCMyers
Jan 16 2017 02:14
@DanCouper So since I am trying to get the feel for things and learning, how can I tell when strings are needed over variables?
Jor
@joreyesl
Jan 16 2017 02:15
@CoryCMyers it should work if you use case "a":
@CoryCMyers most of the time you will be using literals
Kris
@MeanderingSoul
Jan 16 2017 02:17
Good evening everyone!!! I'm just getting started on JavaScript :smile:
Dan Couper
@DanCouper
Jan 16 2017 02:17
@CoryCMyers it isn't something you pick
Like that
A variable has to be defined
It is a pointer to something you have stored in memory
TheVip
@TheVip
Jan 16 2017 02:18

I'm on the challenge 'Return Largest Numbers From Arrays' and I've witten some code for the challenge but the code instead o returning largest numbers from each array , it returns the array containing the largest numbers. Please tell me what I am doing wrong

Challenge Url%20%7B%0A%20%20%2F%2F%20You%20can%20do%20this!%0A%20%20%0A%20%20%2F%2FYes%20I'll%20do%20this!!!!%0A%20%20%0A%20%20var%20largestNum%3B%0A%20%20for(var%20i%3D0%3B%20i%20%3C%20arr.length%3B%20i%2B%2B)%7B%0A%20%20%20%20largestNum%20%3D%20arr%5Bi%5D%3B%0A%20%20%20%20for(var%20j%3D0%3B%20j%20%3C%20arr%5Bi%5D.length%3B%20j%2B%2B)%7B%0A%20%20%20%20%20%20if(largestNum%3Carr%5Bi%5D%5Bj%5D)%7B%0A%20%20%20%20%20%20%20%20largestNum%20%3D%20arr%5Bi%5D%5Bj%5D%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20%0A%20%20return%20largestNum%3B%0A%7D%0A%0AlargestOfFour(%5B%5B4%2C%205%2C%201%2C%203%5D%2C%20%5B13%2C%2027%2C%2018%2C%2026%5D%2C%20%5B32%2C%2035%2C%2037%2C%2039%5D%2C%20%5B1000%2C%201001%2C%20857%2C%201%5D%5D)%3B%0A)

Dan Couper
@DanCouper
Jan 16 2017 02:18
If you haven't stored it, you can't use it - it doesn't exist
In this case you have a function that should accept a string as an argument.
So you give it a string
Jor
@joreyesl
Jan 16 2017 02:20
@TheVip can you put your code here?
fernando Reyna
@frr225
Jan 16 2017 02:21
i want to delete duplicates in my final string but .slice doesn't work at the end of the code even though i used the same expresion at the beggining tarr =arr[i].split('-'); is good, but the expression final.split(' '); doesn't work here is the code

function makeFriendlyDates(arr) {

var tarr=""; var final=[]; var temp=""; var month; var year; var day; var mic=" ";
for(var i =0; i< arr.length; i++){
tarr =arr[i].split('-');
year=tarr[0];month=tarr[1]; day=tarr[2];
day = parseInt(day, 10);

if(year!= 2016) { temp= temp+year; }


if( month.includes("1")) {month = ' January';  }
if( month.includes("2")) {month = ' February'; }
if( month.includes("3")) {month = ' March';    }
if( month.includes("4")) {month = ' April';    }
if( month.includes("5")) {month = ' May';      }
if( month.includes("6")) {month = ' June';     }
if( month.includes("7")) {month = 'July';     }
if( month.includes("8")) {month = ' August';   }
if( month.includes("9")) {month = ' September';}
if( month.includes("10")){month = ' Octuber';  }
if( month.includes("11")){month = ' November'; }
if( month.includes("12")){month = ' December'; }

if( day==1) { day = ' 1st'; }

else if( day==3) { day = ' 3rd'; }
else{
day =" "+ day + 'th'; }

 temp = temp+month+day;

final.push(temp);
temp="";
}

return final.split(' ');

Dan Couper
@DanCouper
Jan 16 2017 02:21
@CoryCMyers Variables are for referring to pieces of information, values, you want to store. Strings are a type of value.
TheVip
@TheVip
Jan 16 2017 02:21
@joreyesl , sure.....
function largestOfFour(arr) {
  // You can do this

  var largestNum;
  for(var i=0; i < arr.length; i++){
    largestNum = arr[i];
    for(var j=0; j < arr[i].length; j++){
      if(largestNum<arr[i][j]){
        largestNum = arr[i][j];
      }
    }
  }

  return largestNum;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Jor
@joreyesl
Jan 16 2017 02:23
ok inside the first loop you have this largestNum = arr[i]; thats setting it equal to an array
TheVip
@TheVip
Jan 16 2017 02:24
thats what i wanted
Dan Couper
@DanCouper
Jan 16 2017 02:25
@frr225 what should be the input/output here? A single date in and out?
Jor
@joreyesl
Jan 16 2017 02:25
@TheVip ok sorry, dont know the challenge. But it looks like what they want you to do is create an array out of the largest of each sub-array
Kris
@MeanderingSoul
Jan 16 2017 02:25
I'm trying to do the initial Celsius to Fahrenheit challenge and I'm having issues figuring it out can anyone help?
TheVip
@TheVip
Jan 16 2017 02:26
@joreyesl , Yes
CoryCMyers
@CoryCMyers
Jan 16 2017 02:27
@DanCouper Thank you!
CamperBot
@camperbot
Jan 16 2017 02:27
corycmyers sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:warning: corycmyers already gave dancouper points
Dan Couper
@DanCouper
Jan 16 2017 02:27
:thumbsup:
CoryCMyers
@CoryCMyers
Jan 16 2017 02:27
There is a lot to get my head around.
DF
@freecodecamper23
Jan 16 2017 02:27
Having problems with this
function getIndexToIns(arr,num) {
return num;
}
getIndexToIns([40, 60], 50);
how do I sort this
Jor
@joreyesl
Jan 16 2017 02:30
@TheVip ok so something like this
var largestArray; // create array to hold largest from each sub-array here
//this loop cycles through each sub-array
  for(var i=0; i < arr.length; i++){
    var largestNum = 0; // reset the largest num before each sub-array

    //this loop finds the largestNum in each subarray
    for(var j=0; j < arr[i].length; j++){
      if(largestNum<arr[i][j]){
        largestNum = arr[i][j];
      }
    }
    // add the largestNum from the currest sub-array to the largestArray here
  }

// return the array here
fernando Reyna
@frr225
Jan 16 2017 02:32
@DanCouper ["July 1st","4th"]. should be my answer returns ["July 1st"," July 4th"]. so i want to split final on the space to delete the repeted July
TheVip
@TheVip
Jan 16 2017 02:34
@joreyesl , got it what you are saying....Thanks!
Dan Couper
@DanCouper
Jan 16 2017 02:35
ok, the code is extremely complex here, having difficulty following. Final is an array, so can’t split. Note you’ve missed out ‘nd’ for days - ‘2nd’, ‘22nd’. ‘23rd’. ‘21st'
@frr225
Brendon Bradley
@brenbrad
Jan 16 2017 02:36
var myVar = 87; how do i input the ++
Ayman Mohatarem
@AymanxD
Jan 16 2017 02:36
Hey guys, did navigator geolocation stop working?
Brendon Bradley
@brenbrad
Jan 16 2017 02:36
so it equals 88
Jor
@joreyesl
Jan 16 2017 02:38
@brenbrad myVar++ this is the same as saying myVar = myVar + 1 or myVar += 1
TheVip
@TheVip
Jan 16 2017 02:38
@joreyesl , what if we assume largestArray variable an array from starting, so it will be declared like this
var largestArray = [];
Jor
@joreyesl
Jan 16 2017 02:38
@TheVip :thumbsup:
Brendon Bradley
@brenbrad
Jan 16 2017 02:38
right on Thaks @joreyesl
thanks @joreyesl
CamperBot
@camperbot
Jan 16 2017 02:38
brenbrad sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 208 | @joreyesl |http://www.freecodecamp.com/joreyesl
Brian
@BrianCodes33
Jan 16 2017 02:39
function isPrime(value) {
    for(var i = 2; i < value; i++) {
        if(value % i === 0) {
            return false;
        }
    }
     return value.reduce(function(a,b){
         return a + b;
  });
}
anyone?
fernando Reyna
@frr225
Jan 16 2017 02:39
ggg
Sarthak Khanna
@khannasarthak
Jan 16 2017 02:40
@BrianCodes33 whats wrong with it?
Brian
@BrianCodes33
Jan 16 2017 02:40
once i put in prime num it gives me error
fernando Reyna
@frr225
Jan 16 2017 02:40
@DanCouper should i save the values in vars?
Brian
@BrianCodes33
Jan 16 2017 02:41
so my goal was to filter out non prime nums
and then grab the prime and add it
TheVip
@TheVip
Jan 16 2017 02:42
@joreyesl ,
Wohooo!!!!!!! I changed the code and it worked :clap: Thanks again!
function largestOfFour(arr) {
  // You can do this

  var largestNum = [];
  for(var i=0; i < arr.length; i++){
    largestNum[i] = [0]; 
    for(var j=0; j < arr[i].length; j++){
      if(largestNum[i]<arr[i][j]){
        largestNum[i] = arr[i][j];
      }
    }
  }

  return largestNum;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
CamperBot
@camperbot
Jan 16 2017 02:42
thevip sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 210 | @joreyesl |http://www.freecodecamp.com/joreyesl
Sarthak Khanna
@khannasarthak
Jan 16 2017 02:42
@BrianCodes33 try using a flag instead of returning directly from the if
when your if block is run, it exits the function due to the return
Dan Couper
@DanCouper
Jan 16 2017 02:42

@frr225 Note also:

> var myDate = new Date('2016-07-01');
> myDate.getFullYear()
2016
> myDate.getMonth()
6
> myDate.getDay()
5
> myDate.getDate()
1

The month is zero-indexed, so instead of it being 7, it is 6, which means you can do this:

function engMonth(n){
  var months = ['January','February','March','April','May','June','July','August','September','October','November','December’]
  return months[n];
}

As are the days of the week (which getDay returns)

Jor
@joreyesl
Jan 16 2017 02:43
@TheVip there you go, thats actually more concise than my example. :thumbsup:
Sarthak Khanna
@khannasarthak
Jan 16 2017 02:44
@BrianCodes33 Could you give the link of the challenge?
Brian
@BrianCodes33
Jan 16 2017 02:44
function isPrime(value) {
    for(var i = 2; i < value; i++) {
        if(value % i === 0) {
            return false;
        }
    }
    return add(value);
}

function add(value){
    return value.reduce(function(a,b){
        return a + b;
  },0);
}
TheVip
@TheVip
Jan 16 2017 02:44
@joreyesl , happy to get that compliment
Sarthak Khanna
@khannasarthak
Jan 16 2017 02:48
fahrenheit = (celsius*9/5) + 32;
You have written
fahrenheit = (fahrenheit*9/5) + 32;
Timothy Hoang
@timh1203
Jan 16 2017 02:49
That totally fixed it, I understand now. Thanks @khannasarthak
CamperBot
@camperbot
Jan 16 2017 02:49
timh1203 sends brownie points to @khannasarthak :sparkles: :thumbsup: :sparkles:
:cookie: 133 | @khannasarthak |http://www.freecodecamp.com/khannasarthak
Dan Couper
@DanCouper
Jan 16 2017 02:50

@BrianCodes33 reduce works on arrays, you need an array of numbers to do what you’re trying to do there

If you do it that way, you need a list of numbers: 2, then odd numbers up to the number going into the argument. Then check each; if it is prime add, if not, ignore.

there are more efficient ways. Easiest and by far the most efficient is to just have a big list of prime numbers, and grab up the number going into the function, and add them up

Brian
@BrianCodes33
Jan 16 2017 02:51
ok
what do you mean grab up the number
Chika Chikwendu
@CheeZeee
Jan 16 2017 02:57
Someone please tell me what I need t
*need to change in the case 7, 8, 9

switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      break;
    case 7:
    case 8:
    case 9:
      count += 0;
      break;
    case 10:
    case 'J':
    case 'K':
    case 'Q':
    case 'A':
      count--;
      break;
Hanqi Liu
@LicheeLiu
Jan 16 2017 02:59
Inside function fun1, assign 5 to oopsGlobal without using the var keyword.
how to assign 5 to a variable when not using var keyword
kevinliu6102
@kevinliu6102
Jan 16 2017 03:01
@LicheeLiu just type the assignment without typing var first
@CheeZeee i don't remember how that question works but count += 0 does nothing
Hanqi Liu
@LicheeLiu
Jan 16 2017 03:01
okay, then?
oh, I got it. @kevinliu6102
kevinliu6102
@kevinliu6102
Jan 16 2017 03:02
then run the tests?
Hanqi Liu
@LicheeLiu
Jan 16 2017 03:02
thanks
Kris
@MeanderingSoul
Jan 16 2017 03:05
Has anyone worked on the Fahrenheit to Celsius challenge that can assist me?! I can get it to give me a number but the results aren't matching what it says they should....
Jason Luboff
@JLuboff
Jan 16 2017 03:05
@MeanderingSoul Whats your code
Kris
@MeanderingSoul
Jan 16 2017 03:05

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

fahrenheit = celsius * 5 % 9 + 32;

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

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

Jason Luboff
@JLuboff
Jan 16 2017 03:06
@MeanderingSoul Your formula is incorrect
Kris
@MeanderingSoul
Jan 16 2017 03:06
I get 32 in this instance
Jason Luboff
@JLuboff
Jan 16 2017 03:06
@MeanderingSoul Its celsius * 9/5 + 32
Kris
@MeanderingSoul
Jan 16 2017 03:07
Haha!!! I guess the order of the 5 and 9 do make a big difference!!! LOL! Thanks @JLuboff
CamperBot
@camperbot
Jan 16 2017 03:07
meanderingsoul sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:cookie: 636 | @jluboff |http://www.freecodecamp.com/jluboff
Jason Luboff
@JLuboff
Jan 16 2017 03:07
:+1: \
sega1219
@sega1219
Jan 16 2017 03:10
could someone please help me

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


function lookUpProfile(firstName, prop){
// Only change code below this line
var result="";
  for(var i=0; i < contacts.length;i++){


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


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

// Change these values to test your function
lookUpProfile("Harry", "likes");
Adel
@AdelMahjoub
Jan 16 2017 03:10
if you someone want to kill some zombies https://codepen.io/SultanCodeCamper/full/jyMGMe/
Adel
@AdelMahjoub
Jan 16 2017 03:16
arrow keys to move, mouse move to aim and left click to shoot
Charan
@charan1998
Jan 16 2017 03:16
Can someone help me with transition effects for my project?!
Sarthak Khanna
@khannasarthak
Jan 16 2017 03:23
@ @sega1219 use break
sega1219
@sega1219
Jan 16 2017 03:25
@khannasarthak where?
fernando Reyna
@frr225
Jan 16 2017 03:25

@DanCouper ok after a little play I came up with this code mic = final[0]+final[1];
mic =mic.split(" ");
var unique = mic.filter(function(elem, index, self) {
return index == self.indexOf(elem);
});
unique = unique.join(" ");

return unique;//temp+day;
} does delete the repeated July fine but now when i try to join i get this July 1st 4th or July ,1st, 4th what i need is "July 1st, 4th" any hints how to do that?

Sarthak Khanna
@khannasarthak
Jan 16 2017 03:25
@sega1219
if(contacts[i].firstName===firstName){
          if(contacts[i].hasOwnProperty(prop)===true){
            result = contacts[i][prop]; 
            break;
          }
          else if (contacts[i].hasOwnProperty(prop)=== false){
            result="No such property";
            break;
          }
      }
      else{
        result="No such contact";

      }
Michael Pimentel Jr
@mtpjr88
Jan 16 2017 03:26
is there a bug?

// Example
var ourArray = [];

for (var i = 1; i < 6; i++) {
  ourArray.push(i);
}

// Setup
var myArray = [];

// Only change code below this line.
myArray = ourArray;
Manish Giri
@Manish-Giri
Jan 16 2017 03:27
@mtpjr88 myArray = ourArray;
why this?
Jor
@joreyesl
Jan 16 2017 03:27
@mtpjr88 yea you are setting myArray = ourArray you should not need to use their array. You need to fill your own array
sega1219
@sega1219
Jan 16 2017 03:27
ohhhhh @khannasarthak thank you so much
CamperBot
@camperbot
Jan 16 2017 03:27
sega1219 sends brownie points to @khannasarthak :sparkles: :thumbsup: :sparkles:
:cookie: 135 | @khannasarthak |http://www.freecodecamp.com/khannasarthak
Jor
@joreyesl
Jan 16 2017 03:29
@sega1219 you should not be returning anything inside of the loop. You should loop through the entire list before deciding if you need to return "No such contact" or "No such property"
fernando Reyna
@frr225
Jan 16 2017 03:30
DanCouper ok after a little play I came up with this code mic = final[0]+final[1];
mic =mic.split(" ");
var unique = mic.filter(function(elem, index, self) {
return index == self.indexOf(elem);
});
unique = unique.join(" ");
return unique;//temp+day;
} does delete the repeated July fine but now when i try to join i get this July 1st 4th or July ,1st, 4th what i need is "July 1st, 4th" any hints how to do that?
yourpalsneakers
@yourpalsneakers
Jan 16 2017 03:31
Can someone explain why this works the way it does? I played around with it until it worked, but I still don't understand why "no such contact" has to be outside the loop to work, but "no such property" does not...
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
  if (firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
    return contacts[i][prop];
  }
  else if (contacts[i].hasOwnProperty(prop) === false) {
    return "No such property";
  }
}
return "No such contact";
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Jor
@joreyesl
Jan 16 2017 03:32
@yourpalsneakers in real world that could would fail in certain scenarios. You should not be returning anything prematurely before you loop through the entire list
yourpalsneakers
@yourpalsneakers
Jan 16 2017 03:34
@joreyesl I'm not quite sure what you mean by that; can you give an example of how this would be done properly?
Jor
@joreyesl
Jan 16 2017 03:37
@yourpalsneakers sure give me a sec to write something
Sarthak Khanna
@khannasarthak
Jan 16 2017 03:37
@yourpalsneakers
function lookUpProfile(firstName, prop){
// Only change code below this line
var result="";
  for(var i=0; i < contacts.length;i++){


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


}
return result;
// Only change code above this line
}
with break after result = contacts[i][prop]; and result="No such property";
if(contacts[i].firstName===firstName){
          if(contacts[i].hasOwnProperty(prop)===true){
            result = contacts[i][prop]; 
            break;
          }
          else if (contacts[i].hasOwnProperty(prop)=== false){
            result="No such property";
            break;
          }
      }
      else{
        result="No such contact";

      }
Jor
@joreyesl
Jan 16 2017 03:49
@yourpalsneakers
function lookUpProfile(firstName, prop){

var foundName = false; //this is to keep track if we ever got a match for the name
var foundProp = false; //this is to keep track if we ever got a match for the prop
for(var i=0; i < contacts.length;i++){
  //if we find the correct contact and they have the prop we return it right away
  // no need to keep looking through the list
  if(contacts[i].firstName===firstName && contacts[i].hasOwnProperty(prop)===true){
    return contacts[i][prop];
  }

  //if we ever get a match for the name, we need to change it to true
  if(contacts[i].firstName===firstName) {
    foundName = true;
  }

  //if any of the contacts have that prop then we will change it to true
  if(contacts[i].hasOwnProperty(prop)===true) {
    foundProp = true;
  }
}

//if the loop does not find a match for name+prop then it will end up here
//now we can check if the name or prop does not exist

//if we didnt match the name then this will execute
if(foundName !== true) {
  return "No such contact";
}

//if we didnt match the prop then this will execute
if(foundProp !== true) {
  return "No such property";
}

}
yourpalsneakers
@yourpalsneakers
Jan 16 2017 03:55
@khannasarthak @joreyesl thanks, very helpful!
CamperBot
@camperbot
Jan 16 2017 03:55
yourpalsneakers sends brownie points to @khannasarthak and @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 136 | @khannasarthak |http://www.freecodecamp.com/khannasarthak
:cookie: 218 | @joreyesl |http://www.freecodecamp.com/joreyesl
TheVip
@TheVip
Jan 16 2017 03:57
@joreyesl , bro in the challenge 'Truncate A String' they tell that inserting the three dots to the end will add to the string length what actually they wanted to say?
Jor
@joreyesl
Jan 16 2017 03:58
@TheVip let me look up the chall real quick
TheVip
@TheVip
Jan 16 2017 03:58
confused :panda_face:
sure!
Jor
@joreyesl
Jan 16 2017 04:00
@TheVip oh so basically, say you have the string "Hello World!" but you need to truncate the string to only 3 characters then they want you to return this "Hel..."
on further reading, they also want you to take into account the "..." so if num > 3 then when you figure the final string length you have to take into account "..." so 3 extra characters.
TheVip
@TheVip
Jan 16 2017 04:07
@joreyesl ,still not getting it, do you mean if number is 4 then answer should be H... ??
Matheus Vicente
@chamatt
Jan 16 2017 04:07
Guys, i need some help undestanding whats going on here. I know what it's doing, but what i don't undestand is the "val" thats being passed to the function, it wasn't declared, so what is it supposed to be? Is it a reserved word in javascript?
var oldArray = [1, 2, 3];
var timesFour = oldArray.map(function(val){
  return val * 4;
});
console.log(timesFour); // returns [4, 8, 12]
console.log(oldArray);  // returns [1, 2, 3]
Jor
@joreyesl
Jan 16 2017 04:08
@TheVip
yes, thats it. If num > 3, say num = 5 then "He..." is correct. But if num <= 3, say num =3, then "Hel..." is correct even though its 6 characters long.
TheVip
@TheVip
Jan 16 2017 04:10
@joreyesl , Fyn, I think i can complete the challenge now. Thanks bro!
CamperBot
@camperbot
Jan 16 2017 04:10
thevip sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 219 | @joreyesl |http://www.freecodecamp.com/joreyesl
Jor
@joreyesl
Jan 16 2017 04:10
@TheVip np, good luck :thumbsup:
Brian Rigoni
@BrianRigoni
Jan 16 2017 04:13
Hello people!
Im stuck in the "Stand in Line" of Javascript, can anyone help me please?
Austiclyse
@Austiclyse
Jan 16 2017 04:15
@BrianRigoni Yeah, which part?
Brian Rigoni
@BrianRigoni
Jan 16 2017 04:16
Write a function nextInLine 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 nextInLine function should then return the element that was removed.
Austiclyse
@Austiclyse
Jan 16 2017 04:17
@BrianRigoni What do you know so far or are you totally in the dark?
Matheus Vicente
@chamatt
Jan 16 2017 04:18
use .push to add a new element and .shift to remove the first, and display the element that was shifted.
Brian Rigoni
@BrianRigoni
Jan 16 2017 04:18
since this waypoint I was totally secure about what I was learning
Reggie
@Reggie01
Jan 16 2017 04:18
@chamatt map function documentation. Map iterates through each item in the array and calls the callback function on each item. At index 0, the number 1 would be passed to the callback function as the first argument.
var oldArray = [1, 2, 3];
function( 1 ) {  // val is replaced by index 0, which value is one.
  return 1 * 4;
}
Matheus Vicente
@chamatt
Jan 16 2017 04:19
I think i get it, the function assigns each value of the array to the val i pass to the function
But i'll read more about callbacks so i can undestand it properly. Thanks for the help!
Manuel Rauda
@Gameruler1
Jan 16 2017 04:20
i have the same issue as @BrianRigoni i'm stuck on "stand in line" and don't have a clue of what to do
Austiclyse
@Austiclyse
Jan 16 2017 04:21
@BrianRigoni lol this course does that to me a lot, too. Especially at the end of JS. I had to go on Stack Overflow and ask just to find out. Here's what they showed me:
    function nextInLine(arr, item) {
      // Your code here
      arr.push(item);
      var nextItem = arr.shift();
      return nextItem;  // Change this line
    }

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

    // Display Code
    console.log("Before: " + JSON.stringify(testArr));
    console.log(nextInLine(testArr, 6)); // Modify this line to test
    console.log("After: " + JSON.stringify(testArr));
Brian Rigoni
@BrianRigoni
Jan 16 2017 04:21
THAT'S IT!! I was trying to remember the shift and push
My mind was kind of blind, Now I have an idea of what to do, Thanks @Austiclyse
CamperBot
@camperbot
Jan 16 2017 04:22
brianrigoni sends brownie points to @austiclyse :sparkles: :thumbsup: :sparkles:
:cookie: 210 | @austiclyse |http://www.freecodecamp.com/austiclyse
Manuel Rauda
@Gameruler1
Jan 16 2017 04:22
ohh ok thank you @Austiclyse !
CamperBot
@camperbot
Jan 16 2017 04:22
:cookie: 211 | @austiclyse |http://www.freecodecamp.com/austiclyse
gameruler1 sends brownie points to @austiclyse :sparkles: :thumbsup: :sparkles:
William Cross
@williamtech814
Jan 16 2017 04:22
having trouble with challenge Profile Lookup
code:
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
for(i=0;i<contacts.length;i++){
  if(contacts[i][firstName]===firstName){
    return "No such contact";
  }else if(contacts[i][prop].hasOwnProperty()===false){
    return "No such property";
  }else{
    return contacts[i][prop];
}}

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Jor
@joreyesl
Jan 16 2017 04:23
@Gameruler1 They want you to add item to the end of arr then remove the first num in arr and return that value
you can use .push() to put a value to the end of an array and .shift() to remove the value at the beginning of an array.
Austiclyse
@Austiclyse
Jan 16 2017 04:23
@BrianRigoni I couldn't figure out the reason for the structure or syntax. But I'm glad this helped.
Ammy3165
@Ammy3165
Jan 16 2017 04:23

Hi, I am working on Return Largest Numbers in Arrays, Help me to find out why my code is not working,
function largestOfFour(arr) {
// You can do this!
var largestNum=0;
var results= [];
for(var i=0; i<arr.length; i++){
for(var j=0; j<arr[i].length; j++){

 if(largestNum< arr[i][j]){
   largestNum= arr[i][j];
}
    results[i]= largestNum;

}
}
return results;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

Manuel Rauda
@Gameruler1
Jan 16 2017 04:24
thank you @joreyesl
CamperBot
@camperbot
Jan 16 2017 04:24
gameruler1 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 223 | @joreyesl |http://www.freecodecamp.com/joreyesl
Ammy3165
@Ammy3165
Jan 16 2017 04:24
Is here anyone can help me
Pls see my challenge above
Brad Hain
@Bhain1431
Jan 16 2017 04:25
How do
var myStr ="FirstLine\n\SecondLine\r\ThridLine";
do this? myStr should have encoded text with the proper escape sequences and no spacing.
Jor
@joreyesl
Jan 16 2017 04:25
@Ammy3165 you need to reset the largestNum after each iteration of the nested loop
otherwise it will retain the largest from the previous sub-array
for(var i=0; i<arr.length; i++){
  largestNum = 0; // reset the largest since we will be looking at a new sub-array
  for(var j=0; j<arr[i].length; j++){

    if(largestNum< arr[i][j]){
       largestNum= arr[i][j];
  }
    results[i]= largestNum;

}
Ammy3165
@Ammy3165
Jan 16 2017 04:27
@joreyesl thanks i got it.
CamperBot
@camperbot
Jan 16 2017 04:27
ammy3165 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 224 | @joreyesl |http://www.freecodecamp.com/joreyesl
Austiclyse
@Austiclyse
Jan 16 2017 04:27
@williamtech814 man, i'm stuck on this one, too. The instructions just go to all crap in some of these challenges.
William Cross
@williamtech814
Jan 16 2017 04:28
@Austiclyse I get what the purpose of the challenge is, I'm just so confused on how to execute it...
Jor
@joreyesl
Jan 16 2017 04:28
@Austiclyse @williamtech814 which challenge is it?
William Cross
@williamtech814
Jan 16 2017 04:28
Profile Lookup
code:
Ezra
@EzraPlato
Jan 16 2017 04:28
Stuck on 137 fahrenheit to celsius problem. I have celsius = 30;
celsius *= 9/5 + 32;
William Cross
@williamtech814
Jan 16 2017 04:28
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
for(i=0;i<contacts.length;i++){
  if(contacts[i][firstName]===firstName){
    return "No such contact";
  }else if(contacts[i][prop].hasOwnProperty()===false){
    return "No such property";
  }else{
    return contacts[i][prop];
}}

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Ammy3165
@Ammy3165
Jan 16 2017 04:29
@Bhain1431 just read the instruction again, and find out what's the fix for backslash.
Manish Giri
@Manish-Giri
Jan 16 2017 04:29
@williamtech814 does this seem logical?
if(contacts[i][firstName]===firstName){
    return "No such contact";
  }
Austiclyse
@Austiclyse
Jan 16 2017 04:29
@joreyesl Profile Lookup. End of JS section
Manish Giri
@Manish-Giri
Jan 16 2017 04:29
@williamtech814 if you find a matching first name, you return "no such contact"??
William Cross
@williamtech814
Jan 16 2017 04:29
Yeah it should be !==
makes sense @Manish-Giri
Manish Giri
@Manish-Giri
Jan 16 2017 04:30
@williamtech814 keep the === but change the conditions
William Cross
@williamtech814
Jan 16 2017 04:30
@Manish-Giri ?
Jor
@joreyesl
Jan 16 2017 04:31
@williamtech814 @Austiclyse ok a lot of ppl have trouble with that one. I think ive writting it like 10 times now. Ok so the one thing I see people doing is that they want to return "No such contact" and "No such property" inside the loop. But this causes a problem because it will return either of those the first time it doesnt find a match. The contact you are looking for could be at the end of the list and you will never find it because of it. What you need to do instead is use boolean to keep track of when you get a match for name or prop. Then at the end of the loop if you didnt find the contact then you can use if statements to find if it was either "No such contact" or "No such property"
Manish Giri
@Manish-Giri
Jan 16 2017 04:31
- loop through the contacts
1. if firstname is a match 
  a. if property exists - return the value
  b. else if property doesn't exist - return "no such prop"
- once outside loop, return "No such contact"
@williamtech814
William Cross
@williamtech814
Jan 16 2017 04:33
I see
@Manish-Giri thanks, I think I get it
CamperBot
@camperbot
Jan 16 2017 04:33
williamtech814 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3803 | @manish-giri |http://www.freecodecamp.com/manish-giri
Ken Haduch
@khaduch
Jan 16 2017 04:33

@williamtech814 @Austiclyse - I'm not going to be on for very long, but a couple hints for this profile exercise

  • always use contacts[i] to access an object from the contacts array
  • you can use contacts[i].firstName, or contacts[i]["firstName"] to access the firstName property in a contact record
  • your for loop's purpose is to iterate through all of the contacts and search for a match, based on the firstName parameter that is passed in. When you find a match, you can then use .hasOwnProperty(prop) to search for the property - there has to be an argument supplied to .hasOwnProperty() and it has to be the prop variable
  • If you return from the function with "No such contact" status from within the for loop, you will not pass all of the tests. You have to be able to test all of the contacts or some of the tests will fail. Do not return "No such contact" before you can check all contacts entries.

Those are my hints, and I see that @Manish-Giri has also given information... Good luck!

Manish Giri
@Manish-Giri
Jan 16 2017 04:34
:+1:
Austiclyse
@Austiclyse
Jan 16 2017 04:34
Wow. I wish half the ppl in here gave explanations like that. Thank you @joreyesl and @Manish-Giri
CamperBot
@camperbot
Jan 16 2017 04:34
austiclyse sends brownie points to @joreyesl and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 226 | @joreyesl |http://www.freecodecamp.com/joreyesl
:star2: 3804 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jan 16 2017 04:34
ty @Austiclyse
CamperBot
@camperbot
Jan 16 2017 04:34
manish-giri sends brownie points to @austiclyse :sparkles: :thumbsup: :sparkles:
:cookie: 212 | @austiclyse |http://www.freecodecamp.com/austiclyse
William Cross
@williamtech814
Jan 16 2017 04:35
@khaduch thanks, very helpful :)
CamperBot
@camperbot
Jan 16 2017 04:35
williamtech814 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2285 | @khaduch |http://www.freecodecamp.com/khaduch
caneno
@caneno
Jan 16 2017 04:35
Hi everybody
I am kind of stuck with a javascript challenge
Austiclyse
@Austiclyse
Jan 16 2017 04:36
and ty @khaduch
CamperBot
@camperbot
Jan 16 2017 04:36
austiclyse sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2286 | @khaduch |http://www.freecodecamp.com/khaduch
caneno
@caneno
Jan 16 2017 04:37
how to I return a removed element form an array
Manish Giri
@Manish-Giri
Jan 16 2017 04:37
@caneno which one
to remove the first element, use .shift()
to return it, use return
caneno
@caneno
Jan 16 2017 04:39
yes but when working in a function and the parameters are an array and a number, I have to return the element that has been removed from the array, how do I do that if the element has disappear because I removed it
Manish Giri
@Manish-Giri
Jan 16 2017 04:40
use return
along with .shift()
Reggie
@Reggie01
Jan 16 2017 04:41

@EzraPlato

celsius *= 9/5 + 32  // This evaluates (9/5)+32, then multiplies by 30

so write it out long form

                    expression
celsius = celsius * (9/5) + 32 // will evaluate expression left to right
caneno
@caneno
Jan 16 2017 04:41
ok just a sec let me tryit
dazewerk
@dazewerk
Jan 16 2017 04:44
I sheepishly need help with 'Testing Objects for Properties'
'''
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty("checkProp") === true) {
return myObj.checkprop;
}
}
// Test your code by modifying these values
checkObj("pet");
CamperBot
@camperbot
Jan 16 2017 04:44
:bulb: to format code use backticks! ``` more info
dazewerk
@dazewerk
Jan 16 2017 04:45
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};
function checkObj(checkProp) {
  // Your Code Here
 if (myObj.hasOwnProperty("checkProp") === true) {
    return myObj.checkprop;
  }
}
// Test your code by modifying these values
checkObj("pet");
Manish Giri
@Manish-Giri
Jan 16 2017 04:45
@dazewerk myObj.hasOwnProperty("checkProp")
remove quotes here
you want to use the checkProp variable, not the string "checkProp"
next, use bracket notation here - return myObj.checkprop;
Ezra
@EzraPlato
Jan 16 2017 04:46

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

Fahrenheit = celsius;
celsius = 30;
celsius *= 9/5 +32;

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

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

CamperBot
@camperbot
Jan 16 2017 04:46
no wiki entry for: function converttofcelsius var fahrenheit only change code below this line fahrenheit celsius celsius 30 celsius 95 32 only change code above this line return fahrenheit change the inputs below to test your codeconverttof30
Manish Giri
@Manish-Giri
Jan 16 2017 04:47
@EzraPlato what's this?
 Fahrenheit = celsius;
celsius = 30;
celsius *= 9/5 +32;
caneno
@caneno
Jan 16 2017 04:47
blob
every time I try one I get an ec to the other one
I get an X
Manish Giri
@Manish-Giri
Jan 16 2017 04:48
@caneno put return on line 5
delete line 6
__mifflin__
@cdrainxv
Jan 16 2017 04:49
@caneno: Return what you just shifted out of the arr array. Remove line 6.
Brian Rigoni
@BrianRigoni
Jan 16 2017 04:49
@EzraPlato remember that fahrenheit is equal to Celcius * 9/5 + 32
Manish Giri
@Manish-Giri
Jan 16 2017 04:49
you want to use arr not testArr
@caneno
Brian Rigoni
@BrianRigoni
Jan 16 2017 04:49
@EzraPlato So, it will be: fahrenheit = celsius * 9/5 + 32
@EzraPlato try with that
caneno
@caneno
Jan 16 2017 04:49
you guys are awesome
dazewerk
@dazewerk
Jan 16 2017 04:51
@Manish-Giri Thank you :smile:
CamperBot
@camperbot
Jan 16 2017 04:51
dazewerk sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3806 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jan 16 2017 04:51
@dazewerk :+1:
caneno
@caneno
Jan 16 2017 04:51
@Manish-Giri @cdrainxv Thanks guys
CamperBot
@camperbot
Jan 16 2017 04:51
caneno sends brownie points to @manish-giri and @cdrainxv :sparkles: :thumbsup: :sparkles:
:star2: 2102 | @cdrainxv |http://www.freecodecamp.com/cdrainxv
:star2: 3807 | @manish-giri |http://www.freecodecamp.com/manish-giri
Brian Rigoni
@BrianRigoni
Jan 16 2017 04:52
@EzraPlato Remove the line "Celius = 30;". and also the "Celsius*=9/5 +32;" Because the number 30 you are trying to multiply 9/5 and add 32, is the function that you are creating, Remember that celsius is not equal to 9/5 + 32, fahrenheit is
I mean, Celsius is equal to Celsius
as fahrenheit is equal to fahrenheit. BUT if you want to convert a Celsius to a Fahrenheit. For example 2°C to Fahrenheit it would be. Fahrenheit = 2 * 9/5 + 32 --> this would be
Fahrenheit = 35,6
ujjwaljain0
@ujjwaljain0
Jan 16 2017 04:57
var myStr = "Firstline \n \SecondLine\ \r ThirdLine"; // Change this line
whats the problem with this
Jor
@joreyesl
Jan 16 2017 04:58
@ujjwaljain0 Firstline should be FirstLine
ujjwaljain0
@ujjwaljain0
Jan 16 2017 04:58
still it isnt accepting it
Jor
@joreyesl
Jan 16 2017 05:00
also the extra \ gets deleted here, but make sure you are escaping the \ around SecondLine
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 05:01
var sexy = {name: 'randy', age: 12};

function addProperty(obj, key) {
  // your code here
   obj.key = true;
}

addProperty(sexy, 'isOld');
whenever i console.log(sexy) it shows up as key: true.. i need the key to be 'isOld' with a value of true
heroiczero
@heroiczero
Jan 16 2017 05:01
@ujjwaljain0
@ujjwaljain0 make sure you have no spaces or " "
Jor
@joreyesl
Jan 16 2017 05:01
@ujjwaljain0 your line should look like "FirstLine\n\\SecondLine\\rThirdLine"
ujjwaljain0
@ujjwaljain0
Jan 16 2017 05:02
ya i removed the spaces now it works . thanx @Jor
CamperBot
@camperbot
Jan 16 2017 05:02
ujjwaljain0 sends brownie points to @jor :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for jor
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 05:03
anyone
Reggie
@Reggie01
Jan 16 2017 05:03
@Dueldrawer8 try using brackets obj[key]
Jor
@joreyesl
Jan 16 2017 05:04
@Dueldrawer8 you have to use bracket notation because obj.key is the same as obj["key"]which is not what you want
when using a variable you want to use obj[key]. notice the lack of quotes around the variable
Robert Wilber
@robert194w
Jan 16 2017 05:06
Hi. I have the same problem with the celcius conversion challenge. I have looked everywhere I could think of and tried all sorts of variations. I am lost
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 05:07
@joreyesl @Reggie01 thank you..
CamperBot
@camperbot
Jan 16 2017 05:07
dueldrawer8 sends brownie points to @joreyesl and @reggie01 :sparkles: :thumbsup: :sparkles:
:cookie: 383 | @reggie01 |http://www.freecodecamp.com/reggie01
:cookie: 232 | @joreyesl |http://www.freecodecamp.com/joreyesl
heroiczero
@heroiczero
Jan 16 2017 05:07
@robert194w lets see your code
Jor
@joreyesl
Jan 16 2017 05:09
@robert194w what have you tried? It should be relatively straight forward. The formula is F = C*9/5 + 32
Tyler Beutel
@TylerBeutel
Jan 16 2017 05:11
Hey guys, is there a neater way of doing this:
function convertHTML(str) {
  return str.replace(/&/g, "\&amp;").replace(/</g, "\&lt;")
    .replace(/>/g, "\&gt;").replace(/"/g, "\&quot;").replace(/'/g, "\&apos;");
}

convertHTML("Hamburgers < Pizza < Tacos");
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 05:11
@joreyesl so whats the diff between the two?
@joreyesl obj['key'] and obj.key are the same and are used to set values i thought.. while what does obj[key] without the quotes do?
Jor
@joreyesl
Jan 16 2017 05:14
@Dueldrawer8 well example var key = "name"then obj[key] is the same as obj["name"]. See key is a variable, it could be anything. I want to get the property that key represents. if I use obj.key i'm saying I want to get obj["key"] the literal "key" property not what the variable represents.
Eric Chung
@chungeric
Jan 16 2017 05:15
function rot13(str) { // LBH QVQ VG!
  var strDecoded = "";
  for (var i = 0; i < str.length; i++) {
    if (str.charCodeAt(i) > 64 && str.charCodeAt(i) <= 77) {
      strDecoded += String.fromCharCode(str.charCodeAt(i) + 13);
    } 
    else if (str.charCodeAt(i) > 77 && str.charCodeAt(i) < 123) {
      strDecoded += String.fromCharCode(str.charCodeAt(i) - 13);
    } 
    else {
      strDecoded += String.fromCharCode(str.charCodeAt(i));
    }
  }

  return strDecoded;
}

// Change the inputs below to test
rot13("SERR CVMMN!");
Anyone know a better way of doing this?
Caesars Cipher
Ezra
@EzraPlato
Jan 16 2017 05:17
@BrianRigoni that didn't work
Jor
@joreyesl
Jan 16 2017 05:18
@chungeric that looks great, its readable and easy to follow. Aside fancy coding. I dont think so.
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 05:18
@joreyesl ah thanks
CamperBot
@camperbot
Jan 16 2017 05:18
dueldrawer8 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:warning: dueldrawer8 already gave joreyesl points
Eric Chung
@chungeric
Jan 16 2017 05:19
@joreyesl Ahh awesome, thanks for the feedback!
CamperBot
@camperbot
Jan 16 2017 05:19
chungeric sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 233 | @joreyesl |http://www.freecodecamp.com/joreyesl
Robert Wilber
@robert194w
Jan 16 2017 05:19
@Reggie01 @joreyesl Thanks folks! Stupid spelling error. Looked at it ten times and didn't see it.
CamperBot
@camperbot
Jan 16 2017 05:19
robert194w sends brownie points to @reggie01 and @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 384 | @reggie01 |http://www.freecodecamp.com/reggie01
:cookie: 234 | @joreyesl |http://www.freecodecamp.com/joreyesl
Robert Wilber
@robert194w
Jan 16 2017 05:21
@heroiczero @heroiczero Thanks for your help!
CamperBot
@camperbot
Jan 16 2017 05:21
robert194w sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:cookie: 679 | @heroiczero |http://www.freecodecamp.com/heroiczero
Robert Wilber
@robert194w
Jan 16 2017 05:22
Must be bedtime. LOL
Ezra
@EzraPlato
Jan 16 2017 05:23
@BrianRigoni thanks. It did work. That was easy and I didn't understand.
CamperBot
@camperbot
Jan 16 2017 05:23
ezraplato sends brownie points to @brianrigoni :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for brianrigoni
Jor
@joreyesl
Jan 16 2017 05:29
@chungeric Here is an example of what you can do to make it 'fancy' but hard to read/follow.
function rot13(str) {
  var decoded = "";

  for(var i = 0; i < str.length; i++) {
    var j = str.charCodeAt(i);
    var k = j < 123 ? (j > 77 ? j - 13 : (j > 64 ? j + 13 : j)) : j;
    decoded += String.fromCharCode(k);
  }

  return decoded;
}
Eric Chung
@chungeric
Jan 16 2017 05:32
@joreyesl oh wow haha that's cool. would you know if that would be better in the workforce? or would the more readable one be better?
TheVip
@TheVip
Jan 16 2017 05:33
@joreyesl , bro I need your help again :alarm_clock:
Jor
@joreyesl
Jan 16 2017 05:35
@chungeric I wouldn't know yet. Still in school. But I would think readability would be better since you will rarely be working on something on your own. Someone has to maintain your code after you are gone.
@TheVip whats up?
TheVip
@TheVip
Jan 16 2017 05:36
@joreyesl , I am stuck on 'Mutation' challenge....actually i don't know where to start from
Eric Chung
@chungeric
Jan 16 2017 05:36
@joreyesl right haha, makes sense
WilliamBadgett97
@WilliamBadgett97
Jan 16 2017 05:39

I feel really dumb; I've been sitting here stuck on this.. var myStr ="FirstLine\n\SecondLine\rThirdLine \";

Escape Sequences in Strings is what i'm supposed to be doing I know I'm doing something wrong really bad, Just can't figure it out

Jor
@joreyesl
Jan 16 2017 05:39
@TheVip alright, I'll take a look at the challenge real quick
@WilliamBadgett97 you have an extra \ at the end of your line
also make sure you have \\ around SecondLine since they want you to escape the \ so it gets printed out.
WilliamBadgett97
@WilliamBadgett97
Jan 16 2017 05:43
var myStr ="FirstLine\n\SecondLine\r\ThirdLine \" ;
Yeah, I'm doing really bad at java lmao...
Jor
@joreyesl
Jan 16 2017 05:45
@WilliamBadgett97 Should be FirstLine\n\\SecondLine\\\rThirdLine
WilliamBadgett97
@WilliamBadgett97
Jan 16 2017 05:46
Thank you, I'm going to review what I did wrong and keep going over it.
Jor
@joreyesl
Jan 16 2017 05:46
np, compare that with yours so you can see where went wrong.
@TheVip Ok so I've looked at it. They want you to check if all the letters in 2nd string are present in 1st string
you will need a for loop and if statement to check
Gabriela Bazan
@GabrielaLBazan
Jan 16 2017 05:49
hello, I would like to get some help if it's available.
Austiclyse
@Austiclyse
Jan 16 2017 05:50
@joreyesl You still kicking ass on here? I need help.
Jor
@joreyesl
Jan 16 2017 05:50
@TheVip
1. Loop through the characters in 2nd string
  a. Check to see if current character is present in 1st string
  b. If characters is not present then return false
2. After loop, since it did not return false, then that means all characters were present so you can return true
@Austiclyse Whats up
TheVip
@TheVip
Jan 16 2017 05:51
@joreyesl , trying what you said :+1:
Gabriela Bazan
@GabrielaLBazan
Jan 16 2017 05:52

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
myAdjective += myNoun += myAdverb += myVerb; // my code is not working, could someone advise please?

// Your code above this line
return result;
}

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

Austiclyse
@Austiclyse
Jan 16 2017 05:53
@joreyesl I feel like I am really close on this.
    function lookUpProfile(firstName, prop){
    // Only change code below this line
      for ( i = 0; i < contacts.length; i ++ ) {
        if ( contacts[i].firstName === firstName); {
          switch (contacts) {
            case contacts[i].prop === prop:
              return contacts[i].prop;
              break;
            default:
              return "No such property";
          }
        } 
      } return "No such contact";
    // Only change code above this line
    }

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

    /*- loop through the contacts
    1. if firstname is a match
        a. if property exists 
            - return the value 
        b. else if property doesn't exist 
    - return "no such prop"
    - once outside loop, return "No such contact"
    */
Bigyan Karki
@bigyankarki
Jan 16 2017 05:55

function titleCase(str) {
  var firstLetter = [];
  var restLetter = [];
  var lowerCase = str.toLowerCase();
  var splitWord = lowerCase.split(/\s/gi);
  for (var i = 0; i < splitWord.length; i++) {
    for (var j = 0; j < splitWord[i].length; j++) {
      if (splitWord[i][0]){
        splitWord[i][0].toUpperCase();
      }

    }
  }
  return ;
}

titleCase("I'm a little tea pot");
guys can someone help me at this capitalizing first letter of the word problem
Jor
@joreyesl
Jan 16 2017 05:56
@Austiclyse yea looks good, just a few comments. You can use an If Else statement instead of a switch. Also if you want to check if a contact has a prop you can use contacts[i].hasOwnProperty(prop). That will return true if the contact has it.
Bigyan Karki
@bigyankarki
Jan 16 2017 05:56
i am so confused as to how do i store and append the first capitlized letter is appended with rest of the strings
TheVip
@TheVip
Jan 16 2017 05:56
@GabrielaLBazan , You need to do like this,
result = myAdverb + " " + myNoun + " " + myVerb + " " + myAdjective;
Austiclyse
@Austiclyse
Jan 16 2017 05:57
@joreyesl Is the switch breaking it? Right now it only returns "No such property"
Phil Seidel
@psbyron3
Jan 16 2017 05:57
Do you need to capitalize every first letter of every word? @bigyankarki
Bigyan Karki
@bigyankarki
Jan 16 2017 05:58
yes @psbyron3
Jor
@joreyesl
Jan 16 2017 05:58
@Austiclyse yea there is a few problems with the switch.
Phil Seidel
@psbyron3
Jan 16 2017 05:58
So every word has whitespace in front of it.. You could monitor the spaces and capitalize the letter that followd @bigyankarki
Gabriela Bazan
@GabrielaLBazan
Jan 16 2017 05:58
thank you @TheVip
CamperBot
@camperbot
Jan 16 2017 05:58
gabrielalbazan sends brownie points to @thevip :sparkles: :thumbsup: :sparkles:
:cookie: 256 | @thevip |http://www.freecodecamp.com/thevip
Greg Duncan
@GregatGit
Jan 16 2017 05:58
@bigyankarki you don't have to keep creating new variable
var lowerCase = str.toLowerCase();
or
str = str.toLowerCase();
Bigyan Karki
@bigyankarki
Jan 16 2017 05:59
oh! @GregatGit thanks
CamperBot
@camperbot
Jan 16 2017 05:59
bigyankarki sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 826 | @gregatgit |http://www.freecodecamp.com/gregatgit
Austiclyse
@Austiclyse
Jan 16 2017 06:00
@joreyesl ;( just when I feel like I was getting it down. lol So should I nest a new "if" statement in the open one or continue on with an "else if"?
Bigyan Karki
@bigyankarki
Jan 16 2017 06:01
@psbyron3 how can i monitor white space and capitalize the first word it follows
Greg Duncan
@GregatGit
Jan 16 2017 06:01
@Austiclyse i woudn't use a switch here
Jor
@joreyesl
Jan 16 2017 06:01
@Austiclyse switch is used when you have to take a varied number of branches depending on the case. But in this problem you only have 2 options, does the contact contain the given property or not. So an if else works best. You would want to keep it in the same nest that the switch statment is at.
Bigyan Karki
@bigyankarki
Jan 16 2017 06:02

function titleCase(str) {

  str = str.toLowerCase();
  str = str.split(/\s/gi);
  for (var i = 0; i < str.length; i++) {
    for (var j = 0; j < str[i].length; j++) {
      if (str[i][0]){
        str[i][0].toUpperCase();
      }

    }
  }
  return str;
}

titleCase("I'm a little tea pot");
okay this is the code
Phil Seidel
@psbyron3
Jan 16 2017 06:04
Okay that's a little complicated.. What does your RegEx do? What does it look for @bigyankarki
Bigyan Karki
@bigyankarki
Jan 16 2017 06:04
is there anything I can do to store that uppercase first letter to the splitted string?
what is RegEx?
Jor
@joreyesl
Jan 16 2017 06:05
@bigyankarki /\s/gi thats a regex expression you are using
Phil Seidel
@psbyron3
Jan 16 2017 06:05
Regular expression ... the
exactly what they said :arrow_up:
Bigyan Karki
@bigyankarki
Jan 16 2017 06:05
oh ya haha
what it does is find the whitespaces
Jor
@joreyesl
Jan 16 2017 06:06
@bigyankarki if you want split by whitespace you can also do .split(" ")
Manish Giri
@Manish-Giri
Jan 16 2017 06:07
@bigyankarki you know, you can call .map() on each split word
inside .map(), pass a callback that gets the first letter, capitalizes it, and joins it with the remaining letters
done
WilliamBadgett97
@WilliamBadgett97
Jan 16 2017 06:08
this is the hardest thing i've ever done in my life, but I enjoy it very much...
Jor
@joreyesl
Jan 16 2017 06:09
@WilliamBadgett97 good! :thumbsup:
Bigyan Karki
@bigyankarki
Jan 16 2017 06:09
hmm let me try that
Hanqi Liu
@LicheeLiu
Jan 16 2017 06:10
swtich(val)
{
case 1: answer="alpha";break;
case 2:answer="beta";break;
case 3: answer="gamma";break;
case 4:answer="delta";break;
}
what's wrong with those code?
Jor
@joreyesl
Jan 16 2017 06:10
@LicheeLiu typo swtich(val)
Hanqi Liu
@LicheeLiu
Jan 16 2017 06:12
aaaaaah, thanks! @joreyesl
CamperBot
@camperbot
Jan 16 2017 06:12
:cookie: 235 | @joreyesl |http://www.freecodecamp.com/joreyesl
licheeliu sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
Austiclyse
@Austiclyse
Jan 16 2017 06:12
@joreyesl @GregatGit Alright, I got it converted over to a if instead of a switch. When I was using the contacts[i].prop === prop it returned "No such property" no matter what. When I use the contacts[i].hasOwnProperty(prop) it returns nothing at all. So, I've still got a bug somewhere... (was hasOwnPropery() covered in a previous lesson or is that just a gifted pearl from you?)
    function lookUpProfile(firstName, prop){
    // Only change code below this line
      for ( i = 0; i < contacts.length; i ++ ) {
        if ( contacts[i].firstName === firstName); {
          if (contacts[i].hasOwnProperty(prop)) {
              return contacts[i].prop;
          } else {
              return "No such property";
          }
        } 
      } return "No such contact";
    // Only change code above this line
    }

    // Change these values to test your function
    lookUpProfile("Lies", "likes");
kevinliu6102
@kevinliu6102
Jan 16 2017 06:13
@Austiclyse contacts[i].prop searches for a literal key 'prop
'prop'
when using variables to reference keys, put them in brackets
Greg Duncan
@GregatGit
Jan 16 2017 06:13
@Austiclyse contacts[i][prop] there is a huge difference
CoryCMyers
@CoryCMyers
Jan 16 2017 06:14

Morning Everyone! Just popping in with a quick question to make sure I understand what was happening here.

// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;       // Change this Line
var player = testObj[playerNumber];   // Change this Line

So I understand that I told it to run down the testObj list to find what was on the side of the : from 16. What I am not understanding is how it worked out ot differentiate the two sides and what the : means when used like this.

Greg Duncan
@GregatGit
Jan 16 2017 06:14
.prop will look for a property called prop
Austiclyse
@Austiclyse
Jan 16 2017 06:15
@GregatGit ???! I though dot notation was used to look up properties with one word names?
kevinliu6102
@kevinliu6102
Jan 16 2017 06:15
@CoryCMyers look up javascript object notation
Greg Duncan
@GregatGit
Jan 16 2017 06:16
@Austiclyse go to https://repl.it/FDIb/6 put an object in there and practice accessing the values
CoryCMyers
@CoryCMyers
Jan 16 2017 06:16
@kevinliu6102 Okay, so it is not just me thinking I missed or forgot it, since all I remember them covering is the </> and equality notation.
Greg Duncan
@GregatGit
Jan 16 2017 06:16
@Austiclyse it just something you should play around with until you get it
Austiclyse
@Austiclyse
Jan 16 2017 06:17
Okay, thats closer. prop is in []s but it only pulls the first contacts info
Jor
@joreyesl
Jan 16 2017 06:17
@CoryCMyers it works similar to a KeyValue pair the Key : Value. Basically when I do this testObj[key], I want the value associated with that key.
CoryCMyers
@CoryCMyers
Jan 16 2017 06:17
@joreyesl Thank you! That is what I was wondering!
CamperBot
@camperbot
Jan 16 2017 06:17
corycmyers sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 236 | @joreyesl |http://www.freecodecamp.com/joreyesl
kevinliu6102
@kevinliu6102
Jan 16 2017 06:17
@CoryCMyers not sure if it was covered before that point but should be easy enough to look it up
CoryCMyers
@CoryCMyers
Jan 16 2017 06:18
I just wanted to be sure I was making the right association in my head before I moved on.
Greg Duncan
@GregatGit
Jan 16 2017 06:18
@Austiclyse put up what you have
Joseph
@revisualize
Jan 16 2017 06:18
@Austiclyse Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
Austiclyse
@Austiclyse
Jan 16 2017 06:19
Should firstName be in [] too then?
    function lookUpProfile(firstName, prop){
    // Only change code below this line
      for ( i = 0; i < contacts.length; i ++ ) {
        if ( contacts[i].firstName === firstName); {
          if (contacts[i].hasOwnProperty(prop)) {
              return contacts[i][prop];
          } else {
              return "No such property";
          }
        } 
      } return "No such contact";
    // Only change code above this line
    }
Joseph
@revisualize
Jan 16 2017 06:20
@Austiclyse No.
@Austiclyse Well. Depends. Do you want to access the property firstName or use the variable firstName?
Jor
@joreyesl
Jan 16 2017 06:21
@Austiclyse No firstName is the literal name of the property you are accessing. prop is a variable.
Austiclyse
@Austiclyse
Jan 16 2017 06:23
sigh I'm gonna have so many ppl to send brownie points to when this is finally solved!
ccw13
@ccw13
Jan 16 2017 06:23
can i get help with this?

var count = 0;

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

if (card<=6){
count =+1;
}
else if (card>=7 && card<=9){
count=0;
}
else if (card==10,"J","Q","K","A"){
count= -1;
}

if (cc>0 && cc<=6){
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); cc(3); cc(4); cc(5); cc(6);

Traek Wells
@TraekWells
Jan 16 2017 06:24
What’s the difference between a const and a var?
GabriRa
@GabriRa
Jan 16 2017 06:25
Guys, the Sum All Primes algorithm is working?
Jor
@joreyesl
Jan 16 2017 06:25
@ccw13 you cant compare to multiple things else if (card==10,"J","Q","K","A")
ccw13
@ccw13
Jan 16 2017 06:26
@joreyesl owh okay thanks
CamperBot
@camperbot
Jan 16 2017 06:26
ccw13 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 237 | @joreyesl |http://www.freecodecamp.com/joreyesl
Jor
@joreyesl
Jan 16 2017 06:26
@ccw13
if that is the last cases you are checking, then you can default to a basic else statement instead of an else if
GabriRa
@GabriRa
Jan 16 2017 06:26
It says the sum of all primes and the constant of the function should be equal to 17, but it should be 27
sumPrimes(10)
This is my code

function sumPrimes(num) {
  var a=[],b=[],c,d=0;
  for (var i=2;i<num;i++){
    a.push(i);
    c=0;
    for (var j=0;j<a.length;j++){

      if (i%a[j]===0){
        c++;
      }
    }
    if (c==1){
      b.push(i);
    }
  }
  for (var k=0;k<b.length;k++){
    d=b[k] + d;
  }
  return d+num;
}

sumPrimes(10);
ccw13
@ccw13
Jan 16 2017 06:27
@joreyesl i fixed it.... still isnt working
annabaum
@annabaum
Jan 16 2017 06:27
Hi there. I am very confused about the palindrome and need some help. I really have no idea why the array is not reversed..
function palindrome(str) {
  str1 = str.toUpperCase().replace(/\s/g, '');
  myArr = str1.split();
  str2 = myArr.reverse().join();

  // should return string and reversed string, but returns the same string twice:
  alert(str1 +" "+ str2);
  return true;
}

palindrome("eye");
Bigyan Karki
@bigyankarki
Jan 16 2017 06:28

function titleCase(str) {

  str = str.toLowerCase();
  str = str.split(" ");
  str = str.map(function() {
    for (var i = 0; i < str.length; i++) {


    }
  });

  return str;
}

titleCase("I'm a little tea pot");
ccw13
@ccw13
Jan 16 2017 06:28

var count = 0;

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

if (card<=6){
count =+1;
}
else if (card>=7 && card<=9){
count=0;
}
else{
count= -1;
}

if (cc>0 && cc<=6){
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); cc(3); cc(4); cc(5); cc(6);

Chase
@Athabasco
Jan 16 2017 06:28
Could I please get some help with the basic algorithms?
ccw13
@ccw13
Jan 16 2017 06:28
something is definitely wrong
Bigyan Karki
@bigyankarki
Jan 16 2017 06:28
how can i now access the first letter of the array?
Chase
@Athabasco
Jan 16 2017 06:28
Why is this getting an error?

function destroyer(arr) {
var args = Array.prototype.slice.call(arguments);
  args.splice(0,1);

  var myArr = [];

  for (var i = 0; i < arr.length; i++){
   myArr = arr.filter(args[1]);
  }

  return myArr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
John
@flyboy1565
Jan 16 2017 06:29
ok, starting on the mutation totally at loss for it
Jor
@joreyesl
Jan 16 2017 06:29

@ccw13

else if (card>=7 && card<=9){
count=0;
}

you are reseting count to 0 anything that is true

Chase
@Athabasco
Jan 16 2017 06:29
@bigyankarki arr[0] gives you the first value of an array.
John
@flyboy1565
Jan 16 2017 06:30
@bigyankarki first letter or first item in an array?
Bigyan Karki
@bigyankarki
Jan 16 2017 06:30
firstletter of the firstarray @flyboy1565
John
@flyboy1565
Jan 16 2017 06:30
@Athabasco put in what you're having an issue you doing
Bigyan Karki
@bigyankarki
Jan 16 2017 06:30
first letter of the first item in the array
karim06
@karim06
Jan 16 2017 06:30
@Athabasco I am also struck at the same algorithm
Bigyan Karki
@bigyankarki
Jan 16 2017 06:30
do i need another loop there?
Jor
@joreyesl
Jan 16 2017 06:30

@ccw13 same thing here

else{
count= -1;
}

should be

else{
count += -1;
}
Bigyan Karki
@bigyankarki
Jan 16 2017 06:31

function titleCase(str) {

  str = str.toLowerCase();
  str = str.split(" ");
  str = str.map(function() {
    for (var i = 0; i < str.length; i++) {


    }
  });

  return str;
}

titleCase("I'm a little tea pot");
here is the code one more time
ccw13
@ccw13
Jan 16 2017 06:31
oh okay thanks @joreyesl
CamperBot
@camperbot
Jan 16 2017 06:31
ccw13 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:warning: ccw13 already gave joreyesl points
Steve Fuller
@wsfuller
Jan 16 2017 06:32
Stuck on "Escape Sequences in Strings. Instructions: "FirstLine newlinebackslash SecondLine backslashcarriage-return ThirdLine" however anything i type is incorrect var myStr = "FirstLine\nSecondLine\rThirdLine"; // Change this line
zzzhenng
@zzzhenng
Jan 16 2017 06:33
i sheepishly need help with "Make Object Properties Private"
Jor
@joreyesl
Jan 16 2017 06:33
@annabaum str1.split() you are not telling it how to split. Try str1.split("") which will split all letters. same with join. try .join("")
CoryCMyers
@CoryCMyers
Jan 16 2017 06:33
I feel a bit off for having ot return to the chat so soon, but am I doing something wrong here? I have checked the solution on other people's profile to make sure it is matching up but this will not complete. it says I am not updating the right object property I think is what it is

// Example
var ourDog = {
  "name": "Camper",
  "legs": 4,
  "tails": 1,
  "friends": ["everything!"]
};

ourDog.name = "Happy Camper";

// Setup
var myDog = {
  "name": "Coder",
  "legs": 4,
  "tails": 1,
  "friends": ["Free Code Camp Campers"]
};

// Only change code below this line.
myDog.name = "Happy Coder";
karim06
@karim06
Jan 16 2017 06:34

```function destroyer(arr) {
// Remove all the values
var newArr = arr.filter(function(val){
var result = true;
for(var i=1;i<arguments.length;i++){
if(val == arguments[i]){
result = false;
}
}
return result;
});
return newArr;
}

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

How to paste code here ??
CoryCMyers
@CoryCMyers
Jan 16 2017 06:34
` Then his shift enter and close with `
three `
Chase
@Athabasco
Jan 16 2017 06:34
`
sup meh dude
```
CoryCMyers
@CoryCMyers
Jan 16 2017 06:35
close it the same way then cntrl enter to send
Chase
@Athabasco
Jan 16 2017 06:35
`test
`test
test
annabaum
@annabaum
Jan 16 2017 06:35
@joreyesl aaaaaah ok. :) Thank you!
CamperBot
@camperbot
Jan 16 2017 06:35
annabaum sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 238 | @joreyesl |http://www.freecodecamp.com/joreyesl
Chase
@Athabasco
Jan 16 2017 06:35
ik how to do this though
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:35
function getSumOfAllElementsAtProperty(obj, key) {
  // your code here
  var total = 0;

  for(var sexy in obj){
     if(Array.isArray(obj[sexy])){
      for(var i = 0; i < obj.sexy.length; i++){
          total+ obj.sexy[i];
      }
     }
    else{
        return 0;
        }
    }
    return total;
}

var obj = {
  sexy: [4, 1, 8]
};

getSumOfAllElementsAtProperty(obj, 'sexy');
my code keeps returning 0.. its suppose to add up all the numbers within the array within the object
i have a feeling my problem has to do with the else statement
Jor
@joreyesl
Jan 16 2017 06:36
@Dueldrawer8 typo here total+ obj.sexy[i];
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:36
@joreyesl yikes!
GabriRa
@GabriRa
Jan 16 2017 06:36
Why this code does not work?
function sumPrimes(num) {
  var a=[],b=[],c,d=0;
  for (var i=2;i<num;i++){
    a.push(i);
    c=0;
    for (var j=0;j<a.length;j++){

      if (i%a[j]===0){
        c++;
      }
    }
    if (c==1){
      b.push(i);
    }
  }
  for (var k=0;k<b.length;k++){
    d=b[k] + d;
  }
  return d+num;
}

sumPrimes(10);
Chase
@Athabasco
Jan 16 2017 06:36
Anybody done with basic algorithms and could lend a quick hand?
Austiclyse
@Austiclyse
Jan 16 2017 06:37
So, the properties search is working relatively well but I can't see why the search doesn't want to move past the first contact even when it shouldn't find one at all?
    function lookUpProfile(firstName, prop){
    // Only change code below this line
      for ( i = 0; i < contacts.length; i ++ ) {
        if ( contacts[i].firstName === firstName); {
          if (contacts[i].hasOwnProperty(prop)) {
              return contacts[i][prop];
          } else {
              return "No such property";
          }
        } 
      } return "No such contact";
    // Only change code above this line
    }
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:37
@joreyesl hm.. it says cannot read property length of undefined
kevinliu6102
@kevinliu6102
Jan 16 2017 06:38
@Austiclyse if you have a return statement in a loop the loop ends, so in your case it is only displaying the 0 index contact
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:38
@joreyesl can i not use length property on an array within an object?
typerror it says
Jor
@joreyesl
Jan 16 2017 06:39
whats the name of the challenge?
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:40
@joreyesl heh its not on here.. im doing other algorithms.. hmm
Jor
@joreyesl
Jan 16 2017 06:40
oh alright, np. Well what does the data structure look like?
trying to see why using a foreach loop
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:41

Write a function called "getSumOfAllElementsAtProperty".

Given an object and a key, "getSumOfAllElementsAtProperty" returns the sum of all the elements in the array located at the given key.

Notes:

  • If the array is empty, it should return 0.
  • If the property at the given key is not an array, it should return 0.
  • If there is no property at the key, it should return 0.
Austiclyse
@Austiclyse
Jan 16 2017 06:41
@kevinliu6102 ..... How... how am I supposed to return the data the loop was looking for outside of the loop that was looking?
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:41
@joreyesl
var obj = {
  key: [4, 1, 8]
};
var output = getSumOfAllElementsAtProperty(obj, 'key');
console.log(output); // --> 13
Jor
@joreyesl
Jan 16 2017 06:42
great! It look like you wont need a foreach
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:43
@joreyesl hmm well it works perfectly find but for some reason whatever test they made.. to test to see if your function works wont allow it
oops..to much lol
sorry meant to copy only top part
kevinliu6102
@kevinliu6102
Jan 16 2017 06:44
@Austiclyse save it in a variable
John
@flyboy1565
Jan 16 2017 06:45
anyone complete the mutation challenge? I'm at a loss.. I have
function mutation(arr) {
  for (i=0; i < arr.length; i++){
    console.log(arr[i])
  }
  return arr;
}
zzzhenng
@zzzhenng
Jan 16 2017 06:46
can i get help with "Make Object Properties Private"? why is not work?
var Bike = function() {
    //only change code below this line.
    var gear;
    this.getGear = function(){
        return gear;
};
    this.setGear = function(gear){
        this.gear = gear;
};
};

var myBike = new Bike();
Jor
@joreyesl
Jan 16 2017 06:46
@Dueldrawer8 here obj.sexy.length try obj[sexy].length instead
John
@flyboy1565
Jan 16 2017 06:47
@zzzhenng , try using a different variable for this.gear = new_gear
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:48
@joreyesl now it says cannot read property '0' of undefined
Austiclyse
@Austiclyse
Jan 16 2017 06:48
@kevinliu6102 So instead of saying "return the information from this spot" tell it "the information in this spot equals this new variable"? Like "contacts[i][prop] = var requestedProp"?
Nikolay Neykov
@shkurata
Jan 16 2017 06:48
zzzhenng: maybe you should return 'this.gear' in getGear method
Eric
@eherod
Jan 16 2017 06:50
Hello
zzzhenng
@zzzhenng
Jan 16 2017 06:51
@shkurata great, u are right.thanks
kevinliu6102
@kevinliu6102
Jan 16 2017 06:51
@Austiclyse try an array
Jor
@joreyesl
Jan 16 2017 06:53
@Dueldrawer8 total+ obj.sexy[i]; try total += obj[sexy][i];
Nikolay Neykov
@shkurata
Jan 16 2017 06:54
eherod: try first yourself
John Freeborn
@jfx1026
Jan 16 2017 06:54
hi gang - I'm having some trouble with an infinite loop, can someone take a look please?
here's my for loop
for (x=0; x<dnaArray.length; x++) {
    if (dnaArray[x] == "G") {
      newArray.splice((x+1), 0, "C");
    } else if (dnaArray[x] == "C") {
      newArray.splice((x+1), 0, "G");
    } else if (dnaArray[x] == "A") {
      newArray.splice((x+1), 0, "T");
    } else if (dnaArray[x] == "T") {
      newArray.splice((x+1), 0, "A");
    }
  }
Eric
@eherod
Jan 16 2017 06:56
@Nikolay. I never thought of that.
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:56
@joreyesl lol that works! thank you..
CamperBot
@camperbot
Jan 16 2017 06:56
dueldrawer8 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 239 | @joreyesl |http://www.freecodecamp.com/joreyesl
Jor
@joreyesl
Jan 16 2017 06:57
@eherod what is the problem?
what are you stuck on
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:57
@joreyesl obj.sexy[i]...isnt that accessing the value? so it would be whatever the array is?
once again trying to figure out the difference
Jor
@joreyesl
Jan 16 2017 06:57
@Dueldrawer8 nope, obj.sexy[i] is the same as obj["sexy"][i] notice the quotes. Sexy is a variable so you NEED to use bracket notation.
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:59
@joreyesl man thats confusing somewhat but i get it
jrhaynes88
@jrhaynes88
Jan 16 2017 07:00
Good Evening! Can anyone help me understand why the new line and carriage returns aren't working in this line: var myStr = "FirstLine\n\Secondline\r\ThirdLine"; // Change this line
Jor
@joreyesl
Jan 16 2017 07:01
@Dueldrawer8 ex: var num = 3. If I do obj.num that is the same as obj["num"] but thats not what I want. I want obj[num] which takes what is stored in num and this becomes obj[3] which is what I want to get.
GabriRa
@GabriRa
Jan 16 2017 07:01
function sumPrimes(num) {
  var a=[],b=[],c,d=0;
  for (var i=2;i<num;i++){
    a.push(i);
    c=0;
    for (var j=0;j<a.length;j++){

      if (i%a[j]===0){
        c++;
      }
    }
    if (c==1){
      b.push(i);
    }
  }
  for (var k=0;k<b.length;k++){
    d=b[k] + d;
  }
  return d+num;
}

sumPrimes(10);
Why this code does not work, it is buged the sum of all primes algorithm?
It works for sumPrimes(997), but not for 10, only when I dont add "num"
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 07:03
@joreyesl makes more sense
Austiclyse
@Austiclyse
Jan 16 2017 07:03
@jrhaynes88 FirstLine\n\SecondLine\\rThirdLine is what you need
@jrhaynes88
FirstLine\n\SecondLine\\rThirdLine
Jor
@joreyesl
Jan 16 2017 07:05
@Austiclyse try putting it between `
Adri Jenie
@Adrifajar
Jan 16 2017 07:07
im confused about the queue. i don't know what i am suppose to do

function nextInLine(arr, item) {
// Your code here

return item; // Change this line
}

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

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

Alber
@AlberMonster
Jan 16 2017 07:07

function steamroller(arr) {
// I'm a steamroller, baby
var result = judge(arr);
return result;

}

var temp = new Array();
function judge(arr){
for(var i=0;i<arr.length;i++){
if(Array.isArray(arr[i])){
judge(arr[i]);
}else{
temp.push(arr[i]);
}
}
return temp;
}

steamroller([[["a"]], [["b"]]]);

grantknaver
@grantknaver
Jan 16 2017 07:08
Ok I dont understand how this...

function uniteUnique(arr) {
var loopArray = []; 
//var flattened = [];
for(var i = 0; i < arr.length; i++){
if(typeof arguments[i] === 'undefined'){
    loopArray = loopArray.concat(arguments[i]);   
}else{
  flattened = arguments[i].reduce(function(a, b) {
  return a.concat(b);
}, []);  
  loopArray = loopArray.concat(flattened); 
  //loopArray.push(flattened);
}    


}   
console.log(loopArray);   

}



uniteUnique([1, 2, 3], [5, 2, 1]);
Jor
@joreyesl
Jan 16 2017 07:08
@Adrifajar they will provide you with an item. You need add item to the end of arr array. Then you need to remove the first item in arr and return that.
h1tag
@h1tag
Jan 16 2017 07:09
Hey, I'm on the Show the Local Weather project, I'm using the weather api from: https://www.apixu.com and here's my code pen: https://codepen.io/FortMax/pen/wgGdGR. I get this error on console after running my project: Uncaught TypeError: Cannot read property 'temp_c' of undefined
grantknaver
@grantknaver
Jan 16 2017 07:09
is console logging undefined in the array
anyone have any ideas im stumped
I dont know
Adri Jenie
@Adrifajar
Jan 16 2017 07:09
@joreyesl using shift and unshift?
grantknaver
@grantknaver
Jan 16 2017 07:10
or maybe just help me understand why me using reduce may me have to do an if else statement
Jor
@joreyesl
Jan 16 2017 07:10
@Adrifajar well unshift will add the item to the beginning of the array.
pvaidya56
@pvaidya56
Jan 16 2017 07:11

i'm stuck on converting celsius to fahrenheit using the algorithm my code is
function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
var fahrenheit = 32;

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

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

dont understand the directions
convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86
Jor
@joreyesl
Jan 16 2017 07:11
@Adrifajar you want to use .push() to add item to end of the array. and .shift() to remove an item from the beginning of the array.
Greg Duncan
@GregatGit
Jan 16 2017 07:14
@pvaidya56 var fahrenheit = 32; fahrenheit should equal and equation with celcius in it
tptynlr
@tptynlr
Jan 16 2017 07:14

function rot13(str) { // LBH QVQ VG!
for(var i=0;i<str.length;i++){

if(str[i]==" ")
str[i]=" "  ;
else
  {
    var value=str.charCodeAt(str[i])+13;
str[i]=String.fromCharCode(value);

}
}

return str;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
rot13("SERR PBQR PNZC") should decode to "FREE CODE CAMP"

grantknaver
@grantknaver
Jan 16 2017 07:15
any ideas guys
Greg Duncan
@GregatGit
Jan 16 2017 07:16
@fortMaximus temp = w.current['temp_c']; the obj that it brings down has no current['temp_c']
@fortMaximus you are getting an error of "No matching location found."
@fortMaximus use this to get your location http://ip-api.com/json
tptynlr
@tptynlr
Jan 16 2017 07:22
help
grantknaver
@grantknaver
Jan 16 2017 07:22
ok can someone explain to me how I made this actually work?
Saeed Jassani
@saeedjassani
Jan 16 2017 07:22
Hello! I have completed my basics of JS (some of the algorithm challenges are remaining), but now I want to start a project... I saw TicTacToe game project and started figuring out how it can be built
when i saw the code of the example project..var MYAPP = MYAPP || {
grantknaver
@grantknaver
Jan 16 2017 07:23
function uniteUnique(arr) {
var loopArray = []; 
//var flattened = [];
for(var i = 0; i < arr.length+1; i++){
if(typeof arguments[i] === 'undefined'){
    loopArray = loopArray.concat(arguments[i]); 
  loopArray.pop();
}else{
  flattened = arguments[i].reduce(function(a, b) {
  return a.concat(b);
}, []);  
  loopArray = loopArray.concat(flattened); 
  //loopArray.push(flattened);
}    


}   
console.log(loopArray);   

}



uniteUnique([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8]);
Saeed Jassani
@saeedjassani
Jan 16 2017 07:23
all these have not been taught
h1tag
@h1tag
Jan 16 2017 07:23
@GregatGit how did you get this error or how did you display it? And how do I fix it?
Muhammad Hasham
@MohammadHasham
Jan 16 2017 07:23
can anyone help me with my simon says game project?
Greg Duncan
@GregatGit
Jan 16 2017 07:25
@fortMaximus this is the first problem you need to fix - if (navigator.geoLocation) { this giving you false
Brendon Bradley
@brenbrad
Jan 16 2017 07:26
var myStr = "FirstLine\nSecondLine\rThirdLine"; where my issue here please and thank you??
var myStr = "FirstLine\nSecondLine\rThirdLine"; //
Sarthak Khanna
@khannasarthak
Jan 16 2017 07:26
@brenbrad This challenge is space sensitive
make sure it is exactly how it is mentioned in the Instruction
Brendon Bradley
@brenbrad
Jan 16 2017 07:27
ok thanks @khannasarthak ill keep trying
CamperBot
@camperbot
Jan 16 2017 07:27
:cookie: 137 | @khannasarthak |http://www.freecodecamp.com/khannasarthak
brenbrad sends brownie points to @khannasarthak :sparkles: :thumbsup: :sparkles:
Ogundele Olumide
@Lumexralph
Jan 16 2017 07:27
@grantknaver in this place for(var i = 0; i < arr.length+1; i++) what do you mean by this i < arr.length+1 ?
@brenbrad where's your backslash ? \\
grantknaver
@grantknaver
Jan 16 2017 07:29
honestly I have no idea. I left out the +1, for along time, but without it I can't get the reduce and concat in the if else statements to work
Sarthak Khanna
@khannasarthak
Jan 16 2017 07:30
@brenbrad Ping me if you are unable to clear it
grantknaver
@grantknaver
Jan 16 2017 07:30
I was initally wanting to iterate through arr, but depending on want arguments I entered in the functions I sometimes got errors
here is the assignment
Ogundele Olumide
@Lumexralph
Jan 16 2017 07:31
@grantknaver arr is a parameter from your function, holding only the first argument when the function is called
@grantknaver what are you trying to do?
grantknaver
@grantknaver
Jan 16 2017 07:32
I'm trying to flatten the arguments, concat them, and get rid of any duplicates
somehow I flattened them and was able to use concat, but it really shouldn't count. I played around with the code until it took
worked
Adri Jenie
@Adrifajar
Jan 16 2017 07:34
im still confused. tell me if there is something wrong. i use pushto add a number in an end of array. then i use shift to remove the first element of the array
Sarthak Khanna
@khannasarthak
Jan 16 2017 07:36
@Adrifajar that seems correct
any code to follow it up?
Adri Jenie
@Adrifajar
Jan 16 2017 07:36

function nextInLine(arr, item) {
arr.push(item);
arr.shift();
// Your code here

return item; // Change this line
}

// Test Setup
var testArr = [2];

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

but i want if i put nextInLine([2],1) to be 2