These are chat archives for FreeCodeCamp/HelpJavaScript

20th
Jun 2016
bdembar
@bdembar
Jun 20 2016 00:01

@Hassanbhb Hi! Do you have any idea how to complete the "Using Objects for Lookups" challenge? Here is the code that I have currently:
```// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line

lookup = {
alpha:"Adams",
bravo:"Boston",
charlie:"Chicago",
delta:"Denver",
echo:"Easy",
foxtrot:"Frank"

};

//I can not figure out what to put here!
// Only change code above this line
return result;
}

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

Greg Duncan
@GregatGit
Jun 20 2016 00:02
@Hassanbhb return "No such contact"; should not be in the loop - it should loop through every contact leave the loop and then return "No such property";
Dave
@BeingDS
Jun 20 2016 00:05

Can anyone explain what is wrong with this code? I don't understand why it doesn't display anything:
var string = "3";
var number = 3;
var answer = "";

function isEqual (string, number) {
if (string == number && string !== number) {
answer = string + " is equal to " + number + "But " + string + "as a string is not the same as the number " + number;
}
else if (string === number) {
answer = string + " is absolutely equal to " + number;
}
return answer
}

Greg Duncan
@GregatGit
Jun 20 2016 00:05
@bdembar in js you need to be able to access property values - I recomend you cut and paste the object in https://repl.it/ and make sure you have your head around getting a value from an object - while it may be frustration at first - you will get it
Dave
@BeingDS
Jun 20 2016 00:06
This message was deleted
Can anyone explain why this code isn't working? It doesn't return anything and I can't find the syntax error:
var string = "3";
var number = 3;
var answer = "";

function isEqual (string, number) {
  if (string == number && string !== number) {
   answer = string + " is equal to " + number + "But " + string + "as a string is not the same as the number " + number;
  }
  else if (string === number) {
   answer = string + " is absolutely equal to " + number;
  }
  return answer
}
CamperBot
@camperbot
Jun 20 2016 00:07
:bulb: to format code use backticks! ``` more info
Norvin Burrus
@ndburrus
Jun 20 2016 00:08
@BeingDS Which exercise (name) is this? :sparkles: this appears contradictory: if (string == number && string !== number) {
Greg Duncan
@GregatGit
Jun 20 2016 00:09
this if (string == number && string !== number) looks wrong - I think it will allways be false
Dayne Johnston
@lowtekn7
Jun 20 2016 00:09
@BeingDS the code works fine for me, are you outputting the function to anything? ex: console.log(isEqual(string,number));
Dave
@BeingDS
Jun 20 2016 00:09
@ndburrus It's not actually a FCC challenge, I'm doing this on CodePen to make sure that I understand the concepts.
@lowtekn7 Is it not true that 3 == "3" and 3 !== "3"?
bdembar
@bdembar
Jun 20 2016 00:11
@GregatGit Thanks!
CamperBot
@camperbot
Jun 20 2016 00:11
bdembar sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 607 | @gregatgit |http://www.freecodecamp.com/gregatgit
Dayne Johnston
@lowtekn7
Jun 20 2016 00:11
@BeingDS this is the result I'm getting from your code: '3 is equal to 3But 3as a string is not the same as the number 3'
Dave
@BeingDS
Jun 20 2016 00:11
@lowtekn7 I'm not using console.log just "return". Doesn't that print the code?
Norvin Burrus
@ndburrus
Jun 20 2016 00:11
@BeingDS aaah... excellent, exploring the concepts.... :+1: nice work :fire:
Greg Duncan
@GregatGit
Jun 20 2016 00:12
@BeingDS in the function change string to str and number to num. In the function set up a variblbe called answer and return that end - then call the function like isEqual("red", 3);
llamatarianism
@llamatarianism
Jun 20 2016 00:12
when in doubt
use ===
Dayne Johnston
@lowtekn7
Jun 20 2016 00:12
@BeingDS You're returning a value, but not actually doing anything with it. So it's not going to output your response, it's just going to return the 'answer' variable that you have set. You need to actually do something with it though.
llamatarianism
@llamatarianism
Jun 20 2016 00:12
because == is confusing nonsense
false == "0"
false == [0]
Greg Duncan
@GregatGit
Jun 20 2016 00:12
@BeingDS instead of codepen to play around with js try https://repl.it/
bdembar
@bdembar
Jun 20 2016 00:13
If you want to paste code in do you just hit 3 back tics? Do I have to add 3 back tics on each line?
llamatarianism
@llamatarianism
Jun 20 2016 00:13
@bdembar no
you put it between 3 backticks
3 backticks, then a newline, then code, then a newline, then 3 backticks
bdembar
@bdembar
Jun 20 2016 00:14
That's what I thought I did.
Greg Duncan
@GregatGit
Jun 20 2016 00:14
@bdembar make sure your ``` are on a seperate line
Dave
@BeingDS
Jun 20 2016 00:14
Thanks @lowtekn7
CamperBot
@camperbot
Jun 20 2016 00:14
beingds sends brownie points to @lowtekn7 :sparkles: :thumbsup: :sparkles:
:cookie: 230 | @lowtekn7 |http://www.freecodecamp.com/lowtekn7
Dave
@BeingDS
Jun 20 2016 00:14
Thanks @ndburrus
CamperBot
@camperbot
Jun 20 2016 00:14
beingds sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 652 | @ndburrus |http://www.freecodecamp.com/ndburrus
bdembar
@bdembar
Jun 20 2016 00:14
Oh, ok.
Dayne Johnston
@lowtekn7
Jun 20 2016 00:14
@GregatGit esentially when you 'return' something, you're looking to set that to something. So you could be doing answer = isEqual(string,number); Then via polymorphism, isEqual(string,number) is actually changed to be whatever you are returning. In this example, you're returning a string. So isEqual(string,number) changes to be the string as if you had said: answer = '3 is equal to 3But 3as a string is not the same as the number 3'
Dave
@BeingDS
Jun 20 2016 00:14
I forgot that I have to call the function at the end in order to make it run. facepalm
Dayne Johnston
@lowtekn7
Jun 20 2016 00:15
Sorry, that was meant for @dave, not @gregatgit :)
Greg Duncan
@GregatGit
Jun 20 2016 00:15
@lowtekn7 :+1:
bdembar
@bdembar
Jun 20 2016 00:17
Well here goes. I have to try once more. Sorry if I did it wrong!
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line

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

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

// Change this value to test
phoneticLookup("charlie");
Dayne Johnston
@lowtekn7
Jun 20 2016 00:18
"alpha":"Adams",
"bravo":"Boston", etc
Dave
@BeingDS
Jun 20 2016 00:19
This is the code that ended up working for me.
var string = "";
var number = "";
var answer = "";

function isEqual (string, number) {
  if (string == number && string !== number) {
   answer = string + " is equal to " + number + " But \"" + string + "\" is not the same as " + number;
  }
  else if (string === number) {
   answer = string + " is absolutely equal to " + number;
  }
  return answer
  console.log(answer);
}

isEqual(3, "3")
Dayne Johnston
@lowtekn7
Jun 20 2016 00:19
and you can remove var value = result; it shouldn't be necessary
JosephKies
@josephkies
Jun 20 2016 00:19
i need help with the Stand in Line challenege!!
Dave
@BeingDS
Jun 20 2016 00:19
@josephkies I just did that one. What's "bugging" you? #DadJokes
Norvin Burrus
@ndburrus
Jun 20 2016 00:20
@BeingDS the following seems to break it: isEqual(3, "3") :sparkles: output: => ''
Greg Duncan
@GregatGit
Jun 20 2016 00:20

@BeingDS

function myFunction (num, str){
    var answer = num + " " + str;
    return answer;
}

var myNum = 1;
var myStr = 'Hello';

myFunction(myNum, myStr);

keep your function indepentant of the variables around it

Dave
@BeingDS
Jun 20 2016 00:20
@ndburrus I think that's cause it's expecting a string first and a number second.
JosephKies
@josephkies
Jun 20 2016 00:20
@BeingDS I am not sure what to push and pop and where etc
Norvin Burrus
@ndburrus
Jun 20 2016 00:20
@BeingDS yes, moment... so, when would a string ever equal a number?
JosephKies
@josephkies
Jun 20 2016 00:21
nextInLine.push([item]);
Dave
@BeingDS
Jun 20 2016 00:21
Standby @josephkies . Let me look at it again real quick
JosephKies
@josephkies
Jun 20 2016 00:21
nextInLine.pop([arr]);
?
TechAgent
@cyberwizkid
Jun 20 2016 00:21
i want to return sweater on this challenge, can anyone help?
@josephkies jose

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


function myOutfit() {
  // Only change code below this line



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

myOutfit();
JosephKies
@josephkies
Jun 20 2016 00:22
change var outerWear
TechAgent
@cyberwizkid
Jun 20 2016 00:22
@josephkies k
JosephKies
@josephkies
Jun 20 2016 00:22
@cyberwizkid change outwear variable to differen text
using assignment operator
Greg Duncan
@GregatGit
Jun 20 2016 00:23
@cyberwizkid inside the function change the value of outerWear to what ever you need it to be
TechAgent
@cyberwizkid
Jun 20 2016 00:24
@GregatGit how does outfit return sweater?
Norvin Burrus
@ndburrus
Jun 20 2016 00:24
@bdembar this is not needed: var value = result;...already mentioned...
TechAgent
@cyberwizkid
Jun 20 2016 00:26
@GregatGit , it worked but still says i should not change the value of outerWear
Dave
@BeingDS
Jun 20 2016 00:26
@josephkies Did you figure it out?
Norvin Burrus
@ndburrus
Jun 20 2016 00:26
@josephkies this may be useful: Javascript Array Methods: Unshift(), Shift(), Push(), And Pop() :sparkles: hint: pop?
Greg Duncan
@GregatGit
Jun 20 2016 00:26
@cyberwizkid how did you do it?
Dave
@BeingDS
Jun 20 2016 00:26
You need to add two lines of code.
JosephKies
@josephkies
Jun 20 2016 00:27
no @BeingDS i was waiting ofr your help :)
you mean in addition to what I showed you?
TechAgent
@cyberwizkid
Jun 20 2016 00:27
@GregatGit i changed the settings caring the value of tshirt
JosephKies
@josephkies
Jun 20 2016 00:27
so far I have nextInLine.arr.push([item]);
nextInLine.arr.pop([arr]);
Alex
@delk0
Jun 20 2016 00:27
guys I found this code to multiply 2 matrices
function matrixMultiplication(a, b){
  var result = [];
    for (var i = 0; i < a.length; i++) {
        result[i] = [];
        for (var j = 0; j < b[0].length; j++) {
            var sum = 0;
            for (var k = 0; k < a[0].length; k++) {
                sum += a[i][k] * b[k][j];
            }
            result[i][j] = sum;
        } 
    } 
    return result;

}
could anyone explain me how that works?
Dave
@BeingDS
Jun 20 2016 00:28
@josephkies you need to add two lines of code. One adds 'item' to the end of 'testArr'. The removes the first item in testArr and modifies a variable to make it return that number.
JosephKies
@josephkies
Jun 20 2016 00:28
I mean nextInLine.push([item])
okay
Dave
@BeingDS
Jun 20 2016 00:28
You're doing too much, and forgetting a step, based on the code you're showing me.
JosephKies
@josephkies
Jun 20 2016 00:29
so testArr.push([item])
Greg Duncan
@GregatGit
Jun 20 2016 00:29
@cyberwizkid did you do it inside the function
Dave
@BeingDS
Jun 20 2016 00:29
@josephkies You've got the first one. Now what do you think the second one is?
JosephKies
@josephkies
Jun 20 2016 00:29
and testArr.pop([arr]);
Dave
@BeingDS
Jun 20 2016 00:29
You're not popping.
You want a different command. Remember, you're trying to remove the first item in the array. Not the last one.
TechAgent
@cyberwizkid
Jun 20 2016 00:30
@GregatGit check this:
JosephKies
@josephkies
Jun 20 2016 00:30
shift
Dave
@BeingDS
Jun 20 2016 00:30
If you push and then pop, you'll adda number and then take it away.
TechAgent
@cyberwizkid
Jun 20 2016 00:30
// Setup
var outerWear = "T-Shirt";

function myOutfit() {
  // Only change code below this line



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

myOutfit();
changing the t-shirt to sweater takes me on a loop
Makhib Choudkhuri
@Makhib19
Jun 20 2016 00:31
Hi can anyone help out with this code?
Greg Duncan
@GregatGit
Jun 20 2016 00:31
@cyberwizkid there is no loop
Dave
@BeingDS
Jun 20 2016 00:31
@josephkies try it out and see what happens. Also remember that only arrays have []'s. variables don't/
Makhib Choudkhuri
@Makhib19
Jun 20 2016 00:31

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

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

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

Greg Duncan
@GregatGit
Jun 20 2016 00:32
inside the funciton change the value of outWear to "sweater"
Makhib Choudkhuri
@Makhib19
Jun 20 2016 00:32
It doesn't return a value of -22
It keeps saying null
TechAgent
@cyberwizkid
Jun 20 2016 00:32
@GregatGit what i mean by loop is that it passes one value at a timee
Dave
@BeingDS
Jun 20 2016 00:32
@Makhib19 you have a ) in the wrong place.
Greg Duncan
@GregatGit
Jun 20 2016 00:32
@Makhib19 you didn't use celsius
Dave
@BeingDS
Jun 20 2016 00:33
@josephkies any luck?
llamatarianism
@llamatarianism
Jun 20 2016 00:33
@Makhib19 fahrenheit = ((fahrenheit * 9) / 5) + 32;
fahrenheit is undefined
you're doing maths on something undefined
JosephKies
@josephkies
Jun 20 2016 00:33
hmm not yet
TechAgent
@cyberwizkid
Jun 20 2016 00:34
@GregatGit when i change the value of T-shirt, it says do not change the value of the global outerwear
Dave
@BeingDS
Jun 20 2016 00:34
Remember: two lines of code gives you the solution.
Makhib Choudkhuri
@Makhib19
Jun 20 2016 00:34
@Makhib19 you have a ) in the wrong place.
@Makhib19 you didn't use celsius
@Makhib19 fahrenheit = ((fahrenheit * 9) / 5) + 32;
Greg Duncan
@GregatGit
Jun 20 2016 00:34
@Makhib19 You have to use celsius in the equaltion , not fahrenheit again
Makhib Choudkhuri
@Makhib19
Jun 20 2016 00:34
Do I need to use the variable celcius instead?
Greg Duncan
@GregatGit
Jun 20 2016 00:34
This message was deleted
Dave
@BeingDS
Jun 20 2016 00:35
@josephkies it's two steps. 1) Add 'item' to the end of 'testArr'. 2) Remove and return as a result the first value in 'testArr'.
Greg Duncan
@GregatGit
Jun 20 2016 00:36
@cyberwizkid you ahve to do it on line 8
@Makhib19 yes
JosephKies
@josephkies
Jun 20 2016 00:36
got it!
Dave
@BeingDS
Jun 20 2016 00:36
@Makhib19 Also watch your parentheses. I think you'll find that one of yours is in the wrong spot.
@josephkies Great! Knew you could do it.
JosephKies
@josephkies
Jun 20 2016 00:37
@BeingDS thanks !!
CamperBot
@camperbot
Jun 20 2016 00:37
josephkies sends brownie points to @beingds :sparkles: :thumbsup: :sparkles:
:cookie: 207 | @beingds |http://www.freecodecamp.com/beingds
Makhib Choudkhuri
@Makhib19
Jun 20 2016 00:38

@Makhib19 yes
@Makhib19 Also watch your parentheses. I think you'll find that one of yours is in the wrong spot.

Sorry but I am still stuck. The var fahrenheight was already pre defined by the question?

Why do I not use it?
TechAgent
@cyberwizkid
Jun 20 2016 00:38
@GregatGit like var myOutfit = "swaeter";?
Greg Duncan
@GregatGit
Jun 20 2016 00:38
@cyberwizkid yes
Dave
@BeingDS
Jun 20 2016 00:38
@Makhib19 Because you're not trying to find fahrenheit. You're trying to find celsius.
@Makhib19 You already have fahrenheit. You need to take that and convert it to something else.
TechAgent
@cyberwizkid
Jun 20 2016 00:40
@GregatGit this:

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

function myOutfit() {
  // Only change code below this line

  var myOutfit = "sweater";

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

myOutfit();
Makhib Choudkhuri
@Makhib19
Jun 20 2016 00:41

@cyberwizkid yes
@Makhib19 Because you're not trying to find fahrenheit. You're trying to find celsius.

Hi I tried this:

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
var celcius;
celcius = ((fahrenheit * 9) / 5) + 32;
celcius = fahrenheit;
// Only change code above this line
return fahrenheit;
}

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

But fails :(

Norvin Burrus
@ndburrus
Jun 20 2016 00:41
@Makhib19 translate this into a formula, accurately: Fahrenheit is the temperature in Celsius times 9/5, plus 32. :sparkles:
Greg Duncan
@GregatGit
Jun 20 2016 00:41
@cyberwizkid no - you have now created a new variable called myOutfit that exists only in the myOutfit call
This message was deleted
Dave
@BeingDS
Jun 20 2016 00:42
@Makhib19 You have a ')' that is in the wrong place. It's ruining your formula.
Makhib Choudkhuri
@Makhib19
Jun 20 2016 00:42
But is that not the formula: C = (F * 9 / 5) + 32
Dave
@BeingDS
Jun 20 2016 00:43
You want to do 'fahrenheit 9/5' and instead you're doing '(fahrenheit 9)/5'
Greg Duncan
@GregatGit
Jun 20 2016 00:43
@Makhib19 your () are fine - this needs to be done in one line
Jerry Bendy
@jerrybendy
Jun 20 2016 00:43
Good morning ~
Dave
@BeingDS
Jun 20 2016 00:43
@GregatGit I don't think his () are fine.
Moisés Man
@moigithub
Jun 20 2016 00:43
F = C * 9 / 5 + 32
TechAgent
@cyberwizkid
Jun 20 2016 00:43
@GregatGit were is that? myOutfit call
Makhib Choudkhuri
@Makhib19
Jun 20 2016 00:44

@GregatGit I don't think his () are fine.

"temperature in Celsius times 9/5, plus 32"

Dave
@BeingDS
Jun 20 2016 00:45
@Makhib19 Correct. But your code you've got a ')' in the middle of your '9/5'.
Greg Duncan
@GregatGit
Jun 20 2016 00:45
@Makhib19 what it the formula for fahrenheit?
TechAgent
@cyberwizkid
Jun 20 2016 00:45
@GregatGit confused
Makhib Choudkhuri
@Makhib19
Jun 20 2016 00:45

@Makhib19 what it the formula for fahrenheit?

temperature in Celsius times 9/5, plus 32

@Makhib19 Correct. But your code you've got a ')' in the middle of your '9/5'.

Yeha but it would not make a difference

TechAgent
@cyberwizkid
Jun 20 2016 00:45
@GregatGit what do i have to do on line 8 to echo sweater for myOutfit
Greg Duncan
@GregatGit
Jun 20 2016 00:46
@Makhib19 make fahrenheit = that formula
@cyberwizkid outerWear = "sweater";
TechAgent
@cyberwizkid
Jun 20 2016 00:46
@GregatGit i wish to flog my head now
@GregatGit can i say myOutfit =
Makhib Choudkhuri
@Makhib19
Jun 20 2016 00:47

@Makhib19 make fahrenheit = that formula

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

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

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

Hmm I tried this

TechAgent
@cyberwizkid
Jun 20 2016 00:48
@GregatGit can i say myOutfit = "sweater";?
Greg Duncan
@GregatGit
Jun 20 2016 00:48
@Makhib19 why did you write var celcius;
@Makhib19 it is already in the function
delete it
TechAgent
@cyberwizkid
Jun 20 2016 00:48
@GregatGit you said: @cyberwizkid outerWear = "sweater";
Greg Duncan
@GregatGit
Jun 20 2016 00:49
@cyberwizkid yes
TechAgent
@cyberwizkid
Jun 20 2016 00:49
but i will be removing T-shirt default
Greg Duncan
@GregatGit
Jun 20 2016 00:49
@cyberwizkid do it in the function
TechAgent
@cyberwizkid
Jun 20 2016 00:49
myOutfit()?
Makhib Choudkhuri
@Makhib19
Jun 20 2016 00:49

@Makhib19 why did you write var celcius;

If I delete it, this comes up: ReferenceError:c elcius not defined

Greg Duncan
@GregatGit
Jun 20 2016 00:50
then you have spelt it wrong
Makhib Choudkhuri
@Makhib19
Jun 20 2016 00:50

then you have spelt it wrong

AHHHH OKAY THANK YOU so much!!!!!

This was killing me
That helps so much. Thank you :))

then you have spelt it wrong

So if it is already in a function does that mean it has already been defined?

Greg Duncan
@GregatGit
Jun 20 2016 00:52
@Makhib19 the function takes it as an input
TechAgent
@cyberwizkid
Jun 20 2016 00:52
@GregatGit Do not change the value of the global outerWear
@GregatGit i placed it inside the function as u said
Greg Duncan
@GregatGit
Jun 20 2016 00:53
@cyberwizkid what is the name of this chanllenge
TechAgent
@cyberwizkid
Jun 20 2016 00:53
@GregatGit Global vs Local Scope in Functions
Greg Duncan
@GregatGit
Jun 20 2016 00:55
@cyberwizkid then make it var outerWear inside the function
Makhib Choudkhuri
@Makhib19
Jun 20 2016 00:56

@Makhib19 the function takes it as an input

Ahh okay thank you @GregatGit :))

CamperBot
@camperbot
Jun 20 2016 00:56
makhib19 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 608 | @gregatgit |http://www.freecodecamp.com/gregatgit
TechAgent
@cyberwizkid
Jun 20 2016 00:58
@GregatGit i have done that
not passing
@GregatGit the var outWear = what?
@GregatGit see my code:

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

function myOutfit() {
  // Only change code below this line

  var myOutwear = "sweater";

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

myOutfit();
Greg Duncan
@GregatGit
Jun 20 2016 01:02
@cyberwizkid i don't think its meant to be called myOuterwear but outerWear
Janodus
@janodus
Jun 20 2016 01:03
what's going on guys. have a quick question.
TechAgent
@cyberwizkid
Jun 20 2016 01:04
@GregatGit so for myOutfit to return "sweater", i need to define myOuterwaer to = sweater, is that what u mean?
Janodus
@janodus
Jun 20 2016 01:04
I'm on the Javascript challenge: Record Collection. But can't seem to figure this one out.
TechAgent
@cyberwizkid
Jun 20 2016 01:04
@GregatGit i dont mind u show me this on team view
Janodus
@janodus
Jun 20 2016 01:05
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

      if (value !== "" && prop !== "tracks") {
        collection.id.prop = value;
      }    
      else if (collection.id.hasOwnProperty("tracks") === false) {
        collection.id.tracks = [];
        collection.id.tracks.push(value);
      }
      else if (prop == "tracks" && value !== "") {
        collection[id][tracks].push(value);
      }
      else if (value === "") {
        delete collection.id.prop;
      }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Fikri55
@Fikri55
Jun 20 2016 01:05
hello.
I wanted to ask something.
if in a function there is two return statements, is it just returning the first one?
Janodus
@janodus
Jun 20 2016 01:08
the function stops after processing the first return.
Ken Haduch
@khaduch
Jun 20 2016 01:08
@janodus - if you go back and review the lesson on accessing object properties with variables, you'll recall that when you have a property name contained in a variable (as you do with the prop function argument here) you cannot use dot notation. This is also true with the id function argument. I think that most of your errors are related to that issue.
Janodus
@janodus
Jun 20 2016 01:08
if you have an if statement, then it branches to see which should be returned
TechAgent
@cyberwizkid
Jun 20 2016 01:09
@GregatGit what is wrong hear:
// Setup
var outerWear = "T-Shirt";

function myOutfit() {
  // Only change code below this line

  OuterWear = "sweater";

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

myOutfit();
sorry to bother u
Juan Moraza
@Morazajuan
Jun 20 2016 01:09
how do i get the popped off value back again?
Norvin Burrus
@ndburrus
Jun 20 2016 01:09
@janodus this may be useful: Javascript Array Methods: Unshift(), Shift(), Push(), And Pop() :sparkles:
Juan Moraza
@Morazajuan
Jun 20 2016 01:09

// Example
var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop(); 
// removedFromOurArray now equals 3, and ourArray now equals [1,2]

// Setup
var myArray = [["John", 23], ["cat", 2]];

// Only change code below this line.
var removedFromMyArray;
myArray.pop(1);
removedFromMyArray = myArray[0];
Ken Haduch
@khaduch
Jun 20 2016 01:09
@janodus - the function should only perform one action when it is called, to returning after it is done is just fine (unless the profile lookup - that requires a different strategy.)
Juan Moraza
@Morazajuan
Jun 20 2016 01:10
["cat",2]
Janodus
@janodus
Jun 20 2016 01:10
@khaduch thanks, I figured it was related to bracket notation, but couldn't put my finger on it. Thanks for the help!
CamperBot
@camperbot
Jun 20 2016 01:10
janodus sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1349 | @khaduch |http://www.freecodecamp.com/khaduch
Dankbanks44
@Sloooop
Jun 20 2016 01:11
var myStr; "I am a \"double quoted\" string insde \"double quotes\"."; // Change this line
What am I missin' here
Says its undefined
Juan Moraza
@Morazajuan
Jun 20 2016 01:11
Anybody there?
Janodus
@janodus
Jun 20 2016 01:11
@ndburrus thanks. i figured i just needed push for one of the statements.
CamperBot
@camperbot
Jun 20 2016 01:11
janodus sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 656 | @ndburrus |http://www.freecodecamp.com/ndburrus
Juan Moraza
@Morazajuan
Jun 20 2016 01:12
How do i get the popped off value back?
Fikri55
@Fikri55
Jun 20 2016 01:13
@Morazajuan assign it to operator
Norvin Burrus
@ndburrus
Jun 20 2016 01:13
@janodus you're welcome... i wanted to post another nice article link for you... JS dot-notation vs. bracket notation ..nice job!
Fikri55
@Fikri55
Jun 20 2016 01:13
variable I mean
Juan Moraza
@Morazajuan
Jun 20 2016 01:13
how? @Fikri55
Fikri55
@Fikri55
Jun 20 2016 01:13
a = list.pop()
Juan Moraza
@Morazajuan
Jun 20 2016 01:14
// Example
var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop(); 
// removedFromOurArray now equals 3, and ourArray now equals [1,2]

// Setup
var myArray = [["John", 23], ["cat", 2]];

// Only change code below this line.
var removedFromMyArray;
myArray.pop(1);
removedFromMyArray = list.pop();
thats what i have so far
Fikri55
@Fikri55
Jun 20 2016 01:15
var removedFromMyArray = list.pop()
Sai Wentum
@smwentum
Jun 20 2016 01:15
your popping twice
Juan Moraza
@Morazajuan
Jun 20 2016 01:15
thats what i gave but its not working
Fikri55
@Fikri55
Jun 20 2016 01:15
with ;?
Greg Duncan
@GregatGit
Jun 20 2016 01:16
@cyberwizkid because you don't want to change the initial var outerWear - inside the function you have to use var outerWear - that will create a new varaible (with the same name)
Bryan Castleman
@castlemaninc
Jun 20 2016 01:16

On 'Everything Be True' algorithm challenge. I don't understand how the pre or predicate relates.

"Check if the predicate (second argument) is truthy on all elements of a collection (first argument)."

What does that mean exactly?

Fikri55
@Fikri55
Jun 20 2016 01:16
the third line from last, would be var removedFromMyArray = list.pop();
then the 1st and 2nd line from last is deleted.
sorry, change the list into myArray
Ken Haduch
@khaduch
Jun 20 2016 01:17
@janodus - you're welcome - let us know if you cannot get all of the tests to run.
Fikri55
@Fikri55
Jun 20 2016 01:17
removedFromMyArray = myArray.pop();
Janodus
@janodus
Jun 20 2016 01:18
@khaduch thanks :)
CamperBot
@camperbot
Jun 20 2016 01:18
janodus sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: janodus already gave khaduch points
TechAgent
@cyberwizkid
Jun 20 2016 01:18
@GregatGit this:
// Setup
var outerWear = "T-Shirt";

function myOutfit() {
  // Only change code below this line

  var OuterWear = "sweater";

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

myOutfit();
Greg Duncan
@GregatGit
Jun 20 2016 01:19
@cyberwizkid you have a typ0 - outerWear not OuterWear -
Janodus
@janodus
Jun 20 2016 01:20
@ndburrus hey wanted to say thanks again for porting the article regarding . and bracket notation. that instantly got me to understand exactly what I was doing wrong. problem solved.
CamperBot
@camperbot
Jun 20 2016 01:20
janodus sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: janodus already gave ndburrus points
Juan Moraza
@Morazajuan
Jun 20 2016 01:21
```
Dankbanks44
@Sloooop
Jun 20 2016 01:21
var myStr; "I am a \"double quoted\"string inside\"double quotes\".";
Not sure what I'm missing on this one.
Juan Moraza
@Morazajuan
Jun 20 2016 01:21

// Example
var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop(); 
// removedFromOurArray now equals 3, and ourArray now equals [1,2]

// Setup
var myArray = [["John", 23], ["cat", 2]];

// Only change code below this line.
var removedFromMyArray = myArray.pop();
myArray.pop(1);
removedFromMyArray = list.pop(1);
Stil not working
Fikri55
@Fikri55
Jun 20 2016 01:21
can anyone explain to me about return in javascript? are any codes below return not executed? or are they, but the return just give us the first value returned?
Moisés Man
@moigithub
Jun 20 2016 01:22
= sign @Sloooop to SET/assign values to the variable
theVar = theValue
Fikri55
@Fikri55
Jun 20 2016 01:22

this:
function testLessOrEqual(val) {
if (val<=12) { // Change this line
return "Smaller Than or Equal to 12";
}

if (val<=24) { // Change this line
return "Smaller Than or Equal to 24";
}

return "25 or More";
}

// Change this value to test
testLessOrEqual(10);

I don't understand why it is like that, instead of structured else if and else....

Dankbanks44
@Sloooop
Jun 20 2016 01:22
says expected expression, got =
Moisés Man
@moigithub
Jun 20 2016 01:23
its
theVar = theValue
NOT theVar; theValue
Janodus
@janodus
Jun 20 2016 01:24
@Fikri55 think of return as the "answer" JS is giving back to you. once a return has been reached, then the if statement knows that you've found your answer, and basically ends the if block.
500seeds
@500seeds
Jun 20 2016 01:24
Hey guys, constantly stuck on the bonfires exercise. I always find myself looking for solution, what should I do?
Fikri55
@Fikri55
Jun 20 2016 01:24
Yes. Then after if block ends, there is the second return.
Juan Moraza
@Morazajuan
Jun 20 2016 01:25
how to assign "assigning the 'popped off' value "?
Fikri55
@Fikri55
Jun 20 2016 01:26
@Janodus, that's why I am wondering, since the code executes two return, whether it returns just the first value returned, or the code below is not executed.
Janodus
@janodus
Jun 20 2016 01:26
@Fikri55 in the case above, you have an if statement with 3 possible return scenarios. depending on the number you plug into the function, then the first IF case may be false, so instead of RETURNing that particular statement, it goes to the next IF branch, if that branch proves true, then JS will RETURN that statement... if everything proves false (js has gone through all your else if statements), then it returns that very last item on the list.
@Fikri55 ah gotcha. in your case, that function will only return 1 function (because a successful return effectively cuts the function/if branch short and immediately gives you the statement you want to give on that particular IF branch.
since you're testing for "10", then the first statement should always fire and RETURN. The other statement and the else statement are never considered.
Fikri55
@Fikri55
Jun 20 2016 01:28
So, for example if I add this line:
value + 10;
above return "25 or more"
it is never executed?
Janodus
@janodus
Jun 20 2016 01:29
never
Fikri55
@Fikri55
Jun 20 2016 01:30
I haven't encountered for loop in this. But hypothetically,
for i in iteration {
return i
}
Janodus
@janodus
Jun 20 2016 01:31
if you put value = value + 10 (or value =+ 10), and place that ABOVE the IF statement start, then the IF statement will be checking for a higher number then the number argument given in the function call (which is 10 originally).
Fikri55
@Fikri55
Jun 20 2016 01:31
then it would return just the first value?
E-Tank
@E-Tank
Jun 20 2016 01:31
Working on Truncate a String and I've got a weird reaction on the ones where the number is equal to or less than three.

function truncateString(str, num) {
  // Clear out that junk in your trunk
  if(str.length > num){
    str = str.slice(0, [num - 3]) + "...";
  }
  else if(str.length > num && num <= 3){
    str = str.slice(0, [num]) + "...";
  }
  return str;
}

truncateString("Absolutely Longer", 2);
This returns Absolutely Longe...
When it should return Ab
Erm, Ab...
Janodus
@janodus
Jun 20 2016 01:32
@Fikri55 if you created a for look that returns i, then it would RETURN I, but the loop would instantly stop at the first round.
loop for loop
Fikri55
@Fikri55
Jun 20 2016 01:33
I see the behavior of return. Thanks Janodus.
thanks @janodus
CamperBot
@camperbot
Jun 20 2016 01:33
fikri55 sends brownie points to @janodus :sparkles: :thumbsup: :sparkles:
:cookie: 222 | @janodus |http://www.freecodecamp.com/janodus
Janodus
@janodus
Jun 20 2016 01:34
@Fikri55 np :) glad to help
E-Tank
@E-Tank
Jun 20 2016 01:35
Can anyone help me out?
Janodus
@janodus
Jun 20 2016 01:36
@ndburrus : ```

// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

      if (value !== "" && prop !== "tracks") {
        collection[id][prop] = value;
      }    
      else if (collection[id].hasOwnProperty("tracks") === false) {
        collection[id].tracks = [];
        collection[id].tracks.push(value);
      }
      else if (prop == "tracks" && value !== "") {
        collection[id].tracks.push(value);
      }
      else if (value === "") {
        delete collection[id][prop];
      }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
@ndburrus got it :)
shivamsonu29
@shivamsonu29
Jun 20 2016 01:39
function diffArray(arr1, arr2) {
  var newArr = [];
  var newArr2= [];
  var newArr3= [];
  var newArr4= [];
  var indexOfi;
  var indexOfj;
  // Same, same; but different.
    function crop(val){
               return val!==arr1[indexOfi];}
function crop2(val){
               return val!==arr2[indexOfj];}


 var len1=arr1.length;
  var len2 =arr2.length;
  for(var i=0;i<len1;i++)
    {
      for(var j=len1;j<len2;j++)
        {
          if(arr1[i]===arr2[j])
            {
              indexOfi=arr1.indexOf(arr1[i]);
              indexOfj=arr2.indexOf(arr2[j]);
              newArr2=newArr2.push(arr1.filter(crop));
              newArr3=newArr3.push(arr2.filter(crop2));

            }
        }
    }
  newArr4=newArr2.concat(newArr3);

return newArr4;
}
diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
error is coming - newArr2 is not a function, what to do??
E-Tank
@E-Tank
Jun 20 2016 01:39
So nobody can help me here?
shivamsonu29
@shivamsonu29
Jun 20 2016 01:43
This message was deleted

@E-Tank

function truncateString(str, num) {
  // Clear out that junk in your trunk
  var len=str.length;
  var fst='';
  if(len>num&&num>3)
    {


      fst=str.slice(0,num-3);
      return fst+'...';

    }
  else if(num<3||num==3)
    {
      fst=str.slice(0,num);
      return fst+'...';
    }
  else if(len<num||len==num)
    return str;




}

truncateString("A-tisket a-tasket A green and yellow basket", 11);

compare your program, you will easily find your mistakes...

E-Tank
@E-Tank
Jun 20 2016 01:47
I'm comparing it and I'm not seeing the difference.
Only difference I see is that I don't check for it being <=3
On the first one, and instead on the second.
And that was it.
shivamsonu29
@shivamsonu29
Jun 20 2016 01:49
@E-Tank try to remove brackets you have mentioned in slice such as from num-3
E-Tank
@E-Tank
Jun 20 2016 01:50
It works with me moving the check for it being less than 3 to the first check instead of the second.
The brackets are fine.
Syntax
str.slice(beginSlice[, endSlice])
Justin Watke
@jbiology
Jun 20 2016 01:51
Anyone have trouble with challenge 173
E-Tank
@E-Tank
Jun 20 2016 01:52
Basically if the number was <=3 it would do it twice, instead of once.
@shivamsonu29 thanks anyway.
CamperBot
@camperbot
Jun 20 2016 01:52
e-tank sends brownie points to @shivamsonu29 :sparkles: :thumbsup: :sparkles:
:cookie: 281 | @shivamsonu29 |http://www.freecodecamp.com/shivamsonu29
shivamsonu29
@shivamsonu29
Jun 20 2016 01:57
@E-Tank you can try by replacing <= with < || == way..
@E-Tank it may work..
Nguyen Hoang
@bkstorm
Jun 20 2016 02:02
I have a problem with the Wikipedia Viewer project. When the client send a request to wikipedia to get search result, I get a error that shows: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access
Here is the project on codepen: wikipedia
shivamsonu29
@shivamsonu29
Jun 20 2016 02:03
function diffArray(arr1, arr2) {
  var newArr = [];
  var newArr2= [];
  var newArr3= [];
  var newArr4= [];
  var indexOfi;
  var indexOfj;
  // Same, same; but different.
    function crop(val){
               return val!==arr1[indexOfi];}
function crop2(val){
               return val!==arr2[indexOfj];}


 var len1=arr1.length;
  var len2 =arr2.length;
  for(var i=0;i<len1;i++)
    {
      for(var j=len1;j<len2;j++)
        {
          if(arr1[i]===arr2[j])
            {
              indexOfi=arr1.indexOf(arr1[i]);
              indexOfj=arr2.indexOf(arr2[j]);
              newArr2=newArr2.push(arr1.filter(crop));
              newArr3=newArr3.push(arr2.filter(crop2));

            }
        }
    }
  newArr4=newArr2.concat(newArr3);

return newArr4;
}
diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
error is coming - newArr2 is not a function, what to do??
co0lsky
@co0lsky
Jun 20 2016 02:10
@bkstorm Try to use dataType: 'jsonp' in your jquery ajax call
Michael Suchorolski
@mikesuchor
Jun 20 2016 02:11
any idea why when I sort an array it outputs [1,1000,1001,857]? Why isn't the 857 the 2nd element?
co0lsky
@co0lsky
Jun 20 2016 02:13
@shivamsonu29 Array.push() is returning the length of the array instead of an array. At your code "newArr2=newArr2.push(arr1.filter(crop));", the newArr2 becomes an int.
@mikesuchor Are they int type or string type in the array?
Nguyen Hoang
@bkstorm
Jun 20 2016 02:15
@co0lsky : thank you, it works, I will read more about it.
CamperBot
@camperbot
Jun 20 2016 02:15
bkstorm sends brownie points to @co0lsky :sparkles: :thumbsup: :sparkles:
:cookie: 20 | @co0lsky |http://www.freecodecamp.com/co0lsky
co0lsky
@co0lsky
Jun 20 2016 02:15
@bkstorm you're welcome
Michael Suchorolski
@mikesuchor
Jun 20 2016 02:15
@co0lsky the default, string?
@mikesuchor you might need a compare function to make it sort
William Cabell
@wbac88
Jun 20 2016 02:22
Hi, I was hoping to get some help with nested for loops. I don't understand the example they give:
var arr = [
[1,2], [3,4], [5,6]
];
for (var i=0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++) {
console.log(arr[i][j]);
}
}
I don't understand how the for i and for j work together.
DC*
@desyncr
Jun 20 2016 02:23
@wbac88 The first loops over [1, 2], [3, 4] and so on, inside that, the other loops over each 1, 2; 3, 4 and so on.
Tiffany White
@twhite96
Jun 20 2016 02:24
Need some help with “Where Do I belong” algorithm
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  var indexed = arr.sort(function(element) {
  return indexed.indexOf(element);  
   if () 

  });

}

getIndexToIns([40, 60], 50);
DC*
@desyncr
Jun 20 2016 02:24
@wbac88 In other words, arr[i] with i = 0, would be [1, 2]; arr[i][j] with i = 0 and j = 0 would be 1.
Tiffany White
@twhite96
Jun 20 2016 02:25
I am reading the wiki but am not sure how to see if the first number is bigger. I also don’t know how to deal with a test case where there is no index
DC*
@desyncr
Jun 20 2016 02:29
@twhite96 You have to loop over the array and make a math comparison
@twhite96 Not sure what you mean by "no index"
Tiffany White
@twhite96
Jun 20 2016 02:30

From the wiki "Hint: 3

If there is no index for that number then you will have to deal with that case too.” @desyncr

William Cabell
@wbac88
Jun 20 2016 02:30
@desyncr OK, so this is what I've written for the challenge:

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 = product * multiplyAll[i][j]; 
           console.log(arr[i][j]);                               }
    }
  // Only change code above this line
  return product;
}
Tiffany White
@twhite96
Jun 20 2016 02:31
So what exactly does sort do here @desyncr?
William Cabell
@wbac88
Jun 20 2016 02:31
It returns cannot read propert 0 of undefined.
DC*
@desyncr
Jun 20 2016 02:32
@twhite96 You have to sort the array in order to determine the item order, otherwise you'll have a headache dealing with an unsorted list
shivamsonu29
@shivamsonu29
Jun 20 2016 02:33
is anybody have idea about how to find difference of 2 arrays and to give output the array having elements which are neither in 1st array or 2nd array..
DC*
@desyncr
Jun 20 2016 02:33
@wbac88 product = product * multiplyAll[i][j] ?
@wbac88 multiplyAll is the name of the function, not an array. You are working with arr, the function argument.
@wbac88 Also, try to properly format your code, it'll be more easily to read and understand
@shivamsonu29 I'd use indexOf, to determine if each elements belongs to the other arr
William Cabell
@wbac88
Jun 20 2016 02:35
@desyncr Got it, thank you. I appreciate the help.
CamperBot
@camperbot
Jun 20 2016 02:35
wbac88 sends brownie points to @desyncr :sparkles: :thumbsup: :sparkles:
:cookie: 279 | @desyncr |http://www.freecodecamp.com/desyncr
Kevin Murphy
@kaym0
Jun 20 2016 02:38
Need help with this

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

return item; // Change this line
}

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

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

Add the number to the end of the array, the remove the first element of the array.
DC*
@desyncr
Jun 20 2016 02:39
@kaym0 You got built-in functions for that. Remember push/pop and shift/unshift?
Kevin Murphy
@kaym0
Jun 20 2016 02:40
Yes but I can't figure out how to write it
DC*
@desyncr
Jun 20 2016 02:42
@kaym0 Well, first you add an element to the end of the array (push), then you remove one from the front of the array (shift).
Kevin Murphy
@kaym0
Jun 20 2016 02:43
I tried that, but
I wrote this
DC*
@desyncr
Jun 20 2016 02:43
@kaym0 IIRC you have to return the element just removed, use a temp variable for that
Kevin Murphy
@kaym0
Jun 20 2016 02:43
item = arr.push(); item=arr.shift();
Luis Carlos Garcia Barajas
@Luiko
Jun 20 2016 02:45
@kaym0 there some functions that does not return any value
ranranking
@ranranking
Jun 20 2016 02:46
Excuse me. In the Falsy Bouncer challenge, how do I check NaN ? If I use isNaN() function, strings will also return true, while non-blank strings should not be removed.
DC*
@desyncr
Jun 20 2016 02:47
@kaym0 Check out how you're using the push function.
Luis Carlos Garcia Barajas
@Luiko
Jun 20 2016 02:47
if the fuction does not return a value you can't assing that function to a value
Kevin Murphy
@kaym0
Jun 20 2016 02:48
I mean this is pretty difficult because I learned that briefly last night, and today I did at least 5 challenges without ever hearing about those commands and now suddenly there's a test where I have to combine multiples of them without even an examaple
DC*
@desyncr
Jun 20 2016 02:49
@kaym0 I think there are a bunch of steps dealing with push/pop shift/unshift. You may go back a few steps
Kevin Murphy
@kaym0
Jun 20 2016 02:50
Yes, but they do not tell you how to combine multiples of those commands
You just do one pop, one shift, etc
It doesn't ever explain how to combine two different ones
Luis Carlos Garcia Barajas
@Luiko
Jun 20 2016 02:51
@kaym0 yes, but everything you see in the challenges you will use, maybe you should take notes.
DC*
@desyncr
Jun 20 2016 02:52
@kaym0 Well, when dealing with big programming problems you have to deal with complexity and apply a "divide and conquer" approach. Do the same thing here.
@kaym0 Divide the problem. 1- Add an element to the end of the array, 2- Remove an element from the front of the array, 3- Combine both solutions.
3jM310
@3jM310
Jun 20 2016 02:57
hey guys i got this var myStr = 'a href="http:www.example.com" target="blank"Link'; and its missing this what i need change Only remove the backslashes \ used to escape quotes.
Diego Mayer
@Chrono79
Jun 20 2016 02:58
@ranranking the way for check for NaN is value != value
ranranking
@ranranking
Jun 20 2016 02:59
@Chrono79 Thanks, I got it. Simply if(val) will do.
CamperBot
@camperbot
Jun 20 2016 02:59
ranranking sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1244 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 20 2016 02:59
@ranranking yes, also !!val and Boolean(val)
David Halls
@DavidHalls
Jun 20 2016 03:03
@3jM310 you removed more than just the \backslashes\
DC*
@desyncr
Jun 20 2016 03:03
@Chrono79 Used !! in a challenge. Felt dirty. Like after working with php. :smile:
Kevin Murphy
@kaym0
Jun 20 2016 03:04
This is the first problem I've encountered so far in this whole program. I guess I'll start taking notes.
3jM310
@3jM310
Jun 20 2016 03:06
So need i to add somenthing? @Byzgig
David Halls
@DavidHalls
Jun 20 2016 03:07
@3jM310 yes, it looks like some < and > tags
3jM310
@3jM310
Jun 20 2016 03:09
Ok i got it thanks @Byzgig
CamperBot
@camperbot
Jun 20 2016 03:09
3jm310 sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 340 | @byzgig |http://www.freecodecamp.com/byzgig
martinronquillo
@martinronquillo
Jun 20 2016 03:13
Can someone help on on the "Selecting from many options with Switch Statements"

function caseInSwitch(val) {
var answer = "";
// Only change code below this line

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

// Change this value to test
caseInSwitch(1);

here is the code that i have so far
David Halls
@DavidHalls
Jun 20 2016 03:18
@martinronquillo ill help but that is what you start with
martinronquillo
@martinronquillo
Jun 20 2016 03:20

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

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

// Change this value to test
caseInSwitch(1);

@Byzgig
David Halls
@DavidHalls
Jun 20 2016 03:21
@martinronquillo getting there, but you dont want to return in the switch, you want to set the result to answer
Arjun
@arjunsingh81989
Jun 20 2016 03:21
Hi, knockout question how do you update the foreach binding that is bound to an observableArray upon a change in an observableArray
like, how will you update
<ul data-bind = "foreach: obserArrayList">
    <li data-bind = "text: $data"></li>
</ul>
David Halls
@DavidHalls
Jun 20 2016 03:22
@martinronquillo and look at the example on the challenge, you need two key words from the top
Arjun
@arjunsingh81989
Jun 20 2016 03:23
This message was deleted
martinronquillo
@martinronquillo
Jun 20 2016 03:24
@Byzgig I don't understand how i would set the result to the answer. Also am I only missing the switch statements?
David Halls
@DavidHalls
Jun 20 2016 03:25
@martinronquillo yea, a switch starts like this --- switch(value to check){ your cases go here }
martinronquillo
@martinronquillo
Jun 20 2016 03:26
@Byzgig hang on I'm about to try something in my code
@Byzgig I got it thanks!
CamperBot
@camperbot
Jun 20 2016 03:27
martinronquillo sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 341 | @byzgig |http://www.freecodecamp.com/byzgig
David Halls
@DavidHalls
Jun 20 2016 03:28
cheers!
Francisco Pena
@daiky00
Jun 20 2016 03:31
can anyone help me with this?
// 2. Longest Increasing Sub-Array.

/**
 * Finds the longest increasing subarray from a given array
 * of integers. A subarray is said to be "increasing" when each
 * non-last value is followed by a value that is greater
 * than the previous value.
 * If there are multiple contenders of the same length, returns
 * the first occurring subarray.
 * If no increasing sub-array of length 2 or greater is found,
 * returns an empty array.
 *
 * @param {number[]} seq  An array of integers
 * @returns {number[]} The longest increasing subarray of `seq`
 */
function longestIncrSubArray(seq) {
  var by_incList = [];
  for (var i = 0; i < seq.length; i++) {
    if (seq[i].length > 1) {
      var moi_Incr = seq[i].every((x, i, a) => {
        //console.log(x,i,a);
        return i === 0 || a[i - 1] < a[i];
      });
      if (moi_Incr) by_incList.push(seq[i]);
    }
  }
  if (by_incList.length) {
    by_incList.sort((a, b) => (b.length - a.length));
    console.log(by_incList);
    return by_incList[0];
  }
  return [];

}
Juan Moraza
@Morazajuan
Jun 20 2016 03:33
anybody can tell me why i doesnt work

function factorialize(num) {
  if (num=5){
    num=120;
  }else if(num=10){
    num=3628800;
  }else if(num=20){
    num=2432902008176640000;
  }else if(num=0){
    num=1;
  }
  else{
    num=5;
  }
  return num;
}

factorialize(5);
factorialize(10);
factorialize(20);
factorialize(0);
David Halls
@DavidHalls
Jun 20 2016 03:33
@daiky00 what challenge is it
@Morazajuan dont hard code the answer
Francisco Pena
@daiky00
Jun 20 2016 03:34
@Byzgig this is not challenge
hahahaha
this actually an interview question
DC*
@desyncr
Jun 20 2016 03:35
@Morazajuan First, you are asigning a value, not comparing, then don't hardcode the results
Francisco Pena
@daiky00
Jun 20 2016 03:35
i mean some challenges to join a company
@Byzgig can you help me?
I am stuck
ftarlaci
@ftarlaci
Jun 20 2016 03:37

I get an error on challenge 133. Instruction goes: Assign the value 7 to variable a.

Assign the contents of a to variable b.

my code is var a;
var b;
// Only change code below this line
var a = 7;
var b = a;
"Do not change code above the line” is the error message I get although I didnt touch it above the line.
anyone has any idea?
David Halls
@DavidHalls
Jun 20 2016 03:38
@ftarlaci you only need var the first time a variable is declared
@daiky00 you probably have a better handle on it than me, sorry
Francisco Pena
@daiky00
Jun 20 2016 03:39
@Byzgig sersiouly?
hahahahha
ftarlaci
@ftarlaci
Jun 20 2016 03:39
even without the “var” it is the same error @Byzgig
DC*
@desyncr
Jun 20 2016 03:39
@daiky00 What's the issue? it's not correctly determining when an array is increasing?
David Halls
@DavidHalls
Jun 20 2016 03:39
@daiky00 youve been on FCC for like 6 months, ive been on for like 3 weeks
Francisco Pena
@daiky00
Jun 20 2016 03:39
read the problem and see the fucntion and tell me whats wrong
@desyncr
DC*
@desyncr
Jun 20 2016 03:40
@daiky00 Haha no
Francisco Pena
@daiky00
Jun 20 2016 03:40
@desyncr why not ? :(
DC*
@desyncr
Jun 20 2016 03:41
@daiky00 I'm here to help, not to do other's work
David Halls
@DavidHalls
Jun 20 2016 03:41
@ftarlaci what is the name of the challenge
Francisco Pena
@daiky00
Jun 20 2016 03:41
@desyncr I know that but im not seeing my mistake
@desyncr thats why I am asking for your help
ftarlaci
@ftarlaci
Jun 20 2016 03:42
Storing Values with the Assignment Operator
Francisco Pena
@daiky00
Jun 20 2016 03:42
otherwise what is help then?
Sandra Lucía
@SandraLuciaPF
Jun 20 2016 03:42
HELP ME WITH Storing Values with the Assignment Operator
CamperBot
@camperbot
Jun 20 2016 03:42
no wiki entry for: me with storing values with the assignment operator
Sandra Lucía
@SandraLuciaPF
Jun 20 2016 03:42
PLEASE
David Halls
@DavidHalls
Jun 20 2016 03:43
@ftarlaci reset your code, then write it agian, you have it right
ftarlaci
@ftarlaci
Jun 20 2016 03:43
tried that too @Byzgig
DC*
@desyncr
Jun 20 2016 03:43
@daiky00 I gave you some help, though. Divide the problem in it's components and evaluate their results. Do they match with the expected results?
Francisco Pena
@daiky00
Jun 20 2016 03:43
pfff
nvm
DC*
@desyncr
Jun 20 2016 03:44
@daiky00 haha alright
ftarlaci
@ftarlaci
Jun 20 2016 03:44
ah got it this time @Byzgig thank you!
CamperBot
@camperbot
Jun 20 2016 03:44
ftarlaci sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 342 | @byzgig |http://www.freecodecamp.com/byzgig
David Halls
@DavidHalls
Jun 20 2016 03:44
@ftarlaci oh, i see in the original statement it has var b = 2; it might check this too
Juan Moraza
@Morazajuan
Jun 20 2016 03:48
@Byzgig its challege 180 Factorialize a number @desyncr
Should i be using if statements? @Byzgig @desyncr
David Halls
@DavidHalls
Jun 20 2016 03:49
@Morazajuan i know, you should try using a for loop
DC*
@desyncr
Jun 20 2016 03:50
@Morazajuan You have to iterate (for loop) the number of times you are given (argument), store the partial result in a temp variable and return the final result
Juan Moraza
@Morazajuan
Jun 20 2016 03:50
but the bottom part is right?
@desyncr @Byzgig

function factorialize(num) {
  for()
  return num;
}

factorialize(5);
factorialize(10);
factorialize(20);
factorialize(0);
David Halls
@DavidHalls
Jun 20 2016 03:51
@Morazajuan the computer will generate that part when it runs the test, you dont need it
Juan Moraza
@Morazajuan
Jun 20 2016 03:51
oh okay that makes sense, let me try
@Byzgig
DC*
@desyncr
Jun 20 2016 03:52
@Morazajuan I'd not use num in the return statement, because it's the argument given, you may use it for other things.
David Halls
@DavidHalls
Jun 20 2016 03:52
^^
DC*
@desyncr
Jun 20 2016 03:52
@Morazajuan I tend to create a "result" to work with, then I'd "return result;"
Juan Moraza
@Morazajuan
Jun 20 2016 03:53
okay got it!

     function factorialize(num) {

  for(result=num!){
    return result;
  }
      }

factorialize(5);
not working
David Halls
@DavidHalls
Jun 20 2016 03:55
@Morazajuan your getting there
your for loop is wack though
Juan Moraza
@Morazajuan
Jun 20 2016 03:56
lol thanks
it says unexpected token
DC*
@desyncr
Jun 20 2016 03:56
@Morazajuan There is no factorial built-in function in js
@Morazajuan You have to do the math part yourself
Juan Moraza
@Morazajuan
Jun 20 2016 03:57
and that is why i need the for loop?
@desyncr
DC*
@desyncr
Jun 20 2016 03:57
@Morazajuan 5! = 5 * 4 * 3 * 2 * 1
@Morazajuan Exactly. You have a number of iterations. Use it to iterate in a for loop.
Stefan Bekirov
@bekir0v
Jun 20 2016 04:01

hey how can I make algoritam to conver celsius to fahrenheit i did dis but it says is not ok
function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
celsius = 'convertToF'*9/5+32;

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

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

Juan Moraza
@Morazajuan
Jun 20 2016 04:02
something like this?

function factorialize(num) {

for (int i = 0; i < num; i++) {
     num*1; 
    }
  return num;
      }

factorialize(5);
David Halls
@DavidHalls
Jun 20 2016 04:02
@Morazajuan var not int
@Morazajuan getting closer
Juan Moraza
@Morazajuan
Jun 20 2016 04:03

function factorialize(num) {

for (var i = 0; i < num; i++) {
     num*i; 
    }
  return num;
      }

factorialize(5);
i also change 1 to i
changed
do you know why i get this error: "
unexpected identifier"
?
@Byzgig
David Halls
@DavidHalls
Jun 20 2016 04:04
@Morazajuan k, with how that is written, num starts at 5, first loop it becomes 0, then it stays 0
DC*
@desyncr
Jun 20 2016 04:05
@Morazajuan First, the expression num*i; leaves the result floating around, you have to store it in a variable
David Halls
@DavidHalls
Jun 20 2016 04:06
@bekir0v you need to make the assignment to fahrenheit
Stefan Bekirov
@bekir0v
Jun 20 2016 04:06
how
DC*
@desyncr
Jun 20 2016 04:06
@Morazajuan Then as @Byzgig said, don't start with 0. Think how a factorial work.
David Halls
@DavidHalls
Jun 20 2016 04:07

celsius = 'convertToF'*9/5+32;

// Only change code above this line
return fahrenheit;

Juan Moraza
@Morazajuan
Jun 20 2016 04:07
```

function factorialize(num) {

for (var i = 0; i < num; i++) {
    i = num*i; 
    }
  return num;
      }

factorialize();
David Halls
@DavidHalls
Jun 20 2016 04:07
you return fahrenheit, but make changes to celsius
Juan Moraza
@Morazajuan
Jun 20 2016 04:07
okay i got the first part right
David Halls
@DavidHalls
Jun 20 2016 04:08
@Morazajuan that will not run, because i = num * i will exit the loop early
DC*
@desyncr
Jun 20 2016 04:08
@Morazajuan Never change the count variable you use to iterate, it may cause unintended effects (infinite loops etc)
@Morazajuan Let's try this. Remember the formula: 5! = 5 * 4 * 3 * 2 * 1? Try to do that (or 1 * 2 * 3 * 4 * 5, that's easier)
@Morazajuan Try to make a for loop that prints 1, 2, 3, 4 and 5
Jackson Leb
@JackLeb130111
Jun 20 2016 04:15
can anyone help me with Adding a default option in Switch statements

