These are chat archives for FreeCodeCamp/HelpJavaScript

18th
Jul 2016
Brendan Kinahan
@BKinahan
Jul 18 2016 00:00
@maxgawason the function signature for a filter callback function is function(value,index,array){} where value is the value of each element, index is that element's index, and array is the array you call it on.
Keli Fine
@kelifine
Jul 18 2016 00:00
@Chrono79 thank you!
CamperBot
@camperbot
Jul 18 2016 00:00
kelifine sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1556 | @chrono79 |http://www.freecodecamp.com/chrono79
Max Gawason
@maxgawason
Jul 18 2016 00:00
@BKinahan ok now I understand what was wrong
Keli Fine
@kelifine
Jul 18 2016 00:00
@Chrono79 hm that didn't work for me
Diego Mayer
@Chrono79
Jul 18 2016 00:02
@kelifine show your code
Keli Fine
@kelifine
Jul 18 2016 00:03
@Chrono79 else if (prop == "tracks" && collection[id].hasOwnProperty("tracks") === false) {
collection[id][prop] = [];
collection[id][prop] = value;
the function has inputs of id,prop,value
Diego Mayer
@Chrono79
Jul 18 2016 00:04
@kelifine these 2 don't work together:
collection[id][prop] = [];
collection[id][prop] = value; // this one overwrites the array
Keli Fine
@kelifine
Jul 18 2016 00:04
oh k so i'd have to push the value to the array
Diego Mayer
@Chrono79
Jul 18 2016 00:04
yes
bitgrower
@bitgrower
Jul 18 2016 00:04
yeppers!!!!
good goin', @kelifine !
Keli Fine
@kelifine
Jul 18 2016 00:04
thanks so much!!!
Diego Mayer
@Chrono79
Jul 18 2016 00:04
:+1:
bitgrower
@bitgrower
Jul 18 2016 00:04
yw !
keep up the great work!
Brendan Kinahan
@BKinahan
Jul 18 2016 00:05
okay this cheerful enthusiasm is too much for me. later y'all o/
bitgrower
@bitgrower
Jul 18 2016 00:05
LOL @BKinahan --
Diego Mayer
@Chrono79
Jul 18 2016 00:05
bye
bitgrower
@bitgrower
Jul 18 2016 00:06
too many black clouds in parts of my world these days ... trying to encourage sunshine & smiles ... :)
Chad Hurley
@ChadDean82
Jul 18 2016 00:12
@Chrono79 ok not sure how to set the value of my access string. tried a few things short of going back thru lessons.
I tried setting the val with = "" & a ="maps".
BarneyIX
@BarneyIX
Jul 18 2016 00:17
So I need a bit of help here.. I'm trying to convert from Fahrenheit to Celcius but every mathematical operation that I input returns a Null value. Here's one of the format's that I've tried fahrenheit =9;
fahrenheit /=5;
fahrenheit +=32; I've also tried fahrenheit = Fahrenheit
operation* number but all values = null
sigh.. I guess it italicized the asterisk or something
bitgrower
@bitgrower
Jul 18 2016 00:19
@BarneyIX -- can you put one of your statements on one line ... ?
BarneyIX
@BarneyIX
Jul 18 2016 00:19
I did that too... all null
also I wasn't sure if it would throw an error if I used ()'s since that didn't cover order of operations
bitgrower
@bitgrower
Jul 18 2016 00:20
or, in fact, can you show all your code ? ... Actually that wasn't for you, that was for us, so we can try and help you ...
without actually seeing your code, we really can't make a good assessment ... we need to see the full context ...thanks...
BarneyIX
@BarneyIX
Jul 18 2016 00:21
fahrenheit =fahrenheit*(9/5)+32;
fahrenheit*=(9/5)+32;
and broken up into parts
Moisés Man
@moigithub
Jul 18 2016 00:22
...whats the first value of fhrenheit ? before it reach that line....
BarneyIX
@BarneyIX
Jul 18 2016 00:22
all results in Null
value of variable = 30
Moisés Man
@moigithub
Jul 18 2016 00:22
30... which variable u talking ??
BarneyIX
@BarneyIX
Jul 18 2016 00:22
I can change that to match requirements but always = null
fahrenheit
Moisés Man
@moigithub
Jul 18 2016 00:23
i know celsuis variable is 30.. farenheit is not
bitgrower
@bitgrower
Jul 18 2016 00:23
@BarneyIX -- can you go into the challenge, and copy all of the lines of the code from there into this chat, please ?
fadyboy
@fadyboy
Jul 18 2016 00:24
Hi guys, I'm having a bit of a challenge with the seek and destroy algorithm please see my code below
function destroyer(arr) {
// Remove all the values
function filt(val){
var arr1 = Array.prototype.slice.call(arguments, 1);
return arr1;
}
return arr.filter(filt);
}
BarneyIX
@BarneyIX
Jul 18 2016 00:24

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

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

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

bitgrower
@bitgrower
Jul 18 2016 00:25
...and where have you put your code, @BarneyIX ?
BarneyIX
@BarneyIX
Jul 18 2016 00:25
above the line it states
and below the other line
bitgrower
@bitgrower
Jul 18 2016 00:25
you're not making this at all easy to help you ... just sayin'
fadyboy
@fadyboy
Jul 18 2016 00:25
I'm stuck as to why filter callback function does not filter accordingly
BarneyIX
@BarneyIX
Jul 18 2016 00:25
like the meat in a sandwhich
sorry
not intentional
bitgrower
@bitgrower
Jul 18 2016 00:27
@fadyboy -- the arguments variable changes value with each new scope ... so your first reference to the arguments variable is referencing the arguments of the function filt routine, not the argument variable containing the values of the parameters of the destroyer function ...
fadyboy
@fadyboy
Jul 18 2016 00:28
@bitgrower hmm, I see what you mean
bitgrower
@bitgrower
Jul 18 2016 00:28
if you haven't read the helpful links page on arguments object, read it ... maybe even a few times ... it's very cool, but you have to understand the various constraints ...
fadyboy
@fadyboy
Jul 18 2016 00:29
@bitgrower - ok I'll take a closer look at it
@bitgrower - tx
CamperBot
@camperbot
Jul 18 2016 00:30
fadyboy sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1142 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Jul 18 2016 00:30
yw !
BarneyIX
@BarneyIX
Jul 18 2016 00:30
So is there any reason why a mathematical operator should result in Null if there is a valid number ?
9*-30<>null
is this a correct mathematical expression in JS? var = var *9; ?
greg
@wearenotgroot
Jul 18 2016 00:34
@BarneyIX that last one is syntax error
@BarneyIX var is use to declare a variable
BarneyIX
@BarneyIX
Jul 18 2016 00:35
I didn't mean the function var I apologize
greg
@wearenotgroot
Jul 18 2016 00:35
@BarneyIX var myVar = otherVar * 9;
BarneyIX
@BarneyIX
Jul 18 2016 00:35
I meant it represented a variable
greg
@wearenotgroot
Jul 18 2016 00:36
ok
BarneyIX
@BarneyIX
Jul 18 2016 00:36
myVar = myVar *9; is ok right?
or myVar *= 9;
greg
@wearenotgroot
Jul 18 2016 00:37
:+1: both
BarneyIX
@BarneyIX
Jul 18 2016 00:37
does javascript use () to help with order of operations?
PEMDAS ?
Santiago Gómez
@Sperkajugglite
Jul 18 2016 00:37
hi guys , I'm having trouble with my simon game,
http://codepen.io/Sperkajugglite/full/JKyGJd?editors=0010
it breaks when you loose in strict mode
greg
@wearenotgroot
Jul 18 2016 00:37
@BarneyIX yes pemdas apply and parenthesis is use sometimes to separate things
Santiago Gómez
@Sperkajugglite
Jul 18 2016 00:38
do you know what the problem could be? :innocent:
BarneyIX
@BarneyIX
Jul 18 2016 00:38
I keep getting null values
greg
@wearenotgroot
Jul 18 2016 00:39
@BarneyIX let see the entire code block?
BarneyIX
@BarneyIX
Jul 18 2016 00:39

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

fahrenheit*=9/5;
fahrenheit+=32;
// Only change code above this line
return fahrenheit;
}

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

Santiago Gómez
@Sperkajugglite
Jul 18 2016 00:40
@BarneyIX use ```
BarneyIX
@BarneyIX
Jul 18 2016 00:40
use what?
Santiago Gómez
@Sperkajugglite
Jul 18 2016 00:40
format
i think your problem is that fahrenheit should be 1
its undefined
so when you multiply it it'll give you the value
BarneyIX
@BarneyIX
Jul 18 2016 00:41
convertToF = Celcius Temperature
so my convertToF value = 30 atm
Santiago Gómez
@Sperkajugglite
Jul 18 2016 00:41
var fahrenheit = 1 @BarneyIX
BarneyIX
@BarneyIX
Jul 18 2016 00:41
so should be 30*9/5+32
sigh
I get it now :(
greg
@wearenotgroot
Jul 18 2016 00:42
@BarneyIX the formula is T(F) = T(C) * 9/5 +32, F in fahrenheit and C in celsius
Santiago Gómez
@Sperkajugglite
Jul 18 2016 00:42
and i
think it would be easier for you to multiply it for 1.8
f = c * 1.8 + 32
BarneyIX
@BarneyIX
Jul 18 2016 00:42
I did exactly that initially but was getting null so I broke it down into steps
M and D
then addition
Santiago Gómez
@Sperkajugglite
Jul 18 2016 00:43
f = (c * 1.8) + 32
Craig
@zeropoint101
Jul 18 2016 00:43
hey does anyone know where in chrome inspector it shows the default browser font size before i set it?
greg
@wearenotgroot
Jul 18 2016 00:44

@BarneyIX yeah because you havent initialized the fahrenheit variable and you did

fahrenheit= fahrenheit * 9/5;

which will give you NaN

Santiago Gómez
@Sperkajugglite
Jul 18 2016 00:44
@zeropoint101 i think its like 16px
Physicallime570
@Physicallime570
Jul 18 2016 00:45
This message was deleted
Craig
@zeropoint101
Jul 18 2016 00:45
@Sperkajugglite yeah i know, i just wondered where it showed it in the inspector to look at the browsers style sheet, BUT... i just figured it out. i didn't realize there was a "show all" checkbox in the browser css properties.
Physicallime570
@Physicallime570
Jul 18 2016 00:45
This message was deleted
BarneyIX
@BarneyIX
Jul 18 2016 00:46
thanks greg
it's weird though cause I get fahrenheit*=9/5; = 1.8 but when I change the convertToF(num) it's always 33.8for some reason. Even if my celcius temp is 0
Physicallime570
@Physicallime570
Jul 18 2016 00:49
stuck on profile lookup challenge ```
Aiden
@AidenMead
Jul 18 2016 00:50
@Physicallime570 I'm stuck on the same
Physicallime570
@Physicallime570
Jul 18 2016 00:50
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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



// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
greg
@wearenotgroot
Jul 18 2016 00:50
@BarneyIX post your updated code?
BarneyIX
@BarneyIX
Jul 18 2016 00:50
lol currently I'm trouble shooting the results
here's what I was playing with

function convertToF(celsius) {
var fahrenheit = 1;
// Only change code below this line

fahrenheit*=9;

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

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

Physicallime570
@Physicallime570
Jul 18 2016 00:51
@AidenMead how is your code looking so far compared to mine
BarneyIX
@BarneyIX
Jul 18 2016 00:51
result of Fahrenheit*9 with a Celsius temp of 100 is 9
greg
@wearenotgroot
Jul 18 2016 00:52
@BarneyIX yes because you havent used the function parameter anywhere :)
Aiden
@AidenMead
Jul 18 2016 00:52
I had some similarities, but scrapped it all just a few minutes ago because it didn't seem to be working. When I simplified it to even the basic line, my testing kept coming back negative, so I figured I was on the wrong track
greg
@wearenotgroot
Jul 18 2016 00:52
@BarneyIX try and actually pluging in variables/params into the formula
BarneyIX
@BarneyIX
Jul 18 2016 00:53
ok working on that :P
thanks again
lol i'm an idiot thanks for that tip
greg
@wearenotgroot
Jul 18 2016 00:55
@BarneyIX nope your not, just not yet familiar with things :smile:
Aiden
@AidenMead
Jul 18 2016 00:56
@Physicallime570 remove the "." after ".hasOwnProperty", it's probably throwing a syntax error
greg
@wearenotgroot
Jul 18 2016 01:01
@Physicallime570
if (contacts[i].hasOwnProperty(prop)){ //<------------ 
        return contacts[i][prop];
}
else 
{ 
       return "No such contact";  //<---------------this should be "No such property" as you are testing .hasOwnProperty(arg) in the if statement
}
Jorge Castaño Delgado
@jhcastanod
Jul 18 2016 01:22
hey guys, I need some help to do the factorial exercise. I have this: for (var i = 1; i <= num ; i++){
var result;
result *= i;
return result;
}
what should I change to do it well? thanks
Florencia
@flopywood
Jul 18 2016 01:23
Hello everyone! This is not a challenge question but a general one. I'm doing the Basic Algorithm Scripting challenges and I couldn't pass any of them without finding the answers on the web. Like, none. Zero. Nada. I haven't done a single challenge on my own and I feel really bad about this because I want to learn and keep going. What's your experience like???
Onwuka Gideon
@dongido001
Jul 18 2016 01:25
@jhcastanod remove the var result; and place it befor for loop and try it
Jorge Castaño Delgado
@jhcastanod
Jul 18 2016 01:26
@dongido001 same result man
Physicallime570
@Physicallime570
Jul 18 2016 01:26
@wearenotgroot i finally got it but i did have some help from google, i think I was reading the challenge wrong
greg
@wearenotgroot
Jul 18 2016 01:28
@Physicallime570 dont worry bunch of people do find this one difficult
Onwuka Gideon
@dongido001
Jul 18 2016 01:30

@jhcastanod

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

}
return result;

