These are chat archives for FreeCodeCamp/HelpJavaScript

1st
Jul 2016
Diego Mayer
@Chrono79
Jul 01 2016 00:02
@96street
 pagesKeys = Object.keys(pages);
for (var i=0; i < pagesKeys.length; i++) {
  page = pages[pagesKeys[i]];
  ...
}
96street
@96street
Jul 01 2016 00:03
thanks! that makes sense now
clintonjohn
@clintonjohn
Jul 01 2016 00:09
I was wondering if there is a way to solve the record collection challenge without using "tracks" in the function, and instead only working with the variable: prop
Diego Mayer
@Chrono79
Jul 01 2016 00:11
@clintonjohn isn't it hard enough for you as it is? ;)
clintonjohn
@clintonjohn
Jul 01 2016 00:11
it seems like I should be able to update my collection or object I. A way that treats all props the same. In other words, what is unique about "tracks"?
its it being used as an example of a prop?
Brendan Kinahan
@BKinahan
Jul 01 2016 00:11
@clintonjohn tracks, when already present, has an array value, but that doesn't help for cases where it's not present.
Diego Mayer
@Chrono79
Jul 01 2016 00:12
tracks is an array and the other properties aren't
clintonjohn
@clintonjohn
Jul 01 2016 00:12
@BKinahan @Chrono79 thanks!
CamperBot
@camperbot
Jul 01 2016 00:12
clintonjohn sends brownie points to @bkinahan and @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1367 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 1881 | @bkinahan |http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Jul 01 2016 00:13
ooh, palindromic brownie points. stniop einworb cimordnilap, hoo
Diego Mayer
@Chrono79
Jul 01 2016 00:13
I should have stopped helping and doing challenges when I reached 1337 :P
Brendan Kinahan
@BKinahan
Jul 01 2016 00:14
@Chrono79 Pro-tip: if you ever decide you're going to stop on a specific number, don't let anyone know or they'll send you a point just to mess it up ;)
clintonjohn
@clintonjohn
Jul 01 2016 00:14
@BKinahan isn't it a palindromic number of completed challenges?
Brendan Kinahan
@BKinahan
Jul 01 2016 00:15
@clintonjohn nah, there aren't 1881 challenges!
clintonjohn
@clintonjohn
Jul 01 2016 00:15
Haha!
Diego Mayer
@Chrono79
Jul 01 2016 00:15
help brownie points
CamperBot
@camperbot
Jul 01 2016 00:15

:point_right: brownie points [wiki]

Brownie Points

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 two ways you can get Brownie Points:

  1. Complete challenges - you get one point per challenge you complete
  2. 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

