These are chat archives for FreeCodeCamp/HelpJavaScript

2nd
Jul 2016
babooon
@babooon
Jul 02 2016 00:00
i learned something though, thanks @excelbrium
CamperBot
@camperbot
Jul 02 2016 00:00
babooon sends brownie points to @excelbrium :sparkles: :thumbsup: :sparkles:
:cookie: 342 | @excelbrium |http://www.freecodecamp.com/excelbrium
Oliver Jumpertz
@excelbrium
Jul 02 2016 00:01
oh, you're welcome
Adewale Adekoya
@Dewale
Jul 02 2016 00:01
@Chrono79 @arinarjani

function repeatStringNumTimes(str, num) {
  // repeat after me
  if(num<0){
    return "";
  }
  var finalA = [];
  var newS = str.split('');
  var newS1 = newS.join('');
  var i=0;
  while(i<num){
    finalA.push(newS1);
    i++;
  }
  var answer = finalA.join('');
  //var regex  = /[\w]/gi;
  //var final = answer.match(regex);
  return answer;
}

repeatStringNumTimes("abc", 3);
is there a better way?
Brendan Kinahan
@BKinahan
Jul 02 2016 00:02
@Dewale definitely, there's a repeat() method :)
Diego Mayer
@Chrono79
Jul 02 2016 00:02
@BKinahan that's cheating!
Brendan Kinahan
@BKinahan
Jul 02 2016 00:02
how is it cheating? :P
Diego Mayer
@Chrono79
Jul 02 2016 00:02
@Dewale why using arrays?
Moisés Man
@moigithub
Jul 02 2016 00:03
@Dewale
var newS = str.split('');
var newS1 = newS.join('');
will be the same as
var newS = str;
Diego Mayer
@Chrono79
Jul 02 2016 00:03
@BKinahan it's like using endsWith in Confirm the ending
Adewale Adekoya
@Dewale
Jul 02 2016 00:03
@moigithub hahaha didnt even notice
Diego Mayer
@Chrono79
Jul 02 2016 00:03
@Dewale use only strings (it can be done without using repeat() )
Brendan Kinahan
@BKinahan
Jul 02 2016 00:04
@Chrono79 perfectly cromulent solution.
Adewale Adekoya
@Dewale
Jul 02 2016 00:04
@Chrono79 ive done it im just looking for your one-liner solutions to learn from
Diego Mayer
@Chrono79
Jul 02 2016 00:05
I'm gonna start leaving false solutions here and there ;)
babooon
@babooon
Jul 02 2016 00:07
you could just declare a new string and add to it with a for-loop
Moisés Man
@moigithub
Jul 02 2016 00:07
for(var i=0, boo=""; i<num; i++,boo+=str); return boo;
one line ?? (or removing the line feed doesnt count ? )
Diego Mayer
@Chrono79
Jul 02 2016 00:09
mmmm, I guess those are 2 lines
but I could be wrong
Brendan Kinahan
@BKinahan
Jul 02 2016 00:12
@Chrono79 lol, just noticed that "Confirm the Ending" has a new test for not using .endsWith() So yeah for that one it would be cheating (if you found a way to use it). But repeat() isn't against a test in Repeat a String!
babooon
@babooon
Jul 02 2016 00:12
in python or something you could do return str*num;
Diego Mayer
@Chrono79
Jul 02 2016 00:13
I'm gonna ask for a test addition then :P
BKinahan @BKinahan shakes fist
Brendan Kinahan
@BKinahan
Jul 02 2016 00:13
why you wanna break my solution?!
Moisés Man
@moigithub
Jul 02 2016 00:13
return [...new Array(num)].map(()=>str).join("")
Diego Mayer
@Chrono79
Jul 02 2016 00:14
lol
that seems a one line solution, but sometimes less lines doesn't mean better performance @moigithub
Moisés Man
@moigithub
Jul 02 2016 00:15
yep :) @Chrono79
that looks like O(M+N) map+join
for/loop seems faster only 1 loop
Diego Mayer
@Chrono79
Jul 02 2016 00:16
it's always good to see another way of doing it though
Leonid S. Knyshov
@wiseleo
Jul 02 2016 00:18
Debugging one liners is always fun. ;)
Luis Felipe López G.
@luishendrix92
Jul 02 2016 00:20
Doesn't the spread operator eliminate the need of the array constructor?
Diego Mayer
@Chrono79
Jul 02 2016 00:20
@moigithub I think this is the right answer because there is a test where num is -2: return num > 0 ? [...new Array(num)].map(()=>str).join("") : "";
Moisés Man
@moigithub
Jul 02 2016 00:21
@Chrono79 no need
cuz new Array(0) return []
Diego Mayer
@Chrono79
Jul 02 2016 00:21
@moigithub you have to return ""
Moisés Man
@moigithub
Jul 02 2016 00:21
unless u enter negative nums.. that would break
[].join("")
""
Leonid S. Knyshov
@wiseleo
Jul 02 2016 00:22

For example, I kept thinking why I kept getting stuck in infinite loop.

var arr = [1,2];
var size = 2;
for (var i = 0; i < arr.length; i++) { console.log ('works')}
for (var i = 0; i < arr.length; i+size) { console.log ('has a bug')}

Well, that's because i++ is a one-liner shortcut for i=i+1 or i+=1 and so i+size is wrong. Not so obvious at 2am. That's part of the fun debugging one-liners and other shortcuts.

Diego Mayer
@Chrono79
Jul 02 2016 00:22
@moigithub RangeError: Invalid array length
Moisés Man
@moigithub
Jul 02 2016 00:22
yep.
unless u enter negative nums.. that would break
@wiseleo i+size make calc.. but dont increasing i
i=i+size
i+=size
Luis Felipe López G.
@luishendrix92
Jul 02 2016 00:28
Is this good to create a range? [...new Array(max-min)].map((_, idx) => idx + min);
Or are there more efficient ways?
Santiago Gómez
@Sperkajugglite
Jul 02 2016 00:31

hi, i have a function increase

function increase(variable) {
    if (variable < 25) {
      variable++;
    }
  }

that is supposed to increase the value of the variable passed to it, and i calle it with:

$("#increase-break").on("click", function() {
    increase(breakTime);
    $("#break-time").text(breakTime);
  });

it works if i use breakTime++, but i want to make code smaller and reusable, do you know why it doesn't work?

Oliver Jumpertz
@excelbrium
Jul 02 2016 00:31
a simple loop would always do the job ;) @luishendrix92
Luis Felipe López G.
@luishendrix92
Jul 02 2016 00:31
@excelbrium A map is a loop, just, abstracted and some miliseconds less efficient
Brendan Kinahan
@BKinahan
Jul 02 2016 00:31
@luishendrix92 that seems like a fine way if you need it to be in one line. I'd probably use a different variable for the index than idx but that's just personal preference.
Luis Felipe López G.
@luishendrix92
Jul 02 2016 00:31
I love ES6, would never let it down
Oliver Jumpertz
@excelbrium
Jul 02 2016 00:32
@luishendrix92 yes, I am aware of that, just wanted to mention it :)
Brendan Kinahan
@BKinahan
Jul 02 2016 00:32
@luishendrix92 just watch out for ES6 feature browser compatibility.
Luis Felipe López G.
@luishendrix92
Jul 02 2016 00:32
babel :)
although instead of Promises in ES6 I use a lib called PromiseJS
and no generators (can't understand them yet to a full extent)
cba to figure out how to install polyfill.js
Emma Cooper
@199coopere
Jul 02 2016 00:34
hey can someone help me filter out NaN values
I'm working on the Falsy Bouncer challenge and everything but that works
Luis Felipe López G.
@luishendrix92
Jul 02 2016 00:34
@199coopere using .filter() and learning about falsy values
help falsey
CamperBot
@camperbot
Jul 02 2016 00:35
no wiki entry for: falsey
Oliver Jumpertz
@excelbrium
Jul 02 2016 00:35
@199coopere the solution actually is dead simple and built in but I'm not sure that MDN states it
Luis Felipe López G.
@luishendrix92
Jul 02 2016 00:35
help falsy
CamperBot
@camperbot
Jul 02 2016 00:35

:point_right: algorithm falsy bouncer [wiki]

Algorithm Falsy Bouncer

: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:

Remove all falsy values from an array.

Relevant Links

:pencil: read more about algorithm falsy bouncer on the FCC Wiki

Emma Cooper
@199coopere
Jul 02 2016 00:35
Ok I know to use filter
every other type gets filtered out
But I don't know how to check for NaN values
Santiago Gómez
@Sperkajugglite
Jul 02 2016 00:36

hi, i have a function increase

function increase(variable) {
    if (variable < 25) {
      variable++;
    }
  }

that is supposed to increase the value of the variable passed to it, and i calle it with:

$("#increase-break").on("click", function() {
    increase(breakTime);
    $("#break-time").text(breakTime);
  });

it works if i use breakTime++, but i want to make code smaller and reusable, do you know why it doesn't work? :P :innocent: :interrobang:

Oliver Jumpertz
@excelbrium
Jul 02 2016 00:36
check hint 1 in the wiki @199coopere
Emma Cooper
@199coopere
Jul 02 2016 00:37
Falsy is something which evaluates to FALSE. There are only six falsy values in JavaScript: undefined, null, NaN, 0, "" (empty string), and false of course.
That?
Oliver Jumpertz
@excelbrium
Jul 02 2016 00:37
yes
Luis Felipe López G.
@luishendrix92
Jul 02 2016 00:37
@Sperkajugglite Because breakTime is being passed "by value", you're modifying the variable in the function, not the one you passed.
Emma Cooper
@199coopere
Jul 02 2016 00:37
I know what to do
I have everything else working
Santiago Gómez
@Sperkajugglite
Jul 02 2016 00:37
@luishendrix92 how con i modify it ?
Brendan Kinahan
@BKinahan
Jul 02 2016 00:38
@Sperkajugglite your function should return something :)
Emma Cooper
@199coopere
Jul 02 2016 00:38
I just need someone to help me figure out how to filter out the specific values that are equal to NaN
Oliver Jumpertz
@excelbrium
Jul 02 2016 00:38
@199coopere no that shows me that you are missing the most obvious solution
Norvin Burrus
@ndburrus
Jul 02 2016 00:38

@199coopere this may be helpful:

  • Boolean

    The value passed as the first parameter is converted to a boolean value, if necessary. If value is omitted or is 0, -0, null, false, NaN, undefined, or the empty string (""), the object has an initial value of false. All other values, including any object or the string "false", create an object with an initial value of true.

Santiago Gómez
@Sperkajugglite
Jul 02 2016 00:38
@BKinahan oh ok...
thanks @BKinahan
CamperBot
@camperbot
Jul 02 2016 00:38
sperkajugglite sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1890 | @bkinahan |http://www.freecodecamp.com/bkinahan
Luis Felipe López G.
@luishendrix92
Jul 02 2016 00:38
@Sperkajugglite by returning it while also incrementing it!
return ++variable I think
Emma Cooper
@199coopere
Jul 02 2016 00:38
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  function isValid(value) {
   return value !== false && value !== null && value !== 0 && value !== "" && value !== undefined && Number.isNaN(value);
  }
  return arr.filter(isValid);
}

