These are chat archives for FreeCodeCamp/HelpJavaScript

16th
Jan 2017
James Shore
@Jimbobmahooley
Jan 16 2017 00:01 UTC
@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 UTC
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 UTC
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 UTC
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 UTC
@moigithub Thanks i really appreciate <3
CamperBot
@camperbot
Jan 16 2017 00:08 UTC
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 UTC
:+1: * @moigithub
Greg Duncan
@GregatGit
Jan 16 2017 00:23 UTC
@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 UTC
help me to solve this ..
CamperBot
@camperbot
Jan 16 2017 00:30 UTC
no wiki entry for: me to solve this
Jaydeep Kataria
@jaydeepk3
Jan 16 2017 00:30 UTC
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 UTC
@jaydeepk3 lookup[val] or something?
Jaydeep Kataria
@jaydeepk3
Jan 16 2017 00:33 UTC
yes
@JohnnyBizzel
Suraj
@suraj-davariya
Jan 16 2017 00:34 UTC
@GregatGit thanks bro :+1:
CamperBot
@camperbot
Jan 16 2017 00:34 UTC
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 UTC
@suraj-davariya np!
Bigyan Karki
@bigyankarki
Jan 16 2017 00:35 UTC
hey everyone !
can someone tell me how to ignore case and special symbols from a string
Yoel Trujillo
@y0el22
Jan 16 2017 00:36 UTC

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 UTC
@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 UTC
having trouble returning the count variable in the card counting challenge
Stephen James
@sjames1958gm
Jan 16 2017 00:40 UTC
@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 UTC
blob
Stephen James
@sjames1958gm
Jan 16 2017 00:40 UTC
@aeselden92 show the code?
miner_paul
@aeselden92
Jan 16 2017 00:40 UTC
Says count should be displayed in a string
not sure how to do that
Yoel Trujillo
@y0el22
Jan 16 2017 00:41 UTC
@sjames1958gm let me se!
Stephen James
@sjames1958gm
Jan 16 2017 00:41 UTC
@aeselden92 your cases are not correct then you need return count + string
miner_paul
@aeselden92
Jan 16 2017 00:41 UTC
thanks @sjames1958gm
CamperBot
@camperbot
Jan 16 2017 00:41 UTC
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 UTC
@troutman21
Phillip Troutman
@troutman21
Jan 16 2017 00:41 UTC
this is going to be accomplished with the .pop(), .shift(), .unshift() those functions right? @sjames1958gm
miner_paul
@aeselden92
Jan 16 2017 00:41 UTC
I totally forgot about combining with addition
Phil Seidel
@psbyron3
Jan 16 2017 00:42 UTC
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 UTC
Hmm ok. Im still really fuzzy on functions in general so ill keep playing with it.
Phil Seidel
@psbyron3
Jan 16 2017 00:43 UTC
What about functions? Just in genereal or is there something specifically stumping you
Yoel Trujillo
@y0el22
Jan 16 2017 00:43 UTC
@sjames1958gm how can i compare the modified one?
Phil Seidel
@psbyron3
Jan 16 2017 00:43 UTC
general**
Yoel Trujillo
@y0el22
Jan 16 2017 00:43 UTC
equal to what?
Jor
@joreyesl
Jan 16 2017 00:45 UTC
@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 UTC
Just general i think. Im having a hard time with arguments and parameters @psbyron3
Phil Seidel
@psbyron3
Jan 16 2017 00:46 UTC
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 UTC
ok and how do you build the function properly? do you still use the param names?
Phil Seidel
@psbyron3
Jan 16 2017 00:47 UTC
function add (param1, param2) {
     return param1 + param2
}

add(2,3) <----- The two arguments
Phillip Troutman
@troutman21
Jan 16 2017 00:47 UTC
@psbyron3
ok that helps ..
miner_paul
@aeselden92
Jan 16 2017 00:48 UTC
@sjames1958gm any hint on how I should change the case?
Phil Seidel
@psbyron3
Jan 16 2017 00:49 UTC
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 UTC
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 UTC

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 UTC
@psbyron3
Bigyan Karki
@bigyankarki
Jan 16 2017 00:52 UTC

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 UTC
they didnt say how to type this answer ?
Phil Seidel
@psbyron3
Jan 16 2017 00:54 UTC
@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 UTC
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
Phil Seidel
@psbyron3
Jan 16 2017 00:54 UTC
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 UTC
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 UTC
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 UTC
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 UTC
fixed my case but still having problems
Jor
@joreyesl
Jan 16 2017 00:59 UTC
@bigyankarki try /[^\w]/gi
miner_paul
@aeselden92
Jan 16 2017 00:59 UTC
blob
Bigyan Karki
@bigyankarki
Jan 16 2017 01:04 UTC
@joreyesl can you please explain how that works?
still the cocde is note working for _eye
Jor
@joreyesl
Jan 16 2017 01:06 UTC
@bigyankarki /[^A-Za-z]/gi
Moisés Man
@moigithub
Jan 16 2017 01:06 UTC
keep numbers too @joreyesl
Jor
@joreyesl
Jan 16 2017 01:07 UTC
[^A-Za-z0-9]/gi ?
Bigyan Karki
@bigyankarki
Jan 16 2017 01:07 UTC
@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 UTC
to remove the first element of array i use the .shift()function right ? @psbyron3
Jor
@joreyesl
Jan 16 2017 01:09 UTC
@troutman21 yes
Moisés Man
@moigithub
Jan 16 2017 01:09 UTC
IF u use i flag no need to specify upper and lower case
(case insensitive flag )
Phillip Troutman
@troutman21
Jan 16 2017 01:09 UTC
how do i return an item that i shif t off?
@joreyesl
Jor
@joreyesl
Jan 16 2017 01:09 UTC
return arr.shift();
Phillip Troutman
@troutman21
Jan 16 2017 01:10 UTC
hmmm ok. Thank you. @joreyesl
CamperBot
@camperbot
Jan 16 2017 01:10 UTC
troutman21 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 202 | @joreyesl |http://www.freecodecamp.com/joreyesl
Jor
@joreyesl
Jan 16 2017 01:10 UTC
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 UTC
@bigyankarki YOu can do /\W|_/g which will replace all non-word characters and _
Bigyan Karki
@bigyankarki
Jan 16 2017 01:13 UTC
check for palindroms
Stephen James
@sjames1958gm
Jan 16 2017 01:14 UTC
@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 UTC

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 UTC
Global vs Local Scope in Functions isn't working UGH
Jor
@joreyesl
Jan 16 2017 01:17 UTC
@troutman21 yea you are .shift() twice
Stephen James
@sjames1958gm
Jan 16 2017 01:17 UTC
@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 UTC
@joreyesl can you check your code
Stephen James
@sjames1958gm
Jan 16 2017 01:18 UTC
@troutman21 If you do return arr.shift(); then you are removing and returing the value
Wayne Watanabe
@WayneWatanabe
Jan 16 2017 01:20 UTC