clintonjohn
@clintonjohn
Jul 01 2016 00:16
So that's why mine is almost equal to my challenge completions. Ahh
@BKinahan also I noticed some peoples answers for the record collection challenge include using "undefined" to set a new array, but others are able to bypass writing that out
Brendan Kinahan
@BKinahan
Jul 01 2016 00:20
@clintonjohn yeah, hasOwnProperty() is probably a better way to go about it.
clintonjohn
@clintonjohn
Jul 01 2016 00:21
Thanks. I've even seen that bypassed successfully
clintonjohn
@clintonjohn
Jul 01 2016 00:29
Maybe that wa door an earlier version of the question
Melissa Guerrero
@Mmgfrog
Jul 01 2016 00:31
"Instructions: Call the processArg function with an argument of 7 and assign its return value to the variable processed."
Jatinder singh
@jatinder751
Jul 01 2016 00:31
Hello guys, i am stuck on word blanks challenge of javascript, anyone please help.
Melissa Guerrero
@Mmgfrog
Jul 01 2016 00:32
I understand calling a function. I don't understand "with an argument of 7." What does that mean?
Diego Mayer
@Chrono79
Jul 01 2016 00:32
@Mmgfrog what do you make of that? the argument is the thing between ()
@jatinder751 first: // Your code below this line
Melissa Guerrero
@Mmgfrog
Jul 01 2016 00:33
@Chrono79 So for example function processArg(7)?
Diego Mayer
@Chrono79
Jul 01 2016 00:33
@Mmgfrog yes
Norvin Burrus
@ndburrus
Jul 01 2016 00:34
@Mmgfrog What are you working on (exercise name)?
Diego Mayer
@Chrono79
Jul 01 2016 00:34
@jatinder751 you're not using your function arguments
review this challenge: https://www.freecodecamp.com/challenges/constructing-strings-with-variables
Melissa Guerrero
@Mmgfrog
Jul 01 2016 00:34
@ndburrus this is Assignment with a ReturnedValue
Norvin Burrus
@ndburrus
Jul 01 2016 00:35
@Mmgfrog ok, thank you... can you post your code so far?
CamperBot
@camperbot
Jul 01 2016 00:35
ndburrus sends brownie points to @mmgfrog :sparkles: :thumbsup: :sparkles:
:cookie: 184 | @mmgfrog |http://www.freecodecamp.com/mmgfrog
Jatinder singh
@jatinder751
Jul 01 2016 00:36
@Mmgfrog thanks for pointing out. ;)
CamperBot
@camperbot
Jul 01 2016 00:36
jatinder751 sends brownie points to @mmgfrog :sparkles: :thumbsup: :sparkles:
:cookie: 185 | @mmgfrog |http://www.freecodecamp.com/mmgfrog
Norvin Burrus
@ndburrus
Jul 01 2016 00:36
help format @Mmgfrog
CamperBot
@camperbot
Jul 01 2016 00:36

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Jatinder singh
@jatinder751
Jul 01 2016 00:37
@Chrono79 What is the role of function in this? can i delete the function and than create separate strings and add them?
Diego Mayer
@Chrono79
Jul 01 2016 00:37
no, you have to use the function and the place where you should write your code is delimited by comments @jatinder751
The function contains your code and you could call it several times with different arguments
Norvin Burrus
@ndburrus
Jul 01 2016 00:38
@Mmgfrog the argument is the var/iable that the called function will use as input... :palm_tree:
Melissa Guerrero
@Mmgfrog
Jul 01 2016 00:38
```
Norvin Burrus
@ndburrus
Jul 01 2016 00:38
@Mmgfrog ...it (posting code) takes some getting used to... you may find pressing shift + enter gives you extrane line feeds, and the backtick/c key located to the left of the number one key... also, there are 2 buttons chat & compose that you might find useful... and, if you click on the 3 elipses to the right of your comments/text, you have a few options for editing... :)
Melissa Guerrero
@Mmgfrog
Jul 01 2016 00:39
yep oops I didn't mean to hit enter. sorry
I really haven't coded anything because I don't understand what they're asking for.
Diego Mayer
@Chrono79
Jul 01 2016 00:39
you can edit your posts @Mmgfrog at the right of post time the ... (also delete them)
Jatinder singh
@jatinder751
Jul 01 2016 00:40
@Chrono79 thank you, i will try it and hope i get it.
CamperBot
@camperbot
Jul 01 2016 00:40
jatinder751 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1368 | @chrono79 |http://www.freecodecamp.com/chrono79
reynro03
@reynro03
Jul 01 2016 00:42
Hi all, I am stuck on Record Collection in Javascript. It says "If prop does not contain the key "tracks" before you update it, create an empty array before pushing a track to it." But the error I get is not having a Track listed for ABBA - all others are green marks, meaning it isn't creating a new array for props that are tracks. Is the instruction off? Do i have to put an if statement inside the "if prop = tracks" to bsay "if prop = tracks and if id doesn't have a tracks, add it"?
Melissa Guerrero
@Mmgfrog
Jul 01 2016 00:43
Thanks anyway @Chrono79 and @ndburrus, I will look up more about this topic and try again another way.
CamperBot
@camperbot
Jul 01 2016 00:43
mmgfrog sends brownie points to @chrono79 and @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 755 | @ndburrus |http://www.freecodecamp.com/ndburrus
:star2: 1369 | @chrono79 |http://www.freecodecamp.com/chrono79
Melissa Guerrero
@Mmgfrog
Jul 01 2016 00:43
Can't get the FCC code to copy-paste.
and have this chat open
Norvin Burrus
@ndburrus
Jul 01 2016 00:44
@Mmgfrog ok, try this.... a) start typing in your chat area, b) type shift + enter 3 or 4 times, c) type the 3 backticks (remember the bactick key is to the left of the #1 key) above & below where the code will be pasted, d) paste your code, e) press enter... then your code will be posted... if not, just type the one line of function code... :)
Diego Mayer
@Chrono79
Jul 01 2016 00:44
there is an arrow to open the chat in another tab @Mmgfrog at the top
Diego Mayer
@Chrono79
Jul 01 2016 00:47
@reynro03
if statement inside the "if prop = tracks" to bsay "if prop = tracks and if id doesn't have a tracks, add it"?
yes
@jatinder751 reset the challenge, and don't put quotes around your vars
Norvin Burrus
@ndburrus
Jul 01 2016 00:49
@jatinder751 the exercise wants a sentence (madlib) to be built. the sentence needs to be a complete sentence. this sentence will use the 4 word types given. so, you'll be working with putting strings together.... getting clearer?
Diego Mayer
@Chrono79
Jul 01 2016 00:49
don't edit code above the comment // Your code below this line or below // Your code above this line
@ndburrus

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

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
Jatinder singh
@jatinder751
Jul 01 2016 00:50
@Chrono79 how do you copy the code to paste it here.
Norvin Burrus
@ndburrus
Jul 01 2016 00:51
@Chrono79 thanks... i overlooked it.. :telescope:
CamperBot
@camperbot
Jul 01 2016 00:51
ndburrus sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1370 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jul 01 2016 00:51
:point_up: 30 de junio de 2016 21:36 @jatinder751
Norvin Burrus
@ndburrus
Jul 01 2016 00:52
@jatinder751 ok, this code outputs the following: => 'my myNoun is myAdjective And myVerb myAdverb.' ...see what's happening? you're defeating the purpose of the given variables. you're using the names, but as strings!
Jatinder singh
@jatinder751
Jul 01 2016 00:52
yes i see it, but i am having hard time relating this with the function.
Norvin Burrus
@ndburrus
Jul 01 2016 00:54
@jatinder751 ok... let's start at the top... here: function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) { this is a function (wordBlanks) that receives input (in this case, 4 word types). see this? these actual words could be anything - corectly categorized - of course. the sample input shows what they are: dog, big, etc... follow?
Jatinder singh
@jatinder751
Jul 01 2016 00:55
yes i get it to that point @ndburrus
yes, i do
Norvin Burrus
@ndburrus
Jul 01 2016 00:56
@jatinder751 ok, great! so, what the code is seing is not the variable inputs (as far as your output is concerned). do you understand the code output above? :point_up: June 30, 2016 8:52 PM
Jatinder singh
@jatinder751
Jul 01 2016 00:58
okay, so do i need to create the variables by the name mynoun,yveb etc, and than add them to produce reult variable
@ndburrus
Diego Mayer
@Chrono79
Jul 01 2016 00:58
@jatinder751 you don't need to create them, they come with your function declaration
Melissa Guerrero
@Mmgfrog
Jul 01 2016 00:58
// Setup
var processed = 0;

function processArg(num) {
  return (num + 3) / 5;
}

// Only change code below this line
function processArg(7) {
 return (num + 3) / 5;
}
processArg = processed;
var processed = 2;
OK I think this is the code posting you were patiently trying to explain. The instructions are "Call the processArg function with an argument of 7 and assign its return value to the variable processed."
reynro03
@reynro03
Jul 01 2016 00:58
@chrono79 thank you. I tried collection[id].indexOf("tracks") >= 0 to check if it contained "tracks" as a property. didn't work. is there another way of testing if it contains trakcs?
CamperBot
@camperbot
Jul 01 2016 00:58
reynro03 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1371 | @chrono79 |http://www.freecodecamp.com/chrono79
Norvin Burrus
@ndburrus
Jul 01 2016 00:59
@jatinder751 yes.... to ensure understanding, you're not creating the variables. they already exist - we just need to use them (as variables, not strings)... clear as mud?
Peter Kenward
@PeterKenward
Jul 01 2016 00:59
function arrayLower(arr){ var i=0; while(i<arr.length){ arr[i]=arr[i].toLowerCase(); i++;}return(arr);} arrayLower(["hello","Hey"]);
Diego Mayer
@Chrono79
Jul 01 2016 00:59
@reynro03 yes, try hasOwnProperty
Peter Kenward
@PeterKenward
Jul 01 2016 00:59
that went wrong
PeterKenward @PeterKenward tries again
Melissa Guerrero
@Mmgfrog
Jul 01 2016 00:59
Had to change browsers to get that to work.
Diego Mayer
@Chrono79
Jul 01 2016 00:59
@Mmgfrog remember we talked about processArg(7)
Melissa Guerrero
@Mmgfrog
Jul 01 2016 01:00
@Chrono79 yes, it didn't work
Peter Kenward
@PeterKenward
Jul 01 2016 01:00
function arrayLower(arr){ var i=0; while(i<arr.length){ arr[i]=arr[i].toLowerCase(); i++;}return(arr);} arrayLower(["hello","Hey"]);
Jatinder singh
@jatinder751
Jul 01 2016 01:00
@ndburrus How do we use them as variables?
sorry if i am frustrating you.
Diego Mayer
@Chrono79
Jul 01 2016 01:00
@Mmgfrog you modifed the function declaration function processArg(7) { put that back to function processArg(num) {
you had to call the function below instead
Norvin Burrus
@ndburrus
Jul 01 2016 01:01
@Mmgfrog ok, this needs a little work: Call the processArg function with an argument of 7 and assign its return value to the variable processed. your code is assigning the value of 2 to processed, and in the prior line assigning processed to processArg.... see what's happening? or, clear as mud?
@jatinder751 use the data exactly how it's given to us. whatever value it is given by the testing function will transfer (to the function) via the variable...
Jatinder singh
@jatinder751
Jul 01 2016 01:02
going for a walk, i be back in 5 mins @ndburrus
Norvin Burrus
@ndburrus
Jul 01 2016 01:03
@jatinder751 ok... :walking:
reynro03
@reynro03
Jul 01 2016 01:03
@Chrono79 thank you!
CamperBot
@camperbot
Jul 01 2016 01:03
reynro03 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: reynro03 already gave chrono79 points
Diego Mayer
@Chrono79
Jul 01 2016 01:03

@Mmgfrog

// Example
var changed = 0;

function change(num) {
  return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 0;

function processArg(num) {
  return (num + 3) / 5;
}

// Only change code below this line

This is the code you start with

Melissa Guerrero
@Mmgfrog
Jul 01 2016 01:03
OK I took out the (7) and put it back to (num). I took out the var processed = 2;
Diego Mayer
@Chrono79
Jul 01 2016 01:04
@Mmgfrog see this? changed = change(10);
That's Call the change function with an argument of 10 and assign its return value to the variable changed.
Melissa Guerrero
@Mmgfrog
Jul 01 2016 01:04
@Chrono79 yes. should I put processArg = processed(7)?
Diego Mayer
@Chrono79
Jul 01 2016 01:05
the other way around
processArg is your function and processed your var
Norvin Burrus
@ndburrus
Jul 01 2016 01:05
@Mmgfrog assign its return value to the variable processed.
Peter Kenward
@PeterKenward
Jul 01 2016 01:06
Do I understand correctly that I can define a method to be used on all arrays, with Array.prototype.newMethod?
Melissa Guerrero
@Mmgfrog
Jul 01 2016 01:06
Ah. I switched it around and it worked. Thanks @Chrono79
CamperBot
@camperbot
Jul 01 2016 01:06
mmgfrog sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: mmgfrog already gave chrono79 points
Norvin Burrus
@ndburrus
Jul 01 2016 01:08
@PeterKenward this may be helpful:
Melissa Guerrero
@Mmgfrog
Jul 01 2016 01:08
Sometimes when run the code and the condition statements in red pop up at the bottom, and I try to reverse-engineer the solution, I get myself in trouble. LOL
Peter Kenward
@PeterKenward
Jul 01 2016 01:08
@ndburrus I am more confused now I read that... :(
Diego Mayer
@Chrono79
Jul 01 2016 01:09
@PeterKenward yes
Array.prototype.hello = (function() {return "hello"})();
arr = [1,2];
console.log(arr.hello);
Peter Kenward
@PeterKenward
Jul 01 2016 01:10
so if I wanted to create a method: Array.prototype.addDonut, whose function is to push("donut") to an array, how would I do that please?
Oh thanks for your example...
Will
@Will-is-Coding
Jul 01 2016 01:11
@PeterKenward An object's prototype is like its basic design, its blueprint - what it can do and what it holds. Now any new object of that kind inherits it all because it is based on that design/blueprint. It's like a plastic mold. The plastic is in the shape of the mold after it's done and then you can modify it how you like.(Weird analogy but eh)
Norvin Burrus
@ndburrus
Jul 01 2016 01:12
@PeterKenward :point_up: June 30, 2016 9:08 PM i like the cookie cutter analogy...
Peter Kenward
@PeterKenward
Jul 01 2016 01:12
thanks y'all:)
PeterKenward @PeterKenward goes away to try pushing some donuts around
Peter Kenward
@PeterKenward
Jul 01 2016 01:13
thanks @Will-is-Coding
CamperBot
@camperbot
Jul 01 2016 01:13
peterkenward sends brownie points to @will-is-coding :sparkles: :thumbsup: :sparkles:
:cookie: 427 | @will-is-coding |http://www.freecodecamp.com/will-is-coding
Norvin Burrus
@ndburrus
Jul 01 2016 01:14
@Mmgfrog you might like this:
Will
@Will-is-Coding
Jul 01 2016 01:15
@PeterKenward That's why when you do var newArray = [1, 2, 3]; console.log(newArray.length) you will get the length of newArray, because in the Array.prototype it has a .length
Peter Kenward
@PeterKenward
Jul 01 2016 01:32
Array.prototype.donut = function(){Array.prototype.push("donut")}(); arr.donut(); console.log(arr);
I am going round in circles here! :)
I keep thinking I get it, but then alas... not so much!
Diego Mayer
@Chrono79
Jul 01 2016 01:33
@PeterKenward https://repl.it/C7nW/1
inside the function use this (keyword) instead of Array.prototype
Orbers
@Orbers
Jul 01 2016 01:35

When I run this on repl.it the code works and passes all tests. When I copy it into Freecodecamp Record Collection it doesn't work.

why?

function updateRecords(id, prop, value) {
  var trackStorage;
  var numOfTracks;

  if(collection[id].tracks) {
        var trackStorageTemp = [];
        var numOfTracksTemp = collection[id].tracks.length;

        for(i = 0; i < numOfTracksTemp; i++) {
            trackStorageTemp.push(collection[id].tracks.pop());
        }
        trackStorage = trackStorageTemp.reverse();
        numOfTracks = numOfTracksTemp;
    }

    collection[id][prop] = value;

    if(collection[id].tracks){
        for(i = 0; i < numOfTracks; i++) {
            collection[id].tracks.unshift(trackStorage.pop());
        }
    }

    if(collection[id][prop] === '') {
        delete collection[id][prop];
   }

    return collection;
}
Peter Kenward
@PeterKenward
Jul 01 2016 01:35
Thanks @Chrono79
CamperBot
@camperbot
Jul 01 2016 01:35
peterkenward sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1372 | @chrono79 |http://www.freecodecamp.com/chrono79
Peter Kenward
@PeterKenward
Jul 01 2016 01:36
this is some cool stuff!
:)
Diego Mayer
@Chrono79
Jul 01 2016 01:36
@Orbers why all the reverse, unshift and Temp vars?
Orbers
@Orbers
Jul 01 2016 01:37
@Chrono79 That's just the way I got it to work on Repl.it...
Dolan
@dguh
Jul 01 2016 01:38
Could someone check out my weather app real quick? I cant get the temperature to show up for some reason.
JohnWright24
@JohnWright24
Jul 01 2016 01:38
Hey guys, I'm having issues with the "Storing Values with the Assignment Operator" javascript challenge. Any suggestions?
I'm supposed to be assigning variable "a" to "b" after establishing that they both are equal to 7
Diego Mayer
@Chrono79
Jul 01 2016 01:39
@JohnWright24 no, only set a = 7 and the use a to set b value
JohnWright24
@JohnWright24
Jul 01 2016 01:40
@Chrono79 Can you show me how you did it? I'm still lost lol
Diego Mayer
@Chrono79
Jul 01 2016 01:41
@Orbers is there any test marked red or something?
@JohnWright24
a = 7;
b = a;
Norvin Burrus
@ndburrus
Jul 01 2016 01:41
@jatinder751 you may enjoy this:
  • JavaScript data types explained
    ... scroll down to Strings ...the variable foo in the example can be thought of as the variable word types (myNoun, myAdjective, etc.) :ok:
Diego Mayer
@Chrono79
Jul 01 2016 01:42
@dguh link?
Orbers
@Orbers
Jul 01 2016 01:42
@Chrono79 the second, fourth and fifth tests are red.
Norvin Burrus
@ndburrus
Jul 01 2016 01:43
@JohnWright24 are you comfortable assigning 7 to a?
Orbers
@Orbers
Jul 01 2016 01:43
@Chrono79 my main frustration is that the code works in rep.it but doesn't work in freecodecamp.com
Diego Mayer
@Chrono79
Jul 01 2016 01:43
@Orbers so all that involve tracks
Orbers
@Orbers
Jul 01 2016 01:43
@Chrono79 yes
Diego Mayer
@Chrono79
Jul 01 2016 01:44
@Orbers tracks should be an array
Orbers
@Orbers
Jul 01 2016 01:44
oh, I see...
JohnWright24
@JohnWright24
Jul 01 2016 01:44
@ndburrus Yep, got it! Thanks man. The problem was my setup
CamperBot
@camperbot
Jul 01 2016 01:44
:cookie: 756 | @ndburrus |http://www.freecodecamp.com/ndburrus
johnwright24 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Diego Mayer
@Chrono79
Jul 01 2016 01:45
@JohnWright24 you're welcome
Norvin Burrus
@ndburrus
Jul 01 2016 01:45
@JohnWright24 ok, great! :vertical_traffic_light:
Orbers
@Orbers
Jul 01 2016 01:45
Thanks @Chrono79 . now, I know what my problem is. I'll keep working on it
CamperBot
@camperbot
Jul 01 2016 01:45
orbers sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1373 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jul 01 2016 01:46
@Orbers there are simpler ways to do that challenge without using all those array methods
Orbers
@Orbers
Jul 01 2016 01:47
@Chrono79 yeah, I just looked at your answer. I'll keep plugging away
Moisés Man
@moigithub
Jul 01 2016 01:48
@dguh first.. ur openweather url need to have http:// at start.. else it will be treated as relative path from codepen
openweather only support http:// protocol (think there are a paid version with https support)
chrome from version 5.+ support geolocation only on https protocol (secure connections)
but.. then u will have a problem of mixed content... https on codepen.. and http on openweather api (check console/devtools)
posible solutions are.. use another api for geolocation and http on openweather
use another weather api with https support
use a https proxy to bridge ur http openweather
... dont use chrome ??
Diego Mayer
@Chrono79
Jul 01 2016 01:50
@moigithub @dguh jsonp to the rescue!
or both
Dolan
@dguh
Jul 01 2016 01:52
okay so my api gives me a json
Diego Mayer
@Chrono79
Jul 01 2016 01:52
geolocation and if it fails api geolocation
but that doesn't work with chrome?
Moisés Man
@moigithub
Jul 01 2016 01:53
yep.... thats http://
geolocatoin on chrome v5.+ ONLY work with HTTPS
reread above :P
Dolan
@dguh
Jul 01 2016 01:54
i saw that it only works with chrome v5.+ im just confused because the geolocation gave me my current coordinates
Diego Mayer
@Chrono79
Jul 01 2016 01:54
@dguh geolocation works on https and openweather doesn't
Dolan
@dguh
Jul 01 2016 01:54
got it
that makes more sense
ill try it in safari
Diego Mayer
@Chrono79
Jul 01 2016 01:55
I'm just repeating what @moigithub said, you could try with firefox and http on codepen instead
Dolan
@dguh
Jul 01 2016 01:58
downloading firefox now
Moisés Man
@moigithub
Jul 01 2016 01:59
u can try with this.. ip-api.com/json/ to get ip location
some1 said there were anther "better" but i forgot which was .P
for the exercise probably would be enough....
Chris Rutherford
@cjrutherford
Jul 01 2016 02:00
okay, so I guess I'm a little confused on how to use the reduce method..... Help?
Moisés Man
@moigithub
Jul 01 2016 02:01
try youtube ? :P @cjrutherford
Chris Rutherford
@cjrutherford
Jul 01 2016 02:01
@moigithub sounds about right....
Jatinder singh
@jatinder751
Jul 01 2016 02:02
@ndburrus Hello again
Norvin Burrus
@ndburrus
Jul 01 2016 02:03
@jatinder751 hi, did you like the article?
Jatinder singh
@jatinder751
Jul 01 2016 02:04
Yes it was good, and i was thinking about what i was doing wrong, but couldnt come up with a straight answer lol, but lets begin from scratch
@ndburrus
how can i make those variable work with the function,
Norvin Burrus
@ndburrus
Jul 01 2016 02:05
@jatinder751 ok, which exercise/lesson was it?
Nany
@NanyR
Jul 01 2016 02:05
@GregatGit thanks!! indexOf worked!
CamperBot
@camperbot
Jul 01 2016 02:05
nanyr sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 641 | @gregatgit |http://www.freecodecamp.com/gregatgit
Jatinder singh
@jatinder751
Jul 01 2016 02:06
the same one we left at earlier
Norvin Burrus
@ndburrus
Jul 01 2016 02:06
@jatinder751 ok, think of a sentence you'd like to create, and type it in - use the four word types given, and ensure it is a complete sentence (ie spacing & punctuation)
MaddAdam
@MaddAdam
Jul 01 2016 02:06
hello, I've gotten to the basic algorithm scripting, and I'm getting through them fine, but my code is pretty ugly, and I have a feeling that if I went through a few more times I could make it shorter and cleaner. should I be going back to clean things up now, or should I focus on learning more about javaScript now?
Jatinder singh
@jatinder751
Jul 01 2016 02:07
okay the four word types that are given, can i define them as strings, or new variables and than add them to produce the result string?
@ndburrus
Norvin Burrus
@ndburrus
Jul 01 2016 02:08
@jatinder751 stay with me... just make the sentence first.... then the code may/will make more sense...
Jatinder singh
@jatinder751
Jul 01 2016 02:08
my dog is big and ran quickly is the sentence i wuld like to make
Chris Rutherford
@cjrutherford
Jul 01 2016 02:08
@moigithub found a really good explanation of the reduce method. https://youtu.be/Wl98eZpkp-c
Jatinder singh
@jatinder751
Jul 01 2016 02:08
*would
Norvin Burrus
@ndburrus
Jul 01 2016 02:09
@jatinder751 where is the punctuation? capitalization?
ashantetimoll
@ashantetimoll
Jul 01 2016 02:09

Can anyone assist? running to an issue with local scope and functions. var myVar = "test";
function myLocalScope() {
'use strict';

var myVar ="test";
console.log(myVar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope

// Now remove the console log line to pass the test

Norvin Burrus
@ndburrus
Jul 01 2016 02:11
@ashantetimoll what is this var myVar = "test"; doing above/outside the function? note the instructions: Declare a local variable myVar inside myLocalScope and myVar is assigned a value globally, & then locally...
Jatinder singh
@jatinder751
Jul 01 2016 02:12
okay i think i hav eit, give me few minutes @ndburrus
Norvin Burrus
@ndburrus
Jul 01 2016 02:13
@jatinder751 how are we doing? ok...
Migs
@migsor3
Jul 01 2016 02:13
Hello
Norvin Burrus
@ndburrus
Jul 01 2016 02:14
@migsor3 hi
Migs
@migsor3
Jul 01 2016 02:14
does anyone have the solution for "Increment a Number with JavaScript"
Chris Rutherford
@cjrutherford
Jul 01 2016 02:14
@moigithub thanks again!
CamperBot
@camperbot
Jul 01 2016 02:14
cjrutherford sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1599 | @moigithub |http://www.freecodecamp.com/moigithub
Migs
@migsor3
Jul 01 2016 02:15
Hi @ndburrus
Norvin Burrus
@ndburrus
Jul 01 2016 02:16
@ashantetimoll how's it going?
Jatinder singh
@jatinder751
Jul 01 2016 02:18
@ndburrus yes finally i got it, thanks i got over the hump
CamperBot
@camperbot
Jul 01 2016 02:18
jatinder751 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 757 | @ndburrus |http://www.freecodecamp.com/ndburrus
DANIELHART19
@DANIELHART19
Jul 01 2016 02:18
can anyone explain the stand in line part in the javascript section to me im baffeled
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.
Norvin Burrus
@ndburrus
Jul 01 2016 02:18
@jatinder751 most excellent... :cake:
@DANIELHART19 this may be helpful:
ashantetimoll
@ashantetimoll
Jul 01 2016 02:22
@ndburrus when I placed it inside I was still getting an error
Norvin Burrus
@ndburrus
Jul 01 2016 02:23
@ashantetimoll the last code i saw had the variable assignment in both places... hint: there can be only one (place)... or simply - pick one (only) hint: see lesson name: Local Scope and Functionsalso reference test notes below console, here: No global myVar variable
ashantetimoll
@ashantetimoll
Jul 01 2016 02:24
@ndburrus yes. that was my fault. I do have it in one place. The two places you saw was my frustration and trying to get something to work

This is how I have it....function myLocalScope() {
'use strict';

var myVar ="test";
console.log(myVar);
}
myLocalScope();

DANIELHART19
@DANIELHART19
Jul 01 2016 02:25
@ndburrus Thank you will give it ago now.
CamperBot
@camperbot
Jul 01 2016 02:25
danielhart19 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 758 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jul 01 2016 02:25
@ashantetimoll ...go to your happy place. relax... take it easy. ok, is it working now?
@DANIELHART19 have you identifed the methods that can be used?
Wasiff A
@is0sceles
Jul 01 2016 02:28
can anyone brainstorm with me for a minute? I have a simple HTML page that has a comment box, when I hit a button, I want the contents of that box to either: 1. write to a file (apparently I can't do that with JS alone, unless PHP is involved), 2. hand it to the Python backend using AJAX ? or 3.. any ideas ?
Norvin Burrus
@ndburrus
Jul 01 2016 02:29
@is0sceles 3) punt :sparkles: ...just kidding. these may be useful:
DANIELHART19
@DANIELHART19
Jul 01 2016 02:31
@ndburrus yes .push() and unshift() still confused on how to write them in the function :S having a brain fart
Norvin Burrus
@ndburrus
Jul 01 2016 02:33
@DANIELHART19 ... buzzer! try again - one of those is correct (push).... carefully match the requirement/s with the method/s considering... also, there example code in the article:
DANIELHART19
@DANIELHART19
Jul 01 2016 02:35
shift()
Norvin Burrus
@ndburrus
Jul 01 2016 02:36
@DANIELHART19 bingo! alright... now what do we do? tackle the 1st requirement first... here: Add the number to the end of the array, what would this look like?
DANIELHART19
@DANIELHART19
Jul 01 2016 02:38

this is what I have so far
function nextInLine(arr, item) {
// Your code here
testArr.push(item++);

return testArr.shift();
}

Norvin Burrus
@ndburrus
Jul 01 2016 02:38
@DANIELHART19 alright.... what exactly is going on here? testArr.push(item++); we are given 2 inputs... aren't we operating on/with those? isn't testArr an array used for testing? reference: // Test Setup
DANIELHART19
@DANIELHART19
Jul 01 2016 02:41
testArr is the array and im trying push the next number item into the array??
Norvin Burrus
@ndburrus
Jul 01 2016 02:41
@DANIELHART19 how did you determine that? note (instructions): Write a function nextInLine which takes an array (arr)
Sam
@alakasam
Jul 01 2016 02:42
palin
christianws
@christianws
Jul 01 2016 02:42
@DANIELHART19 .push(arr[item++]) ?
Norvin Burrus
@ndburrus
Jul 01 2016 02:43
@alakasam Sarah?
Sam
@alakasam
Jul 01 2016 02:43
sorry that was a mistake, i keep mistaking the two composition modes haha
Norvin Burrus
@ndburrus
Jul 01 2016 02:45
...taking a break...
Sam
@alakasam
Jul 01 2016 02:47
hey guys, can anyone suggest a method to uppercase an element in a subarray, then rejoining them? These functions don't seem to work for sub-arrays.. I'm working on the "capitalize the first letter of each word"
Juan Moraza
@Morazajuan
Jul 01 2016 02:49
im totally lost
the challange is called "Record Collection " and this is what i have so far...

// 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(collection.id.prop!== "tracks"){
 collection.id.push("tracks");

}else if(collection.id.prop.tracks!==""){
collection.id.prop.tracks.push(collection.id.prop.tracks.shift());
}else  {
  return "hi";
}

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Alex N.
@N0bl3
Jul 01 2016 03:00
@Morazajuan first you should use brackets notation for dynamically set keys. like collection.id.prop ==> collection[id][prop]
U-ways
@U-ways
Jul 01 2016 03:00

Hello, I am wondering what is the correct way to provide more than one condition within an if statement expression?

Here is how I did it:

if (card = 2 || 3 || 4 || 5 || 6) {
    count += 1;
    answer = count + "bet";
  }

The error is: expected a conditional expression and instead saw an assignment

Alex N.
@N0bl3
Jul 01 2016 03:01
@U-ways first : to check a value you use === not = which is for assignment
U-ways
@U-ways
Jul 01 2016 03:02
@N0bl3 Oh opps, thanks for letting me know that!
CamperBot
@camperbot
Jul 01 2016 03:02
:cookie: 252 | @n0bl3 |http://www.freecodecamp.com/n0bl3
u-ways sends brownie points to @n0bl3 :sparkles: :thumbsup: :sparkles:
Alex N.
@N0bl3
Jul 01 2016 03:02
@U-ways second, you could do card >= 2 && car <= 6
@U-ways i'll make a requst on github to have a linter in FCC
U-ways
@U-ways
Jul 01 2016 03:04
@N0bl3 Ohh!!! Cheers!! Awesome!! Thank you very much!! c:
CamperBot
@camperbot
Jul 01 2016 03:04
u-ways sends brownie points to @n0bl3 :sparkles: :thumbsup: :sparkles:
:warning: u-ways already gave n0bl3 points
Joseph
@revisualize
Jul 01 2016 03:05
@U-ways evaluations don't work like that.
@U-ways You need to do each evaluation independently.
@U-ways Also, a single = is assignment.
Krista Prenesti
@kprenesti
Jul 01 2016 03:07
Hi, all. Does anyone here know how to pass data between angular controllers?
Angular 1
Joseph
@revisualize
Jul 01 2016 03:07

@Morazajuan
You are given a JSON object representing a part of your musical album collection. Each album has several properties and a unique id number as its key. Not all albums have complete information.

Write a function which takes an album's id (like 2548), a property prop (like "artist" or "tracks"), and a value (like "Addicted to Love") to modify the data in this collection.

If prop isn't "tracks" and value isn't blank, update or set the value for that record album's property.

Your function must always return the entire collection object.

There are several rules for handling incomplete data:

If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.

If prop is "tracks" and value isn't blank, push the value onto the end of the album's existing tracks array.

If value is blank, delete that property from the album.

U-ways
@U-ways
Jul 01 2016 03:09
@revisualize Hello, Yes! Alex N. Just explained that, thanks anyways!
CamperBot
@camperbot
Jul 01 2016 03:09
u-ways sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1351 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jul 01 2016 03:09
@Morazajuan Also. Dot notation is a string literal. So..
myObj.name; is the same as myObj["name"]; Whereas:myObj[name];will take the variable representation ofvar name;`
Krista Prenesti
@kprenesti
Jul 01 2016 03:10
Thanks @revisualize
CamperBot
@camperbot
Jul 01 2016 03:10
kprenesti sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1352 | @revisualize |http://www.freecodecamp.com/revisualize
Alex N.
@N0bl3
Jul 01 2016 03:10
@revisualize why do i have cookies and you have stars? :D
Joseph
@revisualize
Jul 01 2016 03:11
+1000
Brendan Pierce
@Dorfnox
Jul 01 2016 03:12
Hello! Can anyone help me on the profile lookup exercise?
Here's my code, which as far as I can tell should work:

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

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