greg
@wearenotgroot
Jul 18 2016 01:31
@flopywood you can try and do the same challenges with different approach? review concepts that you went through with the challenges as well
Drez
@drez14
Jul 18 2016 01:31
@flopywood just don't give up, it's not a matter of doing the challenges in your first attempt
David Di Feo
@ddifeo
Jul 18 2016 01:31
@flopywood I have previous programming experience and some of those challenges had me sitting in my chair for a bit thinking about how to solve them. So it's normal to be completely lost. If you really want to learn, look over the code on the wiki. Study it and try to really understand why they did it that way. Then go back to it the next day and try to solve it on your own.
Onwuka Gideon
@dongido001
Jul 18 2016 01:32
@jhcastanod
u should remove the return result from ur loop;
place it after ur loop to fix ur code
Jorge Castaño Delgado
@jhcastanod
Jul 18 2016 01:33
@dongido001 yeah! it worked! thanks a lot
CamperBot
@camperbot
Jul 18 2016 01:33
jhcastanod sends brownie points to @dongido001 :sparkles: :thumbsup: :sparkles:
:cookie: 245 | @dongido001 |http://www.freecodecamp.com/dongido001
greg
@wearenotgroot
Jul 18 2016 01:34
@jhcastanod did you understand why it worked? hint what does return do?
Florencia
@flopywood
Jul 18 2016 01:36
@realxtensive @drez14 @wearenotgroot thanks guys!!!!
CamperBot
@camperbot
Jul 18 2016 01:36
flopywood sends brownie points to @realxtensive and @drez14 and @wearenotgroot :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for drez14
:cookie: 313 | @realxtensive |http://www.freecodecamp.com/realxtensive
:star2: 1228 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Jul 18 2016 01:38
@flopywood :+1:
Jaren Escueta
@jarenescueta731
Jul 18 2016 01:38
@flopywood something you can try is writing out your program on paper in words first before typing out the code. just write down what you want your program to do, (what problem to solve), then break it down into steps, then figure out how to do those steps. this works differently for different people, but it helped me out a lot in school to write it out and get the brain working instead of staring at the problem
Willyan
@hashtagCode
Jul 18 2016 01:38
Hello!
i think i found a bug
Onwuka Gideon
@dongido001
Jul 18 2016 01:39
hoi
Willyan
@hashtagCode
Jul 18 2016 01:39
somebody can check?
Jorge Castaño Delgado
@jhcastanod
Jul 18 2016 01:39
@wearenotgroot I've always had that problem with loops. I thinks it happens because that returns each number and outside the loop returns the whole operation. am I wrong?
Onwuka Gideon
@dongido001
Jul 18 2016 01:39
@hashtagCode
yeah
greg
@wearenotgroot
Jul 18 2016 01:40
@jhcastanod yeap return will stop the loops exit if statment block and exit the function.
Willyan
@hashtagCode
Jul 18 2016 01:40
in Javascript Mutations
@dongido001 mutation(["floor", "for"]) should return true.
ops
I found my error
Lastly, ["Alien", "line"], should return true because all of the letters in "line" are present in "Alien".
thank you @dongido001
CamperBot
@camperbot
Jul 18 2016 01:41
:cookie: 246 | @dongido001 |http://www.freecodecamp.com/dongido001
hashtagcode sends brownie points to @dongido001 :sparkles: :thumbsup: :sparkles:
Onwuka Gideon
@dongido001
Jul 18 2016 01:42
@hashtagCode uwc
Jorge Castaño Delgado
@jhcastanod
Jul 18 2016 01:43
@wearenotgroot thanks greg
CamperBot
@camperbot
Jul 18 2016 01:43
jhcastanod sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1229 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Willyan
@hashtagCode
Jul 18 2016 01:43
what uwc means?
Onwuka Gideon
@dongido001
Jul 18 2016 01:43
uwc == you are welcome
Jaren Escueta
@jarenescueta731
Jul 18 2016 01:45
want's brownie points but no one needs help ;;
T__T
greg
@wearenotgroot
Jul 18 2016 01:47
why not YW :smile:
Onwuka Gideon
@dongido001
Jul 18 2016 01:47
@jarenescueta731
L0L,
whats the use of points
Jaren Escueta
@jarenescueta731
Jul 18 2016 01:47
@dongido001 gotta keep the streak going!
Onwuka Gideon
@dongido001
Jul 18 2016 01:48
@wearenotgroot
:smile:
greg
@wearenotgroot
Jul 18 2016 01:48
@jarenescueta731 @dongido001 @jhcastanod @flopywood thanks! here have some brownies
CamperBot
@camperbot
Jul 18 2016 01:48
wearenotgroot sends brownie points to @jarenescueta731 and @dongido001 and @jhcastanod and @flopywood :sparkles: :thumbsup: :sparkles:
:cookie: 251 | @flopywood |http://www.freecodecamp.com/flopywood
:cookie: 323 | @jarenescueta731 |http://www.freecodecamp.com/jarenescueta731
:cookie: 261 | @jhcastanod |http://www.freecodecamp.com/jhcastanod
:cookie: 247 | @dongido001 |http://www.freecodecamp.com/dongido001
Jaren Escueta
@jarenescueta731
Jul 18 2016 01:48
and the advanced algo challenge im on is annoying. i know what to do but i'm lazy right now
@wearenotgroot thanks lol
CamperBot
@camperbot
Jul 18 2016 01:49
jarenescueta731 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1230 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Jaren Escueta
@jarenescueta731
Jul 18 2016 01:53
anyone know why javascript doesn't like putting functions inside loops?
greg
@wearenotgroot
Jul 18 2016 01:54
@jarenescueta731 hmm.. not sure what you mean
@jarenescueta731 if you meant executing function inside a loop sure you can
Jaren Escueta
@jarenescueta731
Jul 18 2016 01:55
@wearenotgroot well it works, but when i'm in jsbin it gives me a warning whenever i have a function inside a loop
greg
@wearenotgroot
Jul 18 2016 01:55
@jarenescueta731 probably a warning that you are at risk of creating a infinite loop(calling a function over and over)
Jaren Escueta
@jarenescueta731
Jul 18 2016 01:56
i think it has something to do with memory allocation.
@wearenotgroot that too
greg
@wearenotgroot
Jul 18 2016 01:57
@jhcastanod just make sure the loops you create have proper stopping points
llamatarianism
@llamatarianism
Jul 18 2016 01:57
@jarenescueta731 are you defining a function inside a loop?
or just calling one?
it shouldn't warn you if it's an anonymous function, but defining a function inside a loop is definitely a bad idea
Jaren Escueta
@jarenescueta731
Jul 18 2016 01:59
@llamatarianism well in my program i have an array.reduce in a loop, and that's what jsbin warns about
llamatarianism
@llamatarianism
Jul 18 2016 01:59
@jarenescueta731 show me your code
cuz there are a ton of different ways you could reduce an array inside a loop
some of which are fine, some of which are bad
Jaren Escueta
@jarenescueta731
Jul 18 2016 02:00
var combined = args.reduce(function(a, b){
        return a.concat(b);
}, []);
inside a while loop
llamatarianism
@llamatarianism
Jul 18 2016 02:00
seems fine to me
Jaren Escueta
@jarenescueta731
Jul 18 2016 02:01
yeah it works fine, i was just wondering the context of jsbin's warning
thanks @wearenotgroot @llamatarianism @jarenescueta731 brownie points for everyone lol @dongido001 @camperbot
CamperBot
@camperbot
Jul 18 2016 02:03
jarenescueta731 sends brownie points to @wearenotgroot and @llamatarianism and @dongido001 and @camperbot :sparkles: :thumbsup: :sparkles:
:cookie: 248 | @dongido001 |http://www.freecodecamp.com/dongido001
:warning: jarenescueta731 already gave wearenotgroot points
:star2: 1022 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
:star2: 2070 | @camperbot |http://www.freecodecamp.com/camperbot
Aiden
@AidenMead
Jul 18 2016 02:09
I can't figure out why my if/else statement will only return whichever one come first. If I switch the order, the first will always return. They're both true, so they work, but I want it to return one or other other.
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i=0; i < contacts.length; i++) {
    if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop) === true) {
      return contacts[i][prop];
    } 
  } if (contacts.firstName !== firstName) {
    return "No such contact";
  } else if (contacts.prop !== prop) {
    return "No such property";
  }



// Only change code above this line
}
Anyone have any suggestions?
Stephen James
@sjames1958gm
Jul 18 2016 02:12
@AidenMead contacts is an array and doesn't have a firstName property
@AidenMead It doesn't have a prop property either. Your code will only work for the case where there is a firstname and there is a property
@AidenMead Basically both your tests outside the loop are not valid so always !==
Aiden
@AidenMead
Jul 18 2016 02:15
oh, hmmmm
Stephen James
@sjames1958gm
Jul 18 2016 02:16
@AidenMead Think about this problem as looking through a stack of business cards, for Bob's email address. You may not have his card and his card may not have an email address on it. contacts[i] is a card. If you think about the problem this way maybe the code will come more naturally
Jaymare
@Jaymare
Jul 18 2016 02:18

Hey all, I am stuck on the Record Collection challenge. My code is // Only change code below this line
function updateRecords(id, prop, value) {
if (value === '') {
delete collection[id][prop];
} else if (prop !== 'tracks') {
collection[id][prop] = value;
} else {
collection[id][prop].push(value);
}

return collection;
}

Taur'e Anthony
@k0decraft
Jul 18 2016 02:18

Hello FCC family, could you guys nudge me in the right direction regarding the Testing Objects for Properties challenge.....here's what I have so far....I feel like I just can't follow what the instructions are saying.

Code:


// Setup
var myObj = {

  gift: "pony",
  pet: "kitten",
  bed: "sleigh",

};

function checkObj( checkProp ) {
  // Your Code Here

  if ( myObj.hasOwnProperty('pony') ) {

  } else {

  }

  return "Not Found";
}

// Test your code by modifying these values
checkObj( "gift" );
Stephen James
@sjames1958gm
Jul 18 2016 02:21
@Jaymare your code is not handling - If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.
David Di Feo
@ddifeo
Jul 18 2016 02:22
@k0decraft you want to check if the object has a property that is equal to the variable checkProp. If so, return the value of that property. Else return "Not Found"
Stephen James
@sjames1958gm
Jul 18 2016 02:22
@k0decraft When you have a function with a parameter - here it is checkProp - you should use that
@k0decraft Then refer back to this challenge on how to use objects and properties in variables.
https://www.freecodecamp.com/challenges/accessing-objects-properties-with-variables
BarneyIX
@BarneyIX
Jul 18 2016 02:24

anyone mind helping on this... supposed to take this "FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine” and make it look like this

FirstLine
\SecondLine\
ThirdLine

my guess: "FirstLine\n\"\SecondLine\"\r\"ThirdLine"

Stephen James
@sjames1958gm
Jul 18 2016 02:24
@BarneyIX no need to add " in the middle of the string.
Taur'e Anthony
@k0decraft
Jul 18 2016 02:24
@sjames1958gm Right, but sometimes I need a different explanation then the default instructions here on FCC. I need a human being breaking down the challenges in laymen's terms.
@realxtensive Thanks
CamperBot
@camperbot
Jul 18 2016 02:25
k0decraft sends brownie points to @realxtensive :sparkles: :thumbsup: :sparkles:
:cookie: 316 | @realxtensive |http://www.freecodecamp.com/realxtensive
BarneyIX
@BarneyIX
Jul 18 2016 02:25
I thought that to include the "\" in a string it had to be "\<text\"
Aiden
@AidenMead
Jul 18 2016 02:25
@sjames1958gm Do you have an easy way to explain why the for loop would be used in that code, too? I feel like most of the exercises would be a little easier if I knew the why behind most of the code.
Stephen James
@sjames1958gm
Jul 18 2016 02:25
@BarneyIX No only \\
Jaymare
@Jaymare
Jul 18 2016 02:25
@sjames1958gm Yes.. but how to make it do that?
BarneyIX
@BarneyIX
Jul 18 2016 02:25
\<text>\?
lol it changed it on me
Aiden
@AidenMead
Jul 18 2016 02:26
' <text> '
Stephen James
@sjames1958gm
Jul 18 2016 02:26
@BarneyIX to include a backslash - just two backslashes
BarneyIX
@BarneyIX
Jul 18 2016 02:26
thnx
Stephen James
@sjames1958gm
Jul 18 2016 02:26
@Jaymare Put backquotes on either end of the code to get it to not hide backslashes
help format
CamperBot
@camperbot
Jul 18 2016 02:26

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Peter Weinberg
@no-stack-dub-sack
Jul 18 2016 02:27
ok, who feels like doing a Sunday good deed and helping me out with something? :smile: I'm working on my Twitch API project and am having an issue - when I run the following loop (to test this problem) which retrieves the JSON data and appends certain pieces of data to my project, everything works out fine. However, when I have
more inline html within the if (data.stream !== null) statement, the code within the second if statement does not seem to run. Which makes absolutely no sense to me considering everything else is exactly the same. I can post the full code if someone is interested in taking a look. Thanks!
 for (var i = 0; i < users.length; i++) {
    $.getJSON(twitch + users[i] + api, function(data) { 
      if (data.stream !== null) {
        $("#streamingUsers").append("<div>" + data._links.self.slice(37) + "</div>");
        } else if (data.stream === null) {       
          $("#boringUsers").append("<div>" + data._links.self.slice(37) + "</div>");
        }; 
    }); // end getJSON
  } // end loop
Stephen James
@sjames1958gm
Jul 18 2016 02:28
@AidenMead When you have something where you are lookin at each of some collection and that collection is an array you can use a for loop.
In plain english for each element in the array contacts, blah blah that says to me a for loop (other loops can be used but arrays and for loops work togetjer
@k0decraft I understand, but in the long term you will need to learn to interpret these kinds of instructions.
Aiden
@AidenMead
Jul 18 2016 02:29
okay, so the for loop basically just tells the computer "hey, look through every piece of this array"?
Stephen James
@sjames1958gm
Jul 18 2016 02:30
@AidenMead Kind of, it gives you the ability to more easily run through all of the indexes of the array. from 0 to the end.
@no-stack-dub-sack do you have a codepen link or some such?
Taur'e Anthony
@k0decraft
Jul 18 2016 02:31
@sjames1958gm I definitely agree with that !! Thanks
CamperBot
@camperbot
Jul 18 2016 02:31
k0decraft sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1955 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 18 2016 02:32
@k0decraft :+1: keep on keepin' on
Islam Ibakaev
@dagman
Jul 18 2016 02:32
@k0decraft
function checkObj( checkProp ) {
  const ownProps =  Object.keys(myObj);

  if (ownProps.indexOf(checkProp) > -1 ) {
    return `${checkProp} is presented`;
  } 

  return "Not Found";
}
checkObj('gift');
parthpatelforut
@parthpatelforut
Jul 18 2016 02:32
anyone help me with += operator
Stephen James
@sjames1958gm
Jul 18 2016 02:32
@parthpatelforut What's your issue
Aiden
@AidenMead
Jul 18 2016 02:33
thanks @sjames1958gm !
CamperBot
@camperbot
Jul 18 2016 02:33
aidenmead sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1956 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Taur'e Anthony
@k0decraft
Jul 18 2016 02:33
@dagman Hey man, I don't follow that...I'm just keeping it basic with what I feel like I know already.
Stephen James
@sjames1958gm
Jul 18 2016 02:33
@AidenMead :+1:
Peter Weinberg
@no-stack-dub-sack
Jul 18 2016 02:33
@sjames1958gm Yesssir, I just commented out the test code and um-commented the actual code that is breaking. Excuse the appearance, def a work in progress. Refer to line 16.
http://codepen.io/no_stack_dub_sack/pen/XKVxLJ?editors=0010
Islam Ibakaev
@dagman
Jul 18 2016 02:33
@k0decraft no problem dude
parthpatelforut
@parthpatelforut
Jul 18 2016 02:34
@sjames1958gm i am enable to append string by using +=oparator
Peter Weinberg
@no-stack-dub-sack
Jul 18 2016 02:34
@dagman ha! bojack...
Stephen James
@sjames1958gm
Jul 18 2016 02:35
@no-stack-dub-sack These two lines before your if statement are accessing data.stream before you check if it is null
      var synopsis = data.stream.channel.status;
      var game = data.stream.channel.game;
Peter Weinberg
@no-stack-dub-sack
Jul 18 2016 02:35
@sjames1958gm ahh, so just putting this inside the first if should do the trick then
Stephen James
@sjames1958gm
Jul 18 2016 02:35
@no-stack-dub-sack devtools console is your friend, the error that it showed pointed right to the issue.
@no-stack-dub-sack yes
Peter Weinberg
@no-stack-dub-sack
Jul 18 2016 02:36
@sjames1958gm ughhh, I should've known to check there. In fact, it might have been you that pointed me to a similar issue the other night. The answer was in the console.
Stephen James
@sjames1958gm
Jul 18 2016 02:37
@no-stack-dub-sack Repeat 100 times "The console is your friend" :)
@no-stack-dub-sack Think of it as your best friend who always tells you when you f**k up
Peter Weinberg
@no-stack-dub-sack
Jul 18 2016 02:38
@sjames1958gm haha, if only I had a blackboard and some chalk
Taur'e Anthony
@k0decraft
Jul 18 2016 02:38
Think of the console as a "snitch" lol
greg
@wearenotgroot
Jul 18 2016 02:39
:smile:
Stephen James
@sjames1958gm
Jul 18 2016 02:39
@k0decraft :+1:
Justin
@JustinGaravel
Jul 18 2016 02:39
Hi all, I'm learning about JSON objects for the first time. How do I access a 2nd level of an object, using a variable name? I'm doing" collection[id].prop" right now, which I think would mean that "prop" is the name of the string, when in fact this is a variable name...
Stephen James
@sjames1958gm
Jul 18 2016 02:40
@xxjeep just continue the brackets, just like a 2d array
Peter Weinberg
@no-stack-dub-sack
Jul 18 2016 02:40
@sjames1958gm although, I don't see which error points specifically to that issue... it says... is it "cannot read property channel of null"?
Justin
@JustinGaravel
Jul 18 2016 02:40
@sjames1958gm so - like collection[id[prop]]_
Stephen James
@sjames1958gm
Jul 18 2016 02:40
@no-stack-dub-sack since data.stream is null it cannot read data.stream.channel.
@xxjeep Nope. append collection[id][prop].
Justin
@JustinGaravel
Jul 18 2016 02:41
@sjames1958gm okay I'll try that- thanks!
CamperBot
@camperbot
Jul 18 2016 02:41
xxjeep sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1957 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 18 2016 02:41
@xxjeep collection[id] is the object and you do object[prop] so collection[id][prop]
Peter Weinberg
@no-stack-dub-sack
Jul 18 2016 02:42
@sjames1958gm right, but I don't try to access channel in the second if statement
Stephen James
@sjames1958gm
Jul 18 2016 02:42
@no-stack-dub-sack Once it hits that unhandled error it bails and doesn't continue your code
Peter Weinberg
@no-stack-dub-sack
Jul 18 2016 02:43
@sjames1958gm ooohhhhhhh, ok. I got it. Right, because it's a loop, and once it hits the else if it runs those 2 vars again and quits. Got it.
@sjames1958gm Thank you my friend, you've saved the day yet again
CamperBot
@camperbot
Jul 18 2016 02:44
no-stack-dub-sack sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1958 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jul 18 2016 02:45
lol - my brownies match my username
Peter Weinberg
@no-stack-dub-sack
Jul 18 2016 02:46
haha tell everyone to NEVER thank you ever again
greg
@wearenotgroot
Jul 18 2016 02:46
@sjames1958gm :+1: should have had 1337
Peter Weinberg
@no-stack-dub-sack
Jul 18 2016 02:46
I should win some kind of prize for being the 1958th thanker
Stephen James
@sjames1958gm
Jul 18 2016 02:46
@no-stack-dub-sack All your help is free from now on.
Peter Weinberg
@no-stack-dub-sack
Jul 18 2016 02:47
@sjames1958gm haha, perfect!
Stephen James
@sjames1958gm
Jul 18 2016 02:48
@parthpatelforut Do you have any code written, are you still on Concatenating Strings with the Plus Equals Operator
parthpatelforut
@parthpatelforut
Jul 18 2016 02:49
@sjames1958gm i got the issue solved.
Stephen James
@sjames1958gm
Jul 18 2016 02:50
@parthpatelforut Great - did not see your pm until later
Pitmation
@Pitmation
Jul 18 2016 02:56
can someone help me understand what they mean in the JS exercise Word blanks?
Hopsken
@Hopsken
Jul 18 2016 02:56
Hi, can anyone tell me how to remove all non-alphanumeric characters (punctuation, spaces and symbols) in Javascript?
Pitmation
@Pitmation
Jul 18 2016 02:57

