These are chat archives for FreeCodeCamp/HelpJavaScript

1st
Jan 2017
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 00:00
you need spaces @jimiryquai
the will print out as mydogwasbig
Moisés Man
@moigithub
Jan 01 2017 00:01
@HeebieGeeBee it has spaces.. but hard to see
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 00:01
oh i could tell
couldnt
well then yeah just stop trying to overwrite the variable
James Ryan
@jimiryquai
Jan 01 2017 00:03
@HeebieGeeBee I have spaces and it's printing out fine but I have no idea how to change the words to cat etc other than declaring more variables and a new string etc and I know that just can't be right. Can't seem to get my head around the concept. Has anybody else found it hard or unclear or am I just being a dunce LOL
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 00:03
you dont have to
the parameters of the function are already written for you
James Ryan
@jimiryquai
Jan 01 2017 00:04
So I'm overcomplicating and all it's asking me to do is declare the string etc?
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 00:04
yeah return a result that is a string made up of the parameters and spaces and maybe extra words if you want
Bryan Reese
@breese8009
Jan 01 2017 00:04
good afternoon javascripters lol
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 00:05
good evening
Walid Ashri
@walidashri
Jan 01 2017 00:05
Good Morning :)
James Ryan
@jimiryquai
Jan 01 2017 00:05
Yeah I've sorted it! It confused me by asking for other words etc but It's dropping into place now!
Thanks @HeebieGeeBee and @revisualize - I have a tendency to overcomplicate and now that I've solved it it's making a lot more sense to me!
CamperBot
@camperbot
Jan 01 2017 00:07
jimiryquai sends brownie points to @heebiegeebee and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 409 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:star2: 2787 | @revisualize |http://www.freecodecamp.com/revisualize
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 00:07
it happens i still do it
i wrote like 50 lines of code earlier and was doing my head in
James Ryan
@jimiryquai
Jan 01 2017 00:08
Good to know bud - I give myself a hard time and automatically think I'm being stupid!
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 00:08
until i realised i could do it all in one line
James Ryan
@jimiryquai
Jan 01 2017 00:08
Ha ha sounds like something I'd do!
Thomas Gould
@firebird2552
Jan 01 2017 00:22
I am trying to write some code for one of the javascript portions and I am getting an error I want to console.log some of the info that I am using to see why I am getting the fail but I can not figure out where the log goes to
I am using chrome
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 00:26
f12
developer tools
Thomas Gould
@firebird2552
Jan 01 2017 00:30
thank you
Glitches777
@Glitches777
Jan 01 2017 00:34
How do you put up the picture to show your code?
Joseph
@revisualize
Jan 01 2017 00:38