return "No such contact";

// Only change code above this line
}

Omg how do I format this?
Coy Sanders
@coymeetsworld
Jul 01 2016 03:15
help format
CamperBot
@camperbot
Jul 01 2016 03:15

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Coy Sanders
@coymeetsworld
Jul 01 2016 03:16
check what you're returning when you find the firstname of a contact that has the property @Dorfnox
need to fix that, i think everything else is ok
Brendan Pierce
@Dorfnox
Jul 01 2016 03:17
function lookUpProfile(firstName, prop){
// Only change code below this line

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

  return "No such contact";


// Only change code above this line
}
Omg thanks @coymeetsworld YOU SAVED MY LIFE
CamperBot
@camperbot
Jul 01 2016 03:19
dorfnox sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1222 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Brendan Pierce
@Dorfnox
Jul 01 2016 03:20
Contacts[i][prop] :D
Coy Sanders
@coymeetsworld
Jul 01 2016 03:20
@Dorfnox :ok_hand: no problem
yeah, small detail :)
DANIELHART19
@DANIELHART19
Jul 01 2016 03:34
@ndburrus finally got it thanks for your help!
CamperBot
@camperbot
Jul 01 2016 03:34
danielhart19 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 759 | @ndburrus |http://www.freecodecamp.com/ndburrus
Peter Kenward
@PeterKenward
Jul 01 2016 03:39
https://repl.it/C7qs/0 I get the error message arr.allLowerCase is not a function. I thought I had defined it as a function already?
isn't allLowerCase a method anyway? ARg :)
DJ
@qualitymanifest
Jul 01 2016 03:41
@PeterKenward on your first line, remove the last set of parens at the end
Norvin Burrus
@ndburrus
Jul 01 2016 03:41
@DANIELHART19 you're welcome! :icecream:
David Liendo
@DavLiendoProgramming
Jul 01 2016 03:42
uhm
guys
does somebody knows hwo to remove alphanumeric characters from a string?x.x
Peter Kenward
@PeterKenward
Jul 01 2016 03:42
@qualitymanifest you mean the ();
?
DJ
@qualitymanifest
Jul 01 2016 03:42
@PeterKenward yes
Coy Sanders
@coymeetsworld
Jul 01 2016 03:42
@DavLiendoProgramming regex
David Liendo
@DavLiendoProgramming
Jul 01 2016 03:43
wuts?
how do i use that x.x
Peter Kenward
@PeterKenward
Jul 01 2016 03:43
@DavLiendoProgramming I think it's regex and you're probably looking to remove non alpha numeric characters....
David Liendo
@DavLiendoProgramming
Jul 01 2016 03:44
yeah that exactly, non alphanumeric
xd
Coy Sanders
@coymeetsworld
Jul 01 2016 03:44
its not trivial to explain @DavLiendoProgramming, its a very powerful tool.
but basically you create patterns on what text you want to target and what you want to do with it. Think search and replace
Peter Kenward
@PeterKenward
Jul 01 2016 03:45
@qualitymanifest Can you explain why to me please ? I thought I had to call the anonymous function immediately? I guess I'm missing something!
David Liendo
@DavLiendoProgramming
Jul 01 2016 03:46
thank you ! @coymeetsworld
CamperBot
@camperbot
Jul 01 2016 03:46
davliendoprogramming sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1223 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Allysa Fletcher
@alldanmos
Jul 01 2016 03:46

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch(val) {
case (val === 1):
answer = "alpha";
break;

case (val === 2):
answer = "beta";
break;

case (val === 3):
answer = "gamma";
break;

case (val === 4):
answer = "delta";
break;
}

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

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