function switchOfStuff(val) {
  var answer = "";
    switch (answer) {
      case "a":
        return "apple";
        break;

      case "b":
        return "bird";
        break;

      case "c":
        return "cat";
        break;

      default:
        return "stuff";
    }
  return answer;  
}

// Change this value to test
switchOfStuff(1);
DC*
@desyncr
Jun 20 2016 04:17
@JackLeb130111 It looks good to me. You may have to assign the value to answer rather than returning right away
@JackLeb130111 It's functionally the same thing but to pass the test's checks
Jackson Leb
@JackLeb130111
Jun 20 2016 04:17
@desyncr like
val = "apple"
?
DC*
@desyncr
Jun 20 2016 04:19
@JackLeb130111 Yeah, but assign it to the answer variable, not val.
Jackson Leb
@JackLeb130111
Jun 20 2016 04:19
@desyncr ok ill try it
Impossibeard
@Impossibeard
Jun 20 2016 04:41
Doesn't seem like FCC really covers a lot of JS Events and interacting with DOM elements, unless I'm missing something. I'm really struggling with JS in that regard. Anyone have any good resources?
Isaac Guerreiro
@isaacguerreir
Jun 20 2016 04:46
Hi.
I don't understand the word blank lesson in javascript part.
Corey
@squawpaw
Jun 20 2016 04:48
Hi @isaacguerreir, I can try to help! What don't you understand?
Sandra Lucía
@SandraLuciaPF
Jun 20 2016 04:49
would someone please help me in Understanding Uninitialized Variables? is the fifth in JS
Sultan Yerumbayev
@Sultan91
Jun 20 2016 04:50
Hello people, Is it ok to use code solutions from Github Free codecamp's page?
David Halls
@DavidHalls
Jun 20 2016 04:50
@SandraLuciaPF i got you bro
Sandra Lucía
@SandraLuciaPF
Jun 20 2016 04:51