We will now use our knowledge of strings to build a "Mad Libs" style word game we're calling "Word Blanks". You will create an (optionally humorous) "Fill in the Blanks" style sentence.

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

You will also need to use additional strings, which will not change, and must be in between all of the provided words. The output should be a complete sentence.

We have provided a framework for testing your results with different words. The tests will run your function with several different inputs to make sure all of the provided words appear in the output, as well as your extra strings.

Greg Duncan
@GregatGit
Jul 18 2016 02:57
@Hopsken you can use a combination of replace() and regexpressions
Pitmation
@Pitmation
Jul 18 2016 02:57
wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).

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

// Your code above this line
return result;
}

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

Greg Duncan
@GregatGit
Jul 18 2016 02:58
@Pitmation have a look here - you have to get a good handle on this concept http://www.w3schools.com/jsref/jsref_obj_regexp.asp
Hopsken
@Hopsken
Jul 18 2016 03:02
thx :smile: @GregatGit
CamperBot
@camperbot
Jul 18 2016 03:02
hopsken sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 692 | @gregatgit |http://www.freecodecamp.com/gregatgit
Pitmation
@Pitmation
Jul 18 2016 03:05
@GregatGit so my starting will be something like var mystr="dog"; myNoun= str.replace(/"dog"/i "cat")
?
Greg Duncan
@GregatGit
Jul 18 2016 03:07
@Pitmation starting
str = str.replace(before, after);
Pitmation
@Pitmation
Jul 18 2016 03:08
@parthpatelforut thank you for the under standing. where did they can little hit and slowly come from?
CamperBot
@camperbot
Jul 18 2016 03:08
pitmation sends brownie points to @parthpatelforut :sparkles: :thumbsup: :sparkles:
:cookie: 174 | @parthpatelforut |http://www.freecodecamp.com/parthpatelforut
Pitmation
@Pitmation
Jul 18 2016 03:08
the cat*
Jimmy Pham
@jpham197
Jul 18 2016 03:12
Can someone help me? I'm getting the error "ReferenceError: Count is not defined"

var count = 0;

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

if (card > 1 && card < 7) {
count ++;
} else if (card > 6 && card < 10) {
count = count;
} else if (card == 10 || card == "J" || card == "Q" || card == "K" || card == "A") {
count --;
}

if (card > 0) {
card = "Bet";
} else if (card <= 0) {
card = "Hold";
}
/
switch (card) {
case card > 0:
card = "Bet";
break;
case card <= 0:
card = "Hold";
break;
}
/
if (count > 0) {
return Count + " Bet";
} else {
return Count + " Hold";
}
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);

Norvin Burrus
@ndburrus
Jul 18 2016 03:13
@Pitmation the exercise is asking for a sentence to be built using the 4 word types given. it may be easiest to begin by making a complete (spacing & punctuation) sentence, using the 4 words. to make sense, the complete sentence will require a few "filler" words. :sparkles:
Greg Duncan
@GregatGit
Jul 18 2016 03:13
@Pitmation I was answering someone elses question but directing it at you - that was terrible advice for what you're doing
Pitmation
@Pitmation
Jul 18 2016 03:14
@ndburrus Now that makes sense!
llamatarianism
@llamatarianism
Jul 18 2016 03:16
@jpham197
if (count > 0) {
    return Count + " Bet";
} else {
    return Count + " Hold";
}
Count
Jaren Escueta
@jarenescueta731
Jul 18 2016 03:16

hey guys, i completed the Symmetric Difference advanced algo challenge and i was wondering if someone could help me understand how to convert my for loops into proper array.reduce functions. here's one of the for loops i have (and it has a nested loop as well):

  for (var j = 0; j < args.length; j++){
    var temp = [];
    for (var k = 0; k < args[j].length; k++){
      var number = args[j][k];
      if (temp.indexOf(number) > -1){ // number present in temp array
        continue; // skip number
      } else {
        temp.push(number); // push number to temp array
      }
    }
    args[j] = temp;
  }

or if it's even worth the trouble...

Jimmy Pham
@jpham197
Jul 18 2016 03:17
@llamatarianism how do i fix it?
kevinstonge
@kevinstonge
Jul 18 2016 03:18
I need some help with jQuery $.getJSON and sending keys in the headers (most of what I just wrote is still complete jibberish to me!). How do you include the key when you make an API request? and I don't think that will be the end of my troubles ... where is the simple guide to this? I feel like normally the keys are kept server side so lots of the stuff I find when I search isn't clear. Maybe I'm just not searching for the right thing??
Xavier Velez
@JonSnow08
Jul 18 2016 03:18
function sumAll(arr) {

 var max = Math.max(arr);
 var min = Math.min(arr); 
 var list = [];
for (var i = min; i <= max; i++) {
    list.push(i);
} 

 var total= list.reduce(function(a, b) {
  return a + b;
}, 0);

}

sumAll([1, 4]);
can anybody see what i may be doing wrong here
llamatarianism
@llamatarianism
Jul 18 2016 03:18
you're not returning anything
@jpham197 Count -> count
Xavier Velez
@JonSnow08
Jul 18 2016 03:19