What is wrong with this? This is: Selecting from many options with Switch Statements. I'm really confused.

endlessetudes
@endlessetudes
Jul 01 2016 03:47
@DavLiendoProgramming it's probably worth finding a youtube video or 2 on RegEx (regular expressions) as well. and playing with them in the console. That's a big part of learning for me
Zach
@Moose1551
Jul 01 2016 03:47
Hello all. I'm working on the Pig Latin bonfire challenge. Can anyone help me to understand why my code isn't passing all of the tests? Individually, each condition passes. But, in the if statement, only the 1st condition passes.
function translatePigLatin(str) {

 var twoCon = str.slice(2) + str.substring(0,2) + "ay";
  var oneCon = str.slice(1) + str.substring(0, 1) + "ay";
  var noCon = str + "way";
  var newString = "";

  if (str[0] === "a", "e", "i", "o", "u") {
    newString = noCon;
  } else if (str[0] !== "a", "e", "i", "o", "u") {
    newString = oneCon;
  } else {
    newString = twoCon;
  }
  return newString;


}
  translatePigLatin("glove");
David Liendo
@DavLiendoProgramming
Jul 01 2016 03:49
guys thank you so much!
endlessetudes
@endlessetudes
Jul 01 2016 03:49
@ndburrus great links
DJ
@qualitymanifest
Jul 01 2016 03:49
@PeterKenward you're storing it in a variable (well, as an array prototype) but either way it's being stored so i don't see why you think you need to call it immediately? have youtried it yet? if you remove those parens it works
David Liendo
@DavLiendoProgramming
Jul 01 2016 03:49
youre being really supportive!
张春
@DuXingXia233
Jul 01 2016 03:49
@alldanmos swich(value) { case value1/ "ref to value, not value === value1"}
David Liendo
@DavLiendoProgramming
Jul 01 2016 03:49
thank you ! @ndburrus and @endlessetudes
CamperBot
@camperbot
Jul 01 2016 03:49
davliendoprogramming sends brownie points to @ndburrus and @endlessetudes :sparkles: :thumbsup: :sparkles:
:cookie: 278 | @endlessetudes |http://www.freecodecamp.com/endlessetudes
:cookie: 760 | @ndburrus |http://www.freecodecamp.com/ndburrus
Coy Sanders
@coymeetsworld
Jul 01 2016 03:50
np @DavLiendoProgramming this was also a good video someone linked some time ago explaining it further, thought it was well done https://www.youtube.com/watch?v=EkluES9Rvak
Norvin Burrus
@ndburrus
Jul 01 2016 03:50
@endlessetudes the youtube suggestion was helpful also... :sailboat:
@DavLiendoProgramming you're welcome! enjoy :sparkles:
Peter Kenward
@PeterKenward
Jul 01 2016 03:54
Thanks @qualitymanifest :)
CamperBot
@camperbot
Jul 01 2016 03:54
peterkenward sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1233 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Jul 01 2016 03:55
yw :+1:
Peter Kenward
@PeterKenward
Jul 01 2016 03:55
I got this straight now :)
Allysa Fletcher
@alldanmos
Jul 01 2016 03:56
@DuXingXia233 Thank you.
CamperBot
@camperbot
Jul 01 2016 03:56
alldanmos sends brownie points to @duxingxia233 :sparkles: :thumbsup: :sparkles:
:cookie: 80 | @duxingxia233 |http://www.freecodecamp.com/duxingxia233
Harsiandy
@harsiandy
Jul 01 2016 04:02
Hi, I'm stuck in Local Scope and Functions Challenges. I already removed a line that contain console.log(myVar); and refresh my browser but still not able to submit my test.
CruftMaster
@CruftMaster
Jul 01 2016 04:02

function destroyer(arr) {
// Remove all the values

var args = Array.from(arguments);

var result = args.shift();

for(i=0;i<args.length;i++){
for(j=0;j<result.length;j++){
if (result[j] === args[i]){
result.splice( j, 1);
}
}
}

return result;

}

destroyer([2, 3, 2, 3], 2, 3); // returns [3]

i need help plz. on seek and destroy. I managed to satisfy 3 out of 5 requirements but something is not working
endlessetudes
@endlessetudes
Jul 01 2016 04:07
 function destroyer(arr) {
  // Remove all the values

  var args = Array.from(arguments);
  var result = args.shift();


  for(i=0;i<args.length;i++){
    for(j=0;j<result.length;j++){
      if (result[j] === args[i]){
        result.splice( j, 1);
        }
    }
  }
  return  result;
}

destroyer([2, 3, 2, 3], 2, 3); // returns [3]
@CruftMaster reposted so I could see it better.
CruftMaster
@CruftMaster
Jul 01 2016 04:08
@endlessetudes ok, i appreciate your help
张春
@DuXingXia233
Jul 01 2016 04:10
 function destroyer(arr) {
  // Remove all the values

  var args = Array.from(arguments);
  var result = args.shift();


  for(i=0;i<args.length;i++){
    for(j=0;j<result.length;j++){
      if (result[j] === args[i]){
        result.splice( j, 1);
        }
    }
  }
  return  result;
}

destroyer([2, 3, 2, 3], 2, 3); // returns [3]
endlessetudes
@endlessetudes
Jul 01 2016 04:13
@CruftMaster sorry. It's taking a minute. I used a different method
CruftMaster
@CruftMaster
Jul 01 2016 04:14
@endlessetudes its np
endlessetudes
@endlessetudes
Jul 01 2016 04:15
@CruftMaster on the challenge, a link to the filter method is provided. did you try using filter?
CruftMaster
@CruftMaster
Jul 01 2016 04:16
yeah i tried filter but i couldnt figure out how to get it to work with filtering an array with another array, and i couldnt get a loop to work with it
im just wondering why splice wont work, the code seems to work on some arrays but on others it leaves an element behind
Magnus Holm
@mghlm
Jul 01 2016 04:17
var foodDemand = function(food) {
    console.log("I want to eat" + " " + food);
};

foodDemand (burrito);
What’s wrong with this code??
it says burrito is not defined
Coy Sanders
@coymeetsworld
Jul 01 2016 04:20
@m4gnusholm you want to make burrito a String
i.e. inside quotes
Carl P.
@alofacarl
Jul 01 2016 04:20
help reg
CamperBot
@camperbot
Jul 01 2016 04:20

:point_right: challenge find numbers with regular expressions [wiki]

Challenge Find Numbers with Regular Expressions

We can use special selectors in Regular Expressions to select a particular type of value.

One such selector is the digit selector \d which is used to grab the numbers in a string.

It is used like this: /\d+/g.

:pencil: read more about challenge find numbers with regular expressions on the FCC Wiki

Coy Sanders
@coymeetsworld
Jul 01 2016 04:20
or else the engine will be looking for a variable named burrito
Magnus Holm
@mghlm
Jul 01 2016 04:20
@coymeetsworld Ahh, of course, thank you!!
CamperBot
@camperbot
Jul 01 2016 04:20
m4gnusholm sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1224 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jul 01 2016 04:21
no problem
LiamReading
@LiamReading
Jul 01 2016 04:23
challenge 135?
finding the remainders
endlessetudes
@endlessetudes
Jul 01 2016 04:23
@CruftMaster i think the problem is after the result is spliced the result.length will change shortening the loop
LiamReading
@LiamReading
Jul 01 2016 04:24

Usage
In mathematics, a number can be checked even or odd by checking the remainder of the division of the number by 2.

17 % 2 = 1 (17 is Odd)
48 % 2 = 0 (48 is Even)
Note
The remainder operator is sometimes incorrectly referred to as the "modulus" operator. It is very similar to modulus, but does not work properly with negative numbers.

Instructions
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.

cant work that out haha
CruftMaster
@CruftMaster
Jul 01 2016 04:25
@endlessetudes oh yeah. lol i think youre right
@endlessetudes thanks so much, i will have to work on using filter then
CamperBot
@camperbot
Jul 01 2016 04:28
cruftmaster sends brownie points to @endlessetudes :sparkles: :thumbsup: :sparkles:
:cookie: 279 | @endlessetudes |http://www.freecodecamp.com/endlessetudes
LiamReading
@LiamReading
Jul 01 2016 04:28
Can anyone help on the challenge i am stuck on?
ranranking
@ranranking
Jul 01 2016 04:28
Hello. In the Exact Change challenge, how do I deal with the rounding errors?
LiamReading
@LiamReading
Jul 01 2016 04:28
what is the challenge number?
ranranking
@ranranking
Jul 01 2016 04:29
286
LiamReading
@LiamReading
Jul 01 2016 04:29
i will have a look aha
ranranking
@ranranking
Jul 01 2016 04:29
Thank you!
LiamReading
@LiamReading
Jul 01 2016 04:30
oh, what is the name of the challenge?
endlessetudes
@endlessetudes
Jul 01 2016 04:30
@CruftMaster np :) i'm sure you can find a way to use a nested for loop but filter is very useful
ranranking
@ranranking
Jul 01 2016 04:30
Exact Change
Aata-allah
@Atalaa
Jul 01 2016 04:32
is there a way to have a link from my portfolio project without the codepen bar on the top ? Like a real website ?
endlessetudes
@endlessetudes
Jul 01 2016 04:33
@LiamReading what challenge are you on?
LiamReading
@LiamReading
Jul 01 2016 04:33
135
finding a remainder in javascript
somehow i am stuck aha
endlessetudes
@endlessetudes
Jul 01 2016 04:38
@LiamReading so after var remainder use the % operator the get the remainder
@LiamReading 9 % 3 would equl 0
10 % 3 would equal 1
the % operator divides the first num by the second num and assigns any "left-overs" that don't divide evenly
does that make sense?
Stefan Bekirov
@bekir0v
Jul 01 2016 04:46
hi
I would like to know what I did wrong in this function?
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch(answer){
      case 1:
      return  "alpha";
      break;
      case 2:
      return "beta";
      break;
      case 3:
      return "gamma";
      break;
      case 4:
      return "delta";
      break;
      default:
      return "wrog";
  }


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

// Change this value to test
caseInSwitch(1);
Ian Arsenault
@ianarsenault
Jul 01 2016 04:46
@LiamReading % modula operator
@bekir0v just by a quick look you spelled "wrong" ... wrong lol in the default return. Spelling does cause errors
Nathaniel Nasarow
@Torgian
Jul 01 2016 04:47
yo
Stefan Bekirov
@bekir0v
Jul 01 2016 04:48
@GorgonsMaze thank you boss
CamperBot
@camperbot
Jul 01 2016 04:48
bekir0v sends brownie points to @gorgonsmaze :sparkles: :thumbsup: :sparkles:
:cookie: 297 | @gorgonsmaze |http://www.freecodecamp.com/gorgonsmaze
LiamReading
@LiamReading
Jul 01 2016 04:48
yeah thanks @endlessetudes
CamperBot
@camperbot
Jul 01 2016 04:48
liamreading sends brownie points to @endlessetudes :sparkles: :thumbsup: :sparkles:
:cookie: 280 | @endlessetudes |http://www.freecodecamp.com/endlessetudes
clintonjohn
@clintonjohn
Jul 01 2016 04:48
Record collection try:

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

value = [];
}

else if (collection[id][prop] !== "tracks"); {

collection[id][prop] = value;

}

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

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

}

else (value === "");

{

delete collection[id][prop];

}
return collection;

}

