These are chat archives for FreeCodeCamp/HelpJavaScript

11th
Apr 2016
Nick Rameau
@R4meau
Apr 11 2016 00:00
@Jlipschitz LoL, you're right, I don't feel like this is efficient. Let me think of a better way. Maybe it's time I do this challenge.
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 00:01
@R4meau any and all insight is appreciated :)
Tien Anh Nguyen
@tienanh2007
Apr 11 2016 00:02
help Diff Two Arrays
CamperBot
@camperbot
Apr 11 2016 00:02

:point_right: algorithm diff two arrays [wiki]

Explanation:

Check two arrays and return a new array that contains only the items that are not in either of the original arrays.

:pencil: read more about algorithm diff two arrays on the FCC Wiki

Justin
@daemedeor
Apr 11 2016 00:03
@Jlipschitz don't worry about efficinecy if you can't solve it ;D preoptimization will get you frustrated faster
Nick Rameau
@R4meau
Apr 11 2016 00:03
@tienanh2007 Show us your code mate.
Justin
@daemedeor
Apr 11 2016 00:03
@R4meau might just want to wait, looking for the wiki page
Nick Rameau
@R4meau
Apr 11 2016 00:03
@daemedeor Wait for what?
Justin
@daemedeor
Apr 11 2016 00:04
i'm not sure he was asking for help yet, just for the wiki that cbot has
:D
Nick Rameau
@R4meau
Apr 11 2016 00:04
Ooo, lol, forgot about that @daemedeor
smzagury
@smzagury
Apr 11 2016 00:05
Hi all. I have a question for my weather app. Specifically, for the button to switch between C/F
Nick Rameau
@R4meau
Apr 11 2016 00:05
bonfire diff-two-arrays
CamperBot
@camperbot
Apr 11 2016 00:05

:fire:Bonfire: Diff Two Arrays :link:

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

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);

Compare two arrays and return a new array with any items not found in both of the original arrays.

more info:  bf details | bf links | hint

Nathanael Milien
@naelmilien
Apr 11 2016 00:05
function palindrome(str) {
  // Good luck!
  str = str.replace(/\W+/gi,'').toLowerCase();
  var newStr = str;
  if (str === newStr) {
    return true;
  } else {
    return false;
  }

}



palindrome("A man, a plan, a canal. Panama");
Can someone please help me figure out why this code doesn't want to return false?
Nick Rameau
@R4meau
Apr 11 2016 00:06
@tienanh2007 :point_up:
@smzagury Send us your CodePen mate.
Justin
@daemedeor
Apr 11 2016 00:07
@naelmilien why should it? you are not checking if its a palindrome?
Moisés Man
@moigithub
Apr 11 2016 00:07

@naelmilien
because u setting both variables to the same content

var newStr = str;  //<----
  if (str === newStr) {

u need to REVERSE one of them
hello --> olleh

Justin
@daemedeor
Apr 11 2016 00:07
^
Nick Rameau
@R4meau
Apr 11 2016 00:07
@naelmilien You should declase newStr before modifying str
Nathanael Milien
@naelmilien
Apr 11 2016 00:08
@R4meau let me try
HellzHero
@HellzHero
Apr 11 2016 00:09
help Nesting for Loops
CamperBot
@camperbot
Apr 11 2016 00:09

:point_right: challenge nesting for loops [wiki]

Challenge: Nesting For Loops

If you have a multi-dimensional array, you can use the same logic as the prior Challenge to loop through both the array and any sub-arrays. Here is an example:

    var arr = [
      [1,2], [3,4], [5,6]
    ];
    for (var i=0; i < arr.length; i++) {
      for (var j=0; j < arr[i].length; j++) {
        console.log(arr[i][j]);
      }
    }

This outputs each sub-element in arr one at a time. Note that for the inner loop, we are checking the .length of arr[i], since arr[i] is itself an array.
:pencil: read more about challenge nesting for loops on the FCC Wiki

Nick Rameau
@R4meau
Apr 11 2016 00:09
@naelmilien That's not all. You didn't reverse it yet.
Nathanael Milien
@naelmilien
Apr 11 2016 00:09
@moigithub for palindrome I need to reverse it, right?
Moisés Man
@moigithub
Apr 11 2016 00:09
yep @naelmilien
smzagury
@smzagury
Apr 11 2016 00:09
Haven't done the CSS yet. So right now it loads in metric by default, which I'm ok with. I'm not sure how to structure the switch - as an if-else, or as a switch.
Justin
@daemedeor
Apr 11 2016 00:11
@smzagury try using a radio buttons :D
Nick Rameau
@R4meau
Apr 11 2016 00:11
@smzagury First, bind click events on your buttons.
HellzHero
@HellzHero
Apr 11 2016 00:11
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
for (var i=0; i < arr.length; i++) {
  for (var j=0; j < product.length; j++) {
    console.log(arr[i][j]);
  }
}  
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Im stuck, can someone help me?
Justin
@daemedeor
Apr 11 2016 00:11
@smzagury i suggest using if-else though, since there are only 2 tests that'll happen
:)
Moisés Man
@moigithub
Apr 11 2016 00:11
 if( variable == this case ) {
    //do something
} else if (variable == this another case )
   // do something
}
 switch(variable){
    this case:
          //do something
         break;
     this another case:
           //do something
       break;
}
smzagury
@smzagury
Apr 11 2016 00:12
hmm. thanks @daemedeor and @R4meau , I'll try radio buttons and if/else.
CamperBot
@camperbot
Apr 11 2016 00:12
smzagury sends brownie points to @daemedeor and @r4meau :sparkles: :thumbsup: :sparkles:
:star: 287 | @r4meau | http://www.freecodecamp.com/r4meau
:star: 296 | @daemedeor | http://www.freecodecamp.com/daemedeor
Zabe Sangary
@zabesangary
Apr 11 2016 00:12
@HellzHero you don't need the console
Nick Rameau
@R4meau
Apr 11 2016 00:12
@HellzHero You have to multiply product variable to each arr[i][j], so your 6th line becomes product *= arr[i][j]
Zabe Sangary
@zabesangary
Apr 11 2016 00:13
so stuck for ever at Profile Lookup
Nick Rameau
@R4meau
Apr 11 2016 00:13
@zabefloyd Still? What's your current code?
Zabe Sangary
@zabesangary
Apr 11 2016 00:13
no this is new lesson
Moisés Man
@moigithub
Apr 11 2016 00:13
returning too soon ?
Zabe Sangary
@zabesangary
Apr 11 2016 00:14
//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

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
HellzHero
@HellzHero
Apr 11 2016 00:14
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
for (var i=0; i < arr.length; i++) {
  for (var j=0; j < product.length; j++) {
    console.log(arr[i][j]);
  }
}  
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Still something missing @R4meau :/
Moisés Man
@moigithub
Apr 11 2016 00:14
looks like something is missing.... @zabefloyd
Nathanael Milien
@naelmilien
Apr 11 2016 00:15
@moigithub okay, I got it to return false but now the last checkpoint is not working...I think it's because I removed all non-letter characters...which means redoing the replace method
Nick Rameau
@R4meau
Apr 11 2016 00:15
@HellzHero You didn't multiply the product to arr[i][j]
Zabe Sangary
@zabesangary
Apr 11 2016 00:15
everything is missing I know
Justin
@daemedeor
Apr 11 2016 00:15
@HellzHero still not actually doing anything with product
HellzHero
@HellzHero
Apr 11 2016 00:16
What do you mean, i wrote product *= arr[i][j], aint that it?
Moisés Man
@moigithub
Apr 11 2016 00:16
try to console.log(str) and check what is missing.. u could also use https://repl.it/ to test ur code @naelmilien
Nick Rameau
@R4meau
Apr 11 2016 00:16
@zabefloyd Then, do something then paste it here, nobody's gonna do it for you :P
@HellzHero Where did you write that?
Moisés Man
@moigithub
Apr 11 2016 00:17
@HellzHero i still seeing console.log on ur code...
HellzHero
@HellzHero
Apr 11 2016 00:17
i pasted the old one sorry
Zabe Sangary
@zabesangary
Apr 11 2016 00:17
haha exactly
HellzHero
@HellzHero
Apr 11 2016 00:17
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
for (var i=0; i < arr.length; i++) {
  for (var j=0; j < product.length; j++) {
  product = product * arr[i][j];
  }
}  
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
its actually product *= arr[i][j], i dont know why i changed it
Moisés Man
@moigithub
Apr 11 2016 00:18
@HellzHero for (var j=0; j < product.length; j++) { <-- not right
Zabe Sangary
@zabesangary
Apr 11 2016 00:18
product *= arr[i][j];
Moisés Man
@moigithub
Apr 11 2016 00:18
product is a number.. it dont hav length property
Zabe Sangary
@zabesangary
Apr 11 2016 00:18
@HellzHero
Nick Rameau
@R4meau
Apr 11 2016 00:18
@HellzHero It should be arr[i].length
HellzHero
@HellzHero
Apr 11 2016 00:19
Ya that was it!
Thank you guys :D
Nick Rameau
@R4meau
Apr 11 2016 00:20
Aaah, sometimes I feel like I give the answer way too easily
Nathanael Milien
@naelmilien
Apr 11 2016 00:20
@moigithub console.log(str) just logs out true
Moisés Man
@moigithub
Apr 11 2016 00:21
r u sure ?? paste ur code on https://repl.it
click the save button
n post the link
@naelmilien
Nathanael Milien
@naelmilien
Apr 11 2016 00:21
alright let's see @moigithub
Moisés Man
@moigithub
Apr 11 2016 00:22
console.log(str)
should be before returning.. probably above ur IF
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 00:22
still having trouble with profile lookup .... it keeps returning "no such property" and i'm not sure why T_T
//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) {
  //delcare variables to compare
  var nameFound = false;
  var indexFound = 0;
  //run for loop to see if firstName is in contacts obj
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName === firstName) {
      nameFound = true;
      indexFound = i;
    }
  }
  //return 
  if(nameFound === true) {
    return contacts[indexFound][prop] === prop ? contacts[indexFound][prop] : "No such property";
  } else {
    return "No such contact";
  }
}

lookUpProfile("Akira", "lastName");
Tien Anh Nguyen
@tienanh2007
Apr 11 2016 00:22
help Roman Numeral Converter
CamperBot
@camperbot
Apr 11 2016 00:22

:point_right: algorithm roman numeral converter [wiki]

Problem Explanation:

  • You will create a program that converts an integer to a Roman Numeral.
:pencil: read more about algorithm roman numeral converter on the FCC Wiki
Patrick Black
@Mortiferr
Apr 11 2016 00:23
hi
I need help on the tweeting the quote part
I can't get it to work
Nathanael Milien
@naelmilien
Apr 11 2016 00:23
it says true there too @moigithub
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 00:24
okay nvm got it. had to change contacts[indexFound][prop] === 0 to just contacts[indexFound][prop].. still a little unsure lol
Moisés Man
@moigithub
Apr 11 2016 00:24
@Jlipschitz
contacts[indexFound][prop] === prop <--this is wrong
prop will return something like.. "firstName"
contacts[indexFound][prop] will return "John"
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 00:25
okay that definitely makes a lot of sense @moigithub
Moisés Man
@moigithub
Apr 11 2016 00:25
@Jlipschitz probably u wanna use .hasOwnProperty
@naelmilien share ur code :)
Duncan T
@dtweedle
Apr 11 2016 00:27
@Mortiferr Good to see you amde some progress with you quote machine.. It's actually pretty simple you can just add the quote text to a url to create tweets.
Nick Rameau
@R4meau
Apr 11 2016 00:27
@Mortiferr What exactly is your problem?
Nathanael Milien
@naelmilien
Apr 11 2016 00:28
function palindrome(str) {
  // Good luck!
  var newStr = str.split('').reverse().join('').replace(/\W/gi,'').toLowerCase();
  str = str.replace(/\W/gi,'').toLowerCase();
  if (str === newStr) {
    return true;
  } else {
    return false;
  }

}



