These are chat archives for FreeCodeCamp/HelpJavaScript

19th
Jun 2016
colorpanda
@colorpanda2011
Jun 19 2016 00:00
@moigithub would you like more specific? I dont get you.
MikeBeers
@MikeBeers
Jun 19 2016 00:01
I have a question about using the console.
Moisés Man
@moigithub
Jun 19 2016 00:02
@colorpanda2011 on ur code.. where u return result;
result is a variable....
before that line.. u need to ASSIGN values to result
result = something
based on the object u have above lookup
sooo result = lookup ... something else
but lookup is a object with MANY MANY properties:values pairs
u only need to pick ONE of em
(probably u need to go back few exercises n redo again,, everything related to objects... and access object notations )
MikeBeers
@MikeBeers
Jun 19 2016 00:03
in my code I have a console.log statement and it prints the info to the console. But if i try and access the same info from the Console as trying to debug I get a reply of undefined.
var game = {
        computer: function() {
        var timeOut;
        var cpArr = [];
        cpArr = clrArr.slice(0,2);
        console.log(cpArr);
from the console window. I type game.computer.cpArr and it is undefined.
colorpanda
@colorpanda2011
Jun 19 2016 00:05
@moigithub Thank you, I got it!
CamperBot
@camperbot
Jun 19 2016 00:05
colorpanda2011 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1461 | @moigithub |http://www.freecodecamp.com/moigithub
Jamil Akhtar
@frontender007
Jun 19 2016 00:06
anyone can help with record collection challenge please ?
chegnar
@chegnar
Jun 19 2016 00:08
@moigithub Thanks man :)
CamperBot
@camperbot
Jun 19 2016 00:08
chegnar sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1462 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Jun 19 2016 00:08
@MikeBeers try with debugger keyword
MikeBeers
@MikeBeers
Jun 19 2016 00:09
@moigithub I need a little bit more info ????
Moisés Man
@moigithub
Jun 19 2016 00:09
@frontender007 post what u did ? ( not the original code)
Jamil Akhtar
@frontender007
Jun 19 2016 00:10
// 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 ( collection[id].hasOwnProperty(prop) === false )
   {
      collection.id[prop] = [];
   }
   else if ( value === "") 
   {
       delete collection.id[prop];
   }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Here is my code @moigithub
Moisés Man
@moigithub
Jun 19 2016 00:10

@MikeBeers
example...

function sayHello(name){
     debugger;
     console.log("hello" + name);
}
sayHello("me");

and run the code.. it will STOP where debugger keyword is located
then u can clicky some buttons to navigate ur code.. on ur browser/devtools
or use console.log(variable) cuz ur data is LOADED in memory

3jM310
@3jM310
Jun 19 2016 00:13

please someone can help me with this i need to convert from fahrenheint to celsius a i've tried differents ways and i dont got nothhing function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

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

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

Moisés Man
@moigithub
Jun 19 2016 00:14

@frontender007 id is variable.. NO dot notation collection.id[prop]
also this

 else if ( collection[id].hasOwnProperty(prop) === false )
   {
      collection.id[prop] = [];
   }

should NOT be an else if.. but a nested if.. on the "above" tracks check BEFORE push..

@3jM310 diff ways like ???
Dan Couper
@DanCouper
Jun 19 2016 00:15
@3jM310 what have you tried
Jamil Akhtar
@frontender007
Jun 19 2016 00:17
thanks @moigithub
CamperBot
@camperbot
Jun 19 2016 00:17
frontender007 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1464 | @moigithub |http://www.freecodecamp.com/moigithub
3jM310
@3jM310
Jun 19 2016 00:18
i tried putting this var fahrenheit = ( celsius *(5/9) + 32); and and i got nothing @DanCouper
Diego Mayer
@Chrono79
Jun 19 2016 00:18
@3jM310 isn't it 9/5? and delete the var keyword, fahrenheit is already declared above
Richard
@codecampergg
Jun 19 2016 00:20
can someone give me an example of a "lookup table", please?
Jamil Akhtar
@frontender007
Jun 19 2016 00:21
@moigithub
Diego Mayer
@Chrono79
Jun 19 2016 00:21
var lookup = {
  1: "a",
  2: "b",
  3: "c"
}
@codecampergg
bitgrower
@bitgrower
Jun 19 2016 00:21
the way I remember it is to think of the 2 scales from freezing to boiling ... one is 0-100, the other is 32 to 212 ... so which is smaller in numbers ... celsius ... so you have to multiply it by a number greater than 1, that is 9/5 ... then, for the 32 ... I think ... okay if celsius is 0 degrees at freezing, and f is 32 ... what do I have to do if celsius is 0? add 32 ... so I can synthesize the equation from information I have
Jamil Akhtar
@frontender007
Jun 19 2016 00:21

// 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 ( collection[id].hasOwnProperty(prop) === false )
   {
      collection[id][prop] = [];
   }
   else if ( value === "") 
   {
       delete collection[id][prop];
   }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
don't know whats wrong now
@moigithub
3jM310
@3jM310
Jun 19 2016 00:22
ok so i need to write this fahrenheint = (celsius * (9/5) + 32); @DanCouper is that right?
Jamil Akhtar
@frontender007
Jun 19 2016 00:22
didn't understand which one should be a nested if
Diego Mayer
@Chrono79
Jun 19 2016 00:22

@frontender007 you need to create tracks before trying to push
nest this:

if ( collection[id].hasOwnProperty(prop) === false )
   {
      collection[id][prop] = [];
   }

before using push

Dan Couper
@DanCouper
Jun 19 2016 00:23
@3jM310 what's it returning/what's the error
3jM310
@3jM310
Jun 19 2016 00:24

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

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

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

Moisés Man
@moigithub
Jun 19 2016 00:24
@3jM310 variable name is not correct
Diego Mayer
@Chrono79
Jun 19 2016 00:24
@3jM310 you have one n more
Jamil Akhtar
@frontender007
Jun 19 2016 00:25
thanks @moigithub got it now
CamperBot
@camperbot
Jun 19 2016 00:25
frontender007 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: frontender007 already gave moigithub points
Moisés Man
@moigithub
Jun 19 2016 00:25
:+1: @frontender007
colorpanda
@colorpanda2011
Jun 19 2016 00:26
I stuck on Introducing JavaScript Object Notation JSON
anyone finished that?
Diego Mayer
@Chrono79
Jun 19 2016 00:26
yes
colorpanda
@colorpanda2011
Jun 19 2016 00:26

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

}
];

var myMusic =[
{
"artist": "Bon jowa",// Add record here
"title": "yellow submarine",
"release_year": 1979,
"formats": ["CS", "8T", "LP"]

}

];

Sophia Diaz-Infante
@sophiaelisa
Jun 19 2016 00:26
@colorpanda2011 did you figure out the card challenge?
colorpanda
@colorpanda2011
Jun 19 2016 00:27
yep
3jM310
@3jM310
Jun 19 2016 00:27

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

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

// Change the inputs below to test your code
convertToF(30); and i need to do this convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86

Diego Mayer
@Chrono79
Jun 19 2016 00:27
@colorpanda2011 myMusic is an array of objects
@3jM310 fahrenheint should be fahrenheit
colorpanda
@colorpanda2011
Jun 19 2016 00:27
I tried to put it in array
Sophia Diaz-Infante
@sophiaelisa
Jun 19 2016 00:27
I am soo close to having it solved, however 2 of my sequences are not returning the correct answer
colorpanda
@colorpanda2011
Jun 19 2016 00:27
but failed
Moisés Man
@moigithub
Jun 19 2016 00:27
@3jM310 RECHECK ur variables names..
Sophia Diaz-Infante
@sophiaelisa
Jun 19 2016 00:27

var count = 0;

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

  case 10:
  case 'J':
  case 'Q':
  case 'K':
  case 'A':
answer =   --count + " Hold"; 
    break; 
  case 7: 
  case 8:
  case 9:
   answer = count + " Hold"; 


  }

return answer;   

// Only change code above this line
}

Diego Mayer
@Chrono79
Jun 19 2016 00:27

@colorpanda2011 you have to add another object separated by a comma
reset the challenge, delete //Add record here, and paste this:

{
"artist": "Bon jowa",
"title": "yellow submarine",
"release_year": 1979,
"formats": ["CS", "8T", "LP"]
}

put a comma between the other object and this one

colorpanda
@colorpanda2011
Jun 19 2016 00:28
That`s what I did now, still get wrong,

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

}
];

var myMusic =[
{
"artist": "Bon jowa",// Add record here
"title": "yellow submarine",
"release_year": 1979,
"formats": ["CS", "8T", "LP"]

}

];

Moisés Man
@moigithub
Jun 19 2016 00:29
@colorpanda2011 should be something like [ {....} , {....} ]
an array with 2 object elements
Sophia Diaz-Infante
@sophiaelisa
Jun 19 2016 00:29
all of my sequences are returning correctly, however both of my sequences that are supposed to return "1 Bet" are returning "1 Hold"
Moisés Man
@moigithub
Jun 19 2016 00:30
@sophiaelisa on ur switch u should ONLY inc or dec count...
AFTER ur switch.. u should evaluate count variable. and return count + bet or hold.. (depending on count value )
3jM310
@3jM310
Jun 19 2016 00:30
thanks @DanCouper @moigithub and @Chrono79 you are the best guys
CamperBot
@camperbot
Jun 19 2016 00:30
3jm310 sends brownie points to @dancouper and @moigithub and @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1232 | @chrono79 |http://www.freecodecamp.com/chrono79
:cookie: 147 | @dancouper |http://www.freecodecamp.com/dancouper
:star2: 1465 | @moigithub |http://www.freecodecamp.com/moigithub
colorpanda
@colorpanda2011
Jun 19 2016 00:30
@moigithub you are right!
The key is the comma notation
Diego Mayer
@Chrono79
Jun 19 2016 00:31
@colorpanda2011
var myMusic = [
{
  first object
},
{
  the object you created
}
];
colorpanda
@colorpanda2011
Jun 19 2016 00:31
@Chrono79 thank you, you are right.
CamperBot
@camperbot
Jun 19 2016 00:31
colorpanda2011 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1233 | @chrono79 |http://www.freecodecamp.com/chrono79
Rana Amrit Parth
@ranaparth
Jun 19 2016 00:31

Need help. ```var Person = function(firstAndLast) {
this.fullName = firstAndLast;
var arr = firstAndLast.split(' ');
this.firstName = arr[0];
this.lastName = arr[arr.length - 1];
return {
getFirstName: function() { return this.firstName; },
getLastName: function() { return this.lastName; },
getFullName: function() { return this.fullName; },
setFirstName: function(first) {
this.firstName = first;
},
setLastName: function(last) {
this.lastName = last;
},
setFullName: function(firstAndLast) {
this.fullName = firstAndLast;
var arr = firstAndLast.split(' ');
this.firstName = arr[0];
this.lastName = arr[arr.length - 1];
}
};
//setFullName(firstAndLast);
//return firstAndLast;
};