Ian Arsenault
@ianarsenault
Jul 01 2016 04:48
@bekir0v no problem.
clintonjohn
@clintonjohn
Jul 01 2016 04:49
any ideas?
Coy Sanders
@coymeetsworld
Jul 01 2016 04:56
@bekir0v while you could return the value in the case/switch you probably would want to set answer to the value instead.
this code could pass for this challenge possibly but if you ever needed to execute anything after the case/switch statement you can't have any return statements in there. Return statements will exit any further processing of the function
Stefan Bekirov
@bekir0v
Jul 01 2016 04:57
@coymeetsworld
Thak you Sir I did it
Coy Sanders
@coymeetsworld
Jul 01 2016 04:57
ok
just for future reference :thumbsup:
Ken Nawrocki
@nawrockp
Jul 01 2016 05:01
@bekir0v am i missing something or is there only one possible outcome of your switch?
Ramzi Ik
@ramzi2306
Jul 01 2016 05:01
can some one help me with the Counting Cards test ?
endlessetudes
@endlessetudes
Jul 01 2016 05:03
@ramzi2306 what's giving you trouble?
Stefan Bekirov
@bekir0v
Jul 01 2016 05:04
@nawrockp No Sir
Ken Nawrocki
@nawrockp
Jul 01 2016 05:06
Answer=""
Switch(answer)?
Stefan Bekirov
@bekir0v
Jul 01 2016 05:07
I don't get it
Ken Nawrocki
@nawrockp
Jul 01 2016 05:07
Switch(val)
Stefan Bekirov
@bekir0v
Jul 01 2016 05:08
Yes I did it
Ken Nawrocki
@nawrockp
Jul 01 2016 05:08
Ah,ok
Stefan Bekirov
@bekir0v
Jul 01 2016 05:09
but now I can't undurstand what should I do in this function
function switchOfStuff(val) {
  var answer = "";
  // Only change code below this line
  switch(val){
      case a:
      return "apple";
      break;
      case b: 
      return "bird";
      break;
      case c:
      return "cat";
      break;
    default:

      return "stuff";
  }


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

// Change this value to test
switchOfStuff(1);
Ken Nawrocki
@nawrockp
Jul 01 2016 05:10
Case a:
Stefan Bekirov
@bekir0v
Jul 01 2016 05:10
what is wrong whit it
Magnus Holm
@mghlm
Jul 01 2016 05:11
var sleepCheck = function(numHours) {
    if (numHours >= 8);
    return "You're getting plenty of sleep! Maybe even too much!";
}
else {
    return "Get some more shut eye!";
}

sleepCheck(10)
Me again. What’s wrong with this code? It says “Syntax error: unexpected token else
Ken Nawrocki
@nawrockp
Jul 01 2016 05:11
Answer="apple"
Sorry, on my phone in bed.
Mustafijur rahman
@Dinar717
Jul 01 2016 05:12
@m4gnusholm you gave ; after if. and
Magnus Holm
@mghlm
Jul 01 2016 05:13
@Dinar717 what?
Mustafijur rahman
@Dinar717
Jul 01 2016 05:14
Remove the wrong bracket
@m4gnusholm
Stefan Bekirov
@bekir0v
Jul 01 2016 05:14
@nawrockp
it said a is not defined
Magnus Holm
@mghlm
Jul 01 2016 05:15
@Dinar717 which one?
Mustafijur rahman
@Dinar717
Jul 01 2016 05:15
After if
Ken Nawrocki
@nawrockp
Jul 01 2016 05:16
Case:"a"
Mustafijur rahman
@Dinar717
Jul 01 2016 05:16
And after else
@m4gnusholm
Magnus Holm
@mghlm
Jul 01 2016 05:16
@Dinar717 i have no idea what you mean
Ken Nawrocki
@nawrockp
Jul 01 2016 05:16
Assuming "a" is a string
Mustafijur rahman
@Dinar717
Jul 01 2016 05:17

var sleepCheck = function(numHours) {
if (numHours >= 8)
return "You're getting plenty of sleep! Maybe even too much!";

else
return "Get some more shut eye!";
}

sleepCheck(10)

Stefan Bekirov
@bekir0v
Jul 01 2016 05:18
@nawrockp so what is point I don't undurstand Adding a default option in Switch statements
Magnus Holm
@mghlm
Jul 01 2016 05:19
@Dinar717 oh.
@Dinar717 thanks
CamperBot
@camperbot
Jul 01 2016 05:19
m4gnusholm sends brownie points to @dinar717 :sparkles: :thumbsup: :sparkles:
:cookie: 310 | @dinar717 |http://www.freecodecamp.com/dinar717
Ken Nawrocki
@nawrockp
Jul 01 2016 05:19
Hold on let me find a good example
Stefan Bekirov
@bekir0v
Jul 01 2016 05:20
thank you @nawrockp
CamperBot
@camperbot
Jul 01 2016 05:20
bekir0v sends brownie points to @nawrockp :sparkles: :thumbsup: :sparkles:
:cookie: 328 | @nawrockp |http://www.freecodecamp.com/nawrockp
endlessetudes
@endlessetudes
Jul 01 2016 05:21
has anyone here solved "Missing Letter"?
i don't understand why it should return undefined if the letters are already in order
Mustafijur rahman
@Dinar717
Jul 01 2016 05:23
@endlessetudes because this is a requirement of this problem
Teddy
@teddyoliver
Jul 01 2016 05:24

Hello guys, I am trying to complete this task
Define a variable named roundUp that references the float
1.5.

We will use the Math.round() method to round the number up. This method
rounds either up or down to the nearest integer.

An example of using Math.round():

 Math.round(0.5);  

Define a second variable named rounded that references the output of the
Math.round() method, passing in the roundUp variable as the argument.

Use console.log() to print that number to the terminal.

Check to see if your program is correct by running this command:

 javascripting verify rounding-numbers.js 

and I have done this

var roundUp = 1.5;
var rounded = Math.round("roundUp");
console.log = ("rounded");

But its not working

What should i do?
Mustafijur rahman
@Dinar717
Jul 01 2016 05:26
@teddyoliver remove "" from inside math.round
Ken Nawrocki
@nawrockp
Jul 01 2016 05:26
Not great. But the movie example is better than MDNs example, which is usually good but in this case not really.
endlessetudes
@endlessetudes
Jul 01 2016 05:27
@Dinar717 i get that.. i just thought there might a certain method that should be used which would return undefined without me expressly saying so
Teddy
@teddyoliver
Jul 01 2016 05:27
@Dinar717 so
var roundUp = 1.5;
var rounded = Math.round(roundUp);
console.log = ("rounded");
like that?
Mustafijur rahman
@Dinar717
Jul 01 2016 05:28
Joris Boschmans
@jorisboschmans
Jul 01 2016 05:29
Can someone help me on my way with the following exercise? https://www.freecodecamp.com/challenges/no-repeats-please
I know how to calculate permutations, but i'm stuck at the whole 'no repeats' part. I would rather not like a complete solution, because i want to do it myself, i'd simply like something to get me going...
Mustafijur rahman
@Dinar717
Jul 01 2016 05:30
@endlessetudes but you must return something from a function. without returning how can you get a result from a function?
allon-z
@allon-z
Jul 01 2016 05:31

So I am working on the exercise to capitalize the beginning of each word in a string and I wrote this:

function titleCase(str) {
  words = str.toLowerCase().split(" ");
  for(var i=0; i < words.length; i++){
    firstLetter = words[i].charAt(0).toUpperCase();

  }

  str = words.join(" ");
  return str;
}

titleCase("I'm a little tea pot");

Am I missing something?? Can I not use .charAt() to capitalize?

Teddy
@teddyoliver
Jul 01 2016 05:33
@Dinar717 var roundUp = 1.5;
var rounded = Math.round(roundUp);
console.log = ("rounded");
still not working
Joris Boschmans
@jorisboschmans
Jul 01 2016 05:33
@allon-z you can simply use words[i][0]
Mustafijur rahman
@Dinar717
Jul 01 2016 05:33
@allon-z words.charAt(I).to....
Joris Boschmans
@jorisboschmans
Jul 01 2016 05:33
@Dinar717 words is an array of words
Mustafijur rahman
@Dinar717
Jul 01 2016 05:35
@jorisboschmans yes I didn't noticed that. @allon-z
Teddy
@teddyoliver
Jul 01 2016 05:36
@Dinar717 var roundUp = 1.5;
var rounded = Math.round(roundUp);
console.log = ("rounded");
is till not working :(
allon-z
@allon-z
Jul 01 2016 05:36
@jorisboschmans so I just replace .charAt with [0]? Because I did that and my function still doesn't seem to work. I feel like I'm missing something important but I can't see it.
endlessetudes
@endlessetudes
Jul 01 2016 05:36
@Dinar717 i misread the challenge lol. i thought i was supposed to return the corrected string not just the "missing letter" oops
Joris Boschmans
@jorisboschmans
Jul 01 2016 05:37
@allon-z oh when you set the capital letter to 'firstLetter', you don't do anything with it
allon-z
@allon-z
Jul 01 2016 05:38
@jorisboschmans oh man duh! Thanks man. I'll try to do something with that
CamperBot
@camperbot
Jul 01 2016 05:38
allon-z sends brownie points to @jorisboschmans :sparkles: :thumbsup: :sparkles:
:cookie: 308 | @jorisboschmans |http://www.freecodecamp.com/jorisboschmans
Alex N.
@N0bl3
Jul 01 2016 05:39
Hello again, may you have a look at my codepen and tell me whet s wrong with it? seems like it cant get the initial value TLDR using react!
http://codepen.io/N0bl3/pen/oLWGAO
Teddy
@teddyoliver
Jul 01 2016 05:42

Hello guys, I am trying to complete this task
Define a variable named roundUp that references the float
1.5.

We will use the Math.round() method to round the number up. This method
rounds either up or down to the nearest integer.

An example of using Math.round():

 Math.round(0.5);  

Define a second variable named rounded that references the output of the
Math.round() method, passing in the roundUp variable as the argument.

Use console.log() to print that number to the terminal.

Check to see if your program is correct by running this command:

 javascripting verify rounding-numbers.js 

and I have done this

var roundUp = 1.5;
var rounded = Math.round(roundUp);
console.log = ("rounded");

But its not working

Dolan
@dguh
Jul 01 2016 05:42
hi i am finishing up the weather app and for some reason when after i click my button to change to celsius the button won't switch back to fahrenheit
Joris Boschmans
@jorisboschmans
Jul 01 2016 05:43
can you link?
@dguh
Joris Boschmans
@jorisboschmans
Jul 01 2016 05:50
i think it's because you are replacing the button. Maybe you can simple change the text on the button? @dguh
Wilfred
@wilfredtommy
Jul 01 2016 05:51

any idea what's wrong with this code?
function factorialize(num) {
while(num!==0)
{
for(var i=1;i<num;i++)
{
num=num*(num-i);
}
}
return num;
}

factorialize(5);

Joris Boschmans
@jorisboschmans
Jul 01 2016 05:51
So no one who can help me?
Can someone help me on my way with the following exercise? https://www.freecodecamp.com/challenges/no-repeats-please
I know how to calculate permutations, but i'm stuck at the whole 'no repeats' part. I would rather not like a complete solution, because i want to do it myself, i'd simply like something to get me going...
waaaaaalter
@waaaaaalter
Jul 01 2016 05:54
what am i missing with the encoded text stuff?
i feel clueless right now
Leonid S. Knyshov
@wiseleo
Jul 01 2016 05:58
@jorisboschmans Have you tried clicking the "Wiki" button? It usually gives a series of hints. :)
Joris Boschmans
@jorisboschmans
Jul 01 2016 06:00
@wiseleo wooow! Thanks a lot, i never noticed it :D
CamperBot
@camperbot
Jul 01 2016 06:00
jorisboschmans sends brownie points to @wiseleo :sparkles: :thumbsup: :sparkles:
:cookie: 272 | @wiseleo |http://www.freecodecamp.com/wiseleo
kirbyedy
@kirbyedy
Jul 01 2016 06:00
@wilfredtommy maybe in your if to have i<=num ?
Leonid S. Knyshov
@wiseleo
Jul 01 2016 06:01
wiki no repeats please @jorisboschmans
CamperBot
@camperbot
Jul 01 2016 06:01

:point_right: algorithm no repeats please [wiki]

Algorithm No Repeats Please

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

:checkered_flag: Problem Explanation:

This task requires us to return the number of total permutations of the provided string that don't have repeated consecutive letters. It is to be assumed that all characters in the provided string are each unique. For example, aab should return 2 because it has 6 total permutations (aab, aab, aba, aba, baa, baa), but only 2 of them (aba and aba) don't have the same letter (in this case a) repeating.

To achieve that, we'll have to look at each possible permutation of a string. There are several ways to do that. A common interview question is building a function that collects all permutations of a string. There are several tutorials available on the internet on how to do that.

Potential Methods Used As Solution

Recursive Method

This task can be daunting even after watching a tutorial. To write a recursive solution, you will want to send each new use of the function three inputs:

  1. A new string (or character array) that is being built.
  2. A position in your new string that's going to be filled next.
  3. An idea of what characters (more specifically positions) from the original string have yet to be used.

:pencil: read more about algorithm no repeats please on the FCC Wiki

kirbyedy
@kirbyedy
Jul 01 2016 06:02
@wilfredtommy I tried to run your code with visualiser and got an error: Error: stopped after running 1000 steps and cannot display visualization.
so basically you have an never ending loop or something, I dont know
Leonid S. Knyshov
@wiseleo
Jul 01 2016 06:04
@wilfredtommy Your num will never reach 0, so the code gets stuck in infinite loop.
Stefan Bekirov
@bekir0v
Jul 01 2016 06:05
hi
What is the target of this function
What should I do in this function I don't get it
Please for any help
// Setup
function abTest(a, b) {
  // Only change code below this line



  // 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);
BuntyBru
@BuntyBru
Jul 01 2016 06:05

so currently i am doing "Switch statements " in JavaScript and i seem to forget that why inside the function the variable is declared like (var answer="";)

code:

function switchOfStuff(val) {
var answer = ""; // Explain me about this line please.
// Only change code below this line

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

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

Leonid S. Knyshov
@wiseleo
Jul 01 2016 06:06

@wilfredtommy Also, and this is critical, you must open the brackets in JavaScript on the same line and not on the line below. This syntax error in JavaScript is the source of many bugs.

function ()
{
} // is bad

you must use

function () {
}
kirbyedy
@kirbyedy
Jul 01 2016 06:06
@bekir0v if a is smaller than 0 or b is smaller then 0 return
@bekir0v now try to convert that to code
Stefan Bekirov
@bekir0v
Jul 01 2016 06:07
@kirbyedy
it should be with if/else function
kirbyedy
@kirbyedy
Jul 01 2016 06:07
if yes, else not really
Anirudha Kasralikar
@akasralikar
Jul 01 2016 06:08

Regarding "Truncate a string" challenge
https://www.freecodecamp.com/challenges/truncate-a-string

I am done with it somehow, but I feel there may be better solution to this which is less complex


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

}

truncateString("Absolutely Longer", 2);
is there shorter solution for this?
or better
kirbyedy
@kirbyedy
Jul 01 2016 06:08
@bekir0v just make an if with a condition in the brackets
Leonid S. Knyshov
@wiseleo
Jul 01 2016 06:08
@akasralikar Click the "Wiki" button. I do it after every challenge to see what's a more elegant solution.
Anirudha Kasralikar
@akasralikar
Jul 01 2016 06:09
ok thanks for pointing out to correct source @wiseleo
CamperBot
@camperbot
Jul 01 2016 06:09
akasralikar sends brownie points to @wiseleo :sparkles: :thumbsup: :sparkles:
:cookie: 273 | @wiseleo |http://www.freecodecamp.com/wiseleo
Stefan Bekirov
@bekir0v
Jul 01 2016 06:10
@wiseleo Nothin Sir the same solution
Leonid S. Knyshov
@wiseleo
Jul 01 2016 06:10
@bekir0v I am not sure what you are referring to since I haven't seen your question.
Stefan Bekirov
@bekir0v
Jul 01 2016 06:11
the problem is I don't understand what they want me to do in that function
not only for this one
kirbyedy
@kirbyedy
Jul 01 2016 06:11
@bekir0v lets see your code
I will repeat my explanation: if a is smaller than 0 or b is smaller then 0 return
kirbyedy
@kirbyedy
Jul 01 2016 06:12
you know about IF, you have a, math symbol for smaller is <, 0 I guess you know that, sign OR in javascript is ||
and for the b is pretty much the same...
and after that you just put return
cant explain more easily sorry :(
Alex N.
@N0bl3
Jul 01 2016 06:14
http://codepen.io/N0bl3/pen/oLWGAO I cant get the dynamically generated HTML to be integrated in the web page may you help please? :( see the Markdown output element
BuntyBru
@BuntyBru
Jul 01 2016 06:16
Not able to pass "Adding a deafult option in Switch Statements"
code:

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch(answer)
{
case "a":
return "apple";
break;
case "b":
return "bird";
break;
case "c":
return "cat";
break;
default:
return "stuff";

 }

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

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

Anirudha Kasralikar
@akasralikar
Jul 01 2016 06:16
@BuntyBru I think you need to swicth val not answer
BuntyBru
@BuntyBru
Jul 01 2016 06:17
oh yes, Silly mistake from my side
thanks @akasralikar
CamperBot
@camperbot
Jul 01 2016 06:17
buntybru sends brownie points to @akasralikar :sparkles: :thumbsup: :sparkles:
:cookie: 253 | @akasralikar |http://www.freecodecamp.com/akasralikar
Stefan Bekirov
@bekir0v
Jul 01 2016 06:18
@kirbyedy
function abTest(a, b) {
  // Only change code below this line
 if(a<0 || b<0){

 }


  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
kirbyedy
@kirbyedy
Jul 01 2016 06:18
@bekir0v great
now just put return inside your IF
just the word return nothing else...
Stefan Bekirov
@bekir0v
Jul 01 2016 06:21
@kirbyedy
but when I put just return without nothing it show me red cross which means is somthing wrong
that confused me
Leonid S. Knyshov
@wiseleo
Jul 01 2016 06:21

Doesn't sound like the right solution to that challenge :)

A standalone return; will just return undefined.

Anirudha Kasralikar
@akasralikar
Jul 01 2016 06:21
@bekir0v put semicolon at end
"return;"
to remove red cross
kirbyedy
@kirbyedy
Jul 01 2016 06:22
yes, you always have to end the line with a semicolon as he said :point_up:
Stefan Bekirov
@bekir0v
Jul 01 2016 06:23
@akasralikar yes but I never before have done this I didn't know
Anyway thank you guys
Anirudha Kasralikar
@akasralikar
Jul 01 2016 06:24
you are welcome @bekir0v
Dolan
@dguh
Jul 01 2016 06:24
@jorisboschmans hi joris i tried changing the code to this var sta = $("#style").html();
    ``` $("#degree").on("click",function(){
      if (sta == "F"){
        $("#temperature").html(tempc);
        $("#style").html("C")
      }
      else {
        $("#temperature").html(temperature);
        $("#style").html("F");
      }

    });```
Stefan Bekirov
@bekir0v
Jul 01 2016 06:24
I thought it always should have something to return after it
Anirudha Kasralikar
@akasralikar
Jul 01 2016 06:25
@bekir0v usually its good practice to return something which flags which type of data is returned
but simply return means return void, return nothing
Keone Martin
@Athaman
Jul 01 2016 06:26
return undefined specifically in JS
Dolan
@dguh
Jul 01 2016 06:26
but i am still having trouble getting the temperature to change back
Leonid S. Knyshov
@wiseleo
Jul 01 2016 06:26
@akasralikar Not in JavaScript. It's undefined in JavaScript.
Anirudha Kasralikar
@akasralikar
Jul 01 2016 06:26
ok @wiseleo @Athaman
Keone Martin
@Athaman
Jul 01 2016 06:27
;) similar... but possibly different in niche circumstances
Anirudha Kasralikar
@akasralikar
Jul 01 2016 06:27
yeah agreed
Joris Boschmans
@jorisboschmans
Jul 01 2016 06:28
@dguh I belive the best way to solve this is to create a button at the bottom. Then only have it change the temp value, the temp notation (°C/F) and the value on the button...
Dolan
@dguh
Jul 01 2016 06:37
@jorisboschmans yeah that is still giving me the same problem
Joris Boschmans
@jorisboschmans
Jul 01 2016 06:38
@dguh i'll have a look in a minute
Coy Sanders
@coymeetsworld
Jul 01 2016 06:39
$("#style").html("C") missing a semicolon @dguh
Faisal Zulfiqar
@faisal1337
Jul 01 2016 06:45
I am on 'Record Collection' challenge. And here is the code. What's wrong with it? Why it doesn't pass the checks? Please help me.
function update(id, prop, value) {
if(value === '') {
delete collection[id][prop];
} else if (prop !== 'tracks') {
collection[id][prop] = value;
} else
collection[id][prop].push(value);
return collection;
}
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 06:50
@faisal1337 in the last else you also have to check if the tracks is present in the object you want to push.If it isn't you define the property tracks as an array and then push into it.
Faisal Zulfiqar
@faisal1337
Jul 01 2016 06:54
@UtkarshShukla7 the last else will be like this?
else {
if (collections[id][prop].hasOwnProperty(tracks)) {
collections[id][prop].tracks[];
collections[id][prop].tracks.push(value);
}}
I just started JS. And I am not much comfortable with the syntax. Please correct.
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 06:55
@faisal1337 yes :+1:
now you just have to handle the part of the else of this if
WangTao
@sagomm
Jul 01 2016 06:56
hi ~ everybody
Faisal Zulfiqar
@faisal1337
Jul 01 2016 06:57
@UtkarshShukla7 but the array declaration with '[]' is producing an error.
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 06:57
@faisal1337 like this
else {
if (collections[id].hasOwnProperty(tracks)) {
collections[id][prop]=[];
collections[id][prop].push(value);
}
collection[id][prop].push(value;)}
@faisal1337 I wasn't able to notice that you were defining collection[id][prop].tracks hich is wrong .
and 1 more thing it should be collection not collections
Faisal Zulfiqar
@faisal1337
Jul 01 2016 07:00
@UtkarshShukla7 check this. It is still not working. function update(id, prop, value) {
if(value === '') {
delete collection[id][prop];
} else if (prop !== 'tracks') {
collection[id][prop] = value;
} else {
if (collections[id][prop].hasOwnProperty(tracks)) {
collections[id][prop]=[];
collections[id][prop].push(value);
}
}
collection[id][prop].push(value);
}
I fixed the collections to collection.
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 07:01
@faisal1337
 function update(id, prop, value) {
if(value === '') {
delete collection[id][prop];
} else if (prop !== 'tracks') {
collection[id][prop] = value;
} else {
  if (collection[id].hasOwnProperty(prop)) {
  collection[id][prop]=[];
  collection[id][prop].push(value);
  }else {
  collection[id][prop].push(value);
  }
}
Faisal Zulfiqar
@faisal1337
Jul 01 2016 07:05
It might be a bug because it's still not working. Even after I copy pasted your code.
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 07:05
@faisal1337 ok paste your url here
oh I might have accidently deleted the last } .check that too
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 07:07
@faisal1337 your problem link not your profile .Just copy and paste it .It would be long.
Faisal Zulfiqar
@faisal1337
Jul 01 2016 07:07
https://www.freecodecamp.com/challenges/record-collection#?solution=%0A%2F%2F%20Setup%0Avar%20collection%20%3D%20%7B%0A%20%20%20%20%222548%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20%22artist%22%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%22Let%20It%20Rock%22%2C%20%0A%20%20%20%20%20%20%20%20%22You%20Give%20Love%20a%20Bad%20Name%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%222468%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%221999%22%2C%0A%20%20%20%20%20%20%22artist%22%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%221999%22%2C%20%0A%20%20%20%20%20%20%20%20%22Little%20Red%20Corvette%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%221245%22%3A%20%7B%0A%20%20%20%20%20%20%22artist%22%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20%22tracks%22%3A%20%5B%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%225439%22%3A%20%7B%0A%20%20%20%20%20%20%22album%22%3A%20%22ABBA%20Gold%22%0A%20%20%20%20%7D%0A%7D%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse(JSON.stringify(collection))%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20updateRecords(id%2C%20prop%2C%20value)%20%7B%0Aif(value%20%3D%3D%3D%20'')%20%7B%0Adelete%20collection%5Bid%5D%5Bprop%5D%3B%0A%7D%20else%20if%20(prop%20!%3D%3D%20'tracks')%20%7B%0Acollection%5Bid%5D%5Bprop%5D%20%3D%20value%3B%0A%7D%20else%20%7B%0Aif%20(collection%5Bid%5D.hasOwnProperty(tracks))%20%7B%0Acollection%5Bid%5D%5Bprop%5D%3D%5B%5D%3B%0Acollection%5Bid%5D%5Bprop%5D.push(value)%3B%0A%7Delse%20%7Bcollection%5Bid%5D%5Bprop%5D.push(value)%3B%7D%0A%7D%0Areturn%20collection%3B%20%0A%7D%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0AupdateRecords(5439%2C%20%22artist%22%2C%20%22ABBA%22)%3B
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 07:11
@faisal1337 if (!collection[id].hasOwnProperty(prop)) I wasn't able to notice that too .
Faisal Zulfiqar
@faisal1337
Jul 01 2016 07:13
I just added '!' but still no luck. Is it working on your side?
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 07:13
! symbol ,you have to create an array if it is #not present while you are creating when it is present. @faisal1337
yes
@faisal1337 if (!collection[id].hasOwnProperty(prop)) or if (!collection[id].hasOwnProperty("tracks")) not if (!collection[id].hasOwnProperty(tracks))
Faisal Zulfiqar
@faisal1337
Jul 01 2016 07:15
Thanks @UtkarshShukla7 I added quotes on tracks and it is working now.
CamperBot
@camperbot
Jul 01 2016 07:15
faisal1337 sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 758 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
Faisal Zulfiqar
@faisal1337
Jul 01 2016 07:15
Great help :thumbsup:
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 07:15
@faisal1337 glad to help
afani martin
@whiz25
Jul 01 2016 07:20

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

result = ("cat", "small", "cried", "loudly");

// Your code above this line
return result;
}

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

help no expected result
CamperBot
@camperbot
Jul 01 2016 07:21
no wiki entry for: no expected result
afani martin
@whiz25
Jul 01 2016 07:21
challenge 156. help
Faisal Zulfiqar
@faisal1337
Jul 01 2016 07:24
@whiz25 you have to add spaces in between.
afani martin
@whiz25
Jul 01 2016 07:25
in between what?
Faisal Zulfiqar
@faisal1337
Jul 01 2016 07:27
the words
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 07:28
@whiz25
var h="Hello";
var w="world";
var ex=h+" "+w;//"Hello world"
Alex T.
@lx-t
Jul 01 2016 07:29
@whiz25 You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.
@whiz25 You will also need to use additional strings, which will not change, and must be in between all of the provided words. The output should be a complete sentence.
NatixDev
@NatixDev
Jul 01 2016 07:42
WTF is the DNA Pairing exercise lol
Vibhavmishra
@Vibhavmishra
Jul 01 2016 07:48
what is difference between object and json
DJ
@qualitymanifest
Jul 01 2016 07:49
@NatixDev http://www.biology-pages.info/B/BasePairing.html A pairs with T, T pairs with A, C pairs with G, and G pairs with C. so ATCG becomes AT, TA, CG, GC
Indhu
@Indhusethu
Jul 01 2016 07:49

function chainToSwitch(val) {
var answer = "";
// Only change code below this line
switch(val){
case "Bob":
answer="Marley";
break;
case 42:
answer="The Answer";
break;
case 1:
answer="There is no #1";
break;
case 99:
answer="Missed me by this much!";
break;
default:
answer="Ate Nine";
}

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

// Change this value to test
chainToSwitch(7);

where did i went wrong?
actually i have to change the code from if/else if statement to switch statemnt
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 07:52
@Indhusethu which exercise is this? The code looks fine.
Indhu
@Indhusethu
Jul 01 2016 07:52
Replacing if Else cahins with switch
@UtkarshShukla7
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 07:52
ok
Indhu
@Indhusethu
Jul 01 2016 07:53
do you have any idea about it?
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 07:54
@Indhusethu Bob should be bob
Indhu
@Indhusethu
Jul 01 2016 07:56
ok @UtkarshShukla7

switch(val){
case "bob":
answer="Marley";
break;
case 42:
answer="The Answer";
break;
case 1:
answer="There is no #1";
break;
case 99:
answer="Missed me by this much!";
break;
default:
answer="Ate Nine";
}

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

i'chainToSwitch("John") should be "" (empty string)
chainToSwitch(156) should be "" (empty string)
m getting this error
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 07:59
ok I'll check again
Indhu
@Indhusethu
Jul 01 2016 08:00
ok @UtkarshShukla7
Nathaniel Nasarow
@Torgian
Jul 01 2016 08:00
hey all
so javascript's forEach doesn't work for this JSON object array that I'm receiving from the API
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:00
remove your default @Indhusethu
it is case 7
Nathaniel Nasarow
@Torgian
Jul 01 2016 08:01
Is there another method? filter or map maybe?
Indhu
@Indhusethu
Jul 01 2016 08:01
i should add case instead of default??
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:01
yes
case 7
Indhu
@Indhusethu
Jul 01 2016 08:02
ok thank you i got it!!
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:02
@Indhusethu :+1:
Indhu
@Indhusethu
Jul 01 2016 08:03
:) @UtkarshShukla7
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:04
@Torgian forEach should work.Anyways I think you can use map or filter too .
Nathaniel Nasarow
@Torgian
Jul 01 2016 08:05
I don't think it will in this case. Maybe because it is a JSON response with objects, and not an array of objects? Not sure.
check the response from the call in console
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:06
@Torgian oh ok I thought it was an array of objects .let me check
Nathaniel Nasarow
@Torgian
Jul 01 2016 08:06
and when you click "Get" It responds json.forEach is not a function
primeinstiinct
@primeinstiinct
Jul 01 2016 08:07
can someone help me
how do you copy and paste code into here
Stas
@mastas3
Jul 01 2016 08:08
Help fotmat
CamperBot
@camperbot
Jul 01 2016 08:08
no wiki entry for: fotmat
Stas
@mastas3
Jul 01 2016 08:08
Help format
CamperBot
@camperbot
Jul 01 2016 08:08

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Stas
@mastas3
Jul 01 2016 08:08
Like this
Nathaniel Nasarow
@Torgian
Jul 01 2016 08:10
@UtkarshShukla7 I think i figured it out
using an ajax call instead
$.ajax({
        url: "https://api.forecast.io/forecast/0e3160c20902743e5164c362d063088f/" + latt + "," + long + "?callback=?",
        dataType: 'jsonp',
        success: function(results) {
          console.log(results);
        }
      })
gonna see if I can start using the data now
Indhu
@Indhusethu
Jul 01 2016 08:14
Return Early Pattern for Functions<- can anyone help me with this lesson?
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:15
@Torgian Yeah I was also wondering why json wasn't loading .I forgot to click get button :smile: but this will work
 for(val in json){
        console.log(val);
      };
Nathaniel Nasarow
@Torgian
Jul 01 2016 08:16
Cool, got two ways of doing it then
I kinda like the ajax call a bit better for readability
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:16
@Torgian yep me too that's better
Nathaniel Nasarow
@Torgian
Jul 01 2016 08:16
@UtkarshShukla7 thanks
CamperBot
@camperbot
Jul 01 2016 08:16
torgian sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 760 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:17
@Torgian np :+1:
Karolina Kluz
@karolinaKluz
Jul 01 2016 08:17
@Indhusethu if a or b are less than 0, return undefined. Do you know how to code it?
Indhu
@Indhusethu
Jul 01 2016 08:17
yes
@karolinaKluz
primeinstiinct
@primeinstiinct
Jul 01 2016 08:18
```js
Indhu
@Indhusethu
Jul 01 2016 08:18
a or b in the sense how should i write ?? is it (a,b)<0?
primeinstiinct
@primeinstiinct
Jul 01 2016 08:18
```js var remainder; 11 % 3 = 2;
Karolina Kluz
@karolinaKluz
Jul 01 2016 08:19
@Indhusethu if a is less than 0 or b is less than 0
Indhu
@Indhusethu
Jul 01 2016 08:20

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

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}// Change values below to test your code
abTest(2,2);
}