// Initialize these three variables
var a;
var b;
var c;

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";

the instructions are:
a should be defined and have a value of 6

b should be defined and have a value of 15

c should not contain undefined and should have a value of "I am a String!"

Do not change code below the line

// Initialize these three variables
var a;
var b;
var c;

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";

I don't get it
David Halls
@DavidHalls
Jun 20 2016 04:52

the instructions are:
a should be defined and have a value of 6

b should be defined and have a value of 15

c should not contain undefined and should have a value of "I am a String!"

Sandra Lucía
@SandraLuciaPF
Jun 20 2016 04:53
yes
David Halls
@DavidHalls
Jun 20 2016 04:54
so do that
Impossibeard
@Impossibeard
Jun 20 2016 04:54
For the Factorialize A Number challenge, why should factorialize(0) = 1?
Shouldn't 0 * 0 = 0? lol
Sandra Lucía
@SandraLuciaPF
Jun 20 2016 04:55
sorry, English is not my main language and that's why is so difficult to me but thanks @Byzgig
CamperBot
@camperbot
Jun 20 2016 04:55
sandraluciapf sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 343 | @byzgig |http://www.freecodecamp.com/byzgig
Corey
@squawpaw
Jun 20 2016 04:56
@Impossibeard it took me a while to wrap that one around my head at first too, but this video helped me out: https://www.khanacademy.org/math/probability/probability-and-combinatorics-topic/permutations/v/zero-factorial-or-0
I think the summary was: it just is. lol
Ian Arsenault
@ianarsenault
Jun 20 2016 04:56
LOL
Why? Because!
anyone know the regex to get rid of just comma's and whitespace?
David Halls
@DavidHalls
Jun 20 2016 04:57
@Impossibeard because, you know that multiplying anything by 0 = 0, so why would you start at 0?
Ian Arsenault
@ianarsenault
Jun 20 2016 04:57
^ Yup
David Halls
@DavidHalls
Jun 20 2016 04:58
@SandraLuciaPF sorry buddy, ill try to help
Impossibeard
@Impossibeard
Jun 20 2016 05:00
@Byzgig ...I don't understand the question. The user input zero. Therefore...you would start at zero.
David Halls
@DavidHalls
Jun 20 2016 05:00
@Impossibeard no no no
@Impossibeard it passes because the factor of 0 is 0
@Impossibeard you need to start at 1, because 1 * 0 = 0 and passes, 1 factor(5) = 120 and passes
DC*
@desyncr
Jun 20 2016 05:02
@GorgonsMaze .replace('/,\s/g', ''), not sure if you have to space ,
96street
@96street
Jun 20 2016 05:02
This message was deleted
Impossibeard
@Impossibeard
Jun 20 2016 05:03
that messes up my whole code...-_-;
function factorialize(num) {
i = 1;
var factorial = num;
while (i < factorial){
i *= num;
i++;
}
return num;
}
96street
@96street
Jun 20 2016 05:03
Why isn't my twitter share button working here (quote generator challenge) ? http://codepen.io/kingdezz/pen/mEJPLN
David Halls
@DavidHalls
Jun 20 2016 05:04
@Impossibeard well, your code was not working to begin with, try using a for loop
Ian Arsenault
@ianarsenault
Jun 20 2016 05:04
@desyncr yeah I figured it out but I'm stuck on the last one.... /\s|,|[.]/
palindrome("0_0 (: /-\ :) 0-0") should return true.
Impossibeard
@Impossibeard
Jun 20 2016 05:04
@Byzgig ...huh? It was working. It passes every test except the zero one.
David Halls
@DavidHalls
Jun 20 2016 05:05
@96street well, you have this hard coded itno your button https://twitter.com/share?
url=https%3A%2F%2Fdev.twitter.com%2Fweb%2Ftweet-button&
via=twitterdev&
related=twitterapi%2Ctwitter&
hashtags=example%2Cdemo&
text=custom%20share%20text
DC*
@desyncr
Jun 20 2016 05:05
@GorgonsMaze IIRC there problem was the underscore
Ian Arsenault
@ianarsenault
Jun 20 2016 05:05
Ok I'll check it out. Thank you @desyncr
CamperBot
@camperbot
Jun 20 2016 05:05
gorgonsmaze sends brownie points to @desyncr :sparkles: :thumbsup: :sparkles:
:cookie: 280 | @desyncr |http://www.freecodecamp.com/desyncr
David Halls
@DavidHalls
Jun 20 2016 05:06
@Impossibeard so it failed and you think it is good?
DC*
@desyncr
Jun 20 2016 05:06
@Morazajuan Remember you have to remove all punctuation characters
@Morazajuan So you may use \W
96street
@96street
Jun 20 2016 05:06
@Byzgig what exactly is that block of code doing and where should it be?
Impossibeard
@Impossibeard
Jun 20 2016 05:07
@Byzgig ...no...i just thought I was close. Are you always this abrasively assistive?
David Halls
@DavidHalls
Jun 20 2016 05:07
@Impossibeard no, i just dealt with a troll, sorry bor
CamperBot
@camperbot
Jun 20 2016 05:07
:trollface: troll problems? notify admins here
Nkjefferson
@Nkjefferson
Jun 20 2016 05:08
So Im on the Testing Objects for Properties module and I cant seem to get any console output to help me debug what is going wrong here I have tried multiple ways of declaring my variable and running my if statement and I can only get the not found case to work, I would like a second opinion on if I'm doing something wrong here if anyone would be so kind.

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