bouncer([7, "ate", "", false, 9]);
Brendan Kinahan
@BKinahan
Jul 02 2016 00:38
@Sperkajugglite but then you also need to assign the return of the function to something ;)
Santiago Gómez
@Sperkajugglite
Jul 02 2016 00:38
@luishendrix92 thanks
CamperBot
@camperbot
Jul 02 2016 00:38
sperkajugglite sends brownie points to @luishendrix92 :sparkles: :thumbsup: :sparkles:
Emma Cooper
@199coopere
Jul 02 2016 00:38
that's what I have so far
CamperBot
@camperbot
Jul 02 2016 00:38
:cookie: 815 | @luishendrix92 |http://www.freecodecamp.com/luishendrix92
Oliver Jumpertz
@excelbrium
Jul 02 2016 00:38
@199coopere that's too complicated
Emma Cooper
@199coopere
Jul 02 2016 00:39
but the NaN part doesn't work
Santiago Gómez
@Sperkajugglite
Jul 02 2016 00:39
@luishendrix92 @BKinahan thanks
CamperBot
@camperbot
Jul 02 2016 00:39
sperkajugglite sends brownie points to @luishendrix92 and @bkinahan :sparkles: :thumbsup: :sparkles:
:warning: sperkajugglite already gave bkinahan points
:warning: sperkajugglite already gave luishendrix92 points
Santiago Gómez
@Sperkajugglite
Jul 02 2016 00:39
:)
Sam
@alakasam
Jul 02 2016 00:39
This message was deleted
CamperBot
@camperbot
Jul 02 2016 00:39
:bulb: to format code use backticks! ``` more info
Diego Mayer
@Chrono79
Jul 02 2016 00:39
@199coopere you check for NaN with value != value
Emma Cooper
@199coopere
Jul 02 2016 00:39
Yeah it threw an error
you can't use equality operaters with NaN values
So first I found the function isNaN
Sam
@alakasam
Jul 02 2016 00:40
Hey guys, my code should be correct, but the page isn't marking any tasks completed for Mutations.. I've manually confirmed that all the values correctly return true/false as the challenge requires.. unless there's something wrong with my code?
function mutation(arr) {
  var arr1= arr[0].toLowerCase().split("");
  var arr2 = arr[1].toLowerCase().split("");
  for (var i=0; i<arr2.length; i++) {
    if (arr1.indexOf(arr2[i]) == -1){  
    return false;}
  }
    return true; 
}
mutation(["Mary", "Aarmy"]);
Emma Cooper
@199coopere
Jul 02 2016 00:40
but that didn't work and I continued looking through the documentation and found what was supposedly a better funtion but it uses the number constructor, which threw an error
Luis Felipe López G.
@luishendrix92
Jul 02 2016 00:40
@Sperkajugglite I think it will only work once, you may need to use a side effect, don't receive the breakTime but increment it inside the function and then return it.
Oliver Jumpertz
@excelbrium
Jul 02 2016 00:41
@199coopere the only hint I could give you is the solution :/
Diego Mayer
@Chrono79
Jul 02 2016 00:41
@199coopere first time I heard that https://repl.it/C7nW/3
Emma Cooper
@199coopere
Jul 02 2016 00:41
@alakasam I just finished that challenge I'll help you in a second
Oliver Jumpertz
@excelbrium
Jul 02 2016 00:41
@199coopere do you have a codepen open?
Luis Felipe López G.
@luishendrix92
Jul 02 2016 00:41
Or just plain don't use a function for that, just do ++breakTime in the jQuery thing
Santiago Gómez
@Sperkajugglite
Jul 02 2016 00:41
:( didn't work
 function increase(variable) {
    if (variable < 25) {
      return variable++;
    }
  }
Norvin Burrus
@ndburrus
Jul 02 2016 00:42
@199coopere hint: The Boolean object is an object wrapper for a boolean value.
Luis Felipe López G.
@luishendrix92
Jul 02 2016 00:42
@Sperkajugglite Don't use a function then, just do ++breakTime
Emma Cooper
@199coopere
Jul 02 2016 00:42
@excelbrium I have a codepen account I don't have the program open but I could do so easily
Luis Felipe López G.
@luishendrix92
Jul 02 2016 00:42
by the way, what will the value be if variable is greater or equal than 25? Is it 0?
Santiago Gómez
@Sperkajugglite
Jul 02 2016 00:43
@luishendrix92 ok, then i will , thanks @luishendrix92
CamperBot
@camperbot
Jul 02 2016 00:43
sperkajugglite sends brownie points to @luishendrix92 :sparkles: :thumbsup: :sparkles:
:warning: sperkajugglite already gave luishendrix92 points
Oliver Jumpertz
@excelbrium
Jul 02 2016 00:43
just leaving that here, play around with it :)
var val = "";
if (!val) {
   console.log("Opps...what happened here?!")
}
Diego Mayer
@Chrono79
Jul 02 2016 00:43
Luis Felipe López G.
@luishendrix92
Jul 02 2016 00:45

@Sperkajugglite

$("#increase-break").on("click", function() {
  $("#break-time").text(breakTime < 25? ++breakTime : 0);
});

That will work I think, but what needs to happen when breakTime is not less than 25? I assumed it's gonna be 0 so I put a 0 after the colon but IDK, it's up to you

Emma Cooper
@199coopere
Jul 02 2016 00:46
@alakasam how did you manually confirm the values?
@alakasam also i created another array and put all of the index values in it and then looped through it to see if any were equal to negative one
@alakasam and that worked
Diego Mayer
@Chrono79
Jul 02 2016 00:49
@alakasam if your logic is ok, try refreshing your browser
no need for using arrays, you could use indexOf string method
Edgar Elias
@Edgar-Elias
Jul 02 2016 00:56
how do you put a screen shot of code?
Oliver Jumpertz
@excelbrium
Jul 02 2016 00:56
it's markdown
type ``` and close your code with
Luis Felipe López G.
@luishendrix92
Jul 02 2016 00:57
help format
CamperBot
@camperbot
Jul 02 2016 00:57

: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

Oliver Jumpertz
@excelbrium
Jul 02 2016 00:57
```
Edgar Elias
@Edgar-Elias
Jul 02 2016 01:00
got it thanks guys
Sam
@alakasam
Jul 02 2016 01:03
@199coopere I did so buy changing the strings in the array and running the code
Adewale Adekoya
@Dewale
Jul 02 2016 01:03

function truncateString(str, num) {
  // Clear out that junk in your trunk
 // var f=str.split('')
 if(num>=str.length){
    return str;
  }

  else if (num >3){
    var arr = "...";
    var f = str.slice(0, num-3);
     var nf= f.split('');
    nf.push(arr);
    var gn = nf.join('');

   return gn;
 }

  else if (num<3){
    var arr="...";
    var final = str.slice(0,num);
    var ans = final+arr;

    return ans;
  }


  //var length = f.length;

}

truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length);
better solution appreciated
Sam
@alakasam
Jul 02 2016 01:04
nvm i refreshed the browser and it works! thanks @199coopere and @Chrono79
CamperBot
@camperbot
Jul 02 2016 01:04
alakasam sends brownie points to @199coopere and @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1387 | @chrono79 |http://www.freecodecamp.com/chrono79
:cookie: 274 | @199coopere |http://www.freecodecamp.com/199coopere
Adewale Adekoya
@Dewale
Jul 02 2016 01:04
@Chrono79
Diego Mayer
@Chrono79
Jul 02 2016 01:06
@Dewale try without using arrays
David Liendo
@DavLiendoProgramming
Jul 02 2016 01:07
hello.... its me again ._.
im on the find the longest word in a string challenge...
if soebody could tell me what am i doign wrong in my coide i would appreciate it x.x
function findLongestWord(str) {

  var leng=0;
  var res=str.split(" ");
res2=res;
  for(var i =0; i< res.length;i++){
    if( leng<res.i ){
      leng=res.i.length;
    }
  }

  return leng;
      }
Leonid S. Knyshov
@wiseleo
Jul 02 2016 01:10
@DavLiendoProgramming You are using variables in dot notation while trying to access properties on objects. That does not work. Try return res.i.length; to see what it actually returns.
Norvin Burrus
@ndburrus
Jul 02 2016 01:13
@DavLiendoProgramming also, when you iterate over the words you need to identify each word's length. you can compare this length to your leng variable length to obtain the longest length per iteration...
Arin
@arinarjani
Jul 02 2016 01:18

@DavLiendoProgramming your code is solid once you fix the errors stated above by @wiseleo and @ndburrus . Not sure if you need res2=res

// sample array in case you forgot

var arr = [1,2,3,4,5,6];
console.log( arr[2] );  // should get 3

also, I just started using pythontutor.com today and it is helping a lot with how the code executes step-by-step, so maybe give it a try.

Matt Topping
@ToyGoblin
Jul 02 2016 01:19
This message was deleted
CamperBot
@camperbot
Jul 02 2016 01:19
:bulb: to format code use backticks! ``` more info
Leonid S. Knyshov
@wiseleo
Jul 02 2016 01:19
@arinarjani His code has syntax errors. They are not errors in Python, but they are in JavaScript.
Arin
@arinarjani
Jul 02 2016 01:20
@wiseleo I meant it is solid logic wise. fix the errors and it should work. I should have specified that. I ran his code with the fixed you mentioned and it worked just fine. He also needs to compare each strings length as @ndburrus said
@wiseleo you can test in JS on pythontutor
Leonid S. Knyshov
@wiseleo
Jul 02 2016 01:21
@arinarjani Now, that's interesting. You can edit your original message to add the clarification. These conversations get archived.
Sebastian Dobri
@Seby56
Jul 02 2016 01:22
Hi,
Can anyone help me with Nesting For Loops(#225) ?

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i < arr.length; i++){
for (var j = 0; j < arr[i].length;j++){
product *= j;
}
}
// Only change code above this line
return product;
}

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

this is my code
Matt Topping
@ToyGoblin
Jul 02 2016 01:23
var flatten = function (array){
  for (var i = 0; i <= array.length; i ++) {
  var theFlattening = array.join(',');
  return theFlattening;
  }
}
console.log(flatten([[1, 2, 3], ["a", "b", "c"], [1, 2, 3]]), [1, 2, 3, "a", "b", "c", 1, 2, 3])
Trying to get all array into one string, can't see to grab the other? any input? thank you
Arin
@arinarjani
Jul 02 2016 01:23
@wiseleo thanks for letting me know I can edit my messages. I am still getting used to the rooms on here
CamperBot
@camperbot
Jul 02 2016 01:23
arinarjani sends brownie points to @wiseleo :sparkles: :thumbsup: :sparkles:
:cookie: 279 | @wiseleo |http://www.freecodecamp.com/wiseleo
Luis Felipe López G.
@luishendrix92
Jul 02 2016 01:26
@ToyGoblin You can flatten an array of arrays, but you can't flatten a deep array (arrays inside arrays inside arrays) because you don't exactly know how many levels deep it is.
So the solution is to do Recursion.
which is a complicated topic, basically you check to see if the item is an array, if so, you keep exploring it by calling the same function you're writing and if not, add it to a temporary array or use concat.
Matt Topping
@ToyGoblin
Jul 02 2016 01:31
@luishendrix92 hmm, okay. I will look into recursion. is it possible to try and take all inputs into an empty array and then "flatten" those? Thank you Luis.
CamperBot
@camperbot
Jul 02 2016 01:31
toygoblin sends brownie points to @luishendrix92 :sparkles: :thumbsup: :sparkles:
:cookie: 816 | @luishendrix92 |http://www.freecodecamp.com/luishendrix92
David Liendo
@DavLiendoProgramming
Jul 02 2016 01:33
hey guys x.x @wiseleo and @ndburrus , im sorry but english is not my native lenguage ... i couldnt udnerstand quite well what you guys tried to say..... so i just changed my dot notation for [] ?
Norvin Burrus
@ndburrus
Jul 02 2016 01:33
@Mrblue27 where do you want the result to go?
Luis Felipe López G.
@luishendrix92
Jul 02 2016 01:33
@ToyGoblin Not sure what you mean, if you are talking about the function arguments, you can concat the arguments array into one by using var args = Array.prototype.slice.call(arguments, null);
Norvin Burrus
@ndburrus
Jul 02 2016 01:36
@Seby56 this is what you need: multiplies the product variable by each number in the sub-arrays of arr. you have product *= j; is that accurate? hint: what about the i array iteration?
Matt Topping
@ToyGoblin
Jul 02 2016 01:36
@luishendrix92 correct, sorry I meant arguments.
Sebastian Dobri
@Seby56
Jul 02 2016 01:38
@ndburrus Thank you, I manage to solve that one. But now I need some help at next one (#227) Profile Lookup. Can you help me please?
CamperBot
@camperbot
Jul 02 2016 01:38
seby56 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 764 | @ndburrus |http://www.freecodecamp.com/ndburrus
Leonid S. Knyshov
@wiseleo
Jul 02 2016 01:39
@DavLiendoProgramming Correct. That was my hint.
Norvin Burrus
@ndburrus
Jul 02 2016 01:40
@Seby56 take a swing at it and let's see what you think...
David Liendo
@DavLiendoProgramming
Jul 02 2016 01:40
function findLongestWord(str) {

  var leng=0;
  var res=str.split(" ");

  for(var i =0; i< res.length;i++){
    if( leng<res[i] ){
      leng=res[i].length;
    }
  }

  return leng;
      }
like that? x.x @wiseleo
James S.
@Mrblue27
Jul 02 2016 01:40
@ndburrus I get arr.push is not a function to start
Leonid S. Knyshov
@wiseleo
Jul 02 2016 01:41
@DavLiendoProgramming that looks promising. Do the tests pass?
David Liendo
@DavLiendoProgramming
Jul 02 2016 01:41
nope
it keeps returning me 0
Leonid S. Knyshov
@wiseleo
Jul 02 2016 01:41
@DavLiendoProgramming Which tests fail?
David Liendo
@DavLiendoProgramming
Jul 02 2016 01:41
like its not getting inside the if
all of them fail
Leonid S. Knyshov
@wiseleo
Jul 02 2016 01:42
try putting return 'returning from if'; inside your if statement to see if it actually reaches it.
Greg Duncan
@GregatGit
Jul 02 2016 01:43
@DavLiendoProgramming if( leng<res[i].length )
David Liendo
@DavLiendoProgramming
Jul 02 2016 01:43
nope
its not getting in
ooooooooooooooooh
i forgot the lenght inside the conditioooooooon
omg so blind
thanks everybody!
thanks @wiseleo @ndburrus @GregatGit
CamperBot
@camperbot
Jul 02 2016 01:44
davliendoprogramming sends brownie points to @wiseleo and @ndburrus and @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 280 | @wiseleo |http://www.freecodecamp.com/wiseleo
:cookie: 765 | @ndburrus |http://www.freecodecamp.com/ndburrus
:cookie: 647 | @gregatgit |http://www.freecodecamp.com/gregatgit
Greg Duncan
@GregatGit
Jul 02 2016 01:45
@DavLiendoProgramming are you ment to return the word or the length of the word?
David Liendo
@DavLiendoProgramming
Jul 02 2016 01:45
the length
Leonid S. Knyshov
@wiseleo
Jul 02 2016 01:45
@DavLiendoProgramming When you are done with the challenge, click the Wiki link to see other solutions and learn from that. Just don't do it before you solve it.
David Liendo
@DavLiendoProgramming
Jul 02 2016 01:46
i solved it already
what wiki link is that?
oh...
Leonid S. Knyshov
@wiseleo
Jul 02 2016 01:46
@DavLiendoProgramming At the top of your screen you will see "Map, Chat, Wiki..."
David Liendo
@DavLiendoProgramming
Jul 02 2016 01:46
two weeks and a half in here and i jsut saw the wiki link....
i jsut lost a bit of selfstime, my solution is the basic one :C
George Green
@george-fg
Jul 02 2016 01:54
Hey guys, I would love your help. Its been awhile since I did maths in high school. Does anyone have any tips on the "Factorialize a Number" task?
Santiago Gómez
@Sperkajugglite
Jul 02 2016 01:54
@george-fg use recursion
George Green
@george-fg
Jul 02 2016 01:55
@Sperkajugglite I will now google recursion
Santiago Gómez
@Sperkajugglite
Jul 02 2016 01:55
remember that IF the number is 1
1*1 = 1, so it should RETURN 1
and then ... recursion with the PREVIOUS number.
good luck :P
btw guys, im struggling with mi code, i need my sessionTime variable to change in order to use it in my function.
http://codepen.io/Sperkajugglite/pen/BzRkmk?editors=1010
it works if i assign it, but it has to be assigned by the user
Ghost
@ghost~570d03d4187bb6f0eadf12a6
Jul 02 2016 01:57
help please; my browser got stuck due to an infinite for loop , and the problem remains even if i reload the page ( i dsabled the protection by typing //noprotect in the first line in fact by curiosity).Did any one have the same problem or knows the solution ?
CamperBot
@camperbot
Jul 02 2016 01:57
no wiki entry for: please my browser got stuck due to an infinite for loop and the problem remains even if i reload the page i dsabled the protection by typing noprotect in the first line in fact by curiositydid any one have the same problem or knows the solution
Moisés Man
@moigithub
Jul 02 2016 01:57
wiki auto
CamperBot
@camperbot
Jul 02 2016 01:57

:point_right: freecodecamp disable code autorun [wiki]

Disable Code Auto Run on Free Code Camp

By default, the Free Code Camp site automatically loads and runs your last recorded solution. If you have accidentally created an infinite loop or other irrecoverable error or simply don't trust the code, you can disable code auto-run by putting the following in your URL: run=disabled

:pencil: read more about freecodecamp disable code autorun on the FCC Wiki

Santiago Gómez
@Sperkajugglite
Jul 02 2016 01:58
before the ?solution put run=disabled
happened to me once
Tarun sehgal
@FCCtarun
Jul 02 2016 01:59

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.

Statements
nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10

code:

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

return removeArray; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5,6,7,8,9,10,11,12];

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

Query: IN this code only one statement is executed at a time. It returns only one stement according to changes in the code. I want to return all at a time.
Please help how can I do that

Norvin Burrus
@ndburrus
Jul 02 2016 01:59
@abdel-dreamer this may be helpful:
  • FreeCodeCamp/FreeCodeCamp#6578
@FCCtarun identify which mthods you'd like to use...
Greg Duncan
@GregatGit
Jul 02 2016 02:02
@FCCtarun make sure you format your chat -
help format
CamperBot
@camperbot
Jul 02 2016 02:02

: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

James S.
@Mrblue27
Jul 02 2016 02:04

@ndburrus I tried this and still no luck

function nextInLine(arr, item) {
// Your code here
array = [];
array.shift(arr);
array.push(item);

return item; // Change this line
}
console.log(nextInLine(testArr));
// Test Setup
var testArr =[1,2,3,4,5];
var testArr = ([2],1);
var testArr = ([5,6,7,8,9],1);
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

Tarun sehgal
@FCCtarun
Jul 02 2016 02:04
I have used shift method to remove first element.
But when I had to remove second element in array according to statement that time I had used simple
var removeArray = testArr[1];
buckshot307
@buckshot307
Jul 02 2016 02:05
is there a way to count how many objects come through a $.ajaxSuccess() function and number them?
Norvin Burrus
@ndburrus
Jul 02 2016 02:05
@Mrblue27 you may want to perform the operations in the order given (in the instructions)... a) Add the number to the end of the array, , then b) remove the first element of array
James S.
@Mrblue27
Jul 02 2016 02:06
@ndburrus hmm? I don't understand
Ghost
@ghost~570d03d4187bb6f0eadf12a6
Jul 02 2016 02:07
thanks a lot @Sperkajugglite that helps
CamperBot
@camperbot
Jul 02 2016 02:07
abdel-dreamer sends brownie points to @sperkajugglite :sparkles: :thumbsup: :sparkles:
:cookie: 302 | @sperkajugglite |http://www.freecodecamp.com/sperkajugglite
Tarun sehgal
@FCCtarun
Jul 02 2016 02:08

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

  return removeArray;  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5,6,7,8,9,10,11,12];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