// 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 UTC
@WayneWatanabe The name of the added variable inside the function should match the return
Phillip Troutman
@troutman21
Jan 16 2017 01:26 UTC
Finally got it ! thanks everyone @joreyesl @sjames1958gm
CamperBot
@camperbot
Jan 16 2017 01:26 UTC
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 UTC
hey guys!
Stephen James
@sjames1958gm
Jan 16 2017 01:27 UTC
@troutman21 :+1:
@kazcor Hello
Krzysztof Burka
@kazcor
Jan 16 2017 01:27 UTC

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 UTC
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 UTC
how come this sentence is supposed to return false?
Stephen James
@sjames1958gm
Jan 16 2017 01:28 UTC
@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 UTC
thank you! @sjames1958gm
CamperBot
@camperbot
Jan 16 2017 01:28 UTC
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 UTC
So it is just a simple reason... Always the case! Thanks!
Stephen James
@sjames1958gm
Jan 16 2017 01:29 UTC
@kazcor You should remove the extra characters before split reverse/ join then you only replace once
@etmartinkazoo :)
grantknaver
@grantknaver
Jan 16 2017 01:31 UTC
can someone explain what this tid bit of code is doing?
mexmanny
@mexmanny
Jan 16 2017 01:31 UTC
hi all
Proyash
@PROYASH
Jan 16 2017 01:31 UTC

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

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 UTC
@bigyankarki you dont need a loop to reverse. you can have those 3 lines by themselves
grantknaver
@grantknaver
Jan 16 2017 01:34 UTC
any idea guys
Rob McKinnon
@rwmckinnon
Jan 16 2017 01:34 UTC
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 UTC
@rwmckinnon you can put your code between ``` for readability
Rob McKinnon
@rwmckinnon
Jan 16 2017 01:36 UTC
@joreyesl How's that? Just tick marks at the top and bottom?
Jor
@joreyesl
Jan 16 2017 01:36 UTC
@rwmckinnon yes
Frank V. Adames
@fadam00
Jan 16 2017 01:36 UTC
@rwmckinnon delete "myMusic[1]"
Rob McKinnon
@rwmckinnon
Jan 16 2017 01:36 UTC

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 UTC
You're not declaring another variable, you're only adding an object to the array.
Jor
@joreyesl
Jan 16 2017 01:36 UTC
@rwmckinnon :thumbsup:
CoryCMyers
@CoryCMyers
Jan 16 2017 01:36 UTC
I am confused, what did I do wrong here?
Dan Couper
@DanCouper
Jan 16 2017 01:37 UTC
You literally just need to add you other album object to the myMusic array
Frank V. Adames
@fadam00
Jan 16 2017 01:37 UTC
So delete the whole line right after //Add record here and put a comma there
Dan Couper
@DanCouper
Jan 16 2017 01:38 UTC
var myMusic = [ { existing album here }, { your album here }]
Evan Kalvis
@evan17gr
Jan 16 2017 01:38 UTC
@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 UTC
What am I doing wrong here?
Rob McKinnon
@rwmckinnon
Jan 16 2017 01:39 UTC
@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 UTC
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 UTC
@rwmckinnon , it's exactly as @DanCouper said
CoryCMyers
@CoryCMyers
Jan 16 2017 01:39 UTC
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 UTC
You're welcome
CoryCMyers
@CoryCMyers
Jan 16 2017 01:39 UTC
There finally let me send that. Guess I was missing cntrl-enter
Frank V. Adames
@fadam00
Jan 16 2017 01:39 UTC
@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 UTC
What does the 2 in this mean?
miner_paul
@aeselden92
Jan 16 2017 01:40 UTC
Im very struck and dont think my code is wrong.Help
grantknaver
@grantknaver
Jan 16 2017 01:40 UTC
```
function bin_to_dec(bstr) { 
    return parseInt((bstr + '')
    .replace(/[^01]/gi, ''), 2);
}
```
miner_paul
@aeselden92
Jan 16 2017 01:40 UTC
blob
Ive been stuck on this for awhile im sure its a silly syntax thing
Dan Couper
@DanCouper
Jan 16 2017 01:41 UTC
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 UTC
got it @DanCouper it was the extra space in bet
Dan Couper
@DanCouper
Jan 16 2017 01:44 UTC
:+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 UTC
@DanCouper Thank you for the advice!
CamperBot
@camperbot
Jan 16 2017 01:45 UTC
aeselden92 sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 445 | @dancouper |http://www.freecodecamp.com/dancouper
kevinliu6102
@kevinliu6102
Jan 16 2017 01:46 UTC
@grantknaver the returned integer is specified to be base '2', or binary
Labinot
@mrlabinotjaha
Jan 16 2017 01:46 UTC
// 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 UTC
@kevinliu6102 thanks
CamperBot
@camperbot
Jan 16 2017 01:47 UTC
grantknaver sends brownie points to @kevinliu6102 :sparkles: :thumbsup: :sparkles:
:cookie: 292 | @kevinliu6102 |http://www.freecodecamp.com/kevinliu6102
Jor
@joreyesl
Jan 16 2017 01:48 UTC
@mrlabinotjaha whats the error? looks alright to me
Francisco Chavez
@thetruefrank
Jan 16 2017 01:49 UTC
has someone done the stand in line challenge?
Labinot
@mrlabinotjaha
Jan 16 2017 01:49 UTC
@joreyesl that's the question itself i didnt write anything
CoryCMyers
@CoryCMyers
Jan 16 2017 01:49 UTC
@thetruefrank Whats up?
Jor
@joreyesl
Jan 16 2017 01:49 UTC
whats the challenge name? i'll check it out
Labinot
@mrlabinotjaha
Jan 16 2017 01:49 UTC
jor i wrote you on private
Francisco Chavez
@thetruefrank
Jan 16 2017 01:49 UTC
its called stand in line
Labinot
@mrlabinotjaha
Jan 16 2017 01:50 UTC
check pls
CoryCMyers
@CoryCMyers
Jan 16 2017 01:50 UTC
@joreyesl Was that whats the challenge name for me?
grantknaver
@grantknaver
Jan 16 2017 01:51 UTC
@kevinliu6102 shouldn't this thank convert binary to decimal...
CamperBot
@camperbot
Jan 16 2017 01:51 UTC
grantknaver sends brownie points to @kevinliu6102 :sparkles: :thumbsup: :sparkles:
:warning: grantknaver already gave kevinliu6102 points
grantknaver
@grantknaver
Jan 16 2017 01:51 UTC
parseInt('01000001')
or parseInt('01000001', 10);\
forget the slash
Dan Couper
@DanCouper
Jan 16 2017 01:54 UTC
@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 UTC

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 UTC
You are returning
So
grantknaver
@grantknaver
Jan 16 2017 01:56 UTC
didn't know that about toString(), but I knew the rest
Sarthak Khanna
@khannasarthak
Jan 16 2017 01:56 UTC
@suraj-davariya the return statement exits the function
Suraj
@suraj-davariya
Jan 16 2017 01:56 UTC
ohh i got you
what should i use then ? :(
Sarthak Khanna
@khannasarthak
Jan 16 2017 01:57 UTC
```tempvar = 'value to return'
Dan Couper
@DanCouper
Jan 16 2017 01:57 UTC
Assign it to a variable, return after loop finished
grantknaver
@grantknaver
Jan 16 2017 01:57 UTC
thanks. Just trying to figure out how to turn binary into decimal
kevinliu6102
@kevinliu6102
Jan 16 2017 01:57 UTC
@grantknaver the second input should be 2, because your first input is a binary number
Suraj
@suraj-davariya
Jan 16 2017 01:58 UTC
Thanks @DanCouper @grantknaver @khannasarthak :)
CamperBot
@camperbot
Jan 16 2017 01:58 UTC
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 UTC
thanks @DanCouper
CamperBot
@camperbot
Jan 16 2017 01:58 UTC
suraj-davariya sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:warning: suraj-davariya already gave dancouper points
CoryCMyers
@CoryCMyers
Jan 16 2017 01:59 UTC
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 UTC
@khannasarthak @DanCouper @grantknaver Guys i cant find such cantacts still!!!
Sarthak Khanna
@khannasarthak
Jan 16 2017 02:01 UTC
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 UTC
@CoryCMyers does that function not take a string rather than a variable
Suraj
@suraj-davariya
Jan 16 2017 02:02 UTC
actually @khannasarthak its leading me out of the loop :fearful:
Frank V. Adames
@fadam00
Jan 16 2017 02:02 UTC
@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 UTC
@CoryCMyers 'a' 'b' 'c' not a b c? The latter three would be variables, not strings
grantknaver
@grantknaver
Jan 16 2017 02:02 UTC
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 UTC
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 UTC
@suraj-davariya hint : break
Frank V. Adames
@fadam00
Jan 16 2017 02:03 UTC
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 UTC
@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 UTC
@suraj-davariya what do you need
CoryCMyers
@CoryCMyers
Jan 16 2017 02:04 UTC
@DanCouper Actually, I was looking at the wrong tab one second
Sarthak Khanna
@khannasarthak
Jan 16 2017 02:04 UTC
@CoryCMyers what challenge is this?
CoryCMyers
@CoryCMyers
Jan 16 2017 02:05 UTC
@khannasarthak Adding a default option in a switch statement.
Suraj
@suraj-davariya
Jan 16 2017 02:06 UTC
yeah @fadam00 will try that out now..
@khannasarthak break :thi
CoryCMyers
@CoryCMyers
Jan 16 2017 02:06 UTC
@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 UTC
@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 UTC
so the point of parseInt is to generate a decimal number?
Dan Couper
@DanCouper
Jan 16 2017 02:08 UTC
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 UTC
@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 UTC
that is why decimal is the default
CoryCMyers
@CoryCMyers
Jan 16 2017 02:11 UTC
@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 UTC
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 UTC
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 UTC
@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 UTC
@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 UTC
@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 UTC
@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 UTC
Good evening everyone!!! I'm just getting started on JavaScript :smile:
Dan Couper
@DanCouper
Jan 16 2017 02:17 UTC
@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
Jalaj
@TheVip
Jan 16 2017 02:18 UTC

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 UTC
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 UTC
@TheVip can you put your code here?
fernando Reyna
@frr225
Jan 16 2017 02:21 UTC
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 UTC
@CoryCMyers Variables are for referring to pieces of information, values, you want to store. Strings are a type of value.
Jalaj
@TheVip
Jan 16 2017 02:21 UTC
@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 UTC
ok inside the first loop you have this largestNum = arr[i]; thats setting it equal to an array
Jalaj
@TheVip
Jan 16 2017 02:24 UTC
thats what i wanted
Dan Couper
@DanCouper
Jan 16 2017 02:25 UTC
@frr225 what should be the input/output here? A single date in and out?
Jor
@joreyesl
Jan 16 2017 02:25 UTC
@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 UTC
I'm trying to do the initial Celsius to Fahrenheit challenge and I'm having issues figuring it out can anyone help?
Jalaj
@TheVip
Jan 16 2017 02:26 UTC
@joreyesl , Yes
CoryCMyers
@CoryCMyers
Jan 16 2017 02:27 UTC
@DanCouper Thank you!
CamperBot
@camperbot
Jan 16 2017 02:27 UTC
corycmyers sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:warning: corycmyers already gave dancouper points
Dan Couper
@DanCouper
Jan 16 2017 02:27 UTC
:thumbsup:
CoryCMyers
@CoryCMyers
Jan 16 2017 02:27 UTC
There is a lot to get my head around.
DF
@freecodecamper23
Jan 16 2017 02:27 UTC
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 UTC
@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 UTC
@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
Jalaj
@TheVip
Jan 16 2017 02:34 UTC
@joreyesl , got it what you are saying....Thanks!
Dan Couper
@DanCouper
Jan 16 2017 02:35 UTC
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 UTC
var myVar = 87; how do i input the ++
Ayman Mohatarem
@AymanxD
Jan 16 2017 02:36 UTC
Hey guys, did navigator geolocation stop working?
Brendon Bradley
@brenbrad
Jan 16 2017 02:36 UTC
so it equals 88
Jor
@joreyesl
Jan 16 2017 02:38 UTC
@brenbrad myVar++ this is the same as saying myVar = myVar + 1 or myVar += 1
Jalaj
@TheVip
Jan 16 2017 02:38 UTC
@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 UTC
@TheVip :thumbsup:
Brendon Bradley
@brenbrad
Jan 16 2017 02:38 UTC
right on Thaks @joreyesl
thanks @joreyesl
CamperBot
@camperbot
Jan 16 2017 02:38 UTC
brenbrad sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 208 | @joreyesl |http://www.freecodecamp.com/joreyesl
Brian
@BrianCodes33
Jan 16 2017 02:39 UTC
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 UTC
ggg
Sarthak Khanna
@khannasarthak
Jan 16 2017 02:40 UTC
@BrianCodes33 whats wrong with it?
Brian
@BrianCodes33
Jan 16 2017 02:40 UTC
once i put in prime num it gives me error
fernando Reyna
@frr225
Jan 16 2017 02:40 UTC
@DanCouper should i save the values in vars?
Brian
@BrianCodes33
Jan 16 2017 02:41 UTC
so my goal was to filter out non prime nums
and then grab the prime and add it
Jalaj
@TheVip
Jan 16 2017 02:42 UTC
@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 UTC
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 UTC
@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 UTC

