These are chat archives for FreeCodeCamp/HelpJavaScript

17th
Jun 2016
Stephen James
@sjames1958gm
Jun 17 2016 00:00
But your loop keeps going, so if it hits another matching entry . . .
Umair
@umairbalani
Jun 17 2016 00:00
@hrokr how I should be doing it
Mike
@hitmikey
Jun 17 2016 00:00
@Chrono79 thanks for the help so far. im missing something because im new to arrays...
function updateRecords(id, prop, value) {
  if (value !== "") {
      if (collection[id].prop !== "tracks") {
        collection[id].prop = value;
        console.log("Not tracks!");
      }
      else if (collection[id].prop == "tracks") {
        collection[id].prop.push(value);
      }
      else if (collection.hasOwnProperty[id].prop === false) {
        collection[id].prop = value;
      }
  else {
    delete collection[id].prop;
  }
  }
  return collection;
}
CamperBot
@camperbot
Jun 17 2016 00:00
hitmikey sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: hitmikey already gave chrono79 points
Diego Mayer
@Chrono79
Jun 17 2016 00:00
@hitmikey you can also edit or delete your own posts, the ... at the right of the timestamp
you can't use dot notation with prop either, in fact whenever you use a var as a property, use bracket notation
Mike
@hitmikey
Jun 17 2016 00:01
lol.
ok updating.
hrokr
@hrokr
Jun 17 2016 00:01
@umairbalani - I think most people are leary about just giving the answer because the struggling through it is important. But, I thin it's fair to say you'll need an if statement with a second option. So, like an if-else
Mike
@hitmikey
Jun 17 2016 00:02
ooh. that was a major issue.
Diego Mayer
@Chrono79
Jun 17 2016 00:02

@hitmikey rethink this block

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

If "tracks" is non-existent before you update it, create an empty array before pushing a track to it.

Jonathan Mitchell
@Vanhealen
Jun 17 2016 00:03

You know how you can put
if (foo === false) -> if (!foo)

if (foo===true) -> if (foo)

if you put

 if (maybeTrueOrFalse)

will it evaluate the true or false?

in my example I have