var bob = new Person('Bob Ross');
bob.getFullName();```

Moisés Man
@moigithub
Jun 19 2016 00:31
comma is the array elements separator
@ranaamritparth backticks must be on its own line..
shift+enter to add new lines
colorpanda
@colorpanda2011
Jun 19 2016 00:32
@moigithub yep, thank you very much
CamperBot
@camperbot
Jun 19 2016 00:32
colorpanda2011 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: colorpanda2011 already gave moigithub points
Rana Amrit Parth
@ranaparth
Jun 19 2016 00:32
var Person = function(firstAndLast) { this.fullName = firstAndLast; var arr = firstAndLast.split(' ');
Moisés Man
@moigithub
Jun 19 2016 00:32
```js
code on next line
```
or
```html
code on next line
```
Diego Mayer
@Chrono79
Jun 19 2016 00:33
@ranaamritparth only one backtick is for one line code
Rana Amrit Parth
@ranaparth
Jun 19 2016 00:33
var Person = function(firstAndLast) {
    this.fullName = firstAndLast;
    var arr = firstAndLast.split(' ');
    this.firstName = arr[0];
    this.lastName = arr[arr.length - 1];
    return {
      getFirstName: function() { return this.firstName; },
      getLastName: function() { return this.lastName; },
      getFullName: function() { return this.fullName; },
      setFirstName: function(first) {
        this.firstName = first;
      },
      setLastName: function(last) {
        this.lastName = last;
      },
      setFullName: function(firstAndLast) {
        this.fullName = firstAndLast;
        var arr = firstAndLast.split(' ');
        this.firstName = arr[0];
        this.lastName = arr[arr.length - 1];
      }
    };
    //setFullName(firstAndLast);
    //return firstAndLast;
};

var bob = new Person('Bob Ross');
bob.getFullName();
Diego Mayer
@Chrono79
Jun 19 2016 00:33
:+1:
Moisés Man
@moigithub
Jun 19 2016 00:33
@ranaamritparth :+1:
Rana Amrit Parth
@ranaparth
Jun 19 2016 00:34
Thanks @moigithub
CamperBot
@camperbot
Jun 19 2016 00:34
ranaamritparth sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1466 | @moigithub |http://www.freecodecamp.com/moigithub
Rana Amrit Parth
@ranaparth
Jun 19 2016 00:34
need help with above code
Joe O.
@joffenhauser
Jun 19 2016 00:34
hi guys I’m stuck on exercise 207 (Return Early Pattern for Functions)
Diego Mayer
@Chrono79
Jun 19 2016 00:35
@ranaamritparth that's not good, this.nameOfTheMethod <- you need 6 of this
Joe O.
@joffenhauser
Jun 19 2016 00:35
any body in here up for helping me figure it out??
Diego Mayer
@Chrono79
Jun 19 2016 00:35
@joffenhauser do you have some code?
Rana Amrit Parth
@ranaparth
Jun 19 2016 00:35
okay. let me try.
Moisés Man
@moigithub
Jun 19 2016 00:35
@ranaamritparth getFirstName, getetc etc.. should be PUBlic functions/methods..
soo on the constructor.. u should use this keyword.. like
this.getFirstName = function(){......}
Dan Couper
@DanCouper
Jun 19 2016 00:36
@ranaamritparth do not return from a constructor function.
anacou
@anacou
Jun 19 2016 00:37
hey guys, how can I convert a switch statement into a lookup table?
and how do I call a lookup table "lookup"
Moisés Man
@moigithub
Jun 19 2016 00:37
@joffenhauser the number represent how many brownies points u get.. is not really the exercise number :)
u get more brownie points when some1 thanks you or u complete more challenges
CamperBot
@camperbot
Jun 19 2016 00:37
moigithub sends brownie points to @joffenhauser :sparkles: :thumbsup: :sparkles:
:cookie: 208 | @joffenhauser |http://www.freecodecamp.com/joffenhauser
Diego Mayer
@Chrono79
Jun 19 2016 00:37
:point_up: 18 de junio de 2016 21:21 @anacou
the thing you have in case thing:, should be the object property name, and the value you have in that case, is the value of that property
Dan Couper
@DanCouper
Jun 19 2016 00:38
@anacou (in answer to the second part) var lookup. Like var lookup = { foo: 1, bar: 2 }
shilpi verma
@shilpiverma509
Jun 19 2016 00:40
Hi friends, I needed help in understanding the conditions required to "Truncate a String "
Moisés Man
@moigithub
Jun 19 2016 00:40
@Chrono79 a q hora es en Argentina ? aca son las 7.40pm
Diego Mayer
@Chrono79
Jun 19 2016 00:40
9.40
Joe O.
@joffenhauser
Jun 19 2016 00:40

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

function abTest(a, b) {

// Only change code above this line

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

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

Diego Mayer
@Chrono79
Jun 19 2016 00:41
@joffenhauser if (a || b < 0); 2 errors
the first is the semicolon, it should be {
Joe O.
@joffenhauser
Jun 19 2016 00:41
trying to figure out markup still
This message was deleted
Moisés Man
@moigithub
Jun 19 2016 00:41
:point_up: June 18, 2016 7:32 PM @joffenhauser
Joe O.
@joffenhauser
Jun 19 2016 00:41
sorry @Chrono79
Diego Mayer
@Chrono79
Jun 19 2016 00:41
@joffenhauser no problem
what do you need to return?
Joe O.
@joffenhauser
Jun 19 2016 00:42
ok
whats the second error?
Rana Amrit Parth
@ranaparth
Jun 19 2016 00:42
@shilpiverma509 Do you have any code?
Diego Mayer
@Chrono79
Jun 19 2016 00:42
@joffenhauser there is a 3rd one too
Moisés Man
@moigithub
Jun 19 2016 00:42
@joffenhauser also u returning the funciton name.. i think should return false or true?
maybe reset the code... do again
Diego Mayer
@Chrono79
Jun 19 2016 00:42
@moigithub no true or false, another thing
Moisés Man
@moigithub
Jun 19 2016 00:43
redeclaring the function ?
Diego Mayer
@Chrono79
Jun 19 2016 00:43
@moigithub no, it should return early, some word that starts with un... ;)
Moisés Man
@moigithub
Jun 19 2016 00:43
underground
Sophia Diaz-Infante
@sophiaelisa
Jun 19 2016 00:44
thanks @moigithub !, I will give it a try
CamperBot
@camperbot
Jun 19 2016 00:44
sophiaelisa sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1467 | @moigithub |http://www.freecodecamp.com/moigithub
anacou
@anacou
Jun 19 2016 00:44
hey guys
Joe O.
@joffenhauser
Jun 19 2016 00:44
lol ok so I should amend code to say return undefined
anacou
@anacou
Jun 19 2016 00:44
I'm stuck on Using Objects for Lookups
here's what I have so far
Joe O.
@joffenhauser
Jun 19 2016 00:44
@Chrono79
anacou
@anacou
Jun 19 2016 00:44

// 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"
};
lookup[];
// Only change code above this line
return result;
}

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

Diego Mayer
@Chrono79
Jun 19 2016 00:45
@joffenhauser yes
the other thing is that if you write a || b < 0 is the same as if a != 0 || b < 0 (if a and b are numbers)
you have to write the 2 expressions separated by the or ||
Eric Crescioni
@ecam900
Jun 19 2016 00:46

Can anyone please help me?

Why is my replace not removing the spaces???


function palindrome(str) {
  // Good luck!
  var revString = str.split('').reverse().join('').toLowerCase().replace(/\s/g, '');

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



palindrome("race car");
shilpi verma
@shilpiverma509
Jun 19 2016 00:46
@ranaamritparth I havn't written the code. Wanted to know when it should return a truncated string with the dots and when it should return the string "as is" . I am a bit confused with the instructions given
Joe O.
@joffenhauser
Jun 19 2016 00:46
@Chrono79 all the other conditions to pass the challenge are fulfilled though
the only ones that aren’t are the ones about returning and “undefined” value
Diego Mayer
@Chrono79
Jun 19 2016 00:47
@joffenhauser did you put the quotes? If so, remove them
this test won't pass with the conditions you used: abTest(-2,2) should return undefined
Rana Amrit Parth
@ranaparth
Jun 19 2016 00:48
@shilpiverma509 If the maximum given string length is less than maximum return as it is.
Joe O.
@joffenhauser
Jun 19 2016 00:48

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

function abTest(a, b) {

// Only change code above this line

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

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

DC*
@desyncr
Jun 19 2016 00:49
@ecam900 It does removes the spaces. but revString and str will never match, becase you're not removing the spaces from str (among other things)
Diego Mayer
@Chrono79
Jun 19 2016 00:49
@joffenhauser I said it was the same, not that it was right (in fact, it's wrong)
if (a !== 0 || b < 0); //here replace; for { and fix the condition about a value
return undefined;
}
function abTest(a, b) { //delete this line
Joe O.
@joffenhauser
Jun 19 2016 00:49
lol @Chrono79 ok I see
Rana Amrit Parth
@ranaparth
Jun 19 2016 00:50
@shilpiverma509 If the maximum given string length is less than num return as it is.
Eric Crescioni
@ecam900
Jun 19 2016 00:50
@desyncr Thank you!!!!!!!!!!!!!!!!!!!!!
CamperBot
@camperbot
Jun 19 2016 00:50
ecam900 sends brownie points to @desyncr :sparkles: :thumbsup: :sparkles:
:cookie: 266 | @desyncr |http://www.freecodecamp.com/desyncr
Ryan Williams
@Ryanwfile
Jun 19 2016 00:51
Can someone please help me with this tic tac toe codepen, specifically the win conditions not triggering as they should. Thank you. http://codepen.io/Ryanwfile/pen/rLLoQq
Norvin Burrus
@ndburrus
Jun 19 2016 00:53
@joffenhauser a !== 0 ? ok... :)
Diego Mayer
@Chrono79
Jun 19 2016 00:54
@ndburrus he misunderstood
Joe O.
@joffenhauser
Jun 19 2016 00:54
@Chrono79

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

function abTest(a, b) {





  // Only change code above this line

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

// Change values below to test your code
abTest(2,-2);
?
Diego Mayer
@Chrono79
Jun 19 2016 00:54
@joffenhauser you need to fix this line: if (a || b < 0);
replace ; by {
do the same you did to b with a, that is create a comparison, because as it is written, it doesn't say if a or b are less than 0, you have to write if a is less than 0 or b is less than 0
Norvin Burrus
@ndburrus
Jun 19 2016 00:55
@anacou what does this function lookup[]; need? hint: a variable, perhaps? also, how is the output result being handled (or how do you want to handle it)?
@ecam900 you may find this regex tester useful: Regex101 :sparkles:
Joe O.
@joffenhauser
Jun 19 2016 00:59

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

  // Only change code above this line

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

// Change values below to test your code
abTest(2,-2);
Diego Mayer
@Chrono79
Jun 19 2016 01:00
@joffenhauser you can put both conditions in the same if separated by ||
delete this function abTest(a, b) { again
It's like the terminator or something, it comes back ;)
Joe O.
@joffenhauser
Jun 19 2016 01:02
then it says :
return state,ends are only valid inside functions
statements
Diego Mayer
@Chrono79
Jun 19 2016 01:03
@joffenhauser
function abTest(a, b) { // not this one, this one keep it
  // Only change code below this line
    if (a < 0) { 
    return undefined;
}  
  if (b < 0) {
    return undefined;
  }
} //delete this too
function abTest(a, b) { //this one should be DELETED
Joe O.
@joffenhauser
Jun 19 2016 01:03
if i leave it in there the console log comes back saying null
Diego Mayer
@Chrono79
Jun 19 2016 01:04
do you see the repeated line?
Joe O.
@joffenhauser
Jun 19 2016 01:05
yeah, the thing is if i don’t have it in there I get “return statements are only valid inside functions"
I just copied your code, including the repeated line in there and it somehow worked
I feel like the program had a bug or something possibly
Diego Mayer
@Chrono79
Jun 19 2016 01:06
@joffenhauser you're closing the function
replace the block in my previous post with this one:
function abTest(a, b) { 
  // Only change code below this line
    if (a < 0 || b < 0) { 
      return undefined;
    }
Ankur
@ankur01oct
Jun 19 2016 01:06
stuck with random quote...need help...JSON random quote api gives .... net::ERR_INSECURE_RESPONSE(using chrome browser)
Joe O.
@joffenhauser
Jun 19 2016 01:08
ok. like i said, the other code I was using just worked to pass the challenge though... @Chrono79
humansAreDum
@humansAreDum
Jun 19 2016 01:08
@ankur01oct post your code here or link to your codepen
Joe O.
@joffenhauser
Jun 19 2016 01:08
are you saying the other code was wrong? @Chrono79 Im just a little confused haha
Diego Mayer
@Chrono79
Jun 19 2016 01:08
@joffenhauser but it isn't the right code, you're redeclaring the function
Your code should be like this:
// Setup
function abTest(a, b) {
  // Only change code below this line

  if (a < 0 || b < 0) return undefined;

  // Only change code above this line

  return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}
Joe O.
@joffenhauser
Jun 19 2016 01:10
oook, I see exactly how it was supposed to work now @Chrono79
Diego Mayer
@Chrono79
Jun 19 2016 01:10
good
Joe O.
@joffenhauser
Jun 19 2016 01:11
just went back to the code I pasted initially and saw how it was different from yours
really appreciate the help, thank you
@Chrono79
Diego Mayer
@Chrono79
Jun 19 2016 01:11
no problem
humansAreDum
@humansAreDum
Jun 19 2016 01:11
you got to help my friend with this. someone plz
you will get 2 brownies
Ankur
@ankur01oct
Jun 19 2016 01:17
@Chrono79 @humansAreDum .. thanks
CamperBot
@camperbot
Jun 19 2016 01:17
:cookie: 7 | @humansaredum |http://www.freecodecamp.com/humansaredum
ankur01oct sends brownie points to @chrono79 and @humansaredum :sparkles: :thumbsup: :sparkles:
:star2: 1234 | @chrono79 |http://www.freecodecamp.com/chrono79
shilpi verma
@shilpiverma509
Jun 19 2016 01:23
@ranaamritparth thanks
CamperBot
@camperbot
Jun 19 2016 01:23
shilpiverma509 sends brownie points to @ranaamritparth :sparkles: :thumbsup: :sparkles:
:cookie: 308 | @ranaamritparth |http://www.freecodecamp.com/ranaamritparth
Sophia Diaz-Infante
@sophiaelisa
Jun 19 2016 01:36

After spending just about all day trying to figure out the card counting challenge, I finally got it right! @mrburks Thank you again @moigithub for the help!
var count = 0;

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

  case 10:
  case 'J':
  case 'Q':
  case 'K':
  case 'A':
answer = --count;
    break; 
  case 7: 
  case 8:
  case 9:
   answer = count; 


  }

if (answer >= 1 ) {
return count + " Bet";
}
else{

return count + " Hold"; 

}

// Only change code above this line
}

CamperBot
@camperbot
Jun 19 2016 01:36
sophiaelisa sends brownie points to @mrburks and @moigithub :sparkles: :thumbsup: :sparkles:
:cookie: 210 | @mrburks |http://www.freecodecamp.com/mrburks
:warning: sophiaelisa already gave moigithub points
Dipesh Sukhani
@DKSukhani
Jun 19 2016 01:38
@DKSukhani
Hello All, Need help. I used my FCC code onto a different website to test. However, it is not working.
I mean - the jquery section is not working
I also put the src <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js?ver=1.4.2'>
totes-ma-goats
@josephseverino
Jun 19 2016 01:39

function updateRecords(id, prop, value) {

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

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

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

return collection;
}

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

Can some explain why the above is returning "Cannot read property 'artist' of undefined?
Jason Keenan
@raavin
Jun 19 2016 01:41
@DKSukhani do you need jquery ui??
Kevin Schwert
@kevinpschwert
Jun 19 2016 01:41

On the Profile Lookup I am stuck on getting it to fully work. At one point I was able to get the first three of the solutions checked off and now I'm only able to get the last two. Here is my code:
//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

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

}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Sherlock", "number");

Diego Mayer
@Chrono79
Jun 19 2016 01:48
@kevinpschwert you have to check all the contacts before you can say "No such contact"
also if you return in every branch, your loop will run only one time
Eric
@Code-Eric
Jun 19 2016 01:54
function eliminate(x){


   return x !== "" && x !== false && x !== null && x !== undefined;

 }
  var result = arr.filter(eliminate);
  return result;
}
For some reason, this does not get rid of the null
Diego Mayer
@Chrono79
Jun 19 2016 01:57
Asan Cody
@csordelet
Jun 19 2016 01:57
I am working on a switch staement and have no idea what I am doing wrong. It's getting annoying now
Eric
@Code-Eric
Jun 19 2016 01:58
whatttt but on FCC the output says null @Chrono79
bitgrower
@bitgrower
Jun 19 2016 01:58
let's see the code @csordelet
Eric
@Code-Eric
Jun 19 2016 01:59
I think I understand whats going on
Jefferson Nascimento
@JeffersonCN
Jun 19 2016 01:59
Hey devs! I'm facing some problems trying to do the Wikipedia Challange
'''XMLHttpRequest cannot load https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&exsentences=3&exintro=1&explaintext=1&list=search&srsearch=undefined. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access.'''
CamperBot
@camperbot
Jun 19 2016 01:59
:bulb: to format code use backticks! ``` more info
Diego Mayer
@Chrono79
Jun 19 2016 01:59
@Code-Eric is that all your code? Because if it is, you're closing your function before the last 2 lines
Jefferson Nascimento
@JeffersonCN
Jun 19 2016 01:59
XMLHttpRequest cannot load https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&exsentences=3&exintro=1&explaintext=1&list=search&srsearch=undefined. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access.
Eric
@Code-Eric
Jun 19 2016 02:00
@Chrono79 Is it returning null because there is a NaN in the array? and no it isnt all the code
Diego Mayer
@Chrono79
Jun 19 2016 02:00
:point_up: 18 de junio de 2016 22:14 @JeffersonCN look if it helps you
bitgrower
@bitgrower
Jun 19 2016 02:00
@JeffersonCN -- yes that's a security issue that is, cross domain access is restricted for security reasons ... you can research "Access Control Allow Origin" and/or CORS on either/or stackoverflow, MDN ...
Diego Mayer
@Chrono79
Jun 19 2016 02:01
@Code-Eric you don't need to check all the falsy values one by one, you can use boolean as suggested in the helpful links
But if you want to check them one by one you're missing some values, NaN is one of them
Eric
@Code-Eric
Jun 19 2016 02:01
The .filter(Boolean)
?
Jefferson Nascimento
@JeffersonCN
Jun 19 2016 02:01
Ok! thank you @Chrono79 . I'll take a look at this.
CamperBot
@camperbot
Jun 19 2016 02:01
jeffersoncn sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1235 | @chrono79 |http://www.freecodecamp.com/chrono79
bitgrower
@bitgrower
Jun 19 2016 02:02
oh is this falsy bouncer ??? Yeah, by all means use the Boolean page ... I sweated hours on falsy until I read the boolbean page ... @Code-Eric
Eric
@Code-Eric
Jun 19 2016 02:02
@Chrono79 I did that but I am just curious on how to remove the NaN
Jefferson Nascimento
@JeffersonCN
Jun 19 2016 02:02
@bitgrower thanks! I'll search this too
CamperBot
@camperbot
Jun 19 2016 02:02
jeffersoncn sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1106 | @bitgrower |http://www.freecodecamp.com/bitgrower
Diego Mayer
@Chrono79
Jun 19 2016 02:03
@Code-Eric ok, the test for NaN is a bit tricky, try to find how to test against it
bitgrower
@bitgrower
Jun 19 2016 02:03
NaN is a weird critter ... and it is of type 'number' ...
Eric
@Code-Eric
Jun 19 2016 02:05
@Chrono79 I have a question not related to this one
Diego Mayer
@Chrono79
Jun 19 2016 02:06
shoot
Eric
@Code-Eric
Jun 19 2016 02:08
@Chrono79 in ceasers cipher, one thing i tried was to set up an object with a: n, b: o.. and so on and so forth. But, when I tried to access the object using an array index, like so: object[arr[1][2]] it didnt work for me. Is there any specific reason for that?
Diego Mayer
@Chrono79
Jun 19 2016 02:09
@Code-Eric if your object is like this myObj = {"a":"n", "b": "o" ...}; you should access it like this: myObj["a"] //"n"
Eric
@Code-Eric
Jun 19 2016 02:11
@Chrono79 I see what youre saying. But should it not also work with a variable? Say the “a” = var alpha. Shouldn’t myObj[alpha] work? and by that logic, if ‘a’ = arr[0][1] = var alpha. Should not myObj[alpha] return ’n’?
Micah Neumann
@MN4PVK4
Jun 19 2016 02:12
var myStr="I am a \"double qouted\" string inside \"double quotes\".";
Diego Mayer
@Chrono79
Jun 19 2016 02:12
@Code-Eric pm the code so I can see what's wrong
Micah Neumann
@MN4PVK4
Jun 19 2016 02:12
When I enter this the myStr stays there how do I get it the hell off!?!?!?
Diego Mayer
@Chrono79
Jun 19 2016 02:12
@MN4PVK4 qouted misspelled
Eric
@Code-Eric
Jun 19 2016 02:13
@Chrono79 if i still have it, I will. if not then ill recreate it. I remember it, it will just take a few minutes.
Norvin Burrus
@ndburrus
Jun 19 2016 02:13
@MN4PVK4 . ...was there a period in this exercise? ok... just reviewed it... :)
Diego Mayer
@Chrono79
Jun 19 2016 02:13
yes @ndburrus, it seems they've added it about the same time they've changed the record collection challenge
James Jung
@thejcode24
Jun 19 2016 02:15
Hey guys
can anyone help me with this problem
Using the nodeType information listed in Table 9.1, write a function to find all the HTML comments in the body section of a page and concatenate them into a single string. Add some comments to the code listed in Listing 9.2; then introduce and test your new function.
So far my code is this
<!DOCTYPE html>