@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 UTC
@TheVip there you go, thats actually more concise than my example. :thumbsup:
Sarthak Khanna
@khannasarthak
Jan 16 2017 02:44 UTC
@BrianCodes33 Could you give the link of the challenge?
Brian
@BrianCodes33
Jan 16 2017 02:44 UTC
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);
}
Jalaj
@TheVip
Jan 16 2017 02:44 UTC
@joreyesl , happy to get that compliment
Sarthak Khanna
@khannasarthak
Jan 16 2017 02:48 UTC
fahrenheit = (celsius*9/5) + 32;
You have written
fahrenheit = (fahrenheit*9/5) + 32;
Timothy Hoang
@timh1203
Jan 16 2017 02:49 UTC
That totally fixed it, I understand now. Thanks @khannasarthak
CamperBot
@camperbot
Jan 16 2017 02:49 UTC
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 UTC

@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 UTC
ok
what do you mean grab up the number
Chika Chikwendu
@CheeZeee
Jan 16 2017 02:57 UTC
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 UTC
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 UTC
@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 UTC
okay, then?
oh, I got it. @kevinliu6102
kevinliu6102
@kevinliu6102
Jan 16 2017 03:02 UTC
then run the tests?
Hanqi Liu
@LicheeLiu
Jan 16 2017 03:02 UTC
thanks
Kris
@MeanderingSoul
Jan 16 2017 03:05 UTC
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 UTC
@MeanderingSoul Whats your code
Kris
@MeanderingSoul
Jan 16 2017 03:05 UTC

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 UTC
@MeanderingSoul Your formula is incorrect
Kris
@MeanderingSoul
Jan 16 2017 03:06 UTC
I get 32 in this instance
Jason Luboff
@JLuboff
Jan 16 2017 03:06 UTC
@MeanderingSoul Its celsius * 9/5 + 32
Kris
@MeanderingSoul
Jan 16 2017 03:07 UTC
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 UTC
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 UTC
:+1: \
sega1219
@sega1219
Jan 16 2017 03:10 UTC
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 UTC
if you someone want to kill some zombies https://codepen.io/SultanCodeCamper/full/jyMGMe/
Adel
@AdelMahjoub
Jan 16 2017 03:16 UTC
arrow keys to move, mouse move to aim and left click to shoot
Charan
@charan1998
Jan 16 2017 03:16 UTC
Can someone help me with transition effects for my project?!
Sarthak Khanna
@khannasarthak
Jan 16 2017 03:23 UTC
@ @sega1219 use break
sega1219
@sega1219
Jan 16 2017 03:25 UTC
@khannasarthak where?
fernando Reyna
@frr225
Jan 16 2017 03:25 UTC