function dropElements(arr, func) {
    for (var i = 0; i < arr.length; i++) {
        if (func(arr[i])) { //<—— on this line will this execute this line if func(arr[i]) is false or only when it is true?
            return arr;
        } arr.shift()
    }
}
Mike
@hitmikey
Jun 17 2016 00:03
k. thanks for the guidance. i want to struggle to learn,
Stephen James
@sjames1958gm
Jun 17 2016 00:03
@Vanhealen Drop until true then return.
Jonathan Mitchell
@Vanhealen
Jun 17 2016 00:04
@sjames1958gm that wasnt the question
hrokr
@hrokr
Jun 17 2016 00:04
@Chrono79 - I noticed today .... well, this: FreeCodeCamp/FreeCodeCamp#9168
Jonathan Mitchell
@Vanhealen
Jun 17 2016 00:05
@sjames1958gm thequestion was more so if
if (func(arr[i])
will only go inside that conditional if func(arr[i]) is TRUE ? Or will it go inside the conditional if it is false?
because func(arr[i]) returns a true or false, I didn’t explicitly say that I wanted the conditional to evaluate only for true

does

if (func(arr[i])

the same thing as

if (func(arr[i]) === true)
Diego Mayer
@Chrono79
Jun 17 2016 00:06
@Vanhealen if it evaluates to true, or is truthy
Jonathan Mitchell
@Vanhealen
Jun 17 2016 00:06
truthY?
Diego Mayer
@Chrono79
Jun 17 2016 00:06
yes, not falsy
Jonathan Mitchell
@Vanhealen
Jun 17 2016 00:06
?
whats with the y
Diego Mayer
@Chrono79
Jun 17 2016 00:07
"a", 5, [1,2,3]
not only true
hrokr
@hrokr
Jun 17 2016 00:07
They're the actual terms.
Jonathan Mitchell
@Vanhealen
Jun 17 2016 00:07
???????????????
bool has true or false or null
hrokr
@hrokr
Jun 17 2016 00:07
Yerp.
Jonathan Mitchell
@Vanhealen
Jun 17 2016 00:07
nothing called truthy
Jesus Rivero
@jesusdaver86
Jun 17 2016 00:07
var Car = function() {
  // this is a private variable
  var speed = 10;

  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };

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

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

var Bike = function() {

  // Only change code below this line.
var gear=6;//private

  this.setGear = function(){

   myBike.setGear = 4;

  };


  this.getGear = function(){
    return this.setGear;
  };

};
//console.log(setGear);
var myCar = new Car();

var myBike = new Bike();
hrokr
@hrokr
Jun 17 2016 00:07
No, there is a thing called truthy and falsy in JS.
Diego Mayer
@Chrono79
Jun 17 2016 00:08
do yourself a a test, create an if (5) console.log("this is truthy");

@jesusdaver86 setGear needs a param and you have to change the value of gear inside it
this is also wrong:

this.getGear = function(){
    return this.setGear;
  };

check the code example above

anacou
@anacou
Jun 17 2016 00:09
I'm stuck at the Stand in Line challenge...
hrokr
@hrokr
Jun 17 2016 00:10
@Vanhealen - what if we asked the value of "true" or "false"? do you think they would be the same as true or false, or for that matter True or False?
Diego Mayer
@Chrono79
Jun 17 2016 00:10
@anacou and your code is?
Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:10
@anacou what is the issue exactly? we've already told you about shift() and push()
Umair
@umairbalani
Jun 17 2016 00:10

var count = 0;

function cc(card) {
  // Only change code below this line
var answer = "";

switch(card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count += 1;
answer = count + " Bet";
break;

}

  if (card > 7 && card <10) {

    answer =  count + " Hold";
 }

switch(card) {
case 10:
case "J":
case "Q":
case "K":
case "A":
count += -1;
answer = count + " Hold";
break; 
}


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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2);  cc(3); cc(7); cc('K'); cc('A');
Jonathan Mitchell
@Vanhealen
Jun 17 2016 00:11
i see
dam i was so confused
Umair
@umairbalani
Jun 17 2016 00:11
Still stuck at
Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"
Cards Sequence 2, 2, 10 should return "1 Bet"
Jesus Rivero
@jesusdaver86
Jun 17 2016 00:11
@Chrono79 thanks
I'll try
CamperBot
@camperbot
Jun 17 2016 00:11
jesusdaver86 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1199 | @chrono79 |http://www.freecodecamp.com/chrono79
Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:11
what's this challenge called @Vanhealen
Diego Mayer
@Chrono79
Jun 17 2016 00:11

@umairbalani

 if (card > 7 && card <10) {

    answer =  count + " Hold";
 }

this isn't right, in fact none of the answer assignations should be inside card evaluations

Jonathan Mitchell
@Vanhealen
Jun 17 2016 00:11
This still doesn’t work
function dropElements(arr, func) {
    for (var i = 0; i < arr.length; i++) {
        if (!func(arr[i])) {
            arr.shift()
        }
    } return arr;
}
Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:12
if you arr.shift() you also need to do i-- I believe
because you are removing an element
hrokr
@hrokr
Jun 17 2016 00:12
@Vanhealen - what's the name of that challenge?
Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:13
and will then subsequently be skipping one
anacou
@anacou
Jun 17 2016 00:13
For starters, how do I write a function nextInLine which takes an array (arr) and a number (item) as arguments. I am assuming it's like this: function nextInLine(arr, item)
Diego Mayer
@Chrono79
Jun 17 2016 00:13

@Vanhealen reread the instructions:
Drop the elements of an array (first argument), starting from the front, until the predicate (second argument) returns true.

The second argument, func, is a function you'll use to test the first elements of the array to decide if you should drop it or not.

Return the rest of the array, otherwise return an empty array.

Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:13
@anacou function nextInLine(arr, item) { }
that's it
anacou
@anacou
Jun 17 2016 00:13
ok
good
Mike
@hitmikey
Jun 17 2016 00:14
@Chrono79 what am i missing here to create an array instead of a single value?
 else if (collection[id][prop] == "tracks") {
        collection[id][prop].push(value);
      }
Jonathan Mitchell
@Vanhealen
Jun 17 2016 00:14
function dropElements(arr, func) {
    for (var i = 0; i < arr.length; i++) {
        if (!func(arr[i])) {
            arr.shift()
            i--
        }
    } return arr;
}
Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:15
.push([value]); ?
Diego Mayer
@Chrono79
Jun 17 2016 00:15
@Vanhealen at the first not false you should return the array, not keep looking for falsy values
awbunys
@awbunys
Jun 17 2016 00:15
anacou I am stuck on the same one. I used a push and shift command on my return but now I've been struggling to return the element that was shifted
Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:15
did that work @Vanhealen ?
SBeard
@etacalpha
Jun 17 2016 00:15
@Vanhealen any particular reason you are using a loop?
Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:15
@awbunys you could always save the first element as a variable at the start and then return it at the end?
Diego Mayer
@Chrono79
Jun 17 2016 00:15
@hitmikey you have to join the 2 ifs, nesting them
if (collection[id][prop] == "tracks") {
  if ... {
     collection[id][prop] = [];
  }
  // here you can use push safely
Jonathan Mitchell
@Vanhealen
Jun 17 2016 00:16
@etacalpha what sould i use
@etacalpha I dont want to use filter
awbunys
@awbunys
Jun 17 2016 00:16
@Magnesium-Mike Ill try that, thanks!
CamperBot
@camperbot
Jun 17 2016 00:16
awbunys sends brownie points to @magnesium-mike :sparkles: :thumbsup: :sparkles:
:cookie: 350 | @magnesium-mike |http://www.freecodecamp.com/magnesium-mike
Jonathan Mitchell
@Vanhealen
Jun 17 2016 00:17
@Magnesium-Mike @Chrono79 didtn work
anacou
@anacou
Jun 17 2016 00:17
The next step is confusing to me: "Add the number to the end of the array"? What number???
Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:17
@Vanhealen what is the challenge called s o I can see my answer lol
awbunys
@awbunys
Jun 17 2016 00:18
@anacou I believe it is talking about your test number in the console log
Diego Mayer
@Chrono79
Jun 17 2016 00:18
@Magnesium-Mike drop it
Jonathan Mitchell
@Vanhealen
Jun 17 2016 00:18
dropElements
anacou
@anacou
Jun 17 2016 00:18
thanks @awbunys
CamperBot
@camperbot
Jun 17 2016 00:18
anacou sends brownie points to @awbunys :sparkles: :thumbsup: :sparkles:
Jonathan Mitchell
@Vanhealen
Jun 17 2016 00:18
I cant use a callback because I dont want to go through all teh elements in the array
CamperBot
@camperbot
Jun 17 2016 00:18
:cookie: 174 | @awbunys |http://www.freecodecamp.com/awbunys
guruice4
@guruice4
Jun 17 2016 00:18
Having trouble with record collection. Wrote my code twice before going to the forums but its still giving me an error
// Only change code below this line
function updateRecords(id, prop, value) {
if (value!==""&&prop=="tracks"){
collection[id][prop].push(value);
} else if(value!==""){
collection[id][prop] = value;
} else {
delete collection[id][prop];
}
return collection;
}
SBeard
@etacalpha
Jun 17 2016 00:18
@Vanhealen have you looked up .push and .shift
Jonathan Mitchell
@Vanhealen
Jun 17 2016 00:18
@etacalpha ya obviously
Diego Mayer
@Chrono79
Jun 17 2016 00:18
@Vanhealen there are multiple ways to end the loop
you could return in the else, use a break;
Jonathan Mitchell
@Vanhealen
Jun 17 2016 00:20
………..
meeyakoh
@meeyakoh
Jun 17 2016 00:20
doing increments: can someone help me out?
Mike
@hitmikey
Jun 17 2016 00:20
@Chrono79 @Magnesium-Mike I think I've come undone haha. link: https://www.freecodecamp.com/challenges/record-collection
function updateRecords(id, prop, value) {
  if (value !== "") {
      if (collection[id][prop] !== "tracks") {
        collection[id][prop] = value;
      }
      else if (collection[id][prop] == "tracks") {
        if (collection.hasOwnProperty[id][prop][value] === false) {
          collection[id][prop][value] = [ ];
        }
          collection[id][prop][value].push();
      }
  }
  else {
    delete collection[id][prop][value];
  }
  return collection;
}
Diego Mayer
@Chrono79
Jun 17 2016 00:21
@guruice4 If "tracks" is non-existent before you update it, create an empty array before pushing a track to it.
@hitmikey change this: collection[id][prop][value] to this collection[id][prop]
push(); to this push(value);
collection.hasOwnProperty[id][prop][value]to this collection[id].hasOwnProperty(prop)
man, you messed things up
@meeyakoh what do you need?
hrokr
@hrokr
Jun 17 2016 00:24
@Vanhealen - still having trouble?
Mike
@hitmikey
Jun 17 2016 00:24
hahaha
shoot sorry to be a bother :-/ i was humming along until i got to this page
hrokr
@hrokr
Jun 17 2016 00:26
@hitmikey - you're getting stuck on a page where many do. That almost always means it isn't you but something else.
guruice4
@guruice4
Jun 17 2016 00:26
@Chrono79 Yeah I am stuck here and found 3 solutions online none work and I cannot figure out what I broke.
Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:26
@Vanhealen I checked ,you do need to do i-- when you shift because say you had 4 element, you're looping for the first time so i = 0, it's false so you remove it, now the next loop starts at i is equal to 1 but you need to check position 0 since it's a new value because you just removed the first element
Diego Mayer
@Chrono79
Jun 17 2016 00:27
none work, because they've added a new test case, so those solutions don't apply
you have to address that case, you can't do undefined.push(value)
Mike
@hitmikey
Jun 17 2016 00:27
@hrokr haha thanks. im almost there, but for some reason, somethings broken with creating the array of 'tracks':
function updateRecords(id, prop, value) {
  if (value !== "") {
      if (collection[id][prop] !== "tracks") {
        collection[id][prop] = value;
      }
      else if (collection[id][prop] == "tracks") {
        if (collection.hasOwnProperty(prop) === false) {
          collection[id][prop][value] = [ ];
        }
          collection[id][prop].push(value);
      }
  }
  else {
    delete collection[id][prop];
  }
  return collection;
}
CamperBot
@camperbot
Jun 17 2016 00:27
hitmikey sends brownie points to @hrokr :sparkles: :thumbsup: :sparkles:
:cookie: 267 | @hrokr |http://www.freecodecamp.com/hrokr
Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:27
@Vanhealen so your issue is somewhere else, remember that if all conditions are wrong you also need to return an empty array
Diego Mayer
@Chrono79
Jun 17 2016 00:28
@hitmikey these 2 lines are still wrong:
        if (collection.hasOwnProperty(prop) === false) {
          collection[id][prop][value] = [ ];
Stephen James
@sjames1958gm
Jun 17 2016 00:28
@hitmikey value is not a property and shouldn't end up in [] on the left of =
hrokr
@hrokr
Jun 17 2016 00:29
@hitmikey - also, if you'll notice, it isn't just create. It's also update.
Diego Mayer
@Chrono79
Jun 17 2016 00:31
@hrokr he's updating it at the following line
Mike
@hitmikey
Jun 17 2016 00:33
damn, im too close.
guruice4
@guruice4
Jun 17 2016 00:33
i give up i cheated
hrokr
@hrokr
Jun 17 2016 00:33
@Chrono79 -- this is really interesting to me since they either the one I'm having or had trouble with... which is why I dissect them for CurriculumDevelopment list.
And then make issues of them.
Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:34
@Chrono79 can you link what you have right now?
Diego Mayer
@Chrono79
Jun 17 2016 00:35
@Magnesium-Mike of what are you talking about?
Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:35
oh it's @hitmikey's work not yours my bad
verdelegend
@verdelegend
Jun 17 2016 00:35
can somoen help me with this
Finding a Remainder in JavaScript
cjc77
@cjc77
Jun 17 2016 00:35
This message was deleted
hrokr
@hrokr
Jun 17 2016 00:35
For example the record collections code -- the canonical answer "works" but doesn't. It gives you the thumbs up but doesn't actually add the tracks push the tracks.
verdelegend
@verdelegend
Jun 17 2016 00:36
var remainder;11 % 3 = 2;
why doesn't that work
Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:36
@verdelegend us modulus
Diego Mayer
@Chrono79
Jun 17 2016 00:36
@verdelegend I remember telling you what to do
var remainder; // you're declaring remainder as undefined
Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:36
11 % 3 does equal 2
eeflores
@eeflores
Jun 17 2016 00:36
@verdelegend you aren't assigning to remainder
Mike
@hitmikey
Jun 17 2016 00:36
forget it.
Diego Mayer
@Chrono79
Jun 17 2016 00:37
@hrokr the canonical doesn't work anymore because they've added a new test case
Mike
@hitmikey
Jun 17 2016 00:38
wow can't believe I've been on this challenge for over an hour
Diego Mayer
@Chrono79
Jun 17 2016 00:38
@hitmikey you just had to fix those 2 lines
hrokr
@hrokr
Jun 17 2016 00:38
Right but if a person can't diagnose the problem, they can't get the solution.
Mike
@hitmikey
Jun 17 2016 00:38
function updateRecords(id, prop, value) {
  if (value !== "") {
      if (collection[id][prop] !== "tracks") {
        collection[id][prop] = value;
      }
      else if (collection[id][prop] == "tracks") {
        if (collection[id].hasOwnProperty(prop) === false) {
          collection[id][prop] = [ ];
        }
          collection[id][prop].push(value);
      }
  }
  else {
    delete collection[id][prop];
  }
  return collection;
}
guruice4
@guruice4
Jun 17 2016 00:38
@Chrono79 if you look at the forums the test cases we have appear to be the same and its the same one failing as those who claim the code worked
SBeard
@etacalpha
Jun 17 2016 00:39
var result = arr.push(item);
  result =arr.shift();
  return result;
@Vanhealen If you read the documentation carefully you would see that you do not need a loop to do this
Diego Mayer
@Chrono79
Jun 17 2016 00:39
@hitmikey where is [id] here? collection.hasOwnProperty(prop) === false) {
Mike
@hitmikey
Jun 17 2016 00:40
@Chrono79 updated... after collection?
Diego Mayer
@Chrono79
Jun 17 2016 00:40
@hitmikey yes
Mike
@hitmikey
Jun 17 2016 00:41
still broken and not creating an array
hmm
hrokr
@hrokr
Jun 17 2016 00:41
@Chrono79 - Right but if a person can't diagnose the problem, they can't get the solution. And if the challenge was updated, the answer needs to be too.
meeyakoh
@meeyakoh
Jun 17 2016 00:42
@Chrono79 not sure how myVar works
hrokr
@hrokr
Jun 17 2016 00:42
@verdelegend did you figure it out?
meeyakoh
@meeyakoh
Jun 17 2016 00:42
im not exactly sure how increment works as a whole
Diego Mayer
@Chrono79
Jun 17 2016 00:42
@hrokr internet doesn't work like that, and you're not supposed to go search the solution either, in time they'll update it, in the meantime, we have to help the people who can't work it out themselves
cjc77
@cjc77
Jun 17 2016 00:43
how do you guys include code markdown in chat? I can't seem to figure it out. 'Markdown help' also doesn't seem to do anything.
David Halls
@DavidHalls
Jun 17 2016 00:43
help format
CamperBot
@camperbot
Jun 17 2016 00:43

: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

hrokr
@hrokr
Jun 17 2016 00:44
@Chrono79 - I agree. But a) I had already spent hours on it with no success. So, seeing where I was wrong was needed. But b) the code they have up there is almost the same as mine. All other things I had tried also had not worked.
John
@tertiaryidentifier
Jun 17 2016 00:45
what apis do I use for the random quote machine challenge ....?
hrokr
@hrokr
Jun 17 2016 00:46
@Chrono79 - and i've don't these exercises -- with great difficulty -- before. So, since many people have had/are having the same problems it's really safe to say the problem isn't with them/us. It's something missing in the course. That's why I add to the issues page.
Diego Mayer
@Chrono79
Jun 17 2016 00:46
@hrokr It can be a bug, until recently (earlier today) it was working
But as you can see, from the code they're pasted here, their code wasn't right
cjc77
@cjc77
Jun 17 2016 00:47
I'm doing the map challenge(https://www.freecodecamp.com/challenges/iterate-over-arrays-with-map) and this code outputs correct result to my dev tools console but won't pass the challenge. Error: You should only modify the array with map.
var oldArray = [1, 2, 3, 4, 5];

var newArray = oldArray.map(function(num) {
    return num + 3;
});
Any ideas?
Mike
@hitmikey
Jun 17 2016 00:48
@hrokr @Chrono79 yes, there is a missing step in the course... i got it pretty much but im missing just a step about creating the array
hrokr
@hrokr
Jun 17 2016 00:48
@Chrono79 -- no, not true. It LOOKS like it does but check this out:FreeCodeCamp/FreeCodeCamp#9168 you'll need to look at the images at the bottom.
meeyakoh
@meeyakoh
Jun 17 2016 00:48
to the people here in general - are there different chatrooms for different levels/challenges? I feel like I'm disrupting the flow of the conversation here, but I could really use the help
hrokr
@hrokr
Jun 17 2016 00:48
@hitmikey -- so help folks out and list off what you think would make it more clear.
This message was deleted
@meeyakoh -- JS help, right?
Mike
@hitmikey
Jun 17 2016 00:50
@hrokr I don't know, until I get the solution right!!!
Paul Borawski
@iAmNawa
Jun 17 2016 00:51
@meeyakoh this is the javascript chat, on the left bar there should be the different chat room names
hrokr
@hrokr
Jun 17 2016 00:52
@meeyakoh post your code (using the backticks!).
Diego Mayer
@Chrono79
Jun 17 2016 00:52
@hrokr I'm gonna explain one last time, they've added the case where an object hasn't the property tracks, the code in your screenshots is the solution to the challenge before that
If there is a bug for the right code for the challenge with this case (that wasn't added today or yesterday, just days ago and people was passing this challenge) is another story
Arsalan Savand
@ArsalanSavand
Jun 17 2016 00:53
PLEASE can anyone help me with this?
function reverseString(str) {
  var i = str;
  var s = i.split("");
  var r = s.reverse();
  var j = r.join('');
  return j;
}

reverseString(["hello"]);
im trying to reverse "hello" which is str
Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:53
you're trying to split an array
that only works on strings
Arsalan Savand
@ArsalanSavand
Jun 17 2016 00:53
so how do i get it don
Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:53
do var i = str[0];
Arsalan Savand
@ArsalanSavand
Jun 17 2016 00:54
i know
i already did that
but there is a Problem with it
eeflores
@eeflores
Jun 17 2016 00:54
This message was deleted
Leslie Lee
@leslie5803
Jun 17 2016 00:55
if(Array.isArray(str)){}else{}
SBeard
@etacalpha
Jun 17 2016 00:55
@ArsalanSavand convert to string, split string, reverse string, join string....return
Arsalan Savand
@ArsalanSavand
Jun 17 2016 00:55
@etacalpha how?
I did
but nothing works
Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:55
lol
eeflores
@eeflores
Jun 17 2016 00:55
@ArsalanSavand should the call to the function be reverseString("hello"); (no brackets in function call)
Mike Gergely
@Magnesium-Mike
Jun 17 2016 00:55
check if it's an array, if it is turn it into a string and continue, if not just go on as regular
SBeard
@etacalpha
Jun 17 2016 00:56
look up MDNs for split() reverse() and join() @ArsalanSavand
Arsalan Savand
@ArsalanSavand
Jun 17 2016 00:57
@eeflores thanks it works>>>> look i wanna do it as e String but the challenge says doing it by [] is better
CamperBot
@camperbot
Jun 17 2016 00:57
arsalansavand sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:cookie: 753 | @eeflores |http://www.freecodecamp.com/eeflores
Arsalan Savand
@ArsalanSavand
Jun 17 2016 00:58
at first i was like why but now im like Why????? again
PEACE THANKS EVERYONE!!
Mike
@hitmikey
Jun 17 2016 00:58
WOW. wish I could skip this challenge!
Arsalan Savand
@ArsalanSavand
Jun 17 2016 00:58
which one?
Mike
@hitmikey
Jun 17 2016 00:59
Record Collections
Arsalan Savand
@ArsalanSavand
Jun 17 2016 00:59
@hitmikey whats the errror
show me ur code
Mike
@hitmikey
Jun 17 2016 01:00
welp. i just skipped ahead and found a solution. what a pain in the butt

My code:

function updateRecords(id, prop, value) {
  if (value !== "") {
      if (collection[id][prop] !== "tracks") {
        collection[id][prop] = value;
      }
      else if (collection[id][prop] == "tracks") {
        if (collection[id].hasOwnProperty(prop) === false) {
          collection[id][prop] = [ ];
        }
        collection[id][prop].push(value);
      }
  }
  else {
    delete collection[id][prop];
  }
  return collection;
}

Solution:

function updateRecords(id, prop, value) {
  if (prop === "tracks" && value !== "") {
   if(collection[id][prop]){
    collection[id][prop].push(value);
   }
   else{
    collection[id][prop]=[value];
   }
  } else if (value !== ""){
    collection[id][prop] = value;
  } else {
    delete collection[id][prop];
  }

  return collection;
}
Diego Mayer
@Chrono79
Jun 17 2016 01:01
@hitmikey your code was still wrong
if (collection[id][prop] !== "tracks") { should be if (prop !== "tracks") {
Mike
@hitmikey
Jun 17 2016 01:02
@Chrono79 I know, i used the solution. I guess my ordering was incorrect?
Diego Mayer
@Chrono79
Jun 17 2016 01:02
@hitmikey no, try to fix your own code
Physicallime570
@Physicallime570
Jun 17 2016 01:02
function isLess(a, b) {
  // Fix this code
return a===b;
}
// Change these values to test
isLess(10, 15);
what am i doing wrong?
Tim Crockett
@BoboMunkee
Jun 17 2016 01:03
@hitmike Your ordering is fine, look at the difference between your code and the code that works.
Andrew Thomas
@anthom
Jun 17 2016 01:03
Hey guys...just started the JS section and already feel like I'm missing something on Celsius to Farenheit.
Diego Mayer
@Chrono79
Jun 17 2016 01:03
@Physicallime570 the function name is isLess, === isn't the logical comparison you want to use
Mike
@hitmikey
Jun 17 2016 01:03
@Chrono79 ahhhh. that was the mistake that caused the whole problem. i was evaluating the existing var vs. the argument...
Diego Mayer
@Chrono79
Jun 17 2016 01:03
@hitmikey yes
Mike
@hitmikey
Jun 17 2016 01:04
@Chrono79 @Magnesium-Mike lesson learned lol. painfully. thank you both.
CamperBot
@camperbot
Jun 17 2016 01:04
hitmikey sends brownie points to @chrono79 and @magnesium-mike :sparkles: :thumbsup: :sparkles:
:star2: 1200 | @chrono79 |http://www.freecodecamp.com/chrono79
:cookie: 351 | @magnesium-mike |http://www.freecodecamp.com/magnesium-mike
Diego Mayer
@Chrono79
Jun 17 2016 01:04
sorry I couldn't catch it before, I'm tired
Physicallime570
@Physicallime570
Jun 17 2016 01:04
@Chrono79 what exactly should i be using?
Diego Mayer
@Chrono79
Jun 17 2016 01:05
@Physicallime570 do you know what these 2 mean? < >
hrokr
@hrokr
Jun 17 2016 01:05
This message was deleted
Mike
@hitmikey
Jun 17 2016 01:05

@Chrono79 I guess I should read all of the requirements in the challenge so that i can logically assemble the code better right? for example, i had nested if's when i could've had it simplified as in the solution i posted.

i.e. i could've done a joint if statement like if XXX && XXX

endlessetudes
@endlessetudes
Jun 17 2016 01:05
hello i'm having an issue on the first .hasOwnProperty(); challenge. i don't know how to return the property's value. return checkProp(?)
Diego Mayer
@Chrono79
Jun 17 2016 01:06
@hitmikey you already have one nested if
Chipi
@Chipsta
Jun 17 2016 01:06
Hey guys I'm having trouble getting one of my switch statements to work.
Diego Mayer
@Chrono79
Jun 17 2016 01:06
@endlessetudes no
Mike
@hitmikey
Jun 17 2016 01:06
its object.property (i think)
Chipi
@Chipsta
Jun 17 2016 01:06

var count = 0;

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

switch (card) {

case 2,3,4,5,6:
  return "5 Bet" ;
  break ;  
case 7,8,9 :
  return "0 Hold";
  break;
case 10,"J","Q","K","A" :
  return "-5 Hold" ;
  break;
case 3,7,"Q",8,"A" :
  return "-1 Hold" ;
  break ;
case 2,2,10 :
  return "1 Bet" ;
  break ;
case 2,"J",9,2,7:
  return "1 Bet" ;
  break ;
case 3,2,"A", 10,"K":
return "-1 Hold" ;
  break ;  

if (card==3){
return "-1 Hold";
} else if (card==7){
return"-1 Hold";
} else if (card=="Q") {
return "-1 Hold";
}else if (card==8) {
return "-1 Hold";
} else if (card=="A"){
return "-1 Hold";
}

}

// Only change code above this line
}

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

Physicallime570
@Physicallime570
Jun 17 2016 01:06
@Chrono79 yea that would be greater than and less than
Diego Mayer
@Chrono79
Jun 17 2016 01:07
@hitmikey that solution is actually longer
Chipi
@Chipsta
Jun 17 2016 01:07
having trouble getting Cards Sequence 3, 7, Q, 8, A should return "-1 Hold"
Andrew Thomas
@anthom
Jun 17 2016 01:07
Does this look right for the temperature conversion code? farenheit = (9/5)*celsius+32;
Diego Mayer
@Chrono79
Jun 17 2016 01:08
@Physicallime570 I think it's the other way around, this is lesser than <
David Halls
@DavidHalls
Jun 17 2016 01:08
@Chipsta you cant return in the switch for this challenge, it wants you to process several cards to determine the bet
Diego Mayer
@Chrono79
Jun 17 2016 01:08
@anthom yes, but you misspelled fahrenheit
Andrew Thomas
@anthom
Jun 17 2016 01:09
DOH...knew it had to be something stupid like that. thx
endlessetudes
@endlessetudes
Jun 17 2016 01:09
return myObj.checkProp ? i just don't know how to access the value of the property
Diego Mayer
@Chrono79
Jun 17 2016 01:09
@endlessetudes you can't use dot notation with vars (or with properties whose name contains spaces)

@Chipsta you can't use switch like that either

switch(card) {
  case 2:
  case 3:
  ...
}

and so on

endlessetudes
@endlessetudes
Jun 17 2016 01:12
@Chrono79 that was it. i knew it was something simple. thank you. brownie points away
CamperBot
@camperbot
Jun 17 2016 01:12
:star2: 1201 | @chrono79 |http://www.freecodecamp.com/chrono79
endlessetudes sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Eden Coleman
@nede36
Jun 17 2016 01:21
You're going to want to define the values in a switch statement and then calculate the results and return the results using an if/else if statement
John
@JKilk
Jun 17 2016 01:22
hey guys any tips on how to separate the array argument from the int arguments in the seek and destroy challenge?
Diego Mayer
@Chrono79
Jun 17 2016 01:22
arguments object @JKilk
arr (your function parameter) is already the array, an the rest of the arguments are the things you should seek and destroy in it
John
@JKilk
Jun 17 2016 01:24
right, how would access the first non array argument?
doing something like arr1 is giving me the second element from the array
Diego Mayer
@Chrono79
Jun 17 2016 01:24
arguments[1]
SBeard
@etacalpha
Jun 17 2016 01:25
arrays are zero indexed so start with 0 for first item
Diego Mayer
@Chrono79
Jun 17 2016 01:26
@etacalpha he wants all but the first
Peter Weinberg
@no-stack-dub-sack
Jun 17 2016 01:26
Rando quote machine... 1st time incorporating JS into codepen project. Doesn't do so great with responsiveness because of the background photo placement. Got the twitter window to pop up instead of opening new window, and implemented a facebook sharing feature but its kind of buggy in CodePen - highlight quote to share on FB - only works in debug mode. Also, going to attempt a 2nd version using an API, this version uses a stored array since I had a specific request to do Frank Zappa quotes! Any feedback appreciated! http://s.codepen.io/no_stack_dub_sack/debug/GqqKyQ
John
@JKilk
Jun 17 2016 01:27
yea the first argument is an array consisting of 6 elements, then the second and third arguemnts are ints
Mike
@hitmikey
Jun 17 2016 01:27

@hrokr in this challenge, it didn't really talk about using multi dimension arrays in a for loop, it just gives the example. some feedback i'd give is that i'd prefer to have a little more explanation so that i can retain the concept and apply it to a future challenge:

nesting for loops

SBeard
@etacalpha
Jun 17 2016 01:27
I must have missed something then, what exactly are you trying to do and do You have code to show us @JKilk
John
@JKilk
Jun 17 2016 01:27
wait i think i've got an idea
Diego Mayer
@Chrono79
Jun 17 2016 01:28
help seek and destroy
CamperBot
@camperbot
Jun 17 2016 01:28

:point_right: algorithm seek and destroy [wiki]

Algorithm Seek and Destroy

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

:checkered_flag: Problem Explanation:

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

Relevant Links

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

Diego Mayer
@Chrono79
Jun 17 2016 01:28
@etacalpha that challenge is what @JKilk is trying to do
John
@JKilk
Jun 17 2016 01:28
nah my idea was wrong
thanks for that diego
Diego Mayer
@Chrono79
Jun 17 2016 01:29
anyway, paste your code if you get stuck, but if you think you can solve it without help, go ahead @JKilk
John
@JKilk
Jun 17 2016 01:30
so just generally speaking if i have a function e.g. function foo(arg), and i call the function with arguments: foo([1, 2, 3], 4, 5, 6), within my function body how do i access 4, 5, or 6
Manaraj Rajbahak
@manaraj
Jun 17 2016 01:30
Can anybody help me on this.
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
John
@JKilk
Jun 17 2016 01:31
if i try arg3 it returns null
Manaraj Rajbahak
@manaraj
Jun 17 2016 01:31
My answer is var myStr = "\ Back Slash \t \t Tab \r Carriage-return \n New Line";
Diego Mayer
@Chrono79
Jun 17 2016 01:31
@JKilk it's arguments[3]
Manaraj Rajbahak
@manaraj
Jun 17 2016 01:31
why is it showing wrong
John
@JKilk
Jun 17 2016 01:31
okay so here arguments is like a keyword of accessing the arguments?
Diego Mayer
@Chrono79
Jun 17 2016 01:32
@manaraj you have to use only one side of the table, the codes, not the words too
@JKilk yes
SBeard
@etacalpha
Jun 17 2016 01:32
ok I see now, first separate arguments from array. Create a variable containing only the array
John
@JKilk
Jun 17 2016 01:32
okay that makes a lot of sense thank you very much
SBeard
@etacalpha
Jun 17 2016 01:32
@JKilk
Manaraj Rajbahak
@manaraj
Jun 17 2016 01:32
Ok thanks Diego
Diego Mayer
@Chrono79
Jun 17 2016 01:32
@etacalpha the array comes as the function param, for free ;)
John
@JKilk
Jun 17 2016 01:33
how do i give points for helping ?
Diego Mayer
@Chrono79
Jun 17 2016 01:33
saying thanks and mention someone
John
@JKilk
Jun 17 2016 01:33
thanks @Chrono79 for helping me
CamperBot
@camperbot
Jun 17 2016 01:33
jkilk sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1202 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 17 2016 01:34
no problem
Josh Terry
@jaywikid
Jun 17 2016 01:34
I have a question about Selecting many options from switchs. I cant get my test to ready out the statement.
Diego Mayer
@Chrono79
Jun 17 2016 01:34
your code please
Josh Terry
@jaywikid
Jun 17 2016 01:35
switch (val) {
case 1:
console.log("alpha");
break;
case 2:
console.log("beta");
break;
case 3:
console.log("gamma");
break;
case 4:
console.log("delta");
break;
}
MrBurks
@mrburks
Jun 17 2016 01:35

// Example
var ourStr = "I come first. ";
ourStr += "I come second.";

// Only change code below this line

var myStr = "This is the first sentence. " + "This is the second sentence.";

I know I'm not krazy with this one...
Eden Coleman
@nede36
Jun 17 2016 01:35

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj[playerNumber]; // Change this Line
var player = testObj[16]; // Change this Line

Diego Mayer
@Chrono79
Jun 17 2016 01:36
@mrburks do it like the example, in 2 lines
Eden Coleman
@nede36
Jun 17 2016 01:36
What am I missing? The last thing that won't complete is "playerNumber should be a number"
Eric
@Code-Eric
Jun 17 2016 01:36
function titleCase(str) {
  var result;
  var arr = str.toLowerCase().split(' ');
  arr.map(function(val){

      console.log(val.replace(val[0],val[0].toUpperCase()));
       result = val.replace(val[0],val[0].toUpperCase());
          }
  );
  return result;
}

titleCase("I'm a little tea pot”);
why does it return only the last element of the array?
Diego Mayer
@Chrono79
Jun 17 2016 01:36
@nede36 playerNumber must be a number and you have to use playerNumber in the last line
SBeard
@etacalpha
Jun 17 2016 01:37
@Chrono79 yes but he will still have to slice in order to use arguments
Diego Mayer
@Chrono79
Jun 17 2016 01:37
@jaywikid are you sure you have to console.log?
@etacalpha no need, he could loop over arguments
Josh Terry
@jaywikid
Jun 17 2016 01:37
@Chrono79 I tried it without it and it still doesnt return anything
Diego Mayer
@Chrono79
Jun 17 2016 01:38
@jaywikid challenge name?
Eden Coleman
@nede36
Jun 17 2016 01:38
but what number, the only numbers are what are in the object which is what I am calling. I'm super confused
Josh Terry
@jaywikid
Jun 17 2016 01:38
@Chrono79 Selecting from many options with Switch Statements
Diego Mayer
@Chrono79
Jun 17 2016 01:38
@nede36 look at the instructions, you'll figure out what number do you need
SBeard
@etacalpha
Jun 17 2016 01:38
but the idea of the challenge is to use the filter method
Eden Coleman
@nede36
Jun 17 2016 01:39
I know the number I need is 16
Diego Mayer
@Chrono79
Jun 17 2016 01:39
@etacalpha yes, with the array
loop through arguments, and filter the array, it can be done like that
@nede36 so, set playerNumber to 16
Eden Coleman
@nede36
Jun 17 2016 01:40
Got it, I was overthinking
thanks @Chrono79
CamperBot
@camperbot
Jun 17 2016 01:40
nede36 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1203 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 17 2016 01:40
@Code-Eric you're overwriting result in each loop
Carlota Pearl
@caep2015
Jun 17 2016 01:40
Hi. Do you all know how many challenges are required to be able to maintain a streak? I have been trying to do it every day for the past week yesterday I completed 4. Today I completed 1 and today I noticed it reads 1 day streak???
Diego Mayer
@Chrono79
Jun 17 2016 01:41
@caep2015 I think they're for hours, not challenges, so maybe between a challenge and another passed more than 24hs
DC*
@desyncr
Jun 17 2016 01:43
@caep2015 "If you get Brownie Points on several days in a row, you'll get a streak."
Eric
@Code-Eric
Jun 17 2016 01:43
how do i fix the problem?
Ken Haduch
@khaduch
Jun 17 2016 01:45
@caep2015 - I think that if you get one brownie point or complete one challenge in a day, it counts toward to streak? It seems like that to me, although I don't have an easy time remembering the numbers, but I'm on a 174 day streak, so it's been going for a while. I usually get more than one BP a day from helping people - but completing a challenge for the first time (a lesson, or whatever they are called) also gives you a point. It shows that you are active for that day.
@Code-Eric - you want to store the results in an array in some manner (just as you are reading them from an array) so that you have a complete set of the words to re-build the sentence.
Eric
@Code-Eric
Jun 17 2016 01:48
i got it nvm
i pushed it into a new array and then joined it
yeah exactly what you said @khaduch
Josh Terry
@jaywikid
Jun 17 2016 01:49
Can someone explain to me why my code wont read out anything?
Ken Haduch
@khaduch
Jun 17 2016 01:49
@Code-Eric - good! It's kind of a pattern with a lot of these exercises, so you'll see it again, for sure.
Josh Terry
@jaywikid
Jun 17 2016 01:49

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (answer) {
case 1:
console.log("alpha");
break;
case 2:
console.log("beta");
break;
case 3:
console.log("gamma");
break;
case 4:
console.log("delta");
break;
}

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

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

Carlota Pearl
@caep2015
Jun 17 2016 01:49
I'm trying. It definitely keeps me coming back so that I don't loose my "streak". Today was a big day so I kind of wanted to call it a night after 1 challenge so I checked the streak and was dismayed at the streak = 1 day. Was wondering wondering if I should keep going for it to continue. I have been on here every day for the past 5 days so today would have been day 5 (not 1)....
Ken Haduch
@khaduch
Jun 17 2016 01:50
@jaywikid - you are returning the value in the variable answer, but you are not setting anything in it. And you are doing switch(answer) instead of using the val...
Diego Mayer
@Chrono79
Jun 17 2016 01:50
@jaywikid evaluate val, not answer
MrBurks
@mrburks
Jun 17 2016 01:50
@Chrono79 I already tried it like the example, that didn't work. maybe and browser restarted will work...
Carlota Pearl
@caep2015
Jun 17 2016 01:50
@khaduch Thanks
CamperBot
@camperbot
Jun 17 2016 01:50
caep2015 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1337 | @khaduch |http://www.freecodecamp.com/khaduch
Michael Karpinski
@karpimpski
Jun 17 2016 01:50
@jaywikid answer is a string, your cases are ints
Ken Haduch
@khaduch
Jun 17 2016 01:51
@caep2015 - if you want to do another quick item that should get you a point, look at the bottom of the map for the videos on Computer Basics or Javascript L ingo - they are short and helpful videos with a few questions to answer. Give that a try!
@caep2015 - I'll give you a thanks for the interaction - always good to get some feedback!
CamperBot
@camperbot
Jun 17 2016 01:52
khaduch sends brownie points to @caep2015 :sparkles: :thumbsup: :sparkles:
:cookie: 228 | @caep2015 |http://www.freecodecamp.com/caep2015
Carlota Pearl
@caep2015
Jun 17 2016 01:53
@khaduch thanks again for the feedback and advice I will check out the videos and come back tomorrow morning.
Josh Terry
@jaywikid
Jun 17 2016 01:53
i changed it to Switch(val) and i still get no read out.Shoould i not be using console.log?
CamperBot
@camperbot
Jun 17 2016 01:53
:warning: caep2015 already gave khaduch points
Chris Cullen
@123xylem
Jun 17 2016 01:53
QUESTION:: Im trying to write something that looks at the value of TIll and counts it to see if the till has sufficient funds to cover change...
How do i access the numbers so I can count it or is it possible?

function checkCashRegister(price, cash, cid) {
var cost=arguments[0];
  var money=arguments[1];
var till= arguments[2];
  var count=0;

  var change= money-cost;

  for(var i in till){
    count+= till[i].hasOwnProperty(val);
  if(change>count){
    return "Insufficient Funds";
  }
  }
 return count;
}
CamperBot
@camperbot
Jun 17 2016 01:53
caep2015 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Diego Mayer
@Chrono79
Jun 17 2016 01:53
@jaywikid yes, you should change answer value instead
@mrburks show your code again if reset or refresh doesn't work
Josh Terry
@jaywikid
Jun 17 2016 01:56
@Chrono79 i changed the answer value in switch(xxx), still no read out
SBeard
@etacalpha
Jun 17 2016 01:56
@123xylem why use vars to change the name of arguments ? Use an IF Else to do that
Diego Mayer
@Chrono79
Jun 17 2016 01:57
@jaywikid paste your code again
Josh Terry
@jaywikid
Jun 17 2016 01:57

@Chrono79 function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val) {
case 1:
console.log("alpha");
break;
case 2:
console.log("beta");
break;
case 3:
console.log("gamma");
break;
case 4:
console.log("delta");
break;
}

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

MrBurks
@mrburks
Jun 17 2016 01:57
still not working
bsandusky
@bsandusky
Jun 17 2016 01:57
@jaywikid You are console.loging the answers. Instead, try to set answer = to each case so that when you return answer at the bottom it’s not empty.
Chris Cullen
@123xylem
Jun 17 2016 01:57
@etacalpha what does it matter how I change arg names?
Diego Mayer
@Chrono79
Jun 17 2016 01:57
case 1:
 answer = "alpha";
and so on
Josh Terry
@jaywikid
Jun 17 2016 01:58
@Chrono79 @bsandusky thanks for the help
CamperBot
@camperbot
Jun 17 2016 01:58
jaywikid sends brownie points to @chrono79 and @bsandusky :sparkles: :thumbsup: :sparkles:
:cookie: 301 | @bsandusky |http://www.freecodecamp.com/bsandusky
:star2: 1204 | @chrono79 |http://www.freecodecamp.com/chrono79
SBeard
@etacalpha
Jun 17 2016 01:58
its extra code not needed, not saying your wrong for it just kinda repetative
@123xylem
Diego Mayer
@Chrono79
Jun 17 2016 02:00
@mrburks paste it again
Micah Bales
@micahbales
Jun 17 2016 02:00
Howdy everyone. I think my Simon game is very close to completion. Can you please play it and tell me what flaws you find? Thank you! http://codepen.io/micahbales/pen/MegRqm?editors=0010
Chris Cullen
@123xylem
Jun 17 2016 02:00
@etacalpha Man I like to have it refined but at the moment I just want to be able to actualy code it:)
SBeard
@etacalpha
Jun 17 2016 02:00
if price - cost > cid return INS else return (price - cost) +" is your change" @123xylem
MrBurks
@mrburks
Jun 17 2016 02:00

// Example
var ourStr = "I come first. ";
ourStr += "I come second.";

// Only change code below this line

var myStr = "This is the first sentence. ";
ourStr += "This is the second sentence.";

oh, i see it now
Diego Mayer
@Chrono79
Jun 17 2016 02:01
:+1:
Chris Cullen
@123xylem
Jun 17 2016 02:01
@etacalpha nice and short... Any idea how I access the CID numbers though?
SBeard
@etacalpha
Jun 17 2016 02:03
it's already there as an argument @123xylem
Chris Cullen
@123xylem
Jun 17 2016 02:03
@etacalpha cid is an array though.. It doesnt have 1 numerical val it has a few with strings aswell
SBeard
@etacalpha
Jun 17 2016 02:03
what is the name of the challenge?
Chris Cullen
@123xylem
Jun 17 2016 02:04
exact change
var change= money-cost;

  for(i=1; i<till.length;i+2){
    count+= till[i];
  if(change>count){
    return "Insufficient Funds";
  }
  }
 return count;
}
cid=[["PENNY", 1.01], ["NICKEL", 2.05] etc

  for(i=0; i<till.length;i++){
    for(j=1;j<till[i].length;j+2){
    count+= till[j];
  if(change>count){
    return "Insufficient Funds";
  }}
  }
 return count;
I made a nested loop that looks at 2nd elem of array and adds to count
then i can compare the val of count with change needed
But its giving infi loop...
SBeard
@etacalpha
Jun 17 2016 02:08
@123xylem I have not seen this one before give me a few
Chris Cullen
@123xylem
Jun 17 2016 02:08
@etacalpha sure!
Diego Mayer
@Chrono79
Jun 17 2016 02:09
@123xylem why the second loop, and what is till?
Chris Cullen
@123xylem
Jun 17 2016 02:09
@Chrono79 the second loop is to access the number in cid/till
till is the array of money in the till
SBeard
@etacalpha
Jun 17 2016 02:09
@Chrono79 till is another name for cash register
Diego Mayer
@Chrono79
Jun 17 2016 02:09
ok
Chris Cullen
@123xylem
Jun 17 2016 02:10
o yea and that
Is there an easy way to stop that infi loop... I always get caught up on how to stop them
John
@JKilk
Jun 17 2016 02:11
hey guys, can you not use a for loop in the callback function of filter?
Diego Mayer
@Chrono79
Jun 17 2016 02:11
if you have cid, that's the array, why not use only one loop, and sum cid[i][1]?
Ken Haduch
@khaduch
Jun 17 2016 02:12

@micahbales - hello Micah - what is "strict" mode supposed to do? It doesn't seem to be any different from the normal mode?

It looks pretty good - sometimes the sounds don't play on repeated occurrences of the same color? And when I messed up on my round, I was expecting some kind of explosion or something? :)

Micah Bales
@micahbales
Jun 17 2016 02:12
@khaduch Strict makes it so that the game resets if you mess up. Otherwise, you get to re-try.
Diego Mayer
@Chrono79
Jun 17 2016 02:13
@khaduch you just killed a kitten :crying_cat_face:
Ken Haduch
@khaduch
Jun 17 2016 02:13
@micahbales - oh, I thought it was something different, but it's been a long time since I played a simon game...
Micah Bales
@micahbales
Jun 17 2016 02:13
@khaduch I noticed that problem with the sounds, too. It's happened when I click very quickly. I'm wondering if it's because of the "bounce" effect
I'm also noticing an occasional out-of-control glitchiness that happens at what seems like random times. Not sure what's causing that.
Ken Haduch
@khaduch
Jun 17 2016 02:13
@Chrono79 - oh no!!!! :frowning:
John
@JKilk
Jun 17 2016 02:14
function destroyer(arr) {
  var destroyers = [];
  for(var i = 1; i < arguments.length; i++){
    destroyers.push(arguments[i]);
  }
  var destroyedArr = arr.filter(function(arrayValue){
    for(var i = 0; i < destroyers.length; i++)
      return arrayValue != destroyers[i];
  });
  return destroyedArr;
}
i'm trying this for the seek and destroy but i don't think the loop works, what should i look into replacing it with?
Moisés Man
@moigithub
Jun 17 2016 02:15
@JKilk return break the loop
so it only looping once
John
@JKilk
Jun 17 2016 02:16
yes agreed
Moisés Man
@moigithub
Jun 17 2016 02:17
usually u only return true OR false insode the loop conditionally...
and the oposite value. outside the loop
Ken Haduch
@khaduch
Jun 17 2016 02:17
@micahbales - it is probably some kind of instability in using the setTimeout (not sure if that's the correct term, but that's the idea) - I think that things can affect the operation of the setTimeout for triggering, if the CPU is busy or something? I kind of read through the docs one time and remembered something like that?
Micah Bales
@micahbales
Jun 17 2016 02:17
@khaduch think there's a solution to it?
Moisés Man
@moigithub
Jun 17 2016 02:18

ie:

for (...
   if (some condition )
         return true
// after loop
return false

@JKilk

Jonathan Carroll
@gkcodeman
Jun 17 2016 02:22
is anyone else having issues with the help window?
sometimes bringing in code with back ticks and shift enters works fine but others it's like it doesn't take
Moisés Man
@moigithub
Jun 17 2016 02:25
chat mode vs compose mode maybe ?? ---------------------------------------------------------------------------------------->>>>
Ken Haduch
@khaduch
Jun 17 2016 02:25
@micahbales = there is a description on this page https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout "Reasons for delays longer than specified" that talks about a number of different issues. Not sure if there is a real problem in this way with your app, or if there is a solution? Maybe not using setTimeout would be a solution? I don't really have the understanding of how your code works, but it seems like there are a lot of setTimeout calls - I wouldn't be surprised at some bad interactions there? Again, without really being an expert, it's just a gut feeling...
Micah Bales
@micahbales
Jun 17 2016 02:26
@khaduch There are a ton of setTimeout calls. Is there an alternative you're aware of? Just using what I know! :)
Ken Haduch
@khaduch
Jun 17 2016 02:26
@gkcodeman - it seems to work, in general. There are times when it does things that violate the principle of least astonishment (as a former co-worker of mine used to say) - like when you get into editing a post and you are not in chat mode, it still posts when you hit enter, etc... And like @moigithub said - there are the two modes that give different types of interaction.
christianws
@christianws
Jun 17 2016 02:27
can anyone point me to some information about passing functions as parameters to functions?
Jonathan Carroll
@gkcodeman
Jun 17 2016 02:27
yeah it's def off and on
christianws
@christianws
Jun 17 2016 02:27
  • on the 'Finders Keepers'
Jonathan Carroll
@gkcodeman
Jun 17 2016 02:27
anyways I'm going to try to post my issue again
Diego Mayer
@Chrono79
Jun 17 2016 02:29
@CurlyWS it's like you had written the function passed as a parameter inside your function
Jonathan Carroll
@gkcodeman
Jun 17 2016 02:29

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

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

  return "10 or Under";
}

// Change this value to test
testGreaterThan(10);
ugh finally
so I'm not getting what this is asking me to do. It wan't me to: Add the greater than operator to the indicated lines so that the return statements make sense.
Ken Haduch
@khaduch
Jun 17 2016 02:30
@CurlyWS - you just do something like findElement([ some array ], function( arg ) { code }); - it is the callback function for the filter method.
Diego Mayer
@Chrono79
Jun 17 2016 02:30
@gkcodeman how would you write Over 100 with > ?
christianws
@christianws
Jun 17 2016 02:30
@gkcodeman so you would say
```
if(val>100){}
if(val < 10){}
Jonathan Carroll
@gkcodeman
Jun 17 2016 02:30
oh ;/ smh
sometimes it's just that easy and I have to go and make it harder
@CurlyWS @Chrono79 thanks
CamperBot
@camperbot
Jun 17 2016 02:31
gkcodeman sends brownie points to @curlyws and @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 201 | @curlyws |http://www.freecodecamp.com/curlyws
:star2: 1205 | @chrono79 |http://www.freecodecamp.com/chrono79
Jonathan Carroll
@gkcodeman
Jun 17 2016 02:32
I was thinking I had to pass the correct argument into the parameter that would cover all the basis which I knew off the top wasn't possible
*bases
christianws
@christianws
Jun 17 2016 02:32
@khaduch so how do you reference the parameter function within the outer function???
PeRoXiiDe
@PeRoXiiDe
Jun 17 2016 02:32
hey guys im in "Target the same element with multiple jQuery Selectors" but stuck on add only one class at a time to the same element three different ways. Any tips on this one would be appreciated
Ken Haduch
@khaduch
Jun 17 2016 02:32
@micahbales - good question. I haven't done this challenge yet - I just started tinkering with setting up the display, because I don't know how to do that. But I was thinking that using setInterrupt and having some type of "event queue" would be a more consistent way of controlling the behavior? That's just another gut feeling - I'll see what happens when I get around to coding on this one! :)
Jonathan Carroll
@gkcodeman
Jun 17 2016 02:32
good point
wait so I couldn't ref that parameter unless it is within that function correct
@CurlyWS ?
due to scoping
christianws
@christianws
Jun 17 2016 02:33
@gkcodeman let me try to reword my question hang on
Ken Haduch
@khaduch
Jun 17 2016 02:34
@CurlyWS - it is a function argument - in my editor for this one, I have this: function findElement(arr, func) {, so func will be the value of the function that you pass in, and you just use that as the callback, instead of writing Array.filter( function( value ) { whatever you are doing here; });
PeRoXiiDe
@PeRoXiiDe
Jun 17 2016 02:34
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }

  .thick-green-border {
    border-color: green;
    border-width: 10px;
    border-style: solid;
    border-radius: 50%;
  }

  .smaller-image {
    width: 100px;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>

<img class="smaller-image thick-green-border" src="https://bit.ly/fcc-relaxing-cat">

<p class="red-text">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class="red-text">Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.
</p>
Jonathan Carroll
@gkcodeman
Jun 17 2016 02:34
man this looks so simple now after messing with js
html /css you are so pretty
: )
96street
@96street
Jun 17 2016 02:35
Can somebody tell me why my getQuote function isn't executing when I click <button> ?
PeRoXiiDe
@PeRoXiiDe
Jun 17 2016 02:35

<script>
  $(document).ready(function() {
    $("button").addClass("animated shake btn-primary")
    $(".btn").addClass("animated shake btn-primary")
    $("#target1").addClass("animated shake btn-primary")
    });
</script>

<!-- Only change code above this line. -->

<div class="container-fluid">
  <h3 class="text-primary text-center">jQuery Playground</h3>
  <div class="row">
    <div class="col-xs-6">
      <h4>#left-well</h4>
      <div class="well" id="left-well">
        <button class="btn btn-default target" id="target1">#target1</button>
        <button class="btn btn-default target" id="target2">#target2</button>
        <button class="btn btn-default target" id="target3">#target3</button>
      </div>
    </div>
    <div class="col-xs-6">
      <h4>#right-well</h4>
      <div class="well" id="right-well">
        <button class="btn btn-default target" id="target4">#target4</button>
        <button class="btn btn-default target" id="target5">#target5</button>
        <button class="btn btn-default target" id="target6">#target6</button>
      </div>
    </div>
  </div>
</div>
christianws
@christianws
Jun 17 2016 02:35

@khaduch ok I almost understand I think
but with this code,

function findElement(arr, func) {


 console.log(num);



}

findElement([1, 2, 3, 4], function(num){ return num % 2 === 0; });

can you explain at what point the function takes 'num'. Do you have to declare num from outside the function? what if you never declare it?

PeRoXiiDe
@PeRoXiiDe
Jun 17 2016 02:35
sorry pasted wrong one
Ken Haduch
@khaduch
Jun 17 2016 02:35
@PeRoXiiDe - is there supposed to be some <script> in there? I forget - I'll have to go and look at that challenge...
Micah Bales
@micahbales
Jun 17 2016 02:36
I'll have to take a look at setInterrupt. Thanks, @khaduch
CamperBot
@camperbot
Jun 17 2016 02:36
micahbales sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1338 | @khaduch |http://www.freecodecamp.com/khaduch
Jonathan Carroll
@gkcodeman
Jun 17 2016 02:36
@khaduch second one posted had the $
PeRoXiiDe
@PeRoXiiDe
Jun 17 2016 02:36
@khaduch yeah sorry i pasted the wrong code I went to the regular help room first
Ken Haduch
@khaduch
Jun 17 2016 02:37
@PeRoXiiDe - okay. You have to only have one class listed in each .addClass() method, as per the instructions. Not all three in each one.
David Halls
@DavidHalls
Jun 17 2016 02:37
@PeRoXiiDe it only wants you to add one class each time, you are adding 3
Jonathan Carroll
@gkcodeman
Jun 17 2016 02:38
@PeRoXiiDe does the base class .btn actually need to be manipulated in that problem? I can't remember
Ken Haduch
@khaduch
Jun 17 2016 02:39
@PeRoXiiDe - there are three different ways to "target" the elements:
  • "button" - will select all button element (first way)
  • ".btn" - will select all elements with the class .btn (second way)
  • "#target1" - will select the element (should only be one element, IDs are unique) with that ID - (third way)
    One class in each of the selectors.
John
@JKilk
Jun 17 2016 02:39
hey so i finished seek and destroy challenge but i'm curious what other solutions people came up with, is there a way i can browse them?
Jonathan Carroll
@gkcodeman
Jun 17 2016 02:40
@JKilk congrats on completing it, hope to be there soon
David Halls
@DavidHalls
Jun 17 2016 02:40
@JKilk PM me yours and ill PM you mine
PeRoXiiDe
@PeRoXiiDe
Jun 17 2016 02:40
@khaduch yikes ok so are you saying I should choose one of these three
Ken Haduch
@khaduch
Jun 17 2016 02:40
@JKilk - I don't know if you can browser other's solutions - you might be able to accses their freecodecamp.com page. If you want to look at some recommended solutions, check the wiki for that challenge - they usually provide hints and "spoilers" with the best solutions.
Josh Terry
@jaywikid
Jun 17 2016 02:40
Can someone help me with Return Early Pattern for Functions?
not quite sure what its wanting me to do....
John
@JKilk
Jun 17 2016 02:41
cool will do Ken thanks, also will PM you david
Leo
@Leodhy
Jun 17 2016 02:41

function reverseString(str) {
return str;
}

var arr=[];
var str="";
str=reverseString("hello");
arr=str.split().reverse();
str=arr.join();

Ken Haduch
@khaduch
Jun 17 2016 02:41

@PeRoXiiDe - no, the challenge is to use all three, but with a different class in each one.

Add the animated class to all elements with type button.

Add the shake class to all the buttons with class .btn.

Add the btn-primary class to the button with id #target1.

You have the selectors, you just have to remove the extraneous classes from each one.

Leo
@Leodhy
Jun 17 2016 02:41
what's wrong of my code
Jonathan Carroll
@gkcodeman
Jun 17 2016 02:41
@CurlyWS you get busy? were you wanting to rephrase question still?
John
@JKilk
Jun 17 2016 02:41
ken how do i PM you lol
Leo
@Leodhy
Jun 17 2016 02:42
it is asked to turn a string to an array then reverse it, finally turn the array to a new string
Chris Cullen
@123xylem
Jun 17 2016 02:43
checkCashRegister(20.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
Im trying to make a count only add the number vals of this array
I have tried a nested for loop but cant seem to get it working.. Any Idea how to make count+= the numbers in these arrays?
John
@JKilk
Jun 17 2016 02:43
hey @Leodhy i dont think reverseString() is a function
Ken Haduch
@khaduch
Jun 17 2016 02:43
@Leodhy - the code that you are writing should be within the curly braces of the function reverseString body.
John
@JKilk
Jun 17 2016 02:44
what you want to do is convert the string into an array, reverse the array, convert back to string
David Halls
@DavidHalls
Jun 17 2016 02:45
@JKilk i just invited you to a private room with my solution
John
@JKilk
Jun 17 2016 02:45
okay thanks david how do i go about accessing that
Leo
@Leodhy
Jun 17 2016 02:45
thank you guys, i should write the code in the function
David Halls
@DavidHalls
Jun 17 2016 02:45
click on the icon to the left that looks like a person
Jonathan Carroll
@gkcodeman
Jun 17 2016 02:46
make sure to thank them followed by their @name that way they get points if you can
CamperBot
@camperbot
Jun 17 2016 02:46
gkcodeman sends brownie points to @name :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for name
Jonathan Carroll
@gkcodeman
Jun 17 2016 02:46
not to be bossy, I just know I appreciate it when people do :)
Josh Terry
@jaywikid
Jun 17 2016 02:47
how do i make a val less than 0 show as undefined?
John
@JKilk
Jun 17 2016 02:47
make an uninstantiated variable and return it following an if statment for <0 maybe
honestly can't figure out how to access your private room and its really demoralizing me
David Halls
@DavidHalls
Jun 17 2016 02:49
function destroyer(arr) {
  // Remove all the values
 var args = Array.from(arguments);
 args.splice(0,1);

  return arr.filter(function(e){
      return args.indexOf(e) === -1;
  });
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Josh Terry
@jaywikid
Jun 17 2016 02:49
Heres my challenge Return Early Pattern for Functions
PeRoXiiDe
@PeRoXiiDe
Jun 17 2016 02:49
@khaduch Wow thanks, I was reading that all wrong. Think its probably time to go to sleep. Thank you, thank you, thank you
CamperBot
@camperbot
Jun 17 2016 02:49
peroxiide sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1339 | @khaduch |http://www.freecodecamp.com/khaduch
John
@JKilk
Jun 17 2016 02:49
ah okay i did something similar, i was mostly curious if there was a different way to do it other than using indexOf
thanks @Byzgig
CamperBot
@camperbot
Jun 17 2016 02:49
jkilk sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 326 | @byzgig |http://www.freecodecamp.com/byzgig
christianws
@christianws
Jun 17 2016 02:52

@gkcodeman @khaduch ok I almost understand I think
but with this code,

function findElement(arr, func) {


 console.log(num);



}

findElement([1, 2, 3, 4], function(num){ return num % 2 === 0; });

can you explain at what point the function takes 'num'. Do you have to declare num from outside the function? what if you never declare it?

Mauricio Bonetti
@mauriciocoder
Jun 17 2016 02:53
@CurlyWS just do func(10), for example
Josh Terry
@jaywikid
Jun 17 2016 02:53
Howdo I get a - var to read out as NaN in this equation?

// Setup
function abTest(a, b) {
// Only change code below this line

// Only change code above this line

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

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

Diego Mayer
@Chrono79
Jun 17 2016 02:53
@CurlyWS num is the param of that function, it's already declared there
christianws
@christianws
Jun 17 2016 02:54
@mauriciocoder @Chrono79 It seems I havn't had enough sleep easy stuff thanks
CamperBot
@camperbot
Jun 17 2016 02:54
curlyws sends brownie points to @mauriciocoder and @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 296 | @mauriciocoder |http://www.freecodecamp.com/mauriciocoder
:star2: 1206 | @chrono79 |http://www.freecodecamp.com/chrono79
Connor Hastey-Palindat
@cpalindat
Jun 17 2016 02:54
Can anyone tell me why source[j] returns undefined in this code?

function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line

  //console.log(Object.keys(collection).length);
  for (var i = 0; i < Object.keys(collection).length; i++) {
    for (var j = 0; j < Object.keys(source).length; j++) {
      console.log(collection[i], source[j]);
    }
  }
  // Only change code above this line
  return arr;
}

whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Ken Haduch
@khaduch
Jun 17 2016 02:54
@PeRoXiiDe - sometimes it does get to be a little hard to see what's going on. It is helpful to study the test cases and results - they tell you things that you might not have gotten from the first reading through the instructions, I've found that to be very helpful for some of the challenges where I just was not getting it... :)
Mauricio Bonetti
@mauriciocoder
Jun 17 2016 02:55
@CurlyWS You can pass whatever number you want, just calling func(10), or func(12), or func(numberThatYouInitializedBefore)...
Hassaan Hafeez
@HassHz
Jun 17 2016 02:55
@ConnHurr Source isn't an array?
Diego Mayer
@Chrono79
Jun 17 2016 02:55
@ConnHurr yes, that's why @HassHz
Mauricio Bonetti
@mauriciocoder
Jun 17 2016 02:56
@ConnHurr source is an object not an array, in order to reach it, you may use another approach
christianws
@christianws
Jun 17 2016 02:57
@ConnHurr because if Object.keys(source) does not exist then it will return undefined.
so for your function call source is last:"Capulet". If capulet is not found then it will throw undefined
I assume it is something to do with that
console.log each stage so you can identify the problem
Ken Haduch
@khaduch
Jun 17 2016 02:57
@CurlyWS - if you read the description of the filter method, you'll see that it always passes some parameters when it calls the callback. The first one (if I remember correctly) is the number or the array element that you are work on - the value of that array element.
Diego Mayer
@Chrono79
Jun 17 2016 02:57
@jaywikid reread that challenge instructions
Mauricio Bonetti
@mauriciocoder
Jun 17 2016 02:57
@ConnHurr I did something to deal with that some time ago, just take a look: ''' var pages = data.query.pages;
var links = "";
for (pageId in pages) {
var extract = pages[pageId].extract; '''
CamperBot
@camperbot
Jun 17 2016 02:57
:bulb: to format code use backticks! ``` more info
christianws
@christianws
Jun 17 2016 02:58
@khaduch I don't understand. Why is the filter method relevant to the task?
Josh Terry
@jaywikid
Jun 17 2016 02:58
@Chrono79 the instructions are "Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined."
Connor Hastey-Palindat
@cpalindat
Jun 17 2016 02:58
Okay thanks guys i'll find a work around
Ken Haduch
@khaduch
Jun 17 2016 02:58
@CurlyWS - isn't it? I forget which one we are looking at, perhaps?
Connor Hastey-Palindat
@cpalindat
Jun 17 2016 02:59
the only thing is both collection and source are associative arrays and it works for collection but not source
Josh Terry
@jaywikid
Jun 17 2016 02:59
not sure what functions to use
christianws
@christianws
Jun 17 2016 02:59
@khaduch possibly it suggests using it in 'Finders Keepers'
Connor Hastey-Palindat
@cpalindat
Jun 17 2016 02:59
Wait nveermind I see the error
Ken Haduch
@khaduch
Jun 17 2016 02:59
@CurlyWS - yes, it suggests using it - I'm not sure what they give you to start with?
Mauricio Bonetti
@mauriciocoder
Jun 17 2016 02:59
@ConnHurr When you use for (key in object) you have the key of the object as a variable, so you just need to do object[key]
Diego Mayer
@Chrono79
Jun 17 2016 02:59
@jaywikid yes, so why did you said this: Howdo I get a - var to read out as NaN in this equation?
I think I get it now, look the square root of a number less than 0 gives you NaN
So you have to catch a or b less than 0 before that calculation and return undefined
you have to write an if with 2 conditions joined with a logical operator
Mauricio Bonetti
@mauriciocoder
Jun 17 2016 03:00
@ConnHurr Do you see what I mean?
Ken Haduch
@khaduch
Jun 17 2016 03:01
@CurlyWS - oh, yeah, you're supposed to use it, at least they suggest (recommend) it?
Josh Terry
@jaywikid
Jun 17 2016 03:02
@Chrono79 so write an if thats a<0 and one thats b<0?
christianws
@christianws
Jun 17 2016 03:02
@khaduch this is what I just solved the bonfire with,
function findElement(arr, func) {

  for(var i in arr){     
       if (func(arr[i])){
           return arr[i];
       }    
  }

}

findElement([1, 2, 3, 4], function(num){ return num % 2 === 0; });
Connor Hastey-Palindat
@cpalindat
Jun 17 2016 03:02
@mauriciocoder so is this valid then if I wanted to try to do something similar:
  for (var i = 0; i < Object.keys(collection).length; i++) {
    for (var j = 0; j < Object.keys(source).length; j++) {
      console.log(collection[i], Object.keys(source)[j]);
      var test = Object.keys(source)[j];
      console.log(test, collection[test]);
    }
  }
Ken Haduch
@khaduch
Jun 17 2016 03:03
@CurlyWS - but you could do this without .filter I guess. Like what you did, if it passes, it's good!
Connor Hastey-Palindat
@cpalindat
Jun 17 2016 03:03
I mean to ask if I can access collection[test]?
Its giving me undefined but I feel like I have the right logic
christianws
@christianws
Jun 17 2016 03:03
@khaduch yeah so did you do it using filter? can I see how you did it?
Diego Mayer
@Chrono79
Jun 17 2016 03:03
@jaywikid no, only one with both conditions
Ken Haduch
@khaduch
Jun 17 2016 03:06

@CurlyWS - these are the key lines from my solution:

  num = arr.filter(func);
  return num.shift();

since filter returns an array, and we want to return the first element, I shift it off. I could probably simplify that to one line?

christianws
@christianws
Jun 17 2016 03:07
@khaduch great makes sense. Thanks I appreciate it
CamperBot
@camperbot
Jun 17 2016 03:07
curlyws sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1340 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Jun 17 2016 03:07
@CurlyWS
  return arr.filter(func).shift();
christianws
@christianws
Jun 17 2016 03:07

@khaduch maybe write

return arr.filter(func).shift();

?

Ken Haduch
@khaduch
Jun 17 2016 03:07
@CurlyWS :) I just did... :)
Diego Mayer
@Chrono79
Jun 17 2016 03:08
@khaduch yes, return arr.filter(func)[0]; it's another way of doing the same
christianws
@christianws
Jun 17 2016 03:08
@khaduch :P good stuff
Ken Haduch
@khaduch
Jun 17 2016 03:09
@CurlyWS @Chrono79 - and you can also use [0] as Diego shows. Is that better, @Chrono79 ?
Diego Mayer
@Chrono79
Jun 17 2016 03:09
dunno, I think they're the same
christianws
@christianws
Jun 17 2016 03:10
I assume faster
As probably my original method was. Although looks primitive compared to this elegant filter solution
Islam Ibakaev
@dagman
Jun 17 2016 03:12
@CurlyWS what is the bonfire name?
for which u provide solution
above
Diego Mayer
@Chrono79
Jun 17 2016 03:13
I think it was finders keepers
Dan
@dcgoings
Jun 17 2016 03:13
can someone explain how to use String.fromCharCode()? im just really not understanding the documentation
Islam Ibakaev
@dagman
Jun 17 2016 03:14
@Chrono79 thx
CamperBot
@camperbot
Jun 17 2016 03:14
dagman sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1207 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 17 2016 03:15
@dcgoings "A".charCodeAt(0) is 65 and String.fromCharCode(65) is "A"
Ken Haduch
@khaduch
Jun 17 2016 03:15
@CurlyWS - I think that sometimes the "elegant" solutions are much slower than the straightforward for loop solutions - at least I saw someone posting something about that in some forum or text book. But I think that the statement was made that you shouldn't worry about speed unless you need to - I'm sure that if you're processing a million records or something, it's significant.
christianws
@christianws
Jun 17 2016 03:16
@khaduch that's true
@khaduch did you use the Filter method also in the next task? 'Drop It?'
@khaduch I'm heading towards just using another loop but am curious to whether you managed to employ it again. Because filter return an array right?
Dan
@dcgoings
Jun 17 2016 03:18
@Chrono79 that makes a bit more sense, however, how would i combine multiple fromCharCode() to one string?
Ken Haduch
@khaduch
Jun 17 2016 03:18
@CurlyWS - no, I didn't - the fanciest thing I used was .shift()
and a while loop
Diego Mayer
@Chrono79
Jun 17 2016 03:18
@dcgoings you could use a loop
christianws
@christianws
Jun 17 2016 03:18
@khaduch I think that is appropriate here also
Dan
@dcgoings
Jun 17 2016 03:19
like.. in my head, i keep wanting to do something like
var decoded = "";
decoded += String.fromCharCode(str.charCodeAt(i+13));"
but i feel like that's giving me errors
christianws
@christianws
Jun 17 2016 03:19
@dcgoings it's something along them lines
Dan
@dcgoings
Jun 17 2016 03:19
hmm
Diego Mayer
@Chrono79
Jun 17 2016 03:19
@dcgoings you're doing the +13 wrong
christianws
@christianws
Jun 17 2016 03:19
@dcgoings there is really clever way of doing this using the % operator. Where the code cycles around the 26 alphabet characters
Dan
@dcgoings
Jun 17 2016 03:20
@CurlyWS yeah, i did that in my java class.. but im still getting used to js and didn't want to push that idea just yet.
@Chrono79 how so?
Diego Mayer
@Chrono79
Jun 17 2016 03:21
you first get the code and then add (or substract) the 13
Dan
@dcgoings
Jun 17 2016 03:21
oh nvm
khaduch @khaduch - fading out here... :sleepy: - going to move along for the night... happy coding everyone!!!!
Diego Mayer
@Chrono79
Jun 17 2016 03:21
bye
christianws
@christianws
Jun 17 2016 03:22
@dcgoings I think I just did it using if statements.
So if(char < 26) add 13)
else{// char is higher than 13 add however much you can reset char to 1 then add what is left
sorry I made an erro
if(char <13){ add 13}
maybe that helps
Diego Mayer
@Chrono79
Jun 17 2016 03:22
they are between 65 and 90, the capital letters code, but the idea is right, if substracting 13 it falls below 65 you should add 13 instead
Islam Ibakaev
@dagman
Jun 17 2016 03:23
@khaduch @CurlyWS i think this one is better
function findElement(arr, func) {
    for(var i = 0, len = arr.length; i < len; i++) {
      if(func(arr[i])) return arr[i];
    }
    return;
}
christianws
@christianws
Jun 17 2016 03:24

@dagman yeah very similar to my original solution

for(var i in arr){     
       if (func(arr[i])){
           return arr[i];
       }    
  }

but less elegant than using filer

*filter
Islam Ibakaev
@dagman
Jun 17 2016 03:25
@CurlyWS it is not the same
@CurlyWS filter would be longer
Diego Mayer
@Chrono79
Jun 17 2016 03:25
@dagman it's the same (I think your 2 solutions from above)
christianws
@christianws
Jun 17 2016 03:26
@dagman filter is different. My solution provided above is the same as yours. Perhaps slightly faster
Dan
@dcgoings
Jun 17 2016 03:26
jesus
function rot13(str) { // LBH QVQ VG!
  var decoded = "";

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

  }
  return decoded;
 }