<html>
<head>
    <title>Object Oriented Programming</title>

<script>
    function concatComment() {
        var text = '';
        for (var i=0; i < concatComment.length; i++) {
            if (concatComment[i].nodeType == 8) {
                text = concatComment[i];
                alert(text);
            }
        }
    }
    window.onload = concatComment;

</script>
</head>
<body>
    <!-- Header -->
    <h1>Things To Do</h1>

        <!-- List begin. -->
        <ol id="toDoList">
            <li>Mow the lawn</li>
            <li>Clean the windows</li>
            <li>Answer your email</li>
        </ol>

    <!-- To Do notes. -->
    <p id="toDoNotes">Make sure all these are completed by 8pm so you can watch the game on TV!</p>
</body>
</html>
Micah Neumann
@MN4PVK4
Jun 19 2016 02:15
@ndburrus @Chrono79 Yes there was a period and it's spelled correctly
Diego Mayer
@Chrono79
Jun 19 2016 02:16
@MN4PVK4 let's see it again, it said "double qouted" instead of "double quoted"
James Jung
@thejcode24
Jun 19 2016 02:16
I need to use nodeType == 8 to find all HTML comments and concanate them
Do you guys see where I may have gone wrong in my code?
Micah Neumann
@MN4PVK4
Jun 19 2016 02:17
var myStr="I am a \"double qouted\" string inside \"double quotes\".";
@Chrono79 var myStr="I am a \"double qouted\" string inside \"double quotes\".";
Diego Mayer
@Chrono79
Jun 19 2016 02:17
@MN4PVK4 change qouted for quoted
var myStr="I am a \"double quoted\" string inside \"double quotes\".";
Norvin Burrus
@ndburrus
Jun 19 2016 02:18
@Chrono79 ...nice catch :sparkles:
Diego Mayer
@Chrono79
Jun 19 2016 02:20
:+1:
William Cabell
@wbac88
Jun 19 2016 02:22
Hi guys, so I finally hit the record collection challenge, and I can get the first req green-checked, but the rest won't budge:
function updateRecords(id, prop, value) {

  if (value !== "") {

  collection.id.prop = (value);

  }


  else if (prop === "tracks", value !== "") {

           collection.id.prop.push(value);


           }

  else if (value === "") {

    delete collection.id.prop;

  }


  return collection;
}
Any thoughts?
Aravind
@scriptonist
Jun 19 2016 02:22
Hi...I am currently doing the change making problem in advance algorithm scripting. Should use a greedy approach to solve this problem ?
Diego Mayer
@Chrono79
Jun 19 2016 02:24
@MN4PVK4 did it work?
@wbac88 check dot notation vs bracket notation
Aravind
@scriptonist
Jun 19 2016 02:25
Hi...Currently i am working on the change making problem in advanced algorithm scripting. Should i use a greedy strategy to solve this problem ?
Diego Mayer
@Chrono79
Jun 19 2016 02:26
@scriptonist don't know what do you mean with greedy strategy
@wbac88 also check how you use 2 conditions in an if (they don't go separated by comma)
William Cabell
@wbac88
Jun 19 2016 02:27
@Chrono79 OK, I'll go Google.
Diego Mayer
@Chrono79
Jun 19 2016 02:27
@wbac88 or review previous challenges
William Cabell
@wbac88
Jun 19 2016 02:29
@Chrono79 Ah, ok, the notation helped. I hadn't gotten that difference before.
Meerimay
@futcomen
Jun 19 2016 02:29
hi 4 everyone who can explain me about "stand in line"(queue)? will be thankful
Moisés Man
@moigithub
Jun 19 2016 02:29
@wbac88 u can use "logical operators" (like AND, OR) to combine ur "conditional expression"
Diego Mayer
@Chrono79
Jun 19 2016 02:29
@futcomen what do you need help with?
do you understand how it works?
William Cabell
@wbac88
Jun 19 2016 02:30

OK, so this is the part that I'm having difficulty with now:
If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.

If "tracks" is non-existent before you update it, create an empty array before pushing a track to it.

Meerimay
@futcomen
Jun 19 2016 02:30
i didn't get the question what it wants? @Chrono79
and i couldn't get it how it works( @Chrono79
Diego Mayer
@Chrono79
Jun 19 2016 02:31
@futcomen do you understand the concept queue? It's like when you go buy something and there is a bunch of people before you
the first exits the queue first, and you go to the end
Meerimay
@futcomen
Jun 19 2016 02:32
@Chrono79 yes)
Diego Mayer
@Chrono79
Jun 19 2016 02:32
well, now you have an array
Meerimay
@futcomen
Jun 19 2016 02:33
go on pls. @Chrono79
Diego Mayer
@Chrono79
Jun 19 2016 02:33
you (item) need to be added at the end of it
you need an array method to do that from these 4: push, pop, shift and unshift, you've seen them in previous challenges
colorpanda
@colorpanda2011
Jun 19 2016 02:34
I stuck on Record Collection

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 (prop === "tracks" && value !== "")
collection.id.tracks.push(value);
else if (tracks === false)
collection.id.tracks="";
else if(value === "")
delete collection.id.prop;

return collection;
}

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

Moisés Man
@moigithub
Jun 19 2016 02:34
FIFO (first in , first out )
colorpanda
@colorpanda2011
Jun 19 2016 02:34
Plz helppp
Diego Mayer
@Chrono79
Jun 19 2016 02:34
then you need to remove the first, also, you need to use one of those 4 @futcomen
review those 4 challenges to remember how to use them, and figure out which 2 of those 4 you need
Meerimay
@futcomen
Jun 19 2016 02:35
so ok, thank you will try ) @Chrono79
CamperBot
@camperbot
Jun 19 2016 02:35
futcomen sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1236 | @chrono79 |http://www.freecodecamp.com/chrono79
Moisés Man
@moigithub
Jun 19 2016 02:36
@colorpanda2011 id and prop are variables.. NO dot notation with variables
Diego Mayer
@Chrono79
Jun 19 2016 02:36
@colorpanda2011 you too, review dot notation vs bracket notation (there are also other problems, but start with that)
colorpanda
@colorpanda2011
Jun 19 2016 02:37

function updateRecords(id, prop, value) {
if (value !== "" && prop !== "tracks")
prop = value;
else if (prop === "tracks" && value !== "")
collection.id.tracks.push(value);
else if (tracks === false)
collection.id.tracks="";
else if(value === "")
delete collection.id.prop;

return collection;
}

you mean this?
William Cabell
@wbac88
Jun 19 2016 02:40
function updateRecords(id, prop, value) {

  if (value !== "") {

  collection[id][prop] = (value);

  }


  else if (prop === "tracks" && value !== "") {

           collection[id][prop].push(value);


           }

  else  {

    delete collection[id][prop];

  }


  return collection;
}
This is where I am now, the tracks still aren't being registered even though they show in the console.
Diego Mayer
@Chrono79
Jun 19 2016 02:41
@wbac88 if (value !== "") { needs another condition, otherwise if props is tracks, it'll enter here and not the else
or nesting another if below
William Cabell
@wbac88
Jun 19 2016 02:42
if (value !== "" && prop !=="tracks")?
Diego Mayer
@Chrono79
Jun 19 2016 02:42
@wbac88 :+1:
= (value); the () aren't needed
and now you have to tackle this:
If "tracks" is non-existent before you update it, create an empty array before pushing a track to it.
Norvin Burrus
@ndburrus
Jun 19 2016 02:43
@futcomen this may be useful: Javascript Array Methods: Unshift(), Shift(), Push(), And Pop() :sparkles: @colorpanda2011 you may also like this...
William Cabell
@wbac88
Jun 19 2016 02:44
@Chrono79 Yes! This is what I've been struggling with, I can't figure out how to create the empty array.
I assume it's in a previous challenge, but I haven't seen it in going back through.
[] <- empty array
William Cabell
@wbac88
Jun 19 2016 02:45
facepalm
Diego Mayer
@Chrono79
Jun 19 2016 02:45
Norvin Burrus
@ndburrus
Jun 19 2016 02:45
@wbac88 you might like this Declare an Array in JavaScript :+1:
William Cabell
@wbac88
Jun 19 2016 02:46
@ndburrus Thanks, I'll check that out, too!
CamperBot
@camperbot
Jun 19 2016 02:46
wbac88 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 604 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jun 19 2016 02:46
@wbac88 enjoy! :fire:
William Cabell
@wbac88
Jun 19 2016 02:47
@Chrono79 So, I should use the hasOwnProperty to check and see if "tracks" exists? And then create an array and push the value onto it?
Diego Mayer
@Chrono79
Jun 19 2016 02:48
yes, you have to check if it doesn't exist
William Cabell
@wbac88
Jun 19 2016 02:48
@Chrono79 Alright, thank you again for all the help, I'm off to try that out!
CamperBot
@camperbot
Jun 19 2016 02:48
:star2: 1237 | @chrono79 |http://www.freecodecamp.com/chrono79
wbac88 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Jaren Escueta
@jarenescueta731
Jun 19 2016 02:49
hi everyone, i have an issue right now with the mouseleave() jquery method. any common causes why mouseenter would work but mouseleave does not?
i can post my project for context
ugh formatting looks horrible in the previewer
Meerimay
@futcomen
Jun 19 2016 02:53

@Chrono79 sorry for disturbing again ....
function nextInLine(arr, item) {
// Your code here
testArr=[1,2,3,4,5].shift();
testArr=[1,2,3,4,5].push(1);

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)); am i doing right?

Jaren Escueta
@jarenescueta731
Jun 19 2016 02:53
you can't even see what i'm trying to animate there, just check it out on a new tab
Diego Mayer
@Chrono79
Jun 19 2016 02:53
@futcomen inside your function use arr instead of testArr
and you should use the methods like this: arr.push(yourOtherParamHere);
Norvin Burrus
@ndburrus
Jun 19 2016 02:53
@jarenescueta731 ...are you using .appendTo? :sparkles:
Jaren Escueta
@jarenescueta731
Jun 19 2016 02:54
@ndburrus i don't think i am...
Meerimay
@futcomen
Jun 19 2016 02:54
array itself like [1,2,3,4,5]? @Chrono79
Diego Mayer
@Chrono79
Jun 19 2016 02:55
@futcomen arr, because it's your function parameter: function nextInLine(arr, item) {
Norvin Burrus
@ndburrus
Jun 19 2016 02:55
@jarenescueta731 ...this may be worth a try: "[is] ...event delegation... [being] done from a node which [is] higher in the DOM than the target element?" {ref: jquery hover, mouseenter, and mouseleave not working after .appendTo} :fire:
Gary Siu
@GarySiu
Jun 19 2016 02:55
@jarenescueta731 You never remove the class from the enter event
Meerimay
@futcomen
Jun 19 2016 02:55
@Chrono79 now will try again
Gary Siu
@GarySiu
Jun 19 2016 02:56
The styling even.
Jaren Escueta
@jarenescueta731
Jun 19 2016 02:57
@GarySiu what class should i be removing?
Diego Mayer
@Chrono79
Jun 19 2016 02:59
@futcomen also, check which one of those methods you have to use first
Gary Siu
@GarySiu
Jun 19 2016 02:59
@jarenescueta731 You add right: '50px'; and then never remove it. Try inspecting the switch with dev tools.
You'll see it also adds the left styling when you mouseout
Meerimay
@futcomen
Jun 19 2016 03:00
@Chrono79 push. then shift. is it right?
Diego Mayer
@Chrono79
Jun 19 2016 03:00
@futcomen yes

@jarenescueta731

  $("#sw1").mouseleave(function(){
    $("#sw1").animate({left: '0px'});
  });

it makes it hide again onmouseout

Meerimay
@futcomen
Jun 19 2016 03:03
@Chrono79 how can i return the element that was removed?
Diego Mayer
@Chrono79
Jun 19 2016 03:04
@futcomen https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift
some methods returns a value, check that, sometimes it's not what you expect, keep that in mind, for example, check what push returns too
Jaren Escueta
@jarenescueta731
Jun 19 2016 03:06
@Chrono79 @GarySiu @ndburrus Thanks all, i finally understood what you meant by "removing" the property. That didn't seem intuitive from the docs.
CamperBot
@camperbot
Jun 19 2016 03:06
jarenescueta731 sends brownie points to @chrono79 and @garysiu and @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 57 | @garysiu |http://www.freecodecamp.com/garysiu
:star2: 1238 | @chrono79 |http://www.freecodecamp.com/chrono79
:cookie: 605 | @ndburrus |http://www.freecodecamp.com/ndburrus
David Halls
@DavidHalls
Jun 19 2016 03:08
@jarenescueta731 i didnt like using jquery for this animation, if you hover over it multiple times, it just repeats the animation over and over
MrBurks
@mrburks
Jun 19 2016 03:08

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

// Only change code below this line;

var playerNumber; // Change this Line
var player = testObj;

so this looks nothing like the example yet the rules say only change the code below the comment line. not getting it.

Diego Mayer
@Chrono79
Jun 19 2016 03:09
@mrburks playerNumber value should be a number
if player has to be Montana, what number would you use?
MrBurks
@mrburks
Jun 19 2016 03:10
@Chrono79 yeah I see that
Jaren Escueta
@jarenescueta731
Jun 19 2016 03:10
@Byzgig sorry to hear that, the final version is meant to use those to toggle online/offline streamers. if you click one, it won't slide back but stay out.
David Halls
@DavidHalls
Jun 19 2016 03:10
@jarenescueta731 i know, im playing with it on yours, getting the same result as i did
MrBurks
@mrburks
Jun 19 2016 03:11
how about explaining the logic rather than cryptic hints. because If I don't understand the logic, then the hints are worthless.
Diego Mayer
@Chrono79
Jun 19 2016 03:12
@mrburks the logic is you have to use one var to store a number and then use that var with your object to set the second var value
The example they give you is this:
Here is an example of using a variable to access a property:

var someProp = "propName";
var myObj = {
  propName: "Some Value"
}
myObj[someProp]; // "Some Value"
example                   your code
someProp               playerNumber
"propName"          a number here linked to Montana
myObj                      testObj
"Some Value"       "Montana"
DanJacobCodes
@DanJacobCodes
Jun 19 2016 03:18
This message was deleted
chaitanya ashtekar
@chaitanyaashtekar
Jun 19 2016 03:21
@Chrono79
This message was deleted
Diego Mayer
@Chrono79
Jun 19 2016 03:23
@mrburks did you understand how to do it or not?
chaitanya ashtekar
@chaitanyaashtekar
Jun 19 2016 03:23
@Chrono79 private chat .
christianws
@christianws
Jun 19 2016 03:33

