These are chat archives for FreeCodeCamp/HelpJavaScript

9th
Apr 2016
Ayrton Renan
@AyrtonRenan
Apr 09 2016 00:01
can someone help me?
Paul Borawski
@iAmNawa
Apr 09 2016 00:01
@AyrtonRenan what’s up?
Ayrton Renan
@AyrtonRenan
Apr 09 2016 00:02

function testGreaterThan(val) {
if (val>11) { // Change this line
return "Over 100";
}

if (val > '10') { // Change this line
return "Over 10";
}

return "10 or Under";
}

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

some goals still with errors:
testGreaterThan(99) should return "Over 10"
testGreaterThan(100) should return "Over 10"
Manraaj Nijjar
@ManraajNijjar
Apr 09 2016 00:03
@AyrtonRenan I'm running it in my Terminal and it seems to be working fine
ramses
@ozymandias1
Apr 09 2016 00:04
hmmm can someone help me figure this out? trying to create function that takes the last element of object/string/arguments
function last(list) {
  if (typeof list === "string") {
    return list.split("").pop();
  }
  else if (typeof list === "object") {
    return list.pop();
 } else {
  var args = Array.prototype.slice.call(arguments).pop();
  return args;
  }
}
Justin
@daemedeor
Apr 09 2016 00:05
@ozymandias1 whats the problem?
Ayrton Renan
@AyrtonRenan
Apr 09 2016 00:05
i dont know
ramses
@ozymandias1
Apr 09 2016 00:06
@daemedeor its occasionally returning the wrong element, but i can't figure out from ym code why
Justin
@daemedeor
Apr 09 2016 00:06
@ozymandias1 under which conditions?
Manraaj Nijjar
@ManraajNijjar
Apr 09 2016 00:06

'''console.log(testGreaterThan(99));
console.log(testGreaterThan(100));
console.log(testGreaterThan(10));

function testGreaterThan(val) {
if (val > 11) {
return "Over 100";
}
if (val > 10) {
return "Over 10";
}
return "10 or Under";
}''' is what I have specifically