return val;
}

David Halls
@DavidHalls
Jun 20 2016 05:08
@96street you click the link and it will always take you to the same place
96street
@96street
Jun 20 2016 05:11
So I'm supposed to remove that?
is that just a template?
David Halls
@DavidHalls
Jun 20 2016 05:12
@96street here is an idea, you need to change that link to include the quote on the page
shivamsonu29
@shivamsonu29
Jun 20 2016 05:13

function diffArray(arr1, arr2) {

  var newArr=[];
  var ind=[];
  var fArr=[];
  newArr=arr1.concat(arr2);
  var idx;
  function crop(val){
    for(var i=0;i<ind.length;i++)
            return val!==arr[ind[i]];
          }
  for(var i=0;i<newArr.length;i++)
    {
      do
        {
     idx=newArr.indexOf(newArr[i]);
         ind.push(idx);
          idx=newArr.indexOf(newArr[i],idx+1);

        }while(idx!=-1);
      if(ind.length>1)
        {
          fArr.push(newArr.filter(crop));
        }
    }

  return fArr;
}
diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
infinite loop error is coming for while statement, what to do??
96street
@96street
Jun 20 2016 05:15
@Byzgig yeah that's what i'm trying to do
Impossibeard
@Impossibeard
Jun 20 2016 05:15
function factorialize(num) {

  for (i = 1; i < num; i++){
    num *= i;
  }
  return num;
}

