These are chat archives for FreeCodeCamp/HelpJavaScript

14th
Jun 2016
Greg Duncan
@GregatGit
Jun 14 2016 00:00
if so to access each array in arr it would be arr[i]
Toni Shortsleeve
@KoniKodes
Jun 14 2016 00:00
@dcgoings perhaps if you return something before ending the function?
Dan
@dcgoings
Jun 14 2016 00:01

@GregatGit doesn't look like it. the test function is

chunkArrayInGroups(["a", "b", "c", "d"], 2);

which doesnt look like an array or arrays.

Greg Duncan
@GregatGit
Jun 14 2016 00:03
so you have to return an array with the first 2 or divide it up into smaller arrays with a max of 2?
channsin
@channsin
Jun 14 2016 00:03
Hi I'm working on the challenge "Word Blanks". How dod I add spaces in the string?
FayeQ
@HefeiQ
Jun 14 2016 00:03
@nsloc22 @khaduch Thank you both! A good point about asynchronous, I'll try to figure out how to fix it.
CamperBot
@camperbot
Jun 14 2016 00:03
hefeiq sends brownie points to @nsloc22 and @khaduch :sparkles: :thumbsup: :sparkles:
:cookie: 384 | @nsloc22 |http://www.freecodecamp.com/nsloc22
Dan
@dcgoings
Jun 14 2016 00:03
@KoniKodes im returning newArr? it's saying the infinite loop is at newArr.push(arr.slice(i,i+size));
CamperBot
@camperbot
Jun 14 2016 00:03
:star2: 1310 | @khaduch |http://www.freecodecamp.com/khaduch
nsloc22
@nsloc22
Jun 14 2016 00:03
@dcgoings wouldn't this be always true?
i < arr.length
Dan
@dcgoings
Jun 14 2016 00:03
@GregatGit divide it up into smaller arrays
oh shit
wait no
arr doesnt change
nsloc22
@nsloc22
Jun 14 2016 00:04
@dcgoings if you do
i+size
and size is constant
Greg Duncan
@GregatGit
Jun 14 2016 00:04
@nsloc22 is righti += size
Dan
@dcgoings
Jun 14 2016 00:05
fml
it worked
hmm, im trying to understand now though.
i+size wouldn't be 0+2?
Greg Duncan
@GregatGit
Jun 14 2016 00:06
@dcgoings i never changed in your code - it just stayed at i + size
Ken Haduch
@khaduch
Jun 14 2016 00:07
@channsin - you just add them as literal strings consisting of a space - that is: + ' ' + between your other variables.
Travis Horn
@travishorn
Jun 14 2016 00:07

I'm trying to do the "Check for Palindromes" challenge. I get every test passing except

palindrome("0_0 (: /-\ :) 0-0") should return true.

But this isn't a palindrome is it? _ and - are different characters. AND Isn't backslash space functionally the same as just a regular space in a JavaScript string?

Ken Haduch
@khaduch
Jun 14 2016 00:07
@travishorn - you are supposed to strip out all character that are not numbers and letters. I think that's what the instructions say?
Travis Horn
@travishorn
Jun 14 2016 00:08
Ohhh that's embarrassing. Let me read it again.
Dan
@dcgoings
Jun 14 2016 00:08
@GregatGit hmm, i guess i understand.. maybe.
@GregatGit @nsloc22 thanks
CamperBot
@camperbot
Jun 14 2016 00:08
dcgoings sends brownie points to @gregatgit and @nsloc22 :sparkles: :thumbsup: :sparkles:
:cookie: 385 | @nsloc22 |http://www.freecodecamp.com/nsloc22
:cookie: 582 | @gregatgit |http://www.freecodecamp.com/gregatgit
nsloc22
@nsloc22
Jun 14 2016 00:08
@dcgoings it would, but on every loop iteration it checks if( i < arr.length), when it's false the loop exits, and i is always 2 in this case, so you have infinite loop
Dan
@dcgoings
Jun 14 2016 00:08
okay but
Travis Horn
@travishorn
Jun 14 2016 00:08
@khaduch Yes, it is a Note in the instructions. Thank you.
CamperBot
@camperbot
Jun 14 2016 00:08
travishorn sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1311 | @khaduch |http://www.freecodecamp.com/khaduch
Dan
@dcgoings
Jun 14 2016 00:09
at the start of the for loop, i = 0, right?
then it will execute i+size, so 0+2 = 2?
Ken Haduch
@khaduch
Jun 14 2016 00:09
@travishorn - you're welcome... You must be close to having a solution if that is the only test that is failing.
Dan
@dcgoings
Jun 14 2016 00:10
NVM
got it
it clicked
haha
nsloc22
@nsloc22
Jun 14 2016 00:10
@dcgoings but it won't change i, it will just give you 2 on every iteration
Dan
@dcgoings
Jun 14 2016 00:10
got it, got it
thanks
max77p
@max77p
Jun 14 2016 00:16
can someone help me with this
Travis Horn
@travishorn
Jun 14 2016 00:16
@khaduch I was really close but I was using Array.filter() to filter out spaces. Instead of adding more and more filters, it turned out to be cleaner using a regex.
max77p
@max77p
Jun 14 2016 00:16
why am i getting long string of numbers on my page instead of the "page ids"
what i want to output is the
[ '26413',
'302672',
'11823138',
'13078006',
'13186767',
'20302096',
'41188263',
'49550482',
'49550503',
'49551399' ]
Ken Haduch
@khaduch
Jun 14 2016 00:17
@travishorn - yes, regex is definitely more straightforward!
John Calhoun
@DougCal
Jun 14 2016 00:18
I got 3 out of the 4 checks on this code. Not sure what I have to do. The check I don't got is "nextInLine([], 1) should return 1." https://gist.github.com/DougCal/3c50a7f2ec2a7b05b13496a263a4ef33
Ken Haduch
@khaduch
Jun 14 2016 00:21
@DougCal - you are a little "off" on your solution - your var first = arr[0]; is unnecessary. The instruction say something like Add the number (item) to the end of the array, then remove the first element of array. So you are trying to take something from the array without putting anything in. Get rid of the var first line; and you want to return the value that you're shifting out of the array.
Stephen James
@sjames1958gm
Jun 14 2016 00:23
@DougCal The key is the instruction say return the first item of the array, but that is after the instruction that says add to the end of the array
John Calhoun
@DougCal
Jun 14 2016 00:31
So in order to remove the first element, I wouldn't be shifting?
I'm having difficulties wrapping my head around this.
Stephen James
@sjames1958gm
Jun 14 2016 00:31
@DougCal arr.shift() removes AND returns the first value.
Ken Haduch
@khaduch
Jun 14 2016 00:35
@sjames1958gm @DougCal - arr.shift() doesn't really return the first value - you still need a return statement in there, don't you?
John Calhoun
@DougCal
Jun 14 2016 00:36
When I code 'return arr.shift();' after removing the var first = arr0 it seems to only return the second element. Was this what you were trying to tell me? @sjames1958gm
@khaduch
Ken Haduch
@khaduch
Jun 14 2016 00:37
@DougCal - can you please post your code now with the edits?
John Calhoun
@DougCal
Jun 14 2016 00:37
Sure

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

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

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

Ken Haduch
@khaduch
Jun 14 2016 00:38
@DougCal - you are doing two arr.shift() calls - you only need one.
Stephen James
@sjames1958gm
Jun 14 2016 00:38
@DougCal Now you have one too many shifts
Ken Haduch
@khaduch
Jun 14 2016 00:38
keep the one with the return
John Calhoun
@DougCal
Jun 14 2016 00:39
Got it! Thank you for the help @khaduch @sjames1958gm .
CamperBot
@camperbot
Jun 14 2016 00:39
dougcal sends brownie points to @khaduch and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1552 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 1312 | @khaduch |http://www.freecodecamp.com/khaduch
John Calhoun
@DougCal
Jun 14 2016 00:39

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

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

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

This was the code that worked.
Eden Coleman
@nede36
Jun 14 2016 00:41
I got the same as well @DougCal was working on it exactly when you were!
Stephen James
@sjames1958gm
Jun 14 2016 00:41
@DougCal Is it clear why this code meets the challenge requirements?
Ken Haduch
@khaduch
Jun 14 2016 00:42
@DougCal - correct - you are first adding the item to the end of the array, and then removing the item from the start of the array. So if there is nothing in the array to start with, you add it, then remove it. Just like a line in a bank teller - person comes in and gets in at the end of the line, the first person in the line goes to the teller. If there is no person in line, the person gets in the line, the next one to get serviced at a teller is the only person in the line.
Luis Ulua
@uluawebdev
Jun 14 2016 00:44


function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  if(str.substr() == target) {
   return true;
  } else {
    return false;
  }
  return str;
}

confirmEnding("Bastian", "n");
I am only getting the false right
Ken Haduch
@khaduch
Jun 14 2016 00:45
@uluawebdev - you need some argument for the str.substr() call - something that will get you the appropriate number of letters from the end of the str variable.
Check the information on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr for the values that can be passed to the substr method's parameters.
Chris Cullen
@123xylem
Jun 14 2016 00:47
Can I get some help on Arguments OPTIONAL Task... Why doesnt (2,3) return 5?
 function addTogether() 
{ var total=0; 
if(arguments[1]!==/[0-9]/){ return undefined; } 
else if(arguments[1]){ total=arguments[0]+arguments[1]; return total; }
 else if(!arguments[1]){ var sumTwoAnd=function addTogether(){ return sumTwoAnd()+addTogether(); }; }
 else{return undefined; } } 
addTogether(2,3);
Ken Haduch
@khaduch
Jun 14 2016 00:48
@123xylem - what do you get for an answer?
I don't know if you can do this: if(arguments[1]!==/[0-9]/) - I don't think that a regular expression is a valid value to put in that place?
Chris Cullen
@123xylem
Jun 14 2016 00:49
undefined but no display
undefined in chrome console nothing in fcc
Luis Ulua
@uluawebdev
Jun 14 2016 00:49
Thanks @khaduch , Must have missed something in the doc.
CamperBot
@camperbot
Jun 14 2016 00:49
uluawebdev sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1313 | @khaduch |http://www.freecodecamp.com/khaduch
Chris Cullen
@123xylem
Jun 14 2016 00:51
@khaduch u cant use regex in an if?
Moisés Man
@moigithub
Jun 14 2016 00:51
@123xylem probalby u should use functions like match or test
u could also use typeof
Chris Cullen
@123xylem
Jun 14 2016 00:52
@moigithub ive seen one answer that uses a function with typeofmethod... but
Ken Haduch
@khaduch
Jun 14 2016 00:52
@123xylem - I don't think you can, at least, I've never used it. I think that I used typeof in this solution, as @moigithub suggests.
Chris Cullen
@123xylem
Jun 14 2016 00:52
Theres no point in me just copying
John Calhoun
@DougCal
Jun 14 2016 00:52
@nede36 Glad I was able to help lol. @sjames1958gm I had to think about it a bit, but it does. It was like you said, arr.shift removes AND returns. I didn't realize I would have to do that under one line of code as oppose to 2 or 3. @khaduch thanks for the analogy. I appreciate it.
CamperBot
@camperbot
Jun 14 2016 00:52
dougcal sends brownie points to @nede36 and @sjames1958gm and @khaduch :sparkles: :thumbsup: :sparkles:
:warning: dougcal already gave khaduch points
:warning: dougcal already gave sjames1958gm points
:cookie: 187 | @nede36 |http://www.freecodecamp.com/nede36
Stephen James
@sjames1958gm
Jun 14 2016 00:52
@123xylem You can't use a regex on a number.
Sophia
@theothersophie
Jun 14 2016 00:52
Need help with javascript exercise Chunky Monkey
lmlanigan
@lmlanigan
Jun 14 2016 00:53
currently having trouble getting past the increment a number with javascript lesson
Sophia
@theothersophie
Jun 14 2016 00:53

```function chunkArrayInGroups(arr, size) {
// Break it up.
arr2d=[];

for (i=0;i<arr.length;i+=size) {
arr2d.push(arr.slice(i,size));
}

return arr2d;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
```