var removeArray = testArr[1];
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Norvin Burrus
@ndburrus
Jul 02 2016 02:09
Greg Duncan
@GregatGit
Jul 02 2016 02:09
@Sperkajugglite you should post in help frontend - why do you need interval to change?
Ray
@rbjr
Jul 02 2016 02:09
help
CamperBot
@camperbot
Jul 02 2016 02:09

CamperBot

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. e.g. find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • Algorithm BONFIRENAME info on a Algorithm

meet CamperBot in FreeCodeCamp/camperbotPlayground

:pencil: read more about camperbot on the FCC Wiki

Ray
@rbjr
Jul 02 2016 02:10
help sum all numbers i a range
CamperBot
@camperbot
Jul 02 2016 02:10
no wiki entry for: sum all numbers i a range
Ray
@rbjr
Jul 02 2016 02:10
help sum all numbers in a range
CamperBot
@camperbot
Jul 02 2016 02:10

:point_right: algorithm sum all numbers in a range [wiki]

Algorithm Sum All Numbers in a Range

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

:checkered_flag: Problem Explanation:

You need to create a program that will take an array of two numbers who are not necessarily in order, and then add not just those numbers but any numbers in between. For example, [3,1] will be the same as 1+2+3 and not just 3+1

:pencil: read more about algorithm sum all numbers in a range on the FCC Wiki

Norvin Burrus
@ndburrus
Jul 02 2016 02:11
@rbjr you might like the camperbotPlayground :fast_forward:
gerome
@geginho
Jul 02 2016 02:11
Hi guys, i’m getting an issue revealed by jshint with this function
‘''function() {
// JavaScript to be fired on all pages
    // Animation menu overlay
    var open = $('.trigger-overlay');
    var close = $('.overlay-close');
    var menucel = $('.menu-cel');
    var listItem = $('.menu-cel ul li');
    var tl = new TimelineMax({paused:true});

        tl
          .to(menucel, 0.3, {autoAlpha:1, ease: Power1.easeOut})
          .from(listItem, 0.3, { opacity:0, x:+15, ease: Power1.easeOut});

          tl.reversed(true);

          function toggleDirection(){
          tl.reversed() ? tl.play() :
          tl.reverse();
          }

          open.click(function()
          {
            toggleDirection();
          });’''
it gives me a "Expected an assignment or function call and instead saw an expression.” message for thepart “
‘''function toggleDirection(){
tl.reversed() ? tl.play() :
tl.reverse();
}’''
Leonid S. Knyshov
@wiseleo
Jul 02 2016 02:17
@geginho That's one messy function. Is t1.reversed actually a method or is it a property?
gerome
@geginho
Jul 02 2016 02:18
Hi Leonid
Leonid S. Knyshov
@wiseleo
Jul 02 2016 02:18
@geginho Set this up in a codepen. too much code for the chat room
gerome
@geginho
Jul 02 2016 02:18
ok
Greg Duncan
@GregatGit
Jul 02 2016 02:19
@Sperkajugglite Your code is well laid out and easy to read - but you have made the timer process to complicated. All you have to do is have seconds and minutes - every and every time time seconds === -1 or 0 (however you choose to set it up) then minutes -1 and seconds = 59.
gerome
@geginho
Jul 02 2016 02:25
@wiseleo you can find the same function in this pen… http://codepen.io/rhernando/pen/uLGgm
@wiseleo it seems working but jshint gives me this error message and I would like to understand. It points to the
‘''function toggleDirection(){
tl.reversed() ? tl.play() :
tl.reverse();
}’''
Leonid S. Knyshov
@wiseleo
Jul 02 2016 02:31
@geginho I'd prefer to see your actual code, in full, in one pen if it's not too much trouble.
James S.
@Mrblue27
Jul 02 2016 02:32
@FCCtarun were you able to solve that code
gerome
@geginho
Jul 02 2016 02:33
@wiseleo ok, it will be my fist pen…. ;-)
ranranking
@ranranking
Jul 02 2016 02:56

Excuse me. I have a question. My code looks like this:

var exp = /aa/gi;

  var ret = [];

  var test = ['aaa', 'aaa', 'aaa', 'aaa', 'aaa', 'aaa'];

  for (var j = 0; j < test.length; j++) {

    ret.push(exp.test(test[1]));

  }

  return ret;

However, instead of return [true, true, true, true, true, true] it returns [true, flase, true, false, true, false]. I don't understand why!

Ariel
@ArielLeslie
Jul 02 2016 02:58
This message was deleted
MegatronCoder
@megashrieks
Jul 02 2016 02:58
Hello world!!
CamperBot
@camperbot
Jul 02 2016 02:58

welcome to FreeCodeCamp @megashrieks!

MegatronCoder
@megashrieks
Jul 02 2016 02:59
Thank you for having me
Leonid S. Knyshov
@wiseleo
Jul 02 2016 03:01
@ranranking Interesting... Not sure why.
Mustafijur rahman
@Dinar717
Jul 02 2016 03:02
@ranranking you should give test[j]
in push line
ranranking
@ranranking
Jul 02 2016 03:04
@Dinar717 I did, but nothing changed, than I changed to a fixed value, still the same result. I don't know what's wrong
Mustafijur rahman
@Dinar717
Jul 02 2016 03:08
about @ranranking
CamperBot
@camperbot
Jul 02 2016 03:08
:cookie: 288 | @ranranking |http://www.freecodecamp.com/ranranking
Sam
@alakasam
Jul 02 2016 03:08
This message was deleted
Mustafijur rahman
@Dinar717
Jul 02 2016 03:08
Is test and exp a function?
Sam
@alakasam
Jul 02 2016 03:09
Hey guys, for Falsy Bouncer, why does my code pass, even when I didn't check for NaN?

function bouncer(arr) {

  var newArray = arr.filter(function(val) {
    if ( val ===0 || val==="" || val ===false || val===undefined)
      return false;
    else return val;}                   );

  return newArray;
}

bouncer(["a", "b", "c"]);
ranranking
@ranranking
Jul 02 2016 03:11
@Dinar717 no, test is an array, and exp is a regular expression
DJ
@qualitymanifest
Jul 02 2016 03:12
@alakasam because else return val returns true or false depending on if val is truthy or falsey. NaN is falsy, so returns false and gets filtered out
@alakasam in fact, you could delete your if statement and just return val
Gregory Orton
@ortonomy
Jul 02 2016 03:13
anybody around?
for a JS question
Matt
@TheeMattOliver
Jul 02 2016 03:14
what are you working on @geligelu?
Sam
@alakasam
Jul 02 2016 03:14
@qualitymanifest if NaN is automatically falsy, does that mean that NaN is redundant? would my code still be correct?
Gregory Orton
@ortonomy
Jul 02 2016 03:14
@TheeMattOliver
interested to know why the return statement for a function is written like this:
return (new Date(Date.UTC(dateStr[0], dateStr[1] - 1, dateStr[2])));
DJ
@qualitymanifest
Jul 02 2016 03:14
@alakasam i'm not sure what you're asking
Gregory Orton
@ortonomy
Jul 02 2016 03:15
Why is the constructor call in parentheses
as far as I can tell there is no need for this
Jonathon Lopez
@JonathonLLopez
Jul 02 2016 03:15

// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
I haven't logged on in a while, and I'm a little rusty so I was hoping someone could help me with this

Directions are as follows:

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

For the given id in collection:

If prop does not contain the key "tracks", then update or set the value for that incomplete prop.

If prop does not contain the key "tracks" before you update it, create an empty array before pushing a track to it.

If prop does contain the key "tracks" and its value is non-blank, then push the value onto the end of its existing tracks array.

If value is blank, delete that prop.

Always return the entire collection object.