am i right now? @karolinaKluz
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:20
@primeinstiinct var remainder=11%3;
Indhu
@Indhusethu
Jul 01 2016 08:21
oh i got it
If(a<0)||(b<0) right?
Karolina Kluz
@karolinaKluz
Jul 01 2016 08:22
@Indhusethu you dont need to put a<0 in (), but the whole statement after if if(a<0||b<0)
Indhu
@Indhusethu
Jul 01 2016 08:23
ok @karolinaKluz
abTest(-2,2) should return undefined
abTest(2,-2) should return undefined
i'm getting this error now

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

return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}// Change values below to test your code
abTest(2,2);

Karolina Kluz
@karolinaKluz
Jul 01 2016 08:24
@Indhusethu undefined is not a string, in your code it is
Indhu
@Indhusethu
Jul 01 2016 08:25
oh yes,it is mentioned @karolinaKluz
i got it!! thank you @karolinaKluz
CamperBot
@camperbot
Jul 01 2016 08:25
indhusethu sends brownie points to @karolinakluz :sparkles: :thumbsup: :sparkles:
:cookie: 337 | @karolinakluz |http://www.freecodecamp.com/karolinakluz
Cristian Simionescu
@simi2525
Jul 01 2016 08:27
Cand someone tell me why my solution doesnt seem to work for only this imput?
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  gasit=null;
  arr=arr.sort();
  arr=arr.map(function(val){if(val>=num && gasit===null)gasit=val; return val;});
  if(gasit===null)
    return arr.length;

  return arr.indexOf(gasit);
}