// Change the inputs below to test
rot13("SERR PBQR PNZC");
at least it works
but fml
christianws
@christianws
Jun 17 2016 03:26
@dcgoings why fml man?
Dan
@dcgoings
Jun 17 2016 03:27
i feel like there are 10x more efficient ways of doing some of these algs compared to the way i did it
Islam Ibakaev
@dagman
Jun 17 2016 03:27
@CurlyWS yep your solution much better then what filter do
@CurlyWS so u d better stick with yours
christianws
@christianws
Jun 17 2016 03:27
@dcgoings yeah I felt the same. There is a way of using modulus but I havn't found a way of even searching for that content yet
can anyone here explain how to cycle through the alphabet +13 using %???
I will find the example I saw
Dan
@dcgoings
Jun 17 2016 03:28
i did it in my java class, cant remember exactly though
Islam Ibakaev
@dagman
Jun 17 2016 03:29
@dcgoings what is bonfire name?
Dan
@dcgoings
Jun 17 2016 03:29
caesars cipher
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 03:29
@CurlyWS
65+(str.charCodeAt(0)+13)%65%13
christianws
@christianws
Jun 17 2016 03:29
@chaitanyaashtekar that's it. I don't really understand it though
Diego Mayer
@Chrono79
Jun 17 2016 03:30
str.charCodeAt(0)%26+65
if str.charCodeAt(0) is 65, 65%26 is 13 + 65, so A -> N
if str.charCodeAt(0) is 90, 90%26 is 12 + 65 = 90 -13, so Z -> M
Islam Ibakaev
@dagman
Jun 17 2016 03:32
i did this
function rot13(str) {
  return str.split('').map(function(el) {
    var code = el.charCodeAt(0);
    if(code >= 65 && code <= 90 || code >= 97 && code <= 122){
      return String.fromCharCode(getCorrectCode(el.charCodeAt(0) + 13));
    }
    return el;
  }).join('');

  function getCorrectCode(n) {
    return n > 90 ? n =  n - 26 : n;
  }
}
Diego Mayer
@Chrono79
Jun 17 2016 03:37
In ruby there is a string method called tr, that does it like this:
def rot13(value)
    return value.tr("a-z", "n-za-m")