can someone explain to me this behavior. I want to call a function from within a function using an object.

var personFactory = function (name,gender){

    temp = {};
    temp.name = name;
    temp.gender = gender;

    temp.random= function(){
          return Math.random();
    };

    return temp;

};

var person1 = personFactory( "John" , "male" );
console.log(person1);

// this outputs { name: 'John', gender: 'male', random: [Function] }

when I console.log(person1) I expect to see person1.random returning a number but instead it just displays temp.random = [function]...
why is that?

Diego Mayer
@Chrono79
Jun 19 2016 03:37
@CurlyWS because person1.random is a function, try console.log person1.random(); instead
ronaldrdguez
@ronaldrdguez
Jun 19 2016 03:37
@CurlyWS person1.random is not a number, is a function. The number would be the result of calling said function, like in person1.random()
christianws
@christianws
Jun 19 2016 03:38
@Chrono79 ok that outputs a number
but why doesn't the function get called on it's own and automatically assign random to the return value?
Diego Mayer
@Chrono79
Jun 19 2016 03:39
@CurlyWS read about closures
christianws
@christianws
Jun 19 2016 03:39
I expect personFactory to output something like -> { name: 'John', gender: 'male', random: 0.872638476234}
Diego Mayer
@Chrono79
Jun 19 2016 03:40
@CurlyWS
var personFactory = function (name,gender){

    temp = {};
    temp.name = name;
    temp.gender = gender;

    temp.random= (function(){
          return Math.random();
    })();

    return temp;

};

var person1 = personFactory( "John" , "male" );
console.log(person1);

// this outputs { name: 'John', gender: 'male', random: 0.872638476234}
that's what you wanted
christianws
@christianws
Jun 19 2016 03:41
@Chrono79 ok cool thanks
CamperBot
@camperbot
Jun 19 2016 03:41
curlyws sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1239 | @chrono79 |http://www.freecodecamp.com/chrono79
christianws
@christianws
Jun 19 2016 03:42
@Chrono79 is there a name for that sort of formatting? what you did with the brackets there? I want to research it
Diego Mayer
@Chrono79
Jun 19 2016 03:42
yes, it's name is closures
chaitanya ashtekar
@chaitanyaashtekar
Jun 19 2016 03:42
@CurlyWS or you could just do
var personFactory = function (name,gender){
    temp = {};
    temp.name = name;
    temp.gender = gender;
   var x=Math.random();
      temp.random= x;
      return temp;
};
MrBurks
@mrburks
Jun 19 2016 03:43
@Chrono79 Yeah sorry got pulled away for a time. but yeah I hope I never have use something like that ever. seem a bit redunant.
chaitanya ashtekar
@chaitanyaashtekar
Jun 19 2016 03:43
but sure read about closures,u'll require it for algos
Diego Mayer
@Chrono79
Jun 19 2016 03:43
@mrburks :+1:
christianws
@christianws
Jun 19 2016 03:43
@Chrono79 I thought closures just refered to the fact that inner functions in JS can only access outer function variables?
@Chrono79 I have just spent a good 30 minutes reading about closures so I guess I didn't learn anything useful :P
colorpanda
@colorpanda2011
Jun 19 2016 03:45
@anthony Northrup
christianws
@christianws
Jun 19 2016 03:45
@chaitanyaashtekar @Chrono79 by the way thank you
CamperBot
@camperbot
Jun 19 2016 03:45
curlyws sends brownie points to @chaitanyaashtekar and @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: curlyws already gave chrono79 points
:cookie: 352 | @chaitanyaashtekar |http://www.freecodecamp.com/chaitanyaashtekar
Diego Mayer
@Chrono79
Jun 19 2016 03:45
@CurlyWS maybe I'm wrong, not failproof, but I'll check it out
Norvin Burrus
@ndburrus
Jun 19 2016 03:47
@CurlyWS you may enjoy this: Understand JavaScript Closures With Ease :sparkles:
christianws
@christianws
Jun 19 2016 03:48
@Chrono79 so putting a bracket around a function with() after does something to do with the closure of the function?
@ndburrus ok thanks I will check it now
CamperBot
@camperbot
Jun 19 2016 03:48
curlyws sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 606 | @ndburrus |http://www.freecodecamp.com/ndburrus
Diego Mayer
@Chrono79
Jun 19 2016 03:49
@CurlyWS maybe it's called self invoked/executed function (and I was wrong) https://sarfraznawaz.wordpress.com/2012/01/26/javascript-self-invoking-functions/
Drew Stonebraker
@drstonebraker
Jun 19 2016 03:49
function getFigures() {
  return document.getElementById('carousel').getElementsByTagName('figure');
}
var figures = getFigures();
console.log(figures); //gets me an array 3 figure DOM elements
figures.forEach(function(e, i) { {code} }); //gets me an error: "Uncaught TypeError: figures.forEach is not a function"
anyone know why i'm getting the error?
chaitanya ashtekar
@chaitanyaashtekar
Jun 19 2016 03:50
@Stoney229 which assignment is this ?
Norvin Burrus
@ndburrus
Jun 19 2016 03:50
@CurlyWS enjoy! in particular, see closure rules 1 through 3... this may answer your question/s. also see the "definition" {"What is a closure?"} as this may provide clarity... :+1:
Drew Stonebraker
@drstonebraker
Jun 19 2016 03:50
this is actually from an edx course... if that's okay?
Diego Mayer
@Chrono79
Jun 19 2016 03:52
@CurlyWS yes, self invoked/executed function is the right name
Drew Stonebraker
@drstonebraker
Jun 19 2016 03:52
in the course, they have it as a for loop instead, but I was trying to learn to use a forEach method instead. are there cases in which a for loop works for looping through an array and a forEach method does not?
Norvin Burrus
@ndburrus
Jun 19 2016 03:54
@Chrono79 ...nice article...
Diego Mayer
@Chrono79
Jun 19 2016 03:57
@ndburrus I'll check yours tomorrow so I don't confuse 2 different things again :P
Chris Cullen
@123xylem
Jun 19 2016 03:58
Quick QUESTION: Why is my push chgArr causing a infi loop at the bottom under the else???
function checkCashRegister(price, cash, cid) {
var val;
  var cost=arguments[0];
  var money=arguments[1];
var till= arguments[2];
  var count=0;
  var arr=[];
  var change= money-cost;

  if(change<0){
  change=Math.abs(change);}//this makes change positive if its negative value
else change=change;


  for(i=0; i<till.length;i++){
   count+=till[i][1];}
    if(change>count){
    return "Insufficient Funds";
// Make a count that totals till values. If change is more than till then say so

  }  else{
  var chgCount=0;
    var chgArr=[];
  for(j=till.length-1;j>0;j--){ //go through till from highest to lowest
    while(change>chgCount){//while change is more than 0

      chgCount+=till[j][1]; //add number to change from till
      chgArr.push(till[j][0]);//put that in an array THIS IS CAUSING A INFI LOOP FOR SOME REASON HOW DO I CHANGE THAT!?
      change-=till[j][1];//Take that number off change.
    }
  }return chgArr;


}
}