palindrome("A man, a plan, a canal. Panama");
That's it right here @moigithub
Erth0
@Erth0
Apr 11 2016 00:28
new problem here :)
Patrick Black
@Mortiferr
Apr 11 2016 00:28
@Isymm and @R4meau I actually just figured it out, thank you though!!!
CamperBot
@camperbot
Apr 11 2016 00:28
mortiferr sends brownie points to @isymm and @r4meau :sparkles: :thumbsup: :sparkles:
:star: 290 | @r4meau | http://www.freecodecamp.com/r4meau
:star: 299 | @isymm | http://www.freecodecamp.com/isymm
Erth0
@Erth0
Apr 11 2016 00:28
function golfScore(par, strokes) {
  // Only change code below this line
  if(strokes == 1){
    return "Hole-in-one";
  } else if(strokes <= (par-2)){
    return "Eagle";
  } else if(strokes ==(par-1)){
    return "Birdie";
  } else if (strokes == par){
    return "Par";
  } else if (strokes ==(par+1)){
    return "Bogey";
  } else if(strokes ==(par+2 )){
    return "Double Bogey";
  } else if(strokes >=(par+3)){
    return "Go Home";
  } 
  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 00:28
How would I use that? Inside of the for loop? @moigithub
Moisés Man
@moigithub
Apr 11 2016 00:29
@naelmilien and which test is failing ??
Nick Rameau
@R4meau
Apr 11 2016 00:29
@Erth0 Which challenge is that? And what exactly is your problem?
Erth0
@Erth0
Apr 11 2016 00:30
its Golf Code and its not passing the test :/
i mean not all but the most of them
this is what need to do

1 "Hole-in-one!"
<= par - 2 "Eagle"
par - 1 "Birdie"
par "Par"
par + 1 "Bogey"
par + 2 "Double Bogey"

= par + 3 "Go Home!"

Moisés Man
@moigithub
Apr 11 2016 00:30
@Jlipschitz .hasOwnProperty is a Object method https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Objetos_globales/Object/hasOwnProperty
u apply to the object u testing.. and pass the property name u wanna check
if it exist.. it will return true or false if dont
syntax: myObject.hasOwnProperty(myProp)
Nathanael Milien
@naelmilien
Apr 11 2016 00:30
that very last portion @moigithub ...it's the one that says palindrome("0_0 (: /-\ :) 0-0") should return true.
there shouldn't be a smiley face in there @moigithub lol
Moisés Man
@moigithub
Apr 11 2016 00:31
@naelmilien https://repl.it/CELs/2 <-- this with console.log added
edit: smile removed :)
soo.. u need to check.. the console.. and see.. what still need to be removed
and change ur code accordingly
@naelmilien
Nathanael Milien
@naelmilien
Apr 11 2016 00:34
@moigithub it looks like I've removed too much
Moisés Man
@moigithub
Apr 11 2016 00:35
everything removed.. is ok..
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 00:35
but the property names are always going to exist in that exercise. not sure how that helps me check the values.. sorry new to this stuff. could you help me see where exactly i would implement it?
@moigithub
Moisés Man
@moigithub
Apr 11 2016 00:35
since those character are NOT ALPHAnumeric @naelmilien
u should only keep A-Z and numbers 0-9
Nick Rameau
@R4meau
Apr 11 2016 00:35
@Erth0 Well, some of your if statements are overriding the previous ones.
@Erth0 Try adding the first if at the end.
Undra Tsend
@Undra2000
Apr 11 2016 00:36
(☞゚∀゚)☞ Keep working hard!
Nick Rameau
@R4meau
Apr 11 2016 00:36
@Erth0 Aah, never mind.
@Erth0 They are returned, so this is not a problem.
Nathanael Milien
@naelmilien
Apr 11 2016 00:37
that's what i remember from reading mdn all day but when i put it in the link you provided i see characters missing :worried:
@moigithub
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 00:37
@moigithub okay, okay I completely get it now and see where. i thought for some reason some properties were delcared undefned in the exercise but they're not there completely. sorry about that and thank you
CamperBot
@camperbot
Apr 11 2016 00:37
jlipschitz sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 867 | @moigithub | http://www.freecodecamp.com/moigithub
Nick Rameau
@R4meau
Apr 11 2016 00:38
@Erth0 It's just that you're forgetting punctuations mate.
Greg Duncan
@GregatGit
Apr 11 2016 00:38
@Erth0 Its "Hole-in-one!" not "Hole-in-one" you have to have the "!"
Moisés Man
@moigithub
Apr 11 2016 00:38

@Jlipschitz

if(nameFound === true) {
    return contacts[indexFound][prop] === prop ? contacts[indexFound][prop] : "No such property";
  }
if(nameFound === true) {
    return contacts[indexFound].hasOwnProperty(prop) ? contacts[indexFound][prop] : "No such property";
  }

or..

if(nameFound === true) {
    return contacts[indexFound][prop] ? contacts[indexFound][prop] : "No such property";
  }
a={n:1}
Object {n: 1}
a["a"]
undefined
a["n"]
1

this last code will work.. cuz if u access to a non existant property it will return undefined and coerce to a boolean (false)

Nick Rameau
@R4meau
Apr 11 2016 00:40
@Erth0 "Hole-in-one" becomes "Hole-in-one!" and "Go Home" becomes "Go Home!"
Moisés Man
@moigithub
Apr 11 2016 00:40
@naelmilien the only alphanumeric characters on this 0_0 (: /-\ :) 0-0 are the numbers
all rest need to be removed
Erth0
@Erth0
Apr 11 2016 00:41
@R4meau @GregatGit omg only cuz i mis the !
Nick Rameau
@R4meau
Apr 11 2016 00:41
@Erth0 LoL, yup.
Pawan
@pawan92
Apr 11 2016 00:42
hey guys can someone tell me why this prints yes multiple times?
function diffArray(arr1, arr2) {

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

      if (arr1[i]!== arr2[k]) {
          console.log('yes');

      }
    }
  }

}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Greg Duncan
@GregatGit
Apr 11 2016 00:42
@Erth0 when doing else if statements - the very last one should be just "else" with conditions and its "Go Home!" not "Go home"
Erth0
@Erth0
Apr 11 2016 00:42
@R4meau @GregatGit So thank you guys
CamperBot
@camperbot
Apr 11 2016 00:42
:star: 292 | @r4meau | http://www.freecodecamp.com/r4meau
:star: 398 | @gregatgit | http://www.freecodecamp.com/gregatgit
erth0 sends brownie points to @r4meau and @gregatgit :sparkles: :thumbsup: :sparkles:
Pawan
@pawan92
Apr 11 2016 00:42
im doing the diff array challenge
Nick Rameau
@R4meau
Apr 11 2016 00:42
@pawan92 It's in a loop mate.
Ah, don't mind that :point_up: didn't see your if.
Moisés Man
@moigithub
Apr 11 2016 00:43
computer is dumb @Erth0
u need to give exact instructions or it will not understand :P
a byte/bit makes difference
Greg Duncan
@GregatGit
Apr 11 2016 00:43
@Erth0 But make sure your final statement say only "else" not "else if" it may still work but it is bad coding
Erth0
@Erth0
Apr 11 2016 00:44
hahah yeah i like very much to coding and for me html and css is fun and i know alot but when times comes to js hmm
Nick Rameau
@R4meau
Apr 11 2016 00:44
@pawan92 It's actually being repeated 16 times :P
Pawan
@pawan92
Apr 11 2016 00:44
@R4meau shouldnt it only print it once?
Nick Rameau
@R4meau
Apr 11 2016 00:44
@pawan92 Maybe try using filters instead?
@pawan92 Do you know the filter array method?
Pawan
@pawan92
Apr 11 2016 00:46
yes but wasnt sure if i could use that
Nathanael Milien
@naelmilien
Apr 11 2016 00:47
@moigithub i can't seem to figure out how to remove the underscore...is there a RegExp I'm missing?
Nick Rameau
@R4meau
Apr 11 2016 00:47
@pawan92 Try it and let me know what you come up with.
Moisés Man
@moigithub
Apr 11 2016 00:48
@naelmilien yep.. ur regex need to add _
u can test here https://regex101.com/
Manraaj Nijjar
@ManraajNijjar
Apr 11 2016 00:49
Does a url need to end in .json to be read by the getJson method?
smzagury
@smzagury
Apr 11 2016 00:49
@R4meau @daemedeor I've updated my pen to include radio buttons. http://codepen.io/smzagury/pen/vGGzyV?editors=0010
Justin
@daemedeor
Apr 11 2016 00:50
@smzagury listen for a change via jquery and pull the value of the element out ;D
and hten do the appropriate action
:D
Nick Rameau
@R4meau
Apr 11 2016 00:50
@smzagury Bind a change event to each of them.
smzagury
@smzagury
Apr 11 2016 00:51
@daemedeor how do I do the action "resubmit json url with new unit" or "change json url to include new unit and reload page"
Nathanael Milien
@naelmilien
Apr 11 2016 00:51
really? on the mdn website i saw underscore was included in the list of characters that should be removed with the .replacemethod I used @moigithub
smzagury
@smzagury
Apr 11 2016 00:51
*hope that made sense
Nick Rameau
@R4meau
Apr 11 2016 00:52
@smzagury Not at all XD
Justin
@daemedeor
Apr 11 2016 00:52
@R4meau only need one of them
don't know why and reload page
Nick Rameau
@R4meau
Apr 11 2016 00:52
@daemedeor Right.
Justin
@daemedeor
Apr 11 2016 00:53
i try not get involved in regex questions but... @naelmilien try use regexr.com
you can see how patterns are matched
Nick Rameau
@R4meau
Apr 11 2016 00:54
@naelmilien What's your current code?
Tien Anh Nguyen
@tienanh2007
Apr 11 2016 00:54
help Where art thou
CamperBot
@camperbot
Apr 11 2016 00:54

:point_right: algorithm where art thou [wiki]

Problem Explanation

Write an algorithm that will take an array for the first argument and return an array with all the objects that matches all the properties and values in the Object passed as second parameter.

:pencil: read more about algorithm where art thou on the FCC Wiki

Nathanael Milien
@naelmilien
Apr 11 2016 00:56
function palindrome(str) {
  // Good luck!
  var newStr = str.split('').reverse().join('').replace(/\W/gi,'').replace(/[_],''/).toLowerCase();
  str = str.replace(/\W/gi,'').replace(/[_],''/).toLowerCase();
  if (str === newStr) {
    return true;
  } else {
    return false;
  }

}



palindrome("0_0 (: /-\ :) 0-0");
That's what it looks like now @R4meau
Nick Rameau
@R4meau
Apr 11 2016 00:57
@naelmilien You're doing way too much
@naelmilien Do the replace and the toLowerCase only on str then copy str to newStr
Justin
@daemedeor
Apr 11 2016 00:58
@R4meau in some ways.... definitely not the eaiest way XD
Nick Rameau
@R4meau
Apr 11 2016 00:58
@naelmilien Then reverse newStr
@naelmilien And then compare them, that's it.
Nathanael Milien
@naelmilien
Apr 11 2016 00:58
I've been at it all day and have not been able to figure it out @R4meau
Justin
@daemedeor
Apr 11 2016 00:59
@naelmilien imo you should take a break :D
Nathanael Milien
@naelmilien
Apr 11 2016 00:59
lol trust me i will after this one @daemedeor
Nick Rameau
@R4meau
Apr 11 2016 00:59
@naelmilien Just follow the above steps.
Amir Ghafouri
@amirghafouri
Apr 11 2016 01:00
function checkCashRegister(price, cash, cid) {
  var change;
  var cidSum = 0;

  // sum of cash-in-drawer

  cid.forEach(function(value) {
    cidSum += value[1];
  });

  return cidSum;
}