end
Dan
@dcgoings
Jun 17 2016 03:38
lol of course there is
MrBurks
@mrburks
Jun 17 2016 03:41
Word Blanks - Not really understanding what they want me to do.
Diego Mayer
@Chrono79
Jun 17 2016 03:42
@mrburks Read Mad Libs link and review this challenge: https://www.freecodecamp.com/challenges/constructing-strings-with-variables
MrBurks
@mrburks
Jun 17 2016 03:43
yeah I tried it that way and still nothing
var newStr = "This is a " + myNoun + "about the lorem and the ipsum. They were "+ myAdjective +"Travelers of time and space. However the lorem " + myVerb +"too fast for the Ipsum and left the ipsum behind. So the ipsum had to catch up " + myAdverb +"in order to keep up with the Lorem.";
am I supposed to break it into several smaller strings because I tried that first
Diego Mayer
@Chrono79
Jun 17 2016 03:45
@mrburks you're missing some spaces
myNoun + "abou after the " for instance
and should the name of the var be newStr?
MrBurks
@mrburks
Jun 17 2016 03:47
that is because the space is at the end of the prev string
I don't know what the name of the var should be
Diego Mayer
@Chrono79
Jun 17 2016 03:47
@mrburks no, that space is before the string contained in myNoun
help word blanks
CamperBot
@camperbot
Jun 17 2016 03:48