@Glitches777 If you are posting code that is large, Please use Gist - https://gist.github.com/ then please paste the link here.
...
How to do code block format:
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code
```js [SHIFT+ENTER]
// your code here
``` [CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

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

@Glitches777 It isn't a "picture" it is formatted text.
Try with a small block before you go big.
Glitches777
@Glitches777
Jan 01 2017 00:39
@revisualize thank you
CamperBot
@camperbot
Jan 01 2017 00:39
glitches777 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2788 | @revisualize |http://www.freecodecamp.com/revisualize
aaldea
@aaldea
Jan 01 2017 00:46
Why would I get a console is undefined error?
Walid Ashri
@walidashri
Jan 01 2017 00:48
@aaldea check for typos
aaldea
@aaldea
Jan 01 2017 00:53
@walidashri I tried that. I am trying to actually get it to print to the command window and I am getting 'console' is undefined.
Ian Lee
@asparism
Jan 01 2017 00:53
any idea why this codeine doesn't trigger any of the javascript click events? https://codepen.io/Asparism/pen/ygBORr
aaldea
@aaldea
Jan 01 2017 00:53
var x = 3;

function numSquare(x) {
    return x * x;
}

var sentence = "The square of " + x + "is equal to " + numSquare(x) ;
console.log(sentence);
Walid Ashri
@walidashri
Jan 01 2017 00:56
@asparism u need to wrap all withe document.ready funcion
Ian Lee
@asparism
Jan 01 2017 00:58
@walidashri even then it doesn't work, and i have other pens that work without the wrap
but codepen isn't even working on my end so i'm not sure if it's something other than my code
aaldea
@aaldea
Jan 01 2017 01:02
I got it to work by installing node.
THanks @walidashri
CamperBot
@camperbot
Jan 01 2017 01:02
aaldea sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 823 | @walidashri |http://www.freecodecamp.com/walidashri
mitron6
@mitron6
Jan 01 2017 01:08
@asparism Codepen isn't responding for me at the moment either.
Melissa Guerrero
@Mmgfrog
Jan 01 2017 01:14
Hello! On the Caesar's Cipher algorithm exercise, the hints involve charCodeAt() and fromCharCode(). I feel like I missed something - why are we converting to ASCII or Unicode characters? I understand that's not the only way to solve it but if it's easier, why?
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:18
because caesars cipher is just making the letter into the 13 letter along
and thats easier to do when your using the charcode
cus you just have to add 13 the the first half of the alphabet or take 13 away to the second half of the alphabet
but if you want to write a whole switch table for every letter of the alphabet i guess you can do that too
Walid Ashri
@walidashri
Jan 01 2017 01:21
@Mmgfrog charCodeAt() to get the letter code then add or sub 13 then turn it back to letter with fromCharCode()
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:21
but i think the exercise is probably set up for you maybe experiment with the character codes
Kelechi Chinaka
@ke1echi
Jan 01 2017 01:23
is there a way i can fixed an element at a specific index in an array
thats for the where do i belong test
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:25
why is that needed?
you want to sort the array but make sure one element always stays in the same place?
John P Penaloza
@johnpyp
Jan 01 2017 01:26

Hey guys, I'm working on the "Caesars Cipher" project in basic algorithms. Here is my code so far:


function rot13(str) { // LBH QVQ VG!
  newArray = [];
  for (i = 0; i < str.length; i++) {
    newArray.push(str.charCodeAt(i));
  }

  return String.fromCharCode(newArray[0]+13);
}

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

I'm stuck on how to loop to go from Z-unicode back to A-unicode and how to get all the unicodes into the parenthesis at .fromCharCode.

HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:28
dont get what you mean
but im not sure what youre doing is right
John P Penaloza
@johnpyp
Jan 01 2017 01:29
I'm not sure either.
The point of the project is to take a string (in rot13 caesars cipher) and move it 13 characters up. So A becomes
N etc.
Kelechi Chinaka
@ke1echi
Jan 01 2017 01:30
lol am a little confused on how to tackle the test @HeebieGeeBee
pls tel me how to go bout it @HeebieGeeBee
John P Penaloza
@johnpyp
Jan 01 2017 01:30
oh, @HeebieGeeBee I thought you were talking to me lol nevermind
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:30
i was @johnpyp
John P Penaloza
@johnpyp
Jan 01 2017 01:30
oh
Scott
@zenwattage
Jan 01 2017 01:30
How do you post an image of your code like that?
John P Penaloza
@johnpyp
Jan 01 2017 01:30
I thought you were talking to kelech
haha
@zenwattage use this symbol " ` " 3x before and after your code
mitron6
@mitron6
Jan 01 2017 01:31
@johnpyp how about the using something like a mod 26?
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:32
@kelechichinaka well the first thing is to sort your array properly
Kelechi Chinaka
@ke1echi
Jan 01 2017 01:32
use ``` @johnpyp
darkflikk
@darkflikk
Jan 01 2017 01:32
@johnpyp you still need help?
John P Penaloza
@johnpyp
Jan 01 2017 01:32
@darkflikk yes
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:32
and make sure you get an array thats in the right order to start with
Kelechi Chinaka
@ke1echi
Jan 01 2017 01:32
i hvae sorted it properly @HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:33
then you just need to go through and fin out what index number the new number should be inserted
how do you think you would do that?
darkflikk
@darkflikk
Jan 01 2017 01:33
@johnpyp there are 2 ways of doing that
John P Penaloza
@johnpyp
Jan 01 2017 01:33
@mitron6 Well, the project suggests using unicode to turn the letters into numerics to add 13.
darkflikk
@darkflikk
Jan 01 2017 01:33
@johnpyp most are simply using an if / else
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:33
not just add 13
Kelechi Chinaka
@ke1echi
Jan 01 2017 01:33
loop @HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:34
sounds good @kelechichinaka
John P Penaloza
@johnpyp
Jan 01 2017 01:34
@darkflikk what is the other way?
darkflikk
@darkflikk
Jan 01 2017 01:34
@johnpyp the other way would be to use modulo
mitron6
@mitron6
Jan 01 2017 01:34
@johnpyp Yes but how do you add 13 to a z? You don't get the right answer.
Scott
@zenwattage
Jan 01 2017 01:34
function testLogicalAnd(val) {
  // Only change code below this line

  if (val <= 50 && val >= 25) {
    return "Yes";
  }
}
// Only change code above this line
  return "No";
}
// Change this value to test
testLogicalAnd(51);
I'm getting a, "Syntax Error: Illegal Return Statement" message... I can't figure out why?
John P Penaloza
@johnpyp
Jan 01 2017 01:35
@mitron6 right, which is the problem.
Scott
@zenwattage
Jan 01 2017 01:35
@johnpyp Thanks!
CamperBot
@camperbot
Jan 01 2017 01:35
zenwattage sends brownie points to @johnpyp :sparkles: :thumbsup: :sparkles:
:cookie: 256 | @johnpyp |http://www.freecodecamp.com/johnpyp
mitron6
@mitron6
Jan 01 2017 01:35
@johnpyp mod is a clue.
John P Penaloza
@johnpyp
Jan 01 2017 01:35
@mitron6 So I guess I could use modulo
How do you think I could go about that?
mitron6
@mitron6
Jan 01 2017 01:35
@johnpyp Maybe. Try.
John P Penaloza
@johnpyp
Jan 01 2017 01:35
Alright
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:35
you have too many } for staters @zenwattage
John P Penaloza
@johnpyp
Jan 01 2017 01:35
I haven't used modulo in code so far, but I'll try
mitron6
@mitron6
Jan 01 2017 01:36
@zenwattage You have a return statement outside of a function.
Scott
@zenwattage
Jan 01 2017 01:36
omg...Thanks @HeebieGeeBee
that was it
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:37
@johnpyp did you read the page about caesars cipher?
well ROT13
John P Penaloza
@johnpyp
Jan 01 2017 01:37
@HeebieGeeBee oh, no I didn't. I probably should haha
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:38
probably
Melissa Guerrero
@Mmgfrog
Jan 01 2017 01:40
Thank you @HeebieGeeBee and @walidashri
CamperBot
@camperbot
Jan 01 2017 01:40
mmgfrog sends brownie points to @heebiegeebee and @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 410 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:cookie: 824 | @walidashri |http://www.freecodecamp.com/walidashri
John P Penaloza
@johnpyp
Jan 01 2017 01:40
@HeebieGeeBee oh wait. Could I use mod 52?
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:41
no idea what that is
John P Penaloza
@johnpyp
Jan 01 2017 01:41
I'm not sure
But use 52 corresponding numbers
to 2 sets of the alphabet
So that if I added 13 to say Z, it wouldn't have to loop, just add 13.
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:42
did you read how rot13 works?
im not sure what all this mod stuff is
best speak to mitron about it
John P Penaloza
@johnpyp
Jan 01 2017 01:44
Well, I was thinking based on the input table in the Rot13 page that I could use an object with 1-52 corresponding to 2 sets of the alphabet.
0-52*
so, I guess 0-51
Palmer
@nickpalmer789
Jan 01 2017 01:44
I'm having trouble getting the elements on the page by querySelector. Each time that I try it is returning null. Any ideas? I'm really stuck
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:45
all the letters in caesars cipher are going to be upper case
if you have 26 letters in the alphabet and the code is just the letter thats 13 letters a long
it means for the first half of the alphabet you only have to add 13 but for the second half of the alphabet you can just take 13 away
John P Penaloza
@johnpyp
Jan 01 2017 01:46
oh
You're right
Alright
I think I understand what o do
@HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:47
cool
Palmer
@nickpalmer789
Jan 01 2017 01:47
Here is the pen that I am using for my project: http://codepen.io/nickpalmer789/pen/mRbJXw?editors=1010
John P Penaloza
@johnpyp
Jan 01 2017 01:48

function rot13(str) { // LBH QVQ VG!
  newArray = [];
  for (i = 0; i < str.length; i++) {
    newArray.push(str.charCodeAt(i));
  }

  return String.fromCharCode(newArray[0]+13);
}


// Change the inputs below to test
rot13("SERR PBQR PNZC");
Palmer
@nickpalmer789
Jan 01 2017 01:48
I think that the problem is on line 60 of the js
but I'm not sure
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:48
thats just going to return one letter isnt it? @johnpyp
John P Penaloza
@johnpyp
Jan 01 2017 01:48
Right
but that was just a test
So from here, I should iterate through each element of newArray and either add/subtract 13 from each. Then I have an array with the corresponding unicode. to each letter
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:50
sounds good
John P Penaloza
@johnpyp
Jan 01 2017 01:50
How would I convert that back with fromCharCode?
darkflikk
@darkflikk
Jan 01 2017 01:50
that's the if/else solution
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 01:50
remember you have symbols too
whats this mod stuff @darkflikk
darkflikk
@darkflikk
Jan 01 2017 01:51
I used (char - A + shift) % 26 + A
var A = "A".charCodeAt(0);
var shift = 13;
So i convert the letters into a numbers between 0-25
then i add 13
then i use modulo for the "rotation" in case the new value is >25
So i could change the rotation from 13 to whatever i wanted and it'd still work
mitron6
@mitron6
Jan 01 2017 01:54
@johnpyp Exactly. % 26 can be used to handle tying to add 13 to the character code for Z for exmaple.
@johnpyp You can also just use conditionals.
Kelechi Chinaka
@ke1echi
Jan 01 2017 01:55
pls who know a simpler logic to solve where do i belong test
darkflikk
@darkflikk
Jan 01 2017 01:55
Z - A = 25
25 + 13 = 38
38 % 26 = 12
John P Penaloza
@johnpyp
Jan 01 2017 01:56
huh
How do you simply assign all of the values of Z-A to numbers?
darkflikk
@darkflikk
Jan 01 2017 01:56
then add A again (65)
12 + 65 = 77
and 77 is M
     if( (/[A-Z]/g).test(str.charAt(i)) ){
       var char = str.charCodeAt(i);
       fullStr += String.fromCharCode((char - A + shift) % 26 + A);
     }
like that
using .replace would work even better
mitron6
@mitron6
Jan 01 2017 02:00
@darkflikk FYI, the solution that uses % 26 is in the "advanced solution" in the Free Code Camp GitHub project.
darkflikk
@darkflikk
Jan 01 2017 02:00
it is
?
i never checked the GitHub
mitron6
@mitron6
Jan 01 2017 02:00
@darkflikk It is great to use it but it is a little harder to understand for a beginner.
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:02
@darkflikk how does that account for non alphabet numbers?
darkflikk
@darkflikk
Jan 01 2017 02:03
it's very old code. would do it different now
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:04
dont understand how you would get the symbols back
darkflikk
@darkflikk
Jan 01 2017 02:05
function rot13(encodedStr) {
  var A = "A".charCodeAt(0);
  var shift = 13;

  return encodedStr.replace(/[a-z]/gi,function(c){
     c = c.charCodeAt(0);
     return String.fromCharCode((c - A + shift) % 26 + A);
  });
}
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:05
oh ok
darkflikk
@darkflikk
Jan 01 2017 02:06
i just leave them there ;)
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:06
yeah
very nice
darkflikk
@darkflikk
Jan 01 2017 02:06
otherwise you'd do something like
     if( (/[A-Z]/g).test(str.charAt(i)) ){
       var char = str.charCodeAt(i);
       fullStr += String.fromCharCode((char - A + shift) % 26 + A);
     } else {
       fullStr += str.charAt(i);
     }
HackAttack67
@HackAttack67
Jan 01 2017 02:06
Hello I am stuck on WordBlanks
darkflikk
@darkflikk
Jan 01 2017 02:07
@johnpyp ?
did you just delete your code?
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:07
lol i was just wondering that
John P Penaloza
@johnpyp
Jan 01 2017 02:07

@HeebieGeeBee what am I doing wrong:


function rot13(str) { // LBH QVQ VG!
  var arr = [];
  var newArray = [];
  for (i = 0; i < str.length; i++) {
    newArray.push(str.charCodeAt(i));
  }
  for (i = 0; i < newArray.length; i++) {
    if (newArray[i] > 78) {
      newArray[i] = newArray[i] - 13;

    } else if (newArray[i] < 79 ) {
      newArray[i] = newArray[i] + 13;
    }
    arr.push(String.fromCharCode(newArray[i]));
  }
  return arr.join("");
}


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

This outputs: FREE-CODE-C[MP

Ya, I did haha
tried to edit it and accidentally pressed delete
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:08
what are you doing about the symbols?
darkflikk
@darkflikk
Jan 01 2017 02:08
you'd need to check if it's a letter or not
@johnpyp currently you rotate everything (the spaces included)
space = 32
John P Penaloza
@johnpyp
Jan 01 2017 02:09
right
alright
darkflikk
@darkflikk
Jan 01 2017 02:09
32 + 13 = 45
and 45 is - in the ascii table
ibrahem yassin
@demestic
Jan 01 2017 02:10
hello everyone...i need some help with javascript
the name of the lesson is stand in line
John P Penaloza
@johnpyp
Jan 01 2017 02:10
How did the n turn into [? @darkflikk
Shouldn't it had been A?
darkflikk
@darkflikk
Jan 01 2017 02:10
let's see
ibrahem yassin
@demestic
Jan 01 2017 02:11

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

return testArr[0]; // 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));

HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:11
maybe cus its not 78 and 79
try 77 and 78
John P Penaloza
@johnpyp
Jan 01 2017 02:11
oh
right
darkflikk
@darkflikk
Jan 01 2017 02:12
78+13= 91
ibrahem yassin
@demestic
Jan 01 2017 02:12
when you guys are done help me please
darkflikk
@darkflikk
Jan 01 2017 02:12
and 91 is [
@demestic whatt's the issue?
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:12
and make it <= and >=
ibrahem yassin
@demestic
Jan 01 2017 02:12

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

nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
John P Penaloza
@johnpyp
Jan 01 2017 02:13
How should I filter out alphanumerics then add them back in?
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:13
you dont have to
darkflikk
@darkflikk
Jan 01 2017 02:13
@demestic so, have you tried anything? or put any thought into it?
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:13
you just need to not do anything to those
John P Penaloza
@johnpyp
Jan 01 2017 02:13
sorry, filter out non-alpha
Kelechi Chinaka
@ke1echi
Jan 01 2017 02:14
use the push() to add an element to the end of an array and shift() to remove the first element and return it @demestic
ibrahem yassin
@demestic
Jan 01 2017 02:14
nope
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:14
so figure out how to make your if statements ignore them
ibrahem yassin
@demestic
Jan 01 2017 02:14
so i should change what and put push()
return item; // Change this line<----i should change this line only
John P Penaloza
@johnpyp
Jan 01 2017 02:15
@darkflikk what should I be looking at from there?
Kelechi Chinaka
@ke1echi
Jan 01 2017 02:16
show code @demestic
darkflikk
@darkflikk
Jan 01 2017 02:17

@johnpyp there are 2 options

if (c > ? && c < ?) {}
if (c > ? && c < ?) {}

or

if (c is a character) {
  if (c >? ) {}
  if (c < ?) {}
}
the link wasnt meant for you ^^ @johnpyp
John P Penaloza
@johnpyp
Jan 01 2017 02:17
oh
ibrahem yassin
@demestic
Jan 01 2017 02:18
thanks alot i needed that
John P Penaloza
@johnpyp
Jan 01 2017 02:18
how do I test is alphabetical without a bunch of ||
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:18
alphabet code only runs from 65 to 90
or summin like that
check it
for uppercase that is
darkflikk
@darkflikk
Jan 01 2017 02:18
@johnpyp or with a regular expression
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:19
but regex is the spawn of satan
so you choose
John P Penaloza
@johnpyp
Jan 01 2017 02:19
could I check between 65 - 90?
darkflikk
@darkflikk
Jan 01 2017 02:19
it's not :D
if( (/[A-Z]/g).test(str.newArray(i)) )
John P Penaloza
@johnpyp
Jan 01 2017 02:20
I hate regex
so I would definitely rather not use it haha
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:20
you could say it is less than 77 or more than 65 maybe
darkflikk
@darkflikk
Jan 01 2017 02:20
@johnpyp that's really easy regex
it doesnt even have look aheads
John P Penaloza
@johnpyp
Jan 01 2017 02:20
It doesn't make any sense to me
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:20
=
John P Penaloza
@johnpyp
Jan 01 2017 02:20
@HeebieGeeBee ya that is good
darkflikk
@darkflikk
Jan 01 2017 02:20
^(?=(?!(.)\1)([^\DO:105-93+30])(?-1)(?<!\d(?<=(?![5-90-3])\d))).[^\WHY?]$
tommy
@tommygebru
Jan 01 2017 02:21
LOL i got to use regex right now for a challenge ringing in the new year with freecodecamp
darkflikk
@darkflikk
Jan 01 2017 02:21
who can solve that regex? get :100: points
John P Penaloza
@johnpyp
Jan 01 2017 02:22
I'll put an if statement like `if (newArray[i] >= 65 && newArray[i] <= 90)
ibrahem yassin
@demestic
Jan 01 2017 02:22
The nextInLine function should then return the element that was removed<---how the hek to return the the number that was removed
darkflikk
@darkflikk
Jan 01 2017 02:22
@johnpyp but ... regex ...
ibrahem yassin
@demestic
Jan 01 2017 02:22
i fail everytime i use push or pull
John P Penaloza
@johnpyp
Jan 01 2017 02:22
@darkflikk it just doesn't make sense D:
ibrahem yassin
@demestic
Jan 01 2017 02:22
pop*
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:22
i could copy and paste into regex solver
John P Penaloza
@johnpyp
Jan 01 2017 02:22
Is it a good idea to learn it? Is it used a lot
darkflikk
@darkflikk
Jan 01 2017 02:23
because it's those are not the functions to use
@johnpyp you definately should learn it
John P Penaloza
@johnpyp
Jan 01 2017 02:23
damn
So far, whenever I've had to use regex I just look up and copy&paste. I have no idea what it means except that it excludes alphanumeric for example
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:24
you will need to use it
darkflikk
@darkflikk
Jan 01 2017 02:24
regex is great
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:24
doesnt mean its not evil
John P Penaloza
@johnpyp
Jan 01 2017 02:26
Wait, so how would I apply regex in this case?
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:26
after seeing a regex expression that starts with like (((((((((((((((
Greg Duncan
@GregatGit
Jan 01 2017 02:26
@johnpyp if (newArray[i] >= 65 && newArray[i] <= 90) better to say if (newArray[i] > 64 && newArray[i] < 91)
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:26
why is that better?
John P Penaloza
@johnpyp
Jan 01 2017 02:27
    if (regex here) {
      if (newArray[i] >= 77) {
        newArray[i] = newArray[i] - 13;

      } else if (newArray[i] <= 79 ) {
        newArray[i] = newArray[i] + 13;
      }
    }
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:27
cus less its less code?
tommy
@tommygebru
Jan 01 2017 02:27
hey people its been many weeks since i did a challenge can anyone verify that this is not working or tell me what my code was doing???
https://repl.it/E66t/5
John P Penaloza
@johnpyp
Jan 01 2017 02:27
What would I put in that regex
darkflikk
@darkflikk
Jan 01 2017 02:27
nevermind
since you allready converted them to numbers
John P Penaloza
@johnpyp
Jan 01 2017 02:27
right
darkflikk
@darkflikk
Jan 01 2017 02:28
@johnpyp but
John P Penaloza
@johnpyp
Jan 01 2017 02:28
Ya, I'll just use the first method
Greg Duncan
@GregatGit
Jan 01 2017 02:28
yeah and in js always use >== instead of >= unless you have a good reason
darkflikk
@darkflikk
Jan 01 2017 02:28
you could still use a regex :D
John P Penaloza
@johnpyp
Jan 01 2017 02:28
How would I do it if they were letters?
And could explain what it means?
darkflikk
@darkflikk
Jan 01 2017 02:29
@johnpyp you'd simply do if( (/[A-Z]/g).test("c") )
John P Penaloza
@johnpyp
Jan 01 2017 02:29
what does the /g mean? Also, what does the .test do?
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:29
@tommygebru replit isnt loading for me
John P Penaloza
@johnpyp
Jan 01 2017 02:30
is the c just the string it is testing?
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:30
global
darkflikk
@darkflikk
Jan 01 2017 02:30
@johnpyp .test just checks if the regex has any matches
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:30
means it will test the whole string
John P Penaloza
@johnpyp
Jan 01 2017 02:30
oh alright
if it does it returns true?
tommy
@tommygebru
Jan 01 2017 02:30
so its like failing code or is it replit @HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:30
the page isnt loading
John P Penaloza
@johnpyp
Jan 01 2017 02:31
So say I did /A-Z, 0-9/ instead, would that be alphanumeric?
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:31
no ,
and in []
and woul only do upper case letters
darkflikk
@darkflikk
Jan 01 2017 02:32
@johnpyp would need to be [A-Za-z0-9]
John P Penaloza
@johnpyp
Jan 01 2017 02:32
oh
ok
How would you do it for symbols?
darkflikk
@darkflikk
Jan 01 2017 02:32
but with the / / to make it a regex
@johnpyp what you mean with symbols?
tommy
@tommygebru
Jan 01 2017 02:32
nvm thanks @HeebieGeeBee http://downornotrightnow.com/repl.it
CamperBot
@camperbot
Jan 01 2017 02:32
tommygebru sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 411 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
John P Penaloza
@johnpyp
Jan 01 2017 02:32
so say I wanted to include !@#$%^&*() etc.
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:33
youd include what symbols you wanted
ibrahem yassin
@demestic
Jan 01 2017 02:33
HELP

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

return testArr.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));

John P Penaloza
@johnpyp
Jan 01 2017 02:33
Would !-) do anything?
darkflikk
@darkflikk
Jan 01 2017 02:33
you could use /\W/ for non word characters
ibrahem yassin
@demestic
Jan 01 2017 02:33
nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
thats what should be done...first two steps are done
cant do the rest
John P Penaloza
@johnpyp
Jan 01 2017 02:34
huh
ibrahem yassin
@demestic
Jan 01 2017 02:34
sry guys :D
John P Penaloza
@johnpyp
Jan 01 2017 02:34
Alright, that is enough regex for the day. Thanks @darkflikk and @HeebieGeeBee ! I really appreciate your help
CamperBot
@camperbot
Jan 01 2017 02:34
:cookie: 412 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
johnpyp sends brownie points to @darkflikk and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 233 | @darkflikk |http://www.freecodecamp.com/darkflikk
darkflikk
@darkflikk
Jan 01 2017 02:34
ibrahem yassin
@demestic
Jan 01 2017 02:35
help me with this code guys
CamperBot
@camperbot
Jan 01 2017 02:35
no wiki entry for: me with this code guys
ibrahem yassin
@demestic
Jan 01 2017 02:35
:S
darkflikk
@darkflikk
Jan 01 2017 02:36
@demestic what have you tried yourself
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:37
@demestic you need to push the item into the array
darkflikk
@darkflikk
Jan 01 2017 02:37
@demestic take a good read.
ibrahem yassin
@demestic
Jan 01 2017 02:38
changed this ..return item // Change this lin ..into this ...return testArr.shift(); // Change this lin
and done two steps
1,2,3,4,5 this should return 1 when i add a number and i did it now he wants me to make it return 5 when its 5,6,7,8,9
dunno what to do shall i change 12345 into 56789 to pass this test? actually i did and it didnt work :)
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:40
you havent pushed the item into the array
ibrahem yassin
@demestic
Jan 01 2017 02:41
The nextInLine function should then return the element that was removed.
worked and returned 1 when it was 123456
no idea what to do next...now i know what method to use which is shift...now he wants me to do the same when its 56789(return 5) but i dunno what to do...dunno which part of the code to change
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:43
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 @demestic read this have you done everything it says?
read it carefully
ibrahem yassin
@demestic
Jan 01 2017 02:44
the function is done by dem already
shall i write a new one? O:
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:45
Add the number to the end of the array, @demestic have you done this???
and a number (item) as arguments
ibrahem yassin
@demestic
Jan 01 2017 02:46
didnt add anything just used shift to remove the last number
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:46
then you probably should add the item t the array huh
ibrahem yassin
@demestic
Jan 01 2017 02:48
@HeebieGeeBee are you on the same page now?
i mean can you see the test
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:49
i cant see yours
but i know what the test wants
wants one little line of code that yu havent given it
ibrahem yassin
@demestic
Jan 01 2017 02:50
i did add the number now its 123456 instead of 12345...now i must remove the last number usin shift i guess
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:50
no
how did you add the number?
ibrahem yassin
@demestic
Jan 01 2017 02:51
return testArr.push(6); // Change this line
Michael Grant Warshowksy
@step48765
Jan 01 2017 02:51
Sup dudes
Hugo Ochoa
@Hugo8a8a
Jan 01 2017 02:51
Hey guys :smile: ... a little help?
Instructions
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
ibrahem yassin
@demestic
Jan 01 2017 02:51
sup bro
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:51
its not 6
Michael Grant Warshowksy
@step48765
Jan 01 2017 02:51
@Hugo8a8a you need help??
Hugo Ochoa
@Hugo8a8a
Jan 01 2017 02:51
Pleasee!!
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:51
it wants you to add its item
ibrahem yassin
@demestic
Jan 01 2017 02:52
not 6?
l177l3-br07h3r
@l177l3-br07h3r
Jan 01 2017 02:52
so i am building a random quote machine and i sort of grasp the concept of the JSON. I am at the point where i need to get some JSON data to generate a random quote. where exactly do I get that data from? In the FreeCodeCamp example, they just used some locally stored files
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:52
yes the parameter
Michael Grant Warshowksy
@step48765
Jan 01 2017 02:52
@Hugo8a8a dude what do u need help with im here
ibrahem yassin
@demestic
Jan 01 2017 02:53
HOW
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:53
search quote api @l177l3-br07h3r theres a few sites
l177l3-br07h3r
@l177l3-br07h3r
Jan 01 2017 02:53
thanks @HeebieGeeBee
CamperBot
@camperbot
Jan 01 2017 02:53
l177l3-br07h3r sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 413 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:53
@demestic

function nextInLine(arr, item) {
  arr.push(item);

  return arr.shift();  // Change this line
}
ibrahem yassin
@demestic
Jan 01 2017 02:54
return item; // Change this line <---thats how the code looked at first
item is a number right?
Michael Grant Warshowksy
@step48765
Jan 01 2017 02:54
@HeebieGeeBee alrightalk to you later
Hugo Ochoa
@Hugo8a8a
Jan 01 2017 02:54
@step48765 .. yes, a little stuck no this
Instructions
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
with this I meant
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:55
@step48765 did i miss something
@Hugo8a8a do you know what a reainder is in division?
ibrahem yassin
@demestic
Jan 01 2017 02:56
@HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:57
@demestic i ust gave you the solution
ibrahem yassin
@demestic
Jan 01 2017 02:57
ik and i want to give you some points but i couldnt do it
Hugo Ochoa
@Hugo8a8a
Jan 01 2017 02:57
@HeebieGeeBee .. Yep, just missing some info here

// Only change code below this line

var remainder = 2;

ibrahem yassin
@demestic
Jan 01 2017 02:58
so how to do it XD
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 02:58
so % is the operator used to find the remainder of something
dont worry @demestic
so instead of 11/3 = 3 with remainder of 2 you can just say 11%3 = 2
Hugo Ochoa
@Hugo8a8a
Jan 01 2017 03:00
@HeebieGeeBee .. I need a checkmark on these three, can't get the last one
The variable remainder should be initialized
The value of remainder should be 2
You should use the % operator
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 03:01
did you read my last comment and understand what i meant @Hugo8a8a ?
Hugo Ochoa
@Hugo8a8a
Jan 01 2017 03:04
@HeebieGeeBee ... indeed, I keep on doing that but for some reason it keeps on saying something is wrong
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 03:04
remainder = 11%3
Hugo Ochoa
@Hugo8a8a
Jan 01 2017 03:05
@HeebieGeeBee ... OMG! .. thank's brother .. haha .. finally
CamperBot
@camperbot
Jan 01 2017 03:05
hugo8a8a sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 414 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 03:06
np
HeebieGeeBee
@HeebieGeeBee
Jan 01 2017 03:12
https://www.youtube.com/watch?v=VIEwBm7PWQM pretty cool video for those interested in indie game dev
Menadk
@Menadk
Jan 01 2017 03:39
I'm lost on this one.... Can anyone help me here?
JMNofziger
@JMNofziger
Jan 01 2017 03:46
look at my shitty solution for the "Title Case a Sentence" problem

function titleCase(str) {

  // clean up the input by making everything lower case (use toLowerCase method)
  var cleanStr = str.toLowerCase();

  // split input string into groups by spaces 
  var newArray = cleanStr.split(' ');

  // cycle through each word 
  for(var i = 0; i < newArray.length; i++) {

    // split the word into individual characters
    var secondArray = newArray[i].split('');

    // while the index is on the first character, capitalize
    for(var x = 0; x < 1; x++){
      secondArray[x] = secondArray[x].toUpperCase();
    }
    // join all the characters of the word groups
    newArray[i] = secondArray.join('');

  }
  // concatenate all the groups together again (separated by spaces)
  var finalStr = newArray.join(' ');

  // testing
  console.log(finalStr);

  // return the concatenated string
  return finalStr;
}

titleCase("I'm a little tea pot");
it's ugly but it works
:worried: I want to be a more refined man :cry:
Greg Duncan
@GregatGit
Jan 01 2017 03:49
@leatheronly you don't need to keep creating new variables str = str.toLowerCase() works
Holden Hartsoe
@hartsoeha
Jan 01 2017 03:49
hi folks, I'm having an issue understanding a concept I think? I'm on the challenge "Return Early Pattern for Functions" and I don't understand how to to make a function return a value of undefined for a variable?
JMNofziger
@JMNofziger
Jan 01 2017 03:55
Thanks @GregatGit , I often do that early in working through a problem as a means of separating the problem into steps; it's a dumb habit that continues even after I have a better grasp on the issue
CamperBot
@camperbot
Jan 01 2017 03:55
leatheronly sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 808 | @gregatgit |http://www.freecodecamp.com/gregatgit
darkflikk
@darkflikk
Jan 01 2017 03:56
@leatheronly a long way to go you have
@leatheronly check the array methods ;)
@leatheronly
function titleCase(str) {
  return str.replace(/(\S)(\S*)/g,(a,b,c)=>b.toUpperCase()+c.toLowerCase());
}
~.^
Walid Ashri
@walidashri
Jan 01 2017 04:01
@hartsoeha u need to check the var value if it's not meet with the criteria return undefined
darkflikk
@darkflikk
Jan 01 2017 04:03
@leatheronly if you want to use loops, you shouldnt use more then 1 for this challenge
Holden Hartsoe
@hartsoeha
Jan 01 2017 04:06
@walidashri I don't quite understand
"Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined."
Those are the instructions
Cheru
@cherukss
Jan 01 2017 04:11
Need help with Falsy Bouncer from Basic Algorithm Scripting.
here is my code

function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr.filter(function(curr){
switch(curr){
case false:
case null:
case 0:
case "":
case undefined:
case NaN:
return false;
default:
return true;
}
});

}

bouncer([1, null, NaN, 2, undefined]);

function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr.filter(function(curr) {
switch (curr) {
case false:
case null:
case 0:
case "":
case undefined:
case NaN:
return false;
default:
return true;
}
});
}
bouncer([1, null, NaN, 2, undefined]);

`function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr.filter(function(curr) {
switch (curr) {
case false:
case null:
case 0:
case "":
case undefined:
case NaN:
return false;
default:
return true;
}
});

}

bouncer([1, null, NaN, 2, undefined]);'

lh15
@lh15
Jan 01 2017 04:18

function mutation(arr) {
  var check;
  var arr1;
  arr1 = arr[1].split('');
  for (var i = 0; i < arr1.length; i++)
  check = arr[0].indexOf(arr1[i]);
  if (check !== -1){
     return true;
  } else{
    return false;
  }


}

mutation(["hello", "Hello"]);
need some help with mutation. Right direction?
Menadk
@Menadk
Jan 01 2017 04:21
I'm lost on this one.... Can anyone help me here?
Cheru
@cherukss
Jan 01 2017 04:24

@lh15 function mutation(arr) {
arr[0] = arr[0].toLowerCase();
arr[1] = arr[1].toLowerCase();

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

mutation(["hello", "hey"]);

lh15
@lh15
Jan 01 2017 04:26
@cherukss thanks but that is a very destructive way to help
CamperBot
@camperbot
Jan 01 2017 04:26
lh15 sends brownie points to @cherukss :sparkles: :thumbsup: :sparkles:
:cookie: 273 | @cherukss |http://www.freecodecamp.com/cherukss
Ian
@toianw
Jan 01 2017 04:28
@cherukss NaN is not equal to itself
Holden Hartsoe
@hartsoeha
Jan 01 2017 04:30
haii, anyone have a free moment to help me out? I'm stuck
@Menadk String concatenation with variables parameters
Manu Arora
@manuarora
Jan 01 2017 04:36
@Menadk It's quite simple, use the mentioned 4 nouns/names and form a string with it.
For example,
l177l3-br07h3r
@l177l3-br07h3r
Jan 01 2017 04:38
i am still building this random quote machine and it seems as each time i press my "generate random quote" button, the same json object comes back from my selected API. any thoughts?
Manu Arora
@manuarora
Jan 01 2017 04:40

result = "My" + " " +myNoun + " " is + " " + myAdjective + "and he" + " " + myVerb + " " + "very" + myAdverb;

code looks something like this, Take care of spaces @Menadk

heroiczero
@heroiczero
Jan 01 2017 04:40
@l177l3-br07h3r make sure you are retrieving a new quote every time you click a button
watergs
@watergs
Jan 01 2017 05:00
Why is this line not working?
if(contacts[i].hasOwnProperty(firstName)==1)
heroiczero
@heroiczero
Jan 01 2017 05:01
@watergs hasOwnProperty returns true or false
JMNofziger
@JMNofziger
Jan 01 2017 05:01
Happy new year!
watergs
@watergs
Jan 01 2017 05:01
but true is 1, right?
heroiczero
@heroiczero
Jan 01 2017 05:02
@watergs 1 is a number true is a boolean
watergs
@watergs
Jan 01 2017 05:02
Ah ok, @heroiczero thank you
CamperBot
@camperbot
Jan 01 2017 05:02
watergs sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:cookie: 604 | @heroiczero |http://www.freecodecamp.com/heroiczero
watergs
@watergs
Jan 01 2017 05:03
It's still not working @heroiczero
heroiczero
@heroiczero
Jan 01 2017 05:03
@watergs lets see your whole code
SDJay
@Sdjaynewb
Jan 01 2017 05:04
Hey all. I'm still stumped by the WordBlanks exercise. I grasp the idea of Madlibs and my writing a string that results in an actual sentence. I'm just not understanding how to make that happen in the lesson.
watergs
@watergs
Jan 01 2017 05:04
https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20%20for(i%3D0%3Bi%3Ccontacts.length%3Bi%2B%2B)%7B%0Aif(contacts%5Bi%5D.hasOwnProperty(firstName)%3D%3Dtrue)%7B%0A%20var%20prop1%3Dcontacts%5Bi%5D.likes%3B%0A%20%20%20%20console.log(prop1)%3B%0A%20%20return%20prop1%3B%0A%20%7D%0A%20%20%20%20return%20prop1%3B%0A%20%20%7D%0A%20%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Akira%22%2C%20%22likes%22)%3B%0A
heroiczero
@heroiczero
Jan 01 2017 05:04
@Sdjaynewb lets see your code
watergs
@watergs
Jan 01 2017 05:05
@heroiczero i put the console.log just for my visibility
JMNofziger
@JMNofziger
Jan 01 2017 05:06
ooooo! nice @darkflikk ! I do have a long way to go.
watergs
@watergs
Jan 01 2017 05:07
@heroiczero and also put likes where it was supposed to be prop just to test one case
JMNofziger
@JMNofziger
Jan 01 2017 05:07
thanks @darkflikk
CamperBot
@camperbot
Jan 01 2017 05:07
leatheronly sends brownie points to @darkflikk :sparkles: :thumbsup: :sparkles:
:cookie: 234 | @darkflikk |http://www.freecodecamp.com/darkflikk
heroiczero
@heroiczero
Jan 01 2017 05:09
@watergs hasOwnProperty is a method that check if it has a property. what you want to do is loop though each one and find if the firstName of contacts[i] is equal to firstName variable
watergs
@watergs
Jan 01 2017 05:11
but first I would need to check whether contacts has a property named firstName
right?
ok ,never mind , i get what you are saying
but hasOwnProperty should work too?
Manu Arora
@manuarora
Jan 01 2017 05:13
@Sdjaynewb Let's see your code
watergs
@watergs
Jan 01 2017 05:14
@heroiczero I can't set if(contacts[i].firstName==firstName)
that's confusing for the compiler and me
it would be better to check property with hasOwnProperty?
Anthony Mitchell
@Drantho
Jan 01 2017 05:15
has anyone done Finders Keepers?
Timurtek
@Timurtek
Jan 01 2017 05:16
@watergs I am stuck in that challenge as well. now i am trying the hasOwnProperty
watergs
@watergs
Jan 01 2017 05:17
ok @Timurtek , good luck , in case you need to revise on hasOwnProperty, check Testing Objects for Properties
heroiczero
@heroiczero
Jan 01 2017 05:20
@watergs well it is just a suggestion on how to start or an idea of what to do. the critical thinking process is part of it :)
@watergs if(contacts[i].firstName==firstName) that is right but you have another error in your code check how to access Object notation with variables. Remember the prop in your parameters is treated as a variable
@Drantho what do u need help with?
watergs
@watergs
Jan 01 2017 05:27
woah it worked, @heroiczero thank you again
CamperBot
@camperbot
Jan 01 2017 05:27
watergs sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:warning: watergs already gave heroiczero points
heroiczero
@heroiczero
Jan 01 2017 05:27
@watergs :+1:
@Drantho you might be returning an array. Remember you have to return only the first element of the array
Tyre Brown
@trzl47
Jan 01 2017 05:36
hey all, having some issues with the Mutations challenge - cannot get this to satisfy all of othe test cases and not sure why. code below
function mutation(arr) {
  return arr[1].toLowerCase().split('').every(function(char) {
    return  arr[0].toLowerCase().indexOf(char < 0 ? false:true);
  });
}
Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 05:38

@SeifEddineSlimene
Is there a more contracted version

// jshint esversion: 6
function sumAll(arr) {
  var max = Math.max(...arr);
  var min = Math.min(...arr);
  arr = [];
  for (var i = min; i <= max; i++) {
    arr.push(i);
  }
  var sum = arr.reduce( (a, b) => a + b );
  return sum;
}

sumAll([1, 4]);

?

that is what i have so far
help
Ghulam Shabir
@ghulamshabir
Jan 01 2017 05:39
@trzl47 indexOf(char < 0 ? false:true) is not correct, you should close ) of indexOf to test for return value of it
Tyre Brown
@trzl47
Jan 01 2017 05:40
boom! thank you, @ghulamshabir
CamperBot
@camperbot
Jan 01 2017 05:40
:star2: 1553 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
trzl47 sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
Ghulam Shabir
@ghulamshabir
Jan 01 2017 05:40
@SeifEddineSlimene yes you can just get sum in the loop without pushing into array and using reduce
Anthony Mitchell
@Drantho
Jan 01 2017 05:40
@heroiczero thanks for the response but I got past my issue :)
CamperBot
@camperbot
Jan 01 2017 05:40
:cookie: 606 | @heroiczero |http://www.freecodecamp.com/heroiczero
drantho sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
Ghulam Shabir
@ghulamshabir
Jan 01 2017 05:41
@trzl47 :smile:
Kevin Chandra
@Kaence
Jan 01 2017 05:41
im stuck here
guys

function golfScore(par, strokes) {
// Only change code below this line

if (4,1){
return "Hole-in-one!";
}

else if (4,1){
return "Eagle";
}

else if (5,2){
return "Eagle";
}

else if (4,3){
return "Birdie";
}

else if (4,4){
return "Par";
}

else if (5,5){
return "Par";
}

else if (4,5){
return "Bogey";
}

else if (4,6){
return "Double Bogey";
}

else if (4,7){
return "Go Home!";
}

else if (5,9){
return "Go Home!";
}

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

// Change these values to test
golfScore(5, 4);

Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 05:41
@ghulamshabir in the exercice they gave me reduce function in order to use it (unless why they mention) :)
heroiczero
@heroiczero
Jan 01 2017 05:42
@Kaence your if statement dont seem conditional statements
Ghulam Shabir
@ghulamshabir
Jan 01 2017 05:42
@Kaence you are supposed to compare strokes with par and 1 in case of hole in one
Anthony Mitchell
@Drantho
Jan 01 2017 05:42
@Kaence, @ghulamshabir's advice is right
Kevin Chandra
@Kaence
Jan 01 2017 05:43
@heroiczero can you help me out
@ghulamshabir how do i do that
Ghulam Shabir
@ghulamshabir
Jan 01 2017 05:43
@SeifEddineSlimene there are many ways to do it, one of them is your own
siddhardha maguluri
@siddhardha04
Jan 01 2017 05:43
@Kaence hey you code only works for the cases you specified in if else statements
Anthony Mitchell
@Drantho
Jan 01 2017 05:44
@Kaence do something like var score = par - strokes
siddhardha maguluri
@siddhardha04
Jan 01 2017 05:44
@Kaence you have to compare the arguments par and strokes
Kevin Chandra
@Kaence
Jan 01 2017 05:44
@Drantho thanks!
CamperBot
@camperbot
Jan 01 2017 05:44
kaence sends brownie points to @drantho :sparkles: :thumbsup: :sparkles:
:cookie: 292 | @drantho |http://www.freecodecamp.com/drantho
Anthony Mitchell
@Drantho
Jan 01 2017 05:44
@Kaence then run score through birdie, par, bogey detection
heroiczero
@heroiczero
Jan 01 2017 05:45
@Kaence if(strokes===1) is a conditional statement
Anthony Mitchell
@Drantho
Jan 01 2017 05:45
@Kaence also if strokes == 1 you can skip all that and just return hole in one
Ghulam Shabir
@ghulamshabir
Jan 01 2017 05:46
@Kaence
if(strokes === 1) {
   return "Hole-in-one!";
} else if(...) {
...
}
heroiczero
@heroiczero
Jan 01 2017 05:46
@Kaence stokes<par-2 is also a conditional statement. now i think you can do the rest
Kevin Chandra
@Kaence
Jan 01 2017 05:46
@ghulamshabir thanks!
CamperBot
@camperbot
Jan 01 2017 05:46
kaence sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1554 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Kevin Chandra
@Kaence
Jan 01 2017 05:46
@heroiczero thanks!
CamperBot
@camperbot
Jan 01 2017 05:46
kaence sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:cookie: 607 | @heroiczero |http://www.freecodecamp.com/heroiczero
Ghulam Shabir
@ghulamshabir
Jan 01 2017 05:46
@Kaence :+1:
CamperBot
@camperbot
Jan 01 2017 05:49
no wiki entry for: pls httpswwwfreecodecampcomchallengesprofile-lookupsolution0a2f2fsetup0avar20contacts203d205b0a202020207b0a202020202020202022firstname223a2022akira222c0a202020202020202022lastname223a2022laine222c0a202020202020202022number223a20220543236543222c0a202020202020202022likes223a205b22pizza222c2022coding222c2022brownie20points225d0a202020207d2c0a202020207b0a202020202020202022firstname223a2022harry222c0a202020202020202022lastname223a2022potter222c0a202020202020202022number223a20220994372684222c0a202020202020202022likes223a205b22hogwarts222c2022magic222c2022hagrid225d0a202020207d2c0a202020207b0a202020202020202022firstname223a2022sherlock222c0a202020202020202022lastname223a2022holmes222c0a202020202020202022number223a20220487345643222c0a202020202020202022likes223a205b22intriguing20cases222c2022violin225d0a202020207d2c0a202020207b0a202020202020202022firstname223a2022kristian222c0a202020202020202022lastname223a2022vos222c0a202020202020202022number223a2022unknown222c0a202020202020202022likes223a205b22javascript222c2022gaming222c2022foxes225d0a202020207d0a5d3b0a0a0afunction20lookupprofilefirstname2c20prop7b0a2f2f20only20change20code20below20this20line0a2020var20result3b0a2020forvar20i203d200203b20i203c20contactslength3b20i2b2b7b0a202020200a20202020ifcontacts5bi5dfirstname203d3d20firstname7b0a2020202020200a202020202020ifcontacts5bi5dprop7b0a20202020202020200a2020202020202020result203d20contacts5bi5d5bprop5d3b0a20202020202020200a2020202020207delse7b0a20202020202020200a2020202020202020result203d2022no20such20property223b0a2020202020207d0a2020202020200a202020207delse7b0a2020202020200a20202020202020result203d2022no20such20contact223b0a202020207d0a202020200a20202020return20result3b0a2020202020200a20207d0a2f2f20only20change20code20above20this20line0a7d0a0a2f2f20change20these20values20to20test20your20function0alookupprofile22kristian222c2022lastname223b0a2f2flookupprofile22sherlock222c2022likes223b0a2f2flookupprofile22harry222c2022likes223b0a2f2flookupprofile22bob222c2022likes223b0a2f2flookupprofile22akira222c2022address223b0a0a
Timurtek
@Timurtek
Jan 01 2017 05:50
https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20%20var%20result%3B%0A%20%20for(var%20i%20%3D%200%20%3B%20i%20%3C%20contacts.length%3B%20i%2B%2B)%7B%0A%20%20%20%20%0A%20%20%20%20if(contacts%5Bi%5D.firstName%20%3D%3D%20firstName)%7B%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20if(contacts%5Bi%5D.prop)%7B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20result%20%3D%20contacts%5Bi%5D%5Bprop%5D%3B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%7Delse%7B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20result%20%3D%20%22No%20such%20property%22%3B%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%0A%20%20%20%20%7Delse%7B%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%20result%20%3D%20%22No%20such%20contact%22%3B%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20return%20result%3B%0A%20%20%20%20%20%20%0A%20%20%7D%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Kristian%22%2C%20%22lastName%22)%3B%0A%2F%2FlookUpProfile(%22Sherlock%22%2C%20%22likes%22)%3B%0A%2F%2FlookUpProfile(%22Harry%22%2C%20%22likes%22)%3B%0A%2F%2FlookUpProfile(%22Bob%22%2C%20%22likes%22)%3B%0A%2F%2FlookUpProfile(%22Akira%22%2C%20%22address%22)%3B%0A%0A
I am stuck on this for 1.4 hrs. any help?
Ghulam Shabir
@ghulamshabir
Jan 01 2017 05:54
@Timurtek contacts[i].prop should be contacts[i][prop] in if
SDJay
@Sdjaynewb
Jan 01 2017 05:56
I'm stumped on the Word Blanks exercise. I've searched the web and am not finding how to simply add whitespace in Javascript. Instead I keep seeing "find whitespace". Where can I learn more about simply adding whitespace between my string operators?
Timurtek
@Timurtek
Jan 01 2017 05:56
@ghulamshabir It still is not running for some reason. It doesnt even get true for the first name value, when loop runs for the first time: lookUpProfile("Kristian", "lastName");
Ghulam Shabir
@ghulamshabir
Jan 01 2017 05:59
@Timurtek because your return is inside loop it will stop it at first iteration
Timurtek
@Timurtek
Jan 01 2017 05:59
@ghulamshabir yass.. just saw that :D thank you.
CamperBot
@camperbot
Jan 01 2017 05:59
timurtek sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1555 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Jan 01 2017 06:00
@Sdjaynewb + " " + can be used for adding b/w words
Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 06:01
@ghulamshabir I know i know but here i just want to follow instructions as much as possible :D
SDJay
@Sdjaynewb
Jan 01 2017 06:01
Thanks @ghulamshabir ! Now where can I read about that or what's a better way to search that on the web?
CamperBot
@camperbot
Jan 01 2017 06:01
sdjaynewb sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1556 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Jan 01 2017 06:05
@Sdjaynewb I think there is no books for whitespaces :smile: but to learn javascript in you can do codecademy courses, they will teach you basics very quick and make y ou practice them. it's better than reading a book, a book can have unnecessarily details which you will forget in no time
abpndr1
@abpndr1
Jan 01 2017 06:32
friends how can I use array method "reduce" to sum up all elements of an array ?
(in javascript) I am stuck, thanks in advance
Timurtek
@Timurtek
Jan 01 2017 06:35
@abpndr1 run a loop through the array and add each value into a var
Ghulam Shabir
@ghulamshabir
Jan 01 2017 06:37
@abpndr1 have two parameters in reduce callback and return their sum like this return a+b i supposed you named parameters a and b
Ghulam Shabir
@ghulamshabir
Jan 01 2017 06:47
@cherukss hey here is the correct version of your attempt to solve falsy bouncer challenge using switch
function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr.filter(function(curr){
switch(true){
case curr === null:
case curr === false:
case curr === "":
case curr === 0:
case curr === undefined:
case curr !== curr:
return false;
default:
return true;
}
});
}
bouncer([1, null, NaN, 2, undefined]);
Greg Duncan
@GregatGit
Jan 01 2017 06:54
@abpndr1 write a simple function that adds two parameters together - then use that function so var total = [1, 2, 3].reduce(myFunction); if you write myFunction correct total will be 6
c0d0er
@c0d0er
Jan 01 2017 07:01
var state ={};
state={...state, two: 'mee'};
console.log(state)// why shows SyntaxError: Unexpected token ... at eval???

//this code is from the following example of http://redux.js.org/docs/recipes/UsingObjectSpreadOperator.html#using-object-spread-operator:
var initialState={};
function todoApp(state = initialState, action) {
  switch (action.type) {
    case SET_VISIBILITY_FILTER:
      return { ...state, visibilityFilter: action.filter }
    default:
      return state
  }
}
Ghulam Shabir
@ghulamshabir
Jan 01 2017 07:04
@c0d0er I think ... is supposed to be used for a function parameter to get all of the arguments and to flatten arrays
c0d0er
@c0d0er
Jan 01 2017 07:07
@ghulamshabir thanks
CamperBot
@camperbot
Jan 01 2017 07:07
c0d0er sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1557 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
aviral935
@aviral935
Jan 01 2017 07:08

var myStr="Firstline\n\SecondLine\r\ThirdLine"; // Change this line

please help to solve the bug

Ghulam Shabir
@ghulamshabir
Jan 01 2017 07:10
@aviral935 should be Line in Firstline and should have escaped backslash before \r and remove \ after \r
Nicklas Nilsson
@nilsi
Jan 01 2017 07:12
Noob question but I got a response from a http post that looks like this:
http://pastebin.com/xsjbh8CS
How can I get the attachment as a variable so I can do something like file.size to get the size? this part confuses me 'attachment[file]'
This pastbin is just a console.log(req.files);
Kelechi Chinaka
@ke1echi
Jan 01 2017 07:16
happy new year guys
@ghulamshabir i dont seem to understand what the Caesars Cipher is talking about
Ghulam Shabir
@ghulamshabir
Jan 01 2017 07:17
@kelechichinaka Happy New Year! :D
@kelechichinaka you are supposed to check and convert A-M to N-Z and vice versa and keep other than those as it as
Nicklas Nilsson
@nilsi
Jan 01 2017 07:21
Happy new year! 🍭🍭🍭
aviral935
@aviral935
Jan 01 2017 07:22
@ghulamshabir not happening
var myStr = "FirstLine\n\SecondLine\rThirdLine"; // Change this line
Ghulam Shabir
@ghulamshabir
Jan 01 2017 07:23
@aviral935 you are not escaping backslash before \r, you need to prefix \ to it
aviral935
@aviral935
Jan 01 2017 07:26
var myStr = "FirstLine\n\SecondLine\rThirdLine"; // Change this line
@ghulamshabir not working
Ghulam Shabir
@ghulamshabir
Jan 01 2017 07:27
@nilsi Happy New Year! :dancers:
@aviral935 var myStr = "FirstLine\n\\SecondLine\\\rThirdLine";
Rahul
@s0ulr3ap3r
Jan 01 2017 07:28
Happy New Year
Ghulam Shabir
@ghulamshabir
Jan 01 2017 07:29
@s0ulr3ap3r Happy new year!
Anthony Mitchell
@Drantho
Jan 01 2017 07:30
has anyone done Everything Be True? I dont quite get what it is asking me to do
Ghulam Shabir
@ghulamshabir
Jan 01 2017 07:33
@Drantho Instructions: Check if the predicate (second argument) is truthy on all elements of a collection (first argument).
Anthony Mitchell
@Drantho
Jan 01 2017 07:34
@ghulamshabir does that mean determine if each element in the collection has that prop?
or if the value of that prop can be a bool?
or something else entirely???
Ghulam Shabir
@ghulamshabir
Jan 01 2017 07:35
@Drantho an element has pre as well as it's truthy
Mohamed Osman
@osman5019
Jan 01 2017 07:36

hey guys can you help me i'm stuck on this

//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][j] === contacts.firstName){
      if (contacts.hasOwnProprty(prop) === contacts[i][prop]){
        return firstName + contacts.hasOwnProperty(prop); 
      } else {
        return "No such property";
      }
    }
  }
}

// Only change code above this line
}

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

why doesn't it work?

Ghulam Shabir
@ghulamshabir
Jan 01 2017 07:37
@Drantho and that should be for all of the elements in the collection see the instructions again
JMNofziger
@JMNofziger
Jan 01 2017 07:39
Happy new year!
Ende
@LeForteXL
Jan 01 2017 07:40

I reversed the string with this code" <code>function reverseString(str) {
return str.split('').reverse(str);
}

reverseString("Greetings from Earth");
</code> and it didn't pass me. But it works... uh, help.

JMNofziger
@JMNofziger
Jan 01 2017 07:40
:sparkles: :saxophone: :sparkles:
Ghulam Shabir
@ghulamshabir
Jan 01 2017 07:40
@osman5019 you need only one loop, contacts.hasOwnProprty(prop) is not correct because contacts is an array not an object and also you are supposed to return "No such contact" if no contact matches with firstName parameter
Anthony Mitchell
@Drantho
Jan 01 2017 07:41
@ghulamshabir thanks Ive read the instructions over and over but Im really missing something
CamperBot
@camperbot
Jan 01 2017 07:41
drantho sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1558 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Jan 01 2017 07:42
@AlvinII reverse does not take arguments and you are supposed to return a string as you already have splitted the str
Ende
@LeForteXL
Jan 01 2017 07:42
oh, wait, I need to mmake it a complete string, not an array
Mohamed Osman
@osman5019
Jan 01 2017 07:44
@ghulamshabir alright let me try again
Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 07:44
function diffArray(arr1, arr2) {
  var newArr1 = [], newArr2 = [], newArr = [];
  newArr1 = arr2.filter(function(fil) {
    return arr1.indexOf(fil) === -1;
  });
  newArr2 = arr1.filter(function(fil) {
    return arr2.indexOf(fil) === -1;
  });  
  newArr = newArr1.concat(newArr2);
  // Same, same; but different.
  return newArr;
}

diffArray([1, "calf", 3, "piglet"], [1, "calf", 3, 4]);
The laziest solution ever!
:/
What's the alterntive solution?
Ghulam Shabir
@ghulamshabir
Jan 01 2017 07:48
@SeifEddineSlimene you can solvde it with only one filter if you try to solve it like solved Seek and Destroy
tommy
@tommygebru
Jan 01 2017 07:48
will the livestream be available later ?

open17

codervs
@codervs
Jan 01 2017 07:52

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 booName = false;

for(var i=0; i < contacts.length; i++) {
if((contacts[i].firstName === firstName) && contacts[i].hasOwnProperty(prop)) return console.log(contacts[i].prop);
else if(contacts[i].firstName === firstName) {booName = true; break;}
}

if(booName === true) return "No such property";
else return "No such contact";
// Only change code above this line
}
// Change these values to test your function
lookUpProfile("Kristian", "lastName");

can somebody tell me what's wrong with my above code?
The case where the name and property both exist, is not working.
Don't know why.
The console shows a blank screen.
Is there anything wrong with this line:
if((contacts[i].firstName === firstName) && contacts[i].hasOwnProperty(prop)) return console.log(contacts[i].prop);
If any of you is looking into the problem, please write "yes".
AlliBun
@AlliBun
Jan 01 2017 07:56
myVar = myVar --; what did I mess up? my guess is the syntax
Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 07:56
@ghulamshabir i got stuck :/
Timurtek
@Timurtek
Jan 01 2017 07:57
@Erynfi - - myVar;
Ghulam Shabir
@ghulamshabir
Jan 01 2017 07:57
@ronaldo001 loop over arrayOfStrings and compare each elements length with b and re assign larger length to be
codervs
@codervs
Jan 01 2017 07:57
@Erynfi did you try myVar--
without space
AlliBun
@AlliBun
Jan 01 2017 07:58
yeah, still not working
Ghulam Shabir
@ghulamshabir
Jan 01 2017 07:58
@Erynfi use ++ it increments the variable in place so no need of re assigment
@SeifEddineSlimene post the code
codervs
@codervs
Jan 01 2017 07:59
@vaibhav
can somebody look into this statementif((contacts[i].firstName === firstName) && contacts[i].hasOwnProperty(prop)) return console.log(contacts[i].prop);
if((contacts[i].firstName === firstName) && contacts[i].hasOwnProperty(prop)) return console.log(contacts[i].prop);
Hanif Adams
@omeizahanif
Jan 01 2017 08:00
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  var arr2 = arr.sort();
  var index = 0;
  var n = 1;
  for (i = 0; i < arr2.length - 1; i++) {
    if (arr2[i] < num){
       if (arr2[i + n] > num){
         index = i + (n-1);
       }
      else {
        index = i + n;
      }
    }


  }
  return index;
}

getIndexToIns([40, 60, 20, 70], 50);
codervs
@codervs
Jan 01 2017 08:00
paleez!
Hanif Adams
@omeizahanif
Jan 01 2017 08:00
hi people! whats wrong with my code?
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:00
@shrivastavavaibhav return contacts[i][prop]
codervs
@codervs
Jan 01 2017 08:01
@ghulamshabir It is showing syntax error!
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:02
@shrivastavavaibhav you might have other mistakes in your code
codervs
@codervs
Jan 01 2017 08:02
SyntaxError: Unexpected token [
@ghulamshabir for this statement:
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:03
@shrivastavavaibhav you might have missing bracket or an extra
codervs
@codervs
Jan 01 2017 08:03
if((contacts[i].firstName === firstName) && contacts[i].hasOwnProperty(prop)) return console.log(contacts[i].[prop]);
else if(contacts[i].firstName === firstName) {booName = true; break;}
}
but there isn't any
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:04
@shrivastavavaibhav you have period in between contacts and prop
codervs
@codervs
Jan 01 2017 08:05
Thanks @ghulamshabir ! it solved the syntax error, but the console is still blank
CamperBot
@camperbot
Jan 01 2017 08:05
shrivastavavaibhav sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1559 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
codervs
@codervs
Jan 01 2017 08:05
Can you help?
@ghulamshabir , the console is still blank!
nothing is printing there
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:06
@omeizahanif just compare element with num without using n and return i immediately if the condition is true, make sure you take care of same value in the array as num
Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 08:07
@ghulamshabir
function diffArray(arr1, arr2) {
  var newArr1 = [], newArr2 = [], newArr = [];
  newArr1 = arr2.filter(function(fil) {
    return arr1.indexOf(fil) === -1;
  });
  newArr2 = arr1.filter(function(fil) {
    return arr2.indexOf(fil) === -1;
  });  
  newArr = newArr1.concat(newArr2);
  // Same, same; but different.
  return newArr;
}

diffArray([1, "calf", 3, "piglet"], [1, "calf", 3, 4]);
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:07
@shrivastavavaibhav your logic in the solution is not correct, you need to think about what you have to do
@SeifEddineSlimene that's the same
codervs
@codervs
Jan 01 2017 08:08
@ghulamshabir I removed the console.log() and the question was solved, but can you explain why it wasn't working with the console.log()
James Chance
@JimusMallard
Jan 01 2017 08:09
var filteredStreamers =[];
function filterClosedStreamers() {
  var twitchStreamers = ["freecodecamp", "ESL_SC2", "OgamingSC2", "cretetion", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas", "brunofin", "comster404"]; 
    for (var j = 0; j < twitchStreamers.length; j++) {
      $.ajax({
        url: 'https://wind-bow.gomix.me/twitch-api/channels/' + twitchStreamers[j],
        type: 'GET',
        dataType: 'jsonp'    
      }) 
      .done(function(data) {
        if(data['status'] !== 404) {
          var holding = twitchStreamers.shift();
          filteredStreamers.unshift(holding);
          return filteredStreamers;
        } else {
            console.log(data['message'])
        }
      })
    };
  }
filterClosedStreamers();
console.log(filteredStreamers);
Im working on this at the moment… I’m trying to create a new array from this function. I understand due to the nature of AJAX that this causes a problem. Basically when I return the array at the end its empty according to a count but it does show the items. Is there a way round this?
Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 08:09
@ghulamshabir hh ok how i use one filter?
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:09
@shrivastavavaibhav console.log is to print in browser console
@SeifEddineSlimene yes
Darth Skywalker
@adityaparab
Jan 01 2017 08:10
@SeifEddineSlimene
Array.prototype.unique = function(){
  var uniques = [];
  var len = this.length;
  for(i=0;i<len;i++){
    var current = this[i];
    if(uniques.indexOf(current) === -1){
      uniques.push(current);
    }
  }
  return uniques;
}

function diffArray(arr1, arr2) {
  return arr1.concat(arr2).unique();
}

diffArray([1, "calf", 3, "piglet"], [1, "calf", 3, 4]);
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:11
@j1mu5 why are you returning array, you can use the array inside .done, or you can pass the arrray to a custom function inside .done
Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 08:12
@adityaparab hh i wanna stick with my solution :p
James Chance
@JimusMallard
Jan 01 2017 08:12
@ghulamshabir Basically need to use th array for a second AJAX call in a different function
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:13
@j1mu5 call the second ajax inside first ajax's .done method
Darth Skywalker
@adityaparab
Jan 01 2017 08:13
@SeifEddineSlimene :P
Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 08:14
@adityaparab this refer to?
Darth Skywalker
@adityaparab
Jan 01 2017 08:14

@SeifEddineSlimene

@adityaparab hh i wanna stick with my solution :p

To this :point_up:

:P
anyway... this will be the array on which you call the prototype method.
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:15
@ronaldo001 you are supposed to assign .length to longestWord not the word itself
Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 08:15
@adityaparab in your code this is refer to what?
Darth Skywalker
@adityaparab
Jan 01 2017 08:15
so this in your unique function will be whatever the arr1.concat(arr2) returns
it is a very powerful pattern called chaininig
@SeifEddineSlimene
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:16
@SeifEddineSlimene @adityaparab it's not good practice to change prototype of built in constructor functions
Darth Skywalker
@adityaparab
Jan 01 2017 08:17
@ghulamshabir : That's a half baked truth
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:18
@adityaparab I think I read it in MDN docs
James Chance
@JimusMallard
Jan 01 2017 08:18
@ghulamshabir Ok ill give that a go now.
Darth Skywalker
@adityaparab
Jan 01 2017 08:19
@ghulamshabir - For the starters (who have no idea what they are doing), it stands true. However, we regularly violate such blindly accepted rules depending on context.
in case of unique it poses no danger at all.
because unique is not a standard function.
Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 08:20
@ghulamshabir he just add a function not change
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:20
@SeifEddineSlimene it's considered a change to the original :smile:
Darth Skywalker
@adityaparab
Jan 01 2017 08:20
@ghulamshabir : Have you heard about the idea of polyfill ?
Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 08:21
is that a built it method called unique?
:p
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:21
@adityaparab yes
Darth Skywalker
@adityaparab
Jan 01 2017 08:21
@SeifEddineSlimene not on Array.prototype it's there on underscore and lodash
Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 08:22
@adityaparab is there a built-in function calles unique?
Darth Skywalker
@adityaparab
Jan 01 2017 08:22

@ghulamshabir : Yes, so most polyfills modify native prototypes.

to ensure you don't break existing code, you are advised to modify prototypes like


Array.prototype.unique = Array.prototype.unique || function() { 
  //code
};
@SeifEddineSlimene no. there isn't
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:24
@SeifEddineSlimene you can solve it by concatenating arr1 and arr2 then calling filter on it.
Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 08:25
@adityaparab your solution is not the purpose of the challenge
@ghulamshabir and then?
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:27
@ronaldo001 you should split str with a ' ' not ''. former will give array of words but later will give you an array with only one element which is the entire string as str
Kevin Chandra
@Kaence
Jan 01 2017 08:27
guys
Raymundo Manuel Alvarez
@Raymundo-Alvarez
Jan 01 2017 08:27

Hello everybody and welcome to the New Year! Any who, I am having trouble on the Accessing Nested Objects. Here is my code.


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

// Only change code below this line

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

I am not what I am missing. I have full filled the dot and bracket notation but not when it asks when the gloveBoxContents equal "maps".

Kevin Chandra
@Kaence
Jan 01 2017 08:27
im stuck here
please help me
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:28
@Raymundo-Alvarez you need only the middle line
@SeifEddineSlimene then use indexOf/includes in filter callback to filter out the same numbers
Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 08:31
@ghulamshabir what includes?
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:31
@Kaence you don't need val === 2, as you already have val in switch like this switch(val) so just compare its value like this case 2: for example
Raymundo Manuel Alvarez
@Raymundo-Alvarez
Jan 01 2017 08:31
@ghulamshabir thank you sir.
CamperBot
@camperbot
Jan 01 2017 08:31
raymundo-alvarez sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1560 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Greg Duncan
@GregatGit
Jan 01 2017 08:32
@Kaence you need to understand switch statements better
Aleksandar Zdravkovski
@azdravkovski
Jan 01 2017 08:32
Hey guys. I'm doing the Check for Palindromes challenge and I'm a bit stuck. I can check for palindromes alright but only if it's a single, lower-case word, not a sentence. Here's my code. You don't need to straight up give me the answer - just point me in the right direction. Thanks a lot!

function palindrome(str) {
  // Good luck!
  var repStr = str.replace(/\W/g, '').toLowerCase().split('').reverse().join('');
  if (str === repStr) {
  return true;
  }
  return false;
}



palindrome("race car");
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:32
@SeifEddineSlimene includes is an es6 method which returns true if it finds the element in the array
Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 08:33
@ghulamshabir what about the seek and destroy method you said to me
?
Aleksandar Zdravkovski
@azdravkovski
Jan 01 2017 08:33
Also, Happy New Year!
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:34
@SeifEddineSlimene think of concated arr1 and arr2 as arr as in Seek and Destroy
Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 08:34
@ghulamshabir done already i'm trying using includes
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:35
@SeifEddineSlimene yes i was telling you the similarity of it to Seek and Destroy
Kevin Chandra
@Kaence
Jan 01 2017 08:36
@ghulamshabir thaks
Chris
@chriiisdugger
Jan 01 2017 08:36
hey guys can you help me?
Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 08:36
@ghulamshabir (y)
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:36
@azdravkovski you are supposed to compare non alphanumeric version of str to reversed non alphanumeric not just str
@Kaence :+1:
@SeifEddineSlimene pardon me (y) ?
Sandeep Chary
@dsandeepchary
Jan 01 2017 08:37
:+1:
Chris
@chriiisdugger
Jan 01 2017 08:37
hey guys
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:39
@chriiisdugger hi
christopher liudahl
@eatinfishnchips
Jan 01 2017 08:41
Hey yall have you done the stand in line challenge?
Seif Eddine Slimene
@SeifEddineSlimene
Jan 01 2017 08:41
@ghulamshabir i mean :thumbsup: lol i used it on facebook
@ghulamshabir
function diffArray(arr1, arr2) {
  var newArr = [];
  newArr = arr1.concat(arr2);
  newArr = newArr.filter(function(val) {
    return !newArr.includes(val, newArr.indexOf(val) + 1);
  });
  return newArr;
}
diffArray([1, "calf", 3, "piglet"], [1, "calf", 3, 4]);
Works as charm
Aleksandar Zdravkovski
@azdravkovski
Jan 01 2017 08:42
@ghulamshabir Thanks!
CamperBot
@camperbot
Jan 01 2017 08:42
azdravkovski sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1561 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:43
@SeifEddineSlimene :+1:
Rahul Rao
@iamrahulrao
Jan 01 2017 08:43
not sure what is wrong here, can someone explain the process
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
if(contacts.hasOwnProperty(firstName)===true){
  if(contact.hasOwnProperty(prop)===true){
    return contacts[firstName][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("Akira", "likes");
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:47
@SeifEddineSlimene
function diffArray(arr1, arr2) {

  return arr1.concat(arr2).filter(function(val) {
    return arr1.includes(val) && arr2.includes(val);
  });
}
diffArray([1, "calf", 3, "piglet"], [1, "calf", 3, 4]);
@eatinfishnchips post your code
Hanif Adams
@omeizahanif
Jan 01 2017 08:50
@ghulamshabir im missing something. still cant pass all tests
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  var arr2 = arr.sort();
  var index = 0;

  for ( i = 0; i < arr2.length; i++) {
    if (arr2[i] < num) {
        index = i + 1;
    }
     else if (arr2[i] == num) {
       index = i;
     }

  }
  return index;
}

getIndexToIns([40, 60, 20, 70], 50);
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:53
@omeizahanif you are not take care of the same value as num what if there aleady 50 in the arr ? your if condition will return false for the same values and no need of adding one to i
@omeizahanif should return in the if
Hanif Adams
@omeizahanif
Jan 01 2017 08:55
@ghulamshabir are u saying if arr2[i] is <= num, return the index, i?
Ghulam Shabir
@ghulamshabir
Jan 01 2017 08:56
@omeizahanif yes then return i
Hanif Adams
@omeizahanif
Jan 01 2017 09:00
@ghulamshabir but the instruction clearly implies that if u have [20, 30, 50, 60], and the number is 50, index will be 3 because 50 will come after 50 (index 2) and before 60 (index 3)
@ghulamshabir thats why if arr2[i] <= num, I returned the index as (i+ 1)
Ghulam Shabir
@ghulamshabir
Jan 01 2017 09:05
@omeizahanif adding one messes up things when the numbers are not same, if the numbers are same it does not make any difference because fcc can find 50 at index 3
James Chance
@JimusMallard
Jan 01 2017 09:07

var twitchStreamers = ["freecodecamp", "ESL_SC2", "OgamingSC2", "cretetion", "storbeck", "habathcx", "brunofin", "comster404"];     

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

    $.getJSON('https://wind-bow.gomix.me/twitch-api/streams/' + twitchStreamers[i], function(json) {

        var userName = json['_links']['channel'].substr(38); 

        if (json['stream'] !== null) {
            $('#ResultsArea').append('<a class="removeLinks" href="' + 'https://www.twitch.tv/' + userName + '" target="_blank">' + '<div class="twitchStreamer tsOnline"><p>' + '<strong>User Name: </strong>' + userName + '<br>' + '<strong>Streaming: </strong>' + json['stream']['game'] + '<br></p><img class="img-rounded twitchPreview" src="' + json['stream']['preview']['small'] + '"' + '></div></a>');

        } else {

            $.getJSON('https://wind-bow.gomix.me/twitch-api/users/' + twitchStreamers[i], function(data) {
                console.log(data);

                if(data['status'] !== 404) {

                    $('#ResultsArea').append('<a class="removeLinks" href="' + 'https://www.twitch.tv/' + userName + '" target="_blank">' + '<div class="twitchStreamer tsOffline"><p>' + '<strong>User Name: </strong>' + userName + '<br>' + '<strong>Status: </strong>' + 'Not Online' + '<br></p></div></a>');    
                } else {
                    $('#ResultsArea').append('<div class="twitchStreamer tsOffline"><p>' + '<strong>' + data['message'] + '</strong>' + '<br></p></div>');    
                }
            }) // end of second get json
        }; // end of first else statement
    }) // end of first get json
} // end of first for loop
Right so I have now put the two funcitons together, however now the second getJSON action keeps returning undefined now…
Hanif Adams
@omeizahanif
Jan 01 2017 09:09
@ghulamshabir if i get u correctly, my code should look like this.
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  var arr2 = arr.sort();
  var index = 0;

  for ( i = 0; i < arr2.length; i++) {
    if (arr2[i] < num) {
        index = i;
    }

  }
  return index;
}

getIndexToIns([40, 60, 20, 70], 50);
even with this condition (arr2[i] <= num), i cant pass any test where i simply return 'i'
Ghulam Shabir
@ghulamshabir
Jan 01 2017 09:25
@omeizahanif use >= not < and return i not index = i then after the loop return arr.length
@omeizahanif also your sort needs a callback function because by default it sorts alphabetically
Hanif Adams
@omeizahanif
Jan 01 2017 09:28
@ghulamshabir ok. i got the first part. but, isnt it supposed to sort alphabetically since we are dealing with numbers?
Ghulam Shabir
@ghulamshabir
Jan 01 2017 09:30
@omeizahanif it converts numbers to strings
Rahul Chaurasia
@rahulchaurasia01
Jan 01 2017 09:31
GuyS need help

function myReplace(str, before, after) {
var i , n,j,k;
k = after.length;
n = str.length;
for(i=0;i<=n-1;i++)
{
if(str[i]===before[0])
{
for(j=0;j<=k-1;j++)
{
str[i] = str[i].replace(str[i], after[i]);
}
}
}
return str;
}

myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");

Hanif Adams
@omeizahanif
Jan 01 2017 09:31
oooh. lemme take care of that quickly. thanks @ghulamshabir
CamperBot
@camperbot
Jan 01 2017 09:31
omeizahanif sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1562 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Rahul Chaurasia
@rahulchaurasia01
Jan 01 2017 09:31
@omeizahanif help me
Hanif Adams
@omeizahanif
Jan 01 2017 09:32
@rahulchaurasia01 whats the name of the challenge?
Rahul Chaurasia
@rahulchaurasia01
Jan 01 2017 09:32
search n replace @omeizahanif
Ghulam Shabir
@ghulamshabir
Jan 01 2017 09:33
@omeizahanif if you want to go with your original solution then you don't need sort just increment index index++ instead of index = i
Rahul Chaurasia
@rahulchaurasia01
Jan 01 2017 09:33
@ghulamshabir help me
Greg Duncan
@GregatGit
Jan 01 2017 09:34
@rahulchaurasia01 don't initialize outside the for loops
crisgithub
@crisgithub
Jan 01 2017 09:34
Hi guys! I'm in challenge 244 and I have some problems with null values... someone can help me? Why null case is not working??? Here the code! Thanks!!

function isFalsyBouncer(value) {
var resultat=false;

switch (value) {
case 0:
case undefined:
case null:
case "":
case NaN:
case false:
resultat=false;
break;
default:
resultat=true;
break;
}
return resultat;
}
function bouncer(arr) {
// Don't show a false ID to this bouncer.

var filtered = arr.filter(isFalsyBouncer);

return filtered;
}

bouncer([1, null, NaN, 2, undefined]);

Hanif Adams
@omeizahanif
Jan 01 2017 09:34
@rahulchaurasia01 ooh. sorry, i dont think i've done that challenge yet. try using backticks (```) before and after your code so that I can see it clearly. :smile:
Daniel Wagener
@SigniorGratiano
Jan 01 2017 09:34
I'm doing the Profile Lookup challenge now. Right now I can look up any property for any contact as long as I have the "No such contact" line commented out, but as soon as uncomment it I can only look up properties for the first contact, Akira.
for (i = 0; i < contacts.length; i++) {
   if (contacts[i].firstName == firstName) {
    if (contacts[i].hasOwnProperty(prop) === false) {
      return "No such property";
    } else {
    return contacts[i][prop];
    }
   } else {
     return "No such contact";
   }
}
Rahul Chaurasia
@rahulchaurasia01
Jan 01 2017 09:35
ok
Greg Duncan
@GregatGit
Jan 01 2017 09:35
@rahulchaurasia01 also for this challenge you don't need any loops
just replace
Rahul Chaurasia
@rahulchaurasia01
Jan 01 2017 09:36
@GregatGit ok, tell me try now
Greg Duncan
@GregatGit
Jan 01 2017 09:36
@SigniorGratiano move that line outside the for loop
Hanif Adams
@omeizahanif
Jan 01 2017 09:37
from what i can see, i think u need to compare the word with the string. once u find a word that matches the chosen word, replace it with a new one. i'll get there, maybe i will understand what u are seeing @rahulchaurasia01
Greg Duncan
@GregatGit
Jan 01 2017 09:37
@SigniorGratiano in fact lose that 'else' part - not needed and move return "No... outside the for loop
Daniel Wagener
@SigniorGratiano
Jan 01 2017 09:38
@GregatGit That did it, thanks!
CamperBot
@camperbot
Jan 01 2017 09:38
signiorgratiano sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 809 | @gregatgit |http://www.freecodecamp.com/gregatgit
Ghulam Shabir
@ghulamshabir
Jan 01 2017 09:39
@crisgithub put true in switch parens like this switch(true) then your case condition should be like this case val === 0: and so on
Greg Duncan
@GregatGit
Jan 01 2017 09:39
@SigniorGratiano that else condition was stopping you from looping through all the contacts because it had a return statement that endend the function
Rahul Chaurasia
@rahulchaurasia01
Jan 01 2017 09:40
@GregatGit see this
function myReplace(str, before, after) {
  var i , n,j,k;
  str = str.replace(before, after);
  return str;
}

myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
@GregatGit but it still give 2 error.
Greg Duncan
@GregatGit
Jan 01 2017 09:41
@rahulchaurasia01 you are on the right track
Hanif Adams
@omeizahanif
Jan 01 2017 09:41
@ghulamshabir lol. i got the first part. i forgot how to properly use sort function. U are the man :+1:
Greg Duncan
@GregatGit
Jan 01 2017 09:41
@rahulchaurasia01 jsut don't use loops to fix it
Rahul Chaurasia
@rahulchaurasia01
Jan 01 2017 09:41
@GregatGit yes
Ghulam Shabir
@ghulamshabir
Jan 01 2017 09:42
@omeizahanif you can try your original solution which you first posted just increment index++ and don't need sort in that solution
:point_up: January 1, 2017 2:09 PM @omeizahanif
Hanif Adams
@omeizahanif
Jan 01 2017 09:48
@ghulamshabir i almost passed all test. missing something tho
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  var index = 0;

  for (i = 0; i < arr.length; i++) {
    if (arr[i] >= num) {
        return i;

    }
      index++;
  }
    return arr.length;
}

getIndexToIns([40, 60, 20, 70], 50);
Ghulam Shabir
@ghulamshabir
Jan 01 2017 09:49
@omeizahanif
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
 /* var arr2 = arr.sort(function(a,b){
    return a-b;
  });*/
  var index = 0;

  for ( i = 0; i < arr.length; i++) {
    if (arr[i] < num) {
        index++;
    }

  }
  return index;
}

getIndexToIns([40, 60, 20, 70], 50);
Hanif Adams
@omeizahanif
Jan 01 2017 09:52
woah. Why did that work?
oh. so, index increments as the loop searches for an index i that is greater than num
Ghulam Shabir
@ghulamshabir
Jan 01 2017 09:53
cuz u r counting ur num position
Hanif Adams
@omeizahanif
Jan 01 2017 09:54
hmm. i completely understand it now
AhhMclean
@AhhMclean
Jan 01 2017 10:16
function titleCase(str) {
  var splitr = str.toLowerCase().split(" ");
  var result = "";
  for (i=0; i< splitr.length; i++) {
    result +=  splitr[i].charAt(0).toUpperCase() + splitr[i].slice(1) + " ";
  }

  return result;
}

titleCase("I'm a little tea pot");
how do i make my result a string in " " and not just a sentance
the result is I'm A Little Tea Pot
and i want it to be a string "I'm A Little Tea Pot"
any ideas?
anyone here?
Timurtek
@Timurtek
Jan 01 2017 10:19
try to upper case on final result
AhhMclean
@AhhMclean
Jan 01 2017 10:20
on the return?
Timurtek
@Timurtek
Jan 01 2017 10:21
return result.toUpperCase()
AhhMclean
@AhhMclean
Jan 01 2017 10:21
wouldnt that just make everything uppercase?
Timurtek
@Timurtek
Jan 01 2017 10:23
yes. my bad.. didnt read it all the way through
i just tried your code on JSFiddle it seems to be working
AhhMclean
@AhhMclean
Jan 01 2017 10:24
like the function works as i want it too but its not returning a string in quotations
i want result to = "I'm A Little Tea Pot"
but it jsut returns I'm A Little Tea Pot
Ghulam Shabir
@ghulamshabir
Jan 01 2017 10:25
@AhhMclean re assing the new string you are building to each element of splittr then use join on it after loop
AhhMclean
@AhhMclean
Jan 01 2017 10:25
hwo do i join?
lol .join()?
DKamon
@DKamon
Jan 01 2017 10:26
for(i=0;i<contacts.length;i++){
if(contacts[i].firstName==firstName && contacts[i].hasOwnProperty(prop)===true ){
return contacts[i].prop;
}
if(contacts[i].firstName!=firstName){
return "No such contact";
}
if(contacts[i].hasOwnProperty===false){
return "No such property";
}
}
can anyone help me with this code?
Ghulam Shabir
@ghulamshabir
Jan 01 2017 10:26
@AhhMclean yes with " "
AhhMclean
@AhhMclean
Jan 01 2017 10:27
function titleCase(str) {

  var splitr = str.toLowerCase().split(" ");

  var result = "";

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

  var realResult = result.join(" ");
  return realResult;
}

titleCase("I'm a little tea pot");
AhhMclean
@AhhMclean
Jan 01 2017 10:27
just tried that and it says join isnt a function
how do i use it as a method (which im guessing it is)
Ghulam Shabir
@ghulamshabir
Jan 01 2017 10:27

@AhhMclean

@AhhMclean re assign the new string you are building to each element of splittr then use join on it after loop

Joseph
@revisualize
Jan 01 2017 10:28
@DKamon 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];
Ghulam Shabir
@ghulamshabir
Jan 01 2017 10:29
@AhhMclean join is method of Arrays and result is a string
AhhMclean
@AhhMclean
Jan 01 2017 10:29
ooo okay
revisualize @revisualize drops the :microphone: and says :fu: .... .... :zzz: :zzz:
AhhMclean
@AhhMclean
Jan 01 2017 10:30
@revisualize this fkn guy
Joseph
@revisualize
Jan 01 2017 10:31
I know ... Right! That @revisualize guy is a real a-hole.
AhhMclean
@AhhMclean
Jan 01 2017 10:31
he should probs get a life
lol
Joseph
@revisualize
Jan 01 2017 10:31
yeah! That dude is a LOOOOOOOOSER!
AhhMclean
@AhhMclean
Jan 01 2017 10:32
mmm
DKamon
@DKamon
Jan 01 2017 10:32
@revisualize when changing the code into dot notation there is an error being shown saying that the property is better written with dot notation
Ghulam Shabir
@ghulamshabir
Jan 01 2017 10:33
who is @revisualize ? he has a bad reputation i guess :smile:
Joseph
@revisualize
Jan 01 2017 10:34
@DKamon There isn't an error.
DKamon
@DKamon
Jan 01 2017 10:37
for(i=0;i<contacts.length;i++){
if(contacts[i][firstName]=="firstName" && contacts[i].hasOwnProperty(prop)===true ){
return contacts[i][prop];
}
else if(contacts[i][firstName]!="firstName"){
return "No such contact";
}
else if(contacts[i].hasOwnProperty===false){
return "No such property";
}
}
now @revisualize
is it correct?
@ghulamshabir
can u help?
AhhMclean
@AhhMclean
Jan 01 2017 10:41
@DKamon whats the task called
Ghulam Shabir
@ghulamshabir
Jan 01 2017 10:42
@DKamon yes
@DKamon contacts[i].firstName === firstName without quotes and brackets
DKamon
@DKamon
Jan 01 2017 10:45
still there is some mistake @ghulamshabir
@AhhMclean the task is profile lookup
Artem
@twentyouts
Jan 01 2017 10:46
``` str = str.replace(/\s/g, "");
palindrome("0_0 (: /-\ :) 0-0")
Ghulam Shabir
@ghulamshabir
Jan 01 2017 10:46
@DKamon yes i know, use && part of condition in a nested if inside first if
Artem
@twentyouts
Jan 01 2017 10:47
str = str.replace(/\s/g, ""); palindrome("0_0 (: /-\ :grinning: 0-0") does any body know how to avoid "\" in palindrome delete after .replace ?
AhhMclean
@AhhMclean
Jan 01 2017 10:47
I would have avoided using a loop for this task
you can do it with just if/else statements
Ghulam Shabir
@ghulamshabir
Jan 01 2017 10:48
@twentyouts str = str.toLowerCase().replace(/\W|_/g, "");
AhhMclean
@AhhMclean
Jan 01 2017 10:48
@DKamon try writing the first bit without a for loop
Ghulam Shabir
@ghulamshabir
Jan 01 2017 10:49
@AhhMclean its profile lookup not record collection, loop is needed to iterate over contacts array
DKamon
@DKamon
Jan 01 2017 10:50
thanks @AhhMclean @ghulamshabir
CamperBot
@camperbot
Jan 01 2017 10:50
dkamon sends brownie points to @ahhmclean and @ghulamshabir :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for ahhmclean
:star2: 1563 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Artem
@twentyouts
Jan 01 2017 10:51
@ghulamshabir well..it worked out. But what happened? о_О it converdet it to 0000
Ghulam Shabir
@ghulamshabir
Jan 01 2017 10:51
@DKamon for what ? you passed the challenge ?
@twentyouts i don't know what are you doing with your rest of code
Artem
@twentyouts
Jan 01 2017 10:52

``` str = str.replace(/\W|/g,"");
str = str.replace(/\,/g, "");
str = str.replace(/./g, "");
str = str.replace(/\
(?=e)/g, "");
str = str.replace(/_(?=0)/g, "-");
str = str.replace(/\s/g, "");
str = str.toLowerCase();
var strsplit = str.split('');
strsplit = strsplit.reverse();

//str = str.reverse();
//return split;

strsplit = strsplit.join('');

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

```

str = str.replace(/\W|_/g,""); 
  str = str.replace(/\,/g, "");
  str = str.replace(/\./g, "");
  str = str.replace(/\_(?=e)/g, "");
  str = str.replace(/\_(?=0)/g, "-");
  str = str.replace(/\s/g, "");
  str = str.toLowerCase();
  var strsplit = str.split('');
  strsplit = strsplit.reverse();

  //str = str.reverse();
  //return split;

   strsplit = strsplit.join('');


  if ( strsplit === str){
    return true;}
  else{
    return false;
  } 
}
Ghulam Shabir
@ghulamshabir
Jan 01 2017 10:53
@twentyouts all you need what i gave you , you don't need that many replaces
Artem
@twentyouts
Jan 01 2017 10:54
@ghulamshabir oh yes W is for all those symbols..
DKamon
@DKamon
Jan 01 2017 10:54
@ghulam shabir i thought i could after your hint but i think there is still something missing
for(i=0;i<contacts.length;i++){
if(contacts[i].firstName==firstName && contacts[i].hasOwnProperty(prop)===true ){
if(contacts[i].firstName!=firstName){
return "No such contact";
}
if(contacts[i].hasOwnProperty(prop)===false){
return "No such property";
}
return contacts[i][prop];
}
}
Ghulam Shabir
@ghulamshabir
Jan 01 2017 10:54
@twentyouts yes but you misse |_
Artem
@twentyouts
Jan 01 2017 10:55
@ghulamshabir 1 line instead of mine 10:D thx
CamperBot
@camperbot
Jan 01 2017 10:55
twentyouts sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1564 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ayush Goyal
@ayush987goyal
Jan 01 2017 10:58

function diffArray(arr1, arr2) {
  var newArr = [];
  // Same, same; but different.

  var array = arr1.concat(arr2);
  var result=[];
  var count =0;

  function helper(value){
    for(var i=0;i<array.length;i++){
      if(value===array[i]){
        count++;
      }
    }

    if(count===2){
      return false;
    }

    return true;
  }

  result = array.filter(function(temp){

    return helper(temp);

  });

  return result;
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
hi guys please help me out here ....whats wrong with the aboce code for diffing two arrays
@ghulamshabir hey! anything for the abocve?
anyone? please help me out
Shashank Sharma
@shashank-sharma
Jan 01 2017 11:06
what do you mean by diffing two arrays ? you mean to say difference ?
Ayush Goyal
@ayush987goyal
Jan 01 2017 11:06
yeah
Gulshan Sharma
@gulshanzealous
Jan 01 2017 11:06
@ayush987goyal what is not working in the code?
Ayush Goyal
@ayush987goyal
Jan 01 2017 11:07
diff means the values not present in both arrays
so for above query the result should be [4]
Ghulam Shabir
@ghulamshabir
Jan 01 2017 11:08
@ayush987goyal why don't you use helper as callback to filter then inside it use indexOf on arr1 and arr2 to filter out similar values ?
Ayush Goyal
@ayush987goyal
Jan 01 2017 11:09
i think that can be one of the ways but i was wondering whats wrong with my code
Shashank Sharma
@shashank-sharma
Jan 01 2017 11:09
you should have put count inside helper function else count will keep on incrementing
like count = 0;
Ayush Goyal
@ayush987goyal
Jan 01 2017 11:10
ohh i see
thanks @shashank-sharma
CamperBot
@camperbot
Jan 01 2017 11:10
ayush987goyal sends brownie points to @shashank-sharma :sparkles: :thumbsup: :sparkles:
:cookie: 226 | @shashank-sharma |http://www.freecodecamp.com/shashank-sharma
AhhMclean
@AhhMclean
Jan 01 2017 11:13
if i have an array
and i say array[-1] that should select the last element of an array right?
Gulshan Sharma
@gulshanzealous
Jan 01 2017 11:14
Guys, could you help me about how to make two request 'threads' received on a server pass information to each other?
I am using eventEmitter to do it but is it the preferred way. i couldn't find anything close to this anywhere.
Ghulam Shabir
@ghulamshabir
Jan 01 2017 11:15
@AhhMclean no negative indice don't work in arrays
AhhMclean
@AhhMclean
Jan 01 2017 11:17
ahhh that explains it
so pretty much ive sorted a list of numbers and i want to select the highest number
i thought if i .sort() then i did list[-1] it would work
what other approach can i do?
Shashank Sharma
@shashank-sharma
Jan 01 2017 11:18
why don't you find out the length of the array and do -1
Even i also thought of a[-1] just like in python but here it is a bit different
AhhMclean
@AhhMclean
Jan 01 2017 11:19
ahhh thats where im getting it from
Gulshan Sharma
@gulshanzealous
Jan 01 2017 11:20
I am starting a tcp server and listening on a port. Clients connect to me. I do not send the response right away. I keep their socket on hold. When I receive a particular info on from some other client, I trigger an event which sends a response on the socket I had put on hold. It's like I am delaying a response based on some condition.
Can someone help me figure out what's the best way to do it or is it even advisable?
AhhMclean
@AhhMclean
Jan 01 2017 11:21
@shashank-sharma i cant seem to use length either
so say i do array.length()
how am i getting the last element?
Shashank Sharma
@shashank-sharma
Jan 01 2017 11:22
Let us say I have an array
a = [1,2,3,4]
so last element will be like a[a.length-1]
AhhMclean
@AhhMclean
Jan 01 2017 11:22
lenght(-1) doesnt seem to make sense to em
ooooo
i see what you mean
clever
thanks @shashank-sharma
CamperBot
@camperbot
Jan 01 2017 11:22
ahhmclean sends brownie points to @shashank-sharma :sparkles: :thumbsup: :sparkles:
:cookie: 227 | @shashank-sharma |http://www.freecodecamp.com/shashank-sharma
Ayush Bahuguna
@relentless-coder
Jan 01 2017 11:24
if an element is positioned as absolute, then if we set % values to it's width, then relative what element would it's width be decided? I have an unordered list inside a list item, the unordered list is positioned aboslute.
Gulshan Sharma
@gulshanzealous
Jan 01 2017 11:25
I am starting a tcp server and listening on a port. Clients connect to me. I do not send the response right away. I keep their socket on hold. When I receive a particular info on from some other client, I trigger an event which sends a response on the socket I had put on hold. It's like I am delaying a response based on some condition. Guys, some help please.
Ghulam Shabir
@ghulamshabir
Jan 01 2017 11:27
@AhhMclean because arrays are objects when do this array[-1] = "foo" it takes -1 as a property and converts to string but it does not adds to length of array because its not a positive index, though array[-1] returns "foo"
AhhMclean
@AhhMclean
Jan 01 2017 11:36
omg lol
javascript wtf
when you sort [1000, 1001, 857, 1] 857 comes out on top
wtf is that
Kevin Chandra
@Kaence
Jan 01 2017 11:37
guys
help here
CamperBot