checkCashRegister(19.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 returns 335.409999999997 instead of 335.41

Just out of curiosity, why?

Nathanael Milien
@naelmilien
Apr 11 2016 01:00
alright @R4meau let me see if i can do it with the steps you provided
Justin
@daemedeor
Apr 11 2016 01:00
@amirghafouri how floating path math works
you can get insanely close but it'll not be "perfect"
to counter that you can use .toFixed(2)
Amir Ghafouri
@amirghafouri
Apr 11 2016 01:03
@daemedeor Cool, I'll have to read up about it. Thanks
CamperBot
@camperbot
Apr 11 2016 01:03
amirghafouri sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 302 | @daemedeor | http://www.freecodecamp.com/daemedeor
Manraaj Nijjar
@ManraajNijjar
Apr 11 2016 01:03
Hey does anyone know why I can pull json data
from http://www.json-generator.com/api/json/get/cfniShTtua?indent=2
but not from http://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en
I've definitely used the latter link to do basically the same thing in Swift but it doesn't work with $.getJson()
Justin
@daemedeor
Apr 11 2016 01:05
@ManraajNijjar i tried the link and its fine
something must be wrong on your end
what's the error in the console?
Manraaj Nijjar
@ManraajNijjar
Apr 11 2016 01:08

@daemedeor I'm not getting anything in the console, not even when I console.log the json data. I'm not getting anything back

$.getJSON("http://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en", function(json) {
     console.log(json);
 $(".title").html(JSON.stringify(json));
    });

Is what I'm using. Changing the url to the other one gets me Json data while the current one doesnt

Justin
@daemedeor
Apr 11 2016 01:10
@ManraajNijjar i mean any errors does the console present?
but hmmm
oh
@ManraajNijjar try $.get(url, function(){}); instead
Lucas Barbula
@lbarbula
Apr 11 2016 01:10

So I'm having an issue with a lookup table, here is my code, thanks for you help!// Setup
function phoneticLookup(val) {
var result = "";

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

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

Nathanael Milien
@naelmilien
Apr 11 2016 01:11
i'm still having the same problem @R4meau :(
Manraaj Nijjar
@ManraajNijjar
Apr 11 2016 01:11
@daemedeor I just noticed that the browser was getting errors that weren't showing up on the codepen console, so I'll look into what you just said and that
Justin
@daemedeor
Apr 11 2016 01:12
@ManraajNijjar yea... codepen doesn't show all the errors so its important to always check the console... usually there's a good strart on whats wrong
Nick Rameau
@R4meau
Apr 11 2016 01:12
@naelmilien You had one simple mistake in your code.
@naelmilien Show me your current one.
@naelmilien You're almost there mate.
Nathanael Milien
@naelmilien
Apr 11 2016 01:14
function palindrome(str) {
  // Good luck!
  var newStr = str.replace(/\W/gi,'').replace(/[_],''/).toLowerCase();
  str = str.replace(/\W/gi,'').replace(/[_],''/).toLowerCase();
  if (str === newStr.split('').reverse().join('')) {
    return true;
  } else {
    return false;
  }

}



palindrome("0_0 (: /-\ :) 0-0");
This is what it looks like. It's probably still too much since I'm still a newbie @R4meau
Nick Rameau
@R4meau
Apr 11 2016 01:14
@naelmilien Your error is at line 3 and 4.
@naelmilien In the second replace. Read it carefully.
@naelmilien BTW, I suggested you do the replace and toLowerCase only on str then copy str to newStr, but you didn't do it.
ghnana
@ghnana
Apr 11 2016 01:16
a = a += 12;
b = 9 + b;
c = c += 7;
what am i ding wrong
b not wrking
Nick Rameau
@R4meau
Apr 11 2016 01:17
a = a += 12; should be a += 12 or a = a + 12 @ghnana
@ghnana Same for the rest.
ghnana
@ghnana
Apr 11 2016 01:17
giving it a shot
Nathanael Milien
@naelmilien
Apr 11 2016 01:18
function palindrome(str) {
  // Good luck!
  var newStr = str;
  str = str.replace(/\W/gi,'').replace(/[_],''/).toLowerCase();
  if (str === newStr.split('').reverse().join('')) {
    return true;
  } else {
    return false;
  }

}



palindrome("0_0 (: /-\ :) 0-0");
Like this? @R4meau
Nick Rameau
@R4meau
Apr 11 2016 01:18
@naelmilien Still can't spot the little mistake?
@naelmilien More like this:
function palindrome(str) {
  // Good luck!
  str = str.replace(/\W/gi,'').replace(/[_],''/).toLowerCase();
  var newStr = str;
  if (str === newStr.split('').reverse().join('')) {
    return true;
  } else {
    return false;
  }

}



palindrome("0_0 (: /-\ :) 0-0");
@naelmilien Now the mistake is on line 3. Try to spot it. It's in the second replace
Nathanael Milien
@naelmilien
Apr 11 2016 01:19
I'm trying to review the part on MDN that talks about RegExp to see if I can see it
Nick Rameau
@R4meau
Apr 11 2016 01:19
Good.
ghnana
@ghnana
Apr 11 2016 01:19
@R4meau Thank you
CamperBot
@camperbot
Apr 11 2016 01:19
ghnana sends brownie points to @r4meau :sparkles: :thumbsup: :sparkles:
:star: 293 | @r4meau | http://www.freecodecamp.com/r4meau
Nick Rameau
@R4meau
Apr 11 2016 01:20
@ghnana YW.
@naelmilien You don't really need MDN for that tho. Just try to compare it to the first replace and you will spot the difference.
Trying to save you some time.
Nathanael Milien
@naelmilien
Apr 11 2016 01:23
A billion thanks @R4meau ...you helped me tremendously on this one
CamperBot
@camperbot
Apr 11 2016 01:23
naelmilien sends brownie points to @r4meau :sparkles: :thumbsup: :sparkles:
:star: 294 | @r4meau | http://www.freecodecamp.com/r4meau
Nick Rameau
@R4meau
Apr 11 2016 01:23
@naelmilien Haha, you're welcome mate.
SvenBroman
@SvenBroman
Apr 11 2016 01:24
Thanks @kirah1314 @Rafase282 @jsommamtek @oshliaer for your help with Algorithm: Chunky Monkey
CamperBot
@camperbot
Apr 11 2016 01:24
svenbroman sends brownie points to @kirah1314 and @rafase282 and @jsommamtek and @oshliaer :sparkles: :thumbsup: :sparkles:
:star: 286 | @jsommamtek | http://www.freecodecamp.com/jsommamtek
:star: 963 | @kirah1314 | http://www.freecodecamp.com/kirah1314
:star: 311 | @oshliaer | http://www.freecodecamp.com/oshliaer
:star: 1141 | @rafase282 | http://www.freecodecamp.com/rafase282
Nathanael Milien
@naelmilien
Apr 11 2016 01:26
I've been staring at this problem and reading for hours @R4meau ... Thanks again :) .... I'm gonna rest my eyes now ...enjoy the rest of your day
CamperBot
@camperbot
Apr 11 2016 01:26
naelmilien sends brownie points to @r4meau :sparkles: :thumbsup: :sparkles:
:warning: naelmilien already gave r4meau points
Nick Rameau
@R4meau
Apr 11 2016 01:27
@naelmilien I feel you mate.
Rich
@richardxu100
Apr 11 2016 01:27
Could someone explain to me why the destroyer function returns 1? I'd think it should return arr[0], which is [1,2,3,5,1,2,3].
function destroyer(arr) {
  // Remove all the values
    var changedArr = arr[0];
    return changedArr;
}
destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3);
Nick Rameau
@R4meau
Apr 11 2016 01:27
@naelmilien Thanks, enjoy your rest. You deserve it.
CamperBot
@camperbot
Apr 11 2016 01:27
r4meau sends brownie points to @naelmilien :sparkles: :thumbsup: :sparkles:
:star: 254 | @naelmilien | http://www.freecodecamp.com/naelmilien
Nick Rameau
@R4meau
Apr 11 2016 01:28
@richardxu100 arr[0] is the first element of arr.
@richardxu100 Which is 1
Rich
@richardxu100
Apr 11 2016 01:28
oh, so it's going to arr[0][0]?
Nick Rameau
@R4meau
Apr 11 2016 01:29
@richardxu100 If you want it to return the whole array, you have to do var changedArr = arr or simply return arr itself.
Rich
@richardxu100
Apr 11 2016 01:29
ok, but how would i get rid of the other paramters, "2, 3"?
Nick Rameau
@R4meau
Apr 11 2016 01:30
@richardxu100 You mean, how do you access them? Because you need them to compare them into the array.
Rich
@richardxu100
Apr 11 2016 01:31
Your code worked, and thank you for your help.! I thought that the whole parameter was a 2d array.
Nick Rameau
@R4meau
Apr 11 2016 01:32
@richardxu100 :thumbsup:
Matt Ashman
@mja77
Apr 11 2016 01:39
challenge 181, has me all sorts of confused. "Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed."

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

return item; // Change this line
}

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

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

am I using .push() & .shift() to move and manipulate elements? or is that off track?
Nick Rameau
@R4meau
Apr 11 2016 01:42
@mja77 Yup, just these two methods.
@mja77 And format your code with backticks next time
help format
CamperBot
@camperbot
Apr 11 2016 01:42

: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 the code.

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

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