:point_right: challenge word blanks [wiki]

Challenge Word Blanks

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

:pencil: read more about challenge word blanks on the FCC Wiki

Diego Mayer
@Chrono79
Jun 17 2016 03:49
 var result = "";
  // Your code below this line

  // Your code above this line
  return result;
It should be result
when you join strings with vars, you have to leave spaces before and after the var
MrBurks
@mrburks
Jun 17 2016 03:52
it seem like they want me to use the var result but that var is already define in the section Not where my code is to go.
Diego Mayer
@Chrono79
Jun 17 2016 03:52
@mrburks just use it, it's there for you to use it
MrBurks
@mrburks
Jun 17 2016 03:52
didn't work
Diego Mayer
@Chrono79
Jun 17 2016 03:53
@mrburks let's see your code again
MrBurks
@mrburks
Jun 17 2016 03:53

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
var result = "This is a " + myNoun + "about the lorem and the ipsum. They were "+ myAdjective +" travelers of time and space. However the lorem " + myVerb +" too fast for the Ipsum and left the ipsum behind. So the ipsum had to catch up " + myAdverb +"in order to keep up with the Lorem.";

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("cat", "little", "hit", "slowly");

Leo
@Leodhy
Jun 17 2016 03:54

function titleCase(str) {
str.toLowerCase();
return str;
}

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