factorialize(5);
Still getting the same errors I had from the for loop...=/ Debating just throwing a conditional around it in case of zero, but that seems like cheating
96street
@96street
Jun 20 2016 05:15
not sure how
Corey
@squawpaw
Jun 20 2016 05:16
@Nkjefferson try calling the property with brackets instead of the dot, like this: val = myObj[checkProp];
David Halls
@DavidHalls
Jun 20 2016 05:16
@Impossibeard create a var before your loop, and *= to that
Impossibeard
@Impossibeard
Jun 20 2016 05:17
whoops, sorry Yeah, I did that. Pasted old code

function factorialize(num) {
  factor = num;

  for (i = 1; i < factor; i++){
    num *= i;
  }
  return num;
}

factorialize(5);
David Halls
@DavidHalls
Jun 20 2016 05:17
@Impossibeard in the for loop change factor to num
@96street you should probably call a function with your click of tweet, and the update the url based on that
@96street and your get quote button is not doing anything
96street
@96street
Jun 20 2016 05:22
i'm gonna try do that now
and it works on firefox not chrome for some reason
the getQuote button
David Halls
@DavidHalls
Jun 20 2016 05:23
im on firefox, so...
96street
@96street
Jun 20 2016 05:25
it's working for me :/
Impossibeard
@Impossibeard
Jun 20 2016 05:25
@Byzgig if I do that, it's an infinite loop
96street
@96street
Jun 20 2016 05:26
is there any reason you can see it doesn't work? @Byzgig
David Halls
@DavidHalls
Jun 20 2016 05:26
@96street yea, i push the button and the quote doesnt change
96street
@96street
Jun 20 2016 05:26
in the code
David Halls
@DavidHalls
Jun 20 2016 05:27
@Impossibeard yea, dont change the i
kirbyedy
@kirbyedy
Jun 20 2016 05:28
@Impossibeard maybe you should declare the i.... var i = 1
Corey
@squawpaw
Jun 20 2016 05:29
@Impossibeard or, for a different approach, how about using a for loop with i --?
96street
@96street
Jun 20 2016 05:29
@Byzgig I tried to write the function, can you have a look at this
var tweet = $('.twitter-share-button');

$tweet.on ('click', function() {
  $tweet.attr('href', "'https://twitter.com/share?text=' + $('.quote>p').text() + $('.quote>span').text()));");
});
kirbyedy
@kirbyedy
Jun 20 2016 05:29
@Impossibeard also this: i < factor means the 5 wont be included... only up to 4
David Halls
@DavidHalls
Jun 20 2016 05:30
@Impossibeard take num out of your equation. first pass i is one, second pass i is 2 so i = 2, third pass i should equal 6
@96street your like drowning in jquery, i didnt use any, here is my code

function tweet(){
go = document.getElementById('text').innerHTML;
str = "https://twitter.com/intent/tweet?hashtags=quotes&related=freecodecamp&text=" + go;
go = str.replace(/<\/?[^>]+(>|$)/g, "");
return document.getElementById('tweet').href = go;
alert(go);

}

96street
@96street
Jun 20 2016 05:35
can you explain what each line is doing?
David Halls
@DavidHalls
Jun 20 2016 05:37
get the quote, add it to the twitter str
dont rememeber why i did the replace on it but meh
kirbyedy
@kirbyedy
Jun 20 2016 05:39
I dont know what are you guys doing but I made my twitter button like this:
$("#button").on("click", function() {
    window.open("http://twitter.com/home/?status=" + $("#myquote").text());
  });