@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 UTC
@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 UTC
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 UTC
@mtpjr88 myArray = ourArray;
why this?
Jor
@joreyesl
Jan 16 2017 03:27 UTC
@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 UTC
ohhhhh @khannasarthak thank you so much
CamperBot
@camperbot
Jan 16 2017 03:27 UTC
sega1219 sends brownie points to @khannasarthak :sparkles: :thumbsup: :sparkles:
:cookie: 135 | @khannasarthak |http://www.freecodecamp.com/khannasarthak
Jor
@joreyesl
Jan 16 2017 03:29 UTC
@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 UTC
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 UTC
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 UTC
@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 UTC
@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 UTC
@yourpalsneakers sure give me a sec to write something
Sarthak Khanna
@khannasarthak
Jan 16 2017 03:37 UTC
@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 UTC
@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 UTC
@khannasarthak @joreyesl thanks, very helpful!
CamperBot
@camperbot
Jan 16 2017 03:55 UTC
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
Jalaj
@TheVip
Jan 16 2017 03:57 UTC
@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 UTC
@TheVip let me look up the chall real quick
Jalaj
@TheVip
Jan 16 2017 03:58 UTC
confused :panda_face:
sure!
Jor
@joreyesl
Jan 16 2017 04:00 UTC
@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.
Jalaj
@TheVip
Jan 16 2017 04:07 UTC
@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 UTC
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 UTC
@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.
Jalaj
@TheVip
Jan 16 2017 04:10 UTC
@joreyesl , Fyn, I think i can complete the challenge now. Thanks bro!
CamperBot
@camperbot
Jan 16 2017 04:10 UTC
thevip sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 219 | @joreyesl |http://www.freecodecamp.com/joreyesl
Jor
@joreyesl
Jan 16 2017 04:10 UTC
@TheVip np, good luck :thumbsup:
Brian Rigoni
@BrianRigoni
Jan 16 2017 04:13 UTC
Hello people!
Im stuck in the "Stand in Line" of Javascript, can anyone help me please?
Austiclyse
@Austiclyse
Jan 16 2017 04:15 UTC
@BrianRigoni Yeah, which part?
Brian Rigoni
@BrianRigoni
Jan 16 2017 04:16 UTC
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 UTC
@BrianRigoni What do you know so far or are you totally in the dark?
Matheus Vicente
@chamatt
Jan 16 2017 04:18 UTC
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 UTC
since this waypoint I was totally secure about what I was learning
Reggie
@Reggie01
Jan 16 2017 04:18 UTC
@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 UTC
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 UTC
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 UTC
@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 UTC
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 UTC
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 UTC
ohh ok thank you @Austiclyse !
CamperBot
@camperbot
Jan 16 2017 04:22 UTC
: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 UTC
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 UTC
@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 UTC
@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 UTC

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 UTC
thank you @joreyesl
CamperBot
@camperbot
Jan 16 2017 04:24 UTC
gameruler1 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 223 | @joreyesl |http://www.freecodecamp.com/joreyesl
Ammy3165
@Ammy3165
Jan 16 2017 04:24 UTC
Is here anyone can help me
Pls see my challenge above
Brad Hain
@Bhain1431
Jan 16 2017 04:25 UTC
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 UTC
@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 UTC
@joreyesl thanks i got it.
CamperBot
@camperbot
Jan 16 2017 04:27 UTC
ammy3165 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 224 | @joreyesl |http://www.freecodecamp.com/joreyesl
Austiclyse
@Austiclyse
Jan 16 2017 04:27 UTC
@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 UTC
@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 UTC
@Austiclyse @williamtech814 which challenge is it?
William Cross
@williamtech814
Jan 16 2017 04:28 UTC
Profile Lookup
code:
Ezra
@EzraPlato
Jan 16 2017 04:28 UTC
Stuck on 137 fahrenheit to celsius problem. I have celsius = 30;
celsius *= 9/5 + 32;
William Cross
@williamtech814
Jan 16 2017 04:28 UTC
//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 UTC
@Bhain1431 just read the instruction again, and find out what's the fix for backslash.
Manish Giri
@Manish-Giri
Jan 16 2017 04:29 UTC
@williamtech814 does this seem logical?
if(contacts[i][firstName]===firstName){
    return "No such contact";
  }
Austiclyse
@Austiclyse
Jan 16 2017 04:29 UTC
@joreyesl Profile Lookup. End of JS section
Manish Giri
@Manish-Giri
Jan 16 2017 04:29 UTC
@williamtech814 if you find a matching first name, you return "no such contact"??
William Cross
@williamtech814
Jan 16 2017 04:29 UTC
Yeah it should be !==
makes sense @Manish-Giri
Manish Giri
@Manish-Giri
Jan 16 2017 04:30 UTC
@williamtech814 keep the === but change the conditions
William Cross
@williamtech814
Jan 16 2017 04:30 UTC
@Manish-Giri ?
Jor
@joreyesl
Jan 16 2017 04:31 UTC
@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 UTC
- 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 UTC
I see
@Manish-Giri thanks, I think I get it
CamperBot
@camperbot
Jan 16 2017 04:33 UTC
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 UTC

@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 UTC
:+1:
Austiclyse
@Austiclyse
Jan 16 2017 04:34 UTC
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 UTC
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 UTC
ty @Austiclyse
CamperBot
@camperbot
Jan 16 2017 04:34 UTC
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 UTC
@khaduch thanks, very helpful :)
CamperBot
@camperbot
Jan 16 2017 04:35 UTC
williamtech814 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2285 | @khaduch |http://www.freecodecamp.com/khaduch
caneno
@caneno
Jan 16 2017 04:35 UTC
Hi everybody
I am kind of stuck with a javascript challenge
Austiclyse
@Austiclyse
Jan 16 2017 04:36 UTC
and ty @khaduch
CamperBot
@camperbot
Jan 16 2017 04:36 UTC
austiclyse sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2286 | @khaduch |http://www.freecodecamp.com/khaduch
caneno
@caneno
Jan 16 2017 04:37 UTC
how to I return a removed element form an array
Manish Giri
@Manish-Giri
Jan 16 2017 04:37 UTC
@caneno which one
to remove the first element, use .shift()
to return it, use return
caneno
@caneno
Jan 16 2017 04:39 UTC
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 UTC
use return
along with .shift()
Reggie
@Reggie01
Jan 16 2017 04:41 UTC