Matt Ashman
@mja77
Apr 11 2016 01:43
hmm ok let me play around, and ill yell for help if I can't make any progress, thank you. Thank's a lot, I will read to see how to properly ask for help in the chat!
Nick Rameau
@R4meau
Apr 11 2016 01:43
@mja77 YW.
Matt Ashman
@mja77
Apr 11 2016 01:52
Would love a hint.
The other code is throwing me off, not sure what is happening tbh with this challenge.
Nick Rameau
@R4meau
Apr 11 2016 01:52
@mja77 First, add the item to the array with push.
@mja77 Then remove the first element from the array with shift
@mja77 Last, return the element that you removed. (Make sure you saved it before you remove it).
@mja77 Since shift automatically returns the element that it removes, you can remove and return at the same time ;)
Benjamin Gonzalez
@xasuma
Apr 11 2016 01:56
hey guys, for the weather app, which weather api did you use?
Nick Rameau
@R4meau
Apr 11 2016 01:57
@xasuma People here use the OpenweatherMap api often.
Benjamin Gonzalez
@xasuma
Apr 11 2016 01:57
alright, thats the one I was looking at. :)
Matt Ashman
@mja77
Apr 11 2016 01:58
js
function nextInLine(arr, item) {
 testArr = push([10]);
  tesetArr = shift([0]);
  return nextInLine;  // 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))
is my syntax that off?
Nick Rameau
@R4meau
Apr 11 2016 01:59
@mja77 push and shift are array methods, not simple functions.
@mja77 Therefor you have to use them like so arr.push("hallo") and arr.shift()
Matt Ashman
@mja77
Apr 11 2016 02:00
hmm ok. thank you. anything else I need to correct?
Nick Rameau
@R4meau
Apr 11 2016 02:00
@mja77 Yes, you don't need another variable to push to an array.
@mja77 And why are you returning the function itself? You should be returning the element that was removed.
Matt Ashman
@mja77
Apr 11 2016 02:02

so:

js
 arr.push([10]);
  arr.shift([0]);
  return arr, item;

?

Nope.
Nick Rameau
@R4meau
Apr 11 2016 02:03
arr.push(item)
shift doesn't take any argument.
So arr.shift()
Maybe you should read documentations on these methods before you go on. @mja77
Don't take it bad though, but documenting yourself on a function before trying to use it will save you a lot of time ;) @mja77
Matt Ashman
@mja77
Apr 11 2016 02:06
No, you're right. I'm new - I have to start somewhere. I struggle with putting it all together right now, but, it will come. Thanks for your support thus far. @R4meau
CamperBot
@camperbot
Apr 11 2016 02:06
mja77 sends brownie points to @r4meau :sparkles: :thumbsup: :sparkles:
:star: 296 | @r4meau | http://www.freecodecamp.com/r4meau
Nick Rameau
@R4meau
Apr 11 2016 02:06
@mja77 You're welcome mate. I'm here to help.
Lucas Barbula
@lbarbula
Apr 11 2016 02:06

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

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

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

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

still not working!!!!
Nick Rameau
@R4meau
Apr 11 2016 02:07
@lbarbula Please, format your code
help format
CamperBot
@camperbot
Apr 11 2016 02:08

: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 the code.

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

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

Greg Duncan
@GregatGit
Apr 11 2016 02:08
@lbarbula is it meant to be a switch?
Nick Rameau
@R4meau
Apr 11 2016 02:09
// Setup
function phoneticLookup(val) {
  var result = "";

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

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

// Change this value to test
phoneticLookup("foxtrot");
Greg Duncan
@GregatGit
Apr 11 2016 02:09
@lbarbula You haven't implemented a switch correctly
this page will help you out http://www.w3schools.com/js/js_switch.asp
Nick Rameau
@R4meau
Apr 11 2016 02:12
@lbarbula
switch(variable) {
    case "alpha":
        // do something here
    break;
    case "bravo":
        // do something here
    break;
    // And so on...
    default:
        // do something if not recognized
    break;
}
Lucas Barbula
@lbarbula
Apr 11 2016 02:12
It cannot be a switch, has to be a lookup table @GregatGit
@R4meau
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 02:13
@lbarbula you can use a switch
Lucas Barbula
@lbarbula
Apr 11 2016 02:13
no, you can't as per the directions of the exercise
@Jlipschitz
Greg Duncan
@GregatGit
Apr 11 2016 02:14
@lbarbula which exercize is it?
Lucas Barbula
@lbarbula
Apr 11 2016 02:14
@GregatGit using objects for lookups javascript 90 I believe
@R4meau sorry about the previously unformatted code
Nick Rameau
@R4meau
Apr 11 2016 02:15
@lbarbula It is in fact a switch
Aah, but you have to change it.
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 02:16
I see @lbarbula .
Lucas Barbula
@lbarbula
Apr 11 2016 02:16
@R4meau the last direction on the exercise is that one cannot use switch, case, or if statements
Nick Rameau
@R4meau
Apr 11 2016 02:16
I see..
Lucas Barbula
@lbarbula
Apr 11 2016 02:16
I wish it was a switch haha
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 02:16
You should refrain from declaring result = "something" inside your object properties
Greg Duncan
@GregatGit
Apr 11 2016 02:17
what is the exerise called?
Lucas Barbula
@lbarbula
Apr 11 2016 02:17
I was trying not to, however, I could not seem to get it to work in other ways that i have tried, and currently one call is working and the others aren't which is weird.
@Jlipschitz
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 02:17
so it should look like "alpha": "adams" instead of "alpha": result = "adams" Also, you need to change the return result to reflect the value that's being put in
Lucas Barbula
@lbarbula
Apr 11 2016 02:18
the exercise is called using objects for lookups @GregatGit
Nick Rameau
@R4meau
Apr 11 2016 02:18
@lbarbula Here's an example of an object
var person = {
    firstName:"John", 
    lastName:"Doe",
    age:50, 
    eyeColor:"blue"
};
Lucas Barbula
@lbarbula
Apr 11 2016 02:18
thanks
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 02:18
help format
CamperBot
@camperbot
Apr 11 2016 02:18

: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 the code.

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

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

Lucas Barbula
@lbarbula
Apr 11 2016 02:19
I think that's my problem in understanding, how do i get the return result to reflect the val? @Jlipschitz
Nick Rameau
@R4meau
Apr 11 2016 02:20
@lbarbula After creating the object like result = {"charlie": "Chicago"}, simply return result[val]
Greg Duncan
@GregatGit
Apr 11 2016 02:20
This message was deleted
Lucas Barbula
@lbarbula
Apr 11 2016 02:21
so i'm actually not supposed to change the return line @R4meau
Nick Rameau
@R4meau
Apr 11 2016 02:21
@lbarbula You actually have to.
Lucas Barbula
@lbarbula
Apr 11 2016 02:21
okay, well then these directions are maddeningly unclear @R4meau
thank you @R4meau
CamperBot
@camperbot
Apr 11 2016 02:22
lbarbula sends brownie points to @r4meau :sparkles: :thumbsup: :sparkles:
:star: 297 | @r4meau | http://www.freecodecamp.com/r4meau
Nick Rameau
@R4meau
Apr 11 2016 02:23
@lbarbula LoL, they're making you do extra work.
Drew Stonebraker
@drstonebraker
Apr 11 2016 02:23
I cannot seem to get my jquery function to work at all. Can someone help?
http://codepen.io/dsto/pen/YqepwO
Lucas Barbula
@lbarbula
Apr 11 2016 02:24

// 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",

};

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

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

sorry
still not working
still not formatted
sorry
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 02:24
you need to change the name of your object @lbarbula
Lucas Barbula
@lbarbula
Apr 11 2016 02:25
that is the name that i have to use @Jlipschitz
again, according to the excercise
Nicolas May
@hynso
Apr 11 2016 02:25
help format
CamperBot
@camperbot
Apr 11 2016 02:25

: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 the code.

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

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

Nicolas May
@hynso
Apr 11 2016 02:25
There ya go, @lbarbula
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 02:25
var result = {"alpha": "hello"} names are arbitrary when declaring them, you can name them anything at the start. it only matters from after the point of declaration and you refer back to them
Nick Rameau
@R4meau
Apr 11 2016 02:25
@Stoney229 You didn't declare the function picMove
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 02:25
@lbarbula
also you should remove the result = "" at the top since it's not being used
Nick Rameau
@R4meau
Apr 11 2016 02:26
@Stoney229 Your JS should be
function picMove() {
    $('img').animate({
    'margin-left': '200px'
  }, 300);
 }
Lucas Barbula
@lbarbula
Apr 11 2016 02:28
@Jlipschitz so the result aspect of the code is another thing that cannot be changed as per the directions. And i guess what i'm having a hard time comprehending is getting the val call to relate to my object. maybe the directions are just a little bit fuzzy or something, but i feel like an exercise such as this doesn't have to be this hard and i'm flailing.
Drew Stonebraker
@drstonebraker
Apr 11 2016 02:28
@R4meau well, I was trying to use the document ready function. Do you know why that didn't work? also, using function picMove(), why wouldn't it animate every time there is a mouseenter?
Nick Rameau
@R4meau
Apr 11 2016 02:29
@Stoney229 You do this with
$(document).ready(function() {
    // code here
});
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 02:30
you can then do return lookup[val] instead
Nick Rameau
@R4meau
Apr 11 2016 02:30
@Stoney229 You're not adding to the margin-left you're setting it to a value.
@Stoney229 Therefor to make it move on every mouseenter, your code should be
function picMove() {
    $('img').animate({
    'margin-left': '+=200px'
  }, 300);
 }
@Stoney229 This adds 200px on every mouseenter instead of setting it to 200px from the left.
Lucas Barbula
@lbarbula
Apr 11 2016 02:32
@Jlipschitz that worked, but i'm a little perplexed as to why the directions stipulate that a) i can't change the return line, which i have to do to solve the problem, and b) why i have to name my table lookup instead of result? thanks for the help, bogged down in the directions. much appreciated
CamperBot
@camperbot
Apr 11 2016 02:32
lbarbula sends brownie points to @jlipschitz :sparkles: :thumbsup: :sparkles:
:star: 73 | @jlipschitz | http://www.freecodecamp.com/jlipschitz
Nick Rameau
@R4meau
Apr 11 2016 02:33
@lbarbula You don't need to modify these lines, as I told you previously, they are making you do extra work.
Drew Stonebraker
@drstonebraker
Apr 11 2016 02:33
@R4meau thank you!
CamperBot
@camperbot
Apr 11 2016 02:33
stoney229 sends brownie points to @r4meau :sparkles: :thumbsup: :sparkles:
:star: 298 | @r4meau | http://www.freecodecamp.com/r4meau
Nick Rameau
@R4meau
Apr 11 2016 02:33
@Stoney229 You're welcome.
Lucas Barbula
@lbarbula
Apr 11 2016 02:33
@R4meau Okay, so it works with those lines modified, what is that alternate solution?
*the
Nick Rameau
@R4meau
Apr 11 2016 02:34
@lbarbula Show me your code so I can go faster.
@lbarbula Alternate way:
// 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"
  };

  result = lookup[val];

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

// Change this value to test
phoneticLookup("charlie");
Lucas Barbula
@lbarbula
Apr 11 2016 02:37
boom, thank you @R4meau
CamperBot
@camperbot
Apr 11 2016 02:37
lbarbula sends brownie points to @r4meau :sparkles: :thumbsup: :sparkles:
:warning: lbarbula already gave r4meau points
Allison Bates
@allisonkbates
Apr 11 2016 02:37
This message was deleted
Nick Rameau
@R4meau
Apr 11 2016 02:37
@lbarbula You're welcome.
Allison Bates
@allisonkbates
Apr 11 2016 02:39
Working on Mutations, but having trouble understanding 'indexOf'. For example, how does the following evaluate to 0?
function mutation(arr) {
  var oneValue = arr[0].toLowerCase();
  var twoValue = arr[1].toLowerCase();
  return oneValue.indexOf(twoValue[0]);
  }
mutation(["hello", "hey"]);

var code = "formatted"
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 02:40
@R4meau is clearly a lot more qualified at helping than me lol @lbarbula
Nick Rameau
@R4meau
Apr 11 2016 02:40
@allisonkbates indexOf returns the index of the element inside the array.
random-x
@random-x
Apr 11 2016 02:40
@allisonkbates string indexes work the same as array indexes - they start at 0
Lucas Barbula
@lbarbula
Apr 11 2016 02:40
@Jlipschitz you helped me just fine haha
random-x
@random-x
Apr 11 2016 02:40
@allisonkbates errr.. ignore my comment. just: array indexes start at 0. haha
Nick Rameau
@R4meau
Apr 11 2016 02:41
@allisonkbates twoValue[0] refers to the first letter of the second parameter ("hey"), which is "h".
@allisonkbates "h" is at position 0 in oneValue, therefor, indexOf returns 0.
@Jlipschitz You did great mate :thumbsup:
Allison Bates
@allisonkbates
Apr 11 2016 02:43
so then it's just a coincidence that this code happens to solve all use cases but one?
function mutation(arr) {
  var oneValue = arr[0].toLowerCase();
  var twoValue = arr[1].toLowerCase();



if (oneValue.indexOf(twoValue[0]) >= 0) {
   return true;
   } else {
     return false;
   }

}
mutation(["hello", "hey"]);
@R4meau the if case would only be searching the first value in the 2nd element of the array?
Nick Rameau
@R4meau
Apr 11 2016 02:46
@allisonkbates Yup, you got it right.
@allisonkbates You're gonna need a loop.
Allison Bates
@allisonkbates
Apr 11 2016 02:46
ha got it
Frank XC
@tenkdayz
Apr 11 2016 02:52
learning about webpack here. I see the word 'module' used often. Is a module a file? as in index.html or mystylesheet.css or main.js ? I'm confused.
Manraaj Nijjar
@ManraajNijjar
Apr 11 2016 02:59
@daemedeor Forgot to say Thanks! earlier for helping me out
CamperBot
@camperbot
Apr 11 2016 02:59
manraajnijjar sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 304 | @daemedeor | http://www.freecodecamp.com/daemedeor
Nick Rameau
@R4meau
Apr 11 2016 03:20
@tenkdayz Module refers to AMD and CommonJS module styles. Which are just JS files.
@tenkdayz If you've ever used Node, you've used CommonJS modules
Otavio J S Alves
@TatoAlves
Apr 11 2016 03:21
Hello everyone,
someone can help me to figure out this challenge "Chunky Monkey"
Nick Rameau
@R4meau
Apr 11 2016 03:22
@TatoAlves Share your code, did you try anything?
Otavio J S Alves
@TatoAlves
Apr 11 2016 03:22
function chunkArrayInGroups(arr, size) {
    var result = [];
    for (var i = 0; i < size; i++) {
        result[i] = arr.splice(0, size);
    }
    return result;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
work to the this str and size, but not to other tests like the challenge ask
because is creating the subarray like i need, but creationg subarray too much... I'm stuck
Norvin Burrus
@ndburrus
Apr 11 2016 03:25
swag = ab...
@TatoAlves
Nick Rameau
@R4meau
Apr 11 2016 03:27
@TatoAlves I suggest you create a variable that will hold the current length of the array.
Otavio J S Alves
@TatoAlves
Apr 11 2016 03:27
@ndburrus sorry, how it ? I really don't understand
Norvin Burrus
@ndburrus
Apr 11 2016 03:27
@TatoAlves i'm only near finishing js and need to complete oo & func prog
Otavio J S Alves
@TatoAlves
Apr 11 2016 03:28
@R4meau I'll try it now, let me see
Nick Rameau
@R4meau
Apr 11 2016 03:28
@TatoAlves Then each time you add the pair (or any amount) of elements to the result array, update that variable with the array length
Norvin Burrus
@ndburrus
Apr 11 2016 03:29
@TatoAlves it looks like you used "splice" vs. the advised Array.slice()
Nick Rameau
@R4meau
Apr 11 2016 03:30
@TatoAlves You could use a simple while loop, so if the variable is len, your while loop will be while(len > 0). Don't forget to update it inside the loop after you splice the array.
Otavio J S Alves
@TatoAlves
Apr 11 2016 03:31
hmm a bit confuse, but I'm trying here @R4meau , thank you for the help
CamperBot
@camperbot
Apr 11 2016 03:31
tatoalves sends brownie points to @r4meau :sparkles: :thumbsup: :sparkles:
:star: 301 | @r4meau | http://www.freecodecamp.com/r4meau
Nick Rameau
@R4meau
Apr 11 2016 03:31
@TatoAlves YW. Just let me know if you get stuck.
Otavio J S Alves
@TatoAlves
Apr 11 2016 03:31
Yes @ndburrus , using the splice i get the removed part of the array and back them like a subarray
Norvin Burrus
@ndburrus
Apr 11 2016 03:32
@TatoAlves nevermind - splice is valid
Otavio J S Alves
@TatoAlves
Apr 11 2016 03:32
duo for uno
@ndburrus =]
Norvin Burrus
@ndburrus
Apr 11 2016 03:32
@TatoAlves yep, just read about it
sunshuhan
@sunshuhan
Apr 11 2016 03:32
@TatoAlves adjust the loop condition , and use Array.push()function chunkArrayInGroups(arr, size) {
var result = [];
var num = arr.length/size;
for (var i = 0; i < num; i++) {
result.push( arr.splice(0, size));
}
return result;
}
Nick Rameau
@R4meau
Apr 11 2016 03:34
@sunshuhan Why give the whole code? You're not being helpful here ;)
Otavio J S Alves
@TatoAlves
Apr 11 2016 03:34
LOL
sunshuhan
@sunshuhan
Apr 11 2016 03:36
@R4meau it's almost his code, just help him fix some mistakes
Nick Rameau
@R4meau
Apr 11 2016 03:37
@sunshuhan Okay. Maybe you could just point out some hints.
Otavio J S Alves
@TatoAlves
Apr 11 2016 03:37
thank you @sunshuhan, this var num is the var i created to my function, but why use .push ?
CamperBot
@camperbot
Apr 11 2016 03:37
tatoalves sends brownie points to @sunshuhan :sparkles: :thumbsup: :sparkles:
:star: 278 | @sunshuhan | http://www.freecodecamp.com/sunshuhan
Otavio J S Alves
@TatoAlves
Apr 11 2016 03:37
the push is putting to the end of the array what i need, is it ?
Nick Rameau
@R4meau
Apr 11 2016 03:38
@TatoAlves Yup.
@TatoAlves Here's what I was trying to get you to do, just in case you were wondering:
function chunkArrayInGroups(arr, size) {

  var len = arr.length,
      newArr = [];

  while (len > 0) {
    newArr.push(arr.splice(0,size));
    len = arr.length;
  }

  return newArr;

}
Otavio J S Alves
@TatoAlves
Apr 11 2016 03:40
Awesome, thank you so much for the help @R4meau
CamperBot
@camperbot
Apr 11 2016 03:40
tatoalves sends brownie points to @r4meau :sparkles: :thumbsup: :sparkles:
:warning: tatoalves already gave r4meau points
Nick Rameau
@R4meau
Apr 11 2016 03:41
@TatoAlves You're welcome.
Otavio J S Alves
@TatoAlves
Apr 11 2016 03:41
I was almost... I really not tried .push using it correct, now i know hehe
Nafeesa Amanat
@namanat
Apr 11 2016 03:50
can someone start me off with this:
You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative. The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
Norvin Burrus
@ndburrus
Apr 11 2016 03:53
js
<var count = 0;
var tally = 0;