getIndexToIns([5, 3, 20, 3], 5);
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:30
@simi2525 which challenge is it ?
Karolina Kluz
@karolinaKluz
Jul 01 2016 08:30
@simi2525 you are sorting numbers
@simi2525 you need the full method, this only works for strings, I guess
Cristian Simionescu
@simi2525
Jul 01 2016 08:31
@UtkarshShukla7 The "Where do I belong" one
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:31
@simi2525 ok
Cristian Simionescu
@simi2525
Jul 01 2016 08:31
@karolinaKluz But it works for all of the tested inputs except for this one, and I cant figure out why
Dan Couper
@DanCouper
Jul 01 2016 08:32
@simi2525 firstly, in that example, your sorted array is [20, 3, 3, 5]
it sorts lexically, not by value
and 2 is smaller than 3
so 20 comes before 3
you need to pass a callback
Cristian Simionescu
@simi2525
Jul 01 2016 08:33
@DanCouper Ohh, ok, that sounds like it. But wouldnt it then return 3? As in, that is where it would put it?
Dan Couper
@DanCouper
Jul 01 2016 08:34
No, it’s sorting by character code, not by number, so it looks at the first character and puts it in order of that
essentially, it treats them as strings
maybe best to think of it that way
you need to pass function(a,b) { return a - b; } to the sort to force it to calculate
the order by value
Cristian Simionescu
@simi2525
Jul 01 2016 08:35
@DanCouper I understood that, but after it is sorted like you said [20,3,3,5] , it shouldnt return 0 right?
Dan Couper
@DanCouper
Jul 01 2016 08:36
sorry, that’s a different issue - that’s just the first thing that jumped out at me
gimme a sec
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:37
@simi2525 it should because gasit=20
Karolina Kluz
@karolinaKluz
Jul 01 2016 08:37
@simi2525 I really don't get what are you doing in the map.
Cristian Simionescu
@simi2525
Jul 01 2016 08:37
@DanCouper It worked after I made the comparison function @DanCouper Thanks :D
CamperBot
@camperbot
Jul 01 2016 08:37
simi2525 sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 154 | @dancouper |http://www.freecodecamp.com/dancouper
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:37
@simi2525 arr.indexOf(gasit)=0; as gasit=20
Karolina Kluz
@karolinaKluz
Jul 01 2016 08:38
@simi2525 can I show you my solution to this challenge?
Dan Couper
@DanCouper
Jul 01 2016 08:38
@simi2525 ah, I hadn’t actually tested it :)
Cristian Simionescu
@simi2525
Jul 01 2016 08:39
@karolinaKluz Its fine, my problem was that I thought sort() would sort numbers as numbers and strings as string, I didnt read the documentation, I just presumed. It works now :D
@karolinaKluz And about my map() it just tryes to find the first number where my number would fit in and saves that in ''gasit''. After that it wont save anyother ''posible'' results. And i just return the index of that number.
Indhu
@Indhusethu
Jul 01 2016 08:40

var count = 0;