@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 UTC
ok just a sec let me tryit
dazewerk
@dazewerk
Jan 16 2017 04:44 UTC
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 UTC
:bulb: to format code use backticks! ``` more info
dazewerk
@dazewerk
Jan 16 2017 04:45 UTC
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 UTC
@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 UTC

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 UTC
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 UTC
@EzraPlato what's this?
 Fahrenheit = celsius;
celsius = 30;
celsius *= 9/5 +32;
caneno
@caneno
Jan 16 2017 04:47 UTC
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 UTC
@caneno put return on line 5
delete line 6
__mifflin__
@cdrainxv
Jan 16 2017 04:49 UTC
@caneno: Return what you just shifted out of the arr array. Remove line 6.
Brian Rigoni
@BrianRigoni
Jan 16 2017 04:49 UTC
@EzraPlato remember that fahrenheit is equal to Celcius * 9/5 + 32
Manish Giri
@Manish-Giri
Jan 16 2017 04:49 UTC
you want to use arr not testArr
@caneno
Brian Rigoni
@BrianRigoni
Jan 16 2017 04:49 UTC
@EzraPlato So, it will be: fahrenheit = celsius * 9/5 + 32
@EzraPlato try with that
caneno
@caneno
Jan 16 2017 04:49 UTC
you guys are awesome
dazewerk
@dazewerk
Jan 16 2017 04:51 UTC
@Manish-Giri Thank you :smile:
CamperBot
@camperbot
Jan 16 2017 04:51 UTC
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 UTC
@dazewerk :+1:
caneno
@caneno
Jan 16 2017 04:51 UTC
@Manish-Giri @cdrainxv Thanks guys
CamperBot
@camperbot
Jan 16 2017 04:51 UTC
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 UTC
@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 UTC
var myStr = "Firstline \n \SecondLine\ \r ThirdLine"; // Change this line
whats the problem with this
Jor
@joreyesl
Jan 16 2017 04:58 UTC
@ujjwaljain0 Firstline should be FirstLine
ujjwaljain0
@ujjwaljain0
Jan 16 2017 04:58 UTC
still it isnt accepting it
Jor
@joreyesl
Jan 16 2017 05:00 UTC
also the extra \ gets deleted here, but make sure you are escaping the \ around SecondLine
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 05:01 UTC
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 UTC
@ujjwaljain0
@ujjwaljain0 make sure you have no spaces or " "
Jor
@joreyesl
Jan 16 2017 05:01 UTC
@ujjwaljain0 your line should look like "FirstLine\n\\SecondLine\\rThirdLine"
ujjwaljain0
@ujjwaljain0
Jan 16 2017 05:02 UTC
ya i removed the spaces now it works . thanx @Jor
CamperBot
@camperbot
Jan 16 2017 05:02 UTC
ujjwaljain0 sends brownie points to @jor :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for jor
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 05:03 UTC
anyone
Reggie
@Reggie01
Jan 16 2017 05:03 UTC
@Dueldrawer8 try using brackets obj[key]
Jor
@joreyesl
Jan 16 2017 05:04 UTC
@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 UTC
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 UTC
@joreyesl @Reggie01 thank you..
CamperBot
@camperbot
Jan 16 2017 05:07 UTC
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 UTC
@robert194w lets see your code
Jor
@joreyesl
Jan 16 2017 05:09 UTC
@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 UTC
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 UTC
@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 UTC
@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 UTC
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 UTC
@BrianRigoni that didn't work
Jor
@joreyesl
Jan 16 2017 05:18 UTC
@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 UTC
@joreyesl ah thanks
CamperBot
@camperbot
Jan 16 2017 05:18 UTC
dueldrawer8 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:warning: dueldrawer8 already gave joreyesl points
Eric Chung
@chungeric
Jan 16 2017 05:19 UTC
@joreyesl Ahh awesome, thanks for the feedback!
CamperBot
@camperbot
Jan 16 2017 05:19 UTC
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 UTC
@Reggie01 @joreyesl Thanks folks! Stupid spelling error. Looked at it ten times and didn't see it.
CamperBot
@camperbot
Jan 16 2017 05:19 UTC
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 UTC
@heroiczero @heroiczero Thanks for your help!
CamperBot
@camperbot
Jan 16 2017 05:21 UTC
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 UTC
Must be bedtime. LOL
Ezra
@EzraPlato
Jan 16 2017 05:23 UTC
@BrianRigoni thanks. It did work. That was easy and I didn't understand.
CamperBot
@camperbot
Jan 16 2017 05:23 UTC
ezraplato sends brownie points to @brianrigoni :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for brianrigoni
Jor
@joreyesl
Jan 16 2017 05:29 UTC
@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 UTC
@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?
Jalaj
@TheVip
Jan 16 2017 05:33 UTC
@joreyesl , bro I need your help again :alarm_clock:
Jor
@joreyesl
Jan 16 2017 05:35 UTC
@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?
Jalaj
@TheVip
Jan 16 2017 05:36 UTC
@joreyesl , I am stuck on 'Mutation' challenge....actually i don't know where to start from
Eric Chung
@chungeric
Jan 16 2017 05:36 UTC
@joreyesl right haha, makes sense
WilliamBadgett97
@WilliamBadgett97
Jan 16 2017 05:39 UTC

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 UTC
@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 UTC
var myStr ="FirstLine\n\SecondLine\r\ThirdLine \" ;
Yeah, I'm doing really bad at java lmao...
Jor
@joreyesl
Jan 16 2017 05:45 UTC
@WilliamBadgett97 Should be FirstLine\n\\SecondLine\\\rThirdLine
WilliamBadgett97
@WilliamBadgett97
Jan 16 2017 05:46 UTC
Thank you, I'm going to review what I did wrong and keep going over it.
Jor
@joreyesl
Jan 16 2017 05:46 UTC
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 UTC
hello, I would like to get some help if it's available.
Austiclyse
@Austiclyse
Jan 16 2017 05:50 UTC
@joreyesl You still kicking ass on here? I need help.
Jor
@joreyesl
Jan 16 2017 05:50 UTC
@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
Jalaj
@TheVip
Jan 16 2017 05:51 UTC
@joreyesl , trying what you said :+1:
Gabriela Bazan
@GabrielaLBazan
Jan 16 2017 05:52 UTC

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 UTC
@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 UTC

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 UTC
@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 UTC
i am so confused as to how do i store and append the first capitlized letter is appended with rest of the strings
Jalaj
@TheVip
Jan 16 2017 05:56 UTC
@GabrielaLBazan , You need to do like this,
result = myAdverb + " " + myNoun + " " + myVerb + " " + myAdjective;
Austiclyse
@Austiclyse
Jan 16 2017 05:57 UTC
@joreyesl Is the switch breaking it? Right now it only returns "No such property"
Phil Seidel
@psbyron3
Jan 16 2017 05:57 UTC
Do you need to capitalize every first letter of every word? @bigyankarki
Bigyan Karki
@bigyankarki
Jan 16 2017 05:58 UTC
yes @psbyron3
Jor
@joreyesl
Jan 16 2017 05:58 UTC
@Austiclyse yea there is a few problems with the switch.
Phil Seidel
@psbyron3
Jan 16 2017 05:58 UTC
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 UTC
thank you @TheVip
CamperBot
@camperbot
Jan 16 2017 05:58 UTC
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 UTC
@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 UTC
oh! @GregatGit thanks
CamperBot
@camperbot
Jan 16 2017 05:59 UTC
bigyankarki sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 826 | @gregatgit |http://www.freecodecamp.com/gregatgit
Austiclyse
@Austiclyse
Jan 16 2017 06:00 UTC
@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 UTC
@psbyron3 how can i monitor white space and capitalize the first word it follows
Greg Duncan
@GregatGit
Jan 16 2017 06:01 UTC
@Austiclyse i woudn't use a switch here
Jor
@joreyesl
Jan 16 2017 06:01 UTC
@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 UTC

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 UTC
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 UTC
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 UTC
@bigyankarki /\s/gi thats a regex expression you are using
Phil Seidel
@psbyron3
Jan 16 2017 06:05 UTC
Regular expression ... the
exactly what they said :arrow_up:
Bigyan Karki
@bigyankarki
Jan 16 2017 06:05 UTC
oh ya haha
what it does is find the whitespaces
Jor
@joreyesl
Jan 16 2017 06:06 UTC
@bigyankarki if you want split by whitespace you can also do .split(" ")
Manish Giri
@Manish-Giri
Jan 16 2017 06:07 UTC
@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 UTC
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 UTC
@WilliamBadgett97 good! :thumbsup:
Bigyan Karki
@bigyankarki
Jan 16 2017 06:09 UTC
hmm let me try that
Hanqi Liu
@LicheeLiu
Jan 16 2017 06:10 UTC
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 UTC
@LicheeLiu typo swtich(val)
Hanqi Liu
@LicheeLiu
Jan 16 2017 06:12 UTC
aaaaaah, thanks! @joreyesl
CamperBot
@camperbot
Jan 16 2017 06:12 UTC
:cookie: 235 | @joreyesl |http://www.freecodecamp.com/joreyesl
licheeliu sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
Austiclyse
@Austiclyse
Jan 16 2017 06:12 UTC
@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 UTC
@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 UTC
@Austiclyse contacts[i][prop] there is a huge difference
CoryCMyers
@CoryCMyers
Jan 16 2017 06:14 UTC

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 UTC
.prop will look for a property called prop
Austiclyse
@Austiclyse
Jan 16 2017 06:15 UTC
@GregatGit ???! I though dot notation was used to look up properties with one word names?
kevinliu6102
@kevinliu6102
Jan 16 2017 06:15 UTC
@CoryCMyers look up javascript object notation
Greg Duncan
@GregatGit
Jan 16 2017 06:16 UTC
@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 UTC
@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 UTC
@Austiclyse it just something you should play around with until you get it
Austiclyse
@Austiclyse
Jan 16 2017 06:17 UTC
Okay, thats closer. prop is in []s but it only pulls the first contacts info
Jor
@joreyesl
Jan 16 2017 06:17 UTC
@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 UTC
@joreyesl Thank you! That is what I was wondering!
CamperBot
@camperbot
Jan 16 2017 06:17 UTC
corycmyers sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 236 | @joreyesl |http://www.freecodecamp.com/joreyesl
kevinliu6102
@kevinliu6102
Jan 16 2017 06:17 UTC
@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 UTC
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 UTC
@Austiclyse put up what you have
Joseph
@revisualize
Jan 16 2017 06:18 UTC
@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 UTC
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 UTC
@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 UTC
@Austiclyse No firstName is the literal name of the property you are accessing. prop is a variable.
Austiclyse
@Austiclyse
Jan 16 2017 06:23 UTC
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 UTC
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 UTC
What’s the difference between a const and a var?
GabriRa
@GabriRa
Jan 16 2017 06:25 UTC
Guys, the Sum All Primes algorithm is working?
Jor
@joreyesl
Jan 16 2017 06:25 UTC
@ccw13 you cant compare to multiple things else if (card==10,"J","Q","K","A")
ccw13
@ccw13
Jan 16 2017 06:26 UTC
@joreyesl owh okay thanks
CamperBot
@camperbot
Jan 16 2017 06:26 UTC
ccw13 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 237 | @joreyesl |http://www.freecodecamp.com/joreyesl
Jor
@joreyesl
Jan 16 2017 06:26 UTC
@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 UTC
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 UTC
@joreyesl i fixed it.... still isnt working
annabaum
@annabaum
Jan 16 2017 06:27 UTC
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 UTC

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 UTC

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 UTC
Could I please get some help with the basic algorithms?
ccw13
@ccw13
Jan 16 2017 06:28 UTC
something is definitely wrong
Bigyan Karki
@bigyankarki
Jan 16 2017 06:28 UTC
how can i now access the first letter of the array?
Chase
@Athabasco
Jan 16 2017 06:28 UTC
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 UTC
ok, starting on the mutation totally at loss for it
Jor
@joreyesl
Jan 16 2017 06:29 UTC

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

@ccw13 same thing here

else{
count= -1;
}

should be

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

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 UTC
oh okay thanks @joreyesl
CamperBot
@camperbot
Jan 16 2017 06:31 UTC
ccw13 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:warning: ccw13 already gave joreyesl points
Steve Fuller
@wsfuller
Jan 16 2017 06:32 UTC
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 UTC
i sheepishly need help with "Make Object Properties Private"
Jor
@joreyesl
Jan 16 2017 06:33 UTC
@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 UTC
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 UTC

```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 UTC
` Then his shift enter and close with `
three `
Chase
@Athabasco
Jan 16 2017 06:34 UTC
`
sup meh dude
```
CoryCMyers
@CoryCMyers
Jan 16 2017 06:35 UTC
close it the same way then cntrl enter to send
Chase
@Athabasco
Jan 16 2017 06:35 UTC
`test
`test
test
annabaum
@annabaum
Jan 16 2017 06:35 UTC
@joreyesl aaaaaah ok. :) Thank you!
CamperBot
@camperbot
Jan 16 2017 06:35 UTC
annabaum sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 238 | @joreyesl |http://www.freecodecamp.com/joreyesl
Chase
@Athabasco
Jan 16 2017 06:35 UTC
ik how to do this though
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:35 UTC
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 UTC
@Dueldrawer8 typo here total+ obj.sexy[i];
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:36 UTC
@joreyesl yikes!
GabriRa
@GabriRa
Jan 16 2017 06:36 UTC
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 UTC
Anybody done with basic algorithms and could lend a quick hand?
Austiclyse
@Austiclyse
Jan 16 2017 06:37 UTC
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 UTC
@joreyesl hm.. it says cannot read property length of undefined
kevinliu6102
@kevinliu6102
Jan 16 2017 06:38 UTC
@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 UTC
@joreyesl can i not use length property on an array within an object?
typerror it says
Jor
@joreyesl
Jan 16 2017 06:39 UTC
whats the name of the challenge?
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:40 UTC
@joreyesl heh its not on here.. im doing other algorithms.. hmm
Jor
@joreyesl
Jan 16 2017 06:40 UTC
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 UTC

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 UTC
@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 UTC
@joreyesl
var obj = {
  key: [4, 1, 8]
};
var output = getSumOfAllElementsAtProperty(obj, 'key');
console.log(output); // --> 13
Jor
@joreyesl
Jan 16 2017 06:42 UTC
great! It look like you wont need a foreach
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:43 UTC
@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 UTC
@Austiclyse save it in a variable
John
@flyboy1565
Jan 16 2017 06:45 UTC
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 UTC
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 UTC
@Dueldrawer8 here obj.sexy.length try obj[sexy].length instead
John
@flyboy1565
Jan 16 2017 06:47 UTC
@zzzhenng , try using a different variable for this.gear = new_gear
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:48 UTC
@joreyesl now it says cannot read property '0' of undefined
Austiclyse
@Austiclyse
Jan 16 2017 06:48 UTC
@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 UTC
zzzhenng: maybe you should return 'this.gear' in getGear method
Eric
@eherod
Jan 16 2017 06:50 UTC
Hello
zzzhenng
@zzzhenng
Jan 16 2017 06:51 UTC
@shkurata great, u are right.thanks
kevinliu6102
@kevinliu6102
Jan 16 2017 06:51 UTC
@Austiclyse try an array
Jor
@joreyesl
Jan 16 2017 06:53 UTC
@Dueldrawer8 total+ obj.sexy[i]; try total += obj[sexy][i];
Nikolay Neykov
@shkurata
Jan 16 2017 06:54 UTC
eherod: try first yourself
John Freeborn
@jfx1026
Jan 16 2017 06:54 UTC
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 UTC
@Nikolay. I never thought of that.
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:56 UTC
@joreyesl lol that works! thank you..
CamperBot
@camperbot
Jan 16 2017 06:56 UTC
dueldrawer8 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 239 | @joreyesl |http://www.freecodecamp.com/joreyesl
Jor
@joreyesl
Jan 16 2017 06:57 UTC
@eherod what is the problem?
what are you stuck on
Randy Goldsmith
@Dueldrawer8
Jan 16 2017 06:57 UTC
@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 UTC
@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 UTC
@joreyesl man thats confusing somewhat but i get it
jrhaynes88
@jrhaynes88
Jan 16 2017 07:00 UTC
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 UTC
@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 UTC
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 UTC
@joreyesl makes more sense
Austiclyse
@Austiclyse
Jan 16 2017 07:03 UTC
@jrhaynes88 FirstLine\n\SecondLine\\rThirdLine is what you need
@jrhaynes88
FirstLine\n\SecondLine\\rThirdLine
Jor
@joreyesl
Jan 16 2017 07:05 UTC
@Austiclyse try putting it between `
Adri Jenie
@Adrifajar
Jan 16 2017 07:07 UTC
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 UTC

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 UTC
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 UTC
@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 UTC
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 UTC
is console logging undefined in the array
anyone have any ideas im stumped
I dont know
Adri Jenie
@Adrifajar
Jan 16 2017 07:09 UTC
@joreyesl using shift and unshift?
grantknaver
@grantknaver
Jan 16 2017 07:10 UTC
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 UTC
@Adrifajar well unshift will add the item to the beginning of the array.
pvaidya56
@pvaidya56
Jan 16 2017 07:11 UTC

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 UTC
@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 UTC
@pvaidya56 var fahrenheit = 32; fahrenheit should equal and equation with celcius in it
tptynlr
@tptynlr
Jan 16 2017 07:14 UTC

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 UTC
any ideas guys
Greg Duncan
@GregatGit
Jan 16 2017 07:16 UTC
@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 UTC
help
grantknaver
@grantknaver
Jan 16 2017 07:22 UTC
ok can someone explain to me how I made this actually work?
Saeed Jassani
@saeedjassani
Jan 16 2017 07:22 UTC
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 UTC
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 UTC
all these have not been taught
h1tag
@h1tag
Jan 16 2017 07:23 UTC
@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 UTC
can anyone help me with my simon says game project?
Greg Duncan
@GregatGit
Jan 16 2017 07:25 UTC
@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 UTC
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 UTC
@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 UTC
ok thanks @khannasarthak ill keep trying
CamperBot
@camperbot
Jan 16 2017 07:27 UTC
: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 UTC
@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 UTC
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 UTC
@brenbrad Ping me if you are unable to clear it
grantknaver
@grantknaver
Jan 16 2017 07:30 UTC
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 UTC
@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 UTC
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 UTC
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 UTC
@Adrifajar that seems correct
any code to follow it up?
Adri Jenie
@Adrifajar
Jan 16 2017 07:36 UTC

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
should then return the element that was removed
Sarthak Khanna
@khannasarthak
Jan 16 2017 07:38 UTC
could you send me a link to the challenge?
grantknaver
@grantknaver
Jan 16 2017 07:39 UTC
any help would be appreciated. lol
Sudhanshu Mishra
@rocky3031
Jan 16 2017 07:39 UTC
var count = 0;