function cc(card) {
  // Only change code below this line



    if (card >= 2 && card <= 6) {
      tally = (tally + 1); 
    }

      else if (card == 10) {
      tally = (tally - 1);
      }

      else if (card == 'J') {
      tally = (tally - 1);
      }
      else if (card == 'Q') {
      tally = (tally - 1);
      }
      else if (card == 'K') {
      tally = (tally - 1);
      }
      else if (card == 'A') {
      tally = (tally - 1);
      } 

count = count + tally;>
@namanat i got that far, so far
on the card counting
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 03:54
can you post your code @namanat
Nate
@nateReiners
Apr 11 2016 03:58
A tip for the card counting, use ranges for low and mid, and then "else" for the rest of them which are all values which make your tally lose 1 point
if(card <=6) {
else if(card<=9) {
else { tally--}
it will check to see if it is lower than 6 first, and will only go to the else if statement if the card is not <= 6, then it will only go to the else statement if the card is not <= 9
Alexander Berezkin
@Leidone
Apr 11 2016 04:01

You should be getting the length of lastName by using .length like this: lastName.length.
// Example
var firstNameLength = 0;
var firstName = "Ada";

firstNameLength = firstName.length;

// Setup
var lastNameLength = 8;
var lastName = "Lovelace";

// Only change code below this line.

lastNameLength = lastName.length;

Norvin Burrus
@ndburrus
Apr 11 2016 04:01
@nateReiners thanks.
CamperBot
@camperbot
Apr 11 2016 04:01
ndburrus sends brownie points to @natereiners :sparkles: :thumbsup: :sparkles:
:star: 177 | @natereiners | http://www.freecodecamp.com/natereiners
Ankit
@ankitrn
Apr 11 2016 04:01
Hey, has anyone worked on the "smallest common multiple" problem?
Nate
@nateReiners
Apr 11 2016 04:02
your welcome
@ankitrn no, but tell us what the problem is and maybe someone will be able to help...
or paste your code?
Ankit
@ankitrn
Apr 11 2016 04:08
I think I found a bug in the question
So I have to find the least common multiple of two numbers
for example LCM of 1,5 is 5
and LCM of 4,5 is 20
but it says : smallestCommons([1, 5]) should return 60
which doesn't make sense 0_o
here's another one: smallestCommons([1, 13]) should return 360360.
Nate
@nateReiners
Apr 11 2016 04:11
if you have 1 as the first param, why is the LCM not simply the larger param? 1 and 13 both divide evenly into 13, no?
@ankitrn You're far ahead of me in the curriculem so sorry I don't think I can help.
Ankit
@ankitrn
Apr 11 2016 04:11
yeah.
Oh no worries
Brandon Lee
@brandonlee781
Apr 11 2016 04:14
@ankitrn If you read the instructions closely, its the least common multiple of every number between the two given. So for [1,5], its the smallest common multiple of 1,2,3,4 and 5. Which is 60.
Nate
@nateReiners
Apr 11 2016 04:19
@brandonlee781 nice1 :+1:
bkd705
@bkd705
Apr 11 2016 04:19
heyy, anyone around/
Nick Rameau
@R4meau
Apr 11 2016 04:19
@ankitrn Need any help?
bkd705
@bkd705
Apr 11 2016 04:20
I could use some help on the card counting challenge if anyone is available...
Coy Sanders
@coymeetsworld
Apr 11 2016 04:21
what's the problem @bkd705 ?
bkd705
@bkd705
Apr 11 2016 04:21
I just don't know where to start.
Coy Sanders
@coymeetsworld
Apr 11 2016 04:22
look into using case/switch statements
bkd705
@bkd705
Apr 11 2016 04:22
I know how to do it in my head, like the "logic" behind it, but i dont know how to apply it I guess.
Coy Sanders
@coymeetsworld
Apr 11 2016 04:22
each case would be a card, and you would do something (or nothing) to the count depending on the card value
bkd705
@bkd705
Apr 11 2016 04:23
I'm just assuming that you'd set a number to each of the cards, either being +1, 0 or -1, then modify count by those numbers depending on whats in the hand
Nate
@nateReiners
Apr 11 2016 04:23
I used if, else if, else and ranges for the card counting challenge
Coy Sanders
@coymeetsworld
Apr 11 2016 04:23
you can use if/else too @nateReiners , but case/switch much cleaner
and more appropriate for this challenge
@bkd705 the count isn't about the hand per se, its about every card you see
you're going to need to have a count variable to store the results of all the cards you see
Nate
@nateReiners
Apr 11 2016 04:25
ok. I think a switch statement would entail more typing but maybe not. I am but a noob haha
Coy Sanders
@coymeetsworld
Apr 11 2016 04:25
actually its the opposite @nateReiners :)
much more writing using if/else statements there
that doesn't mean it's wrong per se
Nate
@nateReiners
Apr 11 2016 04:25
@coymeetsworld may have to go back and redo that trying the switch statement. Thanks for the tip
CamperBot
@camperbot
Apr 11 2016 04:25
natereiners sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 517 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Apr 11 2016 04:26
yeah at least try it out and see how it differs, yw @nateReiners
bkd705
@bkd705
Apr 11 2016 04:26
see i was going to do something like if (card < 6) etc etc
Coy Sanders
@coymeetsworld
Apr 11 2016 04:26
the problem with that @bkd705 is that not all the cards are numbers
Nate
@nateReiners
Apr 11 2016 04:26
but "else" solves that problem
bkd705
@bkd705
Apr 11 2016 04:27
alright, i feel like i should know, but how would i actually modify the count variable within the case? through fcc all we ever did was return, not modified variables.
i did just count + 1, but apparently that doesnt work aha
Nate
@nateReiners
Apr 11 2016 04:27
count = count + 1 OR count++
Coy Sanders
@coymeetsworld
Apr 11 2016 04:27
yep @nateReiners
count + 1 alone doesn't do anything, you need to assign it back to the count variable
Ankit
@ankitrn
Apr 11 2016 04:28
@brandonlee781 oh! my bad. Thanks man
CamperBot
@camperbot
Apr 11 2016 04:28
ankitrn sends brownie points to @brandonlee781 :sparkles: :thumbsup: :sparkles:
:star: 366 | @brandonlee781 | http://www.freecodecamp.com/brandonlee781
Coy Sanders
@coymeetsworld
Apr 11 2016 04:28
in this case you definitely have to modify count @bkd705
bkd705
@bkd705
Apr 11 2016 04:30
how do i assign it back to the count variable?
nvm
im slow tonight
Coy Sanders
@coymeetsworld
Apr 11 2016 04:30
lol yeah just look at what @nateReiners wrote
since you're only ever incrementing or decrementing by one i would recommend using count++ and count-- syntax instead of count += 1 or count -= 1, or count = count + 1 or count = count - 1
less typing, and cleaner
bkd705
@bkd705
Apr 11 2016 04:33
alright so i got it all typed up, so the first couple cards do var count = count++; but then when i do the others and do var count = count--; it says var count is already defined,
Nate
@nateReiners
Apr 11 2016 04:33
count = count++ is not the right syntax.
bkd705
@bkd705
Apr 11 2016 04:34
oh
Nate
@nateReiners
Apr 11 2016 04:34
just count++ by itself means count = count + 1
Nick Rameau
@R4meau
Apr 11 2016 04:34
@bkd705 Share your whole code mate.
Coy Sanders
@coymeetsworld
Apr 11 2016 04:34
he hasn't written it yet @R4meau
we're walking him through the idea
Nick Rameau
@R4meau
Apr 11 2016 04:34
@coymeetsworld Aah, okay
Robert Valmassoi
@valmassoi
Apr 11 2016 04:35
hey quick question. whats ... called in js
bkd705
@bkd705
Apr 11 2016 04:35
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      break;
    case 10:
    case J:
    case Q:
    case K:
    case A:
      count--;
      break;
  }
Coy Sanders
@coymeetsworld
Apr 11 2016 04:35
yeah count++ => count += 1 => count = count + 1
bkd705
@bkd705
Apr 11 2016 04:35
thats what we got going so far
Coy Sanders
@coymeetsworld
Apr 11 2016 04:35
looks good, just have to modify J-A though
bkd705
@bkd705
Apr 11 2016 04:35
"j"?
Coy Sanders
@coymeetsworld
Apr 11 2016 04:35
those need to be strings
bkd705
@bkd705
Apr 11 2016 04:35
kk
Coy Sanders
@coymeetsworld
Apr 11 2016 04:35
it will think J is a variable, I think
which its not
V Arun Kumar
@arunvkumr
Apr 11 2016 04:37
@valmassoi if you mean (...) that is called the spread operator.. you can read more about it here.. :smile:
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Spread_operator
bkd705
@bkd705
Apr 11 2016 04:37
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count--;
      break;
  }

  if (count > 0) {
    return count + " Bet";
  } else {
    return count + " Hold";
  }
Justin
@daemedeor
Apr 11 2016 04:37
Yes!
bkd705
@bkd705
Apr 11 2016 04:37
beauty
Coy Sanders
@coymeetsworld
Apr 11 2016 04:37
yep looks good
that should work i think
Justin
@daemedeor
Apr 11 2016 04:37
@bkd705 thats good
bkd705
@bkd705
Apr 11 2016 04:37
yeah it did, thanks for the help guys, guess i need to learn a bit more about proper syntax, i think that was my struggle with starting aswell,
Justin
@daemedeor
Apr 11 2016 04:38
See you don't have time to be bored yet @bkd705
Coy Sanders
@coymeetsworld
Apr 11 2016 04:38
yeah, the challenges leading up to it were showing you if and else statements, then how to replace them with case/switch
bkd705
@bkd705
Apr 11 2016 04:39
aahaha, i napped for a few hours on accident tonight, so i can see myself beind up all night, or well close to it, so might aswell learn javascript :P
Coy Sanders
@coymeetsworld
Apr 11 2016 04:39
Counting Cards is just a challenge to see if you understood it
Justin
@daemedeor
Apr 11 2016 04:39
@bkd705 nah not specifically today.
Doug
@Spazcool
Apr 11 2016 04:39
Bad idea to have had a vacation in the middle of this but, I'm back and I have no clue what to do with the Record Collection challenge. Is there an example of something similar or just another explanation somewhere?
bkd705
@bkd705
Apr 11 2016 04:39
makes sense, well yeah i understood it all but i just had to go back to double check to make sure i was typing it all right aha
@daemedeor oh are you referring to yesterdays conversation about being bored and trying to learn angular before js lmfao.
Justin
@daemedeor
Apr 11 2016 04:40
@Spazcool just review what you've done! There's nothing stopping you
@bkd705 yes
bkd705
@bkd705
Apr 11 2016 04:40
@daemedeor definitely made no sense but idk, im a kid thats my excuse ;)
Justin
@daemedeor
Apr 11 2016 04:41
@bkd705 im not going to let that fly
bkd705
@bkd705
Apr 11 2016 04:41
ahahah @daemedeor
Justin
@daemedeor
Apr 11 2016 04:41
You're 17. Old enough to not be a kid :}
Doug
@Spazcool
Apr 11 2016 04:42
@daemedeor I've reviewed the 5 previous challenges, did them easily enough but now I'm stuck, an hour gone and nothing to show for it.
bkd705
@bkd705
Apr 11 2016 04:42
oh sorry, **im a teenager thats my excuse ;) :P
Justin
@daemedeor
Apr 11 2016 04:42
@bkd705 teenagers should know better than that
@Spazcool what are you having trouble with?
bkd705
@bkd705
Apr 11 2016 04:43
oh but aren't teenagers like steroetyped to be clueless, unorganized without routine or any sense of direction. :P
Justin
@daemedeor
Apr 11 2016 04:44
@bkd705 no. Grow up a little :)
bkd705
@bkd705
Apr 11 2016 04:44
@daemedeor well i mean i was joking, but damn if you really feel that way ;)
Justin
@daemedeor
Apr 11 2016 04:44
dont be a stereotype
I'm joking too.....
a little.
Coy Sanders
@coymeetsworld
Apr 11 2016 04:45
no 17 you should be a kid lol
I sound old saying that and I'm not lol
Justin
@daemedeor
Apr 11 2016 04:46
@coymeetsworld we should hold people and expect better out of everyone should we not?
:}
Coy Sanders
@coymeetsworld
Apr 11 2016 04:46
nah
Doug
@Spazcool
Apr 11 2016 04:46
I guess I don't understand what it's asking me to do. There's a record collection and then some near-pseudo code. I don't know. I was hoping that there might be a better explanation or a clearer demand.
bkd705
@bkd705
Apr 11 2016 04:46
i wish i was younger tbh and im only 17
Robert Valmassoi
@valmassoi
Apr 11 2016 04:46
yep thats what i was looking for @arunkumrv thanks
CamperBot
@camperbot
Apr 11 2016 04:46
valmassoi sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 443 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
bkd705
@bkd705
Apr 11 2016 04:46
i realize now i wasted so much time of my life doing nothing when i could have been the next young prodigy at something if i would have just dedicated my time to something, rather than just floating around between everything.
Coy Sanders
@coymeetsworld
Apr 11 2016 04:47
how much younger @bkd705? lol like 13 or something?
Nate
@nateReiners
Apr 11 2016 04:47
I'm struggling with converting this switch statement to a lookup table in the Using Objects for Lookups exercise ... am I supposed to build an object inside the function?
Justin
@daemedeor
Apr 11 2016 04:47
Help record collection
CamperBot
@camperbot
Apr 11 2016 04:47