function cc(card) {
if(count===0)
{
return "0 Hold";
}
if(count++){
return "+1 Bet";
}
if(count--){
return "-1 Hold";
}

// Only change code above this line

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

did i do any mistake here?
:confused:
Dan Couper
@DanCouper
Jul 01 2016 08:42
@simi2525 also, I wouldn’t set things to null then check against that. But if you are doing that, that’s basically the one situation where you should use double equals rather than triple equals to compare. It means it checks if it’s null or undefined, which is generally what you want. Not specific to this challenge, just best practice: if (myVar == null) rather than if (myVar === null)
Cristian Simionescu
@simi2525
Jul 01 2016 08:46
@DanCouper I'll keep that in mind. I started this challange when I was tired and didnt really think before coding, thats why I resorted to that extra complication with my ''gasit'' variable.
Kunal Gupta
@kunalguptaofficial
Jul 01 2016 08:48

I need help on this
https://www.freecodecamp.com/challenges/stand-in-line

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.

Indhu
@Indhusethu
Jul 01 2016 08:49
where did you get stuck? @kunalguptaofficial
are you doing standinline in js?
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:52
@Indhusethu you have to update your count value after checking your card .
Indhu
@Indhusethu
Jul 01 2016 08:53
i couldn't get you @UtkarshShukla7
you mean increment?
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:53
@Indhusethu yes
Indhu
@Indhusethu
Jul 01 2016 08:54
ok @UtkarshShukla7
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:54
any change to count should be done after checking count
Indhu
@Indhusethu
Jul 01 2016 08:54

var count = 0;

function cc(card) {

if(count++){
return "+1 Bet";
}
if(count--){
return "-1 Hold";
}

is it right?
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:54
@Indhusethu where are you using card?
Indhu
@Indhusethu
Jul 01 2016 08:55
should i use card in if statement?/
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:55
@Indhusethu if or switch anything
Indhu
@Indhusethu
Jul 01 2016 08:57
ok i'm confused still
:confused:
Uliana Sirotina
@ulbka
Jul 01 2016 08:57
hey everybody! is there a d3 expert here?
fanititi
@fanititi
Jul 01 2016 08:58
hey, it's not related to algorithms challanges, but i want to know: how can i turn a string like "1 + 34 - 45 * 2 / 2" into the result (a number)?
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 08:58
@Indhusethu like switch (card ){case 2: count++}
Wenbo Lu
@lwbweb
Jul 01 2016 08:58
Can you speak Chinese?
Kunal Gupta
@kunalguptaofficial
Jul 01 2016 08:58
Hi @Indhusethu

I'm stuck here

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

return item; // Change this line
}

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

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

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.
Indhu
@Indhusethu
Jul 01 2016 08:59
k but i'm using it in if condition @UtkarshShukla7
hii @kunalguptaofficial
Wenbo Lu
@lwbweb
Jul 01 2016 08:59
o no
I will leave!
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:00
Indhu
@Indhusethu
Jul 01 2016 09:00
you should add arr.push(item) @kunalguptaofficial
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:00
@Indhusethu are you checking cards value
Indhu
@Indhusethu
Jul 01 2016 09:00
to add up the numbers
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:01
paste your code if you changed anything
Indhu
@Indhusethu
Jul 01 2016 09:01
@kunalguptaofficial
yeah am checking it @UtkarshShukla7
k sure
Uliana Sirotina
@ulbka
Jul 01 2016 09:01
d3 experts I neeed you
Indhu
@Indhusethu
Jul 01 2016 09:02
wat should i do if i use if statement??
@UtkarshShukla7
Uliana Sirotina
@ulbka
Jul 01 2016 09:02
anybody who knows d3js!!!
pleasssse
Indhu
@Indhusethu
Jul 01 2016 09:02
no am sry @ulbka
Kunal Gupta
@kunalguptaofficial
Jul 01 2016 09:03
@Indhusethu Can you please help me with the full code
That will help me to understand it better
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:03
@ulbka I don't think there is currently any .Try in the main room
help rooms
Indhu
@Indhusethu
Jul 01 2016 09:03
k wait @kunalguptaofficial
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:03
help room
CamperBot
@camperbot
Jul 01 2016 09:03

:point_right: help rooms [wiki]

FreeCodeCamp Chat Rooms

Help Rooms

Chat Room Description Chat Room
HTML/CSS/Bootstrap FreeCodeCamp/Help
JavaScript/Algorithms FreeCodeCamp/HelpJavaScript
Front End FreeCodeCamp/HelpFrontEnd
Data Visualization FreeCodeCamp/HelpDataViz
Back End FreeCodeCamp/HelpBackEnd

Choose the right room for your questions!

See also: :earth_asia: Language Specific | :satellite: Technology | :crystal_ball: Miscellaneous

back to top ↑

:pencil: read more about help rooms on the FCC Wiki

Indhu
@Indhusethu
Jul 01 2016 09:03

function nextInLine(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(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

@kunalguptaofficial
fanititi
@fanititi
Jul 01 2016 09:03
hey, it's not related to algorithms challanges, but i want to know: how can i turn a string like "1 + 34 - 45 * 2 / 2" into the result (a number)?
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:04
@Indhusethu if(card===2) count++;
this is an example
Krishna Sai Gullapalli
@Krish2704
Jul 01 2016 09:04
@fanititi parseInt or parseFloat
Kunal Gupta
@kunalguptaofficial
Jul 01 2016 09:04
Thanks for the code @Indhusethu
CamperBot
@camperbot
Jul 01 2016 09:04
kunalguptaofficial sends brownie points to @indhusethu :sparkles: :thumbsup: :sparkles:
:cookie: 84 | @indhusethu |http://www.freecodecamp.com/indhusethu
Indhu
@Indhusethu
Jul 01 2016 09:05
ok @UtkarshShukla7
it's my pleasure @kunalguptaofficial
Kunal Gupta
@kunalguptaofficial
Jul 01 2016 09:06
I understood the push() function. But can't figure what var testArr is doing there?
Krishna Sai Gullapalli
@Krish2704
Jul 01 2016 09:06
var str="1 + 34 - 45 * 2 /";
str=parseFloat(str);
console.log(str);
\\this will print 1
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:06
@kunalguptaofficial testArray is the array you will pass to the function
Indhu
@Indhusethu
Jul 01 2016 09:06
you are creating a new variable testArr @kunalguptaofficial

var count = 0;

function cc(card) {

if(card===+1){
return "+1 Bet";
}
if(card===-1){
return "-1 Hold";
}
if(card===0){
return "0 Hold";
}

// Only change code above this line

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

UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:07
you can change the value of your testArr and use the same function for your purpose.
Indhu
@Indhusethu
Jul 01 2016 09:07
@UtkarshShukla7
i've changed the code
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:09
@Indhusethu no just read the instructions again .Update the value of count after checking your value of card(2,3,5) and then after changing the value of count ,check
if (count  >0){ return count  + " Bet ";} 
else{ return count+ " Hold";}
Indhu
@Indhusethu
Jul 01 2016 09:10
can you help me with the full code?
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:10
@Indhusethu you want the solution?
Indhu
@Indhusethu
Jul 01 2016 09:10
yes @UtkarshShukla7
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:11
then tell me the name of the challenge
Indhu
@Indhusethu
Jul 01 2016 09:11
counting cards
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:11
ok
Indhu
@Indhusethu
Jul 01 2016 09:11
thank you:) @UtkarshShukla7
CamperBot
@camperbot
Jul 01 2016 09:11
indhusethu sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 761 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
Anirudha Kasralikar
@akasralikar
Jul 01 2016 09:12
@Indhusethu on challenge page there is link called "Wiki" at top navigation click , usually you can use it to verify your solution
wiki generally has standard solution for all challenges
CamperBot
@camperbot
Jul 01 2016 09:12
no wiki entry for: generally has standard solution for all challenges
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:12
@Indhusethu check your pm
Anirudha Kasralikar
@akasralikar
Jul 01 2016 09:12
but use it only when you done with your all efforts
Indhu
@Indhusethu
Jul 01 2016 09:13
ok @UtkarshShukla7
yes sure @akasralikar
i think i'm doing my best
Ayush Sharma
@a-y-u-s-h
Jul 01 2016 09:14
Can somone help me with challenge 211 please?
Anirudha Kasralikar
@akasralikar
Jul 01 2016 09:14
:thumbsup: @Indhusethu
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:15
@a-y-u-s-h tell the challenge name not your brownie points :wink:
Ananay
@ananaymital
Jul 01 2016 09:23
can someone help in the record collection challenge please?
Victor
@Vicktorius
Jul 01 2016 09:26
Hello guys,could somebody help me to understand Manipulating Complex Objects challange,please
Daniel Ekwuazi
@Dcwind
Jul 01 2016 09:26
@a-y-u-s-h @Deadpool37 post your code here.
Ananay
@ananaymital
Jul 01 2016 09:27

// 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": {
"album": "",
"artist": "Robert Palmer",
"tracks": [ ]
},
"5439": {
"album": "ABBA Gold",
"artist": "",
"tracks": []
}
};
// 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(collectionCopy.hasOwnProperty(id)){
if(id.hasOwnProperty("tracks")){
if(value!==null)
collectionCopy.id.prop.push(value);
else
delete collectionCopy.id.prop;
}
else if(!id.hasOwnProperty(prop)){
collectionCopy.id[prop] = "prop";
}
}

return collectionCopy;
}

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

UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:28
@Vicktorius your code
??
Victor
@Vicktorius
Jul 01 2016 09:28

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

}

];
var myMusic = [{
"artist":"Linkin Park",
"title":"Hybrid Theory",
"release_year":2000,
"formats":["CD","Cassete","Vinyl"],
"gold": true
}];

UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:29
@Deadpool37 why are you defining you myMusic
you can add object to the array by separating it with ,
Ananay
@ananaymital
Jul 01 2016 09:30
@UtkarshShukla7 that's not mine
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:30
@Vicktorius :point_up: July 1, 2016 2:59 PM
@Deadpool37 sorry I got confused
Leonid S. Knyshov
@wiseleo
Jul 01 2016 09:31
OK, let's make this a bit more readable...
function updateRecords(id, prop, value) {
  if (collectionCopy.hasOwnProperty(id)) {
    if (id.hasOwnProperty("tracks")) {
      if (value !== null)
        collectionCopy.id.prop.push(value);
      else
        delete collectionCopy.id.prop;
    } else if (!id.hasOwnProperty(prop)) {
      collectionCopy.id[prop] = "prop";
    }
  }
  return collectionCopy;
}
That's a lot of nested ifs. @deadpool37
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:31
@Deadpool37 first of all use collection ,then collection[id] gives you the object you are looking for not just id
Daniel Ekwuazi
@Dcwind
Jul 01 2016 09:33
function updateRecords(id, prop, value) {
 if(prop === "tracks"){
   if(value){  
     if(collection[id].hasOwnProperty(prop)){
       collection[id][prop].push(value);
     }else{
       collection[id][prop] = [];
       collection[id][prop].push(value);
     }
   }else{
     delete collection[id][prop];
   }  
 }else{
   if(value){
      collection[id][prop] = value;
   }else{
     delete collection[id][prop];
   }
 }
 return collection;
}
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:34
@Dcwind I think it can be concised further .
Victor
@Vicktorius
Jul 01 2016 09:34

@UtkarshShukla7
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true}
{"artist":"Linkin Park",
"title":"Hybrid Theory",
"release_year":2000,
"formats":["CD","Cassete"]

}

];

something is not working
it asks me for a semicolon
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:35
after "gold"=true} add a ,
Leonid S. Knyshov
@wiseleo
Jul 01 2016 09:36
@Deadpool37 OK... I know what your problem is. You are using dot notation with variables.
var objname;
var objprop;
objname.objprop = 'test'; // this will not work.
objname[objprop] = 'test'; // this will work
Daniel Ekwuazi
@Dcwind
Jul 01 2016 09:36
@UtkarshShukla7 I also think the same. I'm looking at ways to do so. Your input would be highly appreciated.
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:37
@Dcwind you have 2 delete condition you can bring it to 1 by making the main condition to be value
Ananay
@ananaymital
Jul 01 2016 09:37
ok so using .objprop gives objprop and [objprop] gives the value of .objprop
am i getting it right?
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:38
@Dcwind and
if(!collection[id].hasOwnProperty(prop)){
       collection[id][prop]=[];
 }
       collection[id][prop].push(value);
     }
Leonid S. Knyshov
@wiseleo
Jul 01 2016 09:38
@Deadpool37 It is a syntax error to use variables in dot notation.
Daniel Ekwuazi
@Dcwind
Jul 01 2016 09:39
that's cool, very concised. @UtkarshShukla7
afani martin
@whiz25
Jul 01 2016 09:39

i see no prob here
// Setup
var outerWear = "T-Shirt";

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

outerWear = "sweater";

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

myOutfit(); who sees?

UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:39
try starting by if(value!=="") and you can concise it further
Leonid S. Knyshov
@wiseleo
Jul 01 2016 09:40
@whiz25 What tests are you failing? Please use ``` before pasting your code. :)
help format
CamperBot
@camperbot
Jul 01 2016 09:40

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Ananay
@ananaymital
Jul 01 2016 09:40
@wiseleo really? because i did use dot notation using a variable and there was no error with that
Leonid S. Knyshov
@wiseleo
Jul 01 2016 09:40
@Deadpool37 It's a silent error. One of pitfalls of JavaScript. It's too helpful. :)
UtkarshShukla7
@UtkarshShukla7
Jul 01 2016 09:40
@Vicktorius
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true},
{"artist":"Linkin Park",
"title":"Hybrid Theory",
"release_year":2000,
"formats":["CD","Cassete"]
}
];
Ananay
@ananaymital
Jul 01 2016 09:41
ok thanks :)
Leonid S. Knyshov
@wiseleo
Jul 01 2016 09:41
@Deadpool37 Whenever accessing object properties in a loop, use the bracket notation.
Markus Kiili
@Masd925
Jul 01 2016 09:45
@wiseleo It should not be an error because it just looks for the wrong key.
Indhu
@Indhusethu
Jul 01 2016 09:45

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

// Only change code below this line

var testObj["an entree"]; // Change this line
var testObj["my side"];
var testObj["the drink"];// Change this line

why am i not getting this correctly?
Coy Sanders
@coymeetsworld
Jul 01 2016 09:46
@Indhusethu youre missing variable names
you need to create variables entreeValue and drinkValue and assign those to the appropriate values found in testObj
Indhu
@Indhusethu
Jul 01 2016 09:47
variable name is testObj...right?
Coy Sanders
@coymeetsworld
Jul 01 2016 09:47
no, thats your variable assigned to your object
Indhu
@Indhusethu
Jul 01 2016 09:47
oh!!
kk i understand
@coymeetsworld
C