Luis Ulua
@uluawebdev
Jun 14 2016 00:53
use three ``` @theothersophie
Chris Cullen
@123xylem
Jun 14 2016 00:53
@sjames1958gm not disagreeing but that seems strange given they have a regex [0-9]...
Sophia
@theothersophie
Jun 14 2016 00:54
lol i added more ` and it didnt work
Chris Cullen
@123xylem
Jun 14 2016 00:54
Guess il have to use typeof method
Ken Haduch
@khaduch
Jun 14 2016 00:54
@lmlanigan - what have you got with it so far?
Moisés Man
@moigithub
Jun 14 2016 00:54
@123xylem probably u need to change that regex a bit...
/^[0-9]+$/.test(arguments[1]) <-- all numbers from start to finish.. many digits
Number(arguments[1]) <-- force to number
Stephen James
@sjames1958gm
Jun 14 2016 00:54
@theothersophie You are doing a,b b,c c,d you want a, b then c, d - you need to think about your loop increment and your first parameter to slice
@123xylem That regex is for matching numbers in strings.
Sophia
@theothersophie
Jun 14 2016 00:55
hm ok
lmlanigan
@lmlanigan
Jun 14 2016 00:55
I've got the myVar = myVar++; thing to get myVar to equal 88, but it still won't let me get past the screen
Sophia
@theothersophie
Jun 14 2016 00:55
testing
Stephen James
@sjames1958gm
Jun 14 2016 00:55
@lmlanigan look at the instructions and sample code do they have an = sign when using ++
lmlanigan
@lmlanigan
Jun 14 2016 00:55
There's a red X on the item "myVar = myVar should be changed"
Sophia
@theothersophie
Jun 14 2016 00:55
fgsdfgdfg
sdfgsg
Chris Cullen
@123xylem
Jun 14 2016 00:55
@sjames1958gm oooo ... is there a regex for different purposes then? I thought regex was a handy abbreviation for things in ALL of js
Stephen James
@sjames1958gm
Jun 14 2016 00:56
@123xylem Regexp is for parsing and analyzing strings.
lmlanigan
@lmlanigan
Jun 14 2016 00:56
There is an = sign on myVar = myVar++;
@sjames1958gm
Ken Haduch
@khaduch
Jun 14 2016 00:56
@lmlanigan - re-read the information in the lesson = something like i = i + 1 can be replaced by i++. You need to just change the line from using myVar = myVar + 1; to the same usage of the ++ operator as the little example I just gave here.
Stephen James
@sjames1958gm
Jun 14 2016 00:57
@lmlanigan IS there in the sample code
lmlanigan
@lmlanigan
Jun 14 2016 00:57
ah
let me go take a look...
Chris Cullen
@123xylem
Jun 14 2016 00:58
@sjames1958gm thanks ur right... il have to use typeof
CamperBot
@camperbot
Jun 14 2016 00:58
123xylem sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1553 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 14 2016 00:58
@123xylem Yeah, that appears to be the case
Moisés Man
@moigithub
Jun 14 2016 00:58
@123xylem its possible.. but typeof would be lot faster/performance
edselhans
@edselhans
Jun 14 2016 00:59
@khaduch Thank you so much! That is a wonderful explanation, I really appreciate your thoroughness. I had actually had posted the wrong version of the code before. The if (!tracks) version actually doesn't pass the tests. It was the version below that worked, in which I used if (!collection[id].tracks) in place of if (!tracks). Now I am wondering if if (!collection[id].hasOwnProperty("tracks") is better practice than if (!collection[id].tracks)? Is my code just working because of luck with the test suite?
function updateRecords(id, prop, value) {
  if (value) {
    if (prop === "tracks") {
      if (!collection[id].tracks) {
        collection[id].tracks = [];
      }
      collection[id].tracks.push(value);
    } else {
      collection[id][prop] = value;
    }
  } else {
    delete collection[id][prop];
  }
  return collection;
}
CamperBot
@camperbot
Jun 14 2016 00:59
edselhans sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1314 | @khaduch |http://www.freecodecamp.com/khaduch
Taylor
@tfreeman17
Jun 14 2016 01:00
Little help here...? Trying to Write Reusable JavaScript with Functions and I cannot get past the "Call reusableFunction after you define it" What does it mean my call?
Stephen James
@sjames1958gm
Jun 14 2016 01:00
@edselhans It would be clearer in intent to use hasOwnProperty() -
@tfreeman17 To call a function you use the name of the function followed by ()
Taylor
@tfreeman17
Jun 14 2016 01:02
Screen Shot 2016-06-13 at 7.01.26 PM.png
Stephen James
@sjames1958gm
Jun 14 2016 01:02
You can call or invoke this function by using its name followed by parentheses, like this:

functionName();
Moisés Man
@moigithub
Jun 14 2016 01:02
function sayHello(name){ console.log("hello "+name);} // <-- definition
sayHello("Moi"); //<--- calling
@tfreeman17
Jose Suarez
@Josexv1
Jun 14 2016 01:02
You sould do something like this
function myFunc(arg, arg1, arg2){
... code...
}
// to call your function do this
myFunc(1,"arg", 15);
Ken Haduch
@khaduch
Jun 14 2016 01:03
@tfreeman17 - when you define a function, you write something like function myFunction(arg1, arg2) { return arg1 + arg2; ) - then to call it in a program, you use the name myFunction with parentheses and pass the appropriate arguments. Like this: myFunction(3,5); which in my example would return the value 8.
Stephen James
@sjames1958gm
Jun 14 2016 01:03
If that doesn't help :)
Chris Cullen
@123xylem
Jun 14 2016 01:03
addTogether(2)(3).... Can you tell me what 3 is in this case? Arg 2?
Ken Haduch
@khaduch
Jun 14 2016 01:03
@tfreeman17 - you got three or four helpful answers.... good luck! :)
Jose Suarez
@Josexv1
Jun 14 2016 01:03
Yep, indeed.
Stephen James
@sjames1958gm
Jun 14 2016 01:04
@123xylem When addTogether is called with one argument, it returns a function then (3) is calling that returned function.'
@khaduch 3 or 4 - what are you saying, hmm :)
Taylor
@tfreeman17
Jun 14 2016 01:04
@khaduch thanks for the help try this again later. i'm feeling to dumb at the moment .
CamperBot
@camperbot
Jun 14 2016 01:04
tfreeman17 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1315 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Jun 14 2016 01:05
@123xylem - the first part of this addTogether(2)(3) is the case where you get one argument, so you return a function, which is then called with the next argument (3). It should return the answer.
@sjames1958gm - I wasn't sure if my answer was helpful... ;)
Stephen James
@sjames1958gm
Jun 14 2016 01:05
@khaduch LOL !
Chris Cullen
@123xylem
Jun 14 2016 01:05
@khaduch @sjames1958gm gotya.. this is the second part... ok il try figure out this
Ken Haduch
@khaduch
Jun 14 2016 01:06
@tfreeman17 - don't give up! :)
edselhans
@edselhans
Jun 14 2016 01:06
@sjames1958gm Thanks for the reply! Could you elaborate a little as to why if (!collection[id].hasOwnProperty("tracks") is better than if (!collection[id].tracks)?
CamperBot
@camperbot
Jun 14 2016 01:06
edselhans sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1554 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Taylor
@tfreeman17
Jun 14 2016 01:06
I'm not just might be done for the moment. not super focused to want to understand i'll revisit later.
Stephen James
@sjames1958gm
Jun 14 2016 01:07
@edselhans You want to test if there is a tracks property, IMO using hasOwnProperty more clearly expresses that intent. the ! version could mean that the property is there and falsey.
Ken Haduch
@khaduch
Jun 14 2016 01:07
@tfreeman17 - always good to take a break when you've been working on things for too long... enjoy! :)
Lam Pham
@lampham3110
Jun 14 2016 01:07

Hey, I'm having a problem with check palindrome, could anyone have a look at my code? Thank you!

function palindrome(str) {
var something = /[\W_]/g;
str = str.toLowerCase().replace(something,'');
var leng = str.length;
for(var i =0; i <= leng /2; i++){
if(str[i] === str[leng -1 -i]){
return true;
}
return false;
}
}

palindrome("almostomla");

edselhans
@edselhans
Jun 14 2016 01:08
@sjames1958gm Great point! Thank you so much for your help.
CamperBot
@camperbot
Jun 14 2016 01:08
edselhans sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: edselhans already gave sjames1958gm points
Luis Ulua
@uluawebdev
Jun 14 2016 01:08
function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  if(str.substr(-1) == target) {
   return true;
  } else if (str.substr() !== target){
    return false;
  }
  return str;
}

confirmEnding("Bastian", "n");
So now I'm only down to 2 check points left.
Stephen James
@sjames1958gm
Jun 14 2016 01:09
@uluawebdev Maybe use the length of target and not -1 ?
@uluawebdev Also, only true or false are supposed to be returned not str.
Luis Ulua
@uluawebdev
Jun 14 2016 01:12
@sjames1958gm Do you mean passing target.length as an argument for str.substr()?
Stephen James
@sjames1958gm
Jun 14 2016 01:12
@uluawebdev Possibly, you had a reason for -1, maybe that reasoning could be extended to target.length a more general solution
Luis Ulua
@uluawebdev
Jun 14 2016 01:13
I'll give it a try thanks @sjames1958gm
CamperBot
@camperbot
Jun 14 2016 01:13
uluawebdev sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1555 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Ares
@aresproject
Jun 14 2016 01:22
hi... any known issue on the Golf Code Challenge?
Stephen James
@sjames1958gm
Jun 14 2016 01:22
no
Ares
@aresproject
Jun 14 2016 01:23
im kinda stuck on the Golf code challenge... running my solution on codepen seems correct though
Stephen James
@sjames1958gm
Jun 14 2016 01:24
You can post your code here and get assistance.
Ares
@aresproject
Jun 14 2016 01:25
ok hold on
troyc12
@troyc12
Jun 14 2016 01:25
Hello everybody, I'm having trouble with printing out my statement with Counting Cards challenge.
var count = 0;

function cc(card) {
  // Only change code below this line
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count+=1;
      break;

    case 7:
    case 8:
    case 9:
      count+=0;
      break;

    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
      count-=1;
      break; 

  }

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Ares
@aresproject
Jun 14 2016 01:28
This message was deleted
troyc12
@troyc12
Jun 14 2016 01:29
you forgort your back ticks @aresproject
Ares
@aresproject
Jun 14 2016 01:29
bac ticks?
troyc12
@troyc12
Jun 14 2016 01:30
backticks (```)
Chris Cullen
@123xylem
Jun 14 2016 01:31

function addTogether() {
  var total=0; 
  if(typeof arguments[1]!=="number"||typeof arguments[0]!=="number" ){
     return undefined;
   }
 else if(typeof arguments[1]==="number"){
    total=arguments[0]+arguments[1];
    return total;
  }
 else if(arguments.length<2){
   var sumTwoAnd=function(a){
     return addTogether()+a;
   };

 }
  else{return undefined;

  }
}

addTogether(2,3);
In this code is the problem that my addTogher function is unnaccesible from within?
Ares
@aresproject
Jun 14 2016 01:32
test
test
function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes === 1) {
    return "Hole-in-one!";
  }
  else if (strokes <= par -2) {
    return "Eagle";
  }
  else if (strokes === par -1) { 
    return "Birdie";
  }
  else if (strokes === par) {
    return "par";
  }
  else if (strokes === par + 1) {
    return "Bogey";
  }
  else if (strokes === par + 2) {
    return "Double Bogey";
  }
  else if (strokes >= par + 3) {
    return "Go Home";
  }
  else return "Change Me";

  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
@troyc12 is this it?
can't seem to evaluate properly the "par" and "go home" conditions for the Golf Code Challenge
Joseph
@revisualize
Jun 14 2016 01:37
@troyc12 Where is your return statement?
Jesus Vega
@ParagonChuy
Jun 14 2016 01:40
help smallest common multiple
CamperBot
@camperbot
Jun 14 2016 01:40

:point_right: algorithm smallest common multiple [wiki]

Algorithm Smallest Common Multiple

Explanation:

The smallest common multiple between two numbers is the smallest number that both numbers can divide into. This concept can be extended to more than two numbers as well.

We can first start with just finding the smallest common multiple between two numbers. Naively, you can start writing out multiple of each number until you write a multiple that exists from both numbers.

An example would be the numbers 3 and 4. The multiples of 3 are 3, 6, 9, 12, 15, 18, ... and the multiples of 4 are 4, 8, 12, 16, 20, .... The first smallest number we run into in both lists is 12 so this is the smallest common multiple between 3 and 4.

This problem can be confusing because most people look for the smallest common multiple of just the two numbers but forget the keyword range. However, this means that if you are given [1,5], then you have to check for the smallest common multiple for all the numbers [1,2,3,4,5] that is evenly divisible by all of them.

:pencil: read more about algorithm smallest common multiple on the FCC Wiki

Joseph
@revisualize
Jun 14 2016 01:40
@aresproject You're using the wrong text.
golfScore(5, 5) should return "Par"
golfScore(4, 7) should return "Go Home!"
@aresproject You don't have the capital P or the ! at the end.
silver537
@silver537
Jun 14 2016 01:41
I FINALLY UNDERSTOOD THE ALGORITHM CHALLENGE "FALSY BOUNCER"
i swear it was annoying.
Jesus Vega
@ParagonChuy
Jun 14 2016 01:41
YO
that took me forever!
silver537
@silver537
Jun 14 2016 01:42
such a dumbass answer since the descriptiong for the "Boolean()" object is confusing.
Chipi
@Chipsta
Jun 14 2016 01:43
hi There im having trouble with 193 golf challenge
Ares
@aresproject
Jun 14 2016 01:43
@revisualize, holy smokes! did'nt notice that... thanks man LOL
CamperBot
@camperbot
Jun 14 2016 01:43
aresproject sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1259 | @revisualize |http://www.freecodecamp.com/revisualize
Chipi
@Chipsta
Jun 14 2016 01:43

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

if (strokes<=1) {
return "Hole-in-one!";

} else if (strokes<=par-2) {
return "Eagle";

}else if (strokes >= par+3) {
return "Go Home!";

}else if (par) {
return "Par";

}else if (par-1) {
return "Birdie" ;

}else if (par+1) {
return "Bogey";

} if (par+2) {
return "Double Bogey";

} else if (par-1) {
return "Birdie" ;

}

// Only change code above this line
}

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

golfScore(4, 3) should return "Birdie"
golfScore(4, 5) should return "Bogey"
golfScore(4, 6) should return "Double Bogey"
silver537
@silver537
Jun 14 2016 01:44

change

}else if (par) {
return "Par";

to equal stroke in your statement

@Chipsta
Chipi
@Chipsta
Jun 14 2016 01:47
@silver537 im not sure by what you mean to change? }else if (par) {
return "Par"; That is what i have.
Diego Mayer
@Chrono79
Jun 14 2016 01:48
@Chipsta } else if (strokes == par) {
you're evaluating strokes in all cases
silver537
@silver537
Jun 14 2016 01:48
well nvm.. he gave you the answer.
Chipi
@Chipsta
Jun 14 2016 01:51
@Chrono79 thanks
CamperBot
@camperbot
Jun 14 2016 01:51
chipsta sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1141 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 14 2016 01:51

@Chipsta

if (strokes<=1) {
return "Hole-in-one!";

although it works, it's not logic, how can you make a hole in one with 0 or -1 strokes? ;)

Chipi
@Chipsta
Jun 14 2016 01:56
thank you guys
Chris Cullen
@123xylem
Jun 14 2016 01:57
function addTogether() {
  var total=0; 
  if(typeof arguments[1]!=="number"||typeof arguments[0]!=="number" ){
     return undefined;
    //FIrst see if args are not numbers- if so return undefined
   }
  if(typeof arguments[1]==="number"){
    total=arguments[0]+arguments[1];
    return total;
//NEXT see if arg2 is a number. if so it exists so return it added to arg1
  }
  if(arguments.length<2){
 //if theres only 1 arg    
    var a=arguments[0];

    if(typeof a!=="number"){
 //and its not a number return undefined
      return undefined;}

    else{
    return function(b){
  //Use this function which looks at an arg
      if(typeof b!=="number"){
        return undefined;
  //if that arg isnt a number again undefined
      }
    else  return a+b;
 //otherwise add it to arg1
     };   }   }   }
addTogether(2)(3);
This is saying addtogether not a function. Is it something to do with closures?
Rory Avant
@roryavant8
Jun 14 2016 02:02
Hi all, I've worked relentlessly on the permutations bonfire. I am wondering if you guys struggled with this problem as much as I am. Just can't seem to figure it out.
Diego Mayer
@Chrono79
Jun 14 2016 02:03
@123xylem you have only 1 argument, you return undefined, and undefined(3) is not a function
Chris Cullen
@123xylem
Jun 14 2016 02:03
@Chrono79 ahh
Stephen James
@sjames1958gm
Jun 14 2016 02:05
@123xylem make sure your tests are in the right order. Don't check arguments1 before checking length of arguments
@roryavant8 I left that one for last it was a real challenge figuring out how to generate the permutations
Chris Cullen
@123xylem
Jun 14 2016 02:07
@Chrono79 @sjames1958gm yep thanks... i need to sort out the order on these ifs
CamperBot
@camperbot
Jun 14 2016 02:07
123xylem sends brownie points to @chrono79 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1142 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 1556 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
edselhans
@edselhans
Jun 14 2016 02:13
This message was deleted
Rory Avant
@roryavant8
Jun 14 2016 02:14
@sjames1958gm yea man that's what I am struggling with right now.
Chris Cullen
@123xylem
Jun 14 2016 02:17
function addTogether() {
  var total=0; 
    if(typeof arguments[1]==="number"){
    total=arguments[0]+arguments[1];
    return total;
//NEXT see if arg2 is a number. if so it exists so return it added to arg1
  }

   if(arguments.length<2){
 //if theres only 1 arg    
    var a=arguments[0];

    if(typeof a!=="number"){
 //and its not a number return undefined
      return undefined;}

    else{
    return function(b){
  //Use this function which looks at an arg
      if(typeof b==="number"){
        return a+b;
      }

  if(typeof arguments[1]!=="number"||typeof arguments[0]!=="number" ){
     return undefined;
    //FIrst see if args are not numbers- if so return undefined
   }

 //otherwise add it to arg1
     };   }   }   }
addTogether(2)(3);
I just aced this in record time... Thanks to
@sjames1958gm @Chrono79 @khaduch
:)
Stephen James
@sjames1958gm
Jun 14 2016 02:18
@123xylem :+1:
Tony Johnson
@tnyjhnsn
Jun 14 2016 02:32
Hooray!!! The penny just dropped about using map as an elegant solution to replace for array for loop!!!
function largestOfFour(arr) {
  var newArr = [];
  arr.map(function(val) {
    newArr.push(Math.max.apply(null, val));
  });
  return newArr;
}
Noremak
@Noremak
Jun 14 2016 02:38
This message was deleted
This message was deleted
This message was deleted
CamperBot
@camperbot
Jun 14 2016 02:39
:bulb: to format code use backticks! ``` more info
Noremak
@Noremak
Jun 14 2016 02:40
function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes >= par + 3) {
    return "Go Home!";
  } else if (strokes == par + 2) {
    return "Double Bogey";
  } else if (strokes == par + 1) {
    return "Bogey";
  } else if (strokes == par) {
    return "Par";
  } else if (strokes == par - 1) {
    return "Birdie";
  } else if (strokes <= par - 2) {
    return "Eagle";
  } else (strokes == 1) 
    return "Hole-in-one!";

  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