checkCashRegister(2.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
Norvin Burrus
@ndburrus
Jun 19 2016 03:58
@Chrono79 i do that when i have 3 or more things... :sparkles:
NixonRichard
@NixonRichard
Jun 19 2016 03:59
coding is hard
Brady
@BradyPainter
Jun 19 2016 03:59

How do you make the function exit with a value of undefined? // Setup
function abTest(a, b) {
// Only change code below this line
console.log(a < 0);
console.log(b < 0);

// Only change code above this line

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

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

christianws
@christianws
Jun 19 2016 03:59
@Chrono79 @ndburrus thanks again
CamperBot
@camperbot
Jun 19 2016 03:59
curlyws sends brownie points to @chrono79 and @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: curlyws already gave ndburrus points
:warning: curlyws already gave chrono79 points
Norvin Burrus
@ndburrus
Jun 19 2016 04:01
@CurlyWS you're welcome - pretty neat stuff... i think you're going to get shmancy... :fire:
@BradyPainter you could do a check for undefined... was that one of the requirements?
NixonRichard
@NixonRichard
Jun 19 2016 04:02
i just got my Full Stack certification yesterday
coding s so much ez for me
Norvin Burrus
@ndburrus
Jun 19 2016 04:02
@NixonRichard kudos to you! way to go :fire:
DJ
@qualitymanifest
Jun 19 2016 04:03
@Stoney229 you've got an object, you will need to convert it to an array before you can run the forEach on it
Drew Stonebraker
@drstonebraker
Jun 19 2016 04:04
@qualitymanifest thank you! can you help me understand (or point me somewhere that can explain) why it is an object and not an array?
CamperBot
@camperbot
Jun 19 2016 04:04
stoney229 sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1212 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
chaitanya ashtekar
@chaitanyaashtekar
Jun 19 2016 04:05
@Stoney229 how does your array look like ? paste here
DJ
@qualitymanifest
Jun 19 2016 04:06

@Stoney229 http://www.w3schools.com/js/js_htmldom_nodelist.asp

The getElementsByTagName() method returns a node list. A node list is an array-like collection of nodes.

im sure there's better docs out there, that's just one of the first that pops up

Aaron Hanna
@AaronHanna
Jun 19 2016 04:06
Good evening everyone! Quick question ...

function getIndexToIns(arr, num) {

arr.sort(function (a, b) {
return a - b;

});

for (var i in arr) {
  if (num <= arr[i]) {
    return i;
  }
}

return arr.length; 

}

this code returns the correct number for each test when I run them individually, but does not clear the challenge.
Drew Stonebraker
@drstonebraker
Jun 19 2016 04:07
blob
@chaitanyaashtekar when I console.log it looks like this^
chaitanya ashtekar
@chaitanyaashtekar
Jun 19 2016 04:08
@Stoney229 did u try adding this line
figures=[...figures];
Drew Stonebraker
@drstonebraker
Jun 19 2016 04:09
when I create a breakpoint and type figures in the console it look like [<figure class=visible></figure>, <figure></figure>, <figure></figure>]
chaitanya ashtekar
@chaitanyaashtekar
Jun 19 2016 04:09
@Stoney229 which course on edx? maybe ill try that
Brady
@BradyPainter
Jun 19 2016 04:10
I am lost with the "Return Early Patter for Function" challenge-- I am not sure what I am supposed to write :worried: anyone care to help out?
Drew Stonebraker
@drstonebraker
Jun 19 2016 04:10
@chaitanyaashtekar Microsoft: DEV211.1x Introduction to HTML, CSS and JavaScript Web Development . it's pretty low quality, IMO
Chris Cullen
@123xylem
Jun 19 2016 04:10

function checkCashRegister(price, cash, cid) {
var val;
  var cost=arguments[0];
  var money=arguments[1];
var till= arguments[2];
  var count=0;
  var arr=[];
  var change= money-cost;

  if(change<0){
  change=Math.abs(change);}//this makes change positive if its negative value
else change=change;


  for(i=0; i<till.length;i++){
   count+=till[i][1];}
    if(change>count){
    return "Insufficient Funds";
// Make a count that totals till values. If change is more than till then say so

  }  else{
  var chgCount=0;
    var chgArr=[];
  for(j=till.length-1;j>0;j--){ //go through till from highest to lowest
    while(change>chgCount){//while change is more than 0

      chgCount+=till[j][1]; //add number to change from till
      chgArr.push(till[j][0]);//put that in an array THIS IS CAUSING A INFI LOOP FOR SOME REASON HOW DO I CHANGE THAT!?
      change-=till[j][1];//Take that number off change.
    }
  }return chgArr;


}
}

checkCashRegister(2.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
This works on repl but not on FCC. WTF!!?? Any ideas why?
chaitanya ashtekar
@chaitanyaashtekar
Jun 19 2016 04:10
@Stoney229 ok
Drew Stonebraker
@drstonebraker
Jun 19 2016 04:11
@qualitymanifest @chaitanyaashtekar @ndburrus thanks everyone for you help!
CamperBot
@camperbot
Jun 19 2016 04:11
stoney229 sends brownie points to @qualitymanifest and @chaitanyaashtekar and @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: stoney229 already gave qualitymanifest points
:cookie: 607 | @ndburrus |http://www.freecodecamp.com/ndburrus
:cookie: 353 | @chaitanyaashtekar |http://www.freecodecamp.com/chaitanyaashtekar
MrBurks
@mrburks
Jun 19 2016 04:11
Did I mention I hate Stack Overflow?
NixonRichard
@NixonRichard
Jun 19 2016 04:11
hi what s substr ?
MrBurks
@mrburks
Jun 19 2016 04:11
sub-string maybe
NixonRichard
@NixonRichard
Jun 19 2016 04:12
is it the same ?
chaitanya ashtekar
@chaitanyaashtekar
Jun 19 2016 04:12
@123xylem it doesnt work on repl
@NixonRichard
@NixonRichard yes
NixonRichard
@NixonRichard
Jun 19 2016 04:12
what does it mean ?
MrBurks
@mrburks
Jun 19 2016 04:12
@NixonRichard The substr() method extracts parts of a string, beginning at the character at the specified position, and returns the specified number of characters.
Drew Stonebraker
@drstonebraker
Jun 19 2016 04:12
@chaitanyaashtekar what does figures=[...figures]; do? i've never seen that ellipses in code before
Chris Cullen
@123xylem
Jun 19 2016 04:13
@chaitanyaashtekar

function checkCashRegister(price, cash, cid) {
var val;
  var cost=arguments[0];
  var money=arguments[1];
var till= arguments[2];
  var count=0;
  var arr=[];
  var change= money-cost;

  if(change<0){
  change=Math.abs(change);}//this makes change positive if its negative value
else change=change;


  for(i=0; i<till.length;i++){
   count+=till[i][1];}
    if(change>count){
    return "Insufficient Funds";
// Make a count that totals till values. If change is more than till then say so

  }  else{
  var chgCount=0;
    var chgArr=[];
  for(j=till.length-1;j>0;j--){ //go through till from highest to lowest
    while(change>chgCount){//while change is more than 0

      chgCount+=till[j][1]; //add number to change from till
      chgArr.push(till[j][0]+" : "+till[j][1]);//put that in an array THIS IS CAUSING A INFI LOOP FOR SOME REASON HOW DO I CHANGE THAT!?
      change-=till[j][1];//Take that number off change.
    }
  }return chgArr;


}
}

checkCashRegister(2.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
That shoudl work on repl
I copy pasted it
MrBurks
@mrburks
Jun 19 2016 04:14
@NixonRichard basically it allows you to extract parts of a string with a starting character position and a specified character length
chaitanya ashtekar
@chaitanyaashtekar
Jun 19 2016 04:14
Diego Mayer
@Chrono79
Jun 19 2016 04:14
@AaronHanna isn't i a string instead of a number using for (var i in arr)?
Try return +i; to see if that fixes it
MrBurks
@mrburks
Jun 19 2016 04:15
@NixonRichard so if you had a string of a sentence, and you wanted a word or a group of words from that sentence you want.
I said that badly. "if you had a sentence 'as a string'"
Brady
@BradyPainter
Jun 19 2016 04:16

I am not quite sure if I am doing it right--help me out? // Setup
function abTest(a, b) {
// Only change code below this line
if (a === 0) {
return undefined;
} else if (b === 0) {
return undefined;
}
// Only change code above this line

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

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

Norvin Burrus
@ndburrus
Jun 19 2016 04:16
@BradyPainter well, you'll need a conditional evaluation, right? note: if a or b are less than 0 (in the instructions...)
NixonRichard
@NixonRichard
Jun 19 2016 04:16
yah @mrburks
Diego Mayer
@Chrono79
Jun 19 2016 04:16
@BradyPainter your if conditions are wrong
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
This message was deleted
CamperBot
@camperbot
Jun 19 2016 04:17
no wiki entry for: return early patter for function
Diego Mayer
@Chrono79
Jun 19 2016 04:17
This message was deleted
CamperBot
@camperbot
Jun 19 2016 04:17

:point_right: challenge return early pattern for functions [wiki]

Challenge Return Early Pattern for Functions

When a return statement is reached, the execution of the current function stops and control returns to the calling location.

:pencil: read more about challenge return early pattern for functions on the FCC Wiki

Hassaan Hafeez
@HassHz
Jun 19 2016 04:17
lol
Diego Mayer
@Chrono79
Jun 19 2016 04:19
@BradyPainter you're using a is 0 or b is 0 instead of less than 0
Aaron Hanna
@AaronHanna
Jun 19 2016 04:19
@Chrono79 That fixed it. So i in the for statement is a string and the + converts it to a number? The return didn't have quotes, so it looked as if it returned a number.
Diego Mayer
@Chrono79
Jun 19 2016 04:20
@AaronHanna yes, the + converts it to a number
Aaron Hanna
@AaronHanna
Jun 19 2016 04:20
@Chrono79 got it. thanks!
CamperBot
@camperbot
Jun 19 2016 04:20
aaronhanna sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1240 | @chrono79 |http://www.freecodecamp.com/chrono79
Brady
@BradyPainter
Jun 19 2016 04:20
@Chrono79 @ndburrus got it. :)
Norvin Burrus
@ndburrus
Jun 19 2016 04:21
@BradyPainter excellent work! :sparkles:
Diego Mayer
@Chrono79
Jun 19 2016 04:21
au revoir people
I need to sleep :sleepy:
chibisan352
@chibisan352
Jun 19 2016 04:24
I don't understand escape sequences..
Like at all lol
Norvin Burrus
@ndburrus
Jun 19 2016 04:26
@chibisan352 are you working on that exercise?
Brady
@BradyPainter
Jun 19 2016 04:30
For the counting cards challenge, should I write else/if or switch statements?
Norvin Burrus
@ndburrus
Jun 19 2016 04:32
@BradyPainter it's your choice! :sparkles:
Sonkeng Maldini
@sdmg15
Jun 19 2016 04:32
Hello ,
Could someone make a look at my "sandbox "
Jackson Leb
@JackLeb130111
Jun 19 2016 04:33
can anyone help on the Golf challenge thing
MrBurks
@mrburks
Jun 19 2016 04:33
:thumbsup:
Jackson Leb
@JackLeb130111
Jun 19 2016 04:33

```function golfScore(par, strokes) {
if (strokes = 1) {
return "Hole-in-one!";
}

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

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

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

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

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

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

else {
return "Change Me";
}
}

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

Sonkeng Maldini
@sdmg15
Jun 19 2016 04:33
Waiting for suggestions thx
Jackson Leb
@JackLeb130111
Jun 19 2016 04:33
sry

function golfScore(par, strokes) {
  if (strokes = 1) {
    return "Hole-in-one!";
  }

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

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

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

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

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

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

  else {
    return "Change Me";
  }
}

// Change these values to test
golfScore(5, 4);
Norvin Burrus
@ndburrus
Jun 19 2016 04:35
@JackLeb130111 else { return "Change Me"; ? :sparkles: also, you may want to use the == operator... [assignment in conditional expression]
Carl P.
@alofacarl
Jun 19 2016 04:36
@JackLeb130111 strokes = 1, you're assigning 1 to strokes. Need to set it to equal
Sonkeng Maldini
@sdmg15
Jun 19 2016 04:37
@JackLeb130111 strokes = 1, you're assigning 1 to strokes. Need to set it to equal
Yes in really all
Jackson Leb
@JackLeb130111
Jun 19 2016 04:37
@sdmg15 @alofacarl thanks, such a silly mistake...
CamperBot
@camperbot
Jun 19 2016 04:37
jackleb130111 sends brownie points to @sdmg15 and @alofacarl :sparkles: :thumbsup: :sparkles:
:cookie: 22 | @sdmg15 |http://www.freecodecamp.com/sdmg15
:cookie: 255 | @alofacarl |http://www.freecodecamp.com/alofacarl
Carl P.
@alofacarl
Jun 19 2016 04:37
yep
Sonkeng Maldini
@sdmg15
Jun 19 2016 04:40
@alofacarl please don't forget to have a look on my gist :worried:
MrBurks
@mrburks
Jun 19 2016 04:40
https://www.youtube.com/channel/UCl0hPcsUmeld49qmWWSQKOg I remembered this video series for beginners. its pretty helpful in many cases
Carl P.
@alofacarl
Jun 19 2016 04:41
@sdmg15 lol sorry, I looked at it but I'm a noob so I don't understand it
MrBurks
@mrburks
Jun 19 2016 04:42
does anyone here know how to draw? paint? write and play music?
Brady
@BradyPainter
Jun 19 2016 04:42

I know my code is wrong, but please pinpoint the error so I can fix it...For counting cards challenge---var count = 0;

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

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

Jon
@Antiphilous
Jun 19 2016 04:43
So I'm working on the arguments optional challenge and I can't figure out what I am supposed to do with a call like "addTogether(2)(3);
It keeps on saying addTogether is not a function when it comes to this
MrBurks
@mrburks
Jun 19 2016 04:45
@Antiphilous are you actually typing "addTogether(2)(3);" ?
can I sees ya code?
Jon
@Antiphilous
Jun 19 2016 04:45
@mrburks no I was just doing that to quote it
MrBurks
@mrburks
Jun 19 2016 04:45
ah
how are you expressing it?
Jon
@Antiphilous
Jun 19 2016 04:46

function addTogether() {  
  var a = arguments[0];
  var b = arguments[1];


  if( arguments.length < 2){

    return sumTwoAnd(a);

  }  else if( typeof a !== 'number' || typeof b !== 'number' ){


    return undefined;
  }

  return a + b;

  function sumTwoAnd(){
    if( typeof a !== 'number'){

      return undefined;
    }

    return a + 2;

  }
}

addTogether(2);
himanshu mittal
@himanshu081996
Jun 19 2016 04:46
@BradyPainter switch(card)
Jon
@Antiphilous
Jun 19 2016 04:47
@mrburks I have everything else in the challenge solved perhaps not as they hoped or elegantly but I can't seem to get it to work when it comes to addTogether(2)(3);
himanshu mittal
@himanshu081996
Jun 19 2016 04:47
@BradyPainter u r doing in wrong way
Brady
@BradyPainter
Jun 19 2016 04:47
@himanshu081996 I knew it. I am doing it wrong. I am not sure where to start :worried:
MrBurks
@mrburks
Jun 19 2016 04:48
hmm
Brady
@BradyPainter
Jun 19 2016 04:48
@himanshu081996 Should I write else/if statements, not switch?
Norvin Burrus
@ndburrus
Jun 19 2016 04:49
@BradyPainter the switch statement accepts a var/iable... that variable is used within the switch statement for case by case evaluation/s. check/review the syntax... (there are no returns in the statement, but there are breaks....see that?). what is included in the statement are adjustments to a var/iable used for calculating the running 5 card count total.... clear as mud? :sparkles:
himanshu mittal
@himanshu081996
Jun 19 2016 04:49
@BradyPainter if/else is est but u can do switch also
best
MrBurks
@mrburks
Jun 19 2016 04:49
@Antiphilous yeah some kinda way your code returns 4
Jon
@Antiphilous
Jun 19 2016 04:50
@mrburks Did you get it to work by sending in addTogether(2)(3) ?
MrBurks
@mrburks
Jun 19 2016 04:50
@Antiphilous so at the var declaration, looks like you're creating arrays (?)
Jon
@Antiphilous
Jun 19 2016 04:51
@Antiphilous because I don't understand right now how a function can take (var)(var) rather than just (var);
Brady
@BradyPainter
Jun 19 2016 04:51
@ndburrus @himanshu081996 I dont know why I am doing it wrong.
MikeBeers
@MikeBeers
Jun 19 2016 04:51
On my simon game I am trying to get one color to flash then a second color to flash. I am trying to use window.setTimeout on a for loop. It does not seem to be making it to the for loop.
var game = {
    cpArr: [],
    computer: function() {
        var timeOut;
        this.cpArr = clrArr.slice(0, 2);
        timeOut = window.setTimeout(this.itterate, 500)
    },

    itterate: function() {
        for (var i = 0; i < this.cpArr.length; i++) {    
            alert(this.cpArr[i]);
            if (this.cpArr[i] === "green") {
                display.flash('green');
            }
            if (this.cpArr[i] === "red") {
                display.flash('red');        
            }
            if (this.cpArr[i] === "yellow") {
                display.flash('yellow');
            }
            if (this.cpArr[i] === "blue") {
                display.flash('blue');
            }

        }
    },
Jon
@Antiphilous
Jun 19 2016 04:51
@mrburks no no I am just creating variables out of the arguments given to my function
nimaOngchu
@nimaOngchu
Jun 19 2016 04:52
hi guys i have been working on this inventory Update bonfire. i am getting an error TypeError: arrr1[i].indexOf is not a function. however if i comment the code inside the else statement this error doesnot show up.

function updateInventory(arr1, arr2) {
    // All inventory must be accounted for or you're fired!


  for(var j = 0; j<arr2.length; j++){
    for(var i = 0 ; i< arr1.length; i++){

  if(arr1[i].indexOf(arr2[j][1])>-1){// checking if the string elements in arr2 exits in arr1.
    if(arr1[i][0] !== arr2[j][0]){ // checking if the values are equal or not and decide if to update or not
      arr1[i][0] = arr2[j][0];
    }

  }
  else {
    arr1.push(arr2[j][0], arr2[j][1]);  
  }


}

  }
 return arr1; 

}


// Example inventory lists
var curInv = [
    [21, "Bowling Ball"],
    [2, "Dirty Sock"],
    [1, "Hair Pin"],
    [5, "Microphone"]
];

var newInv = [
    [2, "Hair Pin"],
    [3, "Half-Eaten Apple"],
    [67, "Bowling Ball"],
    [7, "Toothpaste"]
];

updateInventory(curInv, newInv);
MrBurks
@mrburks
Jun 19 2016 04:52
@Antiphilous have you tried "addTogether(2,3);" (?)
pourushsood
@pourushsood
Jun 19 2016 04:52
i'm having a problem in the record collection challenge.... ive tried the first prt and it shows the error : "TypeError": Cannot set property 'prop' of undefined

// 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";
return collection;
}

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

Jon
@Antiphilous
Jun 19 2016 04:54
@mrburks yes that works fine
himanshu mittal
@himanshu081996
Jun 19 2016 04:54
@BradyPainter
switch(card) // it only takes value
case:2
case:3
case:4
case:5
case:6
    count++;
    break;
case:7
case:8
case:9
    break;
case:10
..................
Jon
@Antiphilous
Jun 19 2016 04:54
@mrburks There is literally note which says that addTogether(2)(3) should return 5
himanshu mittal
@himanshu081996
Jun 19 2016 04:54
do like this
Jon
@Antiphilous
Jun 19 2016 04:55
but it just gives me errors if I do it that way :/
MrBurks
@mrburks
Jun 19 2016 04:55
@Antiphilous what is the title of the exercise?
Brady
@BradyPainter
Jun 19 2016 04:55
@himanshu081996 Oh! I will try that Thanks so much
CamperBot
@camperbot
Jun 19 2016 04:55
bradypainter sends brownie points to @himanshu081996 :sparkles: :thumbsup: :sparkles:
Chris Cullen
@123xylem
Jun 19 2016 04:55
Quick Question: How do I make my whhile loop work for the last condition??

function checkCashRegister(price, cash, cid) {
var val;
  var cost=arguments[0];
  var money=arguments[1];
var till= arguments[2];
  var count=0;
  var arr=[];
  var change= money-cost;
 var tillCount=0;
  var chgCount=0;

  if(change<0){
  change=Math.abs(change);}//this makes change positive if its negative value
else change=change;



  for(i=0; i<till.length;i++){
   count+=till[i][1];}
    if(change>count){ 
    return "Insufficient Funds";
// Make a count that totals till values. If change is more than till then say so

  }  else{
    var chgArr=[];
  for(i=till.length-1;i>=0;i--){
    while(change>chgCount&& till[i][1]>0 && till[i][1]<=change){// HOW DO I MAKE till[i][1]<=change NOT FAIL on while loop? I can use if but not sure how to use an if here??

      chgCount+=till[i][1];  
      change-=till[i][1];
      chgArr.push(till[i][0]+till[i][1]);

    }
        return chgArr;}
  }


}

checkCashRegister(2, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
CamperBot
@camperbot
Jun 19 2016 04:55
:cookie: 275 | @himanshu081996 |http://www.freecodecamp.com/himanshu081996
himanshu mittal
@himanshu081996
Jun 19 2016 04:56
@BradyPainter np give ur best
Jon
@Antiphilous
Jun 19 2016 04:57
@mrburks arguments optional
Brady
@BradyPainter
Jun 19 2016 04:58

@himanshu081996 I wrote it but it seemingly failed to recognize the count variable. -var count = 0;

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

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

MrBurks
@mrburks
Jun 19 2016 05:00

@Antiphilous And these are your goals:

addTogether(2, 3) should return 5.
addTogether(2)(3) should return 5.
addTogether("http://bit.ly/IqT6zt") should return undefined.
addTogether(2, "3") should return undefined.
addTogether(2)([3]) should return undefined.

Norvin Burrus
@ndburrus
Jun 19 2016 05:01
@BradyPainter review/check the punctuation, here: variable. -var count = 0;alright, now we need to handle the output.....
Jon
@Antiphilous
Jun 19 2016 05:01
@mrburks correct
I think it has to do something with how I am calling the functions
MrBurks
@mrburks
Jun 19 2016 05:01
@Antiphilous I think you have a few more if conditionals to write.
himanshu mittal
@himanshu081996
Jun 19 2016 05:02
@BradyPainter after ur code u have to add
if (count>0)
return count + " Bet";
else if (count<=0)
return count + " Hold";
this is your desired output for ur challenge
MrBurks
@mrburks
Jun 19 2016 05:02
yeah dude, I'm sorry Im not sure i can help. I thought I could but you're actually beyond me at this point.
Brady
@BradyPainter
Jun 19 2016 05:03
@himanshu081996 my code is in switch statements, I am not sure which place to put the output part..
Norvin Burrus
@ndburrus
Jun 19 2016 05:04
@BradyPainter well, the function has the pupose of evaluating the card running count/total, right? so where, logically, might the output part be?
Brady
@BradyPainter
Jun 19 2016 05:06
@ndburrus I assume the output part will be outside of switch statements?

I know I am doing it wrong....pinpoint the error?
function cc(card) {
// Only change code below this line
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 7:
case 8:
case 9:
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count--;
break;
}
if (count > 0) {
return "Bet";
} else if (count <= 0) {
return "Hold";
}
// Only change code above this line
}

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

Norvin Burrus
@ndburrus
Jun 19 2016 05:08
@BradyPainter that would be correct! as a check (not an assumption), you could reference th statement format/syntax: Switch Statements in JavaScript :sparkles: check the requirement/s: here - The current count and the player's decision ("Bet" or "Hold") should be separated by a single space. :) are you getting the right return/s?
himanshu mittal
@himanshu081996
Jun 19 2016 05:11
@BradyPainter ur code is correct but this is not desired output
see my previous message u will find your error automatically
Brady
@BradyPainter
Jun 19 2016 05:11
@ndburrus forgive me, English is not my first language. I am more confused than before. :worried:
himanshu mittal
@himanshu081996
Jun 19 2016 05:12
if (count>0)
return count + " Bet";
else if (count<=0)
return count + " Hold";
Norvin Burrus
@ndburrus
Jun 19 2016 05:12
@BradyPainter what is your first language?
Brady
@BradyPainter
Jun 19 2016 05:13
@ndburrus American Sign Language is my first language--I am deaf
NixonRichard
@NixonRichard
Jun 19 2016 05:13
hi guyz what s arguments ?
Norvin Burrus
@ndburrus
Jun 19 2016 05:14
@BradyPainter ok, the logic for the return follows the switch statement... the return need the count value information to provide both pieces of information (the final card count value & the playing action, hold/bet) clear as mud? :)
Ayush Kenhi
@AyushKenhi
Jun 19 2016 05:15

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

  // Only change code below this line

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

    result = result.val;

    return result;
}

  // Only change code above this line
}

// Change this value to test
phoneticLookup("charlie");
whats wrong with this?
Norvin Burrus
@ndburrus
Jun 19 2016 05:16
@AyushKenhi which challenge name is this?
Ayush Kenhi
@AyushKenhi
Jun 19 2016 05:16
using objects for lookup
christianws
@christianws
Jun 19 2016 05:17
@AyushKenhi yo check your return
Ayush Kenhi
@AyushKenhi
Jun 19 2016 05:17
@CurlyWS what to check ?
Norvin Burrus
@ndburrus
Jun 19 2016 05:17
@AyushKenhi thank you, val is a variable, and you're using dot notation... this may be useful: JS dot-notation vs. bracket notation also, it is helpful to adhere to the exercise guidance: // Only change code above this line return result;
CamperBot
@camperbot
Jun 19 2016 05:17
ndburrus sends brownie points to @ayushkenhi :sparkles: :thumbsup: :sparkles:
:cookie: 230 | @ayushkenhi |http://www.freecodecamp.com/ayushkenhi
christianws
@christianws
Jun 19 2016 05:18
@AyushKenhi you need to return result before last curly brace
Jon
@Antiphilous
Jun 19 2016 05:18
@mrburks Thank you for the help i finally got it but I still not know if I understand what is going on
CamperBot
@camperbot
Jun 19 2016 05:18
antiphilous sends brownie points to @mrburks :sparkles: :thumbsup: :sparkles:
:cookie: 218 | @mrburks |http://www.freecodecamp.com/mrburks
NixonRichard
@NixonRichard
Jun 19 2016 05:19
hi guyz
happy coding
Ayush Kenhi
@AyushKenhi
Jun 19 2016 05:19
@CurlyWS doesnt work
Brady
@BradyPainter
Jun 19 2016 05:19
@ndburrus I never counted the cards in real life so with coding, it became more confusing for me
NixonRichard
@NixonRichard
Jun 19 2016 05:19
why html s not a programming language ?
Ayush Kenhi
@AyushKenhi
Jun 19 2016 05:19
@ndburrus it says use lookup table called lookup
Hassaan Hafeez
@HassHz
Jun 19 2016 05:20
@AyushKenhi When you're trying to access objects with variables such as val, you need to use bracket notation
Brady
@BradyPainter
Jun 19 2016 05:20
@ndburrus I appreciate your help. I think I will stop for today. Thanks.
CamperBot
@camperbot
Jun 19 2016 05:20
bradypainter sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 610 | @ndburrus |http://www.freecodecamp.com/ndburrus
NixonRichard
@NixonRichard
Jun 19 2016 05:21
this s how u count ur card 2,3,4,5,6,7,8,9,10,J,Q,K,A
Norvin Burrus
@ndburrus
Jun 19 2016 05:21
@BradyPainter you are best in class! nice job! :sparkles:
Hassaan Hafeez
@HassHz
Jun 19 2016 05:21
Also it's kind of confusing, I would suggest making the object a different name
Ayush Kenhi
@AyushKenhi
Jun 19 2016 05:21
@HassHz @ndburrus @CurlyWS Thank you
CamperBot
@camperbot
Jun 19 2016 05:21
ayushkenhi sends brownie points to @hasshz and @ndburrus and @curlyws :sparkles: :thumbsup: :sparkles:
:cookie: 379 | @hasshz |http://www.freecodecamp.com/hasshz
:cookie: 206 | @curlyws |http://www.freecodecamp.com/curlyws
:cookie: 611 | @ndburrus |http://www.freecodecamp.com/ndburrus
christianws
@christianws
Jun 19 2016 05:21
@AyushKenhi @AyushKenhi
function phoneticLookup(val) {
  var result = ""; 

  // Only change code below this line

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

    result = result[val];

    return result;


  // Only change code above this line
}

// Change this value to test
console.log(phoneticLookup("charlie"));
Norvin Burrus
@ndburrus
Jun 19 2016 05:21
@AyushKenhi you're very welcome... is it resolved? wait, where is the key/value pair)/table name? ...and there are 2 result assignments... ?
christianws
@christianws
Jun 19 2016 05:22
@AyushKenhi changes .val to [val] and removed your last curlybrace
NixonRichard
@NixonRichard
Jun 19 2016 05:23
if (str.substr(-target.length) === target)
hi guyz
what s this actually do ?
nevermind i figured it out by myself
Norvin Burrus
@ndburrus
Jun 19 2016 05:26
@NixonRichard you may enjoy this: What is the arguments object? :sparkles:
christianws
@christianws
Jun 19 2016 05:28

oh wow I am having so much trouble with this closure stuff. I don't know how I have got this far.

I thought if you set a function to a variable, the result of the function becomes the value for that variable?

for example in this code,


var test = function(){
    return 45;
};

if (test===45){
    console.log("=45");
}else{
    console.log("!==45");
}

I expect test === 45
but instead test returns [functions]

NixonRichard
@NixonRichard
Jun 19 2016 05:29
okay that seem awesome
:+1:
christianws
@christianws
Jun 19 2016 05:30
oh I think I've just fixed my syntax
*
if (test()===45){
    console.log("=45");
}else{
    console.log("!==45");
}
NixonRichard
@NixonRichard
Jun 19 2016 05:31
what s the best thing a developer can become ?
Chris Cullen
@123xylem
Jun 19 2016 05:31

Quick Interesting QUEstion!!!:

checkCashRegister(2, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);

Im trying to convert the array into usable chuhnks that a count can accumulate with. EXAMPLE: in ["TEN", 20.00] there are 2 10s = 20.00... I need the array to say 10,10 so that count can use the values .
The challenge is Exact Change

Norvin Burrus
@ndburrus
Jun 19 2016 05:31
@CurlyWS nice work :fire:
NixonRichard
@NixonRichard
Jun 19 2016 05:33
hi what does the += do ?
christianws
@christianws
Jun 19 2016 05:34

@123xylem I would first create an object with the values of each coin

for example,
coins = { "penny" : 0.01,
"pound" : 1.00,
"quater": 0.25
};

himanshu mittal
@himanshu081996
Jun 19 2016 05:34
how to convert a binary number to decimal number
??
NixonRichard
@NixonRichard
Jun 19 2016 05:35
u just cant do that
christianws
@christianws
Jun 19 2016 05:35
@123xylem then you can divide the values by the value of the coin ->
penny 1.01 / 0.01 == 101 coins
@himanshu081996 one second
himanshu mittal
@himanshu081996
Jun 19 2016 05:35
@CurlyWS k
christianws
@christianws
Jun 19 2016 05:36
@himanshu081996 parseInt(string, radix);
if you set radix to 2 it can be used to convert from binary -> decimal I think
if you push some some binary data in string form to that function with radix set to 2 it converts it to a number
if I remember correctly. Tell me if that works for my benefit also
Dan
@dcgoings
Jun 19 2016 05:37
is anyone here familiar with the forismatic api?
himanshu mittal
@himanshu081996
Jun 19 2016 05:38
@CurlyWS it works
christianws
@christianws
Jun 19 2016 05:39
@himanshu081996 magic
himanshu mittal
@himanshu081996
Jun 19 2016 05:39
@CurlyWS thank you but y we assign radix to 2
CamperBot
@camperbot
Jun 19 2016 05:39
himanshu081996 sends brownie points to @curlyws :sparkles: :thumbsup: :sparkles:
:cookie: 207 | @curlyws |http://www.freecodecamp.com/curlyws
NixonRichard
@NixonRichard
Jun 19 2016 05:39
 var string = '';
  while (num>0){
    string += str;
    num--;
  }

  return string;
}
christianws
@christianws
Jun 19 2016 05:40
@himanshu081996 it is to do with the formatting. default is 4
NixonRichard
@NixonRichard
Jun 19 2016 05:40
what s the num-- doing in this code ?
christianws
@christianws
Jun 19 2016 05:40
I think if you convert "42" with radix as 4 it will convert it as you expect basically
Coy Sanders
@coymeetsworld
Jun 19 2016 05:40
its decrementing @NixonRichard
christianws
@christianws
Jun 19 2016 05:41
@NixonRichard yeah it's similar to setting a limit. If num = 10 then you limit the iterations to 10
himanshu mittal
@himanshu081996
Jun 19 2016 05:41
@CurlyWS it is giving null
christianws
@christianws
Jun 19 2016 05:41
@himanshu081996 you need to define num before while
himanshu mittal
@himanshu081996
Jun 19 2016 05:42
what if i have to convert a decimal number into binary
christianws
@christianws
Jun 19 2016 05:43

 var string = '';
//insert this
var num = 10;

  while (num>0){
    string += str;
    num--;
  }

  return string;
}
NixonRichard
@NixonRichard
Jun 19 2016 05:43
if it s a limit why can i change it into a number ?
*cant
christianws
@christianws
Jun 19 2016 05:43
@NixonRichard you can ^
@himanshu081996 don't know the answer to that would be interested to know what you find though
Chris Cullen
@123xylem
Jun 19 2016 05:44
@CurlyWS Yea im gonna make denominations and push them into relevant place
christianws
@christianws
Jun 19 2016 05:45
@123xylem I haven't done this challenge yet is in advanced algo?
Chris Cullen
@123xylem
Jun 19 2016 05:47
@CurlyWS ye[
@CurlyWS actually feels like an easier one
Leo
@Leodhy
Jun 19 2016 05:47
i'm doing the "caesars cipher" part, what's wrong with my code?
christianws
@christianws
Jun 19 2016 05:48
@123xylem I'm procrastinating need to finish intermediate today really got 2 left
Leo
@Leodhy
Jun 19 2016 05:48

function rot13(str) { // LBH QVQ VG!
for (var i=0;i<str.length;i++){ if (str[i].charCodeAt >= 65 && str[i].charVodeAt <= 77){
str[i].fromCharCode(str[i].charCodeAt()+13);
}
if (str[i].charCodeAt >= 78 && str[i].charVodeAt <= 90){
str[i].fromCharCode(str[i].charCodeAt()-13);
}
}
return str;
}

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

christianws
@christianws
Jun 19 2016 05:48
^
function rot13(str) { // LBH QVQ VG!
  for (var i=0;i<str.length;i++){
    if (str[i].charCodeAt >= 65 && str[i].charVodeAt <= 77){
      str[i].fromCharCode(str[i].charCodeAt()+13);
    }
    if (str[i].charCodeAt >= 78 && str[i].charVodeAt <= 90){
      str[i].fromCharCode(str[i].charCodeAt()-13);
    }    
  }
  return str;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
use '' and '' between code snippets
himanshu mittal
@himanshu081996
Jun 19 2016 05:49
@CurlyWS i found it but dont know reason parseInt(num, 10).toString(2);
it will convert a decimal number to binary
Leo
@Leodhy
Jun 19 2016 05:50
which line? @CurlyWS
NixonRichard
@NixonRichard
Jun 19 2016 05:50
hmm hmm
  while (num>0){
    str += str;
    num--;
  }

  return str;
}

repeatStringNumTimes("abc",2);
i wonder why this repeat the string too much
instead of 2 it repeat 4 times
Shubham Singh
@shubh305
Jun 19 2016 05:51
function repeat(str, num) {  
    if(num === 0) {
      return str;
    } else if(num > 0) {
      return str.repeat(num);
    } else if(num < 0) {
      return '""';
    }
}
repeat('abc', -1);
Still Getting an error
NixonRichard
@NixonRichard
Jun 19 2016 05:53
num === 0 and < 0 shuold return the same result
Norvin Burrus
@ndburrus
Jun 19 2016 05:53
@shubh305 what is the logic here: if(num === 0) { return str;?
Shubham Singh
@shubh305
Jun 19 2016 05:53
means it won't repeat
christianws
@christianws
Jun 19 2016 05:53
@himanshu081996 so maybe radix 10 converts decimal to binary?
@NixonRichard
  // num represents number of iterations
  var str ="";
  var num=10;

  while (num>0){


    console.log(num);
    str += str;
    num--;
  }
Shubham Singh
@shubh305
Jun 19 2016 05:53
it will return the string itself @ndburrus
Norvin Burrus
@ndburrus
Jun 19 2016 05:54
@shubh305 but, wouldn't an empty string be returned?
Shubham Singh
@shubh305
Jun 19 2016 05:54
everything is working but I an getting 1 error
repeatStringNumTimes("abc", -2) should return "".
this error
even though it is returning ""
NixonRichard
@NixonRichard
Jun 19 2016 05:55
if(num === 0) {
      return str;
    } else if(num > 0) {
      return str.repeat(num);
    } else if(num < 0) {
      return '';
    }
}
ur code fixed
as it said reutrn " "
not " " " "
lol
Shubham Singh
@shubh305
Jun 19 2016 05:56
did you run the code? @ndburrus
Norvin Burrus
@ndburrus
Jun 19 2016 05:56
@shubh305 remove extra quotation marks...
Shubham Singh
@shubh305
Jun 19 2016 05:56
it is giving me an error
NixonRichard
@NixonRichard
Jun 19 2016 05:56
i runed thed code
it worked
Shubham Singh
@shubh305
Jun 19 2016 05:57
nope
still getting the same error
run this repeat('abc', -2);
NixonRichard
@NixonRichard
Jun 19 2016 05:58
just copy my code and paste u ll get it worked
there s no such error here
Shubham Singh
@shubh305
Jun 19 2016 05:58
it isnt working as it is not returning ""
Norvin Burrus
@ndburrus
Jun 19 2016 05:58
@shubh305 can you post entire code?
Shubham Singh
@shubh305
Jun 19 2016 05:58
it is just returning empty string
NixonRichard
@NixonRichard
Jun 19 2016 05:58
yes
Leo
@Leodhy
Jun 19 2016 05:58

function rot13(str) { // LBH QVQ VG!
for (var i=0;i<str.length;i++){ if (str[i].charCodeAt >= 65 && str[i].charVodeAt <= 77){
str[i].fromCharCode(str[i].charCodeAt()+13);
}
if (str[i].charCodeAt >= 78 && str[i].charVodeAt <= 90){
str[i].fromCharCode(str[i].charCodeAt()-13);
}
}
return str;
}

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

NixonRichard
@NixonRichard
Jun 19 2016 05:58
that s right
Leo
@Leodhy
Jun 19 2016 05:58
how could I change my code
NixonRichard
@NixonRichard
Jun 19 2016 05:59
reuturning does not mean the things it show on the black bar
Shubham Singh
@shubh305
Jun 19 2016 05:59
function repeat(str, num) {  
    if(num === 0) {
      return str;
    } else if(num > 0) {
      return str.repeat(num);
    } else if(num < 0) {
      return '""';
    }
}
repeat('abc', -1);
thats my code
NixonRichard
@NixonRichard
Jun 19 2016 05:59
if(num === 0) {
      return str;
    } else if(num > 0) {
      return str.repeat(num);
    } else if(num < 0) {
      return '';
    }
}
this s the right code for u
Shubham Singh
@shubh305
Jun 19 2016 06:00
nope,thats not right..try to run..
David Halls
@DavidHalls
Jun 19 2016 06:00
what challenge are you guys talking about
NixonRichard
@NixonRichard
Jun 19 2016 06:00
that s right i runed many time still right
Shubham Singh
@shubh305
Jun 19 2016 06:00
function repeat(str, num) {  
   if(num === 0) {
      return str;
    } else if(num > 0) {
      return str.repeat(num);
    } else if(num < 0) {
      return '';
    }
}
repeat('a', -2);
that's your code @NixonRichard ?
Norvin Burrus
@ndburrus
Jun 19 2016 06:01
@shubh305 there are still extra quotes...ok, you just posted again...
Shubham Singh
@shubh305
Jun 19 2016 06:01
@ndburrus where?
NixonRichard
@NixonRichard
Jun 19 2016 06:01
just ur code but i replaced return '' into return '""'
David Halls
@DavidHalls
Jun 19 2016 06:02
what challenge is this
Shubham Singh
@shubh305
Jun 19 2016 06:02
@Byzgig Bonfire repeat a string
himanshu mittal
@himanshu081996
Jun 19 2016 06:02
Check if the predicate (second argument) is truthy on all elements of a collection (first argument).
([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
how to do this
Shubham Singh
@shubh305
Jun 19 2016 06:02
@NixonRichard still not working
Norvin Burrus
@ndburrus
Jun 19 2016 06:03
@shubh305 just evaluate for num not positive, and num positive... per the instructions: Return an empty string if num is not a positive number. make sense?
NixonRichard
@NixonRichard
Jun 19 2016 06:03
it worked for me i dont know why not for u
maybe reload the page
it s a bug
Shubham Singh
@shubh305
Jun 19 2016 06:03
@NixonRichard it won't word because it is not returning "" in your case
NixonRichard
@NixonRichard
Jun 19 2016 06:04
no
David Halls
@DavidHalls
Jun 19 2016 06:04
@shubh305 i have a solution that is different
NixonRichard
@NixonRichard
Jun 19 2016 06:04
return s not the result it shows on the black bar
it just the return code and ur input
Shubham Singh
@shubh305
Jun 19 2016 06:05
@Byzgig say
NixonRichard
@NixonRichard
Jun 19 2016 06:05
Return an empty string if num is not a positive number.
Norvin Burrus
@ndburrus
Jun 19 2016 06:05
@Leodhy which exercise (name) is this?
NixonRichard
@NixonRichard
Jun 19 2016 06:05
look at that
David Halls
@DavidHalls
Jun 19 2016 06:05
```
NixonRichard
@NixonRichard
Jun 19 2016 06:05
return an empty string
Leo
@Leodhy
Jun 19 2016 06:06

Caesars Cipher

@Leodhy which exercise (name) is this?

David Halls
@DavidHalls
Jun 19 2016 06:06
function repeatStringNumTimes(str, num) {
  // repeat after me
  var test = "";
  for(var i = 0; i < num; i++){
      console.log(str);
      test = test.concat(str);
  }
  return test;
}

repeatStringNumTimes("abc", 3);
NixonRichard
@NixonRichard
Jun 19 2016 06:06
what does test.concat do ?
UtkarshShukla7
@UtkarshShukla7
Jun 19 2016 06:06
@shubh305 return str+str.repeat(num); for recursion
Ayush Kenhi
@AyushKenhi
Jun 19 2016 06:07

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

function checkObj(checkProp) {
  // Your Code Here
  //myObj.hasOwnPoperty(checkprop);

  return myObj.hasOwnPoperty(checkProp);
}

// Test your code by modifying these values
checkObj("gift");
This message was deleted
Leo
@Leodhy
Jun 19 2016 06:07
Caesars Cipher @ndburrus
NixonRichard
@NixonRichard
Jun 19 2016 06:07
it looks funny cuz concat s a word in my language
Ayush Kenhi
@AyushKenhi
Jun 19 2016 06:07
It isnt working
David Halls
@DavidHalls
Jun 19 2016 06:07
concatenates the strings together
UtkarshShukla7
@UtkarshShukla7
Jun 19 2016 06:07
@AyushKenhi myObj is an object not a function
@AyushKenhi so use bracket (or dot) notation
Ayush Kenhi
@AyushKenhi
Jun 19 2016 06:08
@UtkarshShukla7 return myObj[hasOwnPoperty(checkProp)];
Shubham Singh
@shubh305
Jun 19 2016 06:08
@Byzgig thanks it worked but can you please explain your code?
CamperBot
@camperbot
Jun 19 2016 06:08
shubh305 sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 337 | @byzgig |http://www.freecodecamp.com/byzgig
Ayush Kenhi
@AyushKenhi
Jun 19 2016 06:08
like this?
NixonRichard
@NixonRichard
Jun 19 2016 06:09
function repeat(str, num) {  
   if(num === 0) {
      return str;
    } else if(num > 0) {
      return str.repeat(num);
    } else if(num < 0) {
      return '';
    }
}
repeat('a', -2);
this s still right
UtkarshShukla7
@UtkarshShukla7
Jun 19 2016 06:09
@AyushKenhi ah ,sorry ,I am wrong
@AyushKenhi it was correct .what's the error
Ayush Kenhi
@AyushKenhi
Jun 19 2016 06:09
@ndburrus
David Halls
@DavidHalls
Jun 19 2016 06:10
@shubh305 so test starts as "", then concat adds it to test and gives you 'abc', then you do that 2 more times and get 'abcabcabc'
Chris Cullen
@123xylem
Jun 19 2016 06:10

@123xylem

   [ [ 'PENNY', 1.01, 0.01 ],   [ 'NICKEL', 2.05, 0.05 ],   [ 'DIME', 3.1, 0.1 ],   [ 'QUARTER', 4.25, 0.25 ],   [ 'ONE', 90, 1 ],   [ 'FIVE', 55, 5 ],   [ 'TEN', 20, 10 ],   [ 'TWENTY', 60, 20 ],   [ 'ONE HUNDRED', 100, 100 ] ]

In this array How can i make a var that looks at 2nd element and divides by 3rd element to get 1 number?
Eg var howManYcoins = array1/[2]
but for each array

NixonRichard
@NixonRichard
Jun 19 2016 06:10
concat means d*ck in my language
Ayush Kenhi
@AyushKenhi
Jun 19 2016 06:10
TypeError: myObj.hasOwnProperty is not a function
David Halls
@DavidHalls
Jun 19 2016 06:10
nice
himanshu mittal
@himanshu081996
Jun 19 2016 06:10
why this is not working
function truthCheck(collection, pre) {
  // Is everyone being true?
  var count=0;
  for(var i=0;i<collection.length;i++){
    if(collection[i][pre]===null)
      count++;
  }
  if(count>0)
    return false;
  else
    return true;
}

truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
David Halls
@DavidHalls
Jun 19 2016 06:10
@shubh305 concat basically does the same thing as test += str;
Shubham Singh
@shubh305
Jun 19 2016 06:11
@NixonRichard it worked thanks..must be a bug
CamperBot
@camperbot
Jun 19 2016 06:11
shubh305 sends brownie points to @nixonrichard :sparkles: :thumbsup: :sparkles:
:cookie: 21 | @nixonrichard |http://www.freecodecamp.com/nixonrichard
NixonRichard
@NixonRichard
Jun 19 2016 06:11
my pleasure @shubh305
Ayush Kenhi
@AyushKenhi
Jun 19 2016 06:11
@Byzgig Can you help me
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  //myObj.hasOwnPoperty(checkprop);

  return myObj.hasOwnPoperty(checkProp);
}

// Test your code by modifying these values
checkObj("gift");
David Halls
@DavidHalls
Jun 19 2016 06:11
@AyushKenhi what do you need
Shubham Singh
@shubh305
Jun 19 2016 06:11
@Byzgig thanks but I will go with Richard's code as it was my logic with renoved "" lol..easier to understand
CamperBot
@camperbot
Jun 19 2016 06:11
shubh305 sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:warning: shubh305 already gave byzgig points
David Halls
@DavidHalls
Jun 19 2016 06:12
@AyushKenhi k, what have you got
Ayush Kenhi
@AyushKenhi
Jun 19 2016 06:13
see above
David Halls
@DavidHalls
Jun 19 2016 06:13
@AyushKenhi you are missing this part of the challenge "If not, return "Not Found""
Ayush Kenhi
@AyushKenhi
Jun 19 2016 06:14
okay
Hassaan Hafeez
@HassHz
Jun 19 2016 06:14
@AyushKenhi You also typed "Poperty" instead of Property
Ayush Kenhi
@AyushKenhi
Jun 19 2016 06:14
@HassHz ha
@Byzgig so should i use if?
David Halls
@DavidHalls
Jun 19 2016 06:14
@AyushKenhi yes
himanshu mittal
@himanshu081996
Jun 19 2016 06:15
plzz help me with this
function truthCheck(collection, pre) {
  // Is everyone being true?
  var count=0;
  for(var i=0;i<collection.length;i++){
    if(collection[i][pre]===null)
      count++;
  }
  if(count>0)
    return false;
  else
    return true;
}

truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
David Halls
@DavidHalls
Jun 19 2016 06:15
@himanshu081996 what is the challenge name
himanshu mittal
@himanshu081996
Jun 19 2016 06:15
everything be true @Byzgig
Ayush Kenhi
@AyushKenhi
Jun 19 2016 06:16

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

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp)) {
    return myObj.checkProp;
  } else {
    return myObj.hasOwnProperty(checkProp);
  }

}