```js
function sumAll(arr) {

var max = Math.max(arr);
var min = Math.min(arr);
var list = [];
for (var i = min; i <= max; i++) {
list.push(i);
}

var total= list.reduce(function(a, b) {
return a + b;
}, 0);
return total;
}

sumAll([1, 4]);

function sumAll(arr) {

 var max = Math.max(arr);
 var min = Math.min(arr); 
 var list = [];
for (var i = min; i <= max; i++) {
    list.push(i);
} 

 var total= list.reduce(function(a, b) {
  return a + b;
}, 0);
  return total;
}

sumAll([1, 4]);
even that fails...
Jimmy Pham
@jpham197
Jul 18 2016 03:19
ohH, that was a dumb mistake
thanks @llamatarianism
CamperBot
@camperbot
Jul 18 2016 03:19
:star2: 1023 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
jpham197 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
llamatarianism
@llamatarianism
Jul 18 2016 03:19
oh yeah
Math.max and Math.min only work with numbers
not with arrays
Math.max(1, 4) is 4, but Math.max([1, 4]) is NaN
you want to use apply:
Math.max.apply(Math, arr);
Xavier Velez
@JonSnow08
Jul 18 2016 03:20
ah thank ypu
llamatarianism
@llamatarianism
Jul 18 2016 03:20
Math.max.apply(Math, [1, 4]) is the same as Math.max(1, 2)
the same goes for Math.min :)
Xavier Velez
@JonSnow08
Jul 18 2016 03:21
@llamatarianism thank you
CamperBot
@camperbot
Jul 18 2016 03:21
jonsnow08 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1024 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
kevinstonge
@kevinstonge
Jul 18 2016 03:21
I need some help with jQuery $.getJSON and sending keys in the headers (most of what I just wrote is still complete jibberish to me!). How do you include the key when you make an API request? and I don't think that will be the end of my troubles ... where is the simple guide to this? I feel like normally the keys are kept server side so lots of the stuff I find when I search isn't clear. Maybe I'm just not searching for the right thing??
Norvin Burrus
@ndburrus
Jul 18 2016 03:21
@Pitmation excellent! sometimes the wording can make a difference :palm_tree:
Xavier Velez
@JonSnow08
Jul 18 2016 03:21
@ndburrus hey there
Norvin Burrus
@ndburrus
Jul 18 2016 03:22
@JonSnow08 hey, Jon! good to see you :+1: how's it going?
Xavier Velez
@JonSnow08
Jul 18 2016 03:23
@ndburrus good, took some time off here to polish up my html, css, js and jQuery
Justin
@JustinGaravel
Jul 18 2016 03:23
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i=0; i < arr.length; i++) {
    for (var j=0; j < arr.length; j++) {
      product *= arr[i][j];
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
product is returning NULL, is this a scope issue?
it looked fine to me
Norvin Burrus
@ndburrus
Jul 18 2016 03:23
@JonSnow08 nice! i'm sure it will come in handy :sparkles:
Xavier Velez
@JonSnow08
Jul 18 2016 03:23
@ndburrus did the codeacademy programs for each. I know a little more but I still need some practice
Justin
@JustinGaravel
Jul 18 2016 03:24
since product is declared at the highest level of the function
Norvin Burrus
@ndburrus
Jul 18 2016 03:25
@JonSnow08 i think any and all practice is beter than none... hey, i get stars (vs brownies) now!
...shifting the focus towards lessons & reading now...
Jaren Escueta
@jarenescueta731
Jul 18 2016 03:25
@kevinstonge if a key is required, you usually need to register to use the api. then you add the key to the end (usually) of the api url parameter for .getJSON
Xavier Velez
@JonSnow08
Jul 18 2016 03:25
@ndburrus nice is that cuz you hit 1000?
Norvin Burrus
@ndburrus
Jul 18 2016 03:26
@JonSnow08 yes. that's the breakpoint.
kevinstonge
@kevinstonge
Jul 18 2016 03:26
@jarenescueta731 why isn't the syntax for this listed anywhere? I have a key for a free api... the api's website shows me how to do this in just about every language but javascript :)
Norvin Burrus
@ndburrus
Jul 18 2016 03:27
@kevinstonge which api?
Jaren Escueta
@jarenescueta731
Jul 18 2016 03:27
@kevinstonge if you're talking about mediawiki, the docs are not intuitive at first lol
kevinstonge
@kevinstonge
Jul 18 2016 03:28
I've got a successful connection using $.ajax( ... ) but i don't know how to access the data from ajax since the freecodecamp tutorial used $.getJSON( ... )
llamatarianism
@llamatarianism
Jul 18 2016 03:28
@xxjeep j < arr.length
arr.length in that case is 3
kevinstonge
@kevinstonge
Jul 18 2016 03:28
and my first shot was wikiquotes ... and I just couldn't find anything at all that I could make sense of or put into my code
llamatarianism
@llamatarianism
Jul 18 2016 03:28
but some of the arrays inside arr have a length of just 2
for example
arr[0].length === 2
so arr[0][2] is undefined
so you're multiplying product by undefined
Justin
@JustinGaravel
Jul 18 2016 03:29
@llamatarianism ahh okay so I need to make the 2nd look only check the arr[i] then? for length?
llamatarianism
@llamatarianism
Jul 18 2016 03:29
yes
correct
Justin
@JustinGaravel
Jul 18 2016 03:29
@llamatarianism thanks
CamperBot
@camperbot
Jul 18 2016 03:29
xxjeep sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1025 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
kevinstonge
@kevinstonge
Jul 18 2016 03:30
Thanks @ndburrus ! That has exactly what I needed: "success: function(data) { ... " :)
CamperBot
@camperbot
Jul 18 2016 03:30
kevinstonge sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star2: 1009 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jul 18 2016 03:30
@kevinstonge you are now, officially, on fire! :fire: enjoy :palm_tree:
Jaren Escueta
@jarenescueta731
Jul 18 2016 03:31
@ndburrus thanks for that info! i never figured out how to use their api, i gave up and made my own object of quotes :/
CamperBot
@camperbot
Jul 18 2016 03:31
jarenescueta731 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star2: 1010 | @ndburrus |http://www.freecodecamp.com/ndburrus
Nick Irvine
@irvin3
Jul 18 2016 03:31
Hey everyone!
I was hoping someone could give me a pointer on the Smallest Common Multiple bonfire
Norvin Burrus
@ndburrus
Jul 18 2016 03:32
@jarenescueta731 well, you're creative with initiative! multitalented - outstanding :+1:
Nick Irvine
@irvin3
Jul 18 2016 03:32
I am able to find the smallest common multiple of the first two elements in my array, but im having trouble finding a way to iterate through the rest of the elements
my code is

function smallestCommons(arr) {
//switches arr from low to high if not already
    if(arr[0] > arr[1]){
      arr.push(arr[0]);
      arr.shift();
    }
    //creates an array from low to high of all numbers between arr0 and arr1 inclusive
    var low = arr[0];
    var high = arr[1];
    var newArr = [];
    for(var i = low; i <= high; i++){
      newArr.push(i);
    }

//finds the least common multiple of newArr[0]and newArr[1], removes both
//newArr[0] and newArr[1] and adds their least common multiple to the newArr[0] pos
  var zero = newArr[0];
  var one = newArr[1];
    while(zero !== one){
      zero += newArr[0];
      if(zero === one){
        newArr.shift();
        newArr.shift();
        newArr.unshift(zero);
      }
      else{
      one += newArr[1];
      }

    }


console.log(newArr);

}


smallestCommons([5,4]);
Ujjwal Nambiar
@UjjwalNambiar
Jul 18 2016 03:35
Hello everyone. I'm currently working on Manipulating Complex Objects and would appreciate it if I could get some help on resolving an error I have with my code.
Nick Irvine
@irvin3
Jul 18 2016 03:35
i believe using a for loop to iterate through each element breaks the loop because the length of the loop changes every time
Ujjwal Nambiar
@UjjwalNambiar
Jul 18 2016 03:35
Code:
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
{
"artist": "The Flaming Lips",
"title": "Yoshimi Battles the Pink Robots",
"release_year": 2002,
"formats": [
"CD",
"DVD"],
};
];
kevinstonge
@kevinstonge
Jul 18 2016 03:37
Triple thanks again to @ndburrus my quote machine is almost done! You da best!
CamperBot
@camperbot
Jul 18 2016 03:37
kevinstonge sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: kevinstonge already gave ndburrus points
Kevin
@KevinBruland
Jul 18 2016 03:37
@UjjwalNambiar whats the error?
Norvin Burrus
@ndburrus
Jul 18 2016 03:38
@kevinstonge anytime! glad to hear it! appreciate it :+1:
Cal-culator
@Cal-culator
Jul 18 2016 03:38
@UjjwalNambiar Why do you have two };? can you post the whole code?
Kevin
@KevinBruland
Jul 18 2016 03:38
@UjjwalNambiar its probably because there isnt a comma after myMusic[0]... remember that it is an array, in addition... you don't need the semicolon after the record you added
Norvin Burrus
@ndburrus
Jul 18 2016 03:39
@UjjwalNambiar place a comma between records :sparkles:
llamatarianism
@llamatarianism
Jul 18 2016 03:39
@UjjwalNambiar you're missing a comma after the first item
Cal-culator
@Cal-culator
Jul 18 2016 03:39
@UjjwalNambiar check your brackets. the square bracket is for myMusic. but you put it at the end of an data entry where as you should put a curly bracket
llamatarianism
@llamatarianism
Jul 18 2016 03:39
and you have a semicolon after the 2nd item instead of a comma
powell956
@powell956
Jul 18 2016 03:39

Hey there!
In the "Profile Lookup" exercise in the Javascript lessons, I've submitted an answer that I'm pretty sure is right (it works in the console), but the exercise still counts it as wrong.
Here's what I've got:


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


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


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

Has anyone else had trouble with this, or can you recreate it? Is this a bug?

llamatarianism
@llamatarianism
Jul 18 2016 03:40
hmmm, that's weird
Kevin
@KevinBruland
Jul 18 2016 03:40
@powell956 ill check
Ujjwal Nambiar
@UjjwalNambiar
Jul 18 2016 03:40
@Benalron @Cal-culator @llamatarianism Thanks everyone. I needed to put a comma after the first object (works similarly to arrays), and then add the semicolon to the last array bracket. Thanks!
CamperBot
@camperbot
Jul 18 2016 03:40
ujjwalnambiar sends brownie points to @benalron and @cal-culator and @llamatarianism :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for cal-culator
:star2: 1026 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
:cookie: 382 | @benalron |http://www.freecodecamp.com/benalron
Cal-culator
@Cal-culator
Jul 18 2016 03:40
@powell956 your condition should be contacts[i].hasOwnPropertyprop()=== true
its not checking any conditions right now.
Kevin
@KevinBruland
Jul 18 2016 03:41
@powell956 it doesnt work for the last two test
Cal-culator
@Cal-culator
Jul 18 2016 03:42
I am going to leave the helping to more experienced people :)
llamatarianism
@llamatarianism
Jul 18 2016 03:42
@powell956 shouldn't have full stops
"No such contact."; "No such contact.";
powell956
@powell956
Jul 18 2016 03:43
@llamatarianism that did it!
thank you
Jose A. Mejia
@ariel035
Jul 18 2016 03:43
need help with the challenge of converting farenheit to celsius algorithm
powell956
@powell956
Jul 18 2016 03:43
is there any way we can get that changed?
llamatarianism
@llamatarianism
Jul 18 2016 03:46
submit a github issue
it really ought to be a regex or something
Cal-culator
@Cal-culator
Jul 18 2016 03:56
@ariel035 post it
powell956
@powell956
Jul 18 2016 03:57
done!
thanks again!
Cal-culator
@Cal-culator
Jul 18 2016 03:58
@powell956 llamatarianism solves everything. I mean EVERYTHING.
Luke Bailey
@baileyl91
Jul 18 2016 03:59
This message was deleted
kevinstonge
@kevinstonge
Jul 18 2016 04:00

I've added onclick="quoteFetch()" to my html, but the jQuery notation is returning errors (e.g., "on is not a function") my code looks like some variant of this:

$("#getQuote").on("click", quoteFetch());

what's wrong with this?

html says <button id="getQuote"> ...
Luke Bailey
@baileyl91
Jul 18 2016 04:02
This message was deleted
kevinstonge
@kevinstonge
Jul 18 2016 04:02
console says: "Uncaught TypeError: $(...).on is not a function"
Luke Bailey
@baileyl91
Jul 18 2016 04:03

I'm doing the Accessing Nested Objects lesson.
I'm struggling to understand where I'm going wrong.
Here my code:

myStorage.car.inside["glove box"];

Greg Duncan
@GregatGit
Jul 18 2016 04:03
@kevinstonge have you added jQuery?
kevinstonge
@kevinstonge
Jul 18 2016 04:04
@GregatGit yes: <script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
@baileyl91 can you paste the entire code below the change line?
Greg Duncan
@GregatGit
Jul 18 2016 04:05
@kevinstonge try
$("#getQuote").click( quoteFetch);
mswartz-fcc
@mswartz-fcc
Jul 18 2016 04:05
@powell956
Luke Bailey
@baileyl91
Jul 18 2016 04:05

@kevinstonge

 myStorage.car.inside["glove box"];

var gloveBoxContents = "";

I'm going by following an example provided

kevinstonge
@kevinstonge
Jul 18 2016 04:06

you've got to combine those two lines into one expression - set var gloveBoxContents = myStorage.car.inside["glvoe box"];

it's checking the value of that variable

@GregatGit that doesn't return any errors, but it also doesn't change the quote when I press the button.
mswartz-fcc
@mswartz-fcc
Jul 18 2016 04:07
@powell956 --- You don't have nearly enough code to solve this challenge. Here's my solution that worked.
function lookUpProfile(firstName, prop){
  // load 'firstNames' into an array
  var getFirstNames = [];
  for (var i = 0; i < contacts.length; i++) {
    getFirstNames.push(contacts[i].firstName);
  }

  // check if passed in 'firstName' exists
  var nameExists = false;
  var getIndex = -1;
  for (var j = 0; j < getFirstNames.length; j++) {
    if (firstName === getFirstNames[j]) {
      nameExists = true;
      getIndex = j;
    }
  }

  // if 'firstName' doesn't exist return "No such contact"
  if (nameExists === false) {
    return "No such contact";
  }

  // if 'firstName' exists check if 'prop' exists
  var propList = ["firstName", "lastName", "number", "likes"];
  propExists = false;
  if (nameExists === true) {
    for (var k = 0; k < propList.length; k++) {
      if (prop === propList[k]) {
        propExists = true;
      }
    }
  }

  // if 'prop' doesn't exists return "No such property"
  if (propExists === false) {
    return "No such property";
  }

  // if 'firstName' and 'prop' exist return value of 'prop'
  if (nameExists === true && propExists === true) {
    return contacts[getIndex][prop];
  }
}
Greg Duncan
@GregatGit
Jul 18 2016 04:07
@kevinstonge can i see your pen
kevinstonge
@kevinstonge
Jul 18 2016 04:07
@GregatGit I was writing it in atom to test ... but give me aminute and I'll paste it in :)
Luke Bailey
@baileyl91
Jul 18 2016 04:08
@kevinstonge
Ahh right, now it make sense
Thanks for your help
CamperBot
@camperbot
Jul 18 2016 04:08
baileyl91 sends brownie points to @kevinstonge :sparkles: :thumbsup: :sparkles:
:cookie: 275 | @kevinstonge |http://www.freecodecamp.com/kevinstonge
kevinstonge
@kevinstonge
Jul 18 2016 04:09
mswartz-fcc
@mswartz-fcc
Jul 18 2016 04:10
@powell956 --- posted my solution.
Greg Duncan
@GregatGit
Jul 18 2016 04:11

@kevinstonge

$("#getQuote").click(quoteFetch);

seems to work now

kevinstonge
@kevinstonge
Jul 18 2016 04:11
what do you mean? it's not working...
it's working for you?
Greg Duncan
@GregatGit
Jul 18 2016 04:12
don't have the () after quoteFetch
and yes its working
kevinstonge
@kevinstonge
Jul 18 2016 04:13
Oh, it's working on codepen, but not for me in Chrome via a local htm file
Any idea why?
Greg Duncan
@GregatGit
Jul 18 2016 04:16
What error do you get in your console
kevinstonge
@kevinstonge
Jul 18 2016 04:16
no error, just a button that doesn't respond
DJ
@qualitymanifest
Jul 18 2016 04:16
@kevinstonge have you linked jquery and bootstrap.js properly on that local file?
kevinstonge
@kevinstonge
Jul 18 2016 04:16
same exact code, same jquery version (2.2.4.min) ...
DJ
@qualitymanifest
Jul 18 2016 04:16
hm
kevinstonge
@kevinstonge
Jul 18 2016 04:16
well here is how I link jquery: <script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
Greg Duncan
@GregatGit
Jul 18 2016 04:17
@kevinstonge I would check make a small function that puts up a simple alert and see if that works by clicking on the button
kevinstonge
@kevinstonge
Jul 18 2016 04:18
@GregatGit that function pops up on page load for some reason.
Greg Duncan
@GregatGit
Jul 18 2016 04:18
so create another function and see if that can work
DJ
@qualitymanifest
Jul 18 2016 04:19
@kevinstonge i doubt this would be it, but you have two quotation marks after getQuote here <p class="text-success"><button class="btn-info" id="getQuote"">
kevinstonge
@kevinstonge
Jul 18 2016 04:21
good eye - damned auto formatting did that. but didn't fix it :|
why is it loading the .click event on page load?
this is Chrome
DJ
@qualitymanifest
Jul 18 2016 04:22
@kevinstonge do you have all of your code in one file, or separate files for html, css, js? not that that's an issue, just wondering if it would be easy to plop the whole thing into a JSfiddle or something
kevinstonge
@kevinstonge
Jul 18 2016 04:22
same behavior in Edge
all in one file
I pasted the code from my .htm file into codepen, so what you see there should be the same with the exception of how specifically jquery and bootstrap are called by codepen
DJ
@qualitymanifest
Jul 18 2016 04:23
@kevinstonge wanna a fiddle or codepen? just paste exactly what you have all in the HTML section
*wanna create
i know, i'm just curious. something sounds bizarre and i wanted to try it locally
you know what ... does it work if the .click event is at the very bottom of the file?
nope
does it need to be inside the .ready listener?
kevinstonge
@kevinstonge
Jul 18 2016 04:29
that infinite looped ... it's loading .click on page load
you can see it load two quotes on run
DJ
@qualitymanifest
Jul 18 2016 04:32
@kevinstonge i'm just grasping at straws right now haha.
kevinstonge
@kevinstonge
Jul 18 2016 04:33
same behavior with this instead: $(document).on("click","#getQuote",quoteFetch());
THIS WORKS! $(document).on("click","#getQuote",quoteFetch);
but WHY?! :) :)
@qualitymanifest ^^^
DJ
@qualitymanifest
Jul 18 2016 04:36
@kevinstonge works now too, with the button selector and the jquery click func
@kevinstonge wanna paste your original code back in there real quick?
i just wanna re-try the changes and see what made the difference
kevinstonge
@kevinstonge
Jul 18 2016 04:38
yeah, let me know ... this is insane :)
I see you put everything in document.ready .. called the function ... then set the click listener
I changed <button> to <em> while I was tinkering with the htm. .. doesn't really make a difference though
DJ
@qualitymanifest
Jul 18 2016 04:40
@kevinstonge yeah, i think the things that made the difference were putting everything in the document ready, and getting rid of the () at $("#getQuote").click(quoteFetch());
kevinstonge
@kevinstonge
Jul 18 2016 04:41
Thanks @qualitymanifest that's some quality troubleshooting!
CamperBot
@camperbot
Jul 18 2016 04:41
kevinstonge sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1287 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Jul 18 2016 04:43
@kevinstonge np :+1:
Naveen L Bhandari
@naveenlb
Jul 18 2016 04:48
error2.jpg
guys need help like above
i tried without space too.
eeflores
@eeflores
Jul 18 2016 04:51
@naveenlb no spaces, and capital "L" in "ThirdLine"
Naveen L Bhandari
@naveenlb
Jul 18 2016 04:52
@eeflores Thanks
CamperBot
@camperbot
Jul 18 2016 04:52
naveenlb sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:cookie: 809 | @eeflores |http://www.freecodecamp.com/eeflores
Nelya
@NankaBananka
Jul 18 2016 04:52
find Check for Palindromes
CamperBot
@camperbot
Jul 18 2016 04:52
find check for palidromes
nothing found
eeflores
@eeflores
Jul 18 2016 04:53
wiki palindrome
CamperBot
@camperbot
Jul 18 2016 04:53

:point_right: algorithm check for palindromes [wiki]

Algorithm Check for Palindromes

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

Our goal for solving this problem is tidying up the string passed in, and checking whether it is in fact a palindrome.

  • If you are unsure of what a palindrome is, it is a word or phrase that when reversed spells the same thing forwards or backwards. A simple example is mom, when you reverse the letters, it spells the same thing! Another example of a palindrome is race car. When we take out anything that is not a character it becomes racecar which is the same spelled forwards or backwards!

Once we have determined whether it is a palindrome or not we want to return either true or false based on our findings.

Relevant Links

:pencil: read more about algorithm check for palindromes on the FCC Wiki

Nick Irvine
@irvin3
Jul 18 2016 04:59
anyone know how to loop through a decreasing length array?
I'm using a while loop to decrease and update an array, the array length decreases each time the while loop completes, and I want to keep running the while loop until the array length is =1
kevinstonge
@kevinstonge
Jul 18 2016 05:00
in your for loop, array.length will adapt to the changing size of an array, although that's a bit dangerous, if you mess up your code you might end up with an infinite loop.
Nick Irvine
@irvin3
Jul 18 2016 05:01
I've tried like every version of using array.length to maintain a loop, but it isnt working properly
i can get the array.length to produce the new array length after the while loop has completed, i feel like i must be missing something about how to use that new length in either a while loop or for loop
Pericles
@periman2
Jul 18 2016 05:03
@irvin3 just use another variable to loop the which is equal to the times you want the thing to loop
can you give your code?
Nick Irvine
@irvin3
Jul 18 2016 05:04
function smallestCommons(arr) {
    //switches arr from low to high if not already
    if (arr[0] > arr[1]) {
        arr.push(arr[0]);
        arr.shift();
    }
    //creates an array from low to high of all numbers between arr0 and arr1 inclusive
    var low = arr[0];
    var high = arr[1];
    var newArr = [];
    for (var i = low; i <= high; i++) {
        newArr.push(i);
    }

    //finds the least common multiple of newArr[0]and newArr[1], removes both
    //newArr[0] and newArr[1] and adds their least common multiple to the newArr[0] pos

    var zero = newArr[0];
    var one = newArr[1];
    console.log(newArr[0]);
    while (zero !== one) {
        zero += newArr[0];
        if (zero === one) {
            newArr.shift();
            newArr.shift();
            newArr.unshift(zero);

        } else {
            one += newArr[1];
        }

    }
    console.log(newArr);
}

smallestCommons([5, 2]);
this code will output the least common denominator of the first two elements, I just cant get that damn while loop to run again with the new number as the [0] position
Pericles
@periman2
Jul 18 2016 05:07
@irvin3 hm I'm sorry I don't know how to help you right now it's a bit beyond me so far I haven't done this challenge
Nick Irvine
@irvin3
Jul 18 2016 05:08
ahh man okay, yea my code is like complete as far as the real difficulty of understanding it, I just need to figure a way to keep running that while loop
Markus Kiili
@Masd925
Jul 18 2016 05:12
@irvin3 I can't grasp the logic of what you are doing. How are you testing that a number is evenly divisible by all the numbers in the given range?
Greg Duncan
@GregatGit
Jul 18 2016 05:12
@irvin3 have you seen math.min(num1, num2) - it returns the lowest number and math.max does the opposite
Subramanya Chakravarthy
@chakrihacker
Jul 18 2016 05:17
help caesars
CamperBot
@camperbot
Jul 18 2016 05:17

:point_right: algorithm caesars cipher [wiki]

Algorithm Caesars Cipher

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

  • You need to write a function, which will take a string encoded with Caesar cipher as a parameter and decode it.
  • The one used here is ROT13 where the value of the letter is shifted by 13 places. e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
  • You have to shift it back 13 positions, such that 'N' ↔ 'A'.

Relevant Links

:pencil: read more about algorithm caesars cipher on the FCC Wiki

Nick Irvine
@irvin3
Jul 18 2016 05:19
@Masd925 the logic that i thought of is that you find the least common multiple of the first two elements of an array, remove the first two elements, then put the least common denominator of those two elements as the array[0] position
keep doing that until you are left with one number, that is a way to find the least common multiple, i just dont know how to keep running the while loop multiple times
@GregatGit yea thanks for reminding me, i will go back and make the code simpler later, im just trying to hash together this last bit
CamperBot
@camperbot
Jul 18 2016 05:21
irvin3 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 693 | @gregatgit |http://www.freecodecamp.com/gregatgit
Sudipta Roy
@sudipta7
Jul 18 2016 05:27
help collection
CamperBot
@camperbot
Jul 18 2016 05:27

:point_right: challenge record collection [wiki]

Challenge Record Collection

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

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, check to see if the given element in the array has the property of "tracks". If the element has the property of "tracks", push the value onto the end of the "tracks" array. If the element does not have the property, create the property and value pair.

If value is blank, delete that prop.

Always return the entire collection object.

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

Nick Irvine
@irvin3
Jul 18 2016 05:28
nevermind for now, need to revise my code, just came across a bug
Farrukh
@Farrukhw
Jul 18 2016 05:35
Escape sequence in Javascript
Zauri3645
@Zauri3645
Jul 18 2016 05:55
Question
Storing Values with the Assignment Operator
Sergey Belozyorcev
@belozyorcev
Jul 18 2016 05:55

@belozyorcev I suppose a simple way to do that is "aaabbsdd24vhvfdfaaa".split("aaa").map(v=>v===""?"aaa":v);
But there are probably better ways.

@BKinahan thanks. And how to apply it to regular expressions? "aaabbsdd24vhvfdfaaa".split("/aaa|bb/g")

CamperBot
@camperbot
Jul 18 2016 05:55
belozyorcev sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 2016 | @bkinahan |http://www.freecodecamp.com/bkinahan
Zauri3645
@Zauri3645
Jul 18 2016 05:56

// Setup
var a;
var b = 2;

// Only change code below this line
var a = 7, b = 7;

a should be assigned to b with =
solve tis?
Zauri3645
@Zauri3645
Jul 18 2016 06:02
Hello
kirbyedy
@kirbyedy
Jul 18 2016 06:02
what is the question ? @Zauri3645
Zauri3645
@Zauri3645
Jul 18 2016 06:03
Storing Values with the Assignment Operator
kirbyedy
@kirbyedy
Jul 18 2016 06:05
Assigns 5 to myVar and then resolves myVar to 5 again and assigns it to myNum.
Zauri3645
@Zauri3645
Jul 18 2016 06:06
i dont understand that
kirbyedy
@kirbyedy
Jul 18 2016 06:06
so a should be 7, and b should be a
Zauri3645
@Zauri3645
Jul 18 2016 06:06
:/
kirbyedy
@kirbyedy
Jul 18 2016 06:06
assign 7 to a
first
then
assign b to a
assign is this: =
nickpuma
@nickpuma
Jul 18 2016 06:07
Anyone have tips for the "No repeats please" challenge?
Nick Irvine
@irvin3
Jul 18 2016 06:10
finally fixed my code for that smallest common multiple bonfire, feels so good
Greg Duncan
@GregatGit
Jul 18 2016 06:12
@irvin3 :fire:
nickpuma
@nickpuma
Jul 18 2016 06:13
Thanks @Masd925
CamperBot
@camperbot
Jul 18 2016 06:13
nickpuma sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2132 | @masd925 |http://www.freecodecamp.com/masd925
Nick Irvine
@irvin3
Jul 18 2016 06:15
hmm i dont know why fcc isnt accepting it though, it passes all the test cases. (although the code is a bit slow)
Markus Kiili
@Masd925
Jul 18 2016 06:16
@irvin3 On that challenge, slow enough algorithm can cause that.
Nick Irvine
@irvin3
Jul 18 2016 06:18
damn, im running it in Atom and it takes like around .8 seconds to finish the really large numbers
Markus Kiili
@Masd925
Jul 18 2016 06:19
@irvin3 You are not using any global variables?
Nick Irvine
@irvin3
Jul 18 2016 06:20
i used a global to set the first and second elements of the array
Dany Din
@danydin
Jul 18 2016 06:20
@Masd925 differnce between str.slice(' '); str.prototype.slice(' ');?
Markus Kiili
@Masd925
Jul 18 2016 06:20
@irvin3 Using global variables usually messes up FCC tests.
Nick Irvine
@irvin3
Jul 18 2016 06:21
I feel like i cant change my code to not use global tho?
Markus Kiili
@Masd925
Jul 18 2016 06:21
@danydin You mean String.prototype.slice(' ')
Dany Din
@danydin
Jul 18 2016 06:21
yes @Masd925
Markus Kiili
@Masd925
Jul 18 2016 06:21
@irvin3 You can always make a wrapper function.
Nick Irvine
@irvin3
Jul 18 2016 06:22
@Masd925 whats that like? i dont know that im familiar
Markus Kiili
@Masd925
Jul 18 2016 06:23
@irvin3 Make an inner function with all that code you have. Outer function is smallestCommons and it has the variables and calls that inner function.
Nick Irvine
@irvin3
Jul 18 2016 06:26
@Masd925 thanks for the advice, i looked a few examples and feel kinda lost
CamperBot
@camperbot
Jul 18 2016 06:26
irvin3 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2133 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jul 18 2016 06:27
@danydin String.prototype is an object with all the string methods. All strings use them along the prototype chain. You can use a method straight from the prototype object if you fear that some code might have overwritten the method:
var str = "abc";
str.slice(1); // 'bc'
String.prototype.slice.call(str,1); // 'bc'
Markus Kiili
@Masd925
Jul 18 2016 06:32
@danydin Here is an example where some code overwrites the array toString method and you like to use the original object toString method:
Array.prototype.toString = function () {
    return "catpants";
};

var arr = [1,2,3];

console.log(arr.toString()); // 'catpants'
console.log(Object.prototype.toString.call(arr)); // [object Array]
All arrays have prototype chain -> Array.prototype -> Object.prototype -> null
santosh
@santoshnavle
Jul 18 2016 06:33
In freecodecamp -> Convert Celsius to Fahrenheit not understanding
please help
Demon000
@Demon000
Jul 18 2016 06:34
@santoshnavle What problem are you encountering?
santosh
@santoshnavle
Jul 18 2016 06:34
i don't understand how to write code
Nick Irvine
@irvin3
Jul 18 2016 06:35
lol
santosh
@santoshnavle
Jul 18 2016 06:35
@Demon000 thanks
CamperBot
@camperbot
Jul 18 2016 06:35
santoshnavle sends brownie points to @demon000 :sparkles: :thumbsup: :sparkles:
:cookie: 687 | @demon000 |http://www.freecodecamp.com/demon000
Demon000
@Demon000
Jul 18 2016 06:35
Well, you have instruciton on theleft side.
santosh
@santoshnavle
Jul 18 2016 06:36
ok
Demon000
@Demon000
Jul 18 2016 06:36
just define a variable Fahrenheit that is equal to Celsius times 9, divided by 5, plus 32.
santosh
@santoshnavle
Jul 18 2016 06:37
ok thanks @Demon000
CamperBot
@camperbot
Jul 18 2016 06:37
santoshnavle sends brownie points to @demon000 :sparkles: :thumbsup: :sparkles:
:warning: santoshnavle already gave demon000 points
Demon000
@Demon000
Jul 18 2016 06:37
No problem.
Nick Irvine
@irvin3
Jul 18 2016 06:38
@Masd925 would you mind helping me get started on the wrapper function?
Demon000
@Demon000
Jul 18 2016 06:39
@irvin3 I can help too. :D
Nick Irvine
@irvin3
Jul 18 2016 06:39
that would be awesome!
Demon000
@Demon000
Jul 18 2016 06:40
@irvin3 What needs to be done?
Nick Irvine
@irvin3
Jul 18 2016 06:40
do you wanna get a look at my code @Demon000
Demon000
@Demon000
Jul 18 2016 06:40
Sure.
Nick Irvine
@irvin3
Jul 18 2016 06:40
I have working code but fcc isnt passing it because it may be too slow or something
function smallestCommons(arr) {
    //switches arr from low to high if not already
    if (arr[0] > arr[1]) {
        arr.push(arr[0]);
        arr.shift();
    }
    //creates an array from low to high of all numbers between arr0 and arr1 inclusive
    var low = arr[0];
    var high = arr[1];
    var newArr = [];
    for (var i = low; i <= high; i++) {
        newArr.push(i);
    }


//loops through every element in the array and deals with it decreasing in length
    while (1 < newArr.length) {

        var zero = newArr[0];
        var one = newArr[1];
        //finds the least common multiple of newArr[0]and newArr[1], removes both
        //newArr[0] and newArr[1] and adds their least common multiple to the newArr[0] pos
        while (zero !== one) {

            if (zero % newArr[1] === 0) {
                one = zero;
            }
            if (zero === one) {
                newArr.shift();
                newArr.shift();
                newArr.unshift(zero);

            } else {
                one += newArr[1];
                zero += newArr[0];
            }
        }
    }
    console.log(newArr);
}

smallestCommons([23, 18]);
llamatarianism
@llamatarianism
Jul 18 2016 06:41
your code doesn't return anything
Nick Irvine
@irvin3
Jul 18 2016 06:41
replace console.log with return. im testing in atom
Markus Kiili
@Masd925
Jul 18 2016 06:42
@irvin3 You don't have any global variables.
Nick Irvine
@irvin3
Jul 18 2016 06:43
i thought that var zero and var one were global? I must not understand what a global is
Markus Kiili
@Masd925
Jul 18 2016 06:43
@irvin3 Seems that you are using one of the math solutions, so speed should not be a problem.
@irvin3 They are declared inside a function with var, so they are local variables inside the function. JS has function scope.
Nick Irvine
@irvin3
Jul 18 2016 06:44
@Masd925 ohhh yea duh okay
this is really strange then, i get all the of the correct results, fcc just wont give me the green popup
llamatarianism
@llamatarianism
Jul 18 2016 06:45
are you sure you're supposed to be returning an array?
I can't remember but I'm pretty sure you're meant to return a number
Nick Irvine
@irvin3
Jul 18 2016 06:45
thats probably it
Markus Kiili
@Masd925
Jul 18 2016 06:46
Yes, a number should be returned.
Nick Irvine
@irvin3
Jul 18 2016 06:46
yep, haha thanks @llamatarianism
CamperBot
@camperbot
Jul 18 2016 06:46
irvin3 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1027 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Demon000
@Demon000
Jul 18 2016 06:47
Welp, haven't really helped.
I spent time loking at my solution for that problem just to get a hang of what you should be doing.
And, gosh, your code is so long.
Deepak Yadav
@ydeepk
Jul 18 2016 06:48

Html entites challlange

What I'm doing wrong ??

my code is

function convertHTML(str) {
// :)
// matching object
var match, change, split = str.split(" ");

match = /&+|<+|>+|'+|"+/g;

split.forEach(function(key) {
switch(key) {
case "&": change = "&"; break;
case "<": change = "<"; break;
case ">": change = ">"; break;
case "'": change = "'"; break;
case '"': change = """; break;
}
});

return str.replace(match, change);
}

convertHTML('Stuff in "quotation marks"');

works for all cases except these

  1. ) convertHTML('Stuff in "quotation marks"')
    should return
    -> Stuff in &​quot;quotation marks&​quot;.
    2.) convertHTML("Shindler's List")
    should return
    -> Shindler&​apos;s List.
    3.) convertHTML("<>")
    should return
    -> &​lt;&​gt;

Help me please.

Demon000
@Demon000
Jul 18 2016 06:48
explain format
CamperBot
@camperbot
Jul 18 2016 06:48

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Demon000
@Demon000
Jul 18 2016 06:49
@ydeepk You are not replacing those with entities.
W8.
Nvm.
Deepak Yadav
@ydeepk
Jul 18 2016 06:49
@Demon000 ??
@Demon000 what do yu suggest??
Demon000
@Demon000
Jul 18 2016 06:50
Shouldn't be using something like
        '&':'&amp;',
        '<': '&lt;',
        '>': '&gt;',
        '"': '&quot;',
        "'": '&apos;'
Deepak Yadav
@ydeepk
Jul 18 2016 06:50
@Demon000 what should be used??
Demon000
@Demon000
Jul 18 2016 06:50
THose are the html entities.
You are replacing & with &, I don;t really get it and I'm sure that's not really safe, even if it works.
Nick Irvine
@irvin3
Jul 18 2016 06:51
maybe simple answer...but cant i just used toString to turn the array into a number?
Demon000
@Demon000
Jul 18 2016 06:51
No.
toString just gives you [object Object] I believe
Nick Irvine
@irvin3
Jul 18 2016 06:52
oh true yea thats a string
Markus Kiili
@Masd925
Jul 18 2016 06:53
@irvin3 return newArr[0];
Deepak Yadav
@ydeepk
Jul 18 2016 06:53
@Demon000 so what method should be applied here??
Nick Irvine
@irvin3
Jul 18 2016 06:54
im gonna call it a night after passing that over haha, thanks again @Masd925
CamperBot
@camperbot
Jul 18 2016 06:54
irvin3 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: irvin3 already gave masd925 points
Demon000
@Demon000
Jul 18 2016 06:54
@ydeepk Repalce & with its html entity, which is &amp;, I gave you the entities earlier.
kevinstonge
@kevinstonge
Jul 18 2016 06:55
$.getJSON("https://api.forecast.io/forecast/65fa3e4f3efe5c1c37f5ecbc6feb3dcc/41.5643,-72.5023", function(json) { console.log("hi"); }); it won't enter the function! What have I done wrong? If I navigate to that URL, I can see a plaintext JSON object loaded with data!
llamatarianism
@llamatarianism
Jul 18 2016 06:56
is it actually getting executed
kevinstonge
@kevinstonge
Jul 18 2016 06:57
no "hi"
llamatarianism
@llamatarianism
Jul 18 2016 06:57
no
I meant
SBeard
@etacalpha
Jul 18 2016 06:57
Does anyone have time to help me with a map method question?
llamatarianism
@llamatarianism
Jul 18 2016 06:57
is $.getJSON actually getting executed
kerentang
@kerentang
Jul 18 2016 06:57
hello, I have a question about counting cards, I have no idea how to write that code to pass it ,I tried to use switch() but it didnt work ? would you tell me which loop I should use? if()?or
Demon000
@Demon000
Jul 18 2016 06:57
Is it just me or writing amazingly short and non intelligible solution feels good?
var convertHTML = str => str.split('').map(val => new Object({
        '&':'&amp;',
        '<': '&lt;',
        '>': '&gt;',
        '"': '&quot;',
        "'": '&apos;'
      })[val] || val).join('');

convertHTML("Dolce & Gabbana");
@etacalpha Sure.
Markus Kiili
@Masd925
Jul 18 2016 06:58
@kerentang Switch, if's, lookup object.
llamatarianism
@llamatarianism
Jul 18 2016 06:58
pssshhhh
I can write more unintelligibly
Demon000
@Demon000
Jul 18 2016 06:59
ME too.
kerentang
@kerentang
Jul 18 2016 06:59
maybe there is a function about counting
i dont know
how to count
llamatarianism
@llamatarianism
Jul 18 2016 07:00
`=$=>$==[]?+!![]:$*(-~$)
oops
Justin
@JustinGaravel
Jul 18 2016 07:00
function lookUpProfile(firstName, prop){
// Only change code below this line

  if ((firstName == contacts.firstName) && contacts.hasOwnProperty(prop)) {
    return contacts[prop];
  }
Hi all,
I'm trying to get this function to check an array of objects called contacts to see if the firstName parameter and the firstName key in the array match, and then I'm checking to see if the prop exists in that object...but I have a feeling I'm going in the wrong direction...
Demon000
@Demon000
Jul 18 2016 07:00
var convertHTML = str => str.split``.map(val => new Object({'&':'&amp;','<': '&lt;','>': '&gt;','"': '&quot;',"'": '&apos;'})[val] || val).join``;
llamatarianism
@llamatarianism
Jul 18 2016 07:00
_=$=>$==[]?+!![]:$*_(-~$)
go ahead, try and tell me what it does
Vyvojar123
@Vyvojar123
Jul 18 2016 07:00
hello. I have webpage where an user can show data from database. In some cases it takes long time. How can I add javascript, which show the text during loading results?
Demon000
@Demon000
Jul 18 2016 07:02
@llamatarianism Some next level stuff you've got there.
llamatarianism
@llamatarianism
Jul 18 2016 07:02
`_=$=>$<=!![]
damnit
stupid app
=$=>$<=!![]?+!![]:_(-~$)+($-!![]-!![])
Demon000
@Demon000
Jul 18 2016 07:03
eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('5 4=1=>1.2``.3(0=>6 d({\'&\':\'&7;\',\'<\':\'&b;\',\'>\':\'&a;\',\'"\':\'&8;\',"\'":\'&9;\'})[0]||0).c``;',14,14,'val|str|split|map|convertHTML|var|new|amp|quot|apos|gt|lt|join|Object'.split('|'),0,{}))
llamatarianism
@llamatarianism
Jul 18 2016 07:04
_=$=>$<=!![]?+!![]:_(-~$)+_($-!![]-!![])
there
screw this app and its inability to edit messages
Demon000
@Demon000
Jul 18 2016 07:04
I know.
Screenshot_2016-07-18_10-05-57.png
Works like a charm.
The errors are not errors at all, lol.
llamatarianism
@llamatarianism
Jul 18 2016 07:06
positively disgusting 👌💯 I approve
Vyvojar123
@Vyvojar123
Jul 18 2016 07:06
I have webpage where an user can show data from database. In some cases it takes long time. How can I add javascript, which show the text during loading results?
Bernardo DeLuca
@BernardoDeLuca
Jul 18 2016 07:06

Hi Everyone! I'm stumped in a Basic Javascript challenge, as I'm unsure how to handle the function below which has two arguments. I think I'm missing something very obvious, but I don't see it... :) Challenge details and my code are below:

In the game of golf each hole has a par meaning the average number of strokes a golfer is expected to make in order to sink the ball in a hole to complete the play. Depending on how far above or below par your strokes are, there is a different nickname.

Your function will be passed par and strokes arguments. Return the correct string according to this table which lists the strokes in order of priority; top (highest) to bottom (lowest):

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

= par + 3 "Go Home!"

par and strokes will always be numeric and positive.

Here is what I came up with, but not sure how to deal with "par" argument...

function golfScore(par, strokes) {

if (strokes == 1) {

return "Hole-in-one!";
}
else if (strokes <= (par -2)) {

return "Eagle";
}

else if (strokes == (par -1)) {

return "Birdie";
}

else if (strokes == par) {

return "Par";
}

else if (strokes == (par + 1)) {

return "Bogey";
}

else if (strokes == (par + 2)) {

return "Double Bogey";
}

else {

return "Eagle";
}

}

Zauri3645
@Zauri3645
Jul 18 2016 07:07
blob
solve this please
Demon000
@Demon000
Jul 18 2016 07:07
explain format
explain format
CamperBot
@camperbot
Jul 18 2016 07: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 thecode`.

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

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

Lee
@leebut
Jul 18 2016 07:08
@xxjeep I think you need to access your array using a loop to loop through the contacts.firstName and test the 'prop' keys.
Demon000
@Demon000
Jul 18 2016 07:08
I've written explain format like 10000 times.
@Zauri3645 myVar++;
Cal-culator
@Cal-culator
Jul 18 2016 07:09
How do i fix this?
```
TypeError: undefined is not an object (evaluating 'a[i][j].pop')
Lee
@leebut
Jul 18 2016 07:10
@Zauri3645 Follow the instructions.
Justin
@JustinGaravel
Jul 18 2016 07:10

@leebut thanks ```

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

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

``` I got this far, where I realized I need to loop through all the firstNames to test the keys, but now I need to

CamperBot
@camperbot
Jul 18 2016 07:10
xxjeep sends brownie points to @leebut :sparkles: :thumbsup: :sparkles:
:cookie: 246 | @leebut |http://www.freecodecamp.com/leebut
Vyvojar123
@Vyvojar123
Jul 18 2016 07:10
I have found this for loading http://github.hubspot.com/pace/docs/welcome/ but it does not work properly I need to indicate loading after clicking on a button
kevinstonge
@kevinstonge
Jul 18 2016 07:10
@llamatarianism is there a way to test if $.getJSON is being executed? I'm pretty sure it is, it's the only thing in my <script> right now and the api provider actually has a count of how many times the api is accessed and it shows a hit every time I run the script.
Justin
@JustinGaravel
Jul 18 2016 07:10

@leebut thanks

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

I got this far, where I realized I need to loop through all the firstNames to test the keys, but now I need to

CamperBot
@camperbot
Jul 18 2016 07:10
xxjeep sends brownie points to @leebut :sparkles: :thumbsup: :sparkles:
:warning: xxjeep already gave leebut points
Zauri3645
@Zauri3645
Jul 18 2016 07:10
@Demon000 in which myVar?
Cal-culator
@Cal-culator
Jul 18 2016 07:11
How do i fix this?
TypeError: undefined is not an object (evaluating 'a[i][j].pop')
Lee
@leebut
Jul 18 2016 07:11
@Zauri3645 You haven't used ++
Zauri3645
@Zauri3645
Jul 18 2016 07:11
@leebut still i cant solve this
@leebut
blob
like this?
Lee
@leebut
Jul 18 2016 07:14
@Zauri3645 ++ is the same as +1, which one don't you need?
Sorry, myVar++ is the same as myVar = myVar +1
Demon000
@Demon000
Jul 18 2016 07:15
@Zauri3645 Just myVar++;. Nothign else.
Zauri3645
@Zauri3645
Jul 18 2016 07:16
Ahh Thanx @Demon000 it worked
CamperBot
@camperbot
Jul 18 2016 07:16
zauri3645 sends brownie points to @demon000 :sparkles: :thumbsup: :sparkles:
:cookie: 688 | @demon000 |http://www.freecodecamp.com/demon000
Demon000
@Demon000
Jul 18 2016 07:16
:D
Zauri3645
@Zauri3645
Jul 18 2016 07:16
And thank you too @leebut
CamperBot
@camperbot
Jul 18 2016 07:16
zauri3645 sends brownie points to @leebut :sparkles: :thumbsup: :sparkles:
:cookie: 247 | @leebut |http://www.freecodecamp.com/leebut
Zauri3645
@Zauri3645
Jul 18 2016 07:16
:)
Estelle
@estellelim
Jul 18 2016 07:16

function addTogether(x,y) {
  //CASE ONE: ARGUMENT.LENGTH == 2 BUT ARGUMENT[1] IS NOT A NUMBER ELSE SUM TWO NUMBERS TGT
  if(arguments.length == 2) {
    if(typeof (arguments[1]) !== "number") {
          return undefined;
        } // end if
      var total = arguments[0]+ arguments[1];
      return total; // add arguments first bracket e.g 0 + 2 =2 
      } // end if
  //CASE TWO: ARGUMENT.LENGTH == 1 BUT ARGUMENT[0] IS NOT A NUMBER
   if (typeof (arguments[0]) !== "number") {
      return undefined;
      } 
  }

addTogether(2)(3);
can someone help me with this, this is Arguments Optional. It returns ```TypeError: addTogether(...) is not a function.
Justin
@JustinGaravel
Jul 18 2016 07:17
  for (i = 0; i < contacts.length; i++) {
    while (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    }
  }
I've created a function that looks through contacts array and returns the property if it exists and if firstName corresponds to the one we're looking for. If firstName doesn't correspond to anything in the array I need it to return a string saying it doesn't. Can this be done with a while loop? I think this cannot be done from within the same while loop
Lee
@leebut
Jul 18 2016 07:17
@Zauri3645 I was trying to help you solve it yourself rather than simply give the answer. You're welcome. :)
Markus Kiili
@Masd925
Jul 18 2016 07:19
@estellelim If you pass one argument into addTogether, like addTogether(2) here, it should return a function. Are you doing it?
Demon000
@Demon000
Jul 18 2016 07:19
@Zauri3645 So, myVar++;, ++myVar;, myVar += 1; and myVar = myVar + 1; do the same thing. There are some quirks when using myVar++;, but for now I'll let you find them by yourself.
@leebut I was writing explanation.
@leebut There was like nothing to solve, just to understand that you can write the same thing in multiple ways.
Markus Kiili
@Masd925
Jul 18 2016 07:20
@estellelim JS functions return undefined by default, so you can just make two tests for one and two valid arguments.
Estelle
@estellelim
Jul 18 2016 07:21
@Masd925 like this?
if (typeof (arguments[0]) !== "number") {
      return undefined;
      } 
    var ans = function() {
      ans += arguments[0];
    };
  return ans();
  }