very simple, and it works :)
96street
@96street
Jun 20 2016 05:40
where are you adding the .quote?
David Halls
@DavidHalls
Jun 20 2016 05:40
mine is very simple and it works too, its trying to figure out what other people are doing that posing problems
96street
@96street
Jun 20 2016 05:41
just looking at yours now @kirbyedy
kirbyedy
@kirbyedy
Jun 20 2016 05:42
@96street the quote is pulled from your already populated id
96street
@96street
Jun 20 2016 05:43
I tried yours and still not working http://codepen.io/kingdezz/pen/mEJPLN
@kirbyedy
kirbyedy
@kirbyedy
Jun 20 2016 05:44
$tweet.on well this is wrong
David Halls
@DavidHalls
Jun 20 2016 05:44
yup
96street
@96street
Jun 20 2016 05:45
how
Greg Duncan
@GregatGit
Jun 20 2016 05:45
Dose anyone know how to set a maximum size for an image but still keep it responsive so if the page gets smaller it will scale down?
Dan Couper
@DanCouper
Jun 20 2016 05:47
max-width: x; height: auto
96street
@96street
Jun 20 2016 05:47
fixed? http://codepen.io/kingdezz/pen/mEJPLN @kirbyedy @Byzgig
Dan Couper
@DanCouper
Jun 20 2016 05:47
100%, not x there
@GregatGit
kirbyedy
@kirbyedy
Jun 20 2016 05:48
@96street :thumbsup:
96street
@96street
Jun 20 2016 05:48
it's still not working ? @kirbyedy
kirbyedy
@kirbyedy
Jun 20 2016 05:48
it does now
Impossibeard
@Impossibeard
Jun 20 2016 05:48
@Byzgig that doesn't make any sense. Why i = 6 on the third pass?
kirbyedy
@kirbyedy
Jun 20 2016 05:50
works for me
Untitled-1.jpg
your link...
96street
@96street
Jun 20 2016 05:51
Ah yep it's working now
thanks
can you tell me why my initial code doesn't work?
$tweet.on ('click', function() {
  $tweet.attr('href', "'https://twitter.com/share?text=' + $('.quote>p').text() + $('.quote>span').text()));");
});
David Halls
@DavidHalls
Jun 20 2016 05:52
@Impossibeard post your new code
kirbyedy
@kirbyedy
Jun 20 2016 05:53
@96street no idea, sorry
96street
@96street
Jun 20 2016 05:53
no woz thanks for the help (Y)
@kirbyedy @Byzgig
David Halls
@DavidHalls
Jun 20 2016 05:53
@96street its working? doesnt work on my end
NixonRichard
@NixonRichard
Jun 20 2016 05:54
help chunky monkey
CamperBot
@camperbot
Jun 20 2016 05:54
no wiki entry for: chunky monkey
NixonRichard
@NixonRichard
Jun 20 2016 05:54
help chunkymonkey
CamperBot
@camperbot
Jun 20 2016 05:54
no wiki entry for: chunkymonkey
96street
@96street
Jun 20 2016 05:55
working for me and him @Byzgig
Naguib Bouchibi ⚡️
@naguib101
Jun 20 2016 05:55
Hey everyone ! I'm trying to add a full array of objects on my mongoose DB, someone has any idea about this ? Saving it and retrieving it in a single / few queries ?
(I'm using Node.JS)
David Halls
@DavidHalls
Jun 20 2016 05:56
@96 post a new link
@96street post a new link
NixonRichard
@NixonRichard
Jun 20 2016 05:57
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var Arra = [];
  var Arrb = [];
  for (i = 0;i <arr.length;i++);


  return arr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
hi help me with the chunky monkey challenge plz
what to do next ?
David Halls
@DavidHalls
Jun 20 2016 05:58
@NixonRichard start over
NixonRichard
@NixonRichard
Jun 20 2016 05:58
@@
kirbyedy
@kirbyedy
Jun 20 2016 05:58
@NixonRichard maybe to use slice() and push() methods ?
Punita Ojha
@punitaojha
Jun 20 2016 06:01
This message was deleted
NixonRichard
@NixonRichard
Jun 20 2016 06:01
but how to aply it ?
Gyeognphil Choi
@creativeworkers10
Jun 20 2016 06:02
Hi!
I'm dong my challenge: Convert Celsius to Fahrenheit,
I don't know what do I have to do...

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

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

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

why this is wrong?
NixonRichard
@NixonRichard
Jun 20 2016 06:03
fahrenhit
Gyeognphil Choi
@creativeworkers10
Jun 20 2016 06:03
uh?
kirbyedy
@kirbyedy
Jun 20 2016 06:03
@creativeworkers10 typing mistake
Gyeognphil Choi
@creativeworkers10
Jun 20 2016 06:03
oh?
kirbyedy
@kirbyedy
Jun 20 2016 06:04
fahrenhit = celsius * ( 9 / 5 ) + 32;
Gyeognphil Choi
@creativeworkers10
Jun 20 2016 06:04
!
kirbyedy
@kirbyedy
Jun 20 2016 06:04
fahrenhit instead of fahrenheit
NixonRichard
@NixonRichard
Jun 20 2016 06:05
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var Arra = [];
  var Arrb = [];
  for (i = 0;i <arr.length;i++);



  return arr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
what to do next ?
Gyeognphil Choi
@creativeworkers10
Jun 20 2016 06:05
@NixonRichard @kirbyedy Thank you guys! didn't check it well! haha
CamperBot
@camperbot
Jun 20 2016 06:05
creativeworkers10 sends brownie points to @nixonrichard and @kirbyedy :sparkles: :thumbsup: :sparkles:
:cookie: 23 | @nixonrichard |http://www.freecodecamp.com/nixonrichard
:star2: 1132 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
NixonRichard
@NixonRichard
Jun 20 2016 06:05
how to apply array slice and array push the right way ?
NixonRichard
@NixonRichard
Jun 20 2016 06:07
u guyz cant help me anything zzz
Will Black
@wrblack
Jun 20 2016 06:08
hey guys, did I do the getters/setters right for this object?

var Person = function(firstAndLast) {
  var fullname = firstAndLast;
  var first = firstAndLast.split(' ')[0];
  var last = firstAndLast.split(' ')[1];

    this.getFirstName = function() { return first; };

    this.getLastName = function() { return last; };

    this.getFullName = function() { return fullname; };

    this.setFirstName = function(firstN) {
      this.first = firstN;
    };

    this.setLastName = function(lastN) {
      this.last = lastN;
    };

    this.setFullName = function(firstAndLast) {
      this.first = firstAndLast.split(' ')[0];
      this.last = firstAndLast.split(' ')[1];
    };
};
the checker doesn't seem to like it. I'm guessing the setters are wrong but I don't know why.
NixonRichard
@NixonRichard
Jun 20 2016 06:10
nside our loop, we push to temp using temp.push(arr[a]); if the remainder of a / size is not equal to size - 1.
what does this mean ?
what is a/ size is not equal to size -1 ?
Will Black
@wrblack
Jun 20 2016 06:11
@NixonRichard I'm guessing you want to push arr[a] onto temp if (a/size) !== (size-1)
NixonRichard
@NixonRichard
Jun 20 2016 06:12
but why do i have to do that ?
why do i have push arr[a] onto temp if (a/size) !== (size - 1 )?
Will Black
@wrblack
Jun 20 2016 06:13
I'm guessing what you're trying to do is take one array and split it up?
NixonRichard
@NixonRichard
Jun 20 2016 06:14
like this chunkArrayInGroups(["a", "b", "c", "d"], 2) should return [["a", "b"], ["c", "d"]].
Will Black
@wrblack
Jun 20 2016 06:15
ah okay.
well here's an idea. you could splice the initial array, and then make another array, and push the spliced elements into it
96street
@96street
Jun 20 2016 06:16
Shifaza
@Shifatsar
Jun 20 2016 06:16
Hi. Is anyone able to use Object.values(object_name) in "Where art thou"
Greg Duncan
@GregatGit
Jun 20 2016 06:17
@DanCouper Thanks - I will try that out
CamperBot
@camperbot
Jun 20 2016 06:17
gregatgit sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 149 | @dancouper |http://www.freecodecamp.com/dancouper
NixonRichard
@NixonRichard
Jun 20 2016 06:20
function chunkArrayInGroups(arr, size) {
  // Break it up.

  for (a = 0;a <arr.length;a++);
  var temp = arr;
  arr.slice(0,size);
  var result = temp;
  arr.push(temp);




  return result;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
i know this s wrong zzz
@wrblack
Markus Kiili
@Masd925
Jun 20 2016 06:23
@NixonRichard It gets easier if you increment i by +=size. Then push slices made with .slice() into result array.
Will Black
@wrblack
Jun 20 2016 06:23
function chunkArrayInGroups(arr, size) {
var array2 = arr.splice(2); //['c','d']
var array1 = arr;
var result;
result.push(array1); result.push(array2);
return result;
}
@NixonRichard
Markus Kiili
@Masd925
Jun 20 2016 06:24
@Shifatsar Object.values() is experimental method. Poor support anywhere.
David Halls
@DavidHalls
Jun 20 2016 06:24
@96street i dont know how that is passsing, it fails on my end
Shusil Banjade
@shusil123
Jun 20 2016 06:24
@Masd925 , Profile picture is changed. Didn't recognize at first . :smile:
Shifaza
@Shifatsar
Jun 20 2016 06:24
@Masd925 oh.. damn. Will have to find a work around. Thanks :)
CamperBot
@camperbot
Jun 20 2016 06:24
shifatsar sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1929 | @masd925 |http://www.freecodecamp.com/masd925
Samuel Cupidon
@Zerazera
Jun 20 2016 06:25
@Shifatsar The work around is to use Object.keys() and then use map to get the values
Markus Kiili
@Masd925
Jun 20 2016 06:25
@shusil123 I have gotten more focused.
@Shifatsar Object.keys()
Shusil Banjade
@shusil123
Jun 20 2016 06:26
@Masd925 , You were always focused, sir. :smile: :+1:
Geo Galagaran
@geeofree
Jun 20 2016 06:26
greetings everyone. Can anyone help me with my jQuery problem?
Shifaza
@Shifatsar
Jun 20 2016 06:26
@Zerazera map how?
Will Black
@wrblack
Jun 20 2016 06:27
woops, forgot to use size.
Markus Kiili
@Masd925
Jun 20 2016 06:27
@wrblack Using while goes well with splice there. Or for and slice.
Will Black
@wrblack
Jun 20 2016 06:27
@Masd925 thanks for catching that, didn't even use variable size :|
CamperBot
@camperbot
Jun 20 2016 06:27
wrblack sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1930 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jun 20 2016 06:28
@da7thsin Sure.
Samuel Cupidon
@Zerazera
Jun 20 2016 06:28
@Shifatsar Like this Object.keys(object).map(function(keyValue) {return object[keyValue];})
Geo Galagaran
@geeofree
Jun 20 2016 06:29

@Masd925 thank you! Uhm so I have this

function doAction(){
    var getSayings = myQuotes[Randomizer()];
    var quoteHTML = $("#text").text(getSayings.Quote)
    var authorHTML = $("#author").text("-"+getSayings.Author);
    var hexCode = randomHex();

  //not working
  $("body").animate({
    backgroundColor: hexCode,
    color: hexCode
  }, 1000);
  //not working as well
  $(".nav-button").animate({
    backgroundColor: hexCode
  }, 1000);

}

is the syntax correct or am I misisng something?

CamperBot
@camperbot
Jun 20 2016 06:29
da7thsin sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1931 | @masd925 |http://www.freecodecamp.com/masd925
NixonRichard
@NixonRichard
Jun 20 2016 06:29
it says cannot read property 'push' of undefined
function chunkArrayInGroups(arr, size) {
  // Break it up.
 var array2 = arr.splice(size); //['c','d']
var array1 = arr;
var result;
result.push(array1); result.push(array2);
return result;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Markus Kiili
@Masd925
Jun 20 2016 06:30
@Shifatsar You don't actually need an array of values. You need the keylist of source.
Samuel Cupidon
@Zerazera
Jun 20 2016 06:30
@NixonRichard You have to define result as an empty array
Will Black
@wrblack
Jun 20 2016 06:30
@NixonRichard , correction: "var result = []" so result is set as an array type
Shifaza
@Shifatsar
Jun 20 2016 06:30
@Zerazera i get a "reference object is not defined error"
Markus Kiili
@Masd925
Jun 20 2016 06:30
@NixonRichard Syntax of splice is array.splice(start, deleteCount[, item1[, item2[, ...]]])
Samuel Cupidon
@Zerazera
Jun 20 2016 06:31
@Shifatsar Replace "object" with the actual object
Leave "Object" alone, though
Shifaza
@Shifatsar
Jun 20 2016 06:33
@Zerazera alright that works. but i get both the keys and the values now..
@Zerazera but i think i should be able to work something from it :D thanks
CamperBot
@camperbot
Jun 20 2016 06:34
shifatsar sends brownie points to @zerazera :sparkles: :thumbsup: :sparkles:
:cookie: 463 | @zerazera |http://www.freecodecamp.com/zerazera
NixonRichard
@NixonRichard
Jun 20 2016 06:35
what does deleteCount and the items do ?
trần nguyễn minh anh
@Anntran2222
Jun 20 2016 06:39
Can someone help me with the stand in line challenge, please?
Markus Kiili
@Masd925
Jun 20 2016 06:39
@da7thsin I think jquery cannot animate color without extra plugins.
@da7thsin Yes, color animation is not included in the core jQuery library
Geo Galagaran
@geeofree
Jun 20 2016 06:42
@Masd925 I got it to work now on my codepen haha. Turns out all I had to do was add the plugin like you said. Thank you!
CamperBot
@camperbot
Jun 20 2016 06:42
da7thsin sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: da7thsin already gave masd925 points
Markus Kiili
@Masd925
Jun 20 2016 06:42
@da7thsin Ok, good.
@Anntran2222 Sure.
Thieu van Dijk
@Thieuvandijk
Jun 20 2016 06:57
@Anntran2222 What's your question?
Janodus
@janodus
Jun 20 2016 07:13
anyone able to help still on? :)
Markus Kiili
@Masd925
Jun 20 2016 07:13
@janodus Yes.
Janodus
@janodus
Jun 20 2016 07:14
@Masd925 awesome. So I'm on the "Profile Lookup" js challenge...
i think i might have encountered a bug because when I reset the code, it looks like the function that was originally provided just disappeared.
here's my code for it though... i'm pretty sure it has something to do with . and bracket notation... but here we go:

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


function lookUpProfile(firstName, prop){
// Only change code below this line
var obj;

  for (var i = 0; i < contacts.length; i++) {
    obj = contacts[i];

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

// Change these values to test your function
lookUpProfile("Akira", "likes");
Markus Kiili
@Masd925
Jun 20 2016 07:16
@janodus The simplest structure is two nested if clauses inside contact loop. Firstname check and property existence check. Then only returns needed on correct spots.
Janodus
@janodus
Jun 20 2016 07:17
hmmm...
Markus Kiili
@Masd925
Jun 20 2016 07:17
if (obj[firstName] === contacts[i].firstName <- you need quotes on the first firstName, and you should compare it with firstName, the function parameter.
So you compare the firstName property value of the looped contact with the firstname that is passed to the function. Then you know it is the contact you look for.
The second nested if should test property existence, obj.hasPropertyOf([prop]) <- no brackets on prop here. You look for the property key stored on function parameter prop.
If you make two nested if's, the elses are optional.
Janodus
@janodus
Jun 20 2016 07:24
alright. thanks @Masd925 i'll try to work them out
CamperBot
@camperbot
Jun 20 2016 07:24
janodus sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1932 | @masd925 |http://www.freecodecamp.com/masd925
Janodus
@janodus
Jun 20 2016 07:28
this is odd.. i keep getting a typeError: obj.hasPropertyOf is not a function?
Markus Kiili
@Masd925
Jun 20 2016 07:29
@janodus .hasOwnProperty() or .propertyIsEnumerable(). prop in obj would consider also the inherited properties and also non-enumerable (built-in) properties.
Janodus
@janodus
Jun 20 2016 07:30
@Masd925 oh my... and that's probably my cue to head to sleep then. It's written right in front me of me, and I apparently made my own system function up.
thanks again @Masd925
CamperBot
@camperbot
Jun 20 2016 07:31
janodus sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: janodus already gave masd925 points
Markus Kiili
@Masd925
Jun 20 2016 07:31
@janodus You're wellcome.
laid0724
@laid0724
Jun 20 2016 07:34
Need help with the challenge "Testing Objects for Properties"
Markus Kiili
@Masd925
Jun 20 2016 07:35
@laid0724 What bugs you?
laid0724
@laid0724
Jun 20 2016 07:36
@Masd925 how do i post a screen shot of my code?
Markus Kiili
@Masd925
Jun 20 2016 07:37
@laid0724 It is better to copy/paste it here formatted.
explain format
CamperBot
@camperbot
Jun 20 2016 07:37

: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

laid0724
@laid0724
Jun 20 2016 07:37

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

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

// Test your code by modifying these values
checkObj("gift");
christianws
@christianws
Jun 20 2016 07:38

oh wow I don't know what is happening to my brain!

var testArr = [[2,3,4],[1,3,9]];

    console.log(testArr[0][0]);

why would this return undefined??!!

laid0724
@laid0724
Jun 20 2016 07:38
this is what i have so far but i don't know how to specify the right value
Markus Kiili
@Masd925
Jun 20 2016 07:39
@laid0724 You only make one test with property key stored on checkProp and then access myObj with the key using bracket notation and return it. You don't hardcode the property keys.
laid0724
@laid0724
Jun 20 2016 07:39
Let me try doing that
Markus Kiili
@Masd925
Jun 20 2016 07:41
@CurlyWS I would guess you have grown some gray mass and the capacity of your skull has been used up.
Janodus
@janodus
Jun 20 2016 07:41
@Masd925 last stab for the night... can you tell me what's wrong with this code: it's from the previous problem: ```
function lookUpProfile(firstName, prop){
// Only change code below this line
var obj;

  for (var i = 0; i < contacts.length; i++) {
    obj = contacts[i];

    if (obj.firstName === firstName) {
        if (obj.hasOwnProperty(prop) === true) {
        return obj[prop];
    }
    }
    else if (obj.hasOwnProperty(firstName) === false) {
      return "No such contact";
    }
    else if (obj.hasOwnProperty(prop) === false) {
      return "No such property";
    }
  }
laid0724
@laid0724
Jun 20 2016 07:42
@Masd925 woohoo that worked thank you so much
CamperBot
@camperbot
Jun 20 2016 07:42
laid0724 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1933 | @masd925 |http://www.freecodecamp.com/masd925
christianws
@christianws
Jun 20 2016 07:42
@Masd925 :P what's going on here this is elementary
Markus Kiili
@Masd925
Jun 20 2016 07:42
@janodus You only need the first two if's. Only put the returns on correct spots.
Remove all the other if's and also elses are optional.
Kuldeep
@kuldeep-izap
Jun 20 2016 07:44
hello everyone
can anyone please tell me the solution of Record Collection
Markus Kiili
@Masd925
Jun 20 2016 07:44
@kuldeep-izap No, only help given here.
Kuldeep
@kuldeep-izap
Jun 20 2016 07:45
oks @Masd925
here is my code

// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

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

return collection;
}

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

Markus Kiili
@Masd925
Jun 20 2016 07:45
@kuldeep-izap Create the tracks array if it is absent.
Janodus
@janodus
Jun 20 2016 07:46
hmmm @Masd925 i see what you're saying... but outside of the final then bracket (the very end) of the first 2 ifs nested, I'm not sure where I could put the returns for "no such property" and "no such contact".
could you give me a few hints?
Kuldeep
@kuldeep-izap
Jun 20 2016 07:47
@Masd925 ok i'll try
Markus Kiili
@Masd925
Jun 20 2016 07:48
@janodus No such property after the property existence check block and no such contact after you have checked all the contacts (whereever that might be ;) )
Janodus
@janodus
Jun 20 2016 07:48
alright @Masd925 thanks
CamperBot
@camperbot
Jun 20 2016 07:48
janodus sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: janodus already gave masd925 points
Shraddha Parab
@Shraddha99
Jun 20 2016 08:00

function palindrome(str) {
  // Good luck!
  str.replace(/[A-Z]/g,'');
  str.toLowerCase();
  var revstr = str.split('');
  revstr.reverse();
  if(str == revstr)
  return true;
  else
    return false;
}



palindrome("eye");
hey This is my Idk why its code idk why its giving me False for eye
christianws
@christianws
Jun 20 2016 08:06
This message was deleted

console.log(96-40); // returns 56
console.log(96.74-40); // returns 36.739999999999995
first line as expected. Why the hell is it going mental with the decimals on the second line?
Janodus
@janodus
Jun 20 2016 08:07
hey @Masd925 you still there?
darkf
@darkf
Jun 20 2016 08:09
@CurlyWS because floating point math yo
Blauelf
@Blauelf
Jun 20 2016 08:09
@CurlyWS Numbers in JS are binary floating point. 74/100 cannot be precisely represented in that format.
Shraddha Parab
@Shraddha99
Jun 20 2016 08:10
@CurlyWS coz the 1st digit is a decimal . so its like saying to the calculator to perform 96.74-40.00 also u haven't used floor function
christianws
@christianws
Jun 20 2016 08:11
@Blauelf how do represent 96.74 so I don't get this problem?
@Shraddha99 you have to use a floor function every time you do any math operate with decimals?
@Shraddha99 96.74-40.00 should return 56.74 though?
Thieu van Dijk
@Thieuvandijk
Jun 20 2016 08:12
@Shraddha99 because u compare an array with a string?
Shraddha Parab
@Shraddha99
Jun 20 2016 08:13
@CurlyWS if u want to truncate the decimals after the decimal point . u can even decide uptil how many digits you want after the decimal point.
@Thieuvandijk Yes I got my mistake I didnt used join now I did so but still my code is not passing certain cases
function palindrome(str) {
  // Good luck!
  var orgstr = str;
  orgstr.replace(/[^A-Z^a-z^0-9]/g,'').toLowerCase();

  var revstr = orgstr.split("").reverse().join("");

  if(orgstr === revstr)
  return true;
  else
    return false;
}



palindrome("eye");
Thieu van Dijk
@Thieuvandijk
Jun 20 2016 08:14
@Shraddha99 I used replace(/[^a-z0-9]+/gi, "");, maybe that does the trick
Shraddha Parab
@Shraddha99
Jun 20 2016 08:15
okay I will try @Thieuvandijk
no sucess. :(
Thieu van Dijk
@Thieuvandijk
Jun 20 2016 08:16
what
@Shraddha99 what's your new code
christianws
@christianws
Jun 20 2016 08:16

@Shraddha99 are you telling me this is the workaround?

    (Math.round((96.76 - 40) * 100)) / 100

this seems ridiculous!

is it normal in proggramming for this behaviour
Shraddha Parab
@Shraddha99
Jun 20 2016 08:17
palindrome("race car") should return true. // this case wasn't cleared
palindrome("not a palindrome") should return false. // this case clear @Thieuvandijk
christianws
@christianws
Jun 20 2016 08:17
what is the benefit for thecomputer to handle things this way
DIO
@dhrubesh
Jun 20 2016 08:17

var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  {
    "artist" : "blah blah",
    "title" : "halaluah",
    "release_year": 1998,
    "formats":[
      "ss",
      "ks"

    ]

  }


  // Add record here
];
can anyone help me to find error in the above code?
Shraddha Parab
@Shraddha99
Jun 20 2016 08:18
@Thieuvandijk ```js
Janodus
@janodus
Jun 20 2016 08:18
@CurlyWS might be a JS thing dude.
us͡an̸df͘rien͜ds͠
@usandfriends
Jun 20 2016 08:18
Shraddha Parab
@Shraddha99
Jun 20 2016 08:18

function palindrome(str) {
  // Good luck!
  var orgstr = str;
  orgstr.replace(/[^a-z0-9]+/gi,"").toLowerCase();

  var revstr = orgstr.split("").reverse().join("");

  if(orgstr === revstr)
  return true;
  else
    return false;
}



palindrome("eye");
@CurlyWS yes . sometimes we want the program to return us precise answers (with those many digits after the decimal point) sometimes we want a rounded off result. in whichever case we shd program it correctly as programmers
Thieu van Dijk
@Thieuvandijk
Jun 20 2016 08:21
@Shraddha99 maybe orgstr = orgstr.replace(/[^a-z0-9]+/gi,"").toLowerCase();
Shraddha Parab
@Shraddha99
Jun 20 2016 08:22
@Thieuvandijk THANKS!!! MAN . that was so idiotic n funny !!! It worked :)
CamperBot
@camperbot
Jun 20 2016 08:22
shraddha99 sends brownie points to @thieuvandijk :sparkles: :thumbsup: :sparkles:
:cookie: 321 | @thieuvandijk |http://www.freecodecamp.com/thieuvandijk
Zuzana
@zk433
Jun 20 2016 08:22
@Bouncey and everyone, re: adding a solution to the Palindrome challenge: I have added my solution to the file (did not push it to github yet) but I've just read on the Wiki that you only want one solution per category (beginner, intermediate, advanced). So I guess I should not push it then? Because there already is a solution for intermediate (using a for loop). Even though I used a while loop so it is different? Should I discard the changes or should I push it anyway?
Thieu van Dijk
@Thieuvandijk
Jun 20 2016 08:23
@Shraddha99 no thanx! Do you have any other problems you are stuck with?
CamperBot
@camperbot
Jun 20 2016 08:23
thieuvandijk sends brownie points to @shraddha99 :sparkles: :thumbsup: :sparkles:
:cookie: 245 | @shraddha99 |http://www.freecodecamp.com/shraddha99
Shraddha Parab
@Shraddha99
Jun 20 2016 08:24
@Thieuvandijk don't know . have to solve ahead
Blauelf
@Blauelf
Jun 20 2016 08:24

@CurlyWS If you are ok with imprecise results and just want to present two digits, you can use toFixed(2) on that (creates a string representation with two digits after decimal point).

If you need exact values, multiply so that the fraction you are presenting has a power of two as its denominator. Banks do that (rounding is permitted only after so many digits), I think Euro values are multiplied by 10000 and stored as integers. You just have to remember that number represents something different and is to be read as "/10000".

Stuart Taylor
@Bouncey
Jun 20 2016 08:24
@zk433 Push it anyway and it will be reviewed. It would be a shame to do all that work and not let anybody see it1
Shraddha Parab
@Shraddha99
Jun 20 2016 08:24
@Blauelf True that
Stuart Taylor
@Bouncey
Jun 20 2016 08:24
@zk433 Thanks for contributing :tada:
CamperBot
@camperbot
Jun 20 2016 08:24
bouncey sends brownie points to @zk433 :sparkles: :thumbsup: :sparkles:
:cookie: 266 | @zk433 |http://www.freecodecamp.com/zk433
DIO
@dhrubesh
Jun 20 2016 08:27
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true



  }

    "artist" : "blah blah",
    "title" : "halaluah",
    "release_year": 1998,
    "formats":[
      "ss",
      "ks"
     ]




  // Add record here
];
can anyone help to find error in the above code?
us͡an̸df͘rien͜ds͠
@usandfriends
Jun 20 2016 08:28
@dhrubesh missing comma, opening/closing braces after “gold”: true }
Jupesam
@Jupesam
Jun 20 2016 08:29
Hey! Im trying to create the random quote generator. I can so far do all the things I want expect to change the ”tweet” button data text, this doesnt seem to work: $("#tweetbutton").attr("data-text", quote);
Puvendran Pillay
@puven12
Jun 20 2016 08:36
how does a loop nested in a loop works?
Nikhil Goyal
@ngoyal100894
Jun 20 2016 08:36