Diego Mayer
@Chrono79
Jun 14 2016 02:40

@Noremak you're missing the if here:

} else (strokes == 1)

You can also edit or delete your own posts clicking in the ... at the right of the post time

Noremak
@Noremak
Jun 14 2016 02:42
I added the iff there. It goes through all the checks except for these two: golfScore(1, 1) should return "Hole-in-one!"
golfScore(4, 1) should return "Hole-in-one!"
Diego Mayer
@Chrono79
Jun 14 2016 02:42
@Noremak reorder your ifs
Stephen James
@sjames1958gm
Jun 14 2016 02:43
@Noremak when I play golf I always check my holes in one first
Noremak
@Noremak
Jun 14 2016 02:43
Okay thanks. Did it backwards!
Stephen James
@sjames1958gm
Jun 14 2016 02:44
It's a case of more specific tests first
Noremak
@Noremak
Jun 14 2016 02:45
Thanks. I read this line in the instructions wrong: "Return the correct string according to this table which lists the strokes in order of priority; top (highest) to bottom (lowest):"
ALMY91
@ALMY91
Jun 14 2016 03:15
Hi guys
need some help here
var o ={ p:1 };  

function printprops(o){
for(var p in o)
console.log(p + ": " + o[p]+"\n");
}

console.log(printprops(o));
for my last line im getting an undefined in my console log
and of course a p: 1 for my first consolelog in my code
however if i rid of the last line
nth appears in my console.log
am i doing smth wrong here?
Otto Vogrincic
@ovogrin
Jun 14 2016 03:17
Hello everyone,
I'm having issues with the first basic algorithm scripting, reversing a string. My code seems to be working but it doesn't mark me correct. Could anyone tell me what is wrong with my code? var string="";
function reverseString(str) {
for(var i=str.length -1; i>=0; i--){
string = string + str.charAt(i);
}
return string;
}
reverseString("Greetings from Earth");
Donovan
@dnvn999
Jun 14 2016 03:24
Hi guys, can anyone help me in Make Object Properties Private? My codes are below,
var Bike = function(getGear, setGear) {

  // Only change code below this line.
  Bike.gear = 6;
  this.getGear = getGear;
  this.setGear = setGear;
};

var myCar = new Car();

var myBike = new Bike();
Sanzhar Askaruly
@askaruly
Jun 14 2016 03:25
Hi
I am stuck with Title Case a Sentence
Here is my code:

function titleCase(str) {
var splits = str.split(" ");
for (var i=0; i<splits.length; i++) {
splits[i].toLowerCase();
splits[i].charAt(0).toUpperCase();
return splits[i];
}

}

silver537
@silver537
Jun 14 2016 03:29
use the slice, to return the first letter, then uppcase it, then push it into a another slice of the first letter.
Tony Johnson
@tnyjhnsn
Jun 14 2016 03:30
@dnvn999 you only need to declare your variable without the “this”
  // Only change code below this line.
  var gear;
Gregory Garzon
@chibieee
Jun 14 2016 03:32
@ovogrin can you tell us which of the 4 tests you are failing?
Donovan
@dnvn999
Jun 14 2016 03:33
@tony-tosp like this, am I doing it right for the improvement?
var Bike = function(setGear) {

  // Only change code below this line.
  var gear = 6;
  this.getGear = function() {
    return this.setGear;
  };

  this.setGear = function() {
    return setGear;
  };
};

var myCar = new Car();

var myBike = new Bike();
Otto Vogrincic
@ovogrin
Jun 14 2016 03:34
@chibieee all of them, although the return statements are all correct
Donovan
@dnvn999
Jun 14 2016 03:35
@tony-tosp i still cant fulfill the last 3 requirements.
Gregory Garzon
@chibieee
Jun 14 2016 03:36
@ovogrin i just copy pasted your code in the console, and everytime i ran it, it kept adding on the string input
@ovogrin try putting var string = ""; inside your function, instead of it being a global variable
Otto Vogrincic
@ovogrin
Jun 14 2016 03:38
@chibieee it worked, thank you!
CamperBot
@camperbot
Jun 14 2016 03:38
ovogrin sends brownie points to @chibieee :sparkles: :thumbsup: :sparkles:
:cookie: 307 | @chibieee |http://www.freecodecamp.com/chibieee
Tony Johnson
@tnyjhnsn
Jun 14 2016 03:38
that’s better. The gear property should initaly be nothing and adjust your setGear function to receive an argument that you set the gear to be.
@dnvn999 the setGear doeasn’t return anything… it sets the value of gear to be the arguent you pass to it
Gregory Garzon
@chibieee
Jun 14 2016 03:40
@ovogrin no problem
Tony Johnson
@tnyjhnsn
Jun 14 2016 03:40
@dnvn999 also, your getGear function shouldn’t return setGear.. it should return gear.
Chris Cullen
@123xylem
Jun 14 2016 03:41

function addTogether() {
  var total=0; 
    if(typeof arguments[1]==="number"){
    total=arguments[0]+arguments[1];
    return total;
    }

   if(arguments.length<2){
    var a=arguments[0];

    if(typeof a!=="number"){
      return undefined;}

    else{ // CAN YOU HELP ME WITH THIS FUNCTION? How does it know b is the second ()() of addTogether?
    return function(b){
      if(typeof b==="number"){
        return a+b;
      }

  if(typeof arguments[1]!=="number"||typeof arguments[0]!=="number" ){
     return undefined;
   }
     };   }   }   }
addTogether(2)(3);
Help on the functon
CamperBot
@camperbot
Jun 14 2016 03:41
no wiki entry for: on the functon
Chris Cullen
@123xylem
Jun 14 2016 03:41
How does the function in the midle know what b is?
bitgrower
@bitgrower
Jun 14 2016 03:42
This message was deleted
This message was deleted
dickorydock
@dickorydock
Jun 14 2016 03:44
The wikipedia API project is so hard--CORS requests make my head spin
Donovan
@dnvn999
Jun 14 2016 03:45
Thanks @tony-tosp, I passed the challenge although it is hard to grasp initially :D
CamperBot
@camperbot
Jun 14 2016 03:45
dnvn999 sends brownie points to @tony-tosp :sparkles: :thumbsup: :sparkles:
:cookie: 256 | @tony-tosp |http://www.freecodecamp.com/tony-tosp
Tony Johnson
@tnyjhnsn
Jun 14 2016 03:46
@dnvn999 yw
bitgrower
@bitgrower
Jun 14 2016 03:49
@123xylem what is the name of that challenge ?
Adam Palmer
@adam-palmer
Jun 14 2016 03:51
Hey guys, I just started the Javascript section and was wondering if someone could take a quick look at my code for the 'Convert Celsius to Fahrenheit" challenge. I made it very short but was wondering if for best practice I should have created another variable rather than used celsius again?
This message was deleted

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
celsius *= 1.8;
fahrenheit = celsius + 32;

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

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

Norvin Burrus
@ndburrus
Jun 14 2016 03:52
@123xylem note: ReferenceError: b is not defined
Chris Cullen
@123xylem
Jun 14 2016 03:52
@bitgrower @ndburrus its arguments optional
@ndburrus the code works norvin
but I dont know how when b is not defined
HIKALU
@HIKALU-Z
Jun 14 2016 03:53

hey guys in challenge Stand in Line
my code is


function nextInLine(arr, item) {
  // Your code here
  arr=[];
  arr.push(item);
  arr.unshift();
  return arr[0];  // Change this line
}

// Test Setup
var testArr = [5,6,7,8,9];

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

what's wrong with this code

Norvin Burrus
@ndburrus
Jun 14 2016 03:53
@123xylem that's correct - the code works. if i console.log b, that is the output :) answer: the function does not know what b is, thus the "not defined" message. since b is not used by the code, it doesn't worry (or complain) about it..
Chris Cullen
@123xylem
Jun 14 2016 03:54
@ndburrus right.. my question is how does the function know what b is?
Norvin Burrus
@ndburrus
Jun 14 2016 03:55
@adam-palmer as far as typing, one line of code reduces duplicate typing of celsius (and assignment/s)... :+1:
Adam Palmer
@adam-palmer
Jun 14 2016 03:57
@ndburrus thanks buddy! I thought maybe the function part at the top might mean that I duplicated but I was just over complicating things in my head :P
CamperBot
@camperbot
Jun 14 2016 03:57
adam-palmer sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 544 | @ndburrus |http://www.freecodecamp.com/ndburrus
ddurkee1
@ddurkee1
Jun 14 2016 03:58
hello can someone tell me why this is not returning "apple" for "a" passed to the function. Please and thank you!
silver537
@silver537
Jun 14 2016 03:58
@HIKALU-Z you're returning the whole array instead of the value.
ddurkee1
@ddurkee1
Jun 14 2016 03:58