SmoothMove2000
@SmoothMove2000
Jul 18 2016 07:21
how do i make a varible called difference = 12;
Demon000
@Demon000
Jul 18 2016 07:22
return ans(){};
You are declaring a fucntion, it must have a body.
funciton*
function*
Estelle
@estellelim
Jul 18 2016 07:22
i declared it before the return @Demon000
Demon000
@Demon000
Jul 18 2016 07:22
Wait.
Nevermind.
Estelle
@estellelim
Jul 18 2016 07:22
hahahaa ^^
Demon000
@Demon000
Jul 18 2016 07:23
var ans = function() {
      ans += arguments[0];
    };
How do you add something to a fucntion?
Markus Kiili
@Masd925
Jul 18 2016 07:23
@estellelim The simplest way to test is:
function addTogether() {
  if (arguments.length===2 && typeof(arguments[0])==='number' && typeof(arguments[1])==='number') return ????
  if (arguments.length===1 && typeof(arguments[0])==='number') return ????
}
Demon000
@Demon000
Jul 18 2016 07:24
I think I'm getting rusty.
Estelle
@estellelim
Jul 18 2016 07:24
@Masd925 thank you!
CamperBot
@camperbot
Jul 18 2016 07:24
estellelim sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2134 | @masd925 |http://www.freecodecamp.com/masd925
Justin
@JustinGaravel
Jul 18 2016 07:24