Matt
@TheeMattOliver
Jul 02 2016 03:16
hmmm, I'm not really sure, but could it have something to do with the fact that the UTC is a function working on "Date" and youre passing it arguments?
something like (!isNan(theNumber)) or callback(collection[i])?
Sam
@alakasam
Jul 02 2016 03:17
@qualitymanifest well the challenge asked me to filter out NaN - i did so, accidentally... does it matter if I don't filter NaN out explicitly?
DJ
@qualitymanifest
Jul 02 2016 03:18
@alakasam the code works, so no, it doesn't matter. it would however be good for you to try to get a grasp on why it works
Gregory Orton
@ortonomy
Jul 02 2016 03:19
@TheeMattOliver - perhaps
Sam
@alakasam
Jul 02 2016 03:20
@qualitymanifest I'm assuming it works because NaN is automatically false - i wouldn't have to explicitly include it as a result, since only values that are not false, are returned. would that be correct?
Dylan
@dhcodes
Jul 02 2016 03:21
@JonathonLLopez maybe revisit the challenges regarding objects
but ultimately, I would start by writing if statements that satisfy their criteria.
Z.G.Hao
@akidox
Jul 02 2016 03:23
return findLongestWord(str.slice(1,str.length).join(" "));
Found this in FFC’s wiki page,how dose the use of slice method make sense?
DJ
@qualitymanifest
Jul 02 2016 03:23
@alakasam essentially yes. they're falsy and the filter function evaluates them as false and throws them away
Z.G.Hao
@akidox
Jul 02 2016 03:24
Woundn’t it be slice(1, str.length - 1)?
Sam
@alakasam
Jul 02 2016 03:24
thanks so so much! @qualitymanifest
CamperBot
@camperbot
Jul 02 2016 03:24
alakasam sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1237 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Jul 02 2016 03:25
np
Bnobo
@acloud12345678
Jul 02 2016 03:30
How do you use arrays?
Palakurthi Durga Kiran Kumar
@durgakiran
Jul 02 2016 03:30
I didn't understand this world banks in javascript
Matt
@TheeMattOliver
Jul 02 2016 03:31
@acloud12345678 an array is just a type of collection you use to store data inside of
like [1,2,3,4,5] is an array that contains the numbers 1 through 5
or ["chicken", "pork", "beef", "shrimp", "fish"] is an array that contains the names of types of food
you can manipulate arrays and use them in all kinds of different ways in JS
var arr = [
    "hello world",
    42,
    true
];

arr[0];         // "hello world"
arr[1];         // 42
arr[2];         // true
arr.length;     // 3

typeof arr;     // "object"
Manny
@Alloffices
Jul 02 2016 03:34
how do you create a new line in terminal with node
Matt
@TheeMattOliver
Jul 02 2016 03:35
@durgakiran the point of that exercise is to concatenate together several strings in a little story you're going to tell with variables
Bnobo
@acloud12345678
Jul 02 2016 03:36
@Matt
thanks
Daniel Cartín
@Danielcv93
Jul 02 2016 03:37
wanna take a look for some feedback?
I'll be really thankfull
Bnobo
@acloud12345678
Jul 02 2016 03:38
Matt
edison sim
@Edisonsim
Jul 02 2016 03:41
Hi, im new to javascript any tips for me?
Bnobo
@acloud12345678
Jul 02 2016 03:43
How do you program a Method that returns an array that contains the numbers from 'start' to 'finish', inclusive?
@TheeMattOliver thanks for your help
CamperBot
@camperbot
Jul 02 2016 03:44
acloud12345678 sends brownie points to @theemattoliver :sparkles: :thumbsup: :sparkles:
:cookie: 298 | @theemattoliver |http://www.freecodecamp.com/theemattoliver
Sam
@alakasam
Jul 02 2016 03:46
Hey @acloud12345678 , try checking out slice(), substr(), or substring() methods?
Markus Kiili
@Masd925
Jul 02 2016 03:46
@acloud12345678 For loop can be used.
ranranking
@ranranking
Jul 02 2016 03:46
How do I interpret this regular expression: /(.)\1+/ ? How does that mean repeated character?
Bnobo
@acloud12345678
Jul 02 2016 03:46
@alakasam @Masd925
I still don’t understand
Palakurthi Durga Kiran Kumar
@durgakiran
Jul 02 2016 03:49
This message was deleted
This message was deleted
i stuck someone plz help
Palakurthi Durga Kiran Kumar
@durgakiran
Jul 02 2016 03:50

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

// Your code above this line
return result;
}

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

still didn't get it
cannelflow
@cannelflow
Jul 02 2016 03:53
can anyone tell me why my background color is not changing when button clicked https://jsfiddle.net/cannelflow/j0yhytcw/
Christopher Brashear
@CBrashear
Jul 02 2016 03:54
@durgakiran you're quoting variables
romaisa
@romi012
Jul 02 2016 03:55
@durgakiran send me ur code link
Sam
@alakasam
Jul 02 2016 03:55
@acloud12345678 for the simplest method, you can use a for loop, as @Masd925 suggested...
use a for loop, then push each element into an array that you created before the for loop
Logan Klein
@Lkleindesigns
Jul 02 2016 03:57

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

result += "His "+myAdjective+" "+myNoun+" "+myVerb+" very "+myAdverb+".";

// Your code above this line
return result;
}

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

romaisa
@romi012
Jul 02 2016 03:57
@durgakiran u have to write code like this
result = myNoun + " glued with " + myAdjective + " road " + myVerb + " very "+ myAdverb;
Logan Klein
@Lkleindesigns
Jul 02 2016 03:58
@romi012 Can you explain how the function is determing which strings are associated with noun adjective verb adverb?
stefan-kenyon
@stefan-kenyon
Jul 02 2016 03:58
This message was deleted
Logan Klein
@Lkleindesigns
Jul 02 2016 03:59
or anyone for that matter im reviewing and trying to understand how the word dog is associated with myNoun in the provided code
romaisa
@romi012
Jul 02 2016 03:59
@Lkleindesigns we provided words in a function argument and concatenate with our string simple
Sam
@alakasam
Jul 02 2016 03:59
@Lkleindesigns Look at the arguments in wordBlanks - the first argument, "dog", is passed on as myNoun
stefan-kenyon
@stefan-kenyon
Jul 02 2016 04:00

Hello, I need some help with one of the exercises. Specifically the record collection activity.

One of the directions are "If prop does not contain the key "tracks", then update or set the value for that incomplete prop."

My function is
function updateRecords(id, prop, value)
{
if(prop != "tracks")
{
collection.id = prop;
collection.id.prop = value;
}

return collection;
}

And the output is "TypeError: Cannot create property 'prop' on string 'artist'"

Any help would be appreciated. I am not super sure what they want me to do for this exercise.

Logan Klein
@Lkleindesigns
Jul 02 2016 04:00
so it just goes in order
got it thanks
romaisa
@romi012
Jul 02 2016 04:01
myNoun is basically a function argument and when we call our function we pass dog which become the value of myNoun
got it?
Logan Klein
@Lkleindesigns
Jul 02 2016 04:02
yes i think so thankyou
romaisa
@romi012
Jul 02 2016 04:02
good :smile:
Sam
@alakasam
Jul 02 2016 04:02

for Seek and Destroy, how do I pass in the 2nd,3rd, nth, argument automatically?

function destroyer(arr) {
  // Remove all the values
  return arr;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);

I can manually change function destroyer(arr) to function destroyer(arr,1,2), but there has to be away to automatically set the number of arguments passed on..

someone plz help me to figure this out
Sam
@alakasam
Jul 02 2016 04:06
@romi012 You can use an if function if (value >=2 && value <=6 for the first condition, and so on
if (value >=2 && value <=6)*
then add or subtract a set value if such condition is matched
Shola Abaogun
@codephoo
Jul 02 2016 04:07
@stefan-kenyon maybe you should use []
romaisa
@romi012
Jul 02 2016 04:07
@alakasam ok trying
Shola Abaogun
@codephoo
Jul 02 2016 04:08
like collection[id][prop]
Leonid S. Knyshov
@wiseleo
Jul 02 2016 04:13
romaisa
@romi012
Jul 02 2016 04:18
@alakasam just look at this
last two errors :worried:
sigursiguros
@sigursiguros
Jul 02 2016 04:20
Hi guys, I'm having trouble with my code as the orbitalPeriod is returning null. Would you mind giving help?

function orbitalPeriod(arr) {
  var GM = 398600.4418;
  var earthRadius = 6367.4447;
  var OP = Math.sqrt(Math.pow((arr.avgAlt + earthRadius),3)/GM);
  arr.pop();
  arr.push({name: "sputnik", orbitalPeriod: OP});
  return arr;
}

orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);
Sam
@alakasam
Jul 02 2016 04:21
ooh thanks @wiseleo i just discovered this - works perfectly!
CamperBot
@camperbot
Jul 02 2016 04:21
alakasam sends brownie points to @wiseleo :sparkles: :thumbsup: :sparkles:
:cookie: 281 | @wiseleo |http://www.freecodecamp.com/wiseleo
Sam
@alakasam
Jul 02 2016 04:21
@romi012 unfortunately, links are user-specific i'm not sure what you want me to look at
James S.
@Mrblue27
Jul 02 2016 04:22
has anyone made it pass step 194 the Stand in Line. Help would be greatly appreciated
Nick Neuman
@neecholaus
Jul 02 2016 04:22
hey could someone help me with the record collection exercise? I am completely lost i have gone through every other exercise i can think of that relates and ive looked things up, but i cant figure it out. can someone just like point me in the right direction?
@alakasam now?
Nick Neuman
@neecholaus
Jul 02 2016 04:24
@Mrblue27 i have what do you need?
Sam
@alakasam
Jul 02 2016 04:24
@romi012 can you copy and paste it into gitter?
romaisa
@romi012
Jul 02 2016 04:24

var count = 0;

function cc(card) {
// Only change code below this line
if(card>=2&&card<=6){
++count;
return count+" Bet";
}
else if(card>=7&&card<=9){
count=0;
return count+" Hold";
}

else
return --count+" Hold";

}

// Only change code above this line

i didnt get these errors @alakasam
James S.
@Mrblue27
Jul 02 2016 04:28

@neecholaus a breakdown this is what I have so far

function nextInLine(arr, item) {
// Your code here
function nextInLine(arr, item)
{ var firstItem = arr.shift = (arr);
arr.shift(arr);
arr.push();

}

return removeArr;

// Change this line
}
console.log(testArr);
// 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));

Faisal Zulfiqar
@faisal1337
Jul 02 2016 04:31
I am JS challenge 230. That is Lookup Profile. I made this function but it is not working. Can some one point out what I am doing wrong?
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i <= 3; i++) {
if (contacts[i].hasOwnProperty(firstName) && contacts[i].hasOwnProperty(prop)) {
return contacts[i].likes;
}
if (!contacts[i].hasOwnProperty(firstName)) {
return "No such Contact";
}
if (!contacts[i].hasOwnProperty(prop)) {
return "No such property";
}
}
// Only change code above this line
}
Nick Neuman
@neecholaus
Jul 02 2016 04:32

@Mrblue27 so idk what the first line in your function is supposed to be, but mine is just arr.push(item) and that pushes the item value onto the end of the array, and then i have var removed = shift(); on the next line after that which removes the fist value. then just return removed after that.