// Test your code by modifying these values
checkObj("gift");
will this work?
UtkarshShukla7
@UtkarshShukla7
Jun 19 2016 06:16
This message was deleted
Hassaan Hafeez
@HassHz
Jun 19 2016 06:17
@himanshu081996 First of all, use .hasOwnProperty() method to check if the property exist.
Second, you have to also check for falsy values such as (NaN, null, "", 0, false", undefined)
David Halls
@DavidHalls
Jun 19 2016 06:17
@AyushKenhi no, you need to return "not found" or somethign
Rahul Chaurasia
@rahulchaurasia01
Jun 19 2016 06:17
@HassHz hII
Hassaan Hafeez
@HassHz
Jun 19 2016 06:17
@AyushKenhi Using variables to check for properties requires bracket notation
and you need to do what @Byzgig said in your else statement
@rahulchaurasia01 Hey
karanss
@karanss
Jun 19 2016 06:20
// 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 (prop==="tracks"&&value!==""){
   collection[id][prop].push(value);

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



 }
  return collection;
}






// Alter values below to test your code
updateRecords(5439, "tracks", "Take a Chance on Me");
why I am getting TypeError:Cannot read property push of undefined
himanshu mittal
@himanshu081996
Jun 19 2016 06:21
@HassHz im not getting this
David Halls
@DavidHalls
Jun 19 2016 06:21
@himanshu081996 why are you checking for null?
Hassaan Hafeez
@HassHz
Jun 19 2016 06:22
@karanss To create the tracks property you have to do either:
collection[id]["tracks"]
or collection[id].tracks
What you have right now does nothing because it assumes tracks is a variable
@himanshu081996 What are you not getting?
himanshu mittal
@himanshu081996
Jun 19 2016 06:23
if the value of collection[i][pre] doesnot exit then it will return null
maybe im wrong
Hassaan Hafeez
@HassHz
Jun 19 2016 06:24
I think it will return undefined... either way use:
collection[i].hasOwnProperty(pre)
You should always use ^ for checking if properties exist...
karanss
@karanss
Jun 19 2016 06:24
@HassHz but still I am getting that error
Hassaan Hafeez
@HassHz
Jun 19 2016 06:24
@karanss You fixed what I told you?
David Halls
@DavidHalls
Jun 19 2016 06:25
@himanshu081996 but you want it to be true or false
Shubham Singh
@shubh305
Jun 19 2016 06:26
function truncate(str, num) {

  if(str.length > num){
    str = str.slice(0,num-3);
    str += "...";
  }
  return str;
}
truncate("A-tisket a-tasket A green and yellow basket", 11);
getting the desired output, still getting errors
David Halls
@DavidHalls
Jun 19 2016 06:27
@shubh305 i think it is supposed to be 11 chars, then ...
himanshu mittal
@himanshu081996
Jun 19 2016 06:28
function truthCheck(collection, pre) {
  // Is everyone being true?
  var count=0;
  for(var i=0;i<collection.length;i++){
    if(!collection[i].hasOwnProperty(pre))
      count++;
  }
  if(count<0)
    return false;
  else
    return true;
}

truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
Hassaan Hafeez
@HassHz
Jun 19 2016 06:28
@shubh305 I had to add a condition if(num >= str.length) return str...
himanshu mittal
@himanshu081996
Jun 19 2016 06:28
what is wrong now
Hassaan Hafeez
@HassHz
Jun 19 2016 06:28
@himanshu081996 I said you also have to check for falsy values such as NaN, "", 0, false, undefined, null
Shubham Singh
@shubh305
Jun 19 2016 06:28
@Byzgig its 11 chars man
@HassHz explain please
himanshu mittal
@himanshu081996
Jun 19 2016 06:28
ohh wait
Hassaan Hafeez
@HassHz
Jun 19 2016 06:30
@shubh305 I just found that when num was greater than the length of the string, the output should just be the string. So I added that condition in... I'm not sure if that's correct but it works
Actually it makes sense because the instructions only tell you to "Truncate a string (first argument) if it is longer than the given maximum string length (second argument)"
David Halls
@DavidHalls
Jun 19 2016 06:30
^^
Hassaan Hafeez
@HassHz
Jun 19 2016 06:31
But if num > str.length you don't have to truncate
Shubham Singh
@shubh305
Jun 19 2016 06:31
but my solution is correct and I am getting the desired output,still getting errors
Hassaan Hafeez
@HassHz
Jun 19 2016 06:31
The third case is correct?
@shubh305 Oh, I just tried your code and it worked... maybe try refreshing
karanss
@karanss
Jun 19 2016 06:32
@HassHz but how to define if property don't exist?We can check hasOwnProperty(prop) but how to define if it don't exist
Hassaan Hafeez
@HassHz
Jun 19 2016 06:33
Wait nvm... the last 2 cases aren't working for me
Shubham Singh
@shubh305
Jun 19 2016 06:33
dafaq is happening, it worked again..just like last time
himanshu mittal
@himanshu081996
Jun 19 2016 06:33
@HassHz finally done thanks alot
CamperBot
@camperbot
Jun 19 2016 06:33
:cookie: 380 | @hasshz |http://www.freecodecamp.com/hasshz
himanshu081996 sends brownie points to @hasshz :sparkles: :thumbsup: :sparkles:
Shubham Singh
@shubh305
Jun 19 2016 06:33
I refreshed and it worked..bugs..bugs..everywhere lo
lol
Hassaan Hafeez
@HassHz
Jun 19 2016 06:34
@karanss You can either set that hasOwnProperty(prop) === false or (!"yourObject".hasOwnProperty(prop)
NixonRichard
@NixonRichard
Jun 19 2016 06:35
hi what does the str.slice do ?
Robson Beaudry
@Robson-Beaudry
Jun 19 2016 06:35
Hey guys, I'm on the Arguments Optional algorithm, and was wondering what it means when you call a function with two sets of arguments for a function (ex. addTogether(2)(3);). What does this do?
Does it just call the function twice?
Oliver Lim
@sirpompous
Jun 19 2016 06:36
Hi I'm on the Diff Two Arrays algorithm
and i need a bit of help
function diffArray(arr1, arr2) {
return arr1.concat(arr2).filter(function(item) {
return (arr1.indexOf(item) == -1 && arr2.indexOf(item) == -1);
});
}
this doesn't work
but
David Halls
@DavidHalls
Jun 19 2016 06:36
@shubh305 4 and 5 are not passing
karanss
@karanss
Jun 19 2016 06:36
@HassHz
Oliver Lim
@sirpompous
Jun 19 2016 06:36
function diffArray(arr1, arr2) {
return arr1.concat(arr2).filter(function(item) {
return !(arr1.indexOf(item)! == -1 && arr2.indexOf(item) !== -1);
});
}
this works
NixonRichard
@NixonRichard
Jun 19 2016 06:37
hi what does str.slice do
karanss
@karanss
Jun 19 2016 06:37
This message was deleted
// 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 (prop==="tracks"&&value!==""){
   collection[id][prop].push(value);

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



 }
  return collection;
}