function cc(card) {
  // Only change code below this line
switch (card){
  case 2:
  case 3:
  case 4:
  case 5:
  case 6:
    count+=1;
    break;
  case 7:
  case 8:
  case 9:
    count+=0;
    break;
  case 10:
  case "J":
  case "Q":
  case "K":
  case "A":
    count-=1;
    break;
}

  return ;
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
What should i do in return
Ogundele Olumide
@Lumexralph
Jan 16 2017 07:41 UTC
@Adrifajar return what you shifted from arr
@grantknaver can you give me some mins to work a lil bit with it?
Sarthak Khanna
@khannasarthak
Jan 16 2017 07:42 UTC
@Adrifajar
function nextInLine(arr, item) {
  arr.push(item);
  a = arr.shift();
  // Your code here

  return a;  // Change this line
}
Ogundele Olumide
@Lumexralph
Jan 16 2017 07:43 UTC
@rocky3031 you have not finished, your to return count + string depending whether it's positive or negative
Adri Jenie
@Adrifajar
Jan 16 2017 07:43 UTC
@khannasarthak ty
CamperBot
@camperbot
Jan 16 2017 07:43 UTC
adrifajar sends brownie points to @khannasarthak :sparkles: :thumbsup: :sparkles:
:cookie: 138 | @khannasarthak |http://www.freecodecamp.com/khannasarthak
Adri Jenie
@Adrifajar
Jan 16 2017 07:44 UTC
so i define the one that were shifted by a=arr.shift(). instead of just shifting. so i can return it later?
Sudhanshu Mishra
@rocky3031
Jan 16 2017 07:44 UTC
@Lumexralph how can i do that any example??
Ogundele Olumide
@Lumexralph
Jan 16 2017 07:45 UTC
@rocky3031 what was the instructions ? on the challenge? where it's asking you to bet or hold?
fernando Reyna
@frr225
Jan 16 2017 07:46 UTC
v
Sudhanshu Mishra
@rocky3031
Jan 16 2017 07:47 UTC
@Lumexralph ok thanks
CamperBot
@camperbot
Jan 16 2017 07:47 UTC
rocky3031 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 752 | @lumexralph |http://www.freecodecamp.com/lumexralph
fernando Reyna
@frr225
Jan 16 2017 07:49 UTC
var final=["July 1st", " July 4th"]
Charan
@charan1998
Jan 16 2017 07:50 UTC
Can anyone help me with transition effects?!
Muhammad Hasham
@MohammadHasham
Jan 16 2017 07:51 UTC
can anyone help me with simon says game ?
ccw13
@ccw13
Jan 16 2017 07:52 UTC

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

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

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

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

whats the problem?
Chase
@Athabasco
Jan 16 2017 07:52 UTC
@ccw13 what are you trying to do?
Dan Couper
@DanCouper
Jan 16 2017 07:53 UTC
You're returning undefined
fernando Reyna
@frr225
Jan 16 2017 07:53 UTC

// this returns July 1st 4th does any one knows how to make return "July 1st ","4th" not "July ","1st ","4th" var final=["July 1st", " July 4th"] 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;

Ogundele Olumide
@Lumexralph
Jan 16 2017 07:53 UTC
@grantknaver hey man, are you there?
@ccw13 what are you trying to do?
ccw13
@ccw13
Jan 16 2017 07:54 UTC
@Athabasco @Lumexralph trying to get the object to work
Ogundele Olumide
@Lumexralph
Jan 16 2017 07:54 UTC
@ccw13 which object?
ccw13
@ccw13
Jan 16 2017 07:54 UTC
@Lumexralph all of them isnt working
Dan Couper
@DanCouper
Jan 16 2017 07:57 UTC
@frr225 you should not include July in it from the start, it is much, much easier. But at the minute, you need to save the first month: something like month = mic[0]; mic = mic.filter(el => el ===
Ogundele Olumide
@Lumexralph
Jan 16 2017 07:57 UTC

@grantknaver

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);
var mySet = new Set(loopArray);  // set constructor allows uniques values so no duplication, it returns an object
return [...mySet];  //i spreaded the values of the object mySet into an array

}