Hi I have this code

var j=0;
    text ="<ul>"
    for(var i =0; i<array.length;i++){
      text+= '<li>'+j+ array[i] +'<br/>'+array2[i]+ '<br/><br/><input type ="button" value ="Delete" onclick = "deleteThisInput();" /><input type ="button" value = "Edit" onclick = "editThisInput();"/></li>'

      //for delete button code must be here althogh function can be outside .
        j++;
    }
    text+="</ul>";

    document.getElementById("myArray").innerHTML = text;
}

Here is my codepen link to get a view
if you do not understand what I am trying to do .. click on add multiple time there..
Now what I want to add is each time I click on delete I want to remove that part of problem and answer

Zuzana
@zk433
Jun 20 2016 08:38
@Bouncey Ok, next question, how do I push it? :smile: Do I sync it as per the step 4 in the ReadMe? Or do I need to do anything else? Sorry, I'm a real first timer.
Puvendran Pillay
@puven12
Jun 20 2016 08:38
when the parent loop iterate once, child loop works until false, then the parent loop moves to the next iteration?
how does a loop nested in a loop works?
when the parent loop iterate once, child loop works until false, then the parent loop moves to the next iteration?
Thieu van Dijk
@Thieuvandijk
Jun 20 2016 08:38
@puven12 yep
Puvendran Pillay
@puven12
Jun 20 2016 08:39
@Thieuvandijk thanks and a nested if statement is like if(somehing)&& if(something)?
CamperBot
@camperbot
Jun 20 2016 08:39
puven12 sends brownie points to @thieuvandijk :sparkles: :thumbsup: :sparkles:
:cookie: 322 | @thieuvandijk |http://www.freecodecamp.com/thieuvandijk
Thieu van Dijk
@Thieuvandijk
Jun 20 2016 08:40
@puven12 yep again ;-)
Puvendran Pillay
@puven12
Jun 20 2016 08:41
@Thieuvandijk thanks again
CamperBot
@camperbot
Jun 20 2016 08:41
:warning: puven12 already gave thieuvandijk points
puven12 sends brownie points to @thieuvandijk :sparkles: :thumbsup: :sparkles:
DIO
@dhrubesh
Jun 20 2016 08:41
need help
Access the myStorage JSON object to retrieve the contents of the glove box. Use bracket notation for properties with a space in their name.

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

// Only change code below this line

var gloveBoxContents = myStorage.car["inside"].glovebox; // Change this line
Puvendran Pillay
@puven12
Jun 20 2016 08:42
@dhrubesh myStorage["car inside"]....
@dhrubesh the last last line
DIO
@dhrubesh
Jun 20 2016 08:44
@puven12 did you mean this
var gloveBoxContents = myStorage.["car inside"].glovebox;
ricevind
@ricevind
Jun 20 2016 08:44
try .[glove box]
Snehalnova1994
@Snehalnova1994
Jun 20 2016 08:45

function reverseString(str) {

var arr= [];

for (i = 0; i< 5; i++){
arr[i]=str.charAt[i];
}

return arr.reverse();
}

reverseString("hello");

DIO
@dhrubesh
Jun 20 2016 08:45
@ricevind
var gloveBoxContents = myStorage.car.["inside"].[glove box];
Snehalnova1994
@Snehalnova1994
Jun 20 2016 08:45
what did i do wrong?
DIO
@dhrubesh
Jun 20 2016 08:46
did you mean this? @ricevind
ricevind
@ricevind
Jun 20 2016 08:46
yup, does it work ?
DIO
@dhrubesh
Jun 20 2016 08:46
NO
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 08:46
@dhrubesh glove box must be in quotations
Puvendran Pillay
@puven12
Jun 20 2016 08:46
@dhrubesh var ... = myStorage["car inside"]["glove box"]
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 08:47
@Snehalnova1994 you're returning an array..you'll have to join that before you return
Snehalnova1994
@Snehalnova1994
Jun 20 2016 08:47
oh thanx
got it'
Puvendran Pillay
@puven12
Jun 20 2016 08:48
@dhrubesh use . (dot notation) for single words and [" "] (braket notation) for multiple words with space
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 08:48
thank me by taggging :p
@Snehalnova1994
DIO
@dhrubesh
Jun 20 2016 08:48
@puven12 var gloveBoxContents = myStorage.["car inside"].["glove box"]; this?
Blauelf
@Blauelf
Jun 20 2016 08:48
car and inside are separate, so use .car.inside
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 08:48
@dhrubesh remove dot before the brackets
Puvendran Pillay
@puven12
Jun 20 2016 08:48
@dhrubesh take the dot away
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 08:49
and yes..car and inside are different. you joined them
DIO
@dhrubesh
Jun 20 2016 08:49
gotcha thnx
Puvendran Pillay
@puven12
Jun 20 2016 08:49
@dhrubesh no worries
@dhrubesh use dot for words without a space in between
and [" "] for multiple words with spaces
Snehalnova1994
@Snehalnova1994
Jun 20 2016 08:51
thanks a lot
@Krish2704
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 08:51
in the same line :p @Snehalnova1994
Bhaargavi1
@Bhaargavi1
Jun 20 2016 08:53
how to put a string in the case statement in switch case
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 08:54
@Bhaargavi1 case "string1":
Bhaargavi1
@Bhaargavi1
Jun 20 2016 08:54
its not accepting
Thieu van Dijk
@Thieuvandijk
Jun 20 2016 08:55
@Bhaargavi1 it should
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 08:55
@Bhaargavi1 show me your code
Bhaargavi1
@Bhaargavi1
Jun 20 2016 08:55
we can use a break in that statement part
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 08:55
yup. we can use
Thieu van Dijk
@Thieuvandijk
Jun 20 2016 08:55
@Bhaargavi1 Yes, we can ;-)
Bhaargavi1
@Bhaargavi1
Jun 20 2016 08:56
case"bob":
answer = "Marley";
break;
Thieu van Dijk
@Thieuvandijk
Jun 20 2016 08:56
use {}
Bhaargavi1
@Bhaargavi1
Jun 20 2016 08:56
why is it necessary
Michael Farag
@MichaelFarag
Jun 20 2016 08:57
what the best answer for this
var quotient = 0.0 / 2.0;
Thieu van Dijk
@Thieuvandijk
Jun 20 2016 08:57
case "bob": {answer="Marley"; break;}
Bhaargavi1
@Bhaargavi1
Jun 20 2016 08:57
no not accepting
Michael Farag
@MichaelFarag
Jun 20 2016 08:57
The variable quotient should equal 2.2
Thieu van Dijk
@Thieuvandijk
Jun 20 2016 08:58
@Bhaargavi1 then maybe the error is in the switch statement
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 08:58
@Bhaargavi1 answe+="marley"
Bhaargavi1
@Bhaargavi1
Jun 20 2016 08:58
no its not to be concatenated
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 08:59
@Thieuvandijk and did you initialise answer as var answer=""?
Bhaargavi1
@Bhaargavi1
Jun 20 2016 08:59
rest all the statements are working properly
but the rest have numbers not strings in case
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:00
@Bhaargavi1 show me your complete code
Thieu van Dijk
@Thieuvandijk
Jun 20 2016 09:00
@Bhaargavi1 yes please
Bhaargavi1
@Bhaargavi1
Jun 20 2016 09:02

function chainToSwitch(val) {
var answer = "";
switch(val)
case "bob":
{answer = "Marley"; break;}

case 42:
 answer = "The Answer";
 break;
case 1:
 answer = "There is no #1";
 break;
case 99:
 answer = "Missed me by this much!";
 break;
case 7:
 answer= "Ate Nine";

return answer;
}

Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:03
@Bhaargavi1 you're missing a paranthesis after switch statement
mos
@sophizo
Jun 20 2016 09:03
@Krish2704
Bhaargavi1
@Bhaargavi1
Jun 20 2016 09:03
oh i get it
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:03
@HeumO yeah?
mos
@sophizo
Jun 20 2016 09:03
how r u ?
Bhaargavi1
@Bhaargavi1
Jun 20 2016 09:04
thanks its done
Thieu van Dijk
@Thieuvandijk
Jun 20 2016 09:04
@Bhaargavi1 it works?
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:04
@Bhaargavi1 anytime
@HeumO good bro. how are you?
mos
@sophizo
Jun 20 2016 09:05
not that good
96street
@96street
Jun 20 2016 09:05
I want a div to appear on mouseover right next to the element that was mouseover'd - how do i do this with jquery?
Bhaargavi1
@Bhaargavi1
Jun 20 2016 09:06
no its still not working
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:06
@HeumO why?what happened?
mos
@sophizo
Jun 20 2016 09:06
@Krish2704
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:06
@Bhaargavi1 what?
mos
@sophizo
Jun 20 2016 09:06
This message was deleted
Bhaargavi1
@Bhaargavi1
Jun 20 2016 09:06
i will try once more there is some other problem
mos
@sophizo
Jun 20 2016 09:06

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var array=[];
  for(var i=0;i<arr.length;i+=size)
    {
      array.push(arr.slice(i,i+size));
    }
  return array;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