Diego Mayer
@Chrono79
Jun 17 2016 03:54
@mrburks no need to declare result again, delete var, you haven't added the spaces where I told you to
Leo
@Leodhy
Jun 17 2016 03:54
why the result of this program cannot be lowercased
Diego Mayer
@Chrono79
Jun 17 2016 03:55
@Leodhy toLowerCase() returns a different string, it doesn't modify str
MrBurks
@mrburks
Jun 17 2016 03:55
yeah that didn't work either

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {

// Your code below this line
var result = "This is a " + myNoun + "about the lorem and the ipsum. They were "+ myAdjective +" travelers of time and space. However the lorem " + myVerb +" too fast for the Ipsum and left the ipsum behind. So the ipsum had to catch up " + myAdverb +"in order to keep up with the Lorem.";

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("cat", "little", "hit", "slowly");

Leo
@Leodhy
Jun 17 2016 03:55
ok.thx
Vamshi Gudipati
@vamshikrishna144
Jun 17 2016 03:55
Im trying to write code for reverse of a string . Can you please tell me what is wrong with this?
function FirstReverse(str) {

  var reverse;
  for(i=0;i<str.length+1;i++){
      reverse[i] = (str[str.length-i]);
  }
  return str;
}

FirstReverse('Hello world');
Diego Mayer
@Chrono79
Jun 17 2016 03:56
@mrburks go back to your previous version, delete var before result = "This is a " + myNoun + "a...
Not the var result = ""; above your code
And for God's sake, add the spaces pretty please
Natan Corro
@natancorro
Jun 17 2016 03:56
Hello im in the random quote challenge, any help pls
MrBurks
@mrburks
Jun 17 2016 03:57
0_o
Diego Mayer
@Chrono79
Jun 17 2016 03:58
@mrburks
"about <-here
"in order to keep <- here
see the " touching the text?
NixonRichard
@NixonRichard
Jun 17 2016 03:59
return  str.split().reverse().join();
@vamshikrishna144
Diego Mayer
@Chrono79
Jun 17 2016 03:59
@vamshikrishna144 if you return str, what are you using reverse for?
Vamshi Gudipati
@vamshikrishna144
Jun 17 2016 04:00
@Chrono79 return reverse;
my bad
Diego Mayer
@Chrono79
Jun 17 2016 04:00
@NixonRichard that's no good
Vamshi Gudipati
@vamshikrishna144
Jun 17 2016 04:00
@NixonRichard I know it can be done in that way but I want to do it this way
Diego Mayer
@Chrono79
Jun 17 2016 04:00
@vamshikrishna144 also, use strings if you use a loop
Vamshi Gudipati
@vamshikrishna144
Jun 17 2016 04:00
@NixonRichard THank you though
CamperBot
@camperbot
Jun 17 2016 04:00
vamshikrishna144 sends brownie points to @nixonrichard :sparkles: :thumbsup: :sparkles:
:cookie: 12 | @nixonrichard |http://www.freecodecamp.com/nixonrichard
Diego Mayer
@Chrono79
Jun 17 2016 04:00
@vamshikrishna144 use += to add a letter
Vamshi Gudipati
@vamshikrishna144
Jun 17 2016 04:00
@Chrono79 thank you
CamperBot
@camperbot
Jun 17 2016 04:00
vamshikrishna144 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1208 | @chrono79 |http://www.freecodecamp.com/chrono79
NixonRichard
@NixonRichard
Jun 17 2016 04:00
yeh
Diego Mayer
@Chrono79
Jun 17 2016 04:01
@NixonRichard you forgot the "" where they're needed
NixonRichard
@NixonRichard
Jun 17 2016 04:01
oh right
MrBurks
@mrburks
Jun 17 2016 04:01
ok i guess spacing was an issue thanks @Chrono79
CamperBot
@camperbot
Jun 17 2016 04:01
mrburks sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1209 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 17 2016 04:01
@mrburks no problem
NixonRichard
@NixonRichard
Jun 17 2016 04:02
im having problems with check for palindromes
Diego Mayer
@Chrono79
Jun 17 2016 04:02
code or treat
I guess I should save that for Halloween
NixonRichard
@NixonRichard
Jun 17 2016 04:05
every explanation s in english
really tough to understand
Diego Mayer
@Chrono79
Jun 17 2016 04:06
a palindrome is a word (or a group of words) that (cleaned of all that's not a letter or a number) could be read the same from left to right or right to left
NixonRichard
@NixonRichard
Jun 17 2016 04:06
Not that i mean the code s explantion
The toLowerCase() method to return the calling string value converted to lowercase.
The replace() method to return a new string with some or all matches of a pattern replaced by a replacement. We will use one of the RegExp we just created earlier.
The split() method splits a String object into an array of strings by separating the string into sub strings.
The reverse() method reverses an array in place. The first array element becomes the last and the last becomes the first.
The join() method joins all elements of an array into a string.
Diego Mayer
@Chrono79
Jun 17 2016 04:07
do you know what each method does?
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 04:08
@
NixonRichard
@NixonRichard
Jun 17 2016 04:08
toLowerCase converts things into lower cases ?
Diego Mayer
@Chrono79
Jun 17 2016 04:08
yes
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 04:08
@NixonRichard what your language ?
NixonRichard
@NixonRichard
Jun 17 2016 04:09
Vietnamese
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 04:09
okay
NixonRichard
@NixonRichard
Jun 17 2016 04:09
i dont understand the replace
split reverse and join s okay
just the replace
Diego Mayer
@Chrono79
Jun 17 2016 04:10
do you know what replace means?
it changes one thing for other
NixonRichard
@NixonRichard
Jun 17 2016 04:10
yes
Diego Mayer
@Chrono79
Jun 17 2016 04:10
in this case, you need to get rid of all that's not a letter or a number, like punctuation, spaces and such
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 04:10
@Chrono79 i think he doesnt understand how it works(RegExp)
Diego Mayer
@Chrono79
Jun 17 2016 04:11
well, that's not what he said, but could be, that's the most strange thing there
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 04:11
@NixonRichard have you read the regular expressions chapter man ? its available in many languages. here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
@Chrono79 yup/many ppl have difficulting in grasping rgular expressions
NixonRichard
@NixonRichard
Jun 17 2016 04:12
ya
do i have to get how it works or just what it does ?
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 04:13
@NixonRichard you have to understand how it works
NixonRichard
@NixonRichard
Jun 17 2016 04:15
It helps me code better ?
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 04:15
yup
NixonRichard
@NixonRichard
Jun 17 2016 04:17
Okay then
thx guyz
96street
@96street
Jun 17 2016 04:30
Accessing Nested Objects in JSON
Why isn't this answer working? var gloveBoxContents = "myStorage['glove box']";
Srinivasan
@kksrini89
Jun 17 2016 04:33
Which book can have as reference for JavaScript? Any guidance pls...
himanshu mittal
@himanshu081996
Jun 17 2016 04:34
what iswrong in below code of search and replace:
function myReplace(str, before, after) {
  var After=after.split("");
 if(before.charCodeAt(0)>95 && before.charCodeAt(0)<123 )
  str=str.replace(before, after);
  else if(before.charCodeAt(0)>64 && before.charCodeAt(0)<91){
    if(after.charCodeAt(0)>64 && after.charCodeAt(0)<91){
      str=str.replace(before, after);
    }
    else {
    After=After.splice(0,1,String.fromCharCode(after.charCodeAt(0)-32));
    After=After.join("");
    str=str.replace(before,After);}
  }
  return str;
}

myReplace("A quick brown fox Jumped over the lazy dog", "Jumped", "leaped");
@kksrini89 the missing manual is good book
anyone ???
christianws
@christianws
Jun 17 2016 04:40

can someone explain to me this code for flattening an array,

var falttened = [].concat.apply([], arr);

what is the first parameter in apply doing (the [ ]) ? it doesn't seem to be doing anything?

Srinivasan
@kksrini89
Jun 17 2016 04:43
@himanshu081996 oh ok fine. Will wait some more comments on that from campers.
Diego Mayer
@Chrono79
Jun 17 2016 04:43
@96street "myStorage['glove box']" is a string
myStorage['glove box'] is missing some other properties between myStorage and ['glove box']
96street
@96street
Jun 17 2016 04:47
ah yep you're right
96street
@96street
Jun 17 2016 04:56
How to I get my quoteGenerator to tweet the actual quote and not the codepen? http://codepen.io/kingdezz/pen/mEJPLN/
FM
@mafelix
Jun 17 2016 04:58
I learned something new today
bitgrower
@bitgrower
Jun 17 2016 04:59
@CurlyWS, I would look up the concat & apply methods ... my guess it, it is initializing the array to an empty array ...
only one, @mafelix ?
FM
@mafelix
Jun 17 2016 04:59
only one?
ya only one.
bitgrower
@bitgrower
Jun 17 2016 05:00
@kksrini89
help javascript resources
CamperBot
@camperbot
Jun 17 2016 05:00
no wiki entry for: javascript resources
bitgrower
@bitgrower
Jun 17 2016 05:00
help javascript
CamperBot
@camperbot
Jun 17 2016 05:00

:point_right: challenge add new properties to a javascript object [wiki]

Add New Properties to a JavaScript Object

You can add new properties to existing JavaScript objects the same way you would modify them. Here is how:

myDog.bark = "woof-woof";

:pencil: read more about challenge add new properties to a javascript object on the FCC Wiki

bitgrower
@bitgrower
Jun 17 2016 05:00
^^^ @kksrini89
oops ... wrong
dang it ...
This message was deleted
CamperBot
@camperbot
Jun 17 2016 05:01
no wiki entry for: javascript resource
bitgrower
@bitgrower
Jun 17 2016 05:01
This message was deleted
help js resources
bitgrower
@bitgrower
Jun 17 2016 05:02
finally ... ^^^^ @kksrini89
Zamua Nasrawt
@Zamua
Jun 17 2016 05:02
Is anyone here working on the backend projects?
Srinivasan
@kksrini89
Jun 17 2016 05:02
@bitgrower oh nice
bitgrower
@bitgrower
Jun 17 2016 05:02
@Zamua there is a backend room ...
help rooms
CamperBot
@camperbot
Jun 17 2016 05:02

:point_right: help rooms [wiki]

FreeCodeCamp Chat Rooms

Help Rooms

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

Choose the right room for your questions!

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

back to top ↑

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

Zamua Nasrawt
@Zamua
Jun 17 2016 05:02
@bitgrower thanks! <33
CamperBot
@camperbot
Jun 17 2016 05:02
zamua sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1104 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Jun 17 2016 05:02
yw !!!
it won't be as active as this one, in general, but when folks are there, you'll usually find people who know exactly how to help you -- here, it's a bit more hit or miss ...
Zamua Nasrawt
@Zamua
Jun 17 2016 05:05
ahh gotcha, i'll check it out a couple times a day and see if anyone can help me out haha
k_vdp
@1koenvdp
Jun 17 2016 05:06
This message was deleted
CamperBot
@camperbot
Jun 17 2016 05:06
Sorry, can't find a bonfire called falsy bouncer remove all falsy values from an array could this lead 2 a solution why doesnt it work yet. [ Check the map? ]
Krishna
@krishnakumar360
Jun 17 2016 05:08

Nesting For Loops

getting Erros

code

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=product*arr[i];
}
}
// Only change code above this line
return product;
}

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

k_vdp
@1koenvdp
Jun 17 2016 05:08

Bonfire, Falsy Bouncer, "Remove all falsy values from an array." Could this lead 2 a solution? & why doesn't it work (yet?) function bouncer(arr) {

for(var i=0; i<arr.length;i++){
if (new Boolean(arr[i])=false)
arr[i]=false;
}

}

var arrFiltered = arr.filter(bouncer);

return arrFiltered;

bouncer([7, "ate", "", false, 9]);