uniteUnique([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8]);

will see if i can help you refactor it a lil bit

Dan Couper
@DanCouper
Jan 16 2017 07:57 UTC
month
Ogundele Olumide
@Lumexralph
Jan 16 2017 07:57 UTC
@ccw13 you need to understand the instructions
Jor
@joreyesl
Jan 16 2017 07:58 UTC
@ccw13 var result = val;You dont want to set result = val. You use val to find the result. val is the key for the lookup. so you need to do lookup[val]
ccw13
@ccw13
Jan 16 2017 07:59 UTC
@Lumexralph thats the problem with me and free code camp.. sometimes i feel like i dont even understand the instruction...
@joreyesl okay thanks
CamperBot
@camperbot
Jan 16 2017 07:59 UTC
ccw13 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 240 | @joreyesl |http://www.freecodecamp.com/joreyesl
Muhammad Hasham
@MohammadHasham
Jan 16 2017 07:59 UTC
anyone who can help me with simon says project?
pvaidya56
@pvaidya56
Jan 16 2017 08:00 UTC
@MohammadHasham sorry, not quite at that project yet but i hope you can find someone to help you!
Ogundele Olumide
@Lumexralph
Jan 16 2017 08:00 UTC
@ccw13 okay, your function has a parameter val the parameter will be used as a reference for each property of the objects lookup to access it, and you're to assign the value of that property val in lookup to result
Muhammad Hasham
@MohammadHasham
Jan 16 2017 08:01 UTC
@pvaidya56 i can't find anyone :worried:
Sudhanshu Mishra
@rocky3031
Jan 16 2017 08:02 UTC
var count = 0;