switch (val) {
case 1:
answer="apple";

    answer = "apple";

break;

case 2:

    answer = "bird";

break;

case 3:

    answer = "cat";

break;

default: answer = "stuff";

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

Norvin Burrus
@ndburrus
Jun 14 2016 03:59
@adam-palmer a case can be made for organizing the code that way (it depends on the perspective)... you're welcome! :sparkles:
@ddurkee1 which hallenge is this?
ddurkee1
@ddurkee1
Jun 14 2016 03:59
adding a default option in switch statements
switch (val) {
case 1:
answer="apple";
    answer = "apple";

break;

case 2:

    answer = "bird";

break;

case 3:

    answer = "cat";
silver537
@silver537
Jun 14 2016 04:00
@ddurkee1 cause you're checking numbers instead of letters?
ddurkee1
@ddurkee1
Jun 14 2016 04:01
i don't know, but the image i am trying to paste in the box here is not what is pasting top the screen.
Chris Cullen
@123xylem
Jun 14 2016 04:01
@ndburrus it uses b sometimes though norvin
Norvin Burrus
@ndburrus
Jun 14 2016 04:01
Chris Cullen
@123xylem
Jun 14 2016 04:01
in the case that i showed u it adds 2+3
HIKALU
@HIKALU-Z
Jun 14 2016 04:01

@silver537 so what shou i do?

return arr.unshift();

i code like this it is still wrong

ddurkee1
@ddurkee1
Jun 14 2016 04:01
yes i have tried "a" and "b" and "c"
as the cases but still not working
Norvin Burrus
@ndburrus
Jun 14 2016 04:01
@123xylem hmmm... moment... ok, i see - function happens as a condition. when it is needed/executed, a parameter is passed to it (that parameter is b)... so it gets what it needs, if/when it is needed/used... make sense? i console.logged it, but it was not needed for the use/test case present... thus, it was undefined...
Sam Snyder
@MassNerdy
Jun 14 2016 04:02
Quick question. I'm on the "Nesting For Loops" challenge. I got a warning that I might have a continuous loop, but to enter "// noprotect" if I wanted to continue. Well, I made a dumb mistake and entered it, and now anytime I try to refresh FreeCodeCamp, it opens up to the challenge and immediately gets stuck in an infinite loop. Any suggestions on how to fix so I can debug?
silver537
@silver537
Jun 14 2016 04:02
@HIKALU-Z @ddurkee1 can you paste the name of the challenge so i can further help you humans?
HIKALU
@HIKALU-Z
Jun 14 2016 04:03
changllange name Stand in Line maybe i am not understand the target
Norvin Burrus
@ndburrus
Jun 14 2016 04:04
@MassNerdy this may be useful: pradeepce/fcc-wiki
bitgrower
@bitgrower
Jun 14 2016 04:05
@123xylem the calling function looks for an argument on the stack ... so, when you return the function, the calling function executes it, and the calling function will pluck the next value off the stack ... (I thought you were asking about the other argument) ... however, in your returning function, you still need to determine whether the value is undefined, a number, etc ...
if you look at the particular test cases run against it, you will see where there's an extra value after the function call on some of them ... that's where the function you returned gets that value .. it doesn't just disappear ... :)
ddurkee1
@ddurkee1
Jun 14 2016 04:07

function switchOfStuff(val) {
var answer = "";

// Only change code below this line

switch (val) {
case a:
answer="apple";

    answer = "apple";

break;

case 2:

    answer = "bird";

break;
Chris Cullen
@123xylem
Jun 14 2016 04:08
@bitgrower SO THE function just says... addTogether (2) is taken so il look for antother arg.. O look heres AddTogether ()(3). Il use that?
in computer accent
silver537
@silver537
Jun 14 2016 04:08
@HIKALU-Z you're not supposed to unshift
Gregory Garzon
@chibieee
Jun 14 2016 04:09
@ddurkee1 a should be in quotes, so it should be case "a":
Norvin Burrus
@ndburrus
Jun 14 2016 04:09
@HIKALU-Z ensure you have the right method for this: then remove the first element of array.
Chris Cullen
@123xylem
Jun 14 2016 04:10
@bitgrower the code works btw just wanted to clarify how the function knew where to take (b) from
silver537
@silver537
Jun 14 2016 04:10
@HIKALU-Z The nextInLine function should then return the element that was removed.
ddurkee1
@ddurkee1
Jun 14 2016 04:11
that still does not work "a" or for case "b": same for case "c".
Norvin Burrus
@ndburrus
Jun 14 2016 04:11
@ddurkee1 carefully review the format/syntax of the switch statement:
switch (num) {
  case value1:
    statement1;
    break;
  case value2:
    statement2;
    break;
...
  default:
    defaultStatement;
}
Sam Snyder
@MassNerdy
Jun 14 2016 04:11
@ndburrus I'm trying to run "https://www.freecodecamp.com/challenges/nesting-for-loops#?run=disabled" but it doesn't seem to be working. Any thoughts?
ddurkee1
@ddurkee1
Jun 14 2016 04:12
yes i have that code as well
Sam Snyder
@MassNerdy
Jun 14 2016 04:12
@ndburrus got it! Thanks so much for pointing me the WIKI (bookmarking)
CamperBot
@camperbot
Jun 14 2016 04:12
massnerdy sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 545 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jun 14 2016 04:13
@ddurkee1 alright, are you following the formatting for the exercise? here: "a" - "apple" "b" - "bird" "c" - "cat" default - "stuff"
@MassNerdy you bet! anytime... everything up & running? :fire:
Sam Snyder
@MassNerdy
Jun 14 2016 04:14
Yeah thank goodness. I was starting to panic 😅
silver537
@silver537
Jun 14 2016 04:14
@ddurkee1 paste your whole code without the back ticks
you did something wrong while pasting it so it looks very confusing.
Norvin Burrus
@ndburrus
Jun 14 2016 04:14
@MassNerdy ...absolutely no panicking allowed... :+1:
ddurkee1
@ddurkee1
Jun 14 2016 04:15

function switchOfStuff(val) {
var answer = "";

// Only change code below this line

switch (val) {

 case "a":
    answer="apple";
break;

 case "b":
    answer = "bird";
break;

 case "c":
    answer = "cat";
break;

 default: answer = "stuff";

// Only change code above this line
return answer;

this has been tried...
Sam Snyder
@MassNerdy
Jun 14 2016 04:15
It was bombing out on the second line of this loop...trying to figure out why it was going on infinitely @ndburrus
for (var i = 0; i < arr.length; i++) {
    for (var j = 0; i < arr[i].length; j++) {
      product *= arr[i][i];
    }
  }
silver537
@silver537
Jun 14 2016 04:16
oh i hope it really doesnt matter. but i think the indenting is what's wrong.
you also don't have the } at the end of your switch and your function
Norvin Burrus
@ndburrus
Jun 14 2016 04:18
@HIKALU-Z how are we doing? @ddurkee1 hmmm... moment
ddurkee1
@ddurkee1
Jun 14 2016 04:19
@ndburrus did you see the last post. I have tried to no avail.
dickorydock
@dickorydock
Jun 14 2016 04:20
Can someone help me figure out this error in the Wikipedia API project? $(document).ready(function(){ console.log("this is the before message."); $.ajax({url: "https://en.wikipedia.org/w/api.php?action=query&format=json&list=search&utf8=1&srsearch=Albert+Einstein", success: function(result){ console.log('it worked!'); console.log(result); }, error: function(result){console.log("oh no, it failed.");} }); console.log("this is the after message"); });
oh sorry, line breaks, one sec

  console.log("this is the before message.");

  $.ajax({url: "https://en.wikipedia.org/w/api.php?action=query&format=json&list=search&utf8=1&srsearch=Albert+Einstein", success: function(result){

    console.log('it worked!');

        console.log(result);

    }, error: function(result){console.log("oh no, it failed.");} 

  });

  console.log("this is the after message");

});
ddurkee1
@ddurkee1
Jun 14 2016 04:21

function switchOfStuff(val) {
var answer = "";

// Only change code below this line

switch (val) {

 case 0:
   if(val === "a")
     {
       answer="apple";
     }

break;
Norvin Burrus
@ndburrus
Jun 14 2016 04:21
@ddurkee1 do you have this piece? return answer;
} ? i don't see it in the code...
ddurkee1
@ddurkee1
Jun 14 2016 04:21
this does not work either
Sam Snyder
@MassNerdy
Jun 14 2016 04:21
nm got it @ndburrus I was using [i] instead of [j] to reference the subarray
dickorydock
@dickorydock
Jun 14 2016 04:21
and the error: MLHttpRequest cannot load https://en.wikipedia.org/w/api.php?action=query&format=json&list=search&utf8=1&srsearch=Albert+Einstein. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://dickorydock.github.io' is therefore not allowed access.
Norvin Burrus
@ndburrus
Jun 14 2016 04:22
@MassNerdy ok, great work :+1:
ddurkee1
@ddurkee1
Jun 14 2016 04:22
i don't need to return. The switch statement works and is returning the default case, which has no return statement.
bitgrower
@bitgrower
Jun 14 2016 04:23

@123xylem -- it's a little geeky ... let's take this call ...

addTogether(2)(3)

addTogether(2) -- because of the parens, 2 is the 1 and only parameter passed to addTogether ... that leaves the (3) sitting on the stack ...

So,, when the function which called addTogether gets the function you return, THAT function is looking for a parameter ... guess what... it finds the 3, so the parameter b takes on the value of 3 ... that's where it finds it ...

HIKALU
@HIKALU-Z
Jun 14 2016 04:25
remove the first element of array. The nextInLine function should then return the element that was removed.
then i use arr.shift(); is it wrong?
return arr.shift();
ddurkee1
@ddurkee1
Jun 14 2016 04:25
@ndburrus Geez. No return statement. Noobses. Thank you!
CamperBot
@camperbot
Jun 14 2016 04:25
ddurkee1 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 547 | @ndburrus |http://www.freecodecamp.com/ndburrus
silver537
@silver537
Jun 14 2016 04:25

@ddurkee1

ahhh i see the problem. thats a tricky one.

delete all the comments and you'll probably see what you have to do.
im not telling you since it's an important aspect of 'debugging'
but ill give you a hint, your switch statement is not closed.
ALMY91
@ALMY91
Jun 14 2016 04:26
Need some help here
is anybody there...
silver537
@silver537
Jun 14 2016 04:27
@ddurkee1 oh never mind. i see you got it.
ha
ALMY91
@ALMY91
Jun 14 2016 04:27
????
Norvin Burrus
@ndburrus
Jun 14 2016 04:27
@ddurkee1 i was referring to the code after: // Only change code above this lineexcellent work, watson :)
silver537
@silver537
Jun 14 2016 04:29
@HIKALU-Z lets see your updated code.
@ALMY91 post the name of the challenge and your code
HIKALU
@HIKALU-Z
Jun 14 2016 04:30

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

  return arr.shift();  // Change this line
}
Norvin Burrus
@ndburrus
Jun 14 2016 04:30
@HIKALU-Z shift would be the right method....
stephaniegon
@stephaniegon
Jun 14 2016 04:30

var myVar = 87;

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

Understanding Boolean Values

HIKALU
@HIKALU-Z
Jun 14 2016 04:30
@ndburrus yes i use shift
but it didn't pass
GGvibes
@GGvibes
Jun 14 2016 04:32
@HIKALU-Z you are close, there's something extra that you don't need there. (You need the push and shift methods)
Norvin Burrus
@ndburrus
Jun 14 2016 04:33
@HIKALU-Z can you are erasing the inputted arr/ay! clear as mud?
GGvibes
@GGvibes
Jun 14 2016 04:34
I know that something is wrong in my lookup table but I can't figure out what..Can somebody help me this is the "Using objects for Lookups" problem.
Here's my code:
silver537
@silver537
Jun 14 2016 04:34
you're declaring a new arr. you don't need it.
GGvibes
@GGvibes
Jun 14 2016 04:34
// Setup
function phoneticLookup(val) {
  var result = "";

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

  lookup[val] = result;
  // Only change code above this line
  return result;
}

// Change this value to test
phoneticLookup("charlie");
silver537
@silver537
Jun 14 2016 04:35
@GGvibes reverse
lookup[val] = result;
Norvin Burrus
@ndburrus
Jun 14 2016 04:35
@GGvibes carefully review here: var lookup(val) = { compare to sample code format/syntax
GGvibes
@GGvibes
Jun 14 2016 04:35
yes @ndburrus that is where it's telling me I have a problem
bitgrower
@bitgrower
Jun 14 2016 04:37
@GGvibes -- you also have a problem in the lookup[val] = result; statement ... you have the right components ... but it's backward ...
GGvibes
@GGvibes
Jun 14 2016 04:38
ok @bitgrower I fixed that thank you, I'm not sure where to look for an example of the beginning statement defining the table
CamperBot
@camperbot
Jun 14 2016 04:38
ggvibes sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1099 | @bitgrower |http://www.freecodecamp.com/bitgrower
Norvin Burrus
@ndburrus
Jun 14 2016 04:38
@stephaniegon is that the right exercise name?
silver537
@silver537
Jun 14 2016 04:40
its like no one is listening to me. -.-
Norvin Burrus
@ndburrus
Jun 14 2016 04:40
@GGvibes you didn't address the previous items mentioned...
GGvibes
@GGvibes
Jun 14 2016 04:41
@silver537 I saw your comment! still working on the same problem..
figured it out, thanks ya'll!
@ndburrus thanks
CamperBot
@camperbot
Jun 14 2016 04:44
ggvibes sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 549 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jun 14 2016 04:45
@GGvibes nice work! :+1:
@stephaniegon did you resolve it?
mayankmohan1992
@mayankmohan1992
Jun 14 2016 04:59

'' function largestOfFour(arr) {
// You can do this!
var biggest=[];
var bigger=0;
var len=arr.length;
for (var i=0;i<=len;i++)
{

  for (var j=0;j<=3;j++)
    {
      if (arr[i][j]>arr[i][j+1])
      {bigger =arr[i][j];}
      else {bigger= arr[i][j+1];}
    }
 biggest.push(bigger);

}

return biggest;
}

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

not able to get thru this exercise
plz help
getting error msg " arr[i] is undefined"
Alan Tsai
@ypt3
Jun 14 2016 05:01
Please help me to identify the bug in this code.

function stateLoop() {
if (info.available) {
// this is important!
doImportantThing();
}
checkAndUpdateStep(info);
var current = { step: info.step, available: info.available };
actOnCurrentState(current);
setTimeout(stateLoop,500);
}

var info = { step: 'start', available: false };
stateLoop();

Drew Stonebraker
@drstonebraker
Jun 14 2016 05:04

I am trying to use isotope.js for the first time (hardly ever used plugins before) in a codepen. I looked on their website and it seemed so utterly simple to use:

$('.grid').isotope({
  itemSelector: '.grid-item',
  layoutMode: 'fitRows'
});

I did that and have since spent hours upon hours trying to figure out why it wouldn't work. After what seems like a few hours into it, I eventually decided to take a working demo of isotope and replace code line by line to see what part of my code was the problem. I have now literally replaced every line of code... literally copied and pasted the entire HTML, CSS, and JS files from the working pen to my pen or vice-versa, and my pen is still not working, while the other one, which as far as I can tell is an exact replica line-by-line, is working. I cannot find anything in the settings of the two that are different, either. Clearly there is something I don't know about that it seems like I need to know about... some difference somewhere that I don't know where to look, but what could it be?

@mayankmohan1992 you still there? can you repost your entire code, making sure it is formated correctly for the chat?
Drew Stonebraker
@drstonebraker
Jun 14 2016 05:11
@ypt3 which challenge are you on?
Alan Tsai
@ypt3
Jun 14 2016 05:12
this is a personal challenge not on the free code camp platform
Drew Stonebraker
@drstonebraker
Jun 14 2016 05:12
@ypt3 ok i will look.
Alan Tsai
@ypt3
Jun 14 2016 05:12
thnx @Stoney229
CamperBot
@camperbot
Jun 14 2016 05:12
ypt3 sends brownie points to @stoney229 :sparkles: :thumbsup: :sparkles:
:cookie: 290 | @stoney229 |http://www.freecodecamp.com/stoney229
Alan Tsai
@ypt3
Jun 14 2016 05:13
its a little tricky
Drew Stonebraker
@drstonebraker
Jun 14 2016 05:13
@ypt3 have you defined checkAndUpdateStep?
Alan Tsai
@ypt3
Jun 14 2016 05:16
yeah didn't define checkAndUpdateStep, actOnCurrentState
Drew Stonebraker
@drstonebraker
Jun 14 2016 05:17
@ypt3 is that the source of your problem, or were you having trouble with something else?
Alan Tsai
@ypt3
Jun 14 2016 05:17
I am not too sure if that is really the solution that's why I ask lol
Drew Stonebraker
@drstonebraker
Jun 14 2016 05:18
i don't understand what you're trying to do. what behavior are you expecting and what are you getting instead?
what is breaking?
Alan Tsai
@ypt3
Jun 14 2016 05:18
so my friend showed me his question sheet, and that is one of the question
  1. Please identify the bug in this code.

function checkAndUpdateStep(info) {
switch (info.step) {
case 'start':
status.step = 'available';
status.available = false;
return status;
case 'unavailable':
status.step = 'available';
status.available = true;
break;
case 'available':
status.available = false;
status.step = 'alldone';
return status;
case 'alldone':
status.step = 'unavailable';
status.available = false;
return status;
default:
throw new Error('unknown step');
}
}

//case unavailable needs to end with break

function stateLoop() {
if (info.available) {
// this is important!
doImportantThing();
}
checkAndUpdateStep(info);
var current = { step: info.step, available: info.available };
actOnCurrentState(current);
setTimeout(stateLoop,500);
}

var info = { step: 'start', available: false };
stateLoop();

that is the question
Nathan
@terakilobyte
Jun 14 2016 05:20
@ypt3 is it possible to pass in the necessary information to the function without referencing external state?
oh, it's a question...
Alan Tsai
@ypt3
Jun 14 2016 05:21
yap
Nathan
@terakilobyte
Jun 14 2016 05:21
what is info? what's it look like? what are the keys and values?
Alan Tsai
@ypt3
Jun 14 2016 05:21
thats what it confuses me ha
key and value pair
its an object
Nathan
@terakilobyte
Jun 14 2016 05:21
well yes I gathered that from the object reference notation being used on it...
I mean, what is it, as in what does it represent and what data is currently in it?
ah there, scrolled down to your most recent paste
Alan Tsai
@ypt3
Jun 14 2016 05:25
it pretty much asks to define where the bug is... all i know is they did not define checkAndUpdateStep, actOnCurrentState
but it will be too easy if thats really the answer, I think there is more behind it...
Brian Phillips
@unipheas
Jun 14 2016 05:27
var n = parseInt(readline()); // the number of temperatures to analyse
var temps = readline(); // the n temperatures expressed as integers ranging from -273 to 5526

var array = temps.split(' ');

function closest (num, arr) {
    var curr = arr[0];
    var diff = Math.abs (num - curr);

    for (var val = 0; val < arr.length; val++) {
        var newdiff = Math.abs (num - arr[val]);
        if (newdiff < diff) {
            diff = newdiff;
            curr = arr[val];

            // check for absolute value of negative number and set curr as positive
            for (i=0;i>=n;i++){ //loop through the number of temperatures
                if (array[i] == Math.abs(Number(curr))) {  //checks if value in temps has an equal abs value
                  curr = array[i];   //set abs value
                }
            }
        }
    }
    return curr;
}

if (array == false){
    print("0");
}else {
    print (closest (0, array));
}
I’m having a bit of trouble. if I get a ‘-#’ and it’s abs is inside the array I need to change cure to the abs, but only if there is one.. I can’t just change all negatives to their abs. .. someone mind helping me out on this?
Nathan
@terakilobyte
Jun 14 2016 05:27
there's also inconsistencies within the switch structure
some cases are returning, others aren't
Alan Tsai
@ypt3
Jun 14 2016 05:28
yeah
Nathan
@terakilobyte
Jun 14 2016 05:28
though the return value from the cases that are returning doesn't seem to be used, the function is just called
so it results in a noop
Alan Tsai
@ypt3
Jun 14 2016 05:28
function checkAndUpdateStep(info) {
switch (info.step) {
case 'start':
status.step = 'available';
status.available = false;
return status;
case 'unavailable':
status.step = 'available';
status.available = true;
case 'available':
status.available = false;
status.step = 'alldone';
return status;
case 'alldone':
status.step = 'unavailable';
status.available = false;
return status;
default:
throw new Error('unknown step');
}
}
here is original question
Nathan
@terakilobyte
Jun 14 2016 05:29
help format
CamperBot
@camperbot
Jun 14 2016 05:29

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

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

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

Nathan
@terakilobyte
Jun 14 2016 05:29
@ypt3 please format it for readability
Alan Tsai
@ypt3
Jun 14 2016 05:29
i just add the break on 'case: unavaliable'
Drew Stonebraker
@drstonebraker
Jun 14 2016 05:32
@ypt3 wouldn't you need to return status there?
1ety
@1ety
Jun 14 2016 05:32
What is missing in the following code:

function palindrome(str) {
str=str.toLowerCase();
for(var i=0;i<str.length;i++){
str.replace(' ','');
str.replace('.','');
str.replace(',','');
//str.replace(' ','');
}
var reverStr=str.split('').reverse().join('');

if(str==reverStr){
return true;
}
else{
return false;
}
return str;
}
palindrome("rac car");

Alan Tsai
@ypt3
Jun 14 2016 05:35
Screen Shot 2016-06-13 at 10.34.38 PM.png
@Stoney229 ur right i should return the status instead
Shusil Banjade
@shusil123
Jun 14 2016 05:36
@1ety , since you are comparing str, which has spaces, puntuations and all, with reverseStr, which is a plain collection of letters only, It will always return false.
Alan Tsai
@ypt3
Jun 14 2016 05:36
not add the break i think
@terakilobyte I hope that picture helps ha
anjitapanta
@anjitapanta
Jun 14 2016 05:37
Did anyone do the Profile Lookup?
Shusil Banjade
@shusil123
Jun 14 2016 05:38
var nstr = str.toLowerCase().replace(/\W/g, "); now Compare nstr with nstr.split('').reverse('').join(''); @1ety
And , the regular expression \W, contains all non-alphanumeric characters, with whitespace, yo don't have to replace them manually....
@anjitapanta , Yes. Can you post your code here ??
anjitapanta
@anjitapanta
Jun 14 2016 05:41
function lookUpProfile(firstName, prop){
// Only change code below this line
for(i=0; i<contacts.length; i++){
if(firstName==contacts[i][firstName] && prop==contacts[i]){
return contacts[i][prop];
}else if(firstName!=contacts[i][firstName]){
return"No such contact";
}else if(prop!=contacts[i]){
return"No such property";
}
}
// Only change code above this line
}
@shusil123
Shusil Banjade
@shusil123
Jun 14 2016 05:42
@anjitapanta , you can access firstName with dot notation, like contacts[i].firstName
1ety
@1ety
Jun 14 2016 05:42
@shusil123 , so what should I do?
Markus Kiili
@Masd925
Jun 14 2016 05:42
@anjitapanta Or if(firstName===contacts[i]["firstName"]
Shusil Banjade
@shusil123
Jun 14 2016 05:42
Or , contacts[i]["firstName"]
Markus Kiili
@Masd925
Jun 14 2016 05:43
@anjitapanta The second check should be property existence check with .hasOwnProperty() or .propertyIsEnumerable().
anjitapanta
@anjitapanta
Jun 14 2016 05:43
but thats not why the code is not working. the first part of the code is wrong
Nnattu
@nnattu98
Jun 14 2016 05:43
Hi, Could you please help me on the below
I can't understand the question and how to resolve this
I have defined the first variables and what to do with the second query !
Please advise !
Shusil Banjade
@shusil123
Jun 14 2016 05:44
@1ety , tolowercase and then replace the punctuations for the given str. set it to new variable. And then reverse the variable. compare them
anjitapanta
@anjitapanta
Jun 14 2016 05:45
@nnattu98 result="The "+ " "+myAdjective+" "+myNoun+" "+myVerb+" "+myAdverb;
Markus Kiili
@Masd925
Jun 14 2016 05:45
@anjitapanta You need to put quotes on the firstName inside brackets and also return no such contact is at wrong place.
Nnattu
@nnattu98
Jun 14 2016 05:45
@anjitapanta yes, but what about the second issue - the question with "cat"....
Shusil Banjade
@shusil123
Jun 14 2016 05:45
@nnattu98 , do not define myAdjective, myNoun, ....etc manually, since they are the function arguments
Markus Kiili
@Masd925
Jun 14 2016 05:45
@anjitapanta Your code can return it based on only one contact.
Nnattu
@nnattu98
Jun 14 2016 05:46
@shusil123 - okay, then what should I do ? I am a new bee on here ! Reached learning upto this stage and this one looks little tricky !
Shusil Banjade
@shusil123
Jun 14 2016 05:47
Just concatenate them with your words, like how you wanna form, the word , "The dog is big and ran quickly",
@nnattu98
Nnattu
@nnattu98
Jun 14 2016 05:47
okay, let me try and will be back - Thanks all @shusil123
CamperBot
@camperbot
Jun 14 2016 05:47
nnattu98 sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles:
:cookie: 425 | @shusil123 |http://www.freecodecamp.com/shusil123
1ety
@1ety
Jun 14 2016 05:47
@shusil123 thank you.
CamperBot
@camperbot
Jun 14 2016 05:47
1ety sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles:
:cookie: 426 | @shusil123 |http://www.freecodecamp.com/shusil123
Shusil Banjade
@shusil123
Jun 14 2016 05:48
or the cat is little and hit slowly like : "The" + myNoun + "is" + .............
@nnattu98
Isaac Pak
@pak11273
Jun 14 2016 05:51
can someone tell me if i'm on the right track with the roman numerals algorithm, I'm stuck now:

function convertToRoman(num) {

  var ones = ['','I','II','III','IV','V','VI','VII','VIII','IX','X'];
  var tens = ['', 'XX','XXX','XL','L','LX','LXX','LXXX','XC'];
  var hundreds = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM'];


  if(num < 11) {
    num = ones[num];
  }

  else if(num > 10 && num < 20) {
    num = ones[10] + ones[num%10];
  }

  else if(num > 19 && num < 100) {
   var tens_place = (num - num%10) / 10;
   num = tens[tens_place-1] + ones[num%10];
  }

   return num;
}

convertToRoman(301);
anjitapanta
@anjitapanta
Jun 14 2016 05:52
@nnattu98

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

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

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

Nnattu
@nnattu98
Jun 14 2016 05:53
@anjitapanta - after this there is one more in question - for "cat" etc... - How to call that function !
@shusil123
Chris Kissoon
@ChrisKissoon
Jun 14 2016 05:54
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i < arr.length; i++){
    for(var j = 0; j < arr[i].length; j++){
        product *= arr[i][j];
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Can someone explain to me how this works i know the product multiplies each number in each nested array but i don't understand how the code is doing so
Markus Kiili
@Masd925
Jun 14 2016 05:55
@pak11273 I believe that you should instead put the basis of roman numerals on one array and the Roman letters on another one. It would be easier to solve then by iterating the numbers array and generating the solution on the fly:
var NUM = [1000,900,500,..];
var ROM = ['M', 'CM', 'D',...];
Shusil Banjade
@shusil123
Jun 14 2016 05:55
@nnattu98 , simply myNoun + " " + " is" + myAdjective+ " " + " and" + ........., just seperate the given arguments with spaces and some of your own words between them...
anjitapanta
@anjitapanta
Jun 14 2016 05:56
@nnattu98 as long as you got the result equation right, thats all that matters
Nnattu
@nnattu98
Jun 14 2016 05:56
@shusil123 - & @anjitapanta Yes :) That's sorted now - I finished with : result="The"+" "+myAdjective+" "+myNoun+" "+myVerb+" "+myAdverb+".";
and it worked - lol. Thanks both @shusil123 & @anjitapanta
CamperBot
@camperbot
Jun 14 2016 05:57
nnattu98 sends brownie points to @shusil123 and @anjitapanta :sparkles: :thumbsup: :sparkles:
:warning: nnattu98 already gave shusil123 points
:cookie: 209 | @anjitapanta |http://www.freecodecamp.com/anjitapanta
Norman Dela Cruz
@dcnr
Jun 14 2016 05:58

@ChrisKissoon the outer for loop traverses each element (the arrays) in arr while the inner for loop deals with the elements inside each of those arrays (that is dealt by the outer for loop) in arr.
So given [[1,2],[3,4],[5,6,7]] as arr

arr[i] and i is 0 // arr[i] is [1,2]
arr[i][j] and i and j is 0 // arr[i][j] is 1

each of their values is then multiplied with product (product *= arr[i][j];) and is then returned after all the values are done!

Chris Kissoon
@ChrisKissoon
Jun 14 2016 06:01
Thanks @dcnr :satisfied:
CamperBot
@camperbot
Jun 14 2016 06:01
chriskissoon sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:cookie: 769 | @dcnr |http://www.freecodecamp.com/dcnr
Isaac Pak
@pak11273
Jun 14 2016 06:02
@Masd925 ill take a look at that
Norman Dela Cruz
@dcnr
Jun 14 2016 06:02
thanks too! @ChrisKissoon :D
CamperBot
@camperbot
Jun 14 2016 06:02
dcnr sends brownie points to @chriskissoon :sparkles: :thumbsup: :sparkles:
:cookie: 235 | @chriskissoon |http://www.freecodecamp.com/chriskissoon
Artem Slepets
@slepets-a
Jun 14 2016 06:16
Hi guys.
function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes == 1) {
    return "Hole-in-one";
  }
    else if (strokes <= par - 2) {
      return "Eagle";
    }
      else if (strokes == par - 1) {
        return "Birdie";
      }
        else if (strokes == par) {
          return "Par";
        }
          else if (strokes == par + 1) {
            return "Bogey";
          }
            else if (strokes == par +2) {
              return "Double Bogey";
            }
              else return "Go Home!";
  // Only change code above this line
}
Seems there is a bug in tests) Code do not pass the test.
Norvin Burrus
@ndburrus
Jun 14 2016 06:16
@ChrisKissoon you may find this useful: Iterating over arrays and objects in JavaScript :)
Artem Slepets
@slepets-a
Jun 14 2016 06:17
Goal golfScore(4, 1) should return "Hole-in-one!" still red :smile:
kirbyedy
@kirbyedy
Jun 14 2016 06:17
did you try to put par - 2 in brackets
and all the rest...
Harshit Anand
@nerocool996
Jun 14 2016 06:17
Hey, I need some help, I am at advance algorithm scripting, need help in no repeat please challenge. I want to the math for finding the total no of permutation
Artem Slepets
@slepets-a
Jun 14 2016 06:18
Damn it! Exclamation mark in first text line :fire:
kirbyedy
@kirbyedy
Jun 14 2016 06:18
@49h4DhPERFECT like this: (strokes <= (par+1))
Artem Slepets
@slepets-a
Jun 14 2016 06:19
Nah. ```js
```js
if (strokes == 1) {
    return "Hole-in-one!";
  }
But there must be ```js
"Hole-in-one!"
Norvin Burrus
@ndburrus
Jun 14 2016 06:20
@49h4DhPERFECT !missing something? :)
Sanzhar Askaruly
@askaruly
Jun 14 2016 06:21
gus
guys

function largestOfFour(arr) {
var newArr = [];
var maxElement = 0;
for (i=0; i<arr.length; i++) { for (j=0; j<arr[i].length; j++) { if (arr[i][j] >= maxElement) {
maxElement = arr[i][j];
}
}
newArr = newArr.push(maxElement);
}

}

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

have this
problem
could you help please
Return Largest Numbers in Arrays
anjitapanta
@anjitapanta
Jun 14 2016 06:22
I CANNOT figure out the problem with my code on Profile Lookup:

function lookUpProfile(firstName, prop){
// Only change code below this line
for(i=0; i<contacts.length; i++){
if(contacts[i].firstName==firstName && contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];

}else if(firstName!=contacts[i].firstName){
return"No such contact";
}else if(prop!=contacts[i]){
return"No such property";
}
}
// Only change code above this line
}

DJ
@qualitymanifest
Jun 14 2016 06:23
@askaruly newArr = newArr.push(maxElement); you don't need to assign it back to newArr, just push it to newArr, and don't forget to return newArr. you will also need to reset maxElement with each subarray
Greg Duncan
@GregatGit
Jun 14 2016 06:25
@anjitapanta it will check the very first contact and return something - not give it a chance to go through all the contacts
silver537
@silver537
Jun 14 2016 06:25
so many people needing help holy shit.
Artem Slepets
@slepets-a
Jun 14 2016 06:26
@silver537 Cause coding is not an cooking :smile:
silver537
@silver537
Jun 14 2016 06:26
what?
Sanzhar Askaruly
@askaruly
Jun 14 2016 06:27
@qualitymanifest man thanks!!!
CamperBot
@camperbot
Jun 14 2016 06:27
askaruly sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1199 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
Markus Kiili
@Masd925
Jun 14 2016 06:28
@anjitapanta You can return no such contact once you have checked all the contacts.
Greg Duncan
@GregatGit
Jun 14 2016 06:28
@anjitapanta return"No such contact"; should be outside the loop - it should loop through all the contacts and if it get through them all then it can return "no such contact"
DJ
@qualitymanifest
Jun 14 2016 06:28
@askaruly :+1:
silver537
@silver537
Jun 14 2016 06:28
@anjitapanta you're no such contact has to be the very last it checks..
Natan Corro
@natancorro
Jun 14 2016 06:33
Hi, im really stucked in seek and destroyed
the second and third array cant be compared
Nick Ang
@nickangtc
Jun 14 2016 06:33
Hey I have a question about $.get method, using it for an API call to OpenWeather.
Here's the function I wrote for the API call. I'm supposed to get a JSON object with info about weather based on the user's location:
  //|--- FUNC to Get weather data and display on page
  function getWeather(latitude, longitude) {
    console.log(latitude, longitude)
    var url = "http://api.openweathermap.org/data/2.5/weather?lat=50&lon=2?callback=?&APPID=95eaa17a6d237ecea9f9956ac1b77766"

    $.getJSON(url, function(data) {
      console.log("success")
      tempC = data.weather.main.temp / 10; // OpenWeather API returns Celsius * 10
      rain = data.rain["3h"];
      clouds = data.clouds.all;
      console.log(tempC);
      console.log(rain);
      console.log(clouds);
    }); // end of "get" weather --|
  }
Anyone has any guesses why the above code doesn't work? Console doesn't log "success"
I managed to get the user's geolocation data, stored in the variables latitude and longitude
I copy pasted the code to JSFiddle, loaded jQuery, and still it doesn't work - so it's not Codepen's code messing up the execution
Markus Kiili
@Masd925
Jun 14 2016 06:36
@nickangtc If I remember correctly, someone said that it only works with https nowadays. Maybe someone else could confirm this?
kirbyedy
@kirbyedy
Jun 14 2016 06:37
@Masd925 yes, you are right
Nick Ang
@nickangtc
Jun 14 2016 06:37
Yes someone said it recently... mm you mean the $.get method only works if the call URL is https?
kirbyedy
@kirbyedy
Jun 14 2016 06:37
if you open your console, you will most probably see the error @nickangtc
Nick Ang
@nickangtc
Jun 14 2016 06:37
@kirbyedy some error message from google?
Markus Kiili
@Masd925
Jun 14 2016 06:37
@nickangtc OpenWeather and https, I believe.
kirbyedy
@kirbyedy
Jun 14 2016 06:39
@nickangtc well I dont know exactly, but you will see some kind of warning
Nick Ang
@nickangtc
Jun 14 2016 06:39
Oh yes @kirbyedy you're right! I got this message:
Failed to load resource: the server responded with a status of 404 ()
OH I think I know what the problem is... beside that error message it says that the URL that the $.get used was this:
https://s.codepen.io/nickang/debug/www.api.openweathermap.org/data/2.5/weather?lat=0&lon=0&APPID=95eaa17a6d237ecea9f9956ac1b77766
There's the whole chunk in front of api.openweathermap.org that shouldn't be there
How to resolve this... ?
Arjun
@arjunsingh81989
Jun 14 2016 06:41
hey, can anyone help me with Grunt JS task runner?
Nick Ang
@nickangtc
Jun 14 2016 06:42

Ok just checked console on JSFiddle and it returns a different error message... the one about HTTPS:

jquery.min.js:4 Mixed Content: The page at 'https://jsfiddle.net/go2fjdh8/' was loaded over HTTPS, but requested an insecure script 'http://api.openweathermap.org/data/2.5/weather?lat=50&lon=2?callback=jQuery…33001_1465885696575&APPID=95eaa17a6d237ecea9f9956ac1b77766&_=1465885696576'. This request has been blocked; the content must be served over HTTPS.

kirbyedy
@kirbyedy
Jun 14 2016 06:43
@nickangtc yep thats the error
Nick Ang
@nickangtc
Jun 14 2016 06:43
I wonder if it'll be fixed if I just replaced HTTP with HTTPS in the URL... I doubt it
kirbyedy
@kirbyedy
Jun 14 2016 06:43
nope
Nick Ang
@nickangtc
Jun 14 2016 06:43
Hahah... this is so wonderfully frustrating. Any ideas how I might be able to work around it? Or should I just find some other API that IS hosted on https?
kirbyedy
@kirbyedy
Jun 14 2016 06:44
yes that is one way
the other way is to use ip location for getting the location of the user
ip-api.com for example
Nick Ang
@nickangtc
Jun 14 2016 06:46
@kirbyedy I've heard someone say that here once but I didn't understand. Can you explain in a little more detail how that works?
kirbyedy
@kirbyedy
Jun 14 2016 06:48
instead of getting the location of the user with geolocation, which wont work in chrome, you get the location via http://ip-api.com/json
and then just use that same openweather api to get the data
ooooor... you use wunderground weather api for example
Nick Ang
@nickangtc
Jun 14 2016 06:52
Ooh. Ok, few thoughts:
1) Geolocation (via navigator) works on my Chrome. Not sure why it works, but it does. Hmm.
2) Nice! Is ip-api.com/json a common workaround for geolocation? I just saw the object - looks easy to work with.
3) Yep I'm going to try wunderground API now
on chrome 49 and earlier works
Nick Ang
@nickangtc
Jun 14 2016 06:56
Interesting... thanks @kirbyedy. So now instead of directly asking for geolocation via Chrome's navigator, we need to go through ip-api.com? That honestly doesn't sound any more secure than previously
CamperBot
@camperbot
Jun 14 2016 06:56
nickangtc sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star2: 1110 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
silver537
@silver537
Jun 14 2016 06:56
@kirbyedy i don't like your pic... it makes me think my computer is broke
kirbyedy
@kirbyedy
Jun 14 2016 06:57
:laughing:
Howl
@karst10607
Jun 14 2016 07:07
@silver537 OCD (obcessive compulsive disorder) or something?
I got OCD, and I knew someone with OCD have the same issues as we do.
silver537
@silver537
Jun 14 2016 07:08
which are?
Tim
@t1flanagan
Jun 14 2016 07:08
Can anyone tell me what's wrong with this code for Profile Lookup?
Howl
@karst10607
Jun 14 2016 07:09
they can't help but thinking something is broken or being messed up, so they got to clean and tidy them up all the time.
Tim
@t1flanagan
Jun 14 2016 07:09
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName === firstName) {
      if (contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
      }
      else return "No such property";
    }
    else return "No such contact";
  }
// Only change code above this line
}
Howl
@karst10607
Jun 14 2016 07:09
Fixing the page layout, fonts is just one of it.
Markus Kiili
@Masd925
Jun 14 2016 07:09
@t1flanagan Return no such contact only after checking all the contacts.
Tim
@t1flanagan
Jun 14 2016 07:10
ohhh okay, move it outside the for loop?
Markus Kiili
@Masd925
Jun 14 2016 07:10
Yep.
Tim
@t1flanagan
Jun 14 2016 07:10
Thank you.
pawan shaw
@kpshaw
Jun 14 2016 07:10
@nnattu98 delete all code above the result ="".you will get answer
Eli
@elisspace
Jun 14 2016 07:31
I cannot get my .getJSON to work. I have it as simple as I can imagine but something is wrong. I'm using Firefox, (had a previous issue with chrome not liking cross-site requests)
 $.getJSON('https://en.wikipedia.org/w/api.php?action=query&list=search&format=json&srsearch=test&callback=?', function() {
      console.log("success");
    })
    .done(function() {
      console.log("second success");
    })
    .fail(function() {
      console.log("error");
    })
    .always(function() {
      console.log("complete");
    });
All I get in console is
error
complete
kirbyedy
@kirbyedy
Jun 14 2016 07:32
yea, screw those chrome users :D
stricknein
@stricknein
Jun 14 2016 07:33
@elisspace looks like something failed. and then it was done. what happens when you hard code the url into your browser ?
Eli
@elisspace
Jun 14 2016 07:33
haha--security is for chumps? or something :D
It opens the page just fine @stricknein when I just cut and paste that exact URL
stricknein
@stricknein
Jun 14 2016 07:35
@elisspace well something is failing in the call back. maybe inspect it with f12 and look and see what exactly is comming back
Eli
@elisspace
Jun 14 2016 07:36
I've been trying--not super familiar with that tool. Do you know where I should look @stricknein ? and thanks for the help!
CamperBot
@camperbot
Jun 14 2016 07:36
elisspace sends brownie points to @stricknein :sparkles: :thumbsup: :sparkles:
:cookie: 277 | @stricknein |http://www.freecodecamp.com/stricknein
stricknein
@stricknein
Jun 14 2016 07:36
@elisspace lemme take a look one sec
Eli
@elisspace
Jun 14 2016 07:37
aha wait I got it. I simplified it down to where that is the only code running and it works! Whatever the problem was it came from having that function wrapped in another function. I guess there's an issue with the way it was being called when i clicked the search button.
so the issue is when i try to have it run on a click
$('#searchbox').submit(function(event) {
  //event.preventDefault();
  //console.log('input: '+$('input').val());
   $.getJSON('http://en.wikipedia.org/w/api.php?action=query&list=search&format=json&srsearch=test&callback=?', function() {
      console.log("success");
    })
    .done(function() {
      console.log("second success");
    })
    .fail(function() {
      console.log("error");
    })
    .always(function() {
      console.log("complete");
    });
});
stricknein
@stricknein
Jun 14 2016 07:39
@elisspace after your press f 12 and then click the sources tab. there you should see the request and the corresponding javascript
Hoang 9x
@huyhoang9212
Jun 14 2016 07:40
Hi every one, I get stuck on this challenge : https://www.freecodecamp.com/challenges/return-largest-numbers-in-arrays
stricknein
@stricknein
Jun 14 2016 07:40
@elisspace I see, ya you can run into nesting events like that. I had an issue the other night where a button wasnt updating properly because it was nested in another function.
Hoang 9x
@huyhoang9212
Jun 14 2016 07:41
please someone tell me how to solved it. :smile: thanks
stricknein
@stricknein
Jun 14 2016 07:41
@huyhoang9212 if you format your code and paste it in I can give you some help. But I will not give you the answer. You will not learn anything that way.
Eli
@elisspace
Jun 14 2016 07:42
@stricknein yeah, that's exactly the kind of thing that's happening. the request is getting made and wikipedia is returning the information. It's just jquery (I assume) is acting like it isn't getting it
Kshitij Nikhal
@nikhalster
Jun 14 2016 07:42
does anybody know jquery validation plugin
Raj
@Raj00786
Jun 14 2016 07:42
<h2></h2>
<ul>
<li id="one" >one</li>
<li id="two">two/li>
<li id="three">three</li>
<li id="four">four</li>
</ul>

//javascript
$(function(){
var list,status,event;
$('ul').on('click mouseover',':not(#four)',function(e){
list ="item:"+this.textContent+'<br/>';
event ="event:"+e.type;
$('h2').html(list+event);
});
});
help me
when i remove ':not('#four')' and then changing$('ul') to $('li') it works
please help
Eli
@elisspace
Jun 14 2016 07:49
@stricknein Found it. The key was event.preventDefault(); and it works! This is literally what I've been stuck on the last week. Thanks for the help, again!
CamperBot
@camperbot
Jun 14 2016 07:49
elisspace sends brownie points to @stricknein :sparkles: :thumbsup: :sparkles:
:warning: elisspace already gave stricknein points
Eli
@elisspace
Jun 14 2016 07:50
@nikhalster I'm using a bit of it currently. What do you want to know?
Yildirim
@yildirimmurat
Jun 14 2016 07:51
Hello
I have a problem with Falsy Bouncer
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  function isFalsy(arg){
    return arg===false||arg===null||arg===0||arg===undefined||isNaN(arg);
  }
arr.filter(isFalsy);
  return arr;
}

bouncer([7, "ate", "", false, 9]);
Anyone help pls?
Markus Kiili
@Masd925
Jun 14 2016 07:54
@yildirimmurat isNaN is not really a test for value NaN. It is really iSNaNWhenCoercedToTypeNumber. So it gives true for many values besides just NaN.
@yildirimmurat Your code keeps falsy values. You should remove them.
Anton Bright
@OrthantBing
Jun 14 2016 07:55

Hi
I am at the "Where art thou" challenge.
I have come up with a solution, an ugly inefficient one

function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  for (var l in collection){
    var flag = 0;
    for (var j in source){
      if (source[j] !== collection[l][j]){
        flag = 1;
        break;
      }
    }
    if (flag === 0){
      arr.push (collection[l]);
    }
  }

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

Please suggest me a better efficient one.

Markus Kiili
@Masd925
Jun 14 2016 07:57
@OrthantBing Here is one solution:
function whereAreYou(collection, source) {
  var keyList = Object.keys(source);
  return collection.filter(function(obj){
    return keyList.every(function(key){
      return obj.hasOwnProperty(key) && obj[key]===source[key];
    });
  });
}
Anton Bright
@OrthantBing
Jun 14 2016 07:58
Thanks @Masd925
CamperBot
@camperbot
Jun 14 2016 07:58
orthantbing sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1859 | @masd925 |http://www.freecodecamp.com/masd925
Yildirim
@yildirimmurat
Jun 14 2016 08:00
@Masd925 it warns me to use isNaN function

@Masd925
````function bouncer(arr) {
// Don't show a false ID to this bouncer.
function isFalsy(arg){
return arg!==false||arg!==null||arg!==0||arg!==undefined||!isNaN(arg);
}
arr.filter(isFalsy);
return arr;
}

bouncer([7, "ate", "", false, 9]);

````

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  function isFalsy(arg){
    return arg!==false||arg!==null||arg!==0||arg!==undefined||!isNaN(arg);
  }
arr.filter(isFalsy);
  return arr;
}

bouncer([7, "ate", "", false, 9]);
how about this?
ALMY91
@ALMY91
Jun 14 2016 08:17
hi guys
var square = function(x) {returns x*x;}

console.log(square);
theres smth wrong w my code here but i cant figure out where went wrong
can anybody help me on this ?
kirbyedy
@kirbyedy
Jun 14 2016 08:18
returnS ?
ALMY91
@ALMY91
Jun 14 2016 08:19
@kirbyedy ahh i see okay but im thinking how shd i put in the value of my x here. since this is a definitive expression, theres no way for me to call out the function w arguments
kirbyedy
@kirbyedy
Jun 14 2016 08:22
square(4); ?
ALMY91
@ALMY91
Jun 14 2016 08:25
@kirbyedy alrighty thanks !
CamperBot
@camperbot
Jun 14 2016 08:25
almy91 sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star2: 1112 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
archan6le
@archan6le
Jun 14 2016 08:30
hey guys... any idea why this does not return the desired result Akira?
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"]
    }
];


 console.log(contacts[0].firstName);
I have tried putting firstName in [firstName] as well as ["firstName"]
Anton Bright
@OrthantBing
Jun 14 2016 08:32
contacts[0]["firstName"] should give you "Akira"
Blauelf
@Blauelf
Jun 14 2016 08:35
@archan6le console.log writes to the browser's console (accessible usually via F12 or Ctrl+Shift+I), should output "Akira" there
archan6le
@archan6le
Jun 14 2016 08:35
that seems to get me both a warning in code window "better written in .dot notation... and I still dont return desired result
Blauelf
@Blauelf
Jun 14 2016 08:37
@archan6le Have you checked your browser's Javascript console?
And for the return value... you need a return statement to pass a return value to the calling code.
archan6le
@archan6le
Jun 14 2016 08:38
@Blauelf OMG... That is awesome... I thought I was going nuts.. having such a hard time... you just made it all work.. thank you
CamperBot
@camperbot
Jun 14 2016 08:38
:star2: 1997 | @blauelf |http://www.freecodecamp.com/blauelf
archan6le sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
archan6le
@archan6le
Jun 14 2016 08:38
@OrthantBing thank you too for your help
CamperBot
@camperbot
Jun 14 2016 08:38
:cookie: 206 | @orthantbing |http://www.freecodecamp.com/orthantbing
archan6le sends brownie points to @orthantbing :sparkles: :thumbsup: :sparkles:
Aravind
@scriptonist
Jun 14 2016 08:38
I am Currently doing the exact change problem in Algorithm Scripting (Front End ) But i am unable to understand the details provided in the question. I am not an American so i am not able to understant the different currencies in the question
Blauelf
@Blauelf
Jun 14 2016 08:39
It's all one currency (dollars), just different coins/bills.
Aravind
@scriptonist
Jun 14 2016 08:44
The value of PENNY in the example is 1.01. Does that mean i have 1.01 pennys in my drawer ???
Blauelf
@Blauelf
Jun 14 2016 08:44
You have $1.01 in pennies
Aravind
@scriptonist
Jun 14 2016 08:44
ok
Blauelf
@Blauelf
Jun 14 2016 08:44
So 101 pennies
Aravind
@scriptonist
Jun 14 2016 08:45
Thank you for the help. I hope i can figure it out now !
Blauelf
@Blauelf
Jun 14 2016 08:45
Good luck :)
Jason Keenan
@raavin
Jun 14 2016 08:54
Hey :)
Markus Kiili
@Masd925
Jun 14 2016 08:54
@yildirimmurat If you combine isNaN with type check, it becomes a test for value NaN. typeof val === "number" && isNaN(value) is only true for value NaN.
@yildirimmurat Another test for NaN is value!==value.
Vivek
@vivek28111992
Jun 14 2016 08:56
which is best angular2, react or meteor?
@Masd925 @Blauelf :point_up_2:
Keone Martin
@Athaman
Jun 14 2016 08:57
@vivek28111992 that question is doomed for flame wars :P
Vivek
@vivek28111992
Jun 14 2016 08:58
I want to make site like this http://www.espn.in/football/
for this what which should I learn?
Ayush Kenhi
@AyushKenhi
Jun 14 2016 08:59
Hey all
I want helo with challenge
Using objects with lookup
I tried this
```js

Markus Kiili
@Masd925
Jun 14 2016 09:01
@vivek28111992 Take your crystal ball and see which will be used most in the future ;)
kirbyedy
@kirbyedy
Jun 14 2016 09:02
lol
Ayush Kenhi
@AyushKenhi
Jun 14 2016 09:02
```js function phoneticLookup(val) {}
Vivek
@vivek28111992
Jun 14 2016 09:03
@Masd925 what do you think, please suggest
Markus Kiili
@Masd925
Jun 14 2016 09:04
@vivek28111992 I only know angular1 so I have no opinion.
kirbyedy
@kirbyedy
Jun 14 2016 09:04
react is pushed hard
Vivek
@vivek28111992
Jun 14 2016 09:04
@Masd925 if you have learn any of these, which one you will pick?
archan6le
@archan6le
Jun 14 2016 09:05
hey guys anyone know why I keep getting: TypeError: cannot read property "firstName" of undefined" :

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


function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i <= contacts.length; i++){
 if(firstName === contacts[i]["firstName"]){
     console.log("hello");
   }
 }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira");
Markus Kiili
@Masd925
Jun 14 2016 09:05
@vivek28111992 Ask someone who knows something about them. I don't, sorry.
Vivek
@vivek28111992
Jun 14 2016 09:07
ok
thanks
archan6le
@archan6le
Jun 14 2016 09:08
@Masd925 do you know why it keeps giving me: TypeError: cannot read property "firstName" of undefined" :
Markus Kiili
@Masd925
Jun 14 2016 09:09
@archan6le i <= contacts.length <- Use < not <= You loop too far to non-existent property keys (indices).
archan6le
@archan6le
Jun 14 2016 09:11
ok ty
Jim Dennis
@JimDennis
Jun 14 2016 09:14

So, regarding this SVG animation:

https://codepen.io/JimD/pen/pbyRXW

I'd love to get some ideas on how to make [Hide Solution] to work. :smile_cat:
Ian Quain
@Ian-Quain
Jun 14 2016 09:17
Hey guys, anyone have a link to an online font-awesome directory that I can @import to my codepen css?
Alex T.
@lx-t
Jun 14 2016 09:17
@JimDennis Hello, Jim. Uncomment document.querySelector('svg').removeChild(useElement);
Kashif Mohammed
@Spyreo
Jun 14 2016 09:19
Hello
Alex T.
@lx-t
Jun 14 2016 09:19
@JimDennis It'll remove/hide the path.
Kashif Mohammed
@Spyreo
Jun 14 2016 09:19
can anyone help me Argument with a return value
I'm failing to understand the logic
// Example
var changed = 0;

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

changed = change(10);

// Setup
var processed = 0;

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

// Only change code below this line
processArg(7);
Jim Dennis
@JimDennis
Jun 14 2016 09:20
@lx-t ... the fact that it's commented out like that means I tried it before. But I'll try it again just in case my other changes have somehow enabled that to work.
kirbyedy
@kirbyedy
Jun 14 2016 09:20
@Spyreo changed = change(10); similar to this
Jim Dennis
@JimDennis
Jun 14 2016 09:20
Okay then. That worked.
Kashif Mohammed
@Spyreo
Jun 14 2016 09:20
Shit
Jim Dennis
@JimDennis
Jun 14 2016 09:20
Pesky. :)
Kashif Mohammed
@Spyreo
Jun 14 2016 09:20
thanks @kirbyedy
CamperBot
@camperbot
Jun 14 2016 09:20
spyreo sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star2: 1114 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
Matt
@Pixelbark
Jun 14 2016 09:28

Hi, could someone have a quick look at the bottom function in my code. The function isn't called whenever I click the stated class. I've tried it with on(), click() and plain old onClick(). onClick works to an extent, it will call the function, but if I pass any arguments with onClick. It just plain stops working. So I'm guessing I've done something fundamental incorrectly.

Many thanks!

http://codepen.io/Pixelbark/pen/BzKZZa?editors=0110

Haard Panchal
@h44rd
Jun 14 2016 09:30
Hello! Need some help, this shows "TypeError: str2.splice is not a function" Why?
function palindrome(str) {
  var str2=str.toLowerCase();
  for(i=0;i<str2.length;i++)
  {
    if(str2[i]<"a" || str2[i]>"z")
      str2.splice(i,1);
  }
  return str2;
}
palindrome("Eye90");
Alex T.
@lx-t
Jun 14 2016 09:31
@h44rd It's because splice is an Array method
Haard Panchal
@h44rd
Jun 14 2016 09:32
I thought a string can also be used as an array. @lx-t
Matt
@Pixelbark
Jun 14 2016 09:32
What Alex said, I think you want to use split()
Haard Panchal
@h44rd
Jun 14 2016 09:33
So after split(), Can I use the splice method?
Alex T.
@lx-t
Jun 14 2016 09:33
@h44rd Characters of a string can be accesed as indexed elements of array using square brackets but strings are surely not arrays
Matt
@Pixelbark
Jun 14 2016 09:33
At least, they aren't in Javascript.
Strings are funny things.
Haard Panchal
@h44rd
Jun 14 2016 09:35
okay! Thanks @lx-t @Pixelbark
CamperBot
@camperbot
Jun 14 2016 09:35
h44rd sends brownie points to @lx-t and @pixelbark :sparkles: :thumbsup: :sparkles:
:cookie: 326 | @lx-t |http://www.freecodecamp.com/lx-t
:cookie: 289 | @pixelbark |http://www.freecodecamp.com/pixelbark
ogunoye adebamigbe john
@adebamigbejohn
Jun 14 2016 09:36
hello please need help over here with Return Early Pattern for Functions
kirbyedy
@kirbyedy
Jun 14 2016 09:40
if a or b are less than 0 the function will immediately exit with a value of undefined
ogunoye adebamigbe john
@adebamigbejohn
Jun 14 2016 09:44
here is my code below

// Setup
function abTest(a, b) {
// Only change code below this line
console.log (a || b < 0);
console.log(undefined);

// Only change code above this line

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

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

archan6le
@archan6le
Jun 14 2016 09:48
hey guys.. whats wrong with my function? its for the profile lookup lesson... I cant seem to get all the green checks...
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++){
 if( firstName == contacts[i]["firstName"] && contacts[i].hasOwnProperty(prop)){
     return contacts[i][prop];
     }else if (contacts[i]["firstName"] != firstName){
       return "No such contact";
     }else if( prop != contacts[i][prop]){
       return "No such property";
     }

 }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
ogunoye adebamigbe john
@adebamigbejohn
Jun 14 2016 09:51
hello any one there?
Anusha
@anushavicky
Jun 14 2016 09:51

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

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

George Green
@george-fg
Jun 14 2016 09:55
hey there, does anyone know how to convert celsius to fahrenheit in JavaScript? it is one of the early tasks.
ogunoye adebamigbe john
@adebamigbejohn
Jun 14 2016 09:55
hello please i need help with Return Early Pattern for Functions
Anusha
@anushavicky
Jun 14 2016 09:56
var fahrenheit = celsius * 9/5 + 32
Blauelf
@Blauelf
Jun 14 2016 09:56
@archan6le Don't return "No such contact" on the first name mismatch, keep looping, and return that only after the loop.
George Green
@george-fg
Jun 14 2016 09:56
brilliant, thanks Anusha :D
Anusha
@anushavicky
Jun 14 2016 09:56
opes please add ;
Ezgi
@ezodd
Jun 14 2016 09:56
Hello

var count = 0;

function cc(card) {
// Only change code below this line
if (count > 0)
return "Bet";
else if (count <= 0)
return "Hold";

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

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

Markus Kiili
@Masd925
Jun 14 2016 09:56
@anushavicky You can do without the flag (code gets cleaner) if you just make two nested if clauses for firstname and property existence checks. Only those and returns.
Ezgi
@ezodd
Jun 14 2016 09:56
how can I add card to the return?
Markus Kiili
@Masd925
Jun 14 2016 09:57
@ezodd The card parameter holds the passed card. You check it and change count. Then figure out the return value from count, not card.
Blauelf
@Blauelf
Jun 14 2016 09:58
@anushavicky There's no need for an extra flag, as you return from the function on the first name match (return immediately ends the function and returns to the calling code), and won't ever reach that if(flag===false) with flag being true.
Ezgi
@ezodd
Jun 14 2016 09:59
@Masd925 yes I know but the output should be with card
Markus Kiili
@Masd925
Jun 14 2016 09:59
@ezodd No, output is count and Bet/Hold.
Anusha
@anushavicky
Jun 14 2016 09:59
@Blauelf @Masd925 Thank you :smile:
CamperBot
@camperbot
Jun 14 2016 10:00
anushavicky sends brownie points to @blauelf and @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1998 | @blauelf |http://www.freecodecamp.com/blauelf
:star2: 1860 | @masd925 |http://www.freecodecamp.com/masd925
Ezgi
@ezodd
Jun 14 2016 10:00
@Masd925 could you please write to correct code
Markus Kiili
@Masd925
Jun 14 2016 10:01
@ezodd First you should check the value of card and change count accordingly (no returns yet).
Alex T.
@lx-t
Jun 14 2016 10:01
@adebamigbejohn Instead of logging to console you should compare if a < 0 or b < 0 and then return undefined
Matt
@Pixelbark
Jun 14 2016 10:02
@adebamigbejohn You need to read through the assignment again, at the moment you're only logging to the console. You're not checking any statements.
Wiesiek
@Wiesiek2811
Jun 14 2016 10:05

challenge = You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.

var myNoun = "";
var myAdjective = "";
var myVerb = "";
var myAdverb = "";

var result = myNoun + myAdjective + myVerb + myAdverb;

where have i gone wrong

Coy Sanders
@coymeetsworld
Jun 14 2016 10:13
@Wiesiek2811 you don't need to define those variables, they are parameters in the function
also you need to put at a minimum spaces between each of those variables when you're concatenating the String i believe
or else result will be something like "catquicklyjumped"
ogunoye adebamigbe john
@adebamigbejohn
Jun 14 2016 10:17
please why is my code not working?
Matt
@Pixelbark
Jun 14 2016 10:18
@adebamigbejohn You have two answers, you aren't comparing the values, or using "return" after comparing.
ogunoye adebamigbe john
@adebamigbejohn
Jun 14 2016 10:20

// Setup
function abTest(a, b) {
// Only change code below this line
if (a < 0 || b < 0);
{return (undefined);
}

// Only change code above this line

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

// Change values below to test your code
abTest(2,2);
// if a < 0 or b < 0 and then return undefined

that is my code
Wiesiek
@Wiesiek2811
Jun 14 2016 10:20
@coymeetsworld thank you :)
CamperBot
@camperbot
Jun 14 2016 10:20
wiesiek2811 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1136 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 14 2016 10:20
@Wiesiek2811 :thumbsup: np
Matt
@Pixelbark
Jun 14 2016 10:22
@adebamigbejohn semi-colon after your if statement, remove it.
Jason Keenan
@raavin
Jun 14 2016 10:27
Hey everyone. I'm close to finishing my twitch app but I'm having some issues. It's at https://github.com/raavin/twitch and http://codepen.io/raavin/pen/VjavKV if someone has time to take a look. I've tried to comment the code where the issue is in the javascript
Ian Quain
@Ian-Quain
Jun 14 2016 10:34

function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case (1):
      console.log("alpha");
      break;
    case (2):
      console.log("beta");
      break;
    case (3):
      console.log("gamma");
      break;
    case (4):
      console.log("delta");
      break;
  }
  // Only change code above this line  
  return answer;  
}

// Change this value to test
caseInSwitch(2);
Anyone any idea why it's not sending "beta" as my answer?
Ezgi
@ezodd
Jun 14 2016 10:34
I need help
Coy Sanders
@coymeetsworld
Jun 14 2016 10:35
you're not modifying the answer that's why @Ian-Quain, you're just printing to console.log
Stephen James
@sjames1958gm
Jun 14 2016 10:35
@Ian-Quain console.log sends the string to console, doesn't set the answer variable
Kashif Mohammed
@Spyreo
Jun 14 2016 10:35
Can anyone help me with sand in line
Ian Quain
@Ian-Quain
Jun 14 2016 10:35
What would I use to send the answer variable?
Jason Keenan
@raavin
Jun 14 2016 10:36
This message was deleted
Stephen James
@sjames1958gm
Jun 14 2016 10:36
@Ian-Quain the assignment char =
Coy Sanders
@coymeetsworld
Jun 14 2016 10:36
what do you need help w/ @ezodd ?
Vivek
@vivek28111992
Jun 14 2016 10:36
@coymeetsworld hi
Rich Keyzor
@Web-Dev-Rich
Jun 14 2016 10:36
Can anyone see why I get an error if JS Bin https://jsbin.com/sofobo/edit?js,console but not in Codepen http://codepen.io/Web-Dev-Rich/pen/aZNRjB?editors=0011 Also get error in FCC editor.
Ian Quain
@Ian-Quain
Jun 14 2016 10:36
So I need to change console.log to answe = "alpha";
Coy Sanders
@coymeetsworld
Jun 14 2016 10:36
hey @vivek28111992 hows it going?
Jason Keenan
@raavin
Jun 14 2016 10:37
@Spyreo What are you having problems with???
Ezgi
@ezodd
Jun 14 2016 10:37

var count = 0;

function cc(card) {
// Only change code below this line
if (card >= 2 && card <= 6){
count = 1;

}
else if (card <= 7 && card <= 9)
count = 0;
else
return "Change Me";
// Only change code above this line
}

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

Vivek
@vivek28111992
Jun 14 2016 10:37
@coymeetsworld good, trying to figure which js framework to learn?
Ezgi
@ezodd
Jun 14 2016 10:37
I cannot fix it
Coy Sanders
@coymeetsworld
Jun 14 2016 10:38
@ezodd theres a couple of things
you don't account for T-A, you want to increment the count if its 2-6, not set it to 1.
the idea is if you run cc(2) and then cc(3), your count variable should be 2 because you have 2 low cards
Coy Sanders
@coymeetsworld
Jun 14 2016 10:39
also you should look at using a case/switch statement to modify the count variable, not if/else statements
Jason Keenan
@raavin
Jun 14 2016 10:40
@ezodd card <= 7 && card <= 9 this bit doesn't look right either :(
Coy Sanders
@coymeetsworld
Jun 14 2016 10:40
are you asking me which framework to learn or just stating you're trying to figure it out @vivek28111992 ?
James Dimitrakopoulos
@JamesDimi
Jun 14 2016 10:41
hi guys :) is it possible to call an external .js function inside of a .php script?
Wiesiek
@Wiesiek2811
Jun 14 2016 10:41

Hi ,I still can't get it to work so far i have this

function wordBlanks(myNoun,myAdjective,myVerb,myAdverb) {
var results = "".

Challenge : You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.

Jason Keenan
@raavin
Jun 14 2016 10:42
@FaiqAgayev Hi, you need to break down the instructions
Vivek
@vivek28111992
Jun 14 2016 10:42
@coymeetsworld both :smile:
Coy Sanders
@coymeetsworld
Jun 14 2016 10:42
what do you need from the framework?
Ezgi
@ezodd
Jun 14 2016 10:44

function cc(card) {
// Only change code below this line
if (card >= 2 && card <= 6){
count = count +1;
return "Bet";
}
else if (card <= 7 && card <= 9)
return "Hold";

else if (card > 9){
count = count -1;
return "Hold";
}
return "Change Me";

Agayev Faiq
@FaiqAgayev
Jun 14 2016 10:44
@raavin I search its must be about push or pop but I really didnt understant purpose of this challenge
Jason Keenan
@raavin
Jun 14 2016 10:44
@FaiqAgayev
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. - They've already set this up for you
Add the number to the end of the array - try to figure this out
then remove the first element of array - same as above
The nextInLine function should then return the element that was removed. - have a look at what the previous one returns
@FaiqAgayev you are looking for push() and shift()
Ezgi
@ezodd
Jun 14 2016 10:45
now what should I do?
Coy Sanders
@coymeetsworld
Jun 14 2016 10:46
you don't want to return anything yet @ezodd, also your logic is still wrong
Ezgi
@ezodd
Jun 14 2016 10:46
I can understand it is wrong
Stevan Gulan
@stegula
Jun 14 2016 10:46

Hello there guys. I am stuck on exercize Using Objects for Lookups
could someone tell me what i did wrong here
// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line

var lookup;
lookup = {
"alpha" : "Adams",
"bravo" : "Boston",
"charlie" : "Chicago",
"delta" : "Denver",
"echo" : "Easy",
"foxtrot" : "Frank"
};
result=lookup[val];
}

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

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

Markus Kiili
@Masd925
Jun 14 2016 10:47
@ezodd You should change count based on the card. The return value is determined from count, not card.
Jason Keenan
@raavin
Jun 14 2016 10:47
@ezodd and you need {} around 'return "Hold";'
Ezgi
@ezodd
Jun 14 2016 10:47
How can I return string and count at same time?
Stevan Gulan
@stegula
Jun 14 2016 10:48
@ezodd "string" + variable
Coy Sanders
@coymeetsworld
Jun 14 2016 10:49
you have one too many closing brackets @stegula
Vivek
@vivek28111992
Jun 14 2016 10:49
@coymeetsworld I want to create sports like site in which commentary is there and ppl can chat
Stevan Gulan
@stegula
Jun 14 2016 10:49
@coymeetsworld thank you, and i counted several times :S
CamperBot
@camperbot
Jun 14 2016 10:49
stegula sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1138 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 14 2016 10:50
np @stegula
Vivek
@vivek28111992
Jun 14 2016 10:50
one which they keep updating per minute
Jason Keenan
@raavin
Jun 14 2016 10:51
does anyone mind if I bump my question form earlier. I'm stumped with my twitch project
Coy Sanders
@coymeetsworld
Jun 14 2016 10:52
like twitter @vivek28111992 ? or Facebook?
Jason Keenan
@raavin
Jun 14 2016 10:52
How come everything goes silent every time I ask a question :)
The story of my life ;)
Karolina Kluz
@karolinaKluz
Jun 14 2016 10:54
@raavin I guess because you are more advanced than most of us, so less people here can really help you. I know I can't, I'm not there yet
christianws
@christianws
Jun 14 2016 10:54
Hi guys I'm on the Smallest Common Multiple bonfire. I have been working on it for so long I am really struggling with the maths involved
how have you guys found that challenge? It is kind of demoralising me
Coy Sanders
@coymeetsworld
Jun 14 2016 10:54
whats the problem @raavin ?
I see @vivek28111992
Jason Keenan
@raavin
Jun 14 2016 10:55
@karolinaKluz I'm not there yet either :) I've learned a lot though here
@coymeetsworld
Hey everyone. I'm close to finishing my twitch app but I'm having some issues. It's at https://github.com/raavin/twitch and http://codepen.io/raavin/pen/VjavKV
I've tried to comment the code where the issue is in the javascript
Kat
@Topzie
Jun 14 2016 10:58
help sorted union
CamperBot
@camperbot
Jun 14 2016 10:58

:point_right: algorithm sorted union [wiki]

Algorithm Sorted Union

Problem Explanation:

  • The program has to return a new array of unique values from two original arrays in the order they show up. So there is not sorting required, and no duplicates.
:pencil: read more about algorithm sorted union on the FCC Wiki
Jason Keenan
@raavin
Jun 14 2016 10:58
@coymeetsworld essentially the api give different json when an account is disabled but I don't seem to be able to access the properties of the other 'disabled' json
Vivek
@vivek28111992
Jun 14 2016 10:59
@coymeetsworld which things are required to create site like that but in smaller version
christianws
@christianws
Jun 14 2016 10:59
@raavin I think I can remember having to do to another AJAX request in the case that the account is disabled
Jason Keenan
@raavin
Jun 14 2016 11:00
@coymeetsworld This is an example
{
"error": "Unprocessable Entity",
"message": "Channel 'brunofin' is unavailable",
"status": 422
}

//https://api.twitch.tv/kraken/streams/ISeptimusI
{
"stream": null,
    "_links": {
        "self": "https://api.twitch.tv/kraken/streams/ISeptimusI",
        "channel": "https://api.twitch.tv/kraken/channels/ISeptimusI"
    }
}
Ezgi
@ezodd
Jun 14 2016 11:00

function cc(card) {
// Only change code below this line
if (card == 2){
count = card +1;
return count + " Bet";
}

else if (card == 3){
count = card + 1;
return count +" Bet";
}
else if (card == 4){
count = card + 1;
return count + " Bet";
}
else if (card == 5){
count = card + 1;
return count + " Bet";
}
else if (card == 6){
count = card + 1;
return count + " Bet";
}
else if (7 <= card <= 9){

return count + " Hold";
}

else if (card >= 10){
count = card - 1;
return count + " Hold";
}
return "Change Me";
// Only change code above this line
}

archan6le
@archan6le
Jun 14 2016 11:00
hey guys I really appreciate everyone's help on this I have all but one green check mark for Profile lookup... Wondering if anyone knows what Im doing wrong or how I need to move my code around to get this to return properly:
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++){
 if( firstName == contacts[i]["firstName"]){
   if(contacts[i].hasOwnProperty(prop)){
     return contacts[i][prop];
     }else if(contacts[i].hasOwnProperty(prop) === false){
       return "No such property";
     }  else{
   return "No such contact";
 }   
 } 
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Bob", "address");
Jason Keenan
@raavin
Jun 14 2016 11:01
@CurlyWS Yeah, I was thinking about that. Just doing another call outside, I'll probably just do that if there's not an obvious answer
Markus Kiili
@Masd925
Jun 14 2016 11:01
@archan6le Only return no such contact after checking all the contacts.
Your code can return it after checking only one contact.
Abhilash Srinivsan
@abhilashsrinivasan
Jun 14 2016 11:02
How to declare a string variable?
Coy Sanders
@coymeetsworld
Jun 14 2016 11:03
@raavin yeah you actually need to go about it a different way
Jason Keenan
@raavin
Jun 14 2016 11:03
@abhilashsrinivasan var variable = "string"
christianws
@christianws
Jun 14 2016 11:03
@raavin I came to the conclusion that it was necessary because the JSON provided different information for when the user is either online/offline.
If the user was offline I made a different request using a different url
this can help you to receive information that the original ajax could not provide
Coy Sanders
@coymeetsworld
Jun 14 2016 11:03
the problem is if the account is dead there is no stream property of the data object
so you can't reference it