:point_right: checkpoint record collection [wiki]

Checkpoint: Record Collection

Instructions

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

If value is non-blank (value !== ""), then update or set the value for the prop.

If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.

If value is blank, delete that prop.

Always return the entire collection object.

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about checkpoint record collection on the FCC Wiki

Justin
@daemedeor
Apr 11 2016 04:47
@Spazcool see above
Coy Sanders
@coymeetsworld
Apr 11 2016 04:47
nah you're fine @bkd705, only people that work earlier than where you are are prodigies and there are very few of those
Justin
@daemedeor
Apr 11 2016 04:48
Yea I'm just joking, enjoy your youth :}. Damn I do sound old
look what you did @coymeetsworld
Nate
@nateReiners
Apr 11 2016 04:48
I'm 26 and only now learning to code after teaching for 3 years... be glad you're starting at 17!
Coy Sanders
@coymeetsworld
Apr 11 2016 04:48
remember Mark Zuckerberg and Linus Torvalds and Bill Gates were all in college when they made their huge contributions to the world
and they were in their 20s
bkd705
@bkd705
Apr 11 2016 04:48
@coymeetsworld like those genius third world country kids who develop the most simple solution to a crazy problem and get offered scholarships to every single school you could ever think of, i mean obviously those are rare and you only hear about the ones who made it not the ones who didn't, but if i had a dream that'd be it.
Justin
@daemedeor
Apr 11 2016 04:49
@bkd705 a bit late to be in that dream
bkd705
@bkd705
Apr 11 2016 04:50
@daemedeor aha, would be pretty insane though,
Coy Sanders
@coymeetsworld
Apr 11 2016 04:51
well those are exceptions to the rule @bkd705
Justin
@daemedeor
Apr 11 2016 04:51
@bkd705 quite. Quite.
Coy Sanders
@coymeetsworld
Apr 11 2016 04:51
of course it would be nice, but its not the end of the world if you don't get that
bkd705
@bkd705
Apr 11 2016 04:53
oh obviously not, but just the concept of coming up with something that would save, improve, or just impact a mass of people's lives is great, but being a priviledged kid the only problem i can think of is the fact that i can't get pizza after 2am on weeknights.. ;)
Justin
@daemedeor
Apr 11 2016 04:54
@bkd705 simple solution.
Buy it from a 24/7 Walmart :)
or make kne
one*
bkd705
@bkd705
Apr 11 2016 04:55
i always burn them in the oven
Justin
@daemedeor
Apr 11 2016 04:56
Easy solution
take it out earlier :}
Nate
@nateReiners
Apr 11 2016 04:56
@daemedeor You sir deserve a full ride to MIT for that simple solution.
Justin
@daemedeor
Apr 11 2016 04:57
@nateReiners teach a man to fish, as they say
bkd705
@bkd705
Apr 11 2016 05:00
im stuck on Accessing Objects Properties with Variables
anyone got a moment to help? :P
Justin
@daemedeor
Apr 11 2016 05:01
i've got nothing but time
obj[variable]
done
:D
bkd705
@bkd705
Apr 11 2016 05:01
var playerNumber = testObj[16]; // Change this Line
var player = testObj; // Change this Line
Nate
@nateReiners
Apr 11 2016 05:01
I'm almost at the same spot in the curriculum as you. don't forget to assigning name of a property to the variable
bkd705
@bkd705
Apr 11 2016 05:01
is what i got atm but uhhh
Nate
@nateReiners
Apr 11 2016 05:01
assign*
Justin
@daemedeor
Apr 11 2016 05:03
@bkd705 all you do is playerNumber = 16
bkd705
@bkd705
Apr 11 2016 05:03
oh i figured it out,
yeah
lmfao,
Justin
@daemedeor
Apr 11 2016 05:03
haha
siiiiiimple
Nafeesa Amanat
@namanat
Apr 11 2016 05:08
thanks @nateReiners
CamperBot
@camperbot
Apr 11 2016 05:08
namanat sends brownie points to @natereiners :sparkles: :thumbsup: :sparkles:
:star: 178 | @natereiners | http://www.freecodecamp.com/natereiners
Nafeesa Amanat
@namanat
Apr 11 2016 05:08

var count = 0;

function cc(card) {
// Only change code below this line
if (card <= 6) {
count++;
} else if (card <= 9) {
} else if (card === 10 || card === 'J' || card === 'Q' || card === 'K'|| card ==='A') {
count--;
}

if (count > 0) {
return count + " Bet";
} else {
return count + " Hold";
} @nateReiners

Nate
@nateReiners
Apr 11 2016 05:08
@namanat I've since learned that that was supposed to be done with a switch statement lol but hey. it works!
Nafeesa Amanat
@namanat
Apr 11 2016 05:08
@nateReiners great help thanks!
CamperBot
@camperbot
Apr 11 2016 05:08
namanat sends brownie points to @natereiners :sparkles: :thumbsup: :sparkles:
:warning: namanat already gave natereiners points
Nate
@nateReiners
Apr 11 2016 05:09
your welcome!
you're* ... yikes gettin late
also, instead of typing so much on a second else if statement, it's possible to just say 'else { count--} ' but glad you did it your own way and figured out something that works one way or another
@daemedeor how do I change a switch statement to a lookup table?
Justin
@daemedeor
Apr 11 2016 05:12
@nateReiners lookup table?
Nate
@nateReiners
Apr 11 2016 05:12
I'm totally lost. should have asked a half-hour ago
yeah
Justin
@daemedeor
Apr 11 2016 05:12
lookupTable : {
key: value
}
thats all
Chris Cullen
@123xylem
Apr 11 2016 05:13
Hello. THis task mindfkd me.. Can some1 explain the code in plain english as im making like 3 algebraic conversions for this and I keep losing track of what the hell the things are doing...

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

function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp))
{ return myObj[checkProp];}
return "Not Found";
}

// Test your code by modifying these values
checkObj("gift");

Nate
@nateReiners
Apr 11 2016 05:13
can i do 'key: result = value' to alter the var result?
Mariya
@mariyadiminsky
Apr 11 2016 05:13
Hey guys I want to make a chat app, I know this is possible in node. But how can I create a chat bot in my own chat app? Is this possible in node too? Any recommendations?
Chris Cullen
@123xylem
Apr 11 2016 05:14
Basically Ive checked for myObj via checkObj... But I dont understand the checkObj code in relation to the rest
Justin
@daemedeor
Apr 11 2016 05:14
@nateReiners to alter the var result... lookupTable[key] = newValue :D
Frank XC
@tenkdayz
Apr 11 2016 05:14
@Mashadim yes.. a chat bot something like cleverbot?
Nate
@nateReiners
Apr 11 2016 05:15
@daemedeor thanks man I'll give it a whirl
CamperBot
@camperbot
Apr 11 2016 05:15
natereiners sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 307 | @daemedeor | http://www.freecodecamp.com/daemedeor
tuukkaUosukainen
@tuukkaUosukainen
Apr 11 2016 05:16
HI all! I've been stuck in this challenge for two days: https://www.freecodecamp.com/challenges/profile-lookup. Anyone care to assist me? Should I use for loop? for each, or nested for loops?
Any help would be much appreciated!
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 05:17
what are you most confused about @123xylem ?
post your code @tuukkaUosukainen and i'll take a stab at it :)
tuukkaUosukainen
@tuukkaUosukainen
Apr 11 2016 05:19
@Jlipschitz I will. I've been trying all kinds of things but can't seem to get it :)
//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

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
@Jlipschitz I think I should use .hasOwnProperty too?
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 05:20
well you definitely want to run a for loop to go through that contacts object @tuukkaUosukainen and yes including .hasOwnProperty would be a great touch
tuukkaUosukainen
@tuukkaUosukainen
Apr 11 2016 05:21
Do I need nested loop that goes through the object properties?
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 05:23
one loop should do because once you find your target "contact" then you'll know what position it is and call it contacts[index][prop] (something along those lines) @tuukkaUosukainen
tuukkaUosukainen
@tuukkaUosukainen
Apr 11 2016 05:24
@Jlipschitz Ok, I'll give it a try, thanks!
CamperBot
@camperbot
Apr 11 2016 05:24
tuukkauosukainen sends brownie points to @jlipschitz :sparkles: :thumbsup: :sparkles:
:star: 74 | @jlipschitz | http://www.freecodecamp.com/jlipschitz
Nate
@nateReiners
Apr 11 2016 05:25
blob
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 05:26
Good luck! @tuukkaUosukainen
Nate
@nateReiners
Apr 11 2016 05:26
I'm lost help me! Trying to make a simple lookup table...
tuukkaUosukainen
@tuukkaUosukainen
Apr 11 2016 05:26
@Jlipschitz Thanks will be needed!
CamperBot
@camperbot
Apr 11 2016 05:26
tuukkauosukainen sends brownie points to @jlipschitz :sparkles: :thumbsup: :sparkles:
:warning: tuukkauosukainen already gave jlipschitz points
Nate
@nateReiners
Apr 11 2016 05:27
current code just returns "Frank"
buckshot307
@buckshot307
Apr 11 2016 05:27
@nateReiners you need to remove the
bkd705
@bkd705
Apr 11 2016 05:27
just finished that one nate
Nate
@nateReiners
Apr 11 2016 05:27
darn. I'll catch you tomorrow! haha any tips?
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 05:28
you have to change your return statement and make it use the val that users are inputting @nateReiners
bkd705
@bkd705
Apr 11 2016 05:28
i did basically, "alpha":"Adams"
buckshot307
@buckshot307
Apr 11 2016 05:28
@nateReiners sorry, you need to remove the "result =" part
bkd705
@bkd705
Apr 11 2016 05:28
and result = lookup[val];
Nate
@nateReiners
Apr 11 2016 05:28
ohhhhh
let's see here.
thanks guys
bkd705
@bkd705
Apr 11 2016 05:29
because the function is phoneticLookup(val)
and at the bottom its phoneticLookup("charlie")
so the result would look through the object lookup for the val (being "charlie" in this case)
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 05:29
yes that also. you can set property values by using a colon var myObc { "alpha": "adams"} without having to use =, alpha being the property and adams is the value @nateReiners
bkd705
@bkd705
Apr 11 2016 05:30
im stuck on the next one
testing objects for properties
buckshot307
@buckshot307
Apr 11 2016 05:31
I'm a little stuck on the Profile Lookup. I can get it to return the correct values, but once I add something to return a string if the entry doesn't correspond with property it overwrites my correct answers.
Nate
@nateReiners
Apr 11 2016 05:31
@buckshot307 that doesn't work for this challenge...
bkd705
@bkd705
Apr 11 2016 05:32
nvm figured it out
Justin
@daemedeor
Apr 11 2016 05:33
@bkd705 nice :thumbsup:
buckshot307
@buckshot307
Apr 11 2016 05:33

@nateReiners removing the