CamperBot
@camperbot
Jun 17 2016 05:08
Sorry, can't find a bonfire called falsy bouncer remove all falsy values from an array could this lead 2 a solution why doesnt it work yet function bouncerarr forvar i0 iarrlengthi if new booleanarrifalse arrifalse var arrfiltered arrfilterbouncer return arrfilteredbouncer7 ate false 9. [ Check the map? ]
himanshu mittal
@himanshu081996
Jun 17 2016 05:09
@krishnakumar360 use product= product*arr[i][j];
k_vdp
@1koenvdp
Jun 17 2016 05:09
This message was deleted
Krishna
@krishnakumar360
Jun 17 2016 05:10
@himanshu081996 Thanks Bro
CamperBot
@camperbot
Jun 17 2016 05:10
krishnakumar360 sends brownie points to @himanshu081996 :sparkles: :thumbsup: :sparkles:
:cookie: 263 | @himanshu081996 |http://www.freecodecamp.com/himanshu081996
k_vdp
@1koenvdp
Jun 17 2016 05:10
falsy bouncer --.jpg
onfire, Falsy Bouncer, "Remove all falsy values from an array." Could this lead 2 a solution? & why doesn't it work (yet?)
himanshu mittal
@himanshu081996
Jun 17 2016 05:11
@1koenvdp use filter
k_vdp
@1koenvdp
Jun 17 2016 05:12
@himanshu081996 I did allready-I guess? I wrote arr.filter(bouncer)
himanshu mittal
@himanshu081996
Jun 17 2016 05:14
you are not using filter correctly @1koenvdp
go through links provided by your challenge @1koenvdp
k_vdp
@1koenvdp
Jun 17 2016 05:16
@himanshu081996 ok, I'll look at it, hopefully I'll see what's wrong
himanshu mittal
@himanshu081996
Jun 17 2016 05:16
yup u will c
k_vdp
@1koenvdp
Jun 17 2016 05:21
@himanshu081996 I'm sorry. I really don't see what's wrong :-S
Jason Shoemaker
@kutsuya1
Jun 17 2016 05:23
@1koenvdp don't need new I think
= vs ==
ranranking
@ranranking
Jun 17 2016 05:27
hello, for the collection record challenge, I have the function set up like this:
function updateRecords(id, prop, value) {

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

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

  return collection;
}
but it is letting pass. I don't understand why. I tested, all the functions are working just as required
it is not letting me pass
k_vdp
@1koenvdp
Jun 17 2016 05:29
@kutsuya1 could be true. I changed it after your advice, to if (Boolean(arr[i])=='false') , and now the 'wrong'messages next to that line dissappeared. But the whole of the code still doesn' t work, unfortunately
Markus Kiili
@Masd925
Jun 17 2016 05:30
@ranranking Code works. Save the code and try refreshing the browser.
Krishna
@krishnakumar360
Jun 17 2016 05:30

@ranranking if(prop==="tracks" && value!==""){
if(collection[id][prop]){
collection[id][prop].push(value);
}
else{
collection[id][prop]=[value];
}
}
else if(value!==""){
collection[id][prop]=[value];
}
else{
delete collection[id][prop];
}
return collection;

}

Jason Shoemaker
@kutsuya1
Jun 17 2016 05:30
@1koenvdp why do you need a loop in bouncer? what does arr.filter do?
Markus Kiili
@Masd925
Jun 17 2016 05:31
@1koenvdp Yes, filter will do the looping.
Krishna
@krishnakumar360
Jun 17 2016 05:33