CamperBot
@camperbot
Apr 09 2016 00:06
:bulb: to format code use backticks! ``` more info
Javier
@sh1g
Apr 09 2016 00:06
@daemedeor just saw other solutions. i had no idea you could append split, reverse and join all in one statement..
Justin
@daemedeor
Apr 09 2016 00:07
@ozymandias1 also you might want to use typeof list === "array"
:D
@sh1g
ya
you can
my favorite solution for palindromes return str === str.split('').reverse().join('');
ramses
@ozymandias1
Apr 09 2016 00:07
Manraaj Nijjar
@ManraajNijjar
Apr 09 2016 00:08
Are there any extra steps required to get jQuery animations working in CodePen?
I have some code that works in the codecamp compiler but not there
Justin
@daemedeor
Apr 09 2016 00:08
@ozymandias1 oh yea -.-"
i'm going to guess its around there
though
with objects
which are not arrays
Christian
@cenamorado1
Apr 09 2016 00:09
question, when you make a function like
function myFunctionName () do the parameters is the parenthesis have to be variables? Also what if I didn't assign a variable before I made the function and did it inside the function. Would I then leave the space inside the parenthesis blank?
Stephen
@stephepush
Apr 09 2016 00:10
function reverseString(str) {
  var array = [];
  str.split();
  array.push(str);
  array.reverse();
  str = array.join();
  return str;
}

reverseString("hello");
Is this even close for the first algorithm problem (Reverse a String)?
ManBearPigg
@ManBearPigg
Apr 09 2016 00:12
@stephepush this is very close but it's split('') and join(' ')
Justin
@daemedeor
Apr 09 2016 00:12
@stephepush gotta do some reassigning, most of those aren't going to mutate in place
ManBearPigg
@ManBearPigg
Apr 09 2016 00:12
@stephepush or maybe the opposite split(' ') and join ('') test them both out
@stephepush and you might have to specify what you're reversing in the brackets of reverse(). Use console.log through each step to see what's working and what's not
Stephen
@stephepush
Apr 09 2016 00:14
@ManBearPigg tried both, they aren't working. Seems @daemedeor is right
Justin
@daemedeor
Apr 09 2016 00:15
@stephepush if you want to know someting cool is that they return a mutated value... so you can chain it.... ;D
Stephen
@stephepush
Apr 09 2016 00:15
@daemedeor , you mean nesting functions within functions when you say chaining? I was tempted to try that...
Justin
@daemedeor
Apr 09 2016 00:16
@stephepush nopes thats not chaining, that doing tons of currying or callbacks (depending on the use)
@stephepush return str === str.split('').reverse().join('');
oh wait its just reversing
@stephepush return str.split('').reverse().join('')
ManBearPigg
@ManBearPigg
Apr 09 2016 00:17
@stephepush look at w3schools for all of those methods they provide perfect examples
Stephen
@stephepush
Apr 09 2016 00:17
lol didnt know you could do anything like that
okay @ManBearPigg , thanks
CamperBot
@camperbot
Apr 09 2016 00:18
stephepush sends brownie points to @manbearpigg :sparkles: :thumbsup: :sparkles:
:star: 314 | @manbearpigg | http://www.freecodecamp.com/manbearpigg
Stephen
@stephepush
Apr 09 2016 00:19
and thanks, @daemedeor
CamperBot
@camperbot
Apr 09 2016 00:19
stephepush sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 244 | @daemedeor | http://www.freecodecamp.com/daemedeor
Justin
@daemedeor
Apr 09 2016 00:19
but yea look up the methods
Stephen
@stephepush
Apr 09 2016 00:20
what do you mean when you say "mutate", daemedeor?
@daemedeor ^
Justin
@daemedeor
Apr 09 2016 00:20
@stephepush mutate == "to change"
you can't change the values of strings
its very theory stuff
i mean i 'm not explaining it all the way
Stephen
@stephepush
Apr 09 2016 00:25
indeed
maybe i should just start reading eloquent javascript now that I'm up to algorithms...
Stephen
@stephepush
Apr 09 2016 00:36
hmm so after putting the string through a split function is it one string or a group of individual strings
Tom DeFrank
@TomDeFrank
Apr 09 2016 00:37
@stephepush an array of strings
@stephepush technically though it returns an array, it doesn't change the actual string
Frank XC
@tenkdayz
Apr 09 2016 00:39
anyone know of where to get cursor imgs
?
bitgrower
@bitgrower
Apr 09 2016 00:40
have you tried googling for free cursor images ?
Tom DeFrank
@TomDeFrank
Apr 09 2016 00:40
var a = "hello"
var b;

a.split('')

b = a.split('')

console.log(a) // returns "hello"
console.log(b) // returns [ 'h', 'e', 'l', 'l', 'o' ]
bitgrower
@bitgrower
Apr 09 2016 00:40
whatcha trying to do, @TomDeFrank ?
oh, I see, that's an example for someone else ... :)
Tom DeFrank
@TomDeFrank
Apr 09 2016 00:41
:)
Frank XC
@tenkdayz
Apr 09 2016 00:42
@bitgrower yes but sometimes people have better recommendations
bitgrower
@bitgrower
Apr 09 2016 00:42
sorry ... I don't :(
what kind of cursor images are you looking for ?
Tom DeFrank
@TomDeFrank
Apr 09 2016 00:43
@tenkdayz you might find this interesting https://css-tricks.com/using-css-cursors/
bitgrower
@bitgrower
Apr 09 2016 00:44
cool beans, @TomDeFrank
Tom DeFrank
@TomDeFrank
Apr 09 2016 00:44
looks like FCC is all internal now?
Frank XC
@tenkdayz
Apr 09 2016 00:44
i'm looking for a dropper img.. or gif
Tom DeFrank
@TomDeFrank
Apr 09 2016 00:44
like all of the javascript stuff is on the FCC site only?
Frank XC
@tenkdayz
Apr 09 2016 00:44
@TomDeFrank thanks though.. I'll read that.
CamperBot
@camperbot
Apr 09 2016 00:44
tenkdayz sends brownie points to @tomdefrank :sparkles: :thumbsup: :sparkles:
:star: 211 | @tomdefrank | http://www.freecodecamp.com/tomdefrank
Brandon Dean
@thedeany
Apr 09 2016 00:53
Posted this a few days ago and didn't get a response. I can't figure out why the button colors change slightly before the background color. http://codepen.io/thedeany/pen/reGZZY
Lucas Barbula
@lbarbula
Apr 09 2016 00:58

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

// Test Setup

var testArr = nextInLine([1,2,3,4,5], 6);

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

Looking for a little help on this
supposed to add the item argument to the end of the array, remove the first element of the array, and then print the removed element
Tom DeFrank
@TomDeFrank
Apr 09 2016 01:00
@thedeany .animate is kinda screwy in my experience, maybe have the animation in css and on click add the class
Lucas Barbula
@lbarbula
Apr 09 2016 01:01
updated unshift to push
Tom DeFrank
@TomDeFrank
Apr 09 2016 01:01
@thedeany like instead of colorArray have classArray
soydeedo
@soydeedo
Apr 09 2016 01:04
@thedeany you have a different easing function in your css for the body
Ken Haduch
@khaduch
Apr 09 2016 01:07
@lbarbula - "add an item to the end of the array" first.... then remove the first element. and return it.
@lbarbula - hello, by the way - first time I've seen you in the rooms here... welcome!
Eric D.
@edronen
Apr 09 2016 01:09
Hi everybody - Hopefully this is quick... is console.log supposed to work in all challenges?
Yomi
@Joll59
Apr 09 2016 01:09
@edronen i have noticed it doesnt work in all of them
bitgrower
@bitgrower
Apr 09 2016 01:10
hm .. never had a problem ...
Ken Haduch
@khaduch
Apr 09 2016 01:10
@edronen - console.log should work anywhere - where have you seen that it doesn't work? I'm curious...
@Joll59 - same question - where do you think it doesn't work? I've used it a lot and I haven't seen it not work?
Eric D.
@edronen
Apr 09 2016 01:10
Thank you @Joll59 . i've seen it in a couple of challenges and was just trying to use it in the pallendrome check and it's not working there
CamperBot
@camperbot
Apr 09 2016 01:10
edronen sends brownie points to @joll59 :sparkles: :thumbsup: :sparkles:
:star: 234 | @joll59 | http://www.freecodecamp.com/joll59
Lucas Barbula
@lbarbula
Apr 09 2016 01:10
@khaduch got it thanks so much!
CamperBot
@camperbot
Apr 09 2016 01:10
lbarbula sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 892 | @khaduch | http://www.freecodecamp.com/khaduch
Eric D.
@edronen
Apr 09 2016 01:11
I'm really new... how do I send brownie points?
Ken Haduch
@khaduch
Apr 09 2016 01:11
@edronen - it should work in the palindrome test? I think that I used it there extensively! :)
bitgrower
@bitgrower
Apr 09 2016 01:11
help brownie points
CamperBot
@camperbot
Apr 09 2016 01:11

:point_right: brownie points [wiki]

The number beside your picture on Free Code Camp tells you how many Brownie Points you have.

A user profile picture next to a with Brownie Points score

There are three ways you can get Brownie Points:

  1. Complete challenges - you get one point per challenge you complete
  2. Post relevant links on Camper News - you get 1 point for posting a link, and another point for each upvote your link gets
  3. Help other campers in chat - each time you help another camper and they thank you (by typing "thanks @yourname"), you will get a point

Brownie Points help you look like the kind of person who codes a lot, shares relevant links, and helps people.

They also add to your Streak.
:pencil: read more about brownie points on the FCC Wiki

Ken Haduch
@khaduch
Apr 09 2016 01:11
@bitgrower - hey there! Long time, no see!
Tom DeFrank
@TomDeFrank
Apr 09 2016 01:11
Quincy... 188... for shame.
Brandon Dean
@thedeany
Apr 09 2016 01:11
Thanks @TomDeFrank. I had tried a similar method to that which resulted in the transition property being added to my body declaration which @soydeedo noticed I still had... removing that transition property worked! Thanks @soydeedo!
CamperBot
@camperbot
Apr 09 2016 01:11
thedeany sends brownie points to @tomdefrank and @soydeedo :sparkles: :thumbsup: :sparkles:
:star: 212 | @tomdefrank | http://www.freecodecamp.com/tomdefrank
bitgrower
@bitgrower
Apr 09 2016 01:11
@edronen -- have you been working on the challenges for a while? They've been going thru renaming ...
CamperBot
@camperbot
Apr 09 2016 01:11
:star: 36 | @soydeedo | http://www.freecodecamp.com/soydeedo
Eric D.
@edronen
Apr 09 2016 01:12
thank yoyu @bitgrower :)
CamperBot
@camperbot
Apr 09 2016 01:12
edronen sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 970 | @bitgrower | http://www.freecodecamp.com/bitgrower
Eric D.
@edronen
Apr 09 2016 01:12
Thanks @Joll59
CamperBot
@camperbot
Apr 09 2016 01:12
edronen sends brownie points to @joll59 :sparkles: :thumbsup: :sparkles:
:warning: edronen already gave joll59 points
Ken Haduch
@khaduch
Apr 09 2016 01:12
@lbarbula - that's great! You're
welcome!
bitgrower
@bitgrower
Apr 09 2016 01:13
hi @khaduch ! ... yes, life intervenes ... also trying to bolster some of my education from other sources as well ... (it all started with wanting to be more conversant in bootstrap/responsive sites ...)
Chris Dalton
@manwithgills
Apr 09 2016 01:13
Good evening everyone. I am working on the random quote generator. I have a question about how ajax, or JSON works in regards to events. Here is my pen so far: http://codepen.io/manwithgills/pen/jqYdwM?editors=0010.
Eric D.
@edronen
Apr 09 2016 01:13
@bitgrower - I've been around for about a month or so and just started on the palindrome check today
Ken Haduch
@khaduch
Apr 09 2016 01:13
@bitgrower - sounds like about what I've been trying to do - for me, there are TOO MANY activities going on... but I always try to stop by here for a little while each day. :) I hope that all is going well!
bitgrower
@bitgrower
Apr 09 2016 01:15
reasonably, @khaduch -- found an awesome tax guy ... gonna get some of my crazy tax stuff done ...
CamperBot
@camperbot
Apr 09 2016 01:15
bitgrower sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 893 | @khaduch | http://www.freecodecamp.com/khaduch
Chris Dalton
@manwithgills
Apr 09 2016 01:16
On the exercise I am working on the quote loads when the document is ready. What I want to know is on the click event do I need to execute two functions, one to clear the quote and another to get the json?
Frawel
@Frawel
Apr 09 2016 01:18
why free code camp erase my answer on the exercises ?
Ken Haduch
@khaduch
Apr 09 2016 01:19
@bitgrower - oh, yeah, taxes... :cry: and why did you give me brownie points with your post? That's funny! Well, makes up for other times when people said thanks and camperbot ignored it... and I think I just gave you a browniepoint, too? :)
CamperBot
@camperbot
Apr 09 2016 01:19
khaduch sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 971 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Apr 09 2016 01:20
LOL ... because tax does that, @khaduch
CamperBot
@camperbot
Apr 09 2016 01:20
bitgrower sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: bitgrower already gave khaduch points
Ken Haduch
@khaduch
Apr 09 2016 01:20
@Frawel - sometimes you get back into the original problem if you go to it from the Map? If you go to your freecodecamp home page and click on it, it usually retains the answer there? Not sure if that might be what you're seeing?
@bitgrower - just what I was thinking... but I say "no thanks to taxes!" :hammer:
CamperBot
@camperbot
Apr 09 2016 01:21
khaduch sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: khaduch already gave bitgrower points
bitgrower
@bitgrower
Apr 09 2016 01:21
LOL ...
I don't mind paying taxes as much as I mind doing them ....
Ken Haduch
@khaduch
Apr 09 2016 01:23
@Frawel - something else to watch out for - they have renamed some of the functions on some (many, most?) of the challenges, so the tests are expecting new function names. If you had something that was working, check the test results for the function names that they are now expecting, if you just change that in your code, it should restore the correct operation...
Frawel
@Frawel
Apr 09 2016 01:26
@khaduch My code was deleted, although the exercise is marked as completed
bitgrower
@bitgrower
Apr 09 2016 01:29
super bummer @Frawel ... I was under the impression that solutions are stored locally on your machine ?
I know I had 3 "work in progress" challenges where the code disappeared (dang it!) ...but my previous solutions that I've checked still seem to be around ...
Ken Haduch
@khaduch
Apr 09 2016 01:30
@Frawel - which exercise, as an example?
Frawel
@Frawel
Apr 09 2016 01:31
@khaduch All of them
Ken Haduch
@khaduch
Apr 09 2016 01:31
@bitgrower - I started saving my "work in progress" challenges in a separate text file that I use to keep notes. That way, if it gets lost, I have a backup... :)
@Frawel - I am looking at your page http://freecodecamp.com/frawel and I see answers for the challenges that are listed (although I'm not 100% sure that I'm not seeing mine when I click on a link...) but I think I see answers in there? Perhaps I'm confused...
bitgrower
@bitgrower
Apr 09 2016 01:33
LOL ... yeah, I thought I had been doing that, too ... guess I missed these ... sigh ...
Frawel
@Frawel
Apr 09 2016 01:33
@khaduch Try with this one "Validate US Telephone Numbers " ?
bitgrower
@bitgrower
Apr 09 2016 01:34
too bad -- I had some good inroads and working pieces of code for all 3 ... including my comments on all the possible combinations of dates for Friendly Dates ... (I think there was about 8 different possibilities)...maybe it will help kick my butt to get 'em done ...
Ken Haduch
@khaduch
Apr 09 2016 01:35
This message was deleted
and I know that that is not my solution...
Frawel
@Frawel
Apr 09 2016 01:36
@khaduch why can't I see it then ? that's my code
bitgrower
@bitgrower
Apr 09 2016 01:36
are you clicking on the "view solution" link on your profile page, @Frawel ?
Frawel
@Frawel
Apr 09 2016 01:37
@khaduch delete the code for those are no there yet
Ken Haduch
@khaduch
Apr 09 2016 01:37
@Frawel - so are you trying to access from here: http://freecodecamp.com/frawel and use the "view solution" link?
@Frawel - I deleted it...
Amir Ghafouri
@amirghafouri
Apr 09 2016 01:37
var format1 = /\d{3}\-\d{3}\-\d{4}/;
return format1.test("(555-555-5555");

//returns true
I want this to return false. I understand what's going on, but how do I do something about it? In other words, I want it only to return true if my string matches the reg ex exactly, not if part of it is a perfect match but there are other parts as well. I tried adding word boundaries but that didn't work (or I wasn't doing it right)
bitgrower
@bitgrower
Apr 09 2016 01:37
snap, @khaduch
Frawel
@Frawel
Apr 09 2016 01:39
@khaduch Thanks was doing from the Map.
CamperBot
@camperbot
Apr 09 2016 01:39
frawel sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 894 | @khaduch | http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Apr 09 2016 01:39

@amirghafouri -- anchor your regular expression to match at the beginning of the line. Or beginning and end, like this:

var format1 = /^\d{3}\-\d{3}\-\d{4}$/;

that might get what you want...

@Frawel - phew! I did mention that in my first comment to you, but that's ok... this chat room can be confusing with lots of stuff going on! Glad to have helped you!
Nicole S.
@nicolesteck
Apr 09 2016 01:42
I think my issue is in the return step
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
if (firstName !=="") {
  if (prop !=="") {
    return contacts.prop;
  }
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
wiki profile lookup
CamperBot
@camperbot
Apr 09 2016 01:42

:point_right: checkpoint profile lookup [wiki]

Checkpoint: Profile Lookup

Instructions

We have an array of objects representing different people in our contacts lists.

A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you.

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

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

:pencil: read more about checkpoint profile lookup on the FCC Wiki

Salomón Mendoza
@SHLOMER
Apr 09 2016 01:44
someone how know where Im wrong here in Quoting Strings with Single Quotes
var myStr = "\'<a href=\"http://www.example.com target=_blank\">Link</a>\'";
Frawel
@Frawel
Apr 09 2016 01:45
@amirghafouri did you resolved the problem ?
Amir Ghafouri
@amirghafouri
Apr 09 2016 01:45
@khaduch thanks! it worked
CamperBot
@camperbot
Apr 09 2016 01:45
amirghafouri sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 895 | @khaduch | http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Apr 09 2016 01:46
@nicolesteck - you are not really doing any comparisons to the contact list? At least for starters. A hint is that you have to have some kind of loop that will look through all (potentially all) of the contacts list to find someone with a matching firstname, and then take the rest of the conditions from there...
Kevin Schwert
@kevinpschwert
Apr 09 2016 01:47
Need a little help with the Stand in Line problem. Not understanding what they are trying to get at and how to solve it.
Nicole S.
@nicolesteck
Apr 09 2016 01:47
thx @khaduch
CamperBot
@camperbot
Apr 09 2016 01:47
nicolesteck sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 896 | @khaduch | http://www.freecodecamp.com/khaduch
Salomón Mendoza
@SHLOMER
Apr 09 2016 01:49
anyone? :(
Jason
@BoilingOil
Apr 09 2016 01:51
Hello everybody
I have a question that relates to JS syntax
// ECMA2015?
Registry.registerComponent('app', () => AppName);

// Regular?
Regsitry.registerComponent('app', function() {return AppName});
Is that correct?
the second argument, one being a function, what is () => ThisThing called?
I like the shorter way of doing this
Paul Borawski
@iAmNawa
Apr 09 2016 01:55
@SHLOMER what’s up?
Ken Haduch
@khaduch
Apr 09 2016 01:56
@SHLOMER - let's see...
Jason
@BoilingOil
Apr 09 2016 01:56
anyone able to help clear up my understanding?
Paul Borawski
@iAmNawa
Apr 09 2016 01:57
@BoilingOil arrow function
Jason
@BoilingOil
Apr 09 2016 01:57
thanks @iAmNawa
CamperBot
@camperbot
Apr 09 2016 01:57
boilingoil sends brownie points to @iamnawa :sparkles: :thumbsup: :sparkles:
Paul Borawski
@iAmNawa
Apr 09 2016 01:57
@BoilingOil They were released with ES6
CamperBot
@camperbot
Apr 09 2016 01:57
:star: 363 | @iamnawa | http://www.freecodecamp.com/iamnawa
Ken Haduch
@khaduch
Apr 09 2016 01:57
@SHLOMER - the instructions say "Change the provided string from double to single quotes and remove the escaping." So you should end up with no escaped quotes, and single quotes at the beginning and end of the string.
Jason
@BoilingOil
Apr 09 2016 01:57
ES6 === ECMA2015?
Paul Borawski
@iAmNawa
Apr 09 2016 01:58
yeah i think some people call it that
EcmaScript 6 is what it’s really called
They are transitioning into calling the new release features by year now @BoilingOil
Ken Haduch
@khaduch
Apr 09 2016 02:00
@SHLOMER - in the way that they showed in the example within that lesson...
Jason
@BoilingOil
Apr 09 2016 02:01
@iAmNawa ok cool, JS is evolving so quickly
Paul Borawski
@iAmNawa
Apr 09 2016 02:01
@BoilingOil The way someone decribed it to me was, you’re just behind and you need to catch up. Then try not to fall behind.
Jason
@BoilingOil
Apr 09 2016 02:02
@iAmNawa That's true
oscar
@oscarg91
Apr 09 2016 02:03
need help with the global scope and functions
Ken Haduch
@khaduch
Apr 09 2016 02:05
@oscarg91 - hey there... where are you at with this? Want to post code or ask about specific things?
oscar
@oscarg91
Apr 09 2016 02:05
the challenge
im not sure what I'm doing
or have to do
Ken Haduch
@khaduch
Apr 09 2016 02:07
@oscarg91 - OK... I don't know what code they start with - the "template" - do you have that? It seems to have comments in it to guide you... maybe I have to just reset mine and see what the current starter code is that they give you?
Nicole S.
@nicolesteck
Apr 09 2016 02:07
ok @khaduch i have no clue what's up
i tried adding a for loop
without success
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

  console.log(firstName);


  /*for (var i = 0; i < contacts.length; i++) {

  if (contacts.firstName[i] == firstName) {
  if (prop == contacts.likes[i]) {
    return contacts.likes;
  } else {
    return "No such property";
  }
} else {
  return "No such person";
}
}*/

  /**/

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
(i just commented that all out a second ago)
oscar
@oscarg91
Apr 09 2016 02:08
// Declare your variable here
var myGlobal 

function fun1() {
  // Assign 5 to oopsGlobal Here

}

// Only change code above this line
function fun2() {
  var output = "";
  if (typeof myGlobal != "undefined") {
    output += "myGlobal: " + myGlobal;
  }
  if (typeof oopsGlobal != "undefined") {
    output += " oopsGlobal: " + oopsGlobal;
  }
  console.log(output);
}
Ken Haduch
@khaduch
Apr 09 2016 02:09
@nicolesteck - okay, you have a slight bit of confusion in what you are doing, on the right track with the for loop, though...
Nicole S.
@nicolesteck
Apr 09 2016 02:09
what am i missing?? i'm baffled.
Kevin Schwert
@kevinpschwert
Apr 09 2016 02:10
did anyone get my comment about the Stand in Line problem?
Ken Haduch
@khaduch
Apr 09 2016 02:10
@oscarg91 - ok... the first comment says "Declare your variable here", and the instructions say to assign a value to it.
inside of fun1, they tell you to assign a value to the variable oopsGlobal, and the instructions tell you how to declare that... all you have to do is complete those two steps and try to run the tests...
@nicolesteck - ok Nicole - the contacts is an array of objects. Your for loop has the correct form for (var i = 0; i < contacts.length; i++), treating contacts as an array. But to access elements from an array, you need to have some normal-looking array syntax first, to gain access to the object, like contacts[i]. That's the first step.
@kevinpschwert - I went back pretty far and didn't see it (or just cannot find it...) do you have a question? Could you please repeat it?
Paul Borawski
@iAmNawa
Apr 09 2016 02:14
@kevinpschwert please repeat
Ken Haduch
@khaduch
Apr 09 2016 02:15
@kevinpschwert - I just found it, never mind.
Stand In Line is a play on words... they are talking about a common data structure known as a queue, which is also a term used for a line (in Great Britain, for example.)
soydeedo
@soydeedo
Apr 09 2016 02:15
Yes
Whoops
Kevin Schwert
@kevinpschwert
Apr 09 2016 02:16
I am having trouble solving it. Could you help steer me in the right direction?
Alexandre Peluchi
@alexandrepeluchi
Apr 09 2016 02:17
How i correct this if (contacts[i]["firstName"] == firstName)?
Ken Haduch
@khaduch
Apr 09 2016 02:17
@kevinpschwert - what they want you to do is a simple manipulation of a queue-type structure implemented with a javascript array.
The idea is that you can add something to the end of the queue, and normally you take something from the beginning of the queue. (Think of a line in a bank - the first person goes to the teller, the new person comes into the back of the line.) There are Array functions that add elements to the end of the Array (the "queue"), and functions that remove elements from the start of the array. That's what they want you to do.
If you want to post code that you have, then I'll see where you are, but maybe my explanation there will be helpful?
Kevin Schwert
@kevinpschwert
Apr 09 2016 02:18
I have used push and pop and unshift but that is only partially solving it
Ken Haduch
@khaduch
Apr 09 2016 02:18
@nicolesteck - did my comment help you? You might find that doing a simple first step of trying to print (to console.log) the first names of everyone in the list will get you started on accessing the contacts...
@kevinpschwert - you're on the right track, then.... they want you to add to the end of the array first - that's where you would use .push(), and then remove and return the element from the start of the array, that would be the shift or is it unshift? I get those confused... :( It is shift.
but whichever one removes an element from the beginning of the array. (That would be Array.shift()...)
harpoon747
@harpoon747
Apr 09 2016 02:20
Can someone please help with my code, it is not able to filter ""
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var o = [];
  var filtered = arr.filter(function isCorrectValue(value){
    if(Boolean(value) && value !== "")
      o.push();
      return o;
  });
  return filtered;
}



bouncer([7, "ate", "", false, 9]);
Kevin Schwert
@kevinpschwert
Apr 09 2016 02:26
I am having trouble knowing how to do the multiple steps. I can get one step down like this.// Test Setup

function queue(arr, item) {
arr = arr.shift();

return arr; // Change this line
}

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

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

Ken Haduch
@khaduch
Apr 09 2016 02:27
@harpoon747 - I came up with something slightly different for that. The Boolean(value) will return false for all of the falsy values, so you can really just test if Boolean(value) != false and that is your condition for allowing an element to remain in the list.
@kevinpschwert - the thing that you have to do first is to add the item value to the end of the array with .push()according to the instructions: Add the number to the end of the array, then remove the first element of array. .push() will directly modify the array, so you do not have to assign the value to arr, in fact, that is really going to mess things up because .push() returns the new length of the array, so that clobbers your arr variable... So that is the first step.
Charlotte N.
@clnquacky
Apr 09 2016 02:32
Can someone help me with the following challenge (Introducing JavaScript Object Notation JSON)
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
},
[
{
"artist": "Imagine Dragons",
"title": "Time",
"release_year": 2012,
"formats": [
"AB",
"CD",
"EF"]
}
] // Add record here
];
I seem to be missing something
Ken Haduch
@khaduch
Apr 09 2016 02:34

@kevinpschwert - then you have to remove the first element, which is accomplished by doing the .shift(), and that returns the value, which you can store in a variable, or directly return it to conclude the operation of the function. In other words, one of these two choices:

var result = arr.shift();
return result;

or

return arr.shift();
@clnquacky - hello there.
ZctrapCoding
@ZctrapCoding
Apr 09 2016 02:35
How do i do Stand in line?
Ken Haduch
@khaduch
Apr 09 2016 02:37

@clnquacky - you are just trying to add another object to an array, so you don't need to have any extra square brackets between the objects, just comma-separated objects. Like this:

// the original:
var myMusic = [ { stuff: "here" } ];

// after adding a new one:
var myMusic = [ { stuff: "here" }, { newStuff: "here" } ];

with vastly simplified example objects inside that array... I hope that helps?

@ZctrapCoding - scroll up over the last few dozen comments here and see discussions about "Stand in Line"...
ZctrapCoding
@ZctrapCoding
Apr 09 2016 02:38
alright thx @khaduch
CamperBot
@camperbot
Apr 09 2016 02:38
zctrapcoding sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 897 | @khaduch | http://www.freecodecamp.com/khaduch
Charlotte N.
@clnquacky
Apr 09 2016 02:38
@khaduch thank you.. Yes that helped..
CamperBot
@camperbot
Apr 09 2016 02:38
clnquacky sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 898 | @khaduch | http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Apr 09 2016 02:40
:point_up: April 8, 2016 10:15 PM @ZctrapCoding @ZctrapCoding - start with this note, that is where I started discussing the "Stand in Line" with Kevin... if you follow down through the explanations, maybe it will help you? I've been helping three or four others, so look for the notes mentioning Kevin...
Kevin Schwert
@kevinpschwert
Apr 09 2016 02:40
@ZctrapCoding I am trying to figure it out also.
ZctrapCoding
@ZctrapCoding
Apr 09 2016 02:41
@kevinpschwert alright
i feel the only thing i say is alright xD
Ken Haduch
@khaduch
Apr 09 2016 02:42
@kevinpschwert - what's your code look like at this point? You should have something with .push() and then .shift() without too much else...
Kevin Schwert
@kevinpschwert
Apr 09 2016 02:44
I've got the shift down but still trying to figure out what to push, other than the right letters to make this code work:)
Since I am only returning one thing it's got me confused of how to do both a push and a shift on the same item.
Ken Haduch
@khaduch
Apr 09 2016 02:47
@kevinpschwert - they are passing two arguments to the function, one is the array, the other is the item (I think that's what they call it.) That is the number that they are referring to in the instructions.
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
@kevinpschwert - the array is the item, and you can push and shift on that item for as many elements as you have to deal with, so doing one of each, as long as the push happens first (as per the instructions) then you have something to shift... :)
Ken Haduch
@khaduch
Apr 09 2016 02:53

@kevinpschwert - this might help... https://en.wikipedia.org/wiki/Queue_%28abstract_data_type%29 it's the theory behind the queue as used in computer science. A couple sentences of interest:

Theoretically, one characteristic of a queue is that it does not have a specific capacity. 
Regardless of how many elements are already contained, a new element can always 
be added. It can also be empty, at which point removing an element will be 
impossible until a new element has been added again.

So if the queue is empty, you can add an element to it, then remove it. If it already has elements, you can add a new one to the end, and remove the one that is at the beginning... etc... etc... etc...

ZctrapCoding
@ZctrapCoding
Apr 09 2016 02:54
shouldnt this work?
function queue(arr, item) {
arr.push(item); 
return arr.shift();
}
// Test Setup
var testArr = [1,2,3,4,5];
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Ken Haduch
@khaduch
Apr 09 2016 02:55
@ZctrapCoding - does it work for you?
Dylan
@dhcodes
Apr 09 2016 02:55
@ZctrapCoding you need to shift your arr first and then return the arr
you are returning the shifted value
@ZctrapCoding
ZctrapCoding
@ZctrapCoding
Apr 09 2016 02:55
opps okay
Ken Haduch
@khaduch
Apr 09 2016 02:56
@ZctrapCoding - no no no, don't listen to that! The problem with your code is this:
ZctrapCoding
@ZctrapCoding
Apr 09 2016 02:56
okay
Ken Haduch
@khaduch
Apr 09 2016 02:57
@ZctrapCoding - they changed the names of the functions in the challenge from queue to nextInLine... You just have to edit those places in the code where it says queue to nextInLine, and try to run it again.
They changed a lot of the function names throughout the tests. Observe what the test is checking for and compare it to your code, I don't know why they did this, but that's the way it is!
ALMY91
@ALMY91
Apr 09 2016 02:57
hello all do you think the definitive guide wld be a book suitable for someone who have completed the javascript challenges on codecamp and codecademy?
Dylan
@dhcodes
Apr 09 2016 02:57
@ZctrapCoding sorry, @khaduch is right. I was mistaken
ZctrapCoding
@ZctrapCoding
Apr 09 2016 02:58
alright thx @khaduch and thx for trying to help @dhcodes
CamperBot
@camperbot
Apr 09 2016 02:58
zctrapcoding sends brownie points to @khaduch and @dhcodes :sparkles: :thumbsup: :sparkles:
:warning: zctrapcoding already gave khaduch points
:star: 580 | @dhcodes | http://www.freecodecamp.com/dhcodes
Dylan
@dhcodes
Apr 09 2016 02:58
@ALMY91 are you looking for a javascript book to read?
I recommend this one @ALMY91; it's free if you don't mind reading it digitally
http://eloquentjavascript.net/
ALMY91
@ALMY91
Apr 09 2016 02:59
@dhcodes yeps ..
Dylan
@dhcodes
Apr 09 2016 02:59
@ALMY91 it's pretty solid and has good exercises at the end of each chapter
Kevin Schwert
@kevinpschwert
Apr 09 2016 02:59
@ZctrapCoding Did you get it figured out?
Ken Haduch
@khaduch
Apr 09 2016 03:00
@dhcodes - well, this renaming of functions is nothing if not confusing! So I think it would have worked if the proper function names were there. I want to point this out to @kevinpschwert as well - the information in: :point_up: April 8, 2016 10:57 PM - sorry that I didn't notice that you still have queue in your function names... that cannot be helping! I'm sorry that I didn't catch that! (I am also sorry that the tests changed and they aren't checking for the proper function names - I filed an issue about this a couple days ago!)
ZctrapCoding
@ZctrapCoding
Apr 09 2016 03:00
yes @kevinpschwert \
Dylan
@dhcodes
Apr 09 2016 03:00
@khaduch I agree, idk why they changed so many function names. It's not like they were abstractly named
ALMY91
@ALMY91
Apr 09 2016 03:00
@dhcodes my friend whos majoring in computer science actually recommended me the definitive guide book so i wld like to do a cross reference ...
Ken Haduch
@khaduch
Apr 09 2016 03:01
@kevinpschwert - just to make sure you see it - the function names in the "Stand In Line" have been changed. It is no longer queue, so change the two places where queue is used (IN THE FUNCTION NAME, AND WHERE THE FUNCTION IS CALLED) to nextInLine...
Dylan
@dhcodes
Apr 09 2016 03:01
@ALMY91 then get them both. The one I linked is free so no loss
Ken Haduch
@khaduch
Apr 09 2016 03:02
@dhcodes @ALMY91 - "Eloquent JavaScript" is good, but it is really heavy duty on some of the concepts in the early chapters! I'm trying to work through that with another learning group... but it has a load of interesting stuff!
Dylan
@dhcodes
Apr 09 2016 03:05
@khaduch yeah I reread each chapter at least twice. It's slow going but I feel like it's all quality
@khaduch I can see value in other books too, I just always recommend eloquent because it's free and good
Ken Haduch
@khaduch
Apr 09 2016 03:06

@dhcodes

@khaduch I agree, idk why they changed so many function names. It's not like they were abstractly named

The new names make more sense for the functionality, but it is really a tough thing to deal with when the starter code has the wrong function name, or the previously completed exercises no longer work because of that. You have to read the test output to catch the new name, and it is somewhat of an unexpected thing. You really have to be looking for it!

And I agree about the book - great stuff in there, just that he kinds of slams you with the crazy things that he is using for examples... but if you can get it all (and remember it all) it is a great javascript book, from what I've seen so far!

@kevinpschwert - how is it going - have you made progress with that new bit of information about the function names? I am going to be signing off soon, and I don't want to leave you hanging...
Dylan
@dhcodes
Apr 09 2016 03:10
@khaduch I just think they should put a disclaimer on the login page to clear your cache or something so it doesn't pick up old function names
Ken Haduch
@khaduch
Apr 09 2016 03:12
@dhcodes - I don't know if it would be that simple, because your solutions that you have already completed have the old names in them. I don't really know how they store them, I think that it is just a long string of text that they populate back into the code editor? At least if you've ever seen a URL posted by someone with their challenge code, it gets to be rather a long, URL encoded string of text... But it would be nice if they put some kind of reminder about this change on the site in a prominent place - I agree with you on that!
Dylan
@dhcodes
Apr 09 2016 03:13
@khaduch yeah it's tied to the url somehow I think
I need to set this comp up to start making commits
there are a few issues in the github log I could probably help with
ALMY91
@ALMY91
Apr 09 2016 03:23
@dhcodes okay ! haha but back to reality i still hv 15 challenges to go....
@dhcodes moving at a snail's pace
Dylan
@dhcodes
Apr 09 2016 03:24
@ALMY91 lol no worries. I'm putting off a project as we speak
happy coding
ZctrapCoding
@ZctrapCoding
Apr 09 2016 03:30
hey what is the number for this i know what im supposed to do but i dont know that number
 function testLogicalAnd(val) {
  // Only change code below this line

    if (val > 49 && val < 52) {
      return "Yes";
    }

  // Only change code above this line
  return "No";
}

// Change this value to test
testLogicalAnd(50);
You should use the && operator once
You should only have one if statement
testLogicalAnd(0) should return "No"
testLogicalAnd(24) should return "No"
testLogicalAnd(25) should return "Yes"
testLogicalAnd(30) should return "Yes"
testLogicalAnd(50) should return "Yes"
testLogicalAnd(51) should return "No"
testLogicalAnd(75) should return "No"
testLogicalAnd(80) should return "No"
Ken Haduch
@khaduch
Apr 09 2016 03:32
@ZctrapCoding - it looks like numbers with values between "xxx" and "yyy" should return "Yes"
Asif Ulfat
@au2020
Apr 09 2016 03:33
how can add my screenshots here
ZctrapCoding
@ZctrapCoding
Apr 09 2016 03:33
i know but what would be the number because i cant figure out the numbers for this line
if (val > 49 && val < 52) {
Asif Ulfat
@au2020
Apr 09 2016 03:33
i got stuck with a problem
Ken Haduch
@khaduch
Apr 09 2016 03:33
help code format
CamperBot
@camperbot
Apr 09 2016 03:33

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

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

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

rejiya12345
@rejiya12345
Apr 09 2016 03:35

var oldArray = [1,2,3,4,5];

var timesFour = oldArray.map(function(val){
return val * 3;
});// Only change code below this line.

var newArray = oldArray;

what is wrong with this code at I'm stucked
Ken Haduch
@khaduch
Apr 09 2016 03:35
@ZctrapCoding -
You should use the && operator once
You should only have one if statement
testLogicalAnd(0) should return "No"
testLogicalAnd(24) should return "No"
testLogicalAnd(25) should return "Yes" :arrow_left: this is greater than 24
testLogicalAnd(30) should return "Yes"
testLogicalAnd(50) should return "Yes" :arrow_left: this is less than 51...
testLogicalAnd(51) should return "No" :arrow_left: this is greater than 50
testLogicalAnd(75) should return "No"
testLogicalAnd(80) should return "No"
Arpit Saxena
@arpit-saxena
Apr 09 2016 03:36
@rejiya12345 You are supposed to multiply the value by 4
@rejiya12345 Also, write the code below the comment which states // Only change code below this line.
@au2020 Just drag and drop the photos
ZctrapCoding
@ZctrapCoding
Apr 09 2016 03:38
well i got it @khaduch
Ken Haduch
@khaduch
Apr 09 2016 03:38
@ZctrapCoding - great!
rejiya12345
@rejiya12345
Apr 09 2016 03:39
no,it should be multipled by 3
Ken Haduch
@khaduch
Apr 09 2016 03:39
@rejiya12345 - but the variable name is "timesFour"? Is that just misleading information?
Arpit Saxena
@arpit-saxena
Apr 09 2016 03:40
@rejiya12345 which challenge are u working on? It says timesFour on your array name
Ken Haduch
@khaduch
Apr 09 2016 03:41
@rejiya12345 - the instructions are: Use the map function to add 3 to every value in the variable oldArray, and save the results into variable newArray. oldArrayshould not change.
Iterate over Arrays with map - that's the challenge...
Kevin Schwert
@kevinpschwert
Apr 09 2016 03:45
@ZctrapCoding I sent you a message...did you get it?
ZctrapCoding
@ZctrapCoding
Apr 09 2016 03:45
no i dont see the message
Ken Haduch
@khaduch
Apr 09 2016 03:46
@kevinpschwert - I'm still here but about to leave... I was hoping to get your squared away on this 'Stand in Line' - what's your status?
@ZctrapCoding @kevinpschwert - if it is a private chat, the web interface doesn't automatically show the private chat, you have to refresh the page...
ZctrapCoding
@ZctrapCoding
Apr 09 2016 03:47
im on gitter
ALMY91
@ALMY91
Apr 09 2016 03:53
i need some heeelp
on Record Collection challenge...
Ken Haduch
@khaduch
Apr 09 2016 03:57
@ALMY91 - what's your problem / question / code look like?
ALMY91
@ALMY91
Apr 09 2016 03:57
im just very lost as to how to begin with it @khaduch
wiki Record Collection
CamperBot
@camperbot
Apr 09 2016 03:58
no wiki entry for: record collection
ALMY91
@ALMY91
Apr 09 2016 03:58
// 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) {


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Ken Haduch
@khaduch
Apr 09 2016 03:59
@ALMY91 - the collection is an object containing objects that represent record albums (possibly outdated terminology, but at least they didn't use "8 track tapes"... :) )
ALMY91
@ALMY91
Apr 09 2016 04:00
i know i hv to link the id, prop and values to the function collection
but do i do it within the function or outside the function?
@khaduch
Ken Haduch
@khaduch
Apr 09 2016 04:00
@ALMY91 - each album has an ID, which is a numeric value. So you can access individual album by the id.
All of this has to happen inside the function, they tell you "// Only change code below this line"
ALMY91
@ALMY91
Apr 09 2016 04:01
@khaduch okay lemme try it..
ERWIN JOHN T. CARPIO, MD, FPCR
@RadEdje
Apr 09 2016 04:02
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line

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



  result = lookup[val]; 




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

// Change this value to test
phoneticLookup("alpha");
Just wanted to ask... This set up works and I passed the excercise but for some reason if i use result = lookup.val; instead of the lookup[val]; it doesn't work. Is there something about dot notation? or a limitation? So should I prefer to use the bracket notation whenever I can?
Ken Haduch
@khaduch
Apr 09 2016 04:03
@ALMY91 - in the example that the show at the bottom of the code window, they want you do perform some action on the album with the ID 5439, which is a recording by the group ABBA. So that record initially doesn't have an artist property, you are going to have to add it within your function. There are a number of conditions that they give you, so you have to test the values to determine
if they are blank, or not, and add code to handle those according to the description.
@RadEdje - if you review the lesson on "Accessing Object Properties with a Variable" I think that is the name, they point out that when you have the potential property name in a variable, you have to use the bracket notation to address the object.
ALMY91
@ALMY91
Apr 09 2016 04:07
// Only change code below this line
function updateRecords(id, prop, value) {
id = collection[];

  return collection;
}

// Alter values below to test your code
@khaduch im trying to link the id to the the numeric value in the collections function but im not sure if im doing it right
Ken Haduch
@khaduch
Apr 09 2016 04:07
@ALMY91 collection is not an array, it is an object containing other objects...
@ALMY91 - you need something different, like collection[id]
@ALMY91 - you have to use bracket notation because your id is a variable, as they have covered in the lessons prior to this one. So that notation that I put up there :arrow_up: gets you access to one of the albums in the collection.
ALMY91
@ALMY91
Apr 09 2016 04:10
function updateRecords(id, prop, value) {
id= collection[id];

  return collection;
}
Jon Fulk
@jonfulk
Apr 09 2016 04:11
hey everyone! I've been working on the Diff Two Arrays algorithm for hours now... started several weeks ago and keep getting stumped on it. The following doesn't work, but I thought it would at least pass the first test. I planned on getting it to work for 1 and then to revise it for the others. How can I check one against the other and then switch them without writing the same function twice?
function diff(arr1, arr2) {
  var newArr = [],
      common = [];

  for (var i = 0; i < arr2.length; i++) {
    var idx = arr1.indexOf(arr2[i]);

    if (idx != -1) {
      common.push(arr2[i]);
    } else {
      newArr.push(arr2[i]);
    }
  }

  return newArr;
}

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Ken Haduch
@khaduch
Apr 09 2016 04:11
@ALMY91 - you do not want to change the value of the id function argument variable... you merely need to use it to address the collection object...
@jonfulk - there are ways to do that in a manner similar to what you're doing, but in the instructions they give information about a few very helpful functions for manipulating the arrays. I found that I used at least couple of them.
ALMY91
@ALMY91
Apr 09 2016 04:13
@khaduch very confusing .....
Ken Haduch
@khaduch
Apr 09 2016 04:14
@jonfulk - especially Array.filter(), Array.indexOf(), and Array.concat()...
Jon Fulk
@jonfulk
Apr 09 2016 04:14
@khaduch Thanks. Yes, I read through all of those functions but can't seem how they work together. My first iterations included some of those in various combinations but I kept hitting dead ends.
CamperBot
@camperbot
Apr 09 2016 04:14
jonfulk sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 899 | @khaduch | http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Apr 09 2016 04:15
@ALMY91 - don't worry - this one seems to be one of those "leaps" in the series of programming challenges that gets a lot of people stuck...
Jon Fulk
@jonfulk
Apr 09 2016 04:15
@khaduch ok. i'll keep hitting my head against the wall and will not give up on the methods they suggest. Thanks again.
CamperBot
@camperbot
Apr 09 2016 04:15
jonfulk sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: jonfulk already gave khaduch points
Ken Haduch
@khaduch
Apr 09 2016 04:16
@jonfulk - .filter is a good one to focus on. With it, you can determine (with your filtering function) if a value in one array exists in the other... I don't recall if the documentation has such an example in it? Let me take a peek...
ERWIN JOHN T. CARPIO, MD, FPCR
@RadEdje
Apr 09 2016 04:17
@khaduch Oh it's because it's a property name/variable! thanks!
CamperBot
@camperbot
Apr 09 2016 04:17
radedje sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 900 | @khaduch | http://www.freecodecamp.com/khaduch
Jon Fulk
@jonfulk
Apr 09 2016 04:18
@khaduch yeah i was leaning toward using that one, but i must have given up too soon. I appreciate the help! At least I don't feel so incompetent knowing others struggled with this one as well.
Ken Haduch
@khaduch
Apr 09 2016 04:19
@jonfulk - the example that they give of "filtering out all small values" in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter kind of gives you a start. You need to develop a different filtering function, and I used the .indexOf method in mine to check for values in the 'target' array that exist in the other array... (Not very good terminology on my part.)
Jon Fulk
@jonfulk
Apr 09 2016 04:19
@khaduch ok one question about the "target" array --- this has the be the shortest one, right?
@khaduch and that's a helpful tip!
Ken Haduch
@khaduch
Apr 09 2016 04:22
@jonfulk - you actually have to do the same operation on both arrays. So you filter array1 against array2, and then array2 against array1 and then combine the results. At least that is what I did. Not sure if it is the "optimal" solution? And another key - the .filter method has a second argument that they refer to which you can use as this in the filter function - that is how you get access to the other array within the filter function... Not sure if that's a clear explanation, but it is something that I used.
@ALMY91 - okay... now I don't have a lot of time, so let's see where we can go with this record collection...
Jon Fulk
@jonfulk
Apr 09 2016 04:24
@khaduch that makes sense. I was planning to do something like that, but i didn't think i should since it's not DRY.
Ken Haduch
@khaduch
Apr 09 2016 04:26
@jonfulk - that could be true... as I said, my solution might not be optimal, but I was happy with it... maybe I'll look at the answer in the wiki and see if they posted a better solution?

@jonfulk - they do have an interesting solution in the wiki... but you should try to solve it at least one way before you look... But they do have a solution based on looping with for loops that they say

Code Solution 3:
// This solution runs two times faster than solutions 1 and 2

But it is not really DRY, I would say... but the speed might be the important thing in some applications.

azeem259
@azeem259
Apr 09 2016 04:31
hey guys I need help with the Storing Values with the Assignment Operator challenge
Aman Barnwal
@amanbarnwalce
Apr 09 2016 04:37
Help Please
function destroyer(arr) {
  // Remove all the values
  var  l = arguments.length;
  var arr2 = arguments[0];
  for(i=1; i<l-1; i++) {
   arr2 = arr2.filter(function(x){
      return x !== arr[i];
    }); 
  }
  return arr2;
    }

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
CamperBot
@camperbot
Apr 09 2016 04:37
no wiki entry for: pleasefunction destroyerarr remove all the values var l argumentslength var arr2 arguments0 fori1 il-1 i arr2 arr2filterfunctionx return x arri return arr2 destroyer1 2 3 1 2 3 2 3
Coy Sanders
@coymeetsworld
Apr 09 2016 04:40
what's the problem @amanbarnwalce ? Are you sure the exit condition should be i<l-1
?
Ken Haduch
@khaduch
Apr 09 2016 04:43

@ALMY91 - Record Collection... They give you a series of conditions that you are supposed to use in your function:

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 !== "") and `prop` is not "tracks" then update or set the value for the prop.

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

If `value` is blank, delete that `prop`.

So this should result in a series of test conditions that you would use to determine if you should update or set the value for the prop in the album specified by id. OR if you should push (since the tracks array is an array, it should be able to use .push() to add a value to the end of the array.) the value on the tracks array. And if the value is blank, you just delete the property that they name. So you would start with something like this:

if ( value !== "") {
    if ( prop !== "tracks" ) {
        // add the new property and value to the object
        // you just have to figure out how to do that - it involves using bracket notation
    } else {
        // the prop is equal to tracks, so you have to push the new value on the `tracks` array
    }
} else {
    // the value is blank, so you are just supposed to delete the property that they give you
    // from the album that was specified.

Since I have to get going here, way after midnight for me, I already mentioned that you access an album in the collection with collection[id], and you further access properties within the album by adding another [prop] on the end of that, so you get collection[id][prop], which you can use to set the new property (which will effectively update it if you already have a property), you can do the .push() if you are accessing tracks, and you can use the delete function to delete the property.

That might be giving too much information, but I'm outta here for now. I hope that it helps.

khaduch @khaduch - bailing out for the night... happy coding everyone!
Justin
@daemedeor
Apr 09 2016 04:46
@amanbarnwalce errrr... still need help?
V Arun Kumar
@arunvkumr
Apr 09 2016 05:01
@amanbarnwalce arr and arr2 is the same array [1,2,3,1,2,3]. you need to find a way to use 2 and 3 the second and third parametes of destroyer
Marc Vincent Ong
@marcvincentong
Apr 09 2016 05:04
Hey guys
Can't seem to get this right in "Stand in Line"

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

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine([], 1));
console.log(nextInLine([2], 1));
console.log(nextInLine([5,6,7,8,9], 1));
console.log(nextInLine(testArr, 10));// Modify this line to test
console.log("After: " + JSON.stringify(testArr));

This is my code
This is the question
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
Ahmad Izzan
@elarrr
Apr 09 2016 05:05
Hi guys , I think I'm having some problem on the "Convert celcius to fahrenheit"
V Arun Kumar
@arunvkumr
Apr 09 2016 05:05
@marcvincentong shift removes the element from the front of array.. and every shift removes 1 elem and returns the shifted elem. you are shifting it twice.
@marcvincentong and you are overwritting the passed arr with empty array. remove
arr = []
Ahmad Izzan
@elarrr
Apr 09 2016 05:06
function convertToF(celsius) {
// Only change code below this line
var fahrenheit = celcius * (9/5) + 32;
// Only change code above this line
return fahrenheit;
}
// Change the inputs below to test your code
convertToF(30);
that is my code
the return is: ReferenceError: celcius is not defined
V Arun Kumar
@arunvkumr
Apr 09 2016 05:08
@babalah celcius is spelled wrong in formula
Marc Vincent Ong
@marcvincentong
Apr 09 2016 05:08
@arunkumrv what you're meant by i'm shifting twice is when I wrote "return arr.shift();" is it?
I tried removing "arr = [];" but it didn't work
V Arun Kumar
@arunvkumr
Apr 09 2016 05:08
i mean in function defination @babalah celsius
Ahmad Izzan
@elarrr
Apr 09 2016 05:09
omg, thanks a lot @arunkumrv . I feel so stupid lol, been searching on the internet for a long time haha
CamperBot
@camperbot
Apr 09 2016 05:09
babalah sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 434 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Apr 09 2016 05:10
@marcvincentong yes.. when you do arr.shift()it removes 1 from [1,2,3,4,5] and when you use return arr.shift() it removes 2 from [2,3,4,5]. so remove the first shift all should work fine
Marc Vincent Ong
@marcvincentong
Apr 09 2016 05:11
@arunkumrv alright, got it thanks so much! :)
CamperBot
@camperbot
Apr 09 2016 05:11
marcvincentong sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 435 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Apr 09 2016 05:11
you're welcome :+1:
Eldar Tinjić
@EldarT90
Apr 09 2016 05:18
var Car = function() {
  var speed = 10;

  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

  this.getSpeed = function() {
    return speed;
  };
};

var Bike = function() {
 var gear = 4;

this.getGear = function(changes) {
  gear += changes;
};

this.setGear = function() {
  gear += 1;
};};

var myCar = new Car();

var myBike = new Bike();
why is this not working
sry mistake :
var Car = function() {
  var speed = 10;

  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

  this.getSpeed = function() {
    return speed;
  };
};

var Bike = function() {
 var gear = 4;

this.getGear = function(changes) {
  return gear;
};

this.setGear = function() {
  gear += 1;
};};

var myCar = new Car();

var myBike = new Bike();
Justin
@daemedeor
Apr 09 2016 05:20
@EldarT90 whats the error?
Eldar Tinjić
@EldarT90
Apr 09 2016 05:20
myBike.getGear() should return 4 after calling myBike.setGear(4).
its not passing that test
Justin
@daemedeor
Apr 09 2016 05:20
@EldarT90 but you don't set the gear, you're just adding one?
Eldar Tinjić
@EldarT90
Apr 09 2016 05:21
hmm
getGear should return gear you input , no ?
Justin
@daemedeor
Apr 09 2016 05:21
no
getGear just retrieves the objects gear var and setGear should take an input which sets the gear var to what was passed in
Eldar Tinjić
@EldarT90
Apr 09 2016 05:23
var Car = function() {
  var speed = 10;

  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

  this.getSpeed = function() {
    return speed;
  };
};

var Bike = function() {
 var gear = 5;

this.setGear = function(changes) {
  gear += changes;  
  };

this.getGear = function() {
  return gear;

};};

var myCar = new Car();

var myBike = new Bike();
it is still not working
Justin
@daemedeor
Apr 09 2016 05:24
@EldarT90 because you're adding the changes to gear, not just setting it
-.-"
Eldar Tinjić
@EldarT90
Apr 09 2016 05:24
ok got it
passed, tnx
@daemedeor tnx
CamperBot
@camperbot
Apr 09 2016 05:25
eldart90 sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 245 | @daemedeor | http://www.freecodecamp.com/daemedeor
Andy Roush
@AndyRoush
Apr 09 2016 05:27
test
function queue(arr, item) {
  // Your code here

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
I need help with queueing
"Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed."
Can someone point me in the right direction please?
Robert Uivarosi
@URobert
Apr 09 2016 05:29
@AndyRoush first off change the name of the function from queue to nextInLine as it is required in the instructions
second take a look at the push() method, so you know what's the syntax you need to use to add the item element into your array arr
Andy Roush
@AndyRoush
Apr 09 2016 05:31
Ok and the array I'm using is the var testArr?
Robert Uivarosi
@URobert
Apr 09 2016 05:31
lastly on your return you will return the newly formed arr... without it's first element, you can use shift() for that
no
i mean inside the function you will be working with arr
testArr is an example showed below... your function will be called with testArr and 6
an printed out to the console, so you can see how it works
Andy Roush
@AndyRoush
Apr 09 2016 05:34
Ok so, I need to change the return item to a number, and add a new varr arr, which I am defining from the function? Is that how it works?
cssararat
@cssararat
Apr 09 2016 05:34

Hi there. var testObj = {
"an entree": "hamburger",
"my side": "veggies",
"the drink": "water"
};

// Only change code below this line
// Change this line
testObj["an entree"];
testObj['the drink'];

what is wrong in my code?
Robert Uivarosi
@URobert
Apr 09 2016 05:35
@AndyRoush you don't need to declare var arr , you`ll only use arr inside your function
@cssararat which exercise was that ?
kirbyedy
@kirbyedy
Apr 09 2016 05:36
@alofacarl when you add the numbers in bracket it will sum to 20
Tmore23
@Tmore23
Apr 09 2016 05:36
```
Andy Roush
@AndyRoush
Apr 09 2016 05:36
not gonna lie @URobert , I really appreciate the help, but I am still super confused lol
kirbyedy
@kirbyedy
Apr 09 2016 05:36
@alofacarl var myArr = [ 2, 3, 4, 5, 6];
cssararat
@cssararat
Apr 09 2016 05:36
Accessing Objects Properties with Bracket Notation
Robert Uivarosi
@URobert
Apr 09 2016 05:37
@AndyRoush did you change the name of the function?
Andy Roush
@AndyRoush
Apr 09 2016 05:37
I will try and figure it out then with pushing and returning
I did
Robert Uivarosi
@URobert
Apr 09 2016 05:37
@AndyRoush beside that you only need two lines of code
Tmore23
@Tmore23
Apr 09 2016 05:37
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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



}

// Test your code by modifying these values
checkObj("house");
why isnt this allowing me to pass the challenge? it returns what it should
Robert Uivarosi
@URobert
Apr 09 2016 05:37
@AndyRoush the first one will be pushing item into your array (arr) , did you look up the push () Method?
@AndyRoush here you can find the most basic example: http://www.w3schools.com/jsref/jsref_push.asp
Andy Roush
@AndyRoush
Apr 09 2016 05:38
Yeah I learned about push
Robert Uivarosi
@URobert
Apr 09 2016 05:38
@AndyRoush having taken a look at that, how would you push item into array?
Andy Roush
@AndyRoush
Apr 09 2016 05:38
I just dont know what I am supposed to be pushing in.
Robert Uivarosi
@URobert
Apr 09 2016 05:38
look at the syntax
Andy Roush
@AndyRoush
Apr 09 2016 05:38
Am I adding any random number?>
cssararat
@cssararat
Apr 09 2016 05:39
@AndyRoush Accessing Objects Properties with Bracket Notation
Robert Uivarosi
@URobert
Apr 09 2016 05:39
@AndyRoush no, you are pushing exactly the number/value of item to the end of the array
Andy Roush
@AndyRoush
Apr 09 2016 05:39
nextInLine.push([2],1);
oooohhh
I am using item?!
Robert Uivarosi
@URobert
Apr 09 2016 05:39
@AndyRoush it has nothing to do with name of your function
Uzma Khan
@meow414
Apr 09 2016 05:40
please help with weather app project
Robert Uivarosi
@URobert
Apr 09 2016 05:40
those are the requirements
Uzma Khan
@meow414
Apr 09 2016 05:40
how to get started\
I have no clue
Aiden
@AidenKerr
Apr 09 2016 05:40
help for Testing Objects for Properties
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");
CamperBot
@camperbot
Apr 09 2016 05:40
no wiki entry for: for testing objects for properties setupvar myobj gift pony pet kitten bed sleighfunction checkobjcheckprop your code here if myobjhasownpropertycheckprop return myobjcheckprop else return not found test your code by modifying these valuescheckobjgift
Robert Uivarosi
@URobert
Apr 09 2016 05:40
@meow414 look at the result of your API call, figure out how to access specific elements that interest you
Carl P.
@alofacarl
Apr 09 2016 05:42
@kirbyedy ok so...
for (var i = 0; i < myArr.length; i++) {
  total += myArr[i];
kirbyedy
@kirbyedy
Apr 09 2016 05:42
@AidenKerr this line is wrong: return myObj.checkProp;
Robert Uivarosi
@URobert
Apr 09 2016 05:42
@AidenKerr return myObj[checkProp];
kirbyedy
@kirbyedy
Apr 09 2016 05:43
@alofacarl :thumbsup:
Aiden
@AidenKerr
Apr 09 2016 05:43
@URobert why doesn't dot notation work there
Robert Uivarosi
@URobert
Apr 09 2016 05:43
@kirbyedy why isn't it working with . notation there?
Aiden
@AidenKerr
Apr 09 2016 05:43
maybe because it's a variable?
kirbyedy
@kirbyedy
Apr 09 2016 05:43
no idea
Robert Uivarosi
@URobert
Apr 09 2016 05:43
usually from what I recall you need brackets when you have spaces
Eva Crawford
@grooveva
Apr 09 2016 05:43
ng loops
Aiden
@AidenKerr
Apr 09 2016 05:43
ok
kirbyedy
@kirbyedy
Apr 09 2016 05:44
@Tmore23 check this line: else return ('"Not Found"');
Carl P.
@alofacarl
Apr 09 2016 05:44
@kirbyedy thanks. Just trying to understand what the for loop is doing..
i < myArr.length 
is really i < 20?
CamperBot
@camperbot
Apr 09 2016 05:44
alofacarl sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 825 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
Aman Barnwal
@amanbarnwalce
Apr 09 2016 05:46

Hi there!
I am trying to sort an array with elements

[5, 3, 20, 3] //array.sort();

but it returns

[20, 3, 3, 5]
Robert Uivarosi
@URobert
Apr 09 2016 05:47
@AidenKerr either for special character or variables you need [] notation, i guess
Aiden
@AidenKerr
Apr 09 2016 05:47
@URobert thanks
CamperBot
@camperbot
Apr 09 2016 05:47
aidenkerr sends brownie points to @urobert :sparkles: :thumbsup: :sparkles:
:star: 773 | @urobert | http://www.freecodecamp.com/urobert
Robert Uivarosi
@URobert
Apr 09 2016 05:47
@AidenKerr yw
@amanbarnwalce look into sorting number values ;P
Aman Barnwal
@amanbarnwalce
Apr 09 2016 05:48
What's wrong with them?
@AidenKerr
Aiden
@AidenKerr
Apr 09 2016 05:48
with what
Robert Uivarosi
@URobert
Apr 09 2016 05:48
@amanbarnwalce you need something more than sort, but that is usually when you have your numbers as strings
@amanbarnwalce take a look at this:
var a = [5, 3, 20, 3] ;
var b = a.sort(function(a, b){return a-b});
console.log(b);
@amanbarnwalce this will get you the result you are looking for
Aman Barnwal
@amanbarnwalce
Apr 09 2016 05:52
Got it!
thanks @URobert
CamperBot
@camperbot
Apr 09 2016 05:52
amanbarnwalce sends brownie points to @urobert :sparkles: :thumbsup: :sparkles:
Robert Uivarosi
@URobert
Apr 09 2016 05:52
@amanbarnwalce yw
CamperBot
@camperbot
Apr 09 2016 05:52
:star: 774 | @urobert | http://www.freecodecamp.com/urobert
Robert Uivarosi
@URobert
Apr 09 2016 05:52
i gtg
@amanbarnwalce a last thing, variable names are not great... I just wrote that, ofc a , b have nothing to do with (a,b) used inside the function
ALMY91
@ALMY91
Apr 09 2016 05:54
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

}}
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
help im lost need some guidance
CamperBot
@camperbot
Apr 09 2016 05:54
no wiki entry for: im lost need some guidance
Vitor Lory
@vlory73
Apr 09 2016 06:00
@ALMY91 try to address all the conditions of the exercise. you miss (at least) deleting a value when it's ""
Gerard Jorgensen
@gerardjorgensen
Apr 09 2016 06:09
For the random quote machine do you just need like 6 or 7 different quotes or do you need a lot of different cases using API's or something? Also how do you make the twitter link thing? I'm a bit unfamiliar with twitter
Carl P.
@alofacarl
Apr 09 2016 06:10

@ALMY91 I would work on one if statement at a time. Check if it works and then do the next if statement. For example:

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

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

Then do the next one underneath it and check it. And then you can add the else if to connect them when it works out.

Olawale Akinseye
@brainyfarm
Apr 09 2016 06:40
@gerardjorgensen, there are no fast rules about it. The idea of the project is for you to understand how to get it done.
Carl P.
@alofacarl
Apr 09 2016 06:48
ok i figured it out..
var myArr = [ 2, 3, 4, 5, 6];
var total = 0;
for (var i = 0; i < myArr.length; i++) {
  total += myArr[i];
}
myArr.length = 5. How many are in the array.

total += myArr[i] (total = total + myArr[i]) breaks down to..

total = 0 + 2;  // 2
total = 2 + 3; // 5
total = 5 + 4; // 9
total = 9 + 6; // 14
total = 14 + 6; // 20

total = 20
wait 9 + 6 = 15?
oh whoops it's supposed to be 9 + 5 = 14
lol
Tyler Del Rosario
@TylerDelRosario
Apr 09 2016 06:51
I'm honestly confused on how to retrieve the JSON data from Media Wiki.
The documentation shows uses of AJAX and then just using the .getJSON method.
Ken Truong
@kjjtruong
Apr 09 2016 06:55
Hey everyone! I just finished the Caesars Cipher challenge where I had to create a function to decode the ROT13 string. Just wondering if anyone could review my code and provide some feedback as to whether I could've made it more efficient or If there are any potential bugs. Thanks!
function rot13(str) { // LBH QVQ VG!

  var charCode = [];
  var newString = "";

  //1. Get unicode value of rot13 str and push into array.
  //2. If unicode value is between 65-77(inclusive), add 13. If value is between 78-90, minus 13.
  //3. Convert new unicode stored in array to string and store in new string.

  for(var i = 0; i < str.length; i++) {

    if(str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 77){
      charCode.push(str.charCodeAt(i) + 13);  
    } else if (str.charCodeAt(i) >= 78 && str.charCodeAt(i) <= 90) {
      charCode.push(str.charCodeAt(i) - 13);
    } else {
      charCode.push(str.charCodeAt(i));
    }

    newString += String.fromCharCode(charCode[i]);
  }

  return newString;

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Justin
@daemedeor
Apr 09 2016 07:01
@kjjtruong that's fine XD
Ken Truong
@kjjtruong
Apr 09 2016 07:08
alright i'll take that lol thanks @daemedeor
CamperBot
@camperbot
Apr 09 2016 07:08
kjjtruong sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 249 | @daemedeor | http://www.freecodecamp.com/daemedeor
Justin
@daemedeor
Apr 09 2016 07:09
@kjjtruong well actually why push into charCode, why not set a temp var and then just convert at the end and add it?
V1ad1m1r
@V1ad1m1r
Apr 09 2016 07:11
js
function chunkArrayInGroups(arr, size) {
  // Break it up.

 var newArr = [];

  for(var x=0; x<= arr.length; x++){

    newArr.push(arr.slice(0,size));
    for(var i=0; i<size; i++){
    arr.shift();

  }
    if(arr.length<size){
      size = arr.length;
    }


  }

  return newArr;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3);
having trouble when the number in the array isnt divisible by the size. doesnt include final sub array
any ideas?
i solved it by making it... var x=0; x<= arr.length+1; x++
but that seems cheap
Javier
@sh1g
Apr 09 2016 07:15
function largestOfFour(arr) {
  // You can do this!    
  for (i = 0; i < arr.length; i++){
    for (var j = 0; j < arr[i].length; j++) {
      arr[i].sort(function(a,b){
        return b - a;   
        });
     }
  }
  return arr;
}


largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
I'm struck in this part. I've been thinking of slicing the first value but no clue how to get the first value of each sub-array
Eldar Tinjić
@EldarT90
Apr 09 2016 07:15
function rot13(str) { 
  var str1 = str.split("");
  for (i = 0; i<str1.length; i++) {
    if (typeof str1[i] === "string") {
      String.fromCharCode(str1[i]) == String.fromCharCode(str1[i]+13);
  }


}
  return str1;
}

rot13("SERR PBQR PNZC");
am i on right track?
Aleksander Gębicki
@Takumar
Apr 09 2016 07:16
@sh1g first value is just value with 0 index, so write: arr[i][0] it's your first value of i subarray
Javier
@sh1g
Apr 09 2016 07:16
@Takumar oh right!!! thanks !
CamperBot
@camperbot
Apr 09 2016 07:16
sh1g sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 3036 | @takumar | http://www.freecodecamp.com/takumar
Ken Truong
@kjjtruong
Apr 09 2016 07:16
@daemedeor like so?
function rot13(str) { // LBH QVQ VG!

  var newString = "";

  //1. Get unicode value of rot13 str and push into array.
  //2. If unicode value is between 65-77(inclusive), add 13. If value is between 78-90, minus 13.
  //3. Convert new unicode stored in array to string and store in new string.

  for(var i = 0; i < str.length; i++) {

    if(str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 77){
      newString += String.fromCharCode(str.charCodeAt(i) + 13);  
    } else if (str.charCodeAt(i) >= 78 && str.charCodeAt(i) <= 90) {
      newString += String.fromCharCode(str.charCodeAt(i) - 13);
    } else {
      newString += String.fromCharCode(str.charCodeAt(i));
    }

  }

  return newString;

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Justin
@daemedeor
Apr 09 2016 07:17
@kjjtruong nah not really
Eldar Tinjić
@EldarT90
Apr 09 2016 07:17
@daemedeor can you look up my code and tell me if i am on a right track ? thanks
CamperBot
@camperbot
Apr 09 2016 07:17
eldart90 sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 251 | @daemedeor | http://www.freecodecamp.com/daemedeor
Ken Truong
@kjjtruong
Apr 09 2016 07:18
lol ok. Sorry, can you elaborate then @daemedeor
Aleksander Gębicki
@Takumar
Apr 09 2016 07:18
@sh1g you're welcome. Instead of sorting (of course it is good solution) you could also just compare each element in your loop with largets found till far: if(largest < arr[i][j]) { largest = arr[i][j]; }
You can try it after solving it with sort() method.
Justin
@daemedeor
Apr 09 2016 07:18
function rot13(str) { // LBH QVQ VG!

  var newString = "";

  //1. Get unicode value of rot13 str and push into array.
  //2. If unicode value is between 65-77(inclusive), add 13. If value is between 78-90, minus 13.
  //3. Convert new unicode stored in array to string and store in new string.
  var newCode = 0;
  for(var i = 0; i < str.length; i++) {
   newCode = 0;
    if(str.charCodeAt(i) >= 65 && str.charCodeAt(i) <= 77){
      newCode = str.charCodeAt(i) + 13;  
    } else if (str.charCodeAt(i) >= 78 && str.charCodeAt(i) <= 90) {
      newCode = str.charCodeAt(i) - 13;
    } else {
      newCode = str.charCodeAt(i);
    }
     newString += String.fromCharCode(newCode);
  }

  return newString;

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
ALMY91
@ALMY91
Apr 09 2016 07:18
heeelp
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

  else {delete prop}

}
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
can anybody help me out here
Justin
@daemedeor
Apr 09 2016 07:19
@EldarT90 errr.... sorta no need to check typeof
Javier
@sh1g
Apr 09 2016 07:20
@Takumar I'll keep that in mind. I like to try different ways of solving it, I just remembered the sorting from an earlier example
Eldar Tinjić
@EldarT90
Apr 09 2016 07:20
@daemedeor but how can i know if its a letter and not ! or , etc
@daemedeor or rather how can program know
Aleksander Gębicki
@Takumar
Apr 09 2016 07:20

@ALMY91 in such case you should set value of prop property instead of deleting:

if (prop!=="tracks") {delete collection.id.prop;}

also because id and prop are variables you should use bracket notation in such case.
The delete collection[id][prop]; would be fine instead of else {delete prop} you wrote later.

Justin
@daemedeor
Apr 09 2016 07:20
@EldarT90 the program will still parse ! as a string thats the thing -.-"
@EldarT90 the char code list is here: http://www.asciitable.com/
Eldar Tinjić
@EldarT90
Apr 09 2016 07:21
@daemedeor so i should ask if the chardcode is in certain range?
@daemedeor charcode*
Justin
@daemedeor
Apr 09 2016 07:21
@EldarT90 exactly!
ALMY91
@ALMY91
Apr 09 2016 07:21
@Takumar if im not using push what should i do?
@Takumar cause it states that i have to update as well
Eldar Tinjić
@EldarT90
Apr 09 2016 07:21
@daemedeor k tnx, then there is no need to split the string into an array?
CamperBot
@camperbot
Apr 09 2016 07:21
eldart90 sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:warning: eldart90 already gave daemedeor points
Aleksander Gębicki
@Takumar
Apr 09 2016 07:21
@ALMY91 just assignment: collection[id][prop] = value;
Justin
@daemedeor
Apr 09 2016 07:21
@EldarT90 i didn't say that
just no point in checking the typeof
Eldar Tinjić
@EldarT90
Apr 09 2016 07:22
@daemedeor oke, sec let me try that
Justin
@daemedeor
Apr 09 2016 07:22
though you don't HAVE to split it i guess
since you can get the charAt too -.-"
Aleksander Gębicki
@Takumar
Apr 09 2016 07:23
@ALMY91 this: else {collection[id][tracks].push(value);} is almost perfect, but if you want to use bracket notation with tracks - name of property you have to put it in quotes: ["tracks"] or just use dot: collection[id].tracks.push(value);
Eldar Tinjić
@EldarT90
Apr 09 2016 07:26
@daemedeor this still wont work
function rot13(str) { 
  var str1 = str.split("");
  for (var i = 0; i<str1.length; i++) {
    if ( str1.charCodeAt(i) > 64 && str1.charCodeAt(i) < 91) {
      String.fromCharCode(str1[i]) == String.fromCharCode(str1[i]+13);
  }


}
  return str1;
}

rot13("SERR PBQR PNZC");
ALMY91
@ALMY91
Apr 09 2016 07:26
@Takumar if i didn rbr wrongly dot notations are used for words without spacing and bracket notations are used for words w spacings?
Justin
@daemedeor
Apr 09 2016 07:27
@EldarT90 yea because you're not assigning anything really
ALMY91
@ALMY91
Apr 09 2016 07:28
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

  else {delete collection[id][prop];}

}
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Aleksander Gębicki
@Takumar
Apr 09 2016 07:28
@ALMY91 not exactly. Bracket notation is the only way to access properties which are assigned to variables:
var dog = {
  legs: 4;
};
var prop = "legs";
dog.legs = 4;
dog[prop] = 4;
dog["legs"] = 4;
dog["prop"] = 5; // this is WRONG!!!
ALMY91
@ALMY91
Apr 09 2016 07:28
@Takumar okay i just switched my [] in the delete line to dot notations but im still getting an erroer msg
Ken Truong
@kjjtruong
Apr 09 2016 07:29
ahhhh..I see what you mean now! That does seem a lot cleaner and logical. that charCode array really wasn't necessary. Thanks @daemedeor
CamperBot
@camperbot
Apr 09 2016 07:29
kjjtruong sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
Eldar Tinjić
@EldarT90
Apr 09 2016 07:29
@daemedeor does this make more sense ?
CamperBot
@camperbot
Apr 09 2016 07:29
:warning: kjjtruong already gave daemedeor points
Eldar Tinjić
@EldarT90
Apr 09 2016 07:29
function rot13(str) { 
  var skup = [];
  var str1 = str.split("");
  for (var i = 0; i<str1.length; i++) {
    if ( str1.charCodeAt(i) > 64 && str1.charCodeAt(i) < 91) {
      skup += String.fromCharCode(str1[i]+13);
  }


}
  return skup;
}

rot13("SERR PBQR PNZC");
ALMY91
@ALMY91
Apr 09 2016 07:30
blob
Rada
@Radascript
Apr 09 2016 07:30
@Takumar I've been meaning to ask - could you explain why sometimes when property is in a form of a variable, it seems like brackets work and dot notation doesn't?
Aleksander Gębicki
@Takumar
Apr 09 2016 07:31

@ALMY91 you have to show your current code, but I am afraid you have such structure now:

if () {
  if {}
  else {}
  else {}
}

that is wrong, it should be:

if () {
  if {}
  else {}
}
  else {}
Justin
@daemedeor
Apr 09 2016 07:32
@EldarT90 well what if something happened to be at 89 + 13 > 91 right?
@EldarT90 the charcode for A is 64 after all
Eldar Tinjić
@EldarT90
Apr 09 2016 07:32
@daemedeor ye isee now
Aleksander Gębicki
@Takumar
Apr 09 2016 07:32
@Radascript it is just a syntax, you have to differentiate property from variable
In such form: cat.legs JS knows then legs is name of property
In such case: cat[legs] JS is looking for variable called legs and checks what is value of that variable and it tries to find property which is assigned to that variable.
Eldar Tinjić
@EldarT90
Apr 09 2016 07:32
@daemedeor i have symbols isntead of letters
Rada
@Radascript
Apr 09 2016 07:33
@Takumar ahh yeah ok, that makes sense, thank you
CamperBot
@camperbot
Apr 09 2016 07:33
radascript sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
Justin
@daemedeor
Apr 09 2016 07:33
@EldarT90 thats my hint, should be straight forward
CamperBot
@camperbot
Apr 09 2016 07:33
:star: 3037 | @takumar | http://www.freecodecamp.com/takumar
Justin
@daemedeor
Apr 09 2016 07:33
:}
Eldar Tinjić
@EldarT90
Apr 09 2016 07:33
@daemedeor ye i think i need to make new set of rules, concerning this
Aleksander Gębicki
@Takumar
Apr 09 2016 07:34
@Radascript I'm glad that I could help :-)
Eldar Tinjić
@EldarT90
Apr 09 2016 07:39
@daemedeor passed, thanks for your help
CamperBot
@camperbot
Apr 09 2016 07:39
eldart90 sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:warning: eldart90 already gave daemedeor points
Justin
@daemedeor
Apr 09 2016 07:39
@EldarT90 np
ALMY91
@ALMY91
Apr 09 2016 07:40
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
is there smth wrong w my push line
@Takumar
it isn working for one of the criterias involving push..
Aleksander Gębicki
@Takumar
Apr 09 2016 07:41
@ALMY91 id is variable (parameter of function) use bracket notation with it! There is one place where you wrote collection.id..
@ALMY91 you have to see difference between id (variable) and tracks (name of property - not variable). You can use dot with tracks but you have to use brackets with id.
Javier
@sh1g
Apr 09 2016 07:45
@Takumar thank you for your tip! I was sure I had to use slice or shift and was confused why I couldn't get the answer. Finally managed to get it to work =D
CamperBot
@camperbot
Apr 09 2016 07:45
sh1g sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:warning: sh1g already gave takumar points
ALMY91
@ALMY91
Apr 09 2016 07:47
@Takumar for all parameters we are only allowed to use the bracket notations within the function?
Aleksander Gębicki
@Takumar
Apr 09 2016 07:48
@sh1g you're welcome :-)
@ALMY91 have you seen this example: :point_up: 9 kwietnia 2016 09:28 and :point_up: 9 kwietnia 2016 09:32 ?
Please read it again.
V1ad1m1r
@V1ad1m1r
Apr 09 2016 07:50
This message was deleted
Aleksander Gębicki
@Takumar
Apr 09 2016 07:50
@ALMY91 you use bracket notation for variables (parameters of function) or properties which contains space: cats["number of legs"]
Lara
@Duaa1990
Apr 09 2016 07:50
Hi
V1ad1m1r
@V1ad1m1r
Apr 09 2016 07:51
js
function mutation(arr) {

  for (var x=0; x<arr.length; x++){
    arr[x] = arr[x].toLowerCase();

  }
 arr[1]= arr[1].split('');

  for (var i=0; i<=arr[1].length; i++){

  while (arr[0].indexOf(arr[1][i]) !== -1){
    return true;
  }



    return false;



}}  
mutation(["hello", "hey"]);
all the conditions are working except this one... hmmm
Lara
@Duaa1990
Apr 09 2016 07:51
I want to learn JavaScript
V1ad1m1r
@V1ad1m1r
Apr 09 2016 07:51
@Duaa1990 DO IT!!!
Lara
@Duaa1990
Apr 09 2016 07:51
How do I start?
V1ad1m1r
@V1ad1m1r
Apr 09 2016 07:52
@Duaa1990 Sign up, and go through the course :)
Aleksander Gębicki
@Takumar
Apr 09 2016 07:52
@Duaa1990 you can start on the map from "Basic Javascript": https://www.freecodecamp.com/challenges/comment-your-javascript-code
V1ad1m1r
@V1ad1m1r
Apr 09 2016 07:52
or what he said :)
Lara
@Duaa1990
Apr 09 2016 07:53
thanks
NPeyralans
@NPeyralans
Apr 09 2016 07:54
Can anybody tell me why the getQuote function is called twice every time I load my page?
$(document).ready(function() {
    $('#quote_button').on('click', getQuote());
    alert('Call to getQuote');
}); /*  End of document ready  */


function getQuote(){
    var currentAuthor = '';
    var currentQuote = '';
    $.ajax(
    {
        headers: 
        {
            "X-Mashape-Key": "MAuJTfujezmshkCTwNfidy8Zz1nsp1UW4iPjsnwtkKPnrMclju",
            "Content-Type": "application/x-www-form-urlencoded",
            Accept: "application/json"

        }, 
        url: 'https://andruxnet-random-famous-quotes.p.mashape.com/?cat=movies', 
        method: 'POST'}).then(function(data) {
            var json = JSON.parse(data);
            currentQuote = json.quote;
            currentAuthor = json.author;
            console.log(currentAuthor);
            $('#quote_text').text(currentQuote);
            $('#quote_author').append(currentAuthor);
    });
}
Rada
@Radascript
Apr 09 2016 07:56
@NPeyralans maybe link to your pen so we can see the whole thing?
Jalay
@JalaySimaria
Apr 09 2016 07:56

@NPeyralans maybe this is the error:

$('#quote_button').on('click', getQuote());  // remove () from getQuote()

like this:

$('#quote_button').on('click', getQuote);
NPeyralans
@NPeyralans
Apr 09 2016 07:56
Sorry, I've been doing it all locally and haven't set it up on codepen yet
Jalay
@JalaySimaria
Apr 09 2016 07:57
@NPeyralans because, when you put (), that function gets executed
NPeyralans
@NPeyralans
Apr 09 2016 07:57
@JalaySimaria Ah, I didn't know that thanks!
CamperBot
@camperbot
Apr 09 2016 07:57
npeyralans sends brownie points to @jalaysimaria :sparkles: :thumbsup: :sparkles:
:star: 231 | @jalaysimaria | http://www.freecodecamp.com/jalaysimaria
Jalay
@JalaySimaria
Apr 09 2016 07:59
@NPeyralans :+1:
NPeyralans
@NPeyralans
Apr 09 2016 07:59
@JalaySimaria Just tried it - its still running twice every time I refresh!
Nevermind - Its working great now! Thanks everyone!
Pete
@petegarvin1
Apr 09 2016 08:07
Morning all - if anyone fancies more algo practice codewars is pretty sweet :) www.codewars.com/r/yfzYFQ
Jalay
@JalaySimaria
Apr 09 2016 08:09
cool
Aleksander Gębicki
@Takumar
Apr 09 2016 08:09
@ALMY91 have you solved your challenge?
Marc Vincent Ong
@marcvincentong
Apr 09 2016 08:20

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

// Only change code above this line

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

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

Can't seem to get this right
This message was deleted

Instructions
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.

Hint
Remember that undefined is a keyword, not a string.

Anyone can help?
jklaz
@jklaz
Apr 09 2016 08:22
hello
can anyone help with global/local variables in js?
Justin
@daemedeor
Apr 09 2016 08:23
@jklaz whatcha need to know?
jklaz
@jklaz
Apr 09 2016 08:23
i need to declare a global variable and a local one
so i declare a var in a function
and one outside
however i dont pass the test
Justin
@daemedeor
Apr 09 2016 08:24
@jklaz can you show your code?
jklaz
@jklaz
Apr 09 2016 08:25

var myVar=5;

function myLocalScope() {
'use strict';
var myVar=3;
console.log(myVar);
}

myLocalScope();
console.log(myVar);

Justin
@daemedeor
Apr 09 2016 08:25
@jklaz which assignment was it?
jklaz
@jklaz
Apr 09 2016 08:25
Local Scope and Functions
Kalon
@kaloncpu57
Apr 09 2016 08:26
Hello! o/
Justin
@daemedeor
Apr 09 2016 08:26
@jklaz you don't have to declare outside of the function in that one
Dragan
@daces
Apr 09 2016 08:26
@marcvincentong in if statement it should be (a < 0 || b < 0)
jklaz
@jklaz
Apr 09 2016 08:28
if i declare only in the fuction it says no global myVar variable
Marc Vincent Ong
@marcvincentong
Apr 09 2016 08:28
@daces just got it, thanks mate
CamperBot
@camperbot
Apr 09 2016 08:28
marcvincentong sends brownie points to @daces :sparkles: :thumbsup: :sparkles:
:star: 243 | @daces | http://www.freecodecamp.com/daces
jklaz
@jklaz
Apr 09 2016 08:29
cani continue w/o finish it?
can I*
Justin
@daemedeor
Apr 09 2016 08:29
@jklaz yea you're not suposed to have no global variable "No global myVar variable
"
that said
@sludge256 i'm having a few difficulties on local scope and functions, when i declare myVar only inside the function, then the tests fail
Kalon
@kaloncpu57
Apr 09 2016 08:30
@jklaz Are you still trying to console.log(myVar) in the global scope? ^-^
Justin
@daemedeor
Apr 09 2016 08:30
oh wait i lie
XD
@sludge256 ignore my last note
Marc Vincent Ong
@marcvincentong
Apr 09 2016 08:30
@jklaz you have to remove the global variable outside of the function, as instructed
Andrew McKeever
@andmckvr13
Apr 09 2016 08:30
help chunky monkey
CamperBot
@camperbot
Apr 09 2016 08:30

:point_right: algorithm chunky monkey [wiki]

Explanation

Our goal for this Algorithm is to split arr (first argument) into smaller chunks of arrays with the length provided by size (second argument). There are 4 green checks (objectives) our code needs to pass in order to complete this Algorithm:

  1. (['a', 'b', 'c', 'd'], 2) is expected to be [['a', 'b'], ['c', 'd']]
  2. ([0, 1, 2, 3, 4, 5], 3) is expected to be [[0, 1, 2], [3, 4, 5]]
  3. ([0, 1, 2, 3, 4, 5], 2) is expected to be [[0, 1], [2, 3], [4, 5]]
  4. ([0, 1, 2, 3, 4, 5], 4) is expected to be [[0, 1, 2, 3], [4, 5]]

Click More information under the Algorithm title and read the helpful links if you haven't yet.

:pencil: read more about algorithm chunky monkey on the FCC Wiki

Kalon
@kaloncpu57
Apr 09 2016 08:32
Does anybody know of a good (preferably not eval) way to create dynamic if statements?
Justin
@daemedeor
Apr 09 2016 08:33
@kaloncpu57 errrrr.... dynamic if statements?
jklaz
@jklaz
Apr 09 2016 08:33
@kaloncpu57 i tried to remove all console.write then only one ,declaring w/o var keyword declaring outside the function etc
nothing worked
Justin
@daemedeor
Apr 09 2016 08:33
@jklaz you're not supposed to put the var outside of the function
i only had success with it after deleting the console.log then refreshing the page
hence the hint
Kalon
@kaloncpu57
Apr 09 2016 08:34
@daemedeor Yeah, depending on parameters passed to my Object creator I want to use different if statements.
Justin
@daemedeor
Apr 09 2016 08:35
@kaloncpu57 i think you're doing something wrong if you're looking for dynamic if statements
why not check for the typeof and then do a suite of if tests
Kalon
@kaloncpu57
Apr 09 2016 08:36
I'm looking to pass in whether or not I want to check for the Ctrl and/or Alt keys for a keypress event.
Justin
@daemedeor
Apr 09 2016 08:37
@kaloncpu57 oh then do a switch flag
Jalay
@JalaySimaria
Apr 09 2016 08:37
@kaloncpu57 how about this event.ctrlKey and event.altKey
Kalon
@kaloncpu57
Apr 09 2016 08:37
Ah, I completely forgot about switch case
@JalaySimaria I knew about those, but I wanted to change whether or not I was checking for them.
Justin
@daemedeor
Apr 09 2016 08:38
if( typeof var == "object") { useThisIfTest = true; } else { useThisIfTest = false; } if(useThisIfTest) { doCntrlAltKeyAndBind(); }
don't make it more complicated if you can help it
for example
there's a lot of ways to go about it
dynamic if tests are not something that happen often
Kalon
@kaloncpu57
Apr 09 2016 08:40
Yeah, I should be able to make it work fine without them now that I sat back to think about it. Thanks @daemedeor
CamperBot
@camperbot
Apr 09 2016 08:40
kaloncpu57 sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 252 | @daemedeor | http://www.freecodecamp.com/daemedeor
Justin
@daemedeor
Apr 09 2016 08:41
@kaloncpu57 :)
JackeL
@jackel27
Apr 09 2016 09:11
hey, what do you guys think of my tribute page???
http://codepen.io/SimulatedGREG/pen/xVRqEV
Kalon
@kaloncpu57
Apr 09 2016 09:13
@jackel27 Oh man you got me good. haha How do I make it stop in an embeded pen? NotLikeThis
Had to resort to refreshing.
JackeL
@jackel27
Apr 09 2016 09:14
@kaloncpu57 lmao!
Kalon
@kaloncpu57
Apr 09 2016 09:14
I already knew what it was, but I forgot. That was brilliant.
Brendan Kinahan
@BKinahan
Apr 09 2016 09:18
I mean, the codepen preview loads a screenshot, right? :P Not getting me, Bagel Man!
JackeL
@jackel27
Apr 09 2016 09:20
@BKinahan whaat? idk what you mean
Brendan Kinahan
@BKinahan
Apr 09 2016 09:20
@jackel27 uh huh
JackeL
@jackel27
Apr 09 2016 09:21
@BKinahan ??? its pretty bad ass, used paralax
Kalon
@kaloncpu57
Apr 09 2016 09:22
Preview only shows a Run Pen screen for me. d:
JackeL
@jackel27
Apr 09 2016 09:22
hahaha nt @kaloncpu57
sakram07
@sakrma07
Apr 09 2016 09:25
Hello, I need help filtering Array with filter

var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.

array = oldArray.filter(function(val) {
return val > 5;
});

Brendan Kinahan
@BKinahan
Apr 09 2016 09:26
@sakrma07 val > 5 will return true for any value greater than 5, so those values will be included in the new array assigned to array; the rest will be dropped
sakram07
@sakrma07
Apr 09 2016 09:27
val < 6 should work then, but it does not
Brendan Kinahan
@BKinahan
Apr 09 2016 09:29
Ah, this challenge is picky about the name of the array; you changed it from newArray to array; either change it back or reset the code and try it again :)
sakram07
@sakrma07
Apr 09 2016 09:29
Ah lol :D
Bhushan
@bhupha
Apr 09 2016 09:45
no clue how to complete Record Collection challange :(
any hint
Brendan Kinahan
@BKinahan
Apr 09 2016 10:04
@bhupha have you tried writing any code so far?
Bhushan
@bhupha
Apr 09 2016 10:05
yes sir.. a bit success for one condition... but not sure if on right track
how it can be achive without for loop ??
Brendan Kinahan
@BKinahan
Apr 09 2016 10:05
heh.. track.. records..
Pavlo Glushko
@PavloGl
Apr 09 2016 10:05
help nesting for loops
CamperBot
@camperbot
Apr 09 2016 10:05

:point_right: challenge nesting for loops [wiki]

Challenge: Nesting For Loops

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

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

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

Brendan Kinahan
@BKinahan
Apr 09 2016 10:06
@bhupha You don't need to check every entry, just the one that matches the id parameter :)
@bhupha you can access the correct entry using bracket notation.
Bhushan
@bhupha
Apr 09 2016 10:07
yes doing that... but only one one part is done till now... will try to build onit
let see.. if need help will ask once again... I like this live form and people around thanks @BKinahan
CamperBot
@camperbot
Apr 09 2016 10:08
bhupha sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1250 | @bkinahan | http://www.freecodecamp.com/bkinahan
Alex
@rootisenabled
Apr 09 2016 10:08
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
    if (firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    }
    else if (firstName !== contacts[i].firstName) {
      return "No such contact";
    }
    else if (!contacts[i].hasOwnProperty(prop)) {
      return "No such property";
    }
  }

// Only change code above this line
}
hey guys, can someone help?
i know the problem is function is returning first if statement and then stops executing
Justin
@daemedeor
Apr 09 2016 10:10
@rootisenabled because return statement kicks you out of the function
Brendan Kinahan
@BKinahan
Apr 09 2016 10:10
@rootisenabled you check the first contact, then you are guaranteed to reach one of the returns before checking the second.
Justin
@daemedeor
Apr 09 2016 10:11
it seems to be a common thing to do that for people getting to that challenge
well when people have problems
Alex
@rootisenabled
Apr 09 2016 10:11
yeah, I just don't understand how to check all the conditions before returning something
Pavlo Glushko
@PavloGl
Apr 09 2016 10:12
hi! can anyone help me with nesting for loops?
Riful
@timburrows
Apr 09 2016 10:12
Can someone give me hints for Seek and Destroy?
Pavlo Glushko
@PavloGl
Apr 09 2016 10:13
help seek and destroy
CamperBot
@camperbot
Apr 09 2016 10:13

:point_right: algorithm seek and destroy [wiki]

Explanation:

This problem is a bit tricky because you have to familiarize yourself with Arguments, as you will have to work with two or more but on the script you only see two. Many people hardcode this program for three arguments. You will remove any number from the first argument that is the same as any other other arguments.

:pencil: read more about algorithm seek and destroy on the FCC Wiki

Justin
@daemedeor
Apr 09 2016 10:13
@rootisenabled you can use continue; or break; to help you ;)
Riful
@timburrows
Apr 09 2016 10:14
why do you need to convert arguments in to an array?
isn't it an array already?
Andrew McKeever
@andmckvr13
Apr 09 2016 10:22
help mutations
CamperBot
@camperbot
Apr 09 2016 10:22

:point_right: algorithm mutations [wiki]

Problem Explanation:

  • Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array..
:pencil: read more about algorithm mutations on the FCC Wiki
Bhushan
@bhupha
Apr 09 2016 10:25
// 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) {

  switch(id){

    case 5439:
      if(!collection[id][prop]){
        collection[id][prop] = prop;
      }
    break;

    case 2584:
      if(collection[id][prop]){
        collection[id][prop] = "";
      }
     break;
  }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
am i on right track?
abtak mustapha
@mustapha88
Apr 09 2016 10:25
hello
Justin
@daemedeor
Apr 09 2016 10:26
@bhupha no
Bhushan
@bhupha
Apr 09 2016 10:26
Record Collection??
Pavlo Glushko
@PavloGl
Apr 09 2016 10:26
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
   for (var i = 0; i < arr.length; i++) {
     for (var j = 0; i < arr[i].length; j++) {
       product *= arr[i][j] ;
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
what am i missing?
abtak mustapha
@mustapha88
Apr 09 2016 10:26
do i need to import some js filr to run this line
var geocoder = new google.maps.Geocoder();
Justin
@daemedeor
Apr 09 2016 10:26
if you're doing a switch on the hardcoded keys then you're pretty crazy work not sustainable. the other parts... is fine @bhupha
Bhushan
@bhupha
Apr 09 2016 10:27
can i use for loop here ...?
although its not completed yet?
i m trying in liner fashion with what ever I have learned here till now? but no clue?
Justin
@daemedeor
Apr 09 2016 10:29
@bhupha there should not be a need to use a for loop
or a switch case
Bhushan
@bhupha
Apr 09 2016 10:29
then how to trap values?
Justin
@daemedeor
Apr 09 2016 10:29
@bhupha you're on the right track with the non-switch case code
Brendan Kinahan
@BKinahan
Apr 09 2016 10:29
bracket notation :D
Bhushan
@bhupha
Apr 09 2016 10:30
with if else condition?
Justin
@daemedeor
Apr 09 2016 10:30
@bhupha yes
Alex
@rootisenabled
Apr 09 2016 10:31
@daemedeor Thank you, it helped!
CamperBot
@camperbot
Apr 09 2016 10:31
rootisenabled sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 259 | @daemedeor | http://www.freecodecamp.com/daemedeor
Bhushan
@bhupha
Apr 09 2016 10:31
ok so that many if else ...
thanks @daemedeor and @BKinahan
CamperBot
@camperbot
Apr 09 2016 10:31
bhupha sends brownie points to @daemedeor and @bkinahan :sparkles: :thumbsup: :sparkles:
:warning: bhupha already gave bkinahan points
:star: 260 | @daemedeor | http://www.freecodecamp.com/daemedeor
Justin
@daemedeor
Apr 09 2016 10:31
@rootisenabled yup :D
Andrew McKeever
@andmckvr13
Apr 09 2016 10:39
This message was deleted
This message was deleted
This message was deleted
This message was deleted
function mutation(arr) {
  var newArr = [];
  for (var i= 0; i < arr.length; i++) {

    newArr.push(arr[i].toLowerCase());

  }

  return newArr[0].indexOf(newArr[1]) !== -1;
 //boolean, case  and order ignored
}


mutation(["Hello", "leo"]);
Brendan Kinahan
@BKinahan
Apr 09 2016 10:45
@andmckvr13 you can edit messages rather than delete them, also :)
Andrew McKeever
@andmckvr13
Apr 09 2016 10:46
yeah I know, my damn shift button was getting stuck and the page froze...annoying
anways I'm not understanding why this code wont work
Prosvia
@Prosvia
Apr 09 2016 10:47

Why does this code return [["diorite"],["pink wool"]] instead of ["diorite", "pink wool"] I assume it got something to with push, but I'm not sure. I don't get this behavior. It is the Diff Two Arrays.

Like, could flatten it out, but I just want to understand why push is behaving this way.

function diffArray(arr1, arr2) {

    var newArr = [];

    function checker(arr1, arr2) {
        var newArr = [];
        //Takes every element of arr1
        for (var i = 0; i < arr1.length - 1; i++) {
            var match = false;
            for (var j = 0; j < arr2.length - 1; j++) { 
                //compares it to every element of arr0
                if (arr1[i] === arr2[j]) {
                    match = true;
                    break;
                }
            }
            //When there's no match it pushes that element to the new array.
            if (!match) { 
                newArr.push(arr1[i]);
            }
        }
        return newArr;
    }
    //Uses the checker twice to make compare arr1 to arr2 AND arr2 to arr1.
    newArr.push(checker(arr2, arr1));
    newArr.push(checker(arr1, arr2));

    return newArr;
}

diffArray(["andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"]);
Andrew McKeever
@andmckvr13
Apr 09 2016 10:47
anyone have an idea?
Justin
@daemedeor
Apr 09 2016 10:50
@andmckvr13 you're returning a new array, and then pushing into a newArray
so its doing exactly what you told it to
@andmckvr13 you might want to .concat() or join()
Prosvia
@Prosvia
Apr 09 2016 10:51
@daemedeor Oooh! That was too obvious to notice, thanks.
CamperBot
@camperbot
Apr 09 2016 10:51
prosvia sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 261 | @daemedeor | http://www.freecodecamp.com/daemedeor
Bhushan
@bhupha
Apr 09 2016 10:51
// 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(id === 5439){
    collection[id][prop] = value;      
  }

  if(id === 2548){
    collection[id][prop] = value;      


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Justin
@daemedeor
Apr 09 2016 10:51
@andmckvr13 oh wait wrong person XD
Bhushan
@bhupha
Apr 09 2016 10:51
why second IF is not getting its value set??
Justin
@daemedeor
Apr 09 2016 10:51
@Prosvia glad you got the right person even though I gave you the wrong thing XD
@bhupha because you didn't close the if correctly first of all, and don't make the if tests like that...
Andrew McKeever
@andmckvr13
Apr 09 2016 10:52
@daemedeor hahaha I was a bit confuesd :smile:
Justin
@daemedeor
Apr 09 2016 10:53
@bhupha the idea is that you don't need to hard code the id to check, thats basically the same thing with the switch test
Bhushan
@bhupha
Apr 09 2016 10:54
ok some better generic approch
Justin
@daemedeor
Apr 09 2016 10:55
@andmckvr13 well ... you can't do that because you're not checking to see if leo is in that order but looking for the letters in the word
so hello matches because l, e, o all exist
indexOf doesn't actually ignore cases and punction btw
but you'll have to be clear i don't know what mutation is supposed to do
Andrew McKeever
@andmckvr13
Apr 09 2016 10:58
mutation is supposed to check to see if the letters in element 1 are present in element 2
so I need to get te order to not matter
Justin
@daemedeor
Apr 09 2016 10:59
@andmckvr13 exactly
Andrew McKeever
@andmckvr13
Apr 09 2016 10:59
but Im stuck on how to do that
Justin
@daemedeor
Apr 09 2016 10:59
@andmckvr13 how do you know if a letter is where?
Andrew McKeever
@andmckvr13
Apr 09 2016 10:59
i tried to use .split() after the .toLowerCase() but that didnt work
@daemedeor what do you mean?
indexOf()?
Justin
@daemedeor
Apr 09 2016 11:01
@andmckvr13 correct
@andmckvr13 then how can you strip out a specific character?
Andrew McKeever
@andmckvr13
Apr 09 2016 11:04
string.replace()?
Justin
@daemedeor
Apr 09 2016 11:05
@andmckvr13 nope
@andmckvr13 look at slice()
you should now have all the pieces in order to do that exercise
Oscar
@Oscar3000
Apr 09 2016 11:06

var count = 0;

function cc(card) {
// Only change code below this line
var sum;
if(card > 1 && card < 7){

count++;
sum = count + " Bet";
return sum;

} else if(card < 0 || card == 10 || card === "J" || card ==="Q" || card === "K" || card === "A"){

count--;
sum = count + " Hold";
return sum;

}
else{

sum= count + " Hold";
return sum;

}

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc("J"); cc(9); cc(2); cc(7);
Help me out here pls the output of this is "1 Hold" instead of "1 Bet". So what did i do wrong?

Prosvia
@Prosvia
Apr 09 2016 11:06

Okay, I've got another problem. How can my code succeed in comparing the first four cases correctly, but then muck up this:

[1, "calf", 3, "piglet"], [1, "calf", 3, 4] and return an empty array?

function diffArray(arr1, arr2) {
    //Unique characters get pushed to newArr.
    var newArr = [];
    //finds unique characters by
    function checker(arr1, arr2) {    
        //Taking every element of arr1
        for (var i = 0; i < arr1.length - 1; i++) {
            var match = false;
            for (var j = 0; j < arr2.length - 1; j++) { 
                //comparing it to every element of arr2
                if (arr1[i] === arr2[j]) {
                    match = true;
                    break;
                }
            }
            //Pushing that element to the newArr when no match has been found
            if (!match) { 
                newArr.push(arr1[i]);
            }
        }
    }
    //Comparing arr1 to arr2 AND arr2 to arr1, to find ALL unique characters that might be lost by just doing one       way pass
    (checker(arr2, arr1));
    (checker(arr1, arr2));
    return newArr;
}

diffArray([1, "calf", 3, "piglet"], [1, "calf", 3, 4]);
ERWIN JOHN T. CARPIO, MD, FPCR
@RadEdje
Apr 09 2016 11:06
//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++){
   var    x = contacts[i]["firsName"].hasOwnProperty(firstName);
    var   y = contacts[i].hasOwnProperty(prop);
       if(x===true && y===true){
                    return contacts[i][firstName][prop];
        } else 
         if (x === false){
          return "No such contact";        

        } else
          if (y === false){
            return "No such property";
          }

      }    



} 

// Only change code above this line


// Change these values to test your function
lookUpProfile("Akira", "likes");
Hi thought I'd ask for some help on the "Profile look up" javascript excercise? It keeps saying "cannot read property...'hasOwnPropert' of undefined" i know I declared the variable though.
Andrew McKeever
@andmckvr13
Apr 09 2016 11:10
@daemedeor thanks for the help
CamperBot
@camperbot
Apr 09 2016 11:10
andmckvr13 sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 262 | @daemedeor | http://www.freecodecamp.com/daemedeor
Justin
@daemedeor
Apr 09 2016 11:10
@andmckvr13 np it shouldn't be too much harder
Andrew McKeever
@andmckvr13
Apr 09 2016 11:10
Im just not able to focus right now. need to take a beak
*break
Justin
@daemedeor
Apr 09 2016 11:11
@andmckvr13 good idea!
Oscar
@Oscar3000
Apr 09 2016 11:12
@daemedeor Help me out please
Aleksander Gębicki
@Takumar
Apr 09 2016 11:12

@RadEdje you have some things to correct, one of them is mistyped "firstName"
This line: var y = contacts[i].hasOwnProperty(prop); is good because you check whether property which is hidden in prop variable exists in contacts[i] object.

This: var x = contacts[i]["firsName"].hasOwnProperty(firstName); apart from mistyped name of property is not good. You should check if contacts[i] firstName property value is equal to firstName parameter's value.

Justin
@daemedeor
Apr 09 2016 11:14
@Oscar3000 i'm going to bet its something to do with count
Oscar
@Oscar3000
Apr 09 2016 11:15
so i should give them all different variables?
Justin
@daemedeor
Apr 09 2016 11:15
maybe check the value of count
Oscar
@Oscar3000
Apr 09 2016 11:15
the value of count is one
its because of the cc(7);
Justin
@daemedeor
Apr 09 2016 11:16
@Oscar3000 i mean for the conditionals, you're only doing it based on the card
Islam Ibakaev
@dagman
Apr 09 2016 11:17
@Oscar3000 whats the name of bonfire?
Oscar
@Oscar3000
Apr 09 2016 11:17
counting cards @dagman
so what should i base in on @daemedeor
Justin
@daemedeor
Apr 09 2016 11:19
@Oscar3000 check the value of count when you decide to hold or bet
Oscar
@Oscar3000
Apr 09 2016 11:20
With this "cc(2); cc("J"); cc(9); cc(2); cc(7); ", the value of Count is equals One
Aleksander Gębicki
@Takumar
Apr 09 2016 11:22

@RadEdje contacts[i][firstName][prop] is "too long"
contacts[i]["firstName"] or contacts[i].firstName is giving you value offirstNameproperty i.e. "Alex"contacts[i][prop]gives you value of property which is hidden underprop` variable.