function cc(card) {
  // Only change code below this line
switch (card){
  case 2:
  case 3:
  case 4:
  case 5:
  case 6:
    count+=1;
    break;
  case 7:
  case 8:
  case 9:
    count+=0;
    break;
  case 10:
  case "J":
  case "Q":
  case "K":
  case "A":
    count-=1;
    break;
}

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

  }else if (count <= 0) {
    return count + " hold";
  }
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
what is worng?
Ogundele Olumide
@Lumexralph
Jan 16 2017 08:02 UTC
@MohammadHasham what are you trying to do, i have not had time to do that project but let's see if I can help
pvaidya56
@pvaidya56
Jan 16 2017 08:02 UTC
@MohammadHasham maybe try a different chat room
Ogundele Olumide
@Lumexralph
Jan 16 2017 08:02 UTC
@rocky3031 is it hold or Hold? which
fernando Reyna
@frr225
Jan 16 2017 08:02 UTC
@DanCouper ok ill give it a try
Muhammad Hasham
@MohammadHasham
Jan 16 2017 08:03 UTC
@Lumexralph actually i am trying to match computer generated pattern with user generated pattern using an arrat
@pvaidya56 maybe
Sudhanshu Mishra
@rocky3031
Jan 16 2017 08:03 UTC
@Lumexralph ok thanks
CamperBot
@camperbot
Jan 16 2017 08:03 UTC
rocky3031 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:warning: rocky3031 already gave lumexralph points
Ogundele Olumide
@Lumexralph
Jan 16 2017 08:05 UTC
@MohammadHasham try this room https://gitter.im/FreeCodeCamp/HelpFrontEnd it's majorly for projects
Muhammad Hasham
@MohammadHasham
Jan 16 2017 08:05 UTC
yeah i have posted my question there
Ogundele Olumide
@Lumexralph
Jan 16 2017 08:05 UTC
@MohammadHasham no one responded?
Muhammad Hasham
@MohammadHasham
Jan 16 2017 08:05 UTC
@Lumexralph no one yet :worried:
Adel
@AdelMahjoub
Jan 16 2017 08:06 UTC
@MohammadHasham can you describe that simon says game , and how it works in reality
Muhammad Hasham
@MohammadHasham
Jan 16 2017 08:07 UTC
a pattern is generated let's say
red,blue green
the user has to match the same pattern
@AdelMahjoub
Adel
@AdelMahjoub
Jan 16 2017 08:07 UTC
@MohammadHasham in reality, describe the electronic game
h1tag
@h1tag
Jan 16 2017 08:08 UTC
@GregatGit I fixed it by allowing location access on the website but still the same error
Muhammad Hasham
@MohammadHasham
Jan 16 2017 08:08 UTC
this one is in reality,some colors are turned on in a pattern when they stop the user has to hit the same colors.Actually a memory game!!
@AdelMahjoub
Adel
@AdelMahjoub
Jan 16 2017 08:09 UTC
@MohammadHasham ok, so how do you "generate a pattern"
@MohammadHasham it is a memory game in the player perspective, not in the game perspective
Muhammad Hasham
@MohammadHasham
Jan 16 2017 08:10 UTC
yes
@AdelMahjoub
in player's perp.
through random number generator between 1 and 4 and then storing that in an array then i am taking another array to store user clicks and then i am trying to compare them
Adel
@AdelMahjoub
Jan 16 2017 08:12 UTC
@MohammadHasham and ?
Jalaj
@TheVip
Jan 16 2017 08:12 UTC
I need help related 'Mutations' challenge....actually I don't know from where to start?
Adel
@AdelMahjoub
Jan 16 2017 08:13 UTC
@MohammadHasham can you make the guess the number game ?
Muhammad Hasham
@MohammadHasham
Jan 16 2017 08:13 UTC
@AdelMahjoub and i am failing to compare them
what is it?
'guess the number'
Adel
@AdelMahjoub
Jan 16 2017 08:13 UTC
@MohammadHasham the program generate a random number and the player must find it
@MohammadHasham the player, enter the number in an input field
Muhammad Hasham
@MohammadHasham
Jan 16 2017 08:14 UTC
yeah i guess this could be really eays
easy
@AdelMahjoub
it is just the comparison
Adel
@AdelMahjoub
Jan 16 2017 08:14 UTC
@MohammadHasham ok, make one
Muhammad Hasham
@MohammadHasham
Jan 16 2017 08:15 UTC
actually i have to complete it by next monday! due to some reasons that is why i am in a little bit of hurry!
i'll surely make one but after completing it.
@AdelMahjoub
can you see my pen
Jor
@joreyesl
Jan 16 2017 08:16 UTC
@MohammadHasham are you able to generate an array? are you able to create the user array?
Ogundele Olumide
@Lumexralph
Jan 16 2017 08:16 UTC
@TheVip what're the instructions?
Muhammad Hasham
@MohammadHasham
Jan 16 2017 08:16 UTC
@joreyesl yes u have made them
i don't know what is wrong @joreyesl
Jor
@joreyesl
Jan 16 2017 08:17 UTC
@MohammadHasham so you just need help comparing them?
Adel
@AdelMahjoub
Jan 16 2017 08:17 UTC
@MohammadHasham the program generate a random number between 1 and 4, then in an input field the player must enter the correct number, each time the player gives the correct number, the program generate a second number, and the player must each time enter the whole generated sequence of numbers generated
Muhammad Hasham
@MohammadHasham
Jan 16 2017 08:17 UTC
yeah! maybe that would resolve the issue
@joreyesl
Adel
@AdelMahjoub
Jan 16 2017 08:17 UTC
@MohammadHasham if you can do that game, then you have done simon says
Jalaj
@TheVip
Jan 16 2017 08:18 UTC
@Lumexralph , Challenge link
CronoxAU
@CronoxAU
Jan 16 2017 08:18 UTC
@redoz94 what bit are you having issues with specifically?
Muhammad Hasham
@MohammadHasham
Jan 16 2017 08:18 UTC
but here the problem is that i have to compare a sequence of numbers.If only one number is to be compared that would be easy
@AdelMahjoub
but comparing the whole thing and adjusting counter is really difficult
Ogundele Olumide
@Lumexralph
Jan 16 2017 08:19 UTC
@redoz94 processed = process(7)....you are to call the function with an argument and assign the returned value to processed
Jor
@joreyesl
Jan 16 2017 08:19 UTC
@MohammadHasham
var arr1 = [1,3,4];
var arr2 = [1,3,4];

for(var i = 0; i < arr1.length; i++) {
  if(arr1[i] !== arr2[i]) {
    // if this ever happens they they are not the same
  }
}

//if the loop gets here, then they are the same.
Jalaj
@TheVip
Jan 16 2017 08:20 UTC
@joreyesl , hey bro, i am unable to do the challenge
Muhammad Hasham
@MohammadHasham
Jan 16 2017 08:20 UTC
@joreyesl yeah i know that but i maybe doing wrong at setting counters and in function calling
http://codepen.io/Mohammad_Hasham/pen/JbWOWw?editors=0010
please check the onlick handlers i hpe they make some sense.
Adel
@AdelMahjoub
Jan 16 2017 08:20 UTC
@MohammadHasham don't mix the animation with the data
Jor
@joreyesl
Jan 16 2017 08:21 UTC
@MohammadHasham can you post the relevant portion of the code?
@TheVip whats up
John Alcher
@alchermd
Jan 16 2017 08:22 UTC
Heyy. Anyone that's not that busy? I'm looking to understand a weird behaviour on my code :)
redoz94
@redoz94
Jan 16 2017 08:22 UTC
@Lumexralph thanks man!
CamperBot
@camperbot
Jan 16 2017 08:22 UTC
:cookie: 753 | @lumexralph |http://www.freecodecamp.com/lumexralph
redoz94 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
Dovey
@Doveymd
Jan 16 2017 08:23 UTC
Hello all... I have ran into an issue with escaping leteral quote in strings. "I am a\"double quoted\"string inside\"double quotes\"."; is what I have. It is not reading out correctly (I am a "double quoted" string inside "double quotes".) What am I missing?
Ogundele Olumide
@Lumexralph
Jan 16 2017 08:23 UTC
@TheVip arr is an array that holds 2 elements, access the elements, make them to lowercase, then you look for the indexOf characters in elements in the second arr value from the first element then return a boolean false if that element is greater than or equal to 0 or return true...that should give you an headstart
Adel
@AdelMahjoub
Jan 16 2017 08:23 UTC
@MohammadHasham if you can make guess the number game then you can make guess the array of numbers game.
Ogundele Olumide
@Lumexralph
Jan 16 2017 08:24 UTC
@alchermd ask your question
John Alcher
@alchermd
Jan 16 2017 08:25 UTC
Looking for some guidance here :smile: Basically the commented part is my question. Any ideas why?
flashButton(index) {
        const selector = this.buttons[index];
        typeof index == "number" ? this.highlight(selector) : this.highlight($(".box"))
        // index == undefined as the condition results in typeError
    }
Jalaj
@TheVip
Jan 16 2017 08:26 UTC
@Lumexralph , i will try
kevinliu6102
@kevinliu6102
Jan 16 2017 08:26 UTC
@alchermd enclose the condition in parentheses? not sure lol
Ogundele Olumide
@Lumexralph
Jan 16 2017 08:26 UTC
@alchermd what are you expecting to be in index?
John Alcher
@alchermd
Jan 16 2017 08:26 UTC
The premise here is that I use flashButton() with an index parameter to flash a single button, while calling flashButton() without a parameter flashes them all
@kevinliu6102 Tried it already :D
@Lumexralph Here's my work if you'd like to check. It's working now, I just find it weird that index == undefined is not valid
http://codepen.io/AlcherMD/pen/JEKzmB
Also tried to remove "use strict" just to check, but it's still a typeError
Ezra
@EzraPlato
Jan 16 2017 08:30 UTC
I'm not really sure what is wrong with this
var myStr='FirstLine\n\SecondLine\r\ThirdLine';
Ogundele Olumide
@Lumexralph
Jan 16 2017 08:32 UTC
@alchermd will check
Ezra
@EzraPlato
Jan 16 2017 08:32 UTC
It's suppose to look like this FirstLine
\SecondLine\
ThirdLine
Ogundele Olumide
@Lumexralph
Jan 16 2017 08:32 UTC
@EzraPlato is backslash \\ there?
Ezra
@EzraPlato
Jan 16 2017 08:33 UTC
yeah: 'firstLine\n\SecondLine\r\ThirdLine';
It keeps erasing the second backslash when I post it but there are double backslashes after the n and the r
Ogundele Olumide
@Lumexralph
Jan 16 2017 08:34 UTC
@EzraPlato is it firstLine or FirstLine?
Ezra
@EzraPlato