hi all, it seems if I remove the if else's this works fine:

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

...huh?

Estelle
@estellelim
Jul 18 2016 07:25
@Demon000 it's ok, thank you!
CamperBot
@camperbot
Jul 18 2016 07:25
estellelim sends brownie points to @demon000 :sparkles: :thumbsup: :sparkles:
:cookie: 689 | @demon000 |http://www.freecodecamp.com/demon000
Demon000
@Demon000
Jul 18 2016 07:25
Yay, brownies.
Justin
@JustinGaravel
Jul 18 2016 07:25
the first if seems to work fine then
  • else if's...
Markus Kiili
@Masd925
Jul 18 2016 07:26
@estellelim So you can just do those two positive tests and forget about returning undefined.
Estelle
@estellelim
Jul 18 2016 07:26
@Masd925 alright, i'll try again!
eddsaura
@eddsaura
Jul 18 2016 07:27
One fast question
Cal-culator
@Cal-culator
Jul 18 2016 07:27

function chunkArrayInGroups(arr, size) {
  var str=arr.join("");
  var k=0;
  var a=[];
  for (var i=0;i<Math.floor(str.length/size)+1;i++){
      a.push([]);
      if (str.length%size===0){
          for (var j=0;j<size;j++){
             a[i].push(arr[j+k]);

          }
    else if ((str.length%size)!==0){
        for (j=0;j<size-1;j++){
            a[i].push(arr[j+k]);
            for (var l=0;l<str.length-size;l++){
                a[i].push(arr[j+l]);
            }
        }

    }

          }
      k+=size;
  }
  return a;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4);
How do i fix this? It says "else keyword unexpected".
eddsaura
@eddsaura
Jul 18 2016 07:28
In the Profile Lookup excercice should I do a loop?
because I'm looking into an array
Pablo García
@Liion
Jul 18 2016 07:28

Hey there, so I'm at the challenge "Find the Longest Word in a String", I get a "Cannot read property length of undefined", whats wrong with the code?

function findLongestWord(str) {
var array = str.split(" ");
console.log(array + " " + array.length);

var longest = "";

for (var i=0; i <= array.length; i++) {
  if (array[i].length > longest.length){
    longest = array[i];
  }
}
var largo = longest.length;
return largo;

}
findLongestWord("The quick brown fox jumped over the lazy dog");