```js

Leonid S. Knyshov
@wiseleo
Jul 02 2016 04:32
for @faisal1337 @Mrblue27 - bot will tell you how to paste code with source highlighting.
help format
CamperBot
@camperbot
Jul 02 2016 04:32

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Nick Neuman
@neecholaus
Jul 02 2016 04:32
function nextInLine(arr, item) {
  arr.push(item);
  var removed = arr.shift();// Your code here

  return removed;  // 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));
@Mrblue27
Sam
@alakasam
Jul 02 2016 04:33
@romi012 You have to return the count after ever card has been counted
Juan Moraza
@Morazajuan
Jul 02 2016 04:33
how do i add a property inside an object with multiple id's?

// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }

};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

if(id === collection.id){
 collection.id.prop= value;
}else{
 collection.id.prop= value;
}
  return collection;
}

var trackObj= "tracks";
var trackName= collection[trackObj];

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

console.log(trackObj);
i tried this
 collection.id.prop= value;
but didnt work
Sam
@alakasam
Jul 02 2016 04:34
@romi012 After every counting if, you need to change the count, but not return anything yet
Faisal Zulfiqar
@faisal1337
Jul 02 2016 04:34

So. I am JS challenge 230. That is Lookup Profile. I made this function but it is not working. Can some one point out what I am doing wrong?
The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

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

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

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

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

Didn't work :smirk:
James S.
@Mrblue27
Jul 02 2016 04:35
@neecholaus ok thats a start I now have two areas checked off
Joseph
@revisualize
Jul 02 2016 04:35
@Morazajuan Lots of issues.
romaisa
@romi012
Jul 02 2016 04:36
@alakasam ll u plz send me your code :worried:
Nick Neuman
@neecholaus
Jul 02 2016 04:37
@Mrblue27 did it not fulfill all the requirements?
Joseph
@revisualize
Jul 02 2016 04:37
@Morazajuan You're using dot notation and not bracket notation. Dot Notation is a string literal.
myObj.name; is the same as myObj["name"]; notice a string?
Whereas, myObj[name]; is the representation of var name;
@faisal1337 Your loop is only looping once.
Juan Moraza
@Morazajuan
Jul 02 2016 04:37
okay i see that
@revisualize let me change that
James S.
@Mrblue27
Jul 02 2016 04:38

@neecholaus no just the middle two

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

var removed =arr.shift();
return removed; // 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));

Joseph
@revisualize
Jul 02 2016 04:38
@Morazajuan There is a lot more.
@Morazajuan Let me get you some different text for that lesson.
Juan Moraza
@Morazajuan
Jul 02 2016 04:38
Lol it was added! Thanks alot @revisualize
CamperBot
@camperbot
Jul 02 2016 04:38
morazajuan sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1357 | @revisualize |http://www.freecodecamp.com/revisualize
Juan Moraza
@Morazajuan
Jul 02 2016 04:39

// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }

};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

if(id === collection[id]){
 collection[id][prop]= value;
}else{
 collection[id][prop]= value;
}
  return collection;
}

var trackObj= "tracks";
var trackName= collection[trackObj];

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

console.log(trackObj);
Nick Neuman
@neecholaus
Jul 02 2016 04:39
@Mrblue27 in the function you have to put arr.push(item) instead of just arr.push()
Vibhavmishra
@Vibhavmishra
Jul 02 2016 04:39
can anyone tell me whats difference between json and object?
Joseph
@revisualize
Jul 02 2016 04:39
@Morazajuan We don't need the object to be pasted into chat. (It takes up too much room.)

@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.

@Vibhavmishra The difference between JavaScript Object Notation and Object?
@Vibhavmishra Here.. Let me..
James S.
@Mrblue27
Jul 02 2016 04:41
@neecholaus Oh man thank you thank you you don't know how long and how many circles I been going in
CamperBot
@camperbot
Jul 02 2016 04:41
mrblue27 sends brownie points to @neecholaus :sparkles: :thumbsup: :sparkles:
:cookie: 214 | @neecholaus |http://www.freecodecamp.com/neecholaus
Nick Neuman
@neecholaus
Jul 02 2016 04:42
@Mrblue27 yeah man no problem
Sam
@alakasam
Jul 02 2016 04:42
@romi012 see my PM
Juan Moraza
@Morazajuan
Jul 02 2016 04:44
okay @revisualize but do you know whats wrong with my if statement? it suppose to run the first condition but instead runs the else one
```
if(id === collection.id){
 collection[id][prop]= value;
}else{
 collection[id][prop]= value;
}
just for the record i know they do the same thing but i just was checking if the prop was added
Joseph
@revisualize
Jul 02 2016 04:45
@Morazajuan That statement isn't correct.
@Morazajuan Your evaluation is incorrect.
Juan Moraza
@Morazajuan
Jul 02 2016 04:46
you said not to paste the object into the chat, i pasted the if statement
Joseph
@revisualize
Jul 02 2016 04:46
@Morazajuan I know.
Juan Moraza
@Morazajuan
Jul 02 2016 04:47
Joseph
@revisualize
Jul 02 2016 04:47
@Morazajuan Nothing that I said changes.
@Morazajuan Is my verbiage not coming across clearly?
(id === collection.id)
That line or a line like it is no where in the description text.
Also, you're still using dot notation. But, we'll ignore that.
@Morazajuan This: collection[id][prop]= value; does need to be used in your code somewhere.
Taylor
@TyMx
Jul 02 2016 04:50
Hi, I was wondering if anyone can help me with challenge 155. I can't understand what it wants me to do with the escape sequences and the spacing.
var myStr = "Here is a backslash: \.\n \t\t Here is a new line with two tabs.";
Joseph
@revisualize
Jul 02 2016 04:50
var myStr = "Here is a backslash: \\.\n \t\t Here is a new line with two tabs.";
You have an extra space between \t H
and. \n \t
@TyMx per the instructions:
myStr should not have any spaces in between consecutive escape sequences.
Juan Moraza
@Morazajuan
Jul 02 2016 04:52
okay @revisualize
if(prop === collection[id][prop])
what about now?
Joseph
@revisualize
Jul 02 2016 04:52
@Morazajuan
If prop isn't "tracks" and value isn't blank, update or set the value for that record album's property.
Taylor
@TyMx
Jul 02 2016 04:53
@revisualize ok now I understand. Thank you very much!
CamperBot
@camperbot
Jul 02 2016 04:53
tymx sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1358 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jul 02 2016 04:53
@Morazajuan Can you write that if statement out?
Juan Moraza
@Morazajuan
Jul 02 2016 04:55
if(prop !== collection[id]["tracks"]){
?
@revisualize
Joseph
@revisualize
Jul 02 2016 04:55
@Morazajuan
If prop isn't "tracks" and value isn't blank
if prop !== "tracks" && value !== ""
Juan Moraza
@Morazajuan
Jul 02 2016 04:57
if(prop !== "tracks" && prop!== ""){
wait!
if(prop !== "tracks" && value!== ""){
Joseph
@revisualize
Jul 02 2016 04:57
YAY!
Juan Moraza
@Morazajuan
Jul 02 2016 04:57
lol
Joseph
@revisualize
Jul 02 2016 04:58
Now... Add the part where..
update or set the value for that record album's property.
@Morazajuan Slow down and don't over complicate things.

@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.

@Morazajuan If you slow down and read the text... It actually starts to write itself.
Juan Moraza
@Morazajuan
Jul 02 2016 05:00
wait but i have a question, i see you comapered prop with tracks and value with the track name as the program knew where to find them. dont you have to compared them something like "collection[id][prop][value?]"
@revisualize
Joseph
@revisualize
Jul 02 2016 05:01
No.
Juan Moraza
@Morazajuan
Jul 02 2016 05:02
so the parameters are base on the structure of the object then? @revisualize
Joseph
@revisualize
Jul 02 2016 05:02
I don't know what you mean.
The parameters are passed into the function.
Jonathon Lopez
@JonathonLLopez
Jul 02 2016 05:03

// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
I need help with this if anyone is willing
Oh wait, I see it's already being discussed
Joseph
@revisualize
Jul 02 2016 05:04

@JonathonLLopez Try using this for the lesson description:

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.

sigursiguros
@sigursiguros
Jul 02 2016 05:04
does anyone here know what's the difference between indexOf(a) and indexOf(+a)
somehow one of those worked in my code
and I don't understand the difference
Juan Moraza
@Morazajuan
Jul 02 2016 05:05
like you know how in our function we have three parameters "id,prop,value" and inside our object (collection) we first have the id(1245) then inside we ave the property(artist), then we have the value whcih is "Robert..." does that mean when we use the if statement we dont have to go through all the order as when we want to check for properties?
@revisualize
Joseph
@revisualize
Jul 02 2016 05:05
@Morazajuan You don't.
Juan Moraza
@Morazajuan
Jul 02 2016 05:06
that means when we compare prop to something that is already going through all the props in each id?
Joseph
@revisualize
Jul 02 2016 05:06

@Morazajuan Look at:

    5439: {
      album: "ABBA Gold"
    }

updateRecords(5439, "artist", "ABBA");
That function call should make the object become:

    5439: {
      artist: "ABBA",
      album: "ABBA Gold"
    }
Juan Moraza
@Morazajuan
Jul 02 2016 05:07
that means when we compare prop to something that is already going through all the props in each id? @revisualize
okay im a little confuse when you say the object become you mean the id object right
?
@revisualize
Joseph
@revisualize
Jul 02 2016 05:08
Honestly, I don't understand what you mean by that text.
@Morazajuan This:
5439: {
artist: "ABBA",
album: "ABBA Gold"
}
is an object.
It is an object inside of the collection object.
Just like.. You can have arrays inside of arrays.
Juan Moraza
@Morazajuan
Jul 02 2016 05:09
oooooh!
Joseph
@revisualize
Jul 02 2016 05:09
var arr = [["a1"], ["b2","c2"], ["d3","e3","f3"], ["g4","h4","i4","k4"]];
Juan Moraza
@Morazajuan
Jul 02 2016 05:09
that makes a lot more sense!
so what is the diffrence between property and ids?
Joseph
@revisualize
Jul 02 2016 05:10
id is a variable representation of the collection keys.
Juan Moraza
@Morazajuan
Jul 02 2016 05:10
so an object can also be an id?
when is inside an object obviously

@Morazajuan remember when you made this: (or something like it)

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

You defined the object keys.
Instead the collection object has it's keys as the param id (which are numbers)

Joseph
@revisualize
Jul 02 2016 05:17
WOW! Look at the time.. 10:17pm
Juan Moraza
@Morazajuan
Jul 02 2016 05:18
lol at my location is 12:17
pm
am
Hassaan Hafeez
@HassHz
Jul 02 2016 05:18
var collection = { //collection
    "2548": { //collection[id]
      "album": "Slippery When Wet", collection[id][prop]
      "artist": "Bon Jovi", //collection[id][prop]
      "tracks": [  //collection[id][prop]
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
Jonathon Lopez
@JonathonLLopez
Jul 02 2016 05:18

@revisualize can you explain this portion?

"If prop does not contain the key "tracks" before you update it, create an empty array before pushing a track to it."

Joseph
@revisualize
Jul 02 2016 05:20

@JonathonLLopez

    5439: {
      album: "ABBA Gold"
    }

You need to create an empty array before you can push to it. ... Hint: Testing Objects for Properties

@JonathonLLopez If you try to push to an array and it doesn't exist. You get a big fat error.
Jonathon Lopez
@JonathonLLopez
Jul 02 2016 05:22
@revisualize so it's asking to me create a checkProp function before the the updateRecords function?
Joseph
@revisualize
Jul 02 2016 05:22
@JonathonLLopez No.
Leonid S. Knyshov
@wiseleo
Jul 02 2016 05:22
This message was deleted
Joseph
@revisualize
Jul 02 2016 05:23
@wiseleo Well, just give everyone the answer.
I've already pasted the new description text 3 times. In the last 40 minutes.
Jonathon Lopez
@JonathonLLopez
Jul 02 2016 05:23
I actually think I can figure it out, but I just need to better understand each section of the instructions
Joseph
@revisualize
Jul 02 2016 05:24
@JonathonLLopez What does that lesson teach you to use?
Leonid S. Knyshov
@wiseleo
Jul 02 2016 05:24
laugh OK let's have it the hard way
Joseph
@revisualize
Jul 02 2016 05:24
@JonathonLLopez *cough* .hasOwnProperty()
Jonathon Lopez
@JonathonLLopez
Jul 02 2016 05:24
@revisualize the hasOwnProperty method
yeah that, lol
Joseph
@revisualize
Jul 02 2016 05:25
YAY!
Jonathon Lopez
@JonathonLLopez
Jul 02 2016 05:25
@revisualize but what I'm asking is, that's basically going to start the updateRecords function?
Joseph
@revisualize
Jul 02 2016 05:26
Depends on how you want to write your function's if / else if / nested if statements.
Jonathon Lopez
@JonathonLLopez
Jul 02 2016 05:26
@revisualize I see. It does say to create an empty array before I update, so by that logic, it needs to run first
Joseph
@revisualize
Jul 02 2016 05:27
@JonathonLLopez It needs to run before you push.
edison sim
@Edisonsim
Jul 02 2016 05:27
Hi guys, i try putting <script type="text/javscript" src="tic-tac.js"><script> in my html but it seem like there error at atom
Joseph
@revisualize
Jul 02 2016 05:28

@JonathonLLopez

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.

Leonid S. Knyshov
@wiseleo
Jul 02 2016 05:29
@Edisonsim you don't need type= and you should close it with </script>
Joseph
@revisualize
Jul 02 2016 05:29

Seriously, This text is WAY better than the current instructions:

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.

Leonid S. Knyshov
@wiseleo
Jul 02 2016 05:30
Thanks, I wrote it. @revisualize
CamperBot
@camperbot
Jul 02 2016 05:30
wiseleo sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1359 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jul 02 2016 05:31
@wiseleo Oh, that's your username right above where I copied it from? :P
Leonid S. Knyshov
@wiseleo
Jul 02 2016 05:31
Yep
edison sim
@Edisonsim
Jul 02 2016 05:32
@wiseleo still doesnt work
Screen Shot 2016-07-02 at 1.31.04 PM.png
Joseph
@revisualize
Jul 02 2016 05:32
@Edisonsim you're not ending your script.
@Edisonsim you need to </script>
Jonathon Lopez
@JonathonLLopez
Jul 02 2016 05:33
if(prop !== "tracks") {
   if (collection.hasOwnProperty("tracks")) {
    return collection[];
this is probably wrong, but it's the start so far
edison sim
@Edisonsim
Jul 02 2016 05:33
Thanks @JonathonLLopez 1 small mistake make my brain freeze
CamperBot
@camperbot
Jul 02 2016 05:33
edisonsim sends brownie points to @jonathonllopez :sparkles: :thumbsup: :sparkles:
:cookie: 275 | @jonathonllopez |http://www.freecodecamp.com/jonathonllopez
Joseph
@revisualize
Jul 02 2016 05:33
@JonathonLLopez That's an okay start but, you're missing stuff and it should be === not the !==
clintonjohn
@clintonjohn
Jul 02 2016 05:34

Trying to generate. A random whole number
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

// Only change code below this line.

Math.floor(Math.random() * 10);
}

BuntyBru
@BuntyBru
Jul 02 2016 05:34
i am not able to pass the Counting cards assignment
please help
Joseph
@revisualize
Jul 02 2016 05:34
I'm going to go play some :8ball:
:v:
clintonjohn
@clintonjohn
Jul 02 2016 05:34
Between 1 and 10
0-9 i
mean
Nick Neuman
@neecholaus
Jul 02 2016 05:35
@revisualize okay so heres what i have. its adding the tracks value when there is no prop titled "tracks", but it isnt pushing the value onto id's that already have the prop "tracks".
function updateRecords(id, prop, value) {
  if (prop !== "tracks" && value !== "") {
    collection[id][prop] = value;
  } else if (value === "") {
    delete collection[id][prop];
  } else if (prop === "tracks" && value !== "") {
      if (collection[id].hasOwnProperty([prop])) {
      collection[id][prop].push([value]);
      } else {
        collection[id][prop] = [value];
      }

  }
  return collection;
}
clintonjohn
@clintonjohn
Jul 02 2016 05:36
any hints?
Jack Lyons
@JackEdwardLyons
Jul 02 2016 05:36
hey guys i have a bonfire questions
how wouldi go about finding the index of not just one letter, but a set of vowels, in a word.. so if the word was "hello" i want to search through an array of vowels and locate the indexOf the first vowel
var vowels = ["a", "e", "i", "o", "u"];

  var firstVowel = str.indexOf(vowels);
how doi do indexOf for multiple strings
Joseph
@revisualize
Jul 02 2016 05:38
@neecholaus try changing the nested if logic.
@neecholaus OH! Wait.
Nick Neuman
@neecholaus
Jul 02 2016 05:39
@revisualize okay i figured it out i took the brackets out around value
Joseph
@revisualize
Jul 02 2016 05:39
@neecholaus .push([value]);
Yeah. That.
Nick Neuman
@neecholaus
Jul 02 2016 05:39
thank you for all your help man! @revisualize
CamperBot
@camperbot
Jul 02 2016 05:39
neecholaus sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1360 | @revisualize |http://www.freecodecamp.com/revisualize
Leonid S. Knyshov
@wiseleo
Jul 02 2016 05:40
@clintonjohn Your calculation is right, but your function isn't returning anything.
Logan Klein
@Lkleindesigns
Jul 02 2016 05:40
// Setup
var processed = 0;

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

// Only change code below this line
processed = processArg(7);
i got the answer but i dont feel i understand exactly how it is working
someone help
please
Kevin
@KevinBruland
Jul 02 2016 05:41
@Lkleindesigns sure, are you confused about the whole thing?
Logan Klein
@Lkleindesigns
Jul 02 2016 05:42
pretty much
Kevin
@KevinBruland
Jul 02 2016 05:42
@Lkleindesigns OK, at the top where var processed = 0;, that is called declaring the variable... youre basically just saying it exists and its a number
@Lkleindesigns afterwards, youre creating a function called "processArg", and that function takes in 1 value when called, which in this case is a number.
at the bottom you are calling (using) that function, by saying processed = what the function returns if you provide it with a 7
so when you call it with the number 7 (the argument), it runs the whole function, but where it says "num", that becomes a 7
Logan Klein
@Lkleindesigns
Jul 02 2016 05:45
is there a reason why it is setup as a global variable? @Benalron
Kevin
@KevinBruland
Jul 02 2016 05:46
return ends the function and sends out whatever is after it... so when you say return (num + 3) / 5;, you are saying send out the number (7 + 3) / 5, and you get processed = 2
clintonjohn
@clintonjohn
Jul 02 2016 05:46
@wiseleo I'm confused by the function names
Kevin
@KevinBruland
Jul 02 2016 05:46
well, you are assigning processed outside of the function... so if at the bottom you said processed = processArg(7), and processed was only declared inside the function, you wouldnt be able to assign it
in this case, you want processed to be accessible outside of the function, as that is where you are assigning the value
Daniel Ekwuazi
@Dcwind
Jul 02 2016 05:47
function factorialize(num) {

  var arrOfNum = [];
  var solution = 0;

  if (num === 0){
    return 1;
  }

  for(var i = 1; i <= num; i++) {
    arrOfNum.push(i);
  }

   solution = arrOfNum.reduce(function(previousVal, currentVal){
        return previousVal * currentVal;
  });
  return solution;
}

factorialize(5);
Leonid S. Knyshov
@wiseleo
Jul 02 2016 05:47
@clintonjohn OK. But that's not what the problem is. A function either returns a value or if there is no return statement returns undefined. Although your calculation is correct, your function doesn't have a return statement.
Daniel Ekwuazi
@Dcwind
Jul 02 2016 05:47
Please is there anyway I could write it better.
Leonid S. Knyshov
@wiseleo
Jul 02 2016 05:48
@Dcwind Have you looked at the solutions in the wiki? Just click Wiki at top of your screen.
Logan Klein
@Lkleindesigns
Jul 02 2016 05:48
@Benalron Thanks, that helped. Would send you karma if i knew how.
CamperBot
@camperbot
Jul 02 2016 05:48
lkleindesigns sends brownie points to @benalron :sparkles: :thumbsup: :sparkles:
:cookie: 333 | @benalron |http://www.freecodecamp.com/benalron
Kevin
@KevinBruland
Jul 02 2016 05:49
@Lkleindesigns NP, it's a bit overwhelming at first
Daniel Ekwuazi
@Dcwind
Jul 02 2016 05:50
@wiseleo didn't see it.
Sam
@alakasam
Jul 02 2016 05:52
hey guys, can anyone check for me my solution to [seek and destroy](https://www.freecodecamp.com/challenges/seek-and-destroy)?
i'm sure my code is correct, and it returns the correct arrays, but fcc doesn't seem to be marking it as a pass.

function destroyer(arr) {
  arr = [];
  for (var i=0 ; i< arguments.length; i++) {
    arr.push(arguments[i]);
  } //turned arguments into an array  
  var firstArray=arr[0];// separated first argument
  var filt =[];
  for (var j=1; j<arr.length;j++){
    filt.push(arr[j]);
  }  //filt = the arguments that you want to filter out 
    var finalArray = [];
  finalArray = firstArray.filter(function(val) {         
         for (var k=0; k<filt.length;k++){
            if (filt[k] == val)
              return false;
            }return val;
         }   
  );  
        return finalArray;
  }

destroyer([1,2,3,1,2,3],2,3);
clintonjohn
@clintonjohn
Jul 02 2016 05:52
@wiseleo thank you
CamperBot
@camperbot
Jul 02 2016 05:52
clintonjohn sends brownie points to @wiseleo :sparkles: :thumbsup: :sparkles:
:cookie: 285 | @wiseleo |http://www.freecodecamp.com/wiseleo
Will
@Will-is-Coding
Jul 02 2016 05:57
@alakasam destroyer only takes one parameter arr, yet you're giving it two.
Sam
@alakasam
Jul 02 2016 05:58
@Will-is-Coding "You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments." The intstructions say it should allow for 1+ arguments. My function also works for one, though, so that shouldn't be the problem?
Will
@Will-is-Coding
Jul 02 2016 05:59
Oh sorry misread function
Ermias GIOVANNI
@egg-develops
Jul 02 2016 06:00
I'm curious as to FCC's help forum: how does anybody get any help? It's like a jungle in here!
Sam
@alakasam
Jul 02 2016 06:00
@wiseleo Am I using the arguments object the wrong way?
Leonid S. Knyshov
@wiseleo
Jul 02 2016 06:01
@egg-develops Ask a question and get answers ;)
Will
@Will-is-Coding
Jul 02 2016 06:01
@alakasam I think you need var arguments = Array.prototype.slice.call(arguments);
Ermias GIOVANNI
@egg-develops
Jul 02 2016 06:01
I've asked questions but they got lost in the stream. Why wouldn't the help link be related to the specific section?
Kevin
@KevinBruland
Jul 02 2016 06:02
@alakasam are you positive its returning the correct answer for all of the tests on the left?
Leonid S. Knyshov
@wiseleo
Jul 02 2016 06:03
Will
@Will-is-Coding
Jul 02 2016 06:03
@alakasam You definitely need it. It is breaking your function without it, you get an infinite loop of arrays inside arrays.
Leonid S. Knyshov
@wiseleo
Jul 02 2016 06:03
@egg-develops Click on Wiki for that
Sam
@alakasam
Jul 02 2016 06:03
Hmm I just manually checked each tests, and the console on the left returned the correct answers
Daniel Ekwuazi
@Dcwind
Jul 02 2016 06:04
function factorialize(num) {
  if (num === 0) {
    return 1;
  }
  return num * factorialize (num -1);
}

factorialize(5);
Will
@Will-is-Coding
Jul 02 2016 06:04
I tested it on jsfiddle and it did not work as expected until adding var arguments = Array.prototype.slice.call(arguments);
Ermias GIOVANNI
@egg-develops
Jul 02 2016 06:04
@wiseleo Do you mean Wikipedia?
Sam
@alakasam
Jul 02 2016 06:04
Hmm that's strange, could this be a problem with my browser?
Kevin
@KevinBruland
Jul 02 2016 06:05
@alakasam I have had a couple of weird issues like that, but I don't recall it on that one speicifically
Leonid S. Knyshov
@wiseleo
Jul 02 2016 06:05
@egg-develops At the top of your challenge screen you have a navbar map chat wiki
Ermias GIOVANNI
@egg-develops
Jul 02 2016 06:06
Thank you @wiseleo that helped.
CamperBot
@camperbot
Jul 02 2016 06:06
egg-develops sends brownie points to @wiseleo :sparkles: :thumbsup: :sparkles:
:cookie: 286 | @wiseleo |http://www.freecodecamp.com/wiseleo
Daniel Ekwuazi
@Dcwind
Jul 02 2016 06:06
Thanks @wiseleo
CamperBot
@camperbot
Jul 02 2016 06:06
dcwind sends brownie points to @wiseleo :sparkles: :thumbsup: :sparkles:
:cookie: 287 | @wiseleo |http://www.freecodecamp.com/wiseleo
Sam
@alakasam
Jul 02 2016 06:08
@Will-is-Coding Do you mind explaining what exactly var arguments = Array.prototype.slice.call(arguments); does? According to mozilla, this converts arguments into an array?
Will
@Will-is-Coding
Jul 02 2016 06:11
@alakasam Right, it makes the arguments object accessible as an array. Which allows you to do that for loop you have for it, as currently it shouldn't technically work
Sam
@alakasam
Jul 02 2016 06:13
@Will-is-Coding Okay - that makes sense. I manually converted it somehow, but I'm so glad there's an actual method for doing so. thanks @Will-is-Coding !
CamperBot
@camperbot
Jul 02 2016 06:13
alakasam sends brownie points to @will-is-coding :sparkles: :thumbsup: :sparkles:
:cookie: 429 | @will-is-coding |http://www.freecodecamp.com/will-is-coding
Will
@Will-is-Coding
Jul 02 2016 06:13
Though I would rename arguments to args just so there aren't two arguments floating about
Thank @wiseleo
CamperBot
@camperbot
Jul 02 2016 06:13
will-is-coding sends brownie points to @wiseleo :sparkles: :thumbsup: :sparkles:
:cookie: 288 | @wiseleo |http://www.freecodecamp.com/wiseleo
Sam
@alakasam
Jul 02 2016 06:20
woohoo the code submits! thanks again guys!
edison sim
@Edisonsim
Jul 02 2016 06:20
I dont understand about substring
Will
@Will-is-Coding
Jul 02 2016 06:20
@alakasam Glad you got it working, woo
Nash
@saiyanka
Jul 02 2016 06:20

function ourFunction(isItTrue) {
if (isItTrue) {
return "Yes, it's true";
}
return "No, it's false";
}

// Setup
function trueOrFalse(wasThatTrue) {

// Only change code below this line.
if(wasThatTrue){
return "Yes, that was true";
}

return "No, that was false";

// Only change code above this line.

}

// Change this value to test
trueOrFalse(test);

hello
could someone tell me where i'm going wrong?
gemaderus
@gemaderus
Jul 02 2016 06:23
@saiyanka you can see in the Wiki
@saiyanka I had a mistake in this challenge too and I found the solution in the Wiki
Nash
@saiyanka
Jul 02 2016 06:24
@gemaderus where can i find said wiki
gemaderus
@gemaderus
Jul 02 2016 06:25
@saiyanka at the top of the screen, near your photo
Nash
@saiyanka
Jul 02 2016 06:26
@gemaderus thanks
CamperBot
@camperbot
Jul 02 2016 06:26
saiyanka sends brownie points to @gemaderus :sparkles: :thumbsup: :sparkles:
:cookie: 186 | @gemaderus |http://www.freecodecamp.com/gemaderus
gemaderus
@gemaderus
Jul 02 2016 06:26
@saiyanka :)
Logan Klein
@Lkleindesigns
Jul 02 2016 06:27
// Setup
function trueOrFalse(wasThatTrue) {

  // Only change code below this line.

  if (wasThatTrue) {
    return "Yes, that was true";
  }
    return "No, that was false";
  // Only change code above this line.

}

// Change this value to test
trueOrFalse(true);
@saiyanka
Iegor Shabazov
@Shabazov
Jul 02 2016 06:39
can anyone help me with Record Collection challenge? Can't get how to write that function...
Daniel Godigna
@DGAcode
Jul 02 2016 06:43
@Lkleindesigns make another if or an else
Logan Klein
@Lkleindesigns
Jul 02 2016 06:44
@33hawk ??
@33hawk i was sending someone the answer sorry
Daniel Godigna
@DGAcode
Jul 02 2016 06:44
sorry I just came here
@Shabazov paste your code
Iegor Shabazov
@Shabazov
Jul 02 2016 06:48
function updateRecords(id, prop, value) {
if ( value !== "" && prop !== "tracks") {
collection[id][prop] = value;

}
Bnobo
@acloud12345678
Jul 02 2016 06:48
i need help on Escaping Literal Quotes in Strings
please help me
Iegor Shabazov
@Shabazov
Jul 02 2016 06:49
can't get how to write the rest
Daniel Godigna
@DGAcode
Jul 02 2016 06:49
@acloud12345678 paste your code anyway for escaping characters you use \
Will
@Will-is-Coding
Jul 02 2016 06:49
@acloud12345678 var string = "Yada said, \"You're so getting quoted\"";
Bnobo
@acloud12345678
Jul 02 2016 06:49
@33hawk @Will-is-Coding
thanks
ill try it
Will
@Will-is-Coding
Jul 02 2016 06:50
@Shabazov So what's happening now? Nothing looks wrong in that snippet.
Daniel Godigna
@DGAcode
Jul 02 2016 06:52

@Shabazov Use an else if statement to check the needed steps.

The second step listed in the instructions should be first in your else if statement.

To access the value of a key in this object, you will use collection[id][prop].

Bnobo
@acloud12345678
Jul 02 2016 06:53
i need help on Escaping Literal Quotes in Strings in javascript
please
thanks to whoever helps me
Daniel Godigna
@DGAcode
Jul 02 2016 06:54
@acloud12345678 you need a beginning and an end with quotes " " or' ' you can also concatenate them if you wish to do that
Will
@Will-is-Coding
Jul 02 2016 06:55
@acloud12345678 Post what you have now
Bnobo
@acloud12345678
Jul 02 2016 06:55
@Will-is-Coding it won’t work
@33hawk
i need to type I am a "double quoted" string inside "double quotes".
Will
@Will-is-Coding
Jul 02 2016 06:56
I know it won't work, but show us the code you have
Daniel Godigna
@DGAcode
Jul 02 2016 06:56
@acloud12345678 can I see your code?
Bnobo
@acloud12345678
Jul 02 2016 06:56
how do I do that?
Leonid S. Knyshov
@wiseleo
Jul 02 2016 06:57
@acloud12345678 the bot will tell you
help format
CamperBot
@camperbot
Jul 02 2016 06:57

: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

Will
@Will-is-Coding
Jul 02 2016 06:57
Just copy paste what you've got and use that format.
Ermias GIOVANNI
@egg-develops
Jul 02 2016 06:59
To anybody: On 174 - Stand In Line: I'm curious as to why we need an explicit return statement if arr.shift() returns anyway?
Daniel Godigna
@DGAcode
Jul 02 2016 06:59
@acloud12345678 sometimes you have to reload the browser
Bnobo
@acloud12345678
Jul 02 2016 06:59
var myStr"I am a "double quotes" string inside "double quotes";  // Change this line
@wiseleo thanks
CamperBot
@camperbot
Jul 02 2016 06:59
acloud12345678 sends brownie points to @wiseleo :sparkles: :thumbsup: :sparkles:
:cookie: 289 | @wiseleo |http://www.freecodecamp.com/wiseleo
Daniel Godigna
@DGAcode
Jul 02 2016 07:00
@acloud12345678 quickly I can tell you that the equal is missing
Bnobo
@acloud12345678
Jul 02 2016 07:00
@33hawk ok,i added = now what do I have to add
Will
@Will-is-Coding
Jul 02 2016 07:00
@acloud12345678 Right, you need to use the \ before the inner "
Daniel Godigna
@DGAcode
Jul 02 2016 07:00
@acloud12345678 begin again
Bnobo
@acloud12345678
Jul 02 2016 07:01
@33hawk what do you mean by inner quotes?
Will
@Will-is-Coding
Jul 02 2016 07:01
All double quotes that are not the first or last one.
Bnobo
@acloud12345678
Jul 02 2016 07:01
@Will-is-Coding thanks
CamperBot
@camperbot
Jul 02 2016 07:01
acloud12345678 sends brownie points to @will-is-coding :sparkles: :thumbsup: :sparkles:
:cookie: 430 | @will-is-coding |http://www.freecodecamp.com/will-is-coding
Daniel Godigna
@DGAcode
Jul 02 2016 07:02
@acloud12345678 var myStr = "this ain\'t my string";
@acloud12345678 Maybe that example will help you
Will
@Will-is-Coding
Jul 02 2016 07:02
@33hawk Well that's valid without the escaped single quote
Bnobo
@acloud12345678
Jul 02 2016 07:02
@33hawk ok then, i’ll try it out
Iegor Shabazov
@Shabazov
Jul 02 2016 07:03
still don't get how to write the rest...
Will
@Will-is-Coding
Jul 02 2016 07:03
@Shabazov So what's happening/not happening? Nothing looked wrong with that small snippet
Daniel Godigna
@DGAcode
Jul 02 2016 07:03
@Will-is-Coding I think is a good example
Bnobo
@acloud12345678
Jul 02 2016 07:04
@Will-is-Coding @33hawk now my code is this
Hassaan Hafeez
@HassHz
Jul 02 2016 07:04
@Shabazov Next do the condition for when prop === tracks
Which is check if it exists first of all (if it doesn't, create the property tracks), if it exists push the value to the tracks property
Bnobo
@acloud12345678
Jul 02 2016 07:04
var myStr = "I am a \"double quotes\" string inside \"double quotes";  // Change this line
Will
@Will-is-Coding
Jul 02 2016 07:04
Oh sorry I'm slow @Shabazov I need to see the rest of the challenge
@acloud12345678 Looks good, well done.
Daniel Godigna
@DGAcode
Jul 02 2016 07:05
@acloud12345678 That is valid
Hassaan Hafeez
@HassHz
Jul 02 2016 07:05
@acloud12345678 I think you need a backslash for your final double quote, because there is supposed to be a period after that
quotes\"."
Bnobo
@acloud12345678
Jul 02 2016 07:06
@33hawk @HassHz it says Variable myStr should contain the string: I am a "double quoted" string inside "double quotes".
Iegor Shabazov
@Shabazov
Jul 02 2016 07:07
@HassHz like this if (prop === "tracks") {
collection[id][prop] = value;
}
Daniel Godigna
@DGAcode
Jul 02 2016 07:07
@acloud12345678 well what you did is a valid string not sure if that is what you need to do this time
Will
@Will-is-Coding
Jul 02 2016 07:08
@acloud12345678 Right, that's what @HassHz was saying. It needs to be ar myStr = "I am a \"double quotes\" string inside \"double quotes\".";
Daniel Godigna
@DGAcode
Jul 02 2016 07:09
@acloud12345678 try to not delete anything this time
Bnobo
@acloud12345678
Jul 02 2016 07:09
@33hawk I have to type in "@33hawk @HassHz it says Variable myStr should contain the string: I am a "double quoted" string inside "double quotes". “ I got the first one right, but not the second one, which
Will
@Will-is-Coding
Jul 02 2016 07:10
@acloud12345678 You're missing a double quote and a period.
Bnobo
@acloud12345678
Jul 02 2016 07:10
@Will-is-Coding
var myStr = "I am a \"double quotes\" string inside \"double quotes\".";  // Change this line
Will
@Will-is-Coding
Jul 02 2016 07:10
Yeah
Bnobo
@acloud12345678
Jul 02 2016 07:10
it says its wrong
Will
@Will-is-Coding
Jul 02 2016 07:11
It needs to print out this exactly: I am a "double quoted" string inside "double quotes".
Needs to be quoted, not quotes for the first
Bnobo
@acloud12345678
Jul 02 2016 07:12
I don’t know what you mean
edison sim
@Edisonsim
Jul 02 2016 07:12
Hi guys where can i write Pseudocode? at atom? is it allow?
Will
@Will-is-Coding
Jul 02 2016 07:12
@acloud12345678 var myStr = "I am a \"double quoted\" string inside \"double quotes\".";
Bnobo
@acloud12345678
Jul 02 2016 07:12
@Will-is-Coding oh, I see now, let me change it
Leonid S. Knyshov
@wiseleo
Jul 02 2016 07:13
@Edisonsim Pseudocode is not code. You can write it in any text editor.
Bnobo
@acloud12345678
Jul 02 2016 07:13
@Will-is-Coding @33hawk @HassHz thank you guys very much, I’ve been stuck on that problem for a very long time.
CamperBot
@camperbot
Jul 02 2016 07:13
acloud12345678 sends brownie points to @will-is-coding and @33hawk and @hasshz :sparkles: :thumbsup: :sparkles:
:cookie: 500 | @hasshz |http://www.freecodecamp.com/hasshz
:warning: acloud12345678 already gave will-is-coding points
:cookie: 278 | @33hawk |http://www.freecodecamp.com/33hawk
edison sim
@Edisonsim
Jul 02 2016 07:13
Oh thanks but is there a place i can see the output?
Will
@Will-is-Coding
Jul 02 2016 07:14
@acloud12345678 No problem, glad you got it working.
This message was deleted
Daniel Godigna
@DGAcode
Jul 02 2016 07:14
@acloud12345678 keep it on! :)
wiseleo @wiseleo writes pseudocode in Python :sparkles:
Hassaan Hafeez
@HassHz
Jul 02 2016 07:18
@Shabazov You still need the && value !== "" for that condition
Also if prop = tracks, tracks is an array so instead of doing collection[id][prop] = value, you want to push() value into collection[id][prop]
Daniel Godigna
@DGAcode
Jul 02 2016 07:18
@Edisonsim here is a package for the syntax but I can't help more with that https://atom.io/packages/language-pseudo
Hassaan Hafeez
@HassHz
Jul 02 2016 07:19
@Shabazov Also, as I said before, only push to it if collection[id] actually has a tracks property (if it doesn't create it and initialize it to an empty array before pushing t it)
Iegor Shabazov
@Shabazov
Jul 02 2016 07:22
@HassHz ok. I don't understand how to finish this challenge... Can you show me the right code and give some explanations?
function updateRecords(id, prop, value) {
if ( value !== "" && prop !== "tracks") {
collection[id][prop] = value;

} if (value !== "" && prop === "tracks") {
  collection[id][prop].push("Take a Chance On Me");
}
Daniel Godigna
@DGAcode
Jul 02 2016 07:22
@Shabazov You can search it in google but that is your desition
Iegor Shabazov
@Shabazov
Jul 02 2016 07:23
I need initialize "tracks"?
Will
@Will-is-Coding
Jul 02 2016 07:23
help updateRecords
CamperBot
@camperbot
Jul 02 2016 07:23
no wiki entry for: updaterecords
edison sim
@Edisonsim
Jul 02 2016 07:23
Screen Shot 2016-07-02 at 3.21.29 PM.png
Will
@Will-is-Coding
Jul 02 2016 07:23
Hm, forget how to look up the challenges with the bot
edison sim
@Edisonsim
Jul 02 2016 07:23
They give us this but didnt tell us where can we write it at hahaha
Will
@Will-is-Coding
Jul 02 2016 07:26

@Shabazov So you have four different things this function can do.

  • If prop does not contain the key "tracks", then update or set the value for that incomplete prop.

  • If prop does not contain the key "tracks" before you update it, create an empty array before pushing a track to it.

  • If prop does contain the key "tracks" and its value is non-blank, then push the value onto the end of its existing tracks array.

  • If value is blank, delete that prop.

You've got the first one done already.

Hassaan Hafeez
@HassHz
Jul 02 2016 07:31
help [challenge-name]
CamperBot
@camperbot
Jul 02 2016 07:31
no wiki entry for: challenge-name
Hassaan Hafeez
@HassHz
Jul 02 2016 07:31
if you want hints for a chalenge ^
Will
@Will-is-Coding
Jul 02 2016 07:31
So for the second you would do
if ( value !== "" && prop !== "tracks") {
   collection[id][prop] = value;
   //New Code Below
   if( collection[id]["tracks"] does not exist ) {
        create an empty array for collection[id]["tracks"]
   }
}
@Shabazov
You want to continue suit and make more if statements checking the parameters
Daniel Godigna
@DGAcode
Jul 02 2016 07:33
Somebody want to help me with Repeat a string?
Will
@Will-is-Coding
Jul 02 2016 07:36
@33hawk Sure, what do you need?
Iegor Shabazov
@Shabazov
Jul 02 2016 07:36
ok i think I begin to understand... I'll try to work it out! @Will-is-Coding
thanks @Will-is-Coding @33hawk
CamperBot
@camperbot
Jul 02 2016 07:37
shabazov sends brownie points to @will-is-coding and @33hawk :sparkles: :thumbsup: :sparkles:
:cookie: 279 | @33hawk |http://www.freecodecamp.com/33hawk
:cookie: 431 | @will-is-coding |http://www.freecodecamp.com/will-is-coding
Will
@Will-is-Coding
Jul 02 2016 07:37
@Shabazov Alright, post back if you're having issues. Good luck
@33hawk I think this will help
Indhu
@Indhusethu
Jul 02 2016 07:37

function phoneticLookup(val) {
var result = {
"alpha":"adams",
"bravo":"Boston",
"Charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"Foxtrot":"Frank",

};
result["bravo"];
result["echo"];
var lookup="bravo";
result[lookup];
// Only change code below this line

}

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

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

can anyone identify the mistake i have done here??
Daniel Godigna
@DGAcode
Jul 02 2016 07:38
@Will-is-Coding thanks any tip is good
CamperBot
@camperbot
Jul 02 2016 07:38
33hawk sends brownie points to @will-is-coding :sparkles: :thumbsup: :sparkles:
:cookie: 432 | @will-is-coding |http://www.freecodecamp.com/will-is-coding
Leonid S. Knyshov
@wiseleo
Jul 02 2016 07:39
@Indhusethu Well, first of all where is your code? It's supposed to be between
// Only change code below this line
}
// Only change code above this line
Will
@Will-is-Coding
Jul 02 2016 07:39
@Indhusethu First there's the //Only change code below/above this line. Second you have one too many closing } braces.
Indhu
@Indhusethu
Jul 02 2016 07:40
ok alright thabk you @wiseleo
Will
@Will-is-Coding
Jul 02 2016 07:40
@Indhusethu Third, you are currently manually looking up a specific item result["bravo"]; You want to use the val parameter passed into the function and then return that.`
BuntyBru
@BuntyBru
Jul 02 2016 07:40
Can anyone tell me what is the use of "hasOwnProperty"?
Will
@Will-is-Coding
Jul 02 2016 07:41
@33hawk Get familiar with mozilla's developer pages for javascript, heh
Indhu
@Indhusethu
Jul 02 2016 07:41
i will do it!! @Indhusethu
BuntyBru
@BuntyBru
Jul 02 2016 07:41
thanks @wiseleo
CamperBot
@camperbot
Jul 02 2016 07:41
buntybru sends brownie points to @wiseleo :sparkles: :thumbsup: :sparkles:
:cookie: 290 | @wiseleo |http://www.freecodecamp.com/wiseleo
Hassaan Hafeez
@HassHz
Jul 02 2016 07:42
@BuntyBru In short, to check if an object has a property
Ex:
var obj = {
   "hello": 1,
   "hey": 2
}

obj.hasOwnProperty("hello"); //returns true
obj.hasOwnProperty("bye"); //returns false
Daniel Godigna
@DGAcode
Jul 02 2016 07:43
@Will-is-Coding I know about it and is the best but this challenge is hard
Will
@Will-is-Coding
Jul 02 2016 07:44
@33hawk Oh you didn't see my link that I posted. This link
BuntyBru
@BuntyBru
Jul 02 2016 07:45
okay @HassHz
Daniel Godigna
@DGAcode
Jul 02 2016 07:46
@Will-is-Coding I saw it but I'm not sure that this is exactly what I need
刘德元
@xiaomibaobao
Jul 02 2016 07:46
Make Object Properties Private, cant work, i can fix it on my computer
Will
@Will-is-Coding
Jul 02 2016 07:47
@33hawk It looks like exactly what you want
Except for checking if the number is not positive
Daniel Godigna
@DGAcode
Jul 02 2016 07:48
@Will-is-Coding Man I'm failing with the basic algorithm part
Hassaan Hafeez
@HassHz
Jul 02 2016 07:48
@33hawk There is a repeat() method, or you could use a for loop
Will
@Will-is-Coding
Jul 02 2016 07:48
@33hawk Don't get too discouraged, they can be hard to get into and lots of new functions and things to learn.
Basically you want to do if (num is not positive) return empty string; else return string repeat function
Daniel Godigna
@DGAcode
Jul 02 2016 07:51
@Will-is-Coding let me try it @HassHz
@Will-is-Coding I feel that I am missing something is it ISCII ?
Will
@Will-is-Coding
Jul 02 2016 07:54
ISCII ?
Daniel Godigna
@DGAcode
Jul 02 2016 07:55
@Will-is-Coding sorry I meant regex
Will
@Will-is-Coding
Jul 02 2016 07:55
@33hawk Why would you need regex? You don't need any
Daniel Godigna
@DGAcode
Jul 02 2016 07:56
@Will-is-Coding I thought that because the different options I have to return. But seems wrong.
Will
@Will-is-Coding
Jul 02 2016 07:57
@33hawk The different options?
Daniel Godigna
@DGAcode
Jul 02 2016 07:57
repeatStringNumTimes("", 3) should return "**".
repeatStringNumTimes("abc", 3) should return "abcabcabc".
repeatStringNumTimes("abc", 4) should return "abcabcabcabc".
repeatStringNumTimes("abc", 1) should return "abc".
repeatStringNumTimes("", 8) should return "*".
repeatStringNumTimes("abc", -2) should return "".
Will
@Will-is-Coding
Jul 02 2016 07:58
Right
@33hawk There are two paths. If num > 0 or not. If it isn't then you return empty string. If it is then you use the string repeat method on it with the num as the parameter
The only options are just that. Have repeatStringNumTimes("stringhere", positive number); and repeatStringNumTimes("stringhere", 0 or negative number);
cannelflow
@cannelflow
Jul 02 2016 08:04
need help with DOM Manupulation https://jsfiddle.net/cannelflow/aghoyxLe/ reset button is not working as expected
Daniel Godigna
@DGAcode
Jul 02 2016 08:04
I know the first if is not right but I'm getting it
function repeatStringNumTimes(str, num) {
  // repeat after me
  if( num > 0 ) {
    return str.replace(num * 2);
  }
  else if( num < 0 ) {
    return str.replace(' ');
  }
}

repeatStringNumTimes("abc", 3);
leemurdock
@leemurdock
Jul 02 2016 08:05
Anyone available to assist with "Accessing Nested Objects" in the basic javascript section?
Daniel Godigna
@DGAcode
Jul 02 2016 08:05
@Will-is-Coding thanks
CamperBot
@camperbot
Jul 02 2016 08:05
33hawk sends brownie points to @will-is-coding :sparkles: :thumbsup: :sparkles:
:warning: 33hawk already gave will-is-coding points
Will
@Will-is-Coding
Jul 02 2016 08:05
@33hawk Why are you multiplying by 2? Also you don't need an else if just else will do.
Leonid S. Knyshov
@wiseleo
Jul 02 2016 08:05
@leemurdock It's not too bad. What's the question?
Will
@Will-is-Coding
Jul 02 2016 08:05
But otherwise it looks good
Daniel Godigna
@DGAcode
Jul 02 2016 08:06
@Will-is-Coding just wanted to show you, yea else is better for sure
leemurdock
@leemurdock
Jul 02 2016 08:06
@wiseleo I'm here myStorage.car.inside.glove_box = "gloveBoxContents";
var gloveBoxContents = ""; // Change this line
Will
@Will-is-Coding
Jul 02 2016 08:06
@33hawk Oh okay. Looks good
@33hawk I'm not sure if it'll complain about you not using str.replace("new string here")as it has in the function by default, instead of returning it
Raj Ranjan
@selftaught91
Jul 02 2016 08:07
hello i need help in freecodecamp
Leonid S. Knyshov
@wiseleo
Jul 02 2016 08:07
@leemurdock you are close. That line assigns the string 'gloveBoxContents' to the object property 'glove_box' of the inside object
Raj Ranjan
@selftaught91
Jul 02 2016 08:08
This is my solution var myStr="Here is a backslash:\.\n\t\tHere is a new line with two";
Leonid S. Knyshov
@wiseleo
Jul 02 2016 08:08
@leemurdock Your hint is that you need to change the "" of that challenge and nothing else.
Raj Ranjan
@selftaught91
Jul 02 2016 08:09
      var myStr="Here is a backslash:\\.\n\t\tHere is a new line with two";
leemurdock
@leemurdock
Jul 02 2016 08:10
ok @wiseleo, var gloveBoxContents = "maps"; doesn't work but let me try something else
Leonid S. Knyshov
@wiseleo
Jul 02 2016 08:11
@leemurdock It wants you to access the glove box property using the object access notation. Look at the example.
DavidR
@davidrinconv
Jul 02 2016 08:12
Hey guys I finished my twitch TV app... Van you let me know what you think? http://codepen.io/davidrv/full/VjbpZb/
leemurdock
@leemurdock
Jul 02 2016 08:12
@wiseleo "myStorage.car["inside"].glove_box"; doesn't work
Leonid S. Knyshov
@wiseleo
Jul 02 2016 08:13
@leemurdock there is no underscore in glove box. You are close though
Will
@Will-is-Coding
Jul 02 2016 08:14
@davidrinconv Very clean and well done. Feels sleek, I like it.
leemurdock
@leemurdock
Jul 02 2016 08:15
@wiseleo my struggle with a lot of these js challenges have been that the solution isn't the same format as the examples...
Will
@Will-is-Coding
Jul 02 2016 08:16
@davidrinconv You have some trailing </i> By your status tabs. On line 8 and all other for loops of your javascript for (i = 0; i < streamers.length; i++) you need to create i as a var. so for (var i = 0; i < streamers.length; i++)
Mihajlo Krsmanović
@rektix
Jul 02 2016 08:16
hey i don't understand Arguments Optional problem
can anyone help me?
Daniel Godigna
@DGAcode
Jul 02 2016 08:16
@davidrinconv I like it, I would just fix the height of text of the first bar and maybe a little of border-radius. But that is just design.
leemurdock
@leemurdock
Jul 02 2016 08:17
this has gotten me the closest @wiseleo var gloveBoxContents = myStorage.car["inside"]["glove box"];
Leonid S. Knyshov
@wiseleo
Jul 02 2016 08:18
@leemurdock That should actually work. What do the tests say?
leemurdock
@leemurdock
Jul 02 2016 08:18
annnnnnnnnd var gloveBoxContents = myStorage.car.inside["glove box"]; is where the magic is at!
Leonid S. Knyshov
@wiseleo
Jul 02 2016 08:18
Yep :) :clap: @leemurdock nicely done!
Will
@Will-is-Coding
Jul 02 2016 08:18
@davidrinconv I'm also confused why you have a function starting on line 9 in the for loop. It is unnecessary
tylerprosper
@removed~tylerprosper
Jul 02 2016 08:19
hi, beginner here. Can anybody help with the 'Convert Celsius to Fahrenheit exercise?
Leonid S. Knyshov
@wiseleo
Jul 02 2016 08:19
@leemurdock But myStorage['car']['inside']['glove box'] would also have worked.
leemurdock
@leemurdock
Jul 02 2016 08:19
what makes the difference between the example having the second word inside brackets and quotes vs the solution having the last word in brackets and quotes?
Mihajlo Krsmanović
@rektix
Jul 02 2016 08:20
@tylerprosper its actually simple just use formula given in task
Leonid S. Knyshov
@wiseleo
Jul 02 2016 08:20
@leemurdock the example threw that in to confuse you. When accessing object properties in a loop, always use the ['bracket'] notation but do so without quotes because variables are not strings. Using variable names in .dot notation will not work. If the property name contains a space, you can only access it using the ['bracket'] notation
tylerprosper
@removed~tylerprosper
Jul 02 2016 08:21

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

  fahrenheit = (celcius * (9 / 5) + 32)

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

// Change the inputs below to test your code
convertToF(30);
This is incorrect
obviously
Will
@Will-is-Coding
Jul 02 2016 08:23
@tylerprosper You misspelled celsius
You also need a ; at the end of the line
leemurdock
@leemurdock
Jul 02 2016 08:24
thanks @wiseleo
CamperBot
@camperbot
Jul 02 2016 08:24
leemurdock sends brownie points to @wiseleo :sparkles: :thumbsup: :sparkles:
:cookie: 292 | @wiseleo |http://www.freecodecamp.com/wiseleo
tylerprosper
@removed~tylerprosper
Jul 02 2016 08:25
@Will-is-Coding oh wow smh.. thx!
CamperBot
@camperbot
Jul 02 2016 08:25
tylerprosper sends brownie points to @will-is-coding :sparkles: :thumbsup: :sparkles:
:cookie: 433 | @will-is-coding |http://www.freecodecamp.com/will-is-coding
Will
@Will-is-Coding
Jul 02 2016 08:26
No problem, happens
Janodus
@janodus
Jul 02 2016 08:29
hello guys. is anyone able to help me out. I'm trying to create function that returns the position of numbers in an array that sum to 0.
here's my code:
def two_sum(nums)
    i = 0 

    while i < nums.length
        j = 0     
            while j < nums.length

                if nums[i] + nums[j] == 0
                    return nums[i,j]
                end
            j += 1 
        end
    i += 1
end
return nil
end
oh my. i'm sorry. i just realized that this is JS, not ruby
Ben
@benyiwen
Jul 02 2016 08:30
Hi, can somebody help me? I am stuck with the problem Record collection. I get the error: collection[id][prop].push is not a function. Here is my code: collection[id][prop].push(value);
Granteus
@Granteus
Jul 02 2016 08:31

// Initialize these three variables
var a = 6;
var b = 15;
var c = "I am a";

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";

Understanding Uninitialized Variables

What am I doing wrong?

Leonid S. Knyshov
@wiseleo
Jul 02 2016 08:34
@benyiwen Well, it's not a function unless that property is an array, which will only be true for the tracks property