@ranranking sorry there is some error in above code correct one is this function updateRecords(id, prop, value) {

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

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

Leo
@Leodhy
Jun 17 2016 05:33

function titleCase(str) {
str=str.toLowerCase();
str.substring(0,1)=str.substring(0,1).toUpperCase();

return str;
}

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

why the third line cannot work?
ranranking
@ranranking
Jun 17 2016 05:34
@Masd925 Thank you. I refreshed, but the first requirement still is not met. Is that a bug?
CamperBot
@camperbot
Jun 17 2016 05:34
ranranking sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1889 | @masd925 |http://www.freecodecamp.com/masd925
Hamid Ali
@dimahali
Jun 17 2016 05:34
instead of str.substring(0,1)=str.substring(0,1).toUpperCase();
@Leodhy str=str.substring(0,1).toUpperCase();
ranranking
@ranranking
Jun 17 2016 05:35
@krishnakumar360 Thank you. But I don't see the difference between your code and mine
CamperBot
@camperbot
Jun 17 2016 05:35
ranranking sends brownie points to @krishnakumar360 :sparkles: :thumbsup: :sparkles:
:cookie: 215 | @krishnakumar360 |http://www.freecodecamp.com/krishnakumar360
Markus Kiili
@Masd925
Jun 17 2016 05:35
@ranranking Try another browser. It passed all tests when I tried.
Krishna
@krishnakumar360
Jun 17 2016 05:36
@ranranking only difference will be how you are passing values
Leo
@Leodhy
Jun 17 2016 05:36
but i don't want to change the string str @dimahali
Markus Kiili
@Masd925
Jun 17 2016 05:37
@krishnakumar360 Proper way to test property existence is .hasOwnProperty(). if(obj[key]) has problems.
Hamid Ali
@dimahali
Jun 17 2016 05:37
@Leodhy then create a new variable var new_str = str.substring(0,1).toUpperCase(); and use new_str ?
Leo
@Leodhy
Jun 17 2016 05:37
i need to print the full sentence at the end
"I'm a little tea pot"
Hamid Ali
@dimahali
Jun 17 2016 05:38
which problem?
Leo
@Leodhy
Jun 17 2016 05:38
Title Case a Sentence
i want to lowercase "I" and then uppercase it
k_vdp
@1koenvdp
Jun 17 2016 05:38
@kutsuya1 @Masd925 thank you. I'm trying to implement the advices now, & I try to get 2 the solution again
CamperBot
@camperbot
Jun 17 2016 05:38
1koenvdp sends brownie points to @kutsuya1 and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 395 | @kutsuya1 |http://www.freecodecamp.com/kutsuya1
:star2: 1890 | @masd925 |http://www.freecodecamp.com/masd925
ranranking
@ranranking
Jun 17 2016 05:38
@Masd925 I tried Chrome, Safari, and Firefox, none of them worked. Strange
Krishna
@krishnakumar360
Jun 17 2016 05:39
@ranranking just copy the above code and see it will work
RakeshNerkar
@Rakesh18754
Jun 17 2016 05:39
        HTML

        <div ng-repeat="s in selectedBooks" >
              <p class="col-md-6">{{s.author}}</p>
              <button class="btn btn-success confirmbtn" ng-model="tagName" ng-click="checkout(s.id); addBookID(s.id); updateDataBookID();">
                    Confirm
              </button>
        </div>

        JS

        $scope.bookid= []; 
        $scope.addBookID = function(id){
            $scope.bookid.push({
                name: $scope.id
            });
        };
        console.log($scope.bookid);

        $scope.updateDataBookID = function(){
           $localStorage.bookTaken  =  $scope.bookid;
        }; 
        $scope.updateDataBookID();


        but when in my local storage the value is null? any idea why?
Leo
@Leodhy
Jun 17 2016 05:39
i use tolowercase for the whole string,but i don't know how to uppercase one char in the string
ranranking
@ranranking
Jun 17 2016 05:40
@krishnakumar360 No, your code doesn't work either
Markus Kiili
@Masd925
Jun 17 2016 05:40
@Leodhy Strings are immutable, so create a new titlecased string from the old string.
Leo
@Leodhy
Jun 17 2016 05:40

function titleCase(str) {
str=str.toLowerCase();
str.substring(0,1)=str.substring(0,1).toUpperCase();
for (var i=1;i<=str.length-2;i++){
if (str[i] == " "){
str[i+1]=str[i+1].toUpperCase();
}
}
return str;
}

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

ranranking
@ranranking
Jun 17 2016 05:40
now I am sure it is a bug
Krishna
@krishnakumar360
Jun 17 2016 05:41
@ranranking --not possible bro just now i have done the code and got passed
Hamid Ali
@dimahali
Jun 17 2016 05:42

@Leodhy `function capitalize(s)
{
return s[0].toUpperCase() + s.slice(1);
}

function titleCase(str) {

var str_arr = str.split(' ');

for(var ii = 0; ii< str_arr.length; ii++){
var str_lower = str_arr[ii].toLowerCase();
str_arr[ii] = capitalize(str_lower);
console.log(str_arr[ii]);
}

return str_arr.join(' ');
}

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

Krishna
@krishnakumar360
Jun 17 2016 05:42

@ranranking ------- try this again -----function updateRecords(id, prop, value) {

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

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

ranranking
@ranranking
Jun 17 2016 05:42
@krishnakumar360 Yes, @Masd925 said he used my code and all passed too. However, none of them worked on my browser.
DJ
@qualitymanifest
Jun 17 2016 05:43
@ranranking do me a favor, copy and paste the full URL here. im just curious if there is anything strange outside of the function you pasted that could be causing issues
i doubt it, but who knows
ranranking
@ranranking
Jun 17 2016 05:44
@krishnakumar360 @qualitymanifest @Masd925 oh, I reset my challenge and all passed. It seems that it was not the function but I have touched something in the object. Sorry
Jason Shoemaker
@kutsuya1
Jun 17 2016 05:44
@1koenvdp after recoding, feel free to show code and ask again.
DJ
@qualitymanifest
Jun 17 2016 05:44
haha. so it was something outside the function. cool
ranranking
@ranranking
Jun 17 2016 05:45
Thanks for the help
James Dui
@jamesMD
Jun 17 2016 05:52
what is this code even trying to do?
Math.floor(Math.random() * (max - min + 1)) + min
I know it rounds up with min and max.... but what's with the max-min+1+ min business
NixonRichard
@NixonRichard
Jun 17 2016 05:54
function palindrome(str) {
  var re = /[\W_]/g;
  var lowRegStr = str.toLowerCase().replace(re,''));
  var reverseStr = lowRegStr.split('').reverse('').join('');
  return reverseStr === lowRegStr;
}



palindrome("eye");
hi what s wrong with the code ?
V Arun Kumar
@arunvkumr
Jun 17 2016 05:55
@jamesMD it gives a random number between min and max, including both min and max values.
Markus Kiili
@Masd925
Jun 17 2016 05:55
@jamesMD Math.random() is between 0 and 1 (1 excluded). -> Math.random() (max - min + 1) is between 0 and (max - min + 1). -> Math.random() (max - min + 1)) + min is between min and max+1 (max+1 excluded). Flooring that returns an integer between min and max.
Just a way to normalize the number range to what you wan't.
Darth Skywalker
@adityaparab
Jun 17 2016 05:56

@NixonRichard :smile:

 lowRegStr.split('').reverse('').join('');

Should be

 lowRegStr.split('').reverse().join('');
NixonRichard
@NixonRichard
Jun 17 2016 05:56
after convert str into arr we dont need the ' ' ?
V Arun Kumar
@arunvkumr
Jun 17 2016 05:56
@jamesMD you can read about different ways to write random function and how to include the bound integers from this link..
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
NixonRichard
@NixonRichard
Jun 17 2016 05:57
still wrong
Darth Skywalker
@adityaparab
Jun 17 2016 05:57
@NixonRichard : Whats the error?
NixonRichard
@NixonRichard
Jun 17 2016 05:58
replace(re,''));
lol
Darth Skywalker
@adityaparab
Jun 17 2016 05:58
@NixonRichard : There is extra closing bracket
V Arun Kumar
@arunvkumr
Jun 17 2016 05:58
@NixonRichard remove the ) at the end of that line.
NixonRichard
@NixonRichard
Jun 17 2016 05:58
omg it worked
thx alot guyz
James Dui
@jamesMD
Jun 17 2016 05:59
hmm i understand what it does, but mathatically expanded how does it spit out a random number between the min-max digit
nvm
i just got it
NixonRichard
@NixonRichard
Jun 17 2016 05:59
hey james u look like chinese
James Dui
@jamesMD
Jun 17 2016 05:59
i pretended math.random() = 0
then I solved for it, makes sense now.. thanks @arunkumrv @Masd925
CamperBot
@camperbot
Jun 17 2016 06:00
jamesmd sends brownie points to @arunkumrv and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 553 | @arunkumrv |http://www.freecodecamp.com/arunkumrv
:star2: 1891 | @masd925 |http://www.freecodecamp.com/masd925
James Dui
@jamesMD
Jun 17 2016 06:00
@NixonRichard yeah i am chinese American
Darth Skywalker
@adityaparab
Jun 17 2016 06:00
@jamesMD : Does your last name represent Driving Under Influence? :P
James Dui
@jamesMD
Jun 17 2016 06:01
@adityaparab no it just worked out that way, never know why last name is what it is, apparently when my parents came to the US, their relatives last name was Dui, so Dui became the last name of our family
NixonRichard
@NixonRichard
Jun 17 2016 06:01
yeh
Darth Skywalker
@adityaparab
Jun 17 2016 06:01
@jamesMD : Okay. Just prey that Donald Trump doesn't become the president! :D
NixonRichard
@NixonRichard
Jun 17 2016 06:02
i love duck
Darth Skywalker
@adityaparab
Jun 17 2016 06:02
is it prey or pray? hmm!
NixonRichard
@NixonRichard
Jun 17 2016 06:02
donald s awesome thug
Darth Skywalker
@adityaparab
Jun 17 2016 06:02
English is a funny language
Yeah... Election is for the president of United States of America.. Not for the president of thugs
Markus Kiili
@Masd925
Jun 17 2016 06:03
@adityaparab Just prey that Donald Trump what ;)
Darth Skywalker
@adityaparab
Jun 17 2016 06:03
@Masd925 : Hehe! English is, indeed, a funny language. As you are! :D
Evgueni
@Redoras
Jun 17 2016 06:10
@TylerMoeller Morning, yesterday you gave fixed my wiki search function, but you changed the URL to &callback=? at the end, why was that?
Darth Skywalker
@adityaparab
Jun 17 2016 06:12
@Redoras : Usually, that is how you use JSONP to make AJAX request across different domains.
JSONP requires a callback which we specify in the url as a parameter.
Evgueni
@Redoras
Jun 17 2016 06:12
@adityaparab different domains?
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 06:13
@adityaparab pune here
Darth Skywalker
@adityaparab
Jun 17 2016 06:15
@Redoras : If you're on your website (say example.com) and you want to get data from different website (Say facebook.com). Since example.com and facebook.com are two different domains, the browsers won't let you send ajax request (unless you disable web security). So to be able to send ajax request from one domain to the other (Technically termed as cross domain) we use a construct called padded JSON (JSONP).
I assume you were making ajax call from your site (codepen.io) to Wiki (wikipedia.org) so that is cross domain.
@chaitanyaashtekar : Greetings! :) Pune is awesome!
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 06:16
@adityaparab job or studying ?
Darth Skywalker
@adityaparab
Jun 17 2016 06:17
@chaitanyaashtekar : Job! How about you?
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 06:17
will search for a job
Darth Skywalker
@adityaparab
Jun 17 2016 06:18
Sweet! There are many many UI devs required throughout the industry
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 06:18
yup
@adityaparab do u work as a web developer ?
Darth Skywalker
@adityaparab
Jun 17 2016 06:19
@chaitanyaashtekar : No! As a full stack dev
Full Stack Javascript
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 06:19
okay.awesome
Darth Skywalker
@adityaparab
Jun 17 2016 06:19
Thanks! And all the best! :D
NixonRichard
@NixonRichard
Jun 17 2016 06:19
me ful stack Ruby on Rails
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 06:20
ty :+1:
Darth Skywalker
@adityaparab
Jun 17 2016 06:20
@NixonRichard : You should be the president
again
NixonRichard
@NixonRichard
Jun 17 2016 06:22
I wuold love to
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 06:23
@NixonRichard @adityaparab then it would be very bad for india :laughing:
shaunleow
@shaunleow
Jun 17 2016 06:23
hi can anyone help me with the challenge "make object properties private"?
Darth Skywalker
@adityaparab
Jun 17 2016 06:23
Still better than Donald Trump :D
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 06:23
yup
Darth Skywalker
@adityaparab
Jun 17 2016 06:23
help make object properties private
CamperBot
@camperbot
Jun 17 2016 06:23

:point_right: challenge make object properties private [wiki]

Challenge Make Object Properties Private

Objects have their own attributes, called properties_, and their own functions, called _methods.

You can use the this keyword to reference public properties and methods of the current objects. However, when You need to create private ones so they are not accessible from the outside of the object you just remove the keyword this from the object property or method declaration and declare it with var so that it is private outside its scope.

var Bike = function() {
  var speed = 100; // private
  function addUnit(value) { // private
    return value + "KM/H";
  }

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

};

:pencil: read more about challenge make object properties private on the FCC Wiki

shaunleow
@shaunleow
Jun 17 2016 06:23

var Car = function() {
  // this is a private variable
  var speed = 10;

  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };

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

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

var Bike = function() {

  // Only change code below this line.
  var gear = 3;

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

  this.setGear = function(num) {
    num = gear;
  };

};

var myCar = new Car();

var myBike = new Bike();
im wondering why when num = gear doesn't work
Markus Kiili
@Masd925
Jun 17 2016 06:24
@shaunleow SetGear should assign to gear.
shaunleow
@shaunleow
Jun 17 2016 06:24
but gear = num works?
Markus Kiili
@Masd925
Jun 17 2016 06:24
Assignment operator assigns from right to left. It evaluates the value on the right hand side and assigns it to the variable on the left.
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 06:25
@adityaparab you work as a MEAN stack developer ?
shaunleow
@shaunleow
Jun 17 2016 06:26
@Masd925 does this only apply to assignment operators?
Markus Kiili
@Masd925
Jun 17 2016 06:26
@shaunleow Different operators do different things.
shaunleow
@shaunleow
Jun 17 2016 06:27
@Masd925 ok thanks for clearing that up.
CamperBot
@camperbot
Jun 17 2016 06:27
shaunleow sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1892 | @masd925 |http://www.freecodecamp.com/masd925
RakeshNerkar
@Rakesh18754
Jun 17 2016 06:34

i want to generate an array of objects like this so how do i insert values dynamically

var array = [{
user-id : 5;
cars-id : ["2", "4","6"];
},{
user-id : 6;
cars-id : ["2", "4","6"];
}
];

Darth Skywalker
@adityaparab
Jun 17 2016 06:38
@chaitanyaashtekar : Mostly, yes
But there are way more aspects to being a full stack JS dev than just a MEAN stack
@deepakpatil007 : You need to put user-id in quotes. because if you don't put user-id quotes, the JS interpreter will consider it as a subtraction.
So you can use something like
var array = [{
'user-id': 5,
'cars-id' : ["2", "4","6"]
}];

var newObj = {
'user-id': 6,
'cars-id' : ["2", "4","6"]
}

array.push(newObj);
Same is the case with case-id
Additionally, the JS coding standards recommend using camelCase convention instead of hyphen separated convention.
so you should name your variables/keys as userId and caseId
V Arun Kumar
@arunvkumr
Jun 17 2016 06:43
@deepakpatil007 yes put them in quotes and seperate different object properties with commas , not ;.
Darth Skywalker
@adityaparab
Jun 17 2016 06:44
Yes. properties of object should be separated using , and not ;
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 06:48
@adityaparab ok
FM
@mafelix
Jun 17 2016 06:51
anyone want help?
I'm taking queues while my lol queue is going
RakeshNerkar
@Rakesh18754
Jun 17 2016 07:04
@adityaparab @arunkumrv @adityaparab Thanks but i want to add values to array inside an object using js
CamperBot
@camperbot
Jun 17 2016 07:04
deepakpatil007 sends brownie points to @adityaparab and @arunkumrv :sparkles: :thumbsup: :sparkles:
:cookie: 284 | @adityaparab |http://www.freecodecamp.com/adityaparab
:cookie: 555 | @arunkumrv |http://www.freecodecamp.com/arunkumrv
Markus Kiili
@Masd925
Jun 17 2016 07:06
@deepakpatil007 You wan't to push into 'cards-id' array?
christianws
@christianws
Jun 17 2016 07:25

can someone explain to me why this

console.log([1, [], [3, [[4]]]]);

is returning the 4 as an object?

does using double square brackets -> [[ something ]] make something an object?
Markus Kiili
@Masd925
Jun 17 2016 07:26
@CurlyWS It is an array with one element that happens to be an array (an object too).
Rudolf Carl Pablico
@rudolfpablico
Jun 17 2016 07:26

Hi guys need help, I have this for loop,

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

    if(change > balance[i]){

      coins.push(balance[i]);
      change = change - balance[i];

    }


  }

what I want is to reset the loop when the conditions are met

christianws
@christianws
Jun 17 2016 07:27
@Masd925 sorry, an array that is an object too??
@rudolfpablico what conditions?
@rudolfpablico can you not just set i to 0
change = change - balance[i]
i = 0;
Markus Kiili
@Masd925
Jun 17 2016 07:29
@CurlyWS In javascript, arrays are one type of object. Putting some value into an array element makes an array [value]. Putting that as an element to another array makes an array with an array as an element var arr=[[value]]. You could get that value by arr[0][0].
christianws
@christianws
Jun 17 2016 07:31
@Masd925 so,
arr= [[value]]
//is the same as
arr[0][0]
?
FM
@mafelix
Jun 17 2016 07:33
@monala the way you use special character s in single quoted strings
Markus Kiili
@Masd925
Jun 17 2016 07:33
@CurlyWS var arr=[["catpants"]]; creates an array and assigns it to variable arr. It is an object. You can get the primitive value (string) out by accessing the array var str = arr[0][0];. Variable str then has value "catpants".
Leo
@Leodhy
Jun 17 2016 07:33
i cannot pass the "Slasher Flick" part
the program cannot be tested
FM
@mafelix
Jun 17 2016 07:33
you have to escape the string
Leo
@Leodhy
Jun 17 2016 07:34
the screen has shown "testing challenge" for a long time
FM
@mafelix
Jun 17 2016 07:34
you probably wrote an infinite loop then
just refresh
Rudolf Carl Pablico
@rudolfpablico
Jun 17 2016 07:34
@CurlyWS when I set it to zero it just reverted back to its previous value. But what I want is to reset it from the start.
christianws
@christianws
Jun 17 2016 07:36
@Masd925 ok this has helped me I think Under the same logic I just don't understand why console.log interprets arr=["cat",["pants"]] as an object also
mla
@monala
Jun 17 2016 07:38
@mafelix i understand the topic
but i dont know how pass Instructions!
Brendan Kinahan
@BKinahan
Jun 17 2016 07:43
@monala if you need to replace "tab", use "\t". Do that for each part of the sequence, and separate them by spaces (within one string)
christianws
@christianws
Jun 17 2016 07:43

@rudolfpablico I have done something a bit different here see if you can understand it

//if you use recursion you can create another loop

var balance = [2,3,4,5];
var change = 3;
coins = [];

cycle(0,10);

function cycle(i, limit){
    if(limit===0){return "finished";}

    for(i; i < balance.length;i++){

        console.log(i);
        if(change > balance[i]){
            console.log("condition met");
          coins.push(balance[i]);
          change = change - balance[i];
          limit--;
          return cycle(0,limit);
        }
      }
}

I don't know if this solution is the best workaround though

actually there must be a better way
tell me if you find a solution
Brendan Kinahan
@BKinahan
Jun 17 2016 07:46
@CurlyWS Is that for an FCC challenge, or something else?
JPRocks
@JPRocks
Jun 17 2016 07:47
This message was deleted
christianws
@christianws
Jun 17 2016 07:47
@BKinahan it was a reply to @rudolfpablico problem
Brendan Kinahan
@BKinahan
Jun 17 2016 07:48
@JPRocks review the syntax of a switch statement.
christianws
@christianws
Jun 17 2016 07:48
he wanted to reset a for loop if a condition is met
must be a much simpler way (I have 3 hrs sleep)
JPRocks
@JPRocks
Jun 17 2016 07:48
function switchOfStuff(val) {
  var answer = "";
  // Only change code below this line
  case 'a';
  return 'apple';
  break;
  case 'b':
  return 'bird';
  break;
  case 'c':
  return 'cat';
  break;
  default:'stuff';


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

// Change this value to test
switchOfStuff(2);
Thanks @BKinahan shall do that... Any other pointers welcome. Off to day job now.... Thanks all
CamperBot
@camperbot
Jun 17 2016 07:49
jprocks sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1675 | @bkinahan |http://www.freecodecamp.com/bkinahan
Markus Kiili
@Masd925
Jun 17 2016 07:49
@JPRocks Where is switch(...) clause?
chaitanya ashtekar
@chaitanyaashtekar
Jun 17 2016 07:53
@JPRocks how did that wrok without switch() ?
Brendan Kinahan
@BKinahan
Jun 17 2016 08:02
@chaitanyaashtekar it didn't ;)
mla
@monala
Jun 17 2016 08:03

@BKinahan sorry but I am beginner
this is my string

var myStr = "\this \tis \tJavaScript \rtest \nstring for this challange!"

i didnt work
:(

Brendan Kinahan
@BKinahan
Jun 17 2016 08:04
@monala you don't need to add those extra words, just represent the characters requested in the instructions.
backslash, tab, etc
mla
@monala
Jun 17 2016 08:07
@BKinahan oh thank you so much :+1:
CamperBot
@camperbot
Jun 17 2016 08:07
monala sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1676 | @bkinahan |http://www.freecodecamp.com/bkinahan
Arjun
@arjunsingh81989
Jun 17 2016 08:07
why do we need a scripting language? What advantage does a scripting language like JS may have over Compiled languages like Java?
Mats05
@Mats05
Jun 17 2016 08:07
Hi everyone. I need help. Can anyone tell me what's wrong with this code?

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

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

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

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

return collection;

}

// Alter values below to test your code
updateRecords(1245, "album", "Robert Palmer");

Arjun
@arjunsingh81989
Jun 17 2016 08:08
@Mats05 use backticks to format your code
Brendan Kinahan
@BKinahan
Jun 17 2016 08:08
@Mats05 As I said in the main chat, you don't handle the case where "tracks" is needed but not present :P
Mats05
@Mats05
Jun 17 2016 08:11
@BKinahan I'm not completely sure I understand you. I'm an amateur coder and still learning
Ionatan Mocan
@IonatanMocan
Jun 17 2016 08:13
hey huys
guys*
i have a problem w/ record collection
did someone solve this one?
Brendan Kinahan
@BKinahan
Jun 17 2016 08:14
@Mats05 See the album with id 5439. If you attempt collection[id][prop].push(value);, it won't work, because it has no "tracks" property defined. So you need to create it. read about .hasOwnProperty() if you are not familiar with that :)
@IonatanMocan that message may help you, too ^
Ionatan Mocan
@IonatanMocan
Jun 17 2016 08:14
thank you bro
can you give me an example?
you said if there is no "tracks" property defined
with .hasOwnProperty, then i should create it
right?
@Mats05 ?
Thomas M
@TMORGANT
Jun 17 2016 08:24
Hello guys,
I've a little problem with this code
function largestOfFour(arr) {
  // You can do this!
  var x = 0;
  var tmp = [];
  for (var i = 0; i < arr.length; i++){
    for (var j = 0; j < arr[i].length; j++){
      if (arr[i][j] > arr[i][j+1]) {
        tmp[x] = arr[i][j];
        x++;        
      }
    }
    console.log(arr[i]);
  }

  return tmp;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Markus Kiili
@Masd925
Jun 17 2016 08:25
@IonatanMocan Some records in collection don't have tracks property. It prop is tracks, make a check with .hasOwnProperty() and if it returns false, assign [value] to tracks property. If true, just push the value to tracks array.
Thomas M
@TMORGANT
Jun 17 2016 08:25
This return me [5, 27, 1001, 857]... Do you know why ?
Hitik Rajpal
@hitikrajpalhr
Jun 17 2016 08:30
var myStr = "I am a \"double quoted\" string inside \"double quotes\" "; is ot working what to do now ?
not*
Leo
@Leodhy
Jun 17 2016 08:31
if I want to print an empty array, how to print "[]" to replace "[null]"?
Markus Kiili
@Masd925
Jun 17 2016 08:31
@TMORGANT You have to have some variable that holds the largest number found for each subarray. Also x is not needed. Only obscures the logic. Something like this would work:
function largestOfFour(arr) {
  // You can do this!
  var tmp = [];
  for (var i = 0; i < arr.length; i++){
    tmp[i]=-Infinity;
    for (var j = 0; j < arr[i].length; j++){
      if (arr[i][j] > tmp[i]) {
        tmp[i] = arr[i][j];
      }
    }
  }
  return tmp;
}
Thomas M
@TMORGANT
Jun 17 2016 08:32
@hitikrajpalhr Haven't you forget a "." ?
96street
@96street
Jun 17 2016 08:33
I'm doing the Quote Generator challenge. How do I make it tweet the actual quote and not the codepen? http://codepen.io/kingdezz/pen/mEJPLN
Markus Kiili
@Masd925
Jun 17 2016 08:33
@Leodhy What challenge are you doing? Falsy bouncer perhaps.
Leo
@Leodhy
Jun 17 2016 08:33
yep
Markus Kiili
@Masd925
Jun 17 2016 08:34
@Leodhy I would quess that the value in the array is NaN. It shows as null in FCC console.
Teresa Garriot
@garriottteresa
Jun 17 2016 08:34
I can't figure this simiple function out. what SHOULD go between the comments??
Markus Kiili
@Masd925
Jun 17 2016 08:35
@Leodhy NaN needs special attention there because NaN===NaN is false. NaN is not equal to any value.
Teresa Garriot
@garriottteresa
Jun 17 2016 08:35

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenhett="celsius"*9/5+32;

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

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

Kashif Mohammed
@Spyreo
Jun 17 2016 08:35
Hello
Markus Kiili
@Masd925
Jun 17 2016 08:35
@garriottteresa You have to use celsius in the equation without quotes. It is a parameter that holds the passed number (30 in the test case below the code).
Kashif Mohammed
@Spyreo
Jun 17 2016 08:36
Hi @Masd925
Markus Kiili
@Masd925
Jun 17 2016 08:36
@Spyreo Hi.
Kashif Mohammed
@Spyreo
Jun 17 2016 08:36

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

      console.log(multiplyAll[i]);
  }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Can you tell me what i am doing wrong here sir
Markus Kiili
@Masd925
Jun 17 2016 08:37
@Spyreo Try multiplying product instead of logging. Also you need to access arr, not the function name.
Leo
@Leodhy
Jun 17 2016 08:37
@Masd925 i still cannot avoid null in my output
Thomas M
@TMORGANT
Jun 17 2016 08:37
@Masd925 It works, but can you help me figure out except for the "i" var, what are the big difference between your code and mine ? :/
Markus Kiili
@Masd925
Jun 17 2016 08:38
@Leodhy Post the code.
Teresa Garriot
@garriottteresa
Jun 17 2016 08:38
Markus Kiili
@Masd925 removing the quotes still doesn't pass.
Leo
@Leodhy
Jun 17 2016 08:38

function bouncer(arr) {
// Don't show a false ID to this bouncer.
var arr1=[];
var q=-1;
for (var i=0;i<arr.length;i++){
if (arr[i] !== false && arr[i] !== null && arr[i] !== 0 && arr[i] !== undefined && arr[i] !== "" && arr[i] != "NaN"){
arr1.push(arr[i]);
}
if (arr[i] === null) q=i;
} arr=arr1;
if (q !== -1){
for (i=q;i<arr.length-1;i++){
arr[i] = arr[i+1];
arr.pop();
}
}
return arr;
}

bouncer([false, null, 0, NaN, undefined, ""]);