Markus Kiili
@Masd925
Jul 18 2016 07:28
@Cal-culator Check the if block braces.
@eddsaura Loop or iterate contacts.
Cal-culator
@Cal-culator
Jul 18 2016 07:28
@eddsaura what have you got so far?
eddsaura
@eddsaura
Jul 18 2016 07:28
I did an if but it doesn't have sense
Cal-culator
@Cal-culator
Jul 18 2016 07:28
@Masd925 what do you mean?
eddsaura
@eddsaura
Jul 18 2016 07:29
I have to diference between every "Contact"
Justin
@JustinGaravel
Jul 18 2016 07:29
@eddsaura you've have to loop through the contacts array
that's a start, looking through it
Markus Kiili
@Masd925
Jul 18 2016 07:29
@Cal-culator The if block should end before else.
eddsaura
@eddsaura
Jul 18 2016 07:29
and then every loop check the things
oookay, i get it
<3 ty @xxjeep @Cal-culator @Masd925
CamperBot
@camperbot
Jul 18 2016 07:29
eddsaura sends brownie points to @xxjeep and @cal-culator and @masd925 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for cal-culator
:cookie: 219 | @xxjeep |http://www.freecodecamp.com/xxjeep
:star2: 2135 | @masd925 |http://www.freecodecamp.com/masd925
Cal-culator
@Cal-culator
Jul 18 2016 07:30
@Masd925 got it! thanks
CamperBot
@camperbot
Jul 18 2016 07:30
cal-culator sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2136 | @masd925 |http://www.freecodecamp.com/masd925
Franco Manzanares
@FranMan731
Jul 18 2016 07:31
Falsy Bouncer:
Pablo García
@Liion
Jul 18 2016 07:31

function findLongestWord(str) {
var array = str.split(" ");
console.log(array + " " + array.length);

var longest = "";

for (var i=0; i <= array.length; i++) {
  if (array[i].length > longest.length){
    longest = array[i];
  }
}
var largo = longest.length;
return largo;

}
findLongestWord("The quick brown fox jumped over the lazy dog");

whats wrong with that?
says it can't find the length of undefined
Franco Manzanares
@FranMan731
Jul 18 2016 07:32
<= for <
Cal-culator
@Cal-culator
Jul 18 2016 07:32
How do i fix this?
undefined is not an object (evaluating 'a[i][j].pop')
Markus Kiili
@Masd925
Jul 18 2016 07:33
This message was deleted
Pablo García
@Liion
Jul 18 2016 07:33
thanks
ty @FranMan731 @Masd925
CamperBot
@camperbot
Jul 18 2016 07:33
liion sends brownie points to @franman731 and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 256 | @franman731 |http://www.freecodecamp.com/franman731
:star2: 2137 | @masd925 |http://www.freecodecamp.com/masd925
Franco Manzanares
@FranMan731
Jul 18 2016 07:33
de nada!
Cal-culator
@Cal-culator
Jul 18 2016 07:34
can anyone help me?
undefined is not an object (evaluating 'a[i][j].pop')
How do i fix that?
Franco Manzanares
@FranMan731
Jul 18 2016 07:36
The pop() method removes the last element from an array and returns that element. @Cal-culator
Cal-culator
@Cal-culator
Jul 18 2016 07:37
@FranMan731 Yeah. but why is it undefined
eddsaura
@eddsaura
Jul 18 2016 07:38
omg it's harder than I thought
Demon000
@Demon000
Jul 18 2016 07:38
This message was deleted
This message was deleted
Cal-culator
@Cal-culator
Jul 18 2016 07:38
@eddsaura don't give up :) The feeling of you passing after clicking Run Tests is worth it. :+1:
@Demon000 wouldn't that remove a whole bracket?
Demon000
@Demon000
Jul 18 2016 07:39
I don't really know the context lol.
kerentang
@kerentang
Jul 18 2016 07:39
how to send picture?
Cal-culator
@Cal-culator
Jul 18 2016 07:39
@Demon000 actually... it worked lol. Thanks!
CamperBot
@camperbot
Jul 18 2016 07:39
cal-culator sends brownie points to @demon000 :sparkles: :thumbsup: :sparkles:
:cookie: 690 | @demon000 |http://www.freecodecamp.com/demon000
Cal-culator
@Cal-culator
Jul 18 2016 07:39
@Demon000 going to try to understand the logic
Demon000
@Demon000
Jul 18 2016 07:39
Rly?
Cal-culator
@Cal-culator
Jul 18 2016 07:39
@Demon000 yeah
Demon000
@Demon000
Jul 18 2016 07:39
Much luck, true skill.
Cal-culator
@Cal-culator
Jul 18 2016 07:40
@Demon000 :+1:
Justin
@JustinGaravel
Jul 18 2016 07:42

function lookUpProfile(firstName, prop){
// Only change code below this line
  for (i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    } else if (contacts[i].firstName == firstName && !(contacts[i].hasOwnProperty(prop))) {
      return "No such property";
    }
  }
My final check for this is to see if firstName exists at all, but when I add this in as if (contacts[i].firstName !== firstName) { return "No such contact";} it breaks the rest of my function to be all wrong...what am I possibly missing to get this to check to firstName corresponds to any contact and return "No such contact"?
Cal-culator
@Cal-culator
Jul 18 2016 07:43
Justin
@xxjeep try putting a condition inside another condition
Justin
@JustinGaravel
Jul 18 2016 07:44
@Cal-culator hmm but where, my two if's both check the prop and the firstName variable. Then I'd have to split those up into two if loops wouldn't I?
kerentang
@kerentang
Jul 18 2016 07:44

var count = 0;

function cc(card) {
// Only change code below this line
if(card<7&&card>1){
count+=1;
}
else if(card==10||card=="j"||card=="Q"||card=="K"||card=="A")
{count-=1;}
else{count=count;}
if(count>0){return count+" Bet";}
else{return count+" Hold";}

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

Cal-culator
@Cal-culator
Jul 18 2016 07:45
if firstName is equal to firstName{

}
kerentang
@kerentang
Jul 18 2016 07:45
whats wrong?
eddsaura
@eddsaura
Jul 18 2016 07:46
It should be something wrong... Ummm
function lookUpProfile(firstName, prop){
// Only change code below this line

 for (var i = 0; i < contacts.length; i++){  
  if (contacts[i][firstName] === undefined){
    return "No such contact";}
  else if (contacts[i][prop] === undefined){
    return "No such property";}
  else 
      return contacts[i][firstName][prop];
  }
it is because the return?=!=!=!
wait
Cal-culator
@Cal-culator
Jul 18 2016 07:47
if firstName is equal to firstName{
  if prop is equal to prop{
      return (what you want);
}
  else if prop is not equa to prop{
   return "no such prop";
}
}
else{
return No such Contact;
}
Try this
@eddsaura why do you have an else?
eddsaura
@eddsaura
Jul 18 2016 07:47
mm idw, for the last option?
Cal-culator
@Cal-culator
Jul 18 2016 07:48
yeah.
  else 
      return contacts[i][firstName][prop];
eddsaura
@eddsaura
Jul 18 2016 07:48
oh okay, i need to nest it
Markus Kiili
@Masd925
Jul 18 2016 07:51
@Cal-culator That firstName there needs quotes.
Justin
@JustinGaravel
Jul 18 2016 07:52
@Cal-culator Thanks, I got it. I'm not sure why the contact belongs there and I can't include it in logic but it works
CamperBot
@camperbot
Jul 18 2016 07:52
xxjeep sends brownie points to @cal-culator :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for cal-culator
eddsaura
@eddsaura
Jul 18 2016 07:54
mmmmmmmmmmmmmmm
yeah, I do return the negatives but not the positives

ups
Cal-culator
@Cal-culator
Jul 18 2016 07:56
@Masd925 i was doing a pseudo code. the firstName I copied and pasted from eddsaura's code to ask him why he had it
eddsaura
@eddsaura
Jul 18 2016 07:57
function lookUpProfile(firstName, prop){
// Only change code below this line
 for (var i = 0; i < contacts.length; i++){  
  if (firstName === contacts[i].firstName){
    if (prop === contacts[i][prop]){
        return contacts[i].firstName[prop];
        }
    else 
      return "No such property";
  }
   else
     return "No such contact";
  }
kevinstonge
@kevinstonge
Jul 18 2016 07:57
There is just a ridiculous amount of problem solving required to get these Intermediate Front End Development Projects done.
Markus Kiili
@Masd925
Jul 18 2016 07:57
@Cal-culator ok
Cal-culator
@Cal-culator
Jul 18 2016 07:58
@eddsaura How about instead of the last else, you just put return "No such contact" outside the loop?
Franco Manzanares
@FranMan731
Jul 18 2016 07:58
@kerentang card == "J" and return "Change Me" for return "0 Hold";
eddsaura
@eddsaura
Jul 18 2016 07:58
@Cal-culator same
Jack
@jh0l
Jul 18 2016 07:59
for the random quote machine am I suppose to make my own JSON-esque database of quotes or is there an API that everyone uses?
Cal-culator
@Cal-culator
Jul 18 2016 07:59
@eddsaura i did it differently
Zauri3645
@Zauri3645
Jul 18 2016 08:00
blob
Cal-culator
@Cal-culator
Jul 18 2016 08:00
@eddsaura try using hasOwnProperty()
to check if it has the property or not
Zauri3645
@Zauri3645
Jul 18 2016 08:01
Solve this
Cal-culator
@Cal-culator
Jul 18 2016 08:01
@Zauri3645 what is the assignment name called
Zauri3645
@Zauri3645
Jul 18 2016 08:02
Finding a Remainder in JavaScript
Franco Manzanares
@FranMan731
Jul 18 2016 08:02
@Zauri3645 remainder =11 % 3
Jack
@jh0l
Jul 18 2016 08:02
Are there still any working quote api things
Zauri3645
@Zauri3645
Jul 18 2016 08:03
thanks @FranMan731
CamperBot
@camperbot
Jul 18 2016 08:03
zauri3645 sends brownie points to @franman731 :sparkles: :thumbsup: :sparkles:
:cookie: 257 | @franman731 |http://www.freecodecamp.com/franman731
Zauri3645
@Zauri3645
Jul 18 2016 08:03
:)
Alex T.
@lx-t
Jul 18 2016 08:03
@Jhollond It's up to you. Most people use an API mentioned in example, some people find other APIs, and some people, skilled enough to write their own simple API server, do that.
eddsaura
@eddsaura
Jul 18 2016 08:04
nah it just don't work that way
Jack
@jh0l
Jul 18 2016 08:05
@lx-t hey that last option sounds interesting
Franco Manzanares
@FranMan731
Jul 18 2016 08:05
@eddsaura lo pudiste solucionar?
Alex T.
@lx-t
Jul 18 2016 08:06
@Jhollond Personally, I managed to write my own API server using Flask python framework and hosting it on Heroku.
eddsaura
@eddsaura
Jul 18 2016 08:06
Not yet
@FranMan731
Cal-culator
@Cal-culator
Jul 18 2016 08:07
@eddsaura

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


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

}
// Only change code above this line

// Change these values to test your function
lookUpProfile("Akira", "address");
this is how i did it
@eddsaura
Jack
@jh0l
Jul 18 2016 08:07
@lx-t Noice
Franco Manzanares
@FranMan731
Jul 18 2016 08:08
look, more short
for(var i=0; i<contacts.length; i++) {
if(contacts[i].firstName === firstName && contacts[i][prop]) {
return contacts[i][prop];
} else if(contacts[i].firstName === firstName && !contacts[i][prop]) {
return "No such property";
}
}
for(var j=0; j<contacts.length; j++) {
if(contacts[j].firstName !== firstName) {
return "No such contact";
}
}
kerentang
@kerentang
Jul 18 2016 08:10
var count = 0;
function cc(card) {
// Only change code below this line
if(card>1&&card<7){count+=1;} else if(card<10&&card>6){count+=0;}
else if(card>9||card=="J"||card=="Q"||card=="K"||card=="A"){count=count-1;}
else {return "Change Me";}
if(count>0){return count+" Bet";}
else{return count+" Hold";}
// Only change code above this line
}
finally it works out!
Pedro Abel Díaz Sánchez
@coderHook
Jul 18 2016 08:11
Can someone explain me the differnecies between let and var? I just discover that you can declare "variables" with let
fobindianman
@fobindianman
Jul 18 2016 08:11
Anyone know how to get the specific challenge requirements to show up again? Mine disappeared - http://puu.sh/q5zMo/b6d567d33e.png
Franco Manzanares
@FranMan731
Jul 18 2016 08:12
syntax error, missing }
fobindianman
@fobindianman
Jul 18 2016 08:12
I mean the requirements to complete the challenge don't show up
The ones that say your code must have this
Dmitrij Schmidt
@dmitrij-schmidt
Jul 18 2016 08:15
hi all! anyone fluent in regex p here? @fobindianman try to run tests by ctrl+enter
usually after test is not passed they're showed up again
fobindianman
@fobindianman
Jul 18 2016 08:16
Didn't work :/
Pedro Abel Díaz Sánchez
@coderHook
Jul 18 2016 08:17
@FranMan731 is i not better to use var?
Dmitrij Schmidt
@dmitrij-schmidt
Jul 18 2016 08:18
try refreshing browser window, or even closing and reopening tab ;) @fobindianman
Franco Manzanares
@FranMan731
Jul 18 2016 08:21
@coderHook hablas castellano?
Pedro Abel Díaz Sánchez
@coderHook
Jul 18 2016 08:21
Si : )
Franco Manzanares
@FranMan731
Jul 18 2016 08:21
jaja mejor, que querias preguntar?
Pedro Abel Díaz Sánchez
@coderHook
Jul 18 2016 08:22
Let's go to the spanish chatroom, ok?
Franco Manzanares
@FranMan731
Jul 18 2016 08:23
no sabia que existia jaja, ahi entre
fobindianman
@fobindianman
Jul 18 2016 08:24
Negative on that @dmitrij-schmidt
Vyvojar123
@Vyvojar123
Jul 18 2016 08:25
how can I make autoload function? I mean catching click on a button(which cause redirect)staying on the same page and show a text and when browser recieved next page then let to redirect on that
Dmitrij Schmidt
@dmitrij-schmidt
Jul 18 2016 08:27
@Vyvojar123 - read more on event.preventDefault(), and also http://stackoverflow.com/questions/3682805/javascript-load-a-page-on-button-click
Aleksandar B.
@aleksandar-b
Jul 18 2016 08:28
@Vyvojar123 you must create something like Single page app, or use Angular or React. Changing routes is instant there because all is done with js and browser comunicate with server via json which sends him data
Aleksandr Vinogradskiy
@patapum86
Jul 18 2016 08:31
Gents, I have a question: is arr.slice(howMany); is the same as arr.slice(0, howMany); There reason I'm asking is because it produces different results.
SBeard
@etacalpha
Jul 18 2016 08:32
Will anyone tell me why this will not pass

function rot13(str) { // LBH QVQ VG!
  var coded =[];
  for(var i= 0; i<str.length; i++){
    coded += str.charCodeAt(i) +" ";
  }
  var decoded = coded.split(" ").map(function(item){
    if(item >= 32 && item <= 47){
       return item;
     }else if (item >=78){
       return item -13;
     }
      return Number(item) + 13;     
  });
  return String.fromCharCode(...decoded);

}