result =

part?

Nate
@nateReiners
Apr 11 2016 05:35
got it now...
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 05:35
awesome @nateReiners
Nate
@nateReiners
Apr 11 2016 05:35
sheesh that took way too long! thanks everyone!
I had tried the syntax you all recommended at first but forgot to add result = lookup[val]; at the end
so yeah... time for bed I think! haha
happy coding everyone
bkd705
@bkd705
Apr 11 2016 05:36
i should stop asking for help because i tend to figure it out right after i ask
Nate
@nateReiners
Apr 11 2016 05:37
lol that's how it usually works :smile:
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 05:37
alternative could also just do return lookup[val] without having to declare it right before. night!
Nate
@nateReiners
Apr 11 2016 05:37
just kidding I'm not sleeping. Gotta catch up to @bkd705 :smile:
bkd705
@bkd705
Apr 11 2016 05:38
aha, its a race now ;) @nateReiners
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 05:38
on your marks...
Nate
@nateReiners
Apr 11 2016 05:38
right on! any extra motivation helps!
bkd705
@bkd705
Apr 11 2016 05:38
"why are you late for school?" "uhh, i uhh had a coding race with some guy on the internet all night and slept in...???"
buckshot307
@buckshot307
Apr 11 2016 05:39

so I have

for (var i = 0; i < contacts.length; i++) {
    if (firstName === contacts[i]["firstName"])
      return contacts[i][prop];
  }

which gets the first 3 check on the test. When I add something like
js if (firstName !== contacts[i]["firstName] return "No such contact"; it always prints "No such contact"

Nate
@nateReiners
Apr 11 2016 05:39
naw dog. this is like... an ongoing thing
you can sleep and try to catch me later. get some rest man
evil laughter
bkd705
@bkd705
Apr 11 2016 05:40
i was staying up anyways :P
buckshot307
@buckshot307
Apr 11 2016 05:41
should I be using another for or a while statement as well?
Nate
@nateReiners
Apr 11 2016 05:42
@bkd705 "a coding race" is a better excuse than most students have for sleeping in so you're good.
bkd705
@bkd705
Apr 11 2016 05:42
i just got stuck on a challenge for 5 minutes and couldn't figure it out, realized it wanted "formats" and i spealt "format".. lmao
spelt* jesus
@nateReiners yeah that is a solid point,
Mariya
@mariyadiminsky
Apr 11 2016 05:44
@tenkdayz Well I just wanted to build my own chat app, which I know is pretty simple on node with some get and post requests, but then I wanted there to be a, I guess it would be a 'bot', in the chat that responds to you based on a certain word you typed etc.
Justin
@daemedeor
Apr 11 2016 05:46
@buckshot307 you can try .hasOwnProperty... :D
look it up!
@Mashadim well on every input of the text, you can search through the string for specific words and it'll chat out a response based on those words
:D
bkd705
@bkd705
Apr 11 2016 05:48
// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

var secondTree = myPlants[2].list[2]; // Change this line
why does that not work?
Nate
@nateReiners
Apr 11 2016 05:48
let him struggle with it guys... lol
bkd705
@bkd705
Apr 11 2016 05:48
yet again
nvm
Nate
@nateReiners
Apr 11 2016 05:48
jk
bkd705
@bkd705
Apr 11 2016 05:48
i figure it out after i ask
Jas
@JB2016
Apr 11 2016 05:49
thank you @cannelflow and @gwenf, I figured it out just needed the following line result = lookup[val]; Sorry for the really late reply :/
CamperBot
@camperbot
Apr 11 2016 05:49
jb2016 sends brownie points to @cannelflow and @gwenf :sparkles: :thumbsup: :sparkles:
:star: 697 | @gwenf | http://www.freecodecamp.com/gwenf
:star: 1054 | @cannelflow | http://www.freecodecamp.com/cannelflow
buckshot307
@buckshot307
Apr 11 2016 05:49
@daemedeor I tried that as well in place of the firstName !== line but it gave the same results.
Mariya
@mariyadiminsky
Apr 11 2016 05:49
@daemedeor is it really that simple o.o
bkd705
@bkd705
Apr 11 2016 05:49
@nateReiners aha playing dirty to catch up ;)
Nate
@nateReiners
Apr 11 2016 05:49
@bkd705 nice going
Justin
@daemedeor
Apr 11 2016 05:49
@Mashadim a bit yea
@buckshot307 shouldn't be in place of you need a little more logic ;D
Jas
@JB2016
Apr 11 2016 05:50
Anyone done record collection in the basic javascript section?
bkd705
@bkd705
Apr 11 2016 05:50
im doing it now if that helps aha ;)
Nate
@nateReiners
Apr 11 2016 05:50
there's no way I'm catching this guy tonight. I'll nurse my wounds and come back strong another day. My brain is mush haha. Night everyone!! Keep killin' it @bkd705 !!
buckshot307
@buckshot307
Apr 11 2016 05:50
@daemedeor hmm okay thanks, gonna try a few other things.
CamperBot
@camperbot
Apr 11 2016 05:50
buckshot307 sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 309 | @daemedeor | http://www.freecodecamp.com/daemedeor
bkd705
@bkd705
Apr 11 2016 05:50
goodnight dude @nateReiners I won't make it much farther tonight so you'll have all day tomorrow to catch up ;)
Nate
@nateReiners
Apr 11 2016 05:51
right on
Mariya
@mariyadiminsky
Apr 11 2016 05:51
@daemedeor im having a hard time finding examples of this online...I need to write articles to really understand. Its either articles on how to create real time node chat apps, or articles on how to make irc/slack bots. There is nothing on creating conditional responses in your own created node app...T_T
Nate
@nateReiners
Apr 11 2016 05:51
that's what i like to hear
tuukkaUosukainen
@tuukkaUosukainen
Apr 11 2016 05:51
Anyone finished this challenge: https://www.freecodecamp.com/challenges/profile-lookup. Still stuck and don't know what to do? S.O.S. HELP :)
Justin
@daemedeor
Apr 11 2016 05:51
@Mashadim well.... regex and such, i would hold off on the bot making though.....
Mariya
@mariyadiminsky
Apr 11 2016 05:51
read not write*
Jas
@JB2016
Apr 11 2016 05:52
@bkd705 okay so just can't get 2 and 4 working the "should not be set"
Mariya
@mariyadiminsky
Apr 11 2016 05:52
yeah I know some regex, why hold off on bot making?
Justin
@daemedeor
Apr 11 2016 05:52
@Mashadim well focus on one item at a time, so probably create the node chat app first (if you want real time look up sockets.io)
then look up how to do bots
bkd705
@bkd705
Apr 11 2016 05:53
@JB2016 i can't focus on anything so i don't think ill be doing this one tonight aha, im sure someone will help you out ;P
Mariya
@mariyadiminsky
Apr 11 2016 05:53
@daemedeor Yeah Ive made a chat app before and I researched some socket.io as well
Now I want to create a personality in there
Jas
@JB2016
Apr 11 2016 05:53
All good @bkd705
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 05:54
post your code @JB2016
Mariya
@mariyadiminsky
Apr 11 2016 05:55
@daemedeor yep...
"Its either articles on how to create real time node chat apps, or articles on how to make irc/slack bots"
Justin
@daemedeor
Apr 11 2016 05:55
@Mashadim its fairly the same thing though
Aman Barnwal
@amanbarnwalce
Apr 11 2016 05:55
Doesn't work!
function destroyer(arr) {
  var arr1 = arguments[0];
  var arr2 = [];
    for(i=1; i<arguments.length; i++) {
   arr2.push(arguments[i]);
  }
  for(i=0; i<arr2.length; i++) {
   arr1 = arr1.filter(arr2[i]);
  }
  return arr1;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Justin
@daemedeor
Apr 11 2016 05:56
you basically hit an API and do response based on what was said
Mariya
@mariyadiminsky
Apr 11 2016 05:57
hmm..yeah...But its still on the slack chat right. So if I made it, that's the only place I could use it. I wanted to use it on my own server. Can chat inputs be stored into databases like mongodb or postgresql? but then deleted later?
Justin
@daemedeor
Apr 11 2016 05:58
@Mashadim same thing
just remove the slack requirements
Jas
@JB2016
Apr 11 2016 05:58
@Jlipschitz
I'm only struggling with this line
collection[id].pop(prop);
Justin
@daemedeor
Apr 11 2016 05:58
and post to x room
@JB2016 pop doesn't take a parameter
Jas
@JB2016
Apr 11 2016 05:59
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) {
  //collection.id.artist = value;
  if (value !== ""){
    if (prop != "tracks"){
      collection[id][prop] = value;

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

    }
  } else {
   collection[id].pop();
  }
  return collection;
}

// Alter values below to test your code
updateRecords(2548, "artist", "");
Mariya
@mariyadiminsky
Apr 11 2016 05:59
@daemedeor yeah im still new to all this so im iffy lol but thank you for the great advice :) i may do it on slack in the end anyway and maybe do it on my own later. Thanks!!
CamperBot
@camperbot
Apr 11 2016 05:59
mashadim sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 310 | @daemedeor | http://www.freecodecamp.com/daemedeor
Justin
@daemedeor
Apr 11 2016 05:59
@Mashadim exactly.... baby steps baby steps, but continue on socket.io if you want real time
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 06:00
@JB2016 delete collection[id][prop] instead of pop is what I think your'e looking to do
Justin
@daemedeor
Apr 11 2016 06:00
^
Jas
@JB2016
Apr 11 2016 06:01
@Jlipschitz yes thank you !!
CamperBot
@camperbot
Apr 11 2016 06:01
jb2016 sends brownie points to @jlipschitz :sparkles: :thumbsup: :sparkles:
:star: 75 | @jlipschitz | http://www.freecodecamp.com/jlipschitz
bkcpro123
@bkcpro123
Apr 11 2016 06:01
any javascript freelancer here?
Nick Rameau
@R4meau
Apr 11 2016 06:01
@bkcpro123 :point_up:
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 06:02
happy I could help! learned about delete today as well @JB2016
bkcpro123
@bkcpro123
Apr 11 2016 06:02
need someone who has enough expertise in jquery
Nick Rameau
@R4meau
Apr 11 2016 06:02
@bkcpro123 You can DM me.
Rujool Doshi
@rujool
Apr 11 2016 06:03
Can some1 pls help me with this code:
Eldar Tinjić
@EldarT90
Apr 11 2016 06:03
$("#temp").append('<p id="switcher">' + (Math.round(data.main.temp - 273.15) + <span>" &#x2103") +  '</p>');
Jas
@JB2016
Apr 11 2016 06:04
@Jlipschitz yeah just used stackoverflow to learn difference between pop, delete and remove oh the joys
Rujool Doshi
@rujool
Apr 11 2016 06:04
function smallestCommons(arr) {
  var min = Math.min(arr[0],arr[1]);
  var max = Math.max(arr[0],arr[1]);
  var sortedArr = [];
  for(var i = min; i <= max; i++){
    sortedArr.push(i);
  }
  return getLCM(sortedArr);
}
function getLCM(arr){
  if(arr.length === 2){
    console.log(arr[0]+" "+arr[1]);
    return findLCM(arr[0],arr[1]);
  }
  else{
    console.log(arr[0], arr.slice(1));
    return findLCM(arr[0],getLCM(arr.slice(1)));
  }
}  
function findLCM(a,b){
  if(a === b){
    return a;
  }
  else if(a>b){
    A = a;
    while(a <= A*b){
      if(a%b === 0 && a%A === 0){
        console.log("LCM of "+A+" and "+b+" is: "+a);
        return a;
      }
      a+=a;
    }
  }

  else{
    B = b;
    while(b <= B*a){
      if(b%a === 0 && b%B ===0){
        console.log("LCM of "+a+" and "+B+" is: "+b);
        return b;
      }
      b+=b;
    }
  }
}
smallestCommons([1, 5]);
Eldar Tinjić
@EldarT90
Apr 11 2016 06:04
sry, mistake
 $("#temp").append('<p id="switcher">' + (Math.round(data.main.temp - 273.15) + " &#x2103") +  '</p>');