contacts[i][firstName][prop] is bad.

Brendan Kinahan
@BKinahan
Apr 09 2016 11:29
@Takumar howdy
Islam Ibakaev
@dagman
Apr 09 2016 11:36
@Oscar3000 i did it
var count = 0;

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

  }

  if([10, 'J', 'Q', 'K','A'].indexOf(card) !== -1) {
   count--;
  }

  if(count > 0) {
    return count + ' Bet';
  }

  return count + ' Hold';
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(10); cc('J'); cc('Q'); cc('K'); cc('A');
looks like it works
Justin
@daemedeor
Apr 09 2016 11:37
@dagman thats my point, he wasn't checking on the count variable to determine whether to bet and or hold
Islam Ibakaev
@dagman
Apr 09 2016 11:38
@daemedeor yep this part is tricky :smile:
  if(count > 0) {
    return count + ' Bet';
  }

  return count + ' Hold';
  // Only change code above this line
}
Justin
@daemedeor
Apr 09 2016 11:39
@dagman well maybe misread instructions
Bhushan
@bhupha
Apr 09 2016 11:41
is it allowed to give full answer i may help @rootisenabled
i just completed that cc few hours back
and stuck at something else... @daemedeor i m not getting correct logic may be
Justin
@daemedeor
Apr 09 2016 11:42
@bhupha see what dagman gave you XD i'm getting pretty tired XD
Bhushan
@bhupha
Apr 09 2016 11:43
ok no problem
Islam Ibakaev
@dagman
Apr 09 2016 11:43
@daemedeor :clap:
:smile:
@bhupha what the problem man!
Bhushan
@bhupha
Apr 09 2016 11:45
function cc(card) {
  // Only change code below this line
  switch(card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count = count +1;
      break;
    case 7:
    case 8:
    case 9:
      count = count;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count = count - 1;
      break;
  }
  if(count > 0){
    playerDecision = "Bet";
  }else if(count === 0){
    playerDecision = "Hold";
  }else{
    playerDecision = "Hold";
  }

  return (count + " " +playerDecision);
this is perfect working solution for CC game propsed by me
plz help me with Record collection anyone
Islam Ibakaev
@dagman
Apr 09 2016 11:46
@bhupha you can do it more perfect lol)
@bhupha
function cc(card) {
  // Only change code below this line
  switch(card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count = count +1;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count = count - 1;
      break;
  }

  if(count > 0){
    playerDecision = "Bet";
  }

  playerDecision = 'Hold';

  return (count + " " +playerDecision);
Bhushan
@bhupha
Apr 09 2016 11:49
yes perfect... dont need that extra condition
Islam Ibakaev
@dagman
Apr 09 2016 11:49
@bhupha :smile:
Bhushan
@bhupha
Apr 09 2016 11:49
when you come to record collection
Islam Ibakaev
@dagman
Apr 09 2016 11:50
@bhupha is it bonfire name?
Bhushan
@bhupha
Apr 09 2016 11:50
plz ping your solution... I m really stuck there...