// Change the inputs below to test
rot13("SERR CVMMN!");
Aleksandr Vinogradskiy
@patapum86
Jul 18 2016 08:34
@kirbyedy yes, I've read this documentation. it seems like ommiting first parametr will set it to 0, but if I manualy set it to 0, results are different.
kirbyedy
@kirbyedy
Jul 18 2016 08:36
@patapum86 maybe the image will help
Screen Shot 2016-07-18 at 11.34.38.png
Aleksandr Vinogradskiy
@patapum86
Jul 18 2016 08:37
@kirbyedy thanks
CamperBot
@camperbot
Jul 18 2016 08:37
patapum86 sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star2: 1242 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
Muhammad Hasham
@MohammadHasham
Jul 18 2016 08:37
can ayone help me on random quote machine?
Aleksandr Vinogradskiy
@patapum86
Jul 18 2016 08:38
I know it's pretty basic stuff, just need to figure it out, thanks for image
kirbyedy
@kirbyedy
Jul 18 2016 08:38
so if you ommit the second parameter he will slice it until the end of the array
and it will start at the first one
Nathaniel Nasarow
@Torgian
Jul 18 2016 08:39
hey guys, doing the roman numeral exercise right now
kirbyedy
@kirbyedy
Jul 18 2016 08:39
@MohammadHasham describe the problem
Muhammad Hasham
@MohammadHasham
Jul 18 2016 08:39
Nathaniel Nasarow
@Torgian
Jul 18 2016 08:39
問題:Can I assign multiple keys to a single object? Trying to figure out how
Muhammad Hasham
@MohammadHasham
Jul 18 2016 08:39
Why is my jquery not running @kirbyedy
Nathaniel Nasarow
@Torgian
Jul 18 2016 08:40
@MohammadHasham did you add the jQuery script to your JS?
kirbyedy
@kirbyedy
Jul 18 2016 08:40
@MohammadHasham what should your jquery do ?
Muhammad Hasham
@MohammadHasham
Jul 18 2016 08:40
@kirbyedy Yes i am a newbie but i guess yes i did that
@Torgian
Nathaniel Nasarow
@Torgian
Jul 18 2016 08:40
oh yeah you did, just checked
Muhammad Hasham
@MohammadHasham
Jul 18 2016 08:41
@kirbyedy I want it to use API to display text in that black box
Nathaniel Nasarow
@Torgian
Jul 18 2016 08:41
ahhh
so I don't recognize the .load
Muhammad Hasham
@MohammadHasham
Jul 18 2016 08:41
and then change it whenever i try to click that @kirbyedy
kirbyedy
@kirbyedy
Jul 18 2016 08:41
@MohammadHasham ok, but the way you wrote your code, it does not do anything
did you read the documentation of the api you are trying to use ?
Muhammad Hasham
@MohammadHasham
Jul 18 2016 08:42
@kirbyedy What should i do?
@Torgian Am i wrong there?
kirbyedy
@kirbyedy
Jul 18 2016 08:42
which api are you trying to use ?
Muhammad Hasham
@MohammadHasham
Jul 18 2016 08:43
theysaidso
@kirbyedy
am i using it right @kirbyedy
Nathaniel Nasarow
@Torgian
Jul 18 2016 08:43
actually, I think so, but I'm reading the jQuery documentation right now. However, if you are trying to access their API, this isn't the correct way to access it
kirbyedy
@kirbyedy
Jul 18 2016 08:43
ok, I havent worked with that one, but here is a page to it: https://theysaidso.com/api/
btw. you will have to register on their website and get the api key in order to use it
Muhammad Hasham
@MohammadHasham
Jul 18 2016 08:44
@kirbyedy Okay then i shall paste that key
@Torgian How can i call that. any way?
Nathaniel Nasarow
@Torgian
Jul 18 2016 08:45
@MohammadHasham Actually, one thing about your .load call that is incorrect is that you didn't set a target for the data you are trying to grab to be appended to
Joni petriashvili
@Jonhnwhantcoding
Jul 18 2016 08:45
hello campers
function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  item2 = arr.shift();
  return item;  // Change this line
}
Nathaniel Nasarow
@Torgian
Jul 18 2016 08:46
You'll also have to specify what you are grabbing from the file loaded from the API.... either way, it is incorrect. Like @kirbyedy said, you'll have to register for a key, and then use an ajax call
kirbyedy
@kirbyedy
Jul 18 2016 08:46
@Jonhnwhantcoding you are returning the item, is that what you want ?
Joni petriashvili
@Jonhnwhantcoding
Jul 18 2016 08:47
@kirbyedy no I have this issues 1.nextInLine([2], 1) should return 2 2. nextInLine([5,6,7,8,9], 1) should return 5
kirbyedy
@kirbyedy
Jul 18 2016 08:47
@Jonhnwhantcoding or the item2 maybe ?
Joni petriashvili
@Jonhnwhantcoding
Jul 18 2016 08:47
@kirbyedy oo i thought it would be item2 becaues i addes item
thanks
Stephen James
@sjames1958gm
Jul 18 2016 08:48
@Jonhnwhantcoding Your code is just returning the input value item and not the value you removed from the array (per instructions)
Aleksandr Vinogradskiy
@patapum86
Jul 18 2016 08:48
gents, how do you attach freecampcode editor screenshot to the chat ? just simplescreenshot? or is there an option to attach that im missing ?
Muhammad Hasham
@MohammadHasham
Jul 18 2016 08:48
@Torgian This means that in the load() function i actually need to paste the key straight in load()
Nathaniel Nasarow
@Torgian
Jul 18 2016 08:48
anyways, can multiple names be applied as keys for a single value?
Stephen James
@sjames1958gm
Jul 18 2016 08:49
@patapum86 You can get the formatting with the black background :point_down:
help format
CamperBot
@camperbot
Jul 18 2016 08:49

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Nathaniel Nasarow
@Torgian
Jul 18 2016 08:49
@MohammadHasham I've never used .load() function before, I'm just reading what I see in the documentation. I think you might be correct with the key though, give it a try. Otherwise, use an ajax call
Aleksandr Vinogradskiy
@patapum86
Jul 18 2016 08:50
@sjames1958gm thanks
CamperBot
@camperbot
Jul 18 2016 08:50
patapum86 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1959 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Aleksandr Vinogradskiy
@patapum86
Jul 18 2016 08:52
test
var test = test;
Dmitrij Schmidt
@dmitrij-schmidt
Jul 18 2016 09:00
anyone can help with phone number validation? I really hate regexp stuff...
function telephoneCheck(str) {

  var re = /(^1\s|^1\s\(?[0-9]{3}\)?).?([0-9]{3}).?([0-9]{4})/g;

  return re.test(str);
}

telephoneCheck("555-555-5555");
Faisal Zulfiqar
@faisal-zulfiqar
Jul 18 2016 09:00
How can I access the quote? Through JS?
{
    "success":{"total":1},
    "contents":{
        "quotes":[{"quote":"It wasn't raining when Noah built the ark....",
        "length":"45",
        "author":"Howard Ruff",
        "tags":["being-prepared","inspire"],
        "category":"inspire",
        "date":"2016-07-18",
        "title":"Inspiring Quote of the day",
        "background":"https://theysaidso.com/img/bgs/man_on_the_mountain.jpg","id":"bcYwS_RS1KCvfQ_ymsXk0AeF"
    }
  ]
 }
}
Muhammad Hasham
@MohammadHasham
Jul 18 2016 09:00
@faisal1337 use .load()
Faisal Zulfiqar
@faisal-zulfiqar
Jul 18 2016 09:01
This is the code, can't think of how to access the quote through the forEach()
  $(document).ready(function() {

    $("#getMessage").on("click", function() {
      $.getJSON("http://quotes.rest/qod.json", function(json) {

        var html = "";
        json.forEach(function(val) {
        var keys = Object.keys(val);

        keys.forEach(function(key) {
          if (keys == 1) {
          html += "<b>" + key + "</b>: " + val[key] + "<br>";
        }

  });

});

        $(".message").html(html);

      });
    });
  });
Muhammad Hasham
@MohammadHasham
Jul 18 2016 09:02
@Torgian It is loading the page with a new record actually in the raw form ! why is this so?
Markus Kiili
@Masd925
Jul 18 2016 09:02
@faisal1337 obj.contents.quotes[0].quote;
Nathaniel Nasarow
@Torgian
Jul 18 2016 09:02
can you give me your codepen?
Muhammad Hasham
@MohammadHasham
Jul 18 2016 09:02
Nathaniel Nasarow
@Torgian
Jul 18 2016 09:03
oh, cool
I'll have to keep .load in mind next time
Muhammad Hasham
@MohammadHasham
Jul 18 2016 09:04
@Torgian But why is it loading the data in raw form ?
Nathaniel Nasarow
@Torgian
Jul 18 2016 09:04
Because you haven't specified what exact data you want to grab from the request
Muhammad Hasham
@MohammadHasham
Jul 18 2016 09:05
is there any specified method to grab something specific out there?
Nathaniel Nasarow
@Torgian
Jul 18 2016 09:05
I suggest making a separate variable that takes the API request, as well as specifying what data you want exactly
and then putting that variable into the .load() function
Muhammad Hasham
@MohammadHasham
Jul 18 2016 09:05
how can i specify that which data i want to use
Nathaniel Nasarow
@Torgian
Jul 18 2016 09:05
also, since .load() is a function, try .load(function () { code here } to grab that data
you would access that data like you would in an array
or an array of objects
Muhammad Hasham
@MohammadHasham
Jul 18 2016 09:06
Okay i'll try that
Nathaniel Nasarow
@Torgian
Jul 18 2016 09:06
but it might be more complicated since you are grabbing it differently than an ajax call, at least I think it would be
Muhammad Hasham
@MohammadHasham
Jul 18 2016 09:06
@Torgian what method do u prefer to call ajax is it load or something else?
Nathaniel Nasarow
@Torgian
Jul 18 2016 09:07
I prefer ajax, but I never even heard of load before today
Again, try doing .load(function(){
Muhammad Hasham
@MohammadHasham
Jul 18 2016 09:07
okay i'll do that
Nathaniel Nasarow
@Torgian
Jul 18 2016 09:07
in the function.. hmm
make a variable with the api call
then....
maybe you can access it directly from there?
have it append data to your html like... hmmm
var called = "http: api stuff"
then called.contents.quote
maybe that will work
Muhammad Hasham
@MohammadHasham
Jul 18 2016 09:09
okay i'll do that
Nathaniel Nasarow
@Torgian
Jul 18 2016 09:09
I get a feeling the code would be different than an ajax
Muhammad Hasham
@MohammadHasham
Jul 18 2016 09:10
where do i need to paste the api key now?
in function(...)?
@Torgian
oh Sorry i have pasted that in called
@Torgian @sjames1958gm
Why is this not updating can you help me
http://codepen.io/Mohammad_Hasham/pen/akqzgP
Zauri3645
@Zauri3645
Jul 18 2016 09:15
Hello
Solve this.. Convert Celsius to Fahrenheit
Stephen James
@sjames1958gm
Jul 18 2016 09:15
@MohammadHasham You mean when you click? I am not sure .load works the way you are trying to use it. It doesn't appear to be useful for loading non-html
Faisal Zulfiqar
@faisal-zulfiqar
Jul 18 2016 09:16
@sjames1958gm please look at this : http://codepen.io/faisal1337/pen/ZOvgNR I want to change the quote when the button is clicked
but I cannot achieve it. Please show me how to.
Muhammad Hasham
@MohammadHasham
Jul 18 2016 09:16
@sjames1958gm I want that when i click the quote should change but nohing is happening there
Faisal Zulfiqar
@faisal-zulfiqar
Jul 18 2016 09:17
@MohammadHasham I don't think that you should use load.
Muhammad Hasham
@MohammadHasham
Jul 18 2016 09:17
@faisal1337 you need to extract the data you want same was the problem with me
Stephen James
@sjames1958gm
Jul 18 2016 09:17
@MohammadHasham You took the url out of the .load call that is probably why. $.load expects the first parameter to be url
@faisal1337 You need to parse the json data to get to the quote - you are dumping the raw json into the DOM
Faisal Zulfiqar
@faisal-zulfiqar
Jul 18 2016 09:18
$(document).ready(function() {

    $("#getMessage").on("click", function() {
      $.getJSON("/json/cats.json", function(json) {

        var html = "";
        // Only change code below this line.



        // Only change code above this line.

        $(".message").html(html);

      });
    });
  });
Use this @MohammadHasham
add stuff to html variable and $(".message").html(html); will replace the quote
if you've applied the message class properly
to the button
Sorry getMessage to the button.
@sjames1958gm lemme check
Muhammad Hasham
@MohammadHasham
Jul 18 2016 09:19
Faisal Zulfiqar
@faisal-zulfiqar
Jul 18 2016 09:19
parse function
Stephen James
@sjames1958gm
Jul 18 2016 09:19
@faisal1337 The quote is text is at json.contents.quotes[0].quote (I think)
{"success":{"total":1},"contents":{"quotes":[{"quote":"It wasn't raining when Noah built the ark....","length":"45","author":"Howard Ruff","tags":["being-prepared","inspire"],"category":"inspire","date":"2016-07-18","title":"Inspiring Quote of the day","background":"https://theysaidso.com/img/bgs/man_on_the_mountain.jpg","id":"bcYwS_RS1KCvfQ_ymsXk0AeF"}]}}
Muhammad Hasham
@MohammadHasham
Jul 18 2016 09:19
@sjames1958gm Please have a look http://codepen.io/Mohammad_Hasham/full/akqzgP/
Faisal Zulfiqar
@faisal-zulfiqar
Jul 18 2016 09:20
@sjames1958gm you are right. I should parse it first.
Lemme do that .
Stephen James
@sjames1958gm
Jul 18 2016 09:20
@MohammadHasham I did, @faisal1337 is correct you need to use $.getJSON or $.ajax to get that data $.load is for fetching html not json
Muhammad Hasham
@MohammadHasham
Jul 18 2016 09:21
Okay i'll do that
Stephen James
@sjames1958gm
Jul 18 2016 09:21
@faisal1337 json is not an array - so forEach is likely not going to work
eakl
@eakl
Jul 18 2016 09:23
Hi, is anyone aware of a bug in the "Record Collection" part of the JS course ?
The push method doesn't seem to work
Stephen James
@sjames1958gm
Jul 18 2016 09:23
@eakl There is no bug that I am aware of - did you check to see if the array exists on the object before pushing?
Zauri3645
@Zauri3645
Jul 18 2016 09:24
hello
anyone?
Faisal Zulfiqar
@faisal-zulfiqar
Jul 18 2016 09:24
@sjames1958gm this is how I should do it?
$(document).ready(function() {

    $("#getMessage").on("click", function() {
      $.getJSON("/json/cats.json", function(json) {

        var html = "";

        var obj = JSON.parse(json);

        $(".message").html(html);

      });
    });
  });
eakl
@eakl
Jul 18 2016 09:25
@sjames1958gm yes, I create the array just the line above
but the push method replace the existing values in the array
Blauelf
@Blauelf
Jul 18 2016 09:25
@faisal1337 When you use getJSON, json already is parsed and a javascript object rather than a string.
Stephen James
@sjames1958gm
Jul 18 2016 09:25
@faisal1337 No, getJSON already has parsed the json, you have to use object accessors to reach into the data and get what you want.
json.property1.property2 if you open your devtools to the network tab you can see the response
Elazar Fein
@SkySibe
Jul 18 2016 09:26
Check this out to understand how modulus works step by step:
https://jsfiddle.net/elazar170/7hhnagrj/
Blauelf @Blauelf just hates name autocomplete
Stephen James
@sjames1958gm
Jul 18 2016 09:27
@eakl You'll have to show your code - you can paste it (just the code, not the record collection)
Faisal Zulfiqar
@faisal-zulfiqar
Jul 18 2016 09:27
@sjames1958gm @Blauelf THANKYOU SO MUCH
CamperBot
@camperbot
Jul 18 2016 09:27
faisal1337 sends brownie points to @sjames1958gm and @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 1960 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 2199 | @blauelf |http://www.freecodecamp.com/blauelf
Faisal Zulfiqar
@faisal-zulfiqar
Jul 18 2016 09:27
the quote is changing now ^_^
Zauri3645
@Zauri3645
Jul 18 2016 09:27
blob
This one.
Stephen James
@sjames1958gm
Jul 18 2016 09:28
@faisal1337 Woot woot
eakl
@eakl
Jul 18 2016 09:28
@sjames1958gm This is the code
// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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