i need to insert span around celsius sign
but when i try to do that, i break whole line
Nick Rameau
@R4meau
Apr 11 2016 06:05
@EldarT90 Show your whole CodePen mate.
Eldar Tinjić
@EldarT90
Apr 11 2016 06:05
jorgon1022
@jorgon1022
Apr 11 2016 06:09
hey guys
Im sorry to bother but I was woderring if any of you guys can help me figure out an issue I have with my coded?
code?
Nick Rameau
@R4meau
Apr 11 2016 06:10
@EldarT90 Instead of handling click events in HTML, you should do them in JS mate.
@EldarT90 Your code is kinda scary like this :P
Eldar Tinjić
@EldarT90
Apr 11 2016 06:11
@R4meau well :D thats the only approach i have learned so far, what exactly do you recommend in order for code to look "cleaner" ^^
Nick Rameau
@R4meau
Apr 11 2016 06:11
@EldarT90 Bind click events with the jQuery .on('click'... function. Let me do it and you'll see. Hold on.
Eldar Tinjić
@EldarT90
Apr 11 2016 06:12
@R4meau oke tnx
CamperBot
@camperbot
Apr 11 2016 06:12
eldart90 sends brownie points to @r4meau :sparkles: :thumbsup: :sparkles:
:star: 303 | @r4meau | http://www.freecodecamp.com/r4meau
Zach
@Moose1551
Apr 11 2016 06:13
In "Factorialize a number" in Basic javaScript, which lessons touched on the idea? I'm at a loss.
Tej Pratap
@tejscript
Apr 11 2016 06:15
@jorgon1022 what are you on ?
George
@clefnetwork
Apr 11 2016 06:19
hey all--anyone have insight into why my third if/else statement doesnt work?
var count = 0;

function cc(card) {
  // Only change code below this line

  if(card <=6) {
      count++;
  } else if (card === 7 || 8 || 9){
      count = count;
  }
  else if(card === 10 || 'J' || 'Q' || 'K' || 'A') {
      count--;
  } 


  if(count > 0) {
    return count + " Bet";
  } else if(count <= 0) {
    return count + " Hold";
  }

  // Only change code above this line
}
bkd705
@bkd705
Apr 11 2016 06:19
@Moose1551 still need help with that one?
Eldar Tinjić
@EldarT90
Apr 11 2016 06:20
count = count resets your count, thats not good
bkd705
@bkd705
Apr 11 2016 06:20
@Moose1551 its super simple concepts you just have to put them together, basically just an if/else statement with multiplication, thats how i just did it
Eldar Tinjić
@EldarT90
Apr 11 2016 06:20
i think
bkd705
@bkd705
Apr 11 2016 06:21
since 7, 8 and 9 don't actually impact your end number
since they all equal 0
you don't need to include them at all.
and you can shorten up your bet/hold if/else aswell,
George
@clefnetwork
Apr 11 2016 06:21
hmm, taking them out still throws an error though for test cases involving 7 8 9
bkd705
@bkd705
Apr 11 2016 06:22
i did it using switch/case
instead of if/else
just do count + 0
i think that might fix the erorr
George
@clefnetwork
Apr 11 2016 06:22
yeah i was thinking switch
bkd705
@bkd705
Apr 11 2016 06:22
error*
George
@clefnetwork
Apr 11 2016 06:23
my problem is, if i switch the second and third if else, each of them work, but when i put them both in, they fail out
and im not sure why its failing out on the third
Eldar Tinjić
@EldarT90
Apr 11 2016 06:23
@clefnetwork i also used switch
@clefnetwork switch break combo for each card
except 7-9
bkd705
@bkd705
Apr 11 2016 06:25
switch (card) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
 count++;
 break;
case 10:
case "J":
case "Q":
case "K":
case "A":
 count--;
 break;
}

if (count > 0) { return count + " Bet";}
 else { return count + " Hold";}
is what mine looked like.
Zach
@Moose1551
Apr 11 2016 06:25
I gotcha, @bkd705 . Thanks, partner.
CamperBot
@camperbot
Apr 11 2016 06:25
moose1551 sends brownie points to @bkd705 :sparkles: :thumbsup: :sparkles:
:star: 206 | @bkd705 | http://www.freecodecamp.com/bkd705
bkd705
@bkd705
Apr 11 2016 06:26
basically just do an if statement that checks to see if the number is 0, and if it is return 1, then an else statement that basically takes the num and multiplies it by the num-1
George
@clefnetwork
Apr 11 2016 06:28
cool thanks @bkd705
CamperBot
@camperbot
Apr 11 2016 06:28
clefnetwork sends brownie points to @bkd705 :sparkles: :thumbsup: :sparkles:
:star: 208 | @bkd705 | http://www.freecodecamp.com/bkd705
bkd705
@bkd705
Apr 11 2016 06:29
i think case works better in that one because then you can just ignore the 7 8 and stuff because they don't impact the outcome,
Zach
@Moose1551
Apr 11 2016 06:30

@bkd705, Is it actually possible to use the shorthand notation "n!" in javaScript? For example, could I say:

function factorialize(num) {
  if (num) {
    return num!;
  }

}

factorialize(5);

It's not showing up as a possible option, but could it possibly be?

Jamie Lipschitz
@Jlipschitz
Apr 11 2016 06:30
else if(card === 10 || 'J' || 'Q' || 'K' || 'A') can this be done? i thought it had to be card === 10 || card === 'J'.. never knew you can shorthand?
Nick Rameau
@R4meau
Apr 11 2016 06:33
@EldarT90 Check this. Can be better tho. I just wanted to show you how .on('click'... works. But you can still improve it later.
V Arun Kumar
@arunvkumr
Apr 11 2016 06:33
@clefnetwork or( || ) needs condition on both sides.. like this
(conditioin 1) || (condition 2). if you specify anything other than false values in it automatically takes it as true.. in your case (condition 1) || 7 or (condition 1) || 'J' Here logical or takes 7 (or anything other than false values) as true.. if condition 1 fails it looks for second condition in your case which is always true.. So, use like
card === 7 || card === 8.
Eldar Tinjić
@EldarT90
Apr 11 2016 06:33
@Jlipschitz i dont think you can
@R4meau thanks mate, let me check it out ^^
CamperBot
@camperbot
Apr 11 2016 06:33
eldart90 sends brownie points to @r4meau :sparkles: :thumbsup: :sparkles:
:warning: eldart90 already gave r4meau points
Nick Rameau
@R4meau
Apr 11 2016 06:33
@Jlipschitz Lol, it can be done, but it won't work as expected.
Eldar Tinjić
@EldarT90
Apr 11 2016 06:34
@R4meau can you shorten it, i tought you had to write new statement for each element .. or not ?
@R4meau i mean regarding counting card issue
Jamie Lipschitz
@Jlipschitz
Apr 11 2016 06:34
@clefnetwork good to know for the both of us then. thanks guys
CamperBot
@camperbot
Apr 11 2016 06:34
jlipschitz sends brownie points to @clefnetwork :sparkles: :thumbsup: :sparkles:
bkd705
@bkd705
Apr 11 2016 06:34
@Moose1551 no you can't because the notation isn't in JS.
CamperBot
@camperbot
Apr 11 2016 06:34
:warning: could not find receiver for clefnetwork
bkd705
@bkd705
Apr 11 2016 06:34
@Moose1551 so you have to do it the boring long way using if/else statements
Zach
@Moose1551
Apr 11 2016 06:35
@bkd705 , haha. Rock on.
bkd705
@bkd705
Apr 11 2016 06:35
@Moose1551 im sure theres many ways to do it but my way basically was just an if checking if it equaled to zero, then an else that just did num * num - 1
V Arun Kumar
@arunvkumr
Apr 11 2016 06:37
@Moose1551 No.. that doesn't work.. you have to follow the expansion. (using multiplication operator(*) ). :grinning:
Eldar Tinjić
@EldarT90
Apr 11 2016 06:40
@R4meau could you explain me this, piece by piece? thanks
CamperBot
@camperbot
Apr 11 2016 06:40
eldart90 sends brownie points to @r4meau :sparkles: :thumbsup: :sparkles:
:warning: eldart90 already gave r4meau points
Eldar Tinjić
@EldarT90
Apr 11 2016 06:40
    $('#temp').on('click', function() {
        if ($(this).text().match("C$")) {
            $(this).html('<p id="switcher">' + (far + " <sup>o</sup>F") +  '</p>')
        } else {
            $(this).html('<p id="switcher">' + (cel + " <sup>o</sup>C") +  '</p>');
        }
what needs to match what, in practice ... and why we still need previous statements then
Bharat
@BharatKalluri
Apr 11 2016 06:41
can anybody explain why this code does not work
function mutation(arr) {
  fir = arr[0].toLowerCase(); sec = arr[1].toLowerCase();
  var count = 0;
  if(fir.length<sec.length) {
    count = fir.length;
  }
  else {
    count = sec.length;
  }
  flag = true;
  for(var i = 0 ;i <=count;i++) 
  {
     if(fir.indexOf(sec[i])) {
         flag = true;
    }
   else {
        flag = false;
        break;
   } 
}
 return flag; 
}



mutation(["hello", "Hello"]);
for Mutations in algo rithims
Rujool Doshi
@rujool
Apr 11 2016 06:43
@Bharat-Kalluri check indexOf condition
Nick Rameau
@R4meau
Apr 11 2016 06:43
@EldarT90 .on('click', function, is the same as onclick in html. So that's not a new thing to you, really. The only thing that could look new is $(this).text().match("C$") which is a regex looking for what the temperature ends with, if it ends with "C", replace the content with the far, else, replace it with the cel.
Frank XC
@tenkdayz
Apr 11 2016 06:43
@Bharat-Kalluri .. does it work?
Bharat
@BharatKalluri
Apr 11 2016 06:44
@rujool is there anything wrong
@tenkdayz nope..
Frank XC
@tenkdayz
Apr 11 2016 06:44
@Bharat-Kalluri it has to check every letter.. looks like it isnt
Bharat
@BharatKalluri
Apr 11 2016 06:44
@rujool @tenkdayz it fails when case changes
Eldar Tinjić
@EldarT90
Apr 11 2016 06:44
@R4meau ("C$") this part bothers me most , what is this
V Arun Kumar
@arunvkumr
Apr 11 2016 06:44
@Bharat-Kalluri
for loop condition <= not right..
and indexOf() returns index values if value found and for first value it returns 0 which if takes as false. and indexOf returns -1 if value doesn't exist. so use something in if to compare with -1
Eldar Tinjić
@EldarT90
Apr 11 2016 06:44
@R4meau aha oke
Nick Rameau
@R4meau
Apr 11 2016 06:44
@EldarT90 You got it now?
Eldar Tinjić
@EldarT90
Apr 11 2016 06:45
@R4meau i got that part, but how can he know what to look for, which statement out of 3 to take into consideration
@R4meau ok i think i got it now
Frank XC
@tenkdayz
Apr 11 2016 06:46
@Bharat-Kalluri it's only returning true if it finds one letter.. then nothing happens
Bharat
@BharatKalluri
Apr 11 2016 06:46
@arunkumrv
if(fir.indexOf(sec[i])!=-1) {
         flag = true;
    }
V Arun Kumar
@arunvkumr
Apr 11 2016 06:46
@Bharat-Kalluri yea that will do..
Bharat
@BharatKalluri
Apr 11 2016 06:47
is this it? this also does not wok :-(
V Arun Kumar
@arunvkumr
Apr 11 2016 06:47
for loop condition.. <= you changes that? it should be <
Nick Rameau
@R4meau
Apr 11 2016 06:47
@EldarT90 Good :thumbsup:
@Bharat-Kalluri There's no need to do this at all:
if(fir.indexOf(sec[i])) {
         flag = true;
    }
Bharat
@BharatKalluri
Apr 11 2016 06:48
my initial code is exactly same @R4meau
@R4meau but it fails if words are case sensitive
Nick Rameau
@R4meau
Apr 11 2016 06:49
@Bharat-Kalluri So your for loop can just be
for(var i = 0 ; i < count;i++) 
     if(fir.indexOf(sec[i]) == -1)
         flag = false;
V Arun Kumar
@arunvkumr
Apr 11 2016 06:49
@Bharat-Kalluri working? i ran your code, it works. repost your code.. with changes.
@R4meau for condition you sure it should be <=?
Nick Rameau
@R4meau
Apr 11 2016 06:50
@arunkumrv I edited it.
Bharat
@BharatKalluri
Apr 11 2016 06:50
it still does not work
function mutation(arr) {
  fir = arr[0].toLowerCase(); sec = arr[1].toLowerCase();
  var count = 0;
  if(fir.length<sec.length) {
    count = fir.length;
  }
  else {
    count = sec.length;
  }
  flag = true;
  for(var i = 0 ;i <=count;i++) 
{
     if(fir.indexOf(sec[i]) == -1) {
         flag = false;
       break;
    }
}
 return flag; 
}



mutation(["hello", "Hello"]);
V Arun Kumar
@arunvkumr
Apr 11 2016 06:51
@Bharat-Kalluri repost you code.. with changes lets have a look
@Bharat-Kalluri for loop condition.... i <= count this is iterating for one more time.. it should be i < count.
Nick Rameau
@R4meau
Apr 11 2016 06:52
@Bharat-Kalluri This works fine for me:
function mutation(arr) {
  var fir = arr[0].toLowerCase(), 
      sec = arr[1].toLowerCase(),
      flag = true;

  for(var i = 0 ; i < sec.length;i++) 
     if(fir.indexOf(sec[i]) == -1)