@Krish2704 can u explain ur code ?
Bhaargavi1
@Bhaargavi1
Jun 20 2016 09:07
its done finally
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:07
@HeumO you know how arr.slice works?
@Bhaargavi1 good
mos
@sophizo
Jun 20 2016 09:08
yup
it returns a shadow of the elements
holds 2 para's
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:08
@HeumO so for the first iteration it will be array.push(arr,slice(0,2))
now what will the array have?
mos
@sophizo
Jun 20 2016 09:09
a & b
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:09
show me following the syntax
what will be the output when i return arr?
mos
@sophizo
Jun 20 2016 09:10
[a,b,c]
because we r taking values till 2
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:11
@HeumO nope...slice(0,2) means including 0 and excluding 2
mos
@sophizo
Jun 20 2016 09:12
oki
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:12
so now array.slice will give [a,b]
mos
@sophizo
Jun 20 2016 09:12
yes
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:12
but i asked for the array, so array.push will give [[a,b]]
mos
@sophizo
Jun 20 2016 09:13
yup
Manikanth
@manikanth1024
Jun 20 2016 09:13
Hi guys
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:13
so, in the next interation array.push(array.slice(2,4))
so, array.sliicce will reeturn [c,d]
Manikanth
@manikanth1024
Jun 20 2016 09:13
Is there any chat room for android devs in fcc?
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:13
array.push will push the array into existing array which is [[a,b]]
so,now the array will be [[a,b],[c,d]]
mos
@sophizo
Jun 20 2016 09:14
@Krish2704 how ?
the next i value will be 1
after 0
Manikanth
@manikanth1024
Jun 20 2016 09:14
Does anyone know android dev here?
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:15
@HeumO no i'm incrementing i as i=i+size, since the size=2 now,i=i+2 that is i=0+2 so,i=2
@manikanth1024 nope.
Manikanth
@manikanth1024
Jun 20 2016 09:15
ok
mos
@sophizo
Jun 20 2016 09:16
@Krish2704 yes , but after 0 what will be the value for i in the next iteration ?
after 0 it will increase , right ?
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:17
@HeumO yes. now i=0 and for next iteration i=i+size, so i=i+2 so i=2
and in the next iteration i=4
and so on
but since our termination condition is i<4 it will stop after i=2 's iteration
mos
@sophizo
Jun 20 2016 09:18
how i = 2 for the next iteration ? why not 1 after 0 ?
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:18
@HeumO see the code carefully, the third expression in for statement is i+=size i.e., i = i+size
mos
@sophizo
Jun 20 2016 09:19
yes i get that
the i values should be 0 ,1 ,2, 3......arr.length
correct ?
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:20
@HeumO no. size is 2. so 0,2,4,6,8...arr.length
mos
@sophizo
Jun 20 2016 09:20
but that is size values
where is the i value ?
does it remains 0 always ?
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:22
@HeumO no. i'm talkking about i values
i=i+size
here size is 2. so i=i+2 is incrementing operator here
normally it will be i++ which is i=i+1
FNGR2911
@FNGR2911
Jun 20 2016 09:23
hey everbody! I'm working on my tic tac toe game and just wan't to know, if this is a way to get this working. I commented the way I wan't to solve the challenge. Maybe you can tell me, if this is a smart way :)
$(document).ready(function() {
  // global variables
  var startBoard  = [0,1,2,3,4,5,6,7,8];
  var currBoard   = [];
  var currPlayer  = 'X';
  var level       = 'Beginner';
  var boardCell   = $('.cell');
  var startButton = $('#start');

  // need to store winning combinations in an variable (array or object)
  var winningCombos = //[...];

  // user clicks on start game game
  startButton.on('click', function() {
    // make sure currPlayer is X so AI starts
    currPlayer = 'X';

    // got to moveAI function let AI make a move
  });

  // if currPlayer is O and he clicks on cell => push to currBoard
  boardCell.on('click', function() {
    if (currPlayer === 'O') {
      var cellIndex = $(this).attr('data-index');
      currBoard.push(cellIndex);

      // now go to checkBoard function to check if win or draw or make AI move
    }
  });

  // function that checks for a win or draw (full board)
  function checkBoard() {
    // check if board got a winning combination
      // if yes, return currPlayer as winner and quit game

      // if not, check if currBoard is full without a winner
      // if yes, return a draw and quit game

      // if nothing is true, check the currPlayer and set it to the other player
      // if the next player is AI, got to moveAI function, else let User make move
  }

  function moveAI() {
    // if AI is beginner make a random move

    // if AI is on expert check best move and make one (implement the MINIMAX algo)

    // go to the checkboard function
  }
});
mos
@sophizo
Jun 20 2016 09:24
@Krish2704 shit sorry
was ignoring that all the time
yes, thats correct @Krish2704 thanks
CamperBot
@camperbot
Jun 20 2016 09:25
heumo sends brownie points to @krish2704 :sparkles: :thumbsup: :sparkles:
:cookie: 375 | @krish2704 |http://www.freecodecamp.com/krish2704
mos
@sophizo
Jun 20 2016 09:31
@Krish2704 when i use direct return after the for statement the code doesnt works
but when i use it after words ,it works
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:31
@HeumO what?
mos
@sophizo
Jun 20 2016 09:32

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

  for (var i = 0 ; i< arr.length ; i+=size)
return    krr.push(arr.slice(i,i+size));
 }
chunkArrayInGroups(["a", "b", "c", "d"], 2);
this doesnt works
when i use return directly
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:33
@HeumO if you use return here, it will execute for first iteration and then the code returns
so you'll have to return it after the for statement completes
mos
@sophizo
Jun 20 2016 09:34
@Krish2704 i see
DIO
@dhrubesh
Jun 20 2016 09:34
need help

// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (value === '') {
    delete collection[id][prop];
  } else if (prop !== 'tracks') {
    collection[id][prop] = value;
  } 
  else {
    collection[id][prop].push(value);
  }


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
mos
@sophizo
Jun 20 2016 09:34
so it will return the whole answer then
DIO
@dhrubesh
Jun 20 2016 09:34
If "tracks" is non-existent before you update it, create an empty array before pushing a track to it.
mos
@sophizo
Jun 20 2016 09:34
instead some parts of it ,right ?
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:34
@HeumO yup
@HeumO not some parts. when the first time it iterates it will return directly. so return it after the for loop
mos
@sophizo
Jun 20 2016 09:36
@dhrubesh i think u have to use hasOwnProp method
can u link to the exercise ?
DIO
@dhrubesh
Jun 20 2016 09:36
@HeumO https://www.freecodecamp.com/challenges/record-collection#?solution=%0A%2F%2F%20Setup%0Avar%20collection%20%3D%20%7B%0A%20%20%20%202548%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%22Let%20It%20Rock%22%2C%20%0A%20%20%20%20%20%20%20%20%22You%20Give%20Love%20a%20Bad%20Name%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%202468%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%221999%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%221999%22%2C%20%0A%20%20%20%20%20%20%20%20%22Little%20Red%20Corvette%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%201245%3A%20%7B%0A%20%20%20%20%20%20artist%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%205439%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%22ABBA%20Gold%22%0A%20%20%20%20%7D%0A%7D%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse(JSON.stringify(collection))%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20updateRecords(id%2C%20prop%2C%20value)%20%7B%0Aif%20(value%20%3D%3D%3D%20'')%20%7B%0A%20%20%20%20delete%20collection%5Bid%5D%5Bprop%5D%3B%0A%20%20%7D%20else%20if%20(prop%20!%3D%3D%20'tracks')%20%7B%0A%20%20%20%20collection%5Bid%5D%5Bprop%5D%20%3D%20value%3B%0A%20%20%7D%20%0A%20%20else%20%7B%0A%20%20%20%20collection%5Bid%5D%5Bprop%5D.push(value)%3B%0A%20%20%7D%0A%20%20%0A%0A%20%20return%20collection%3B%0A%7D%0A%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0AupdateRecords(5439%2C%20%22artist%22%2C%20%22ABBA%22)%3B%0A%0A
@HeumO its the record collection of javascript.
mos
@sophizo
Jun 20 2016 09:37
yes
try using hasOwnProp method
@dhrubesh refer the previous exercise & use that method
& paste code
juw3lstar
@juw3lstar
Jun 20 2016 09:42
This task should have a test for num <= 3 and str.length to be the same/lower than that num for example: truncateString("AB", 3);
mos
@sophizo
Jun 20 2016 09:45
@juw3lstar what do u mean ?
Puvendran Pillay
@puven12
Jun 20 2016 09:46

//fizzbuzz challenge
//fizz when a number is divisible by 3
//buzz when a number is divisible by 5

function fizzBuzz(num){
for (var i = 0; i <= num; i++){
if (i % 3 === 0 && i % 5 === 0){
console.log("fizzbuzz");
}
else if (i % 3 === 0){console.log("fizz");
}
else if (i % 5 === 0){console.log("buzz");}
}
else { console.log(i);
}
}
} fizzBuzz(100);

``` //fizzbuzz challenge
//fizz when a number is divisible by 3
//buzz when a number is divisible by 5

function fizzBuzz(num){
for (var i = 0; i <= num; i++){
if (i % 3 === 0 && i % 5 === 0){
console.log("fizzbuzz");
}
else if (i % 3 === 0){console.log("fizz");
}
else if (i % 5 === 0){console.log("buzz");}
}
else { console.log(i);
}
}
} fizzBuzz(100);```

Error is at else statement... How to fix it?
mos
@sophizo
Jun 20 2016 09:48
@Krish2704
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:48
@puven12 you gave two closing brackets after the last else if statement
mos
@sophizo
Jun 20 2016 09:48
function slasher(arr, howMany) {
  // it doesn't always pay to be first
  return arr.slice(arr.splice(0,howMany));
}

slasher([1, 2, 3], 2);
is this code wrong ?
Krishna Sai Gullapalli
@Krish2704
Jun 20 2016 09:48
@puven12 remove one bracket before the else stateement and your code will work
@HeumO what should be the output?
Markus Kiili
@Masd925
Jun 20 2016 09:49
@HeumO One method call is enough.
mos
@sophizo
Jun 20 2016 09:49
we have to remove chrs from 0 index until howMany
juw3lstar
@juw3lstar
Jun 20 2016 09:50
@HeumO My Solution%20%7B%0A%20%20%2F%2F%20Clear%20out%20that%20junk%20in%20your%20trunk%0A%20%20if%20(num%20%3C%3D%203%20%26%26%20str.length%20%3E%20num)%20%7B%0A%20%20%20%20str%20%3D%20str.slice(0%2C%20num)%3B%0A%20%20%20%20return%20str%20%2B%20%22...%22%3B%0A%20%20%7D%0A%20%20%0A%20%20if%20(str.length%20%3E%20num)%20%7B%0A%20%20%20%20str%20%3D%20str.slice(0%2C%20num-3)%3B%0A%20%20%20%20return%20str%20%2B%20%22...%22%3B%0A%20%20%7D%0A%20%20%0A%20%20return%20str%3B%0A%7D%0A%0AtruncateString(%22AB%22%2C%203)%3B%0A) i added && str.length > num after already finishing. try leaving it away. Any text equal to or lower 3 will have a ... at the end despite there wont be any further text
This message was deleted
Markus Kiili
@Masd925
Jun 20 2016 09:51
@HeumO Slice arguments are indices arr.slice([begin[, end]]), but your code puts an array (splice return value) as an argument.
mos
@sophizo
Jun 20 2016 09:51
yes
but the question is how is the code working ?
juw3lstar
@juw3lstar
Jun 20 2016 09:51
function truncateString(str, num) {
  // Clear out that junk in your trunk
  if (num <= 3) {
    str = str.slice(0, num);
    return str + "...";
  }

  if (str.length > num) {
    str = str.slice(0, num-3);
    return str + "...";
  }

  return str;
}

truncateString("AB", 2);
this code works but returns a str with "..." at the end even though AB has no more characters
Blauelf
@Blauelf
Jun 20 2016 09:52
@HeumO splice will remove howMany elements starting at index 0, and return the removed elements as an array. Slice does not know what to do with that array, I guess. You can just return arr.slice(howMany);, or arr.slice(0, howMany); return arr; (which I don't like as it also alters the array from the calling code's view)
mos
@sophizo
Jun 20 2016 09:52
@juw3lstar what if it is greater than str.length ?
u need one more statement to cover that
Dan Couper
@DanCouper
Jun 20 2016 09:53
@HeumO what you're doing with push is changing karr: every time the loop iterates, karr is changing, it is having the values pushed into it. And what push does is push a value onto karr and return the new length - so like [].push('hello') will return 1. return is literally returning out of the function, so your implementation will just return 1. Which is why you return karr after the loop has finished, once it's been populated.
juw3lstar
@juw3lstar
Jun 20 2016 09:53
@HeumO i solved it already im saying this is a bug/needs to be fixed. i was able to solve the task even though this solution returned AB... there needs to be a check for thta
Dan Couper
@DanCouper
Jun 20 2016 09:54
This message was deleted
juw3lstar
@juw3lstar
Jun 20 2016 09:54
@HeumO i added && str.length > num to my first if statement to solve it completely.
Alexander Apostolov
@AlexApostolov
Jun 20 2016 09:55
I am also a bit stuck on "Record Collection".
```
mos
@sophizo
Jun 20 2016 09:56
@DanCouper thanks
CamperBot
@camperbot
Jun 20 2016 09:56
heumo sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 150 | @dancouper |http://www.freecodecamp.com/dancouper
juw3lstar
@juw3lstar
Jun 20 2016 09:57
@HeumO can you see what i mean?
Nikola
@Ajvaro
Jun 20 2016 09:57
```
mos
@sophizo
Jun 20 2016 09:57
@Masd925 does splice returns the length ?
@juw3lstar yes , i faced that as well
Markus Kiili
@Masd925
Jun 20 2016 09:57
@HeumO Returns an array of removed elements.
mos
@sophizo
Jun 20 2016 09:58
but dont think thats a bug
Tbuglc
@tbuglc
Jun 20 2016 09:58
about @clement12345
CamperBot
@camperbot
Jun 20 2016 09:58
:warning: no user found for clement12345
mos
@sophizo
Jun 20 2016 09:58
@Masd925 then when i used slice on splice as argument , how could it work ?
i think it took that as the first argument & since no end was mentioned it went all the way to the end

function slasher(arr, howMany) {
  // it doesn't always pay to be first
  return arr.slice(arr.splice(0,howMany));
}

slasher([1, 2, 3], 2);
here i mean
Alexander Apostolov
@AlexApostolov
Jun 20 2016 09:59
after using backticks, how do I submit?
Markus Kiili
@Masd925
Jun 20 2016 09:59
@HeumO Your code removes the first howMany elements, and then slice makes a copy of the arr (because it has no sensible arguments). An array is coerced to NaN if there is coercion.
juw3lstar
@juw3lstar
Jun 20 2016 10:00
@HeumO it is not a bug but it is simply not covered by the check-through statements. And it should! Where do i need to go with sucha problem? @Masd925
Puvendran Pillay
@puven12
Jun 20 2016 10:00
@Krish2704 thanks. I was testing out an android app