// Alter values below to test your code
updateRecords(5439, "tracks", "Take a Chance on Me");
still not working
Hassaan Hafeez
@HassHz
Jun 19 2016 06:37
@NixonRichard I believe slice() returns a portion of an array within the specified indeces
David Halls
@DavidHalls
Jun 19 2016 06:38
@NixonRichard it returns a copy of a portion of teh array
Hassaan Hafeez
@HassHz
Jun 19 2016 06:39

@karanss

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

This ^ is supposed to go within this condition:
else if (prop==="tracks"&&value!==""){

You should only be checking if collection has a tracks property IF prop === tracks

NixonRichard
@NixonRichard
Jun 19 2016 06:39
does that mean it extracts a new string from the provided string ?
Hassaan Hafeez
@HassHz
Jun 19 2016 06:39
@NixonRichard
The slice() method extracts a section of a string and returns a new string.
So yeah
David Halls
@DavidHalls
Jun 19 2016 06:39
yes, but the original string remains the same
NixonRichard
@NixonRichard
Jun 19 2016 06:40
okay
David Halls
@DavidHalls
Jun 19 2016 06:41
@sirpompous what is your question?
Rahul Chaurasia
@rahulchaurasia01
Jun 19 2016 06:42
@HassHz look this
@HassHz

function slasher(arr, howMany) {
  // it doesn't always pay to be first
  var mia, lucy = [];
  mia = arr.length;
  if (howMany > mia) {
    return [];
  }
  else if (howMany === 0) {
    return arr;
  }
  else if (howMany < mia){
    for (var i = 0; i<mia-howMany; i++){
     lucy = arr.filter(function(val) { return (val > howMany);});

    }
  }
  return lucy;
}

slasher([1, 2, 3], 2);
anacou
@anacou
Jun 19 2016 06:43
hey! I'm stuck on the Using Objects for Lookups challenge
Hassaan Hafeez
@HassHz
Jun 19 2016 06:43
@rahulchaurasia01 Looks complicated... not really but could be done simpler
David Halls
@DavidHalls
Jun 19 2016 06:44
@rahulchaurasia01 my code for that is one line
Rahul Chaurasia
@rahulchaurasia01
Jun 19 2016 06:44
hahhah
David Halls
@DavidHalls
Jun 19 2016 06:44
@anacou speak
anacou
@anacou
Jun 19 2016 06:45
@Byzgig here is what i have so far
var lookup ={
alpha: "Adams",
bravo: "Boston",
charlie: "Chicago",
delta: "Denver",
echo: "Easy",
foxtrot: "Frank"
};
Hassaan Hafeez
@HassHz
Jun 19 2016 06:45
@rahulchaurasia01 You can do it in one line too:
return arr.slice(howMany, arr.length);
anacou
@anacou
Jun 19 2016 06:45
I don't know how to use the lookup table above to lookup val and assign the associated string to the result variable
Rahul Chaurasia
@rahulchaurasia01
Jun 19 2016 06:45
oHhh yeah i just that slice
:P
i just forget
Hassaan Hafeez
@HassHz
Jun 19 2016 06:46
:)
Nick Ang
@nickangtc
Jun 19 2016 06:46
Hi guys, I have a question about promise and .then(). When using this code:
getLocation.then(function() { // some code to run using obtained location }, errorHandling), assuming getLocation function is "thenable", must getLocation end with a return statement?
David Halls
@DavidHalls
Jun 19 2016 06:46
@anacou k, that is the code already provided to you, what are your thoughts
Nick Ang
@nickangtc
Jun 19 2016 06:46
The problem I'm facing is that I get this error: Uncaught TypeError: Cannot read property 'then' of undefined
I'm very close to giving up on this cos I've spent more than a week trying to figure out how to use the god damn promises :(
MrBurks
@mrburks
Jun 19 2016 06:48
ok this lesson teaches nothing for accomplishing the goals what's up with that? Introducing JavaScript Object Notation JSON
anacou
@anacou
Jun 19 2016 06:49
I'm assuming that after the semi colon, I need something like this: lookup[???];
MrBurks
@mrburks
Jun 19 2016 06:49
I've check several other resources, even Stack OverDrown and still can't find anything
chaitanya ashtekar
@chaitanyaashtekar
Jun 19 2016 06:49
@nickangtc what assgn is that ?
David Halls
@DavidHalls
Jun 19 2016 06:49
@anacou good, getting warm, how would you do that
Nick Ang
@nickangtc
Jun 19 2016 06:50
@chaitanyaashtekar it's the weather app challenge - https://www.freecodecamp.com/challenges/show-the-local-weather
chaitanya ashtekar
@chaitanyaashtekar
Jun 19 2016 06:50
okay
Nick Ang
@nickangtc
Jun 19 2016 06:50
I think what would be really helpful is if someone here is willing to have a chat with me about Promises
NixonRichard
@NixonRichard
Jun 19 2016 06:51
something s wrong with this
Nick Ang
@nickangtc
Jun 19 2016 06:51
@chaitanyaashtekar ? :P
NixonRichard
@NixonRichard
Jun 19 2016 06:51
function truncateString(str, num) {
  // Clear out that junk in your trunk
  if (str.length > num)
    { str=str.slice(0,num-3);
      str += '...';}

  return str;
}

truncateString("A-", 1);
David Halls
@DavidHalls
Jun 19 2016 06:51
@nickangtc i dont know promises, and did not use them for that challenge
christianws
@christianws
Jun 19 2016 06:51
Hi guys I'm on the Arguments Optional bonfire of Intermediate Algos.
Can someone simply explain what it is asking me to do??? I have no idea
anacou
@anacou
Jun 19 2016 06:51
@Byzgig I'm not sure...
Nick Ang
@nickangtc
Jun 19 2016 06:52
@Byzgig did you just use multiple callbacks?
NixonRichard
@NixonRichard
Jun 19 2016 06:52
it shuold return "A..."not just ... as it is now
David Halls
@DavidHalls
Jun 19 2016 06:52
@anacou consider lookup like its a function, how would you call the lookup function
chaitanya ashtekar
@chaitanyaashtekar
Jun 19 2016 06:52
@CurlyWS real about closures 2-3 times on mdn and then attempt again
christianws
@christianws
Jun 19 2016 06:53
@chaitanyaashtekar but I don't even know what it is asking me to do
anacou
@anacou
Jun 19 2016 06:53
either with '' or [] if I remember correctly
Leo
@Leodhy
Jun 19 2016 06:53
how can i change my cold
code

function rot13(str) { // LBH QVQ VG!
for (var i=0;i<str.length;i++){ if (str[i].charCodeAt >= 65 && str[i].charVodeAt <= 77){
str[i].fromCharCode(str[i].charCodeAt()+13);
}
if (str[i].charCodeAt >= 78 && str[i].charVodeAt <= 90){
str[i].fromCharCode(str[i].charCodeAt()-13);
}
}
return str;
}

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

NixonRichard
@NixonRichard
Jun 19 2016 06:54
format help
MrBurks
@mrburks
Jun 19 2016 06:54
@Leodhy sneeze
Leo
@Leodhy
Jun 19 2016 06:54
Caesars Cipher part
NixonRichard
@NixonRichard
Jun 19 2016 06:54
help format
CamperBot
@camperbot
Jun 19 2016 06:54

: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

Nick Ang
@nickangtc
Jun 19 2016 06:54
@Byzgig I'd gotten really close without using promises (used multiple callbacks instead). The only problem I had was making the last callback (the one to display a background image according to weather conditions) execute only AFTER weather data has been obtained from forecast.io API
Leo
@Leodhy
Jun 19 2016 06:54
@mrburks what's that
Chris Cullen
@123xylem
Jun 19 2016 06:55
@CurlyWS btw why are u doing easy challenges for urself if u r good at coding?
Shusil Banjade
@shusil123
Jun 19 2016 06:55
@Leodhy , str.charCodeAt(i), not str[i].charCodeAt()
Nick Ang
@nickangtc
Jun 19 2016 06:55
And then I read about promises and how promising they are for cleanly managing multiple async processes
christianws
@christianws
Jun 19 2016 06:56
@123xylem I'm completing the course like everyone else man. I'm not finding this challenge easy
Nick Ang
@nickangtc
Jun 19 2016 06:56
It's this video that sold me on the power of promises - https://www.youtube.com/watch?v=obaSQBBWZLk @Byzgig
David Halls
@DavidHalls
Jun 19 2016 06:56
@anacou you need to tag me buddy so i can see when you respond, but your getting there
Chris Cullen
@123xylem
Jun 19 2016 06:56
@CurlyWS ahh. u have no prior experience?>
David Halls
@DavidHalls
Jun 19 2016 06:57
@nickangtc idk man, i didnt use promises, and i cant see any callbacks in my code
christianws
@christianws
Jun 19 2016 06:57
@123xylem I'm not a developer if that's what you mean
@123xylem in regards to the challenge I just don't understand it's brief
David Halls
@DavidHalls
Jun 19 2016 06:58
@CurlyWS what challenge
anacou
@anacou
Jun 19 2016 06:58
@Byzgig I just don't get it...
christianws
@christianws
Jun 19 2016 06:58
Arguments Optional - Last on Intermediate Algos
Nick Ang
@nickangtc
Jun 19 2016 06:58
@Byzgig can you help me by taking a look at my code (just briefly)? Particularly see what happens in console. "Background image loaded" happens too early - it's supposed to happen at the end only. https://codepen.io/nickang/pen/xOwgvK?editors=1111
NixonRichard
@NixonRichard
Jun 19 2016 06:59
function truncateString(str, num) {
  // Clear out that junk in your trunk
  if (str.length > num)
    { str=str.slice(0,num-3);
      str += '...';}

  return str;
}

truncateString("A-", 1);
what s wrong with this code ?
David Halls
@DavidHalls
Jun 19 2016 06:59
@NixonRichard its wrong, it doesnt pass the last 2 tests
Chris Cullen
@123xylem
Jun 19 2016 07:00
@CurlyWS whiich one/
?
NixonRichard
@NixonRichard
Jun 19 2016 07:00
yes
christianws
@christianws
Jun 19 2016 07:00
@123xylem Arguments Optional of INtermediate Algos
NixonRichard
@NixonRichard
Jun 19 2016 07:00
what s the wrong thing
Chris Cullen
@123xylem
Jun 19 2016 07:01
@CurlyWS o yea toughie
christianws
@christianws
Jun 19 2016 07:01
"If only one argument is provided, then return a function that expects one argument and returns the sum."
Brendan Kinahan
@BKinahan
Jun 19 2016 07:01
@NixonRichard "However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string."
David Halls
@DavidHalls
Jun 19 2016 07:01
@anacou your on the right track
Chris Cullen
@123xylem
Jun 19 2016 07:01
I used a lot of if statements
Leo
@Leodhy
Jun 19 2016 07:01
@shusil123 str[i] is the string
so i think that's right
christianws
@christianws
Jun 19 2016 07:01
how can you return a sum of one number?
Chris Cullen
@123xylem
Jun 19 2016 07:02
Key is getting them in the right order.. So u wanna check how many args. If the args contain numbers. If only 1 make function that takes first arg and looks for a second number to add to it
christianws
@christianws
Jun 19 2016 07:02
@123xylem it says to return a function that expects just one arguments then return the sum. sum of what?
Chris Cullen
@123xylem
Jun 19 2016 07:02
sum of arg1 plus the other arg in the function
Brendan Kinahan
@BKinahan
Jun 19 2016 07:02
@CurlyWS if there is only one number argument, you don't return the sum of the number, you return a function that adds that number to whatever the following argument is (if it's also a number)
Chris Cullen
@123xylem
Jun 19 2016 07:03
arg(1)(2)... arg 1 here is what your mainly checking and the 2nd bracket would be what the function uses
2 is a totally different arg
christianws
@christianws
Jun 19 2016 07:04
@123xylem where can I look to learn about using double brackets like this?
function()();
I've never seen that before
anacou
@anacou
Jun 19 2016 07:04
help using objects for lookups
CamperBot
@camperbot
Jun 19 2016 07:04

:point_right: challenge using objects for lookups [wiki]

Challenge Using Objects for Lookups

Objects can be thought of as a key/value storage, like a dictionary. If you have tabular data, you can use an object to "lookup" values rather than a switch statement or an if/else chain. This is most useful when you know that your input data is limited to a certain range.

Here is an example of a simple reverse alphabet lookup:

var alpha = {
  1:"Z",
  2:"Y",
  3:"X",
  4:"W",
  ...
  24:"C",
  25:"B",
  26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"

:pencil: read more about challenge using objects for lookups on the FCC Wiki

Brendan Kinahan
@BKinahan
Jun 19 2016 07:05
@CurlyWS it's a little like if you have the expression arr[1][2] for arr = [[3,4],[5,6,7]]: First arr[1] returns [5,6,7] so arr[1][2] == [5,6,7][2], which evaluates to 7
anacou
@anacou
Jun 19 2016 07:05
@Byzgig I'm stuck! what do I do?
David Halls
@DavidHalls
Jun 19 2016 07:05
@NixonRichard i looked at your code, i dont get the issue
Chris Cullen
@123xylem
Jun 19 2016 07:05
@CurlyWS i didnt get it either... tbh still dont FULLY understand how it works but a function that looks for(arg) will use that if the first arg is taken...
David Halls
@DavidHalls
Jun 19 2016 07:06
@anacou post your code again
Brendan Kinahan
@BKinahan
Jun 19 2016 07:06
@CurlyWS so for function(1)(2), first function(1) is evaluated, and say it returns a function called addOne(), the next evaluation is addOne(2)
David Halls
@DavidHalls
Jun 19 2016 07:06
@nickangtc i looked at your code, what is the issue
Brendan Kinahan
@BKinahan
Jun 19 2016 07:06
@CurlyWS (the function you return won't have a name, but it's useful for this illustration)
Shusil Banjade
@shusil123
Jun 19 2016 07:06
@Leodhy , I know that , but that's wrong . You have to specify which positioned charcode you are using. like, str.charCodeAt(2), .
anacou
@anacou
Jun 19 2016 07:06

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

// Only change code above this line
@Byzgig

NixonRichard
@NixonRichard
Jun 19 2016 07:07
function truncateString(str, num) {
  // Clear out that junk in your trunk

   if (str.length <= 3)
    {str=str.slice(0,num);
    str += '...';}
 else if (str.length > num)
    { str=str.slice(0,num-3);
      str += '...';}

  return str;
}

truncateString("Absolutely Longer", 2);
christianws
@christianws
Jun 19 2016 07:07
@BKinahan if I even run code with double brackets it throws an error
NixonRichard
@NixonRichard
Jun 19 2016 07:07
it s wrong
truncateString("Absolutely Longer", 2) should return "Ab...".
christianws
@christianws
Jun 19 2016 07:07
what does it return? @NixonRichard
David Halls
@DavidHalls
Jun 19 2016 07:08
@anacou ok so you have var lookup, lets say we want to "search" or "call" this like a function, how?
NixonRichard
@NixonRichard
Jun 19 2016 07:08
Absolutely Longe...
Nick Ang
@nickangtc
Jun 19 2016 07:08
@Byzgig thanks for looking through it. The problem is that the bgWeather is supposed to load last. When you run the code it runs right after getLocation
CamperBot
@camperbot
Jun 19 2016 07:08