These are chat archives for FreeCodeCamp/HelpJavaScript

13th
Mar 2016
bitgrower
@bitgrower
Mar 13 2016 00:00
thanks @Ronolibert -- I was thinking that was probably true ...
CamperBot
@camperbot
Mar 13 2016 00:00
bitgrower sends brownie points to @ronolibert :sparkles: :thumbsup: :sparkles:
Ron Cruz
@Ronolibert
Mar 13 2016 00:00
Er, the 4 lessons about manipulating an array
CamperBot
@camperbot
Mar 13 2016 00:00
:star: 253 | @ronolibert | http://www.freecodecamp.com/ronolibert
Claire Walker
@kjarva
Mar 13 2016 00:00
@SteveCarroll yep I've been staring at the docs for an hour, calling it quits for the night ;)
Steve Carroll
@SteveCarroll
Mar 13 2016 00:01
@kjarva My take: Use an API when you really need one
bitgrower
@bitgrower
Mar 13 2016 00:02
@Macxim -- consider using .hasOwnProperty and re-read the instructions carefully -- kinda just follow the bouncing ball ... except for "no such contact"
alpox
@alpox
Mar 13 2016 00:02
@kjarva I think the twitter api is quite well documented as i see :D
Maxime Laforet
@Macxim
Mar 13 2016 00:02
My last 2 conditions seem to work.
The first one, not so sure.
Am I supposed to know about .hasOwnPropertyat this point?
alpox
@alpox
Mar 13 2016 00:04
@kjarva But its not really an api which is good for beginning with apis
Ron Cruz
@Ronolibert
Mar 13 2016 00:05
collection[id][prop] = value
Steve Carroll
@SteveCarroll
Mar 13 2016 00:05
@alpox Plus, at the point of that lesson. there is no API info
Ron Cruz
@Ronolibert
Mar 13 2016 00:05
why does that work for reassigning a value
Steve Carroll
@SteveCarroll
Mar 13 2016 00:05
Or, if there was, I missed it ;)
Ron Cruz
@Ronolibert
Mar 13 2016 00:05
but using dot notation for the prop doesn't?
alpox
@alpox
Mar 13 2016 00:05
@SteveCarroll I don't even know which point of lesson it is :D
Steve Carroll
@SteveCarroll
Mar 13 2016 00:06
@alpox Quote machine
Provided you're going linearly
bitgrower
@bitgrower
Mar 13 2016 00:06
@Macxim -- I think so ...
alpox
@alpox
Mar 13 2016 00:06
@SteveCarroll Ah yeah well i guess that they expect you to hardcode the quotes for the quotes machine
Steve Carroll
@SteveCarroll
Mar 13 2016 00:06
Hola bitgrower!
alpox
@alpox
Mar 13 2016 00:07
@SteveCarroll I used the youtube api for it though. But i knew apis already
Steve Carroll
@SteveCarroll
Mar 13 2016 00:07
@alpox YT for Twitter?
alpox
@alpox
Mar 13 2016 00:07
@SteveCarroll YT? o.O
Steve Carroll
@SteveCarroll
Mar 13 2016 00:08
Quote machine has you tweeting out the quote.
alpox
@alpox
Mar 13 2016 00:08
@SteveCarroll Aaaah
@SteveCarroll That is no api call!
Steve Carroll
@SteveCarroll
Mar 13 2016 00:08
YT = Your Tube
YOu
Damn
bitgrower
@bitgrower
Mar 13 2016 00:09
there's a bunch of challenges on JSON & objects I believe that come before Profile Lookup @Macxim
alpox
@alpox
Mar 13 2016 00:10
@SteveCarroll I got you :D
Its just an url with some parameters which you add as href to your link
https://twitter.com/intent/tweet?url=#{url}&original_referer=Someone
Something like that
Steve Carroll
@SteveCarroll
Mar 13 2016 00:12
That's all I did
alpox
@alpox
Mar 13 2016 00:12
yeah
But thats no api :D
Steve Carroll
@SteveCarroll
Mar 13 2016 00:12
I never said it was ;)
alpox
@alpox
Mar 13 2016 00:12
kk :D
Steve Carroll
@SteveCarroll
Mar 13 2016 00:12
I see people asking about Twitter's API for that challenge, though
alpox
@alpox
Mar 13 2016 00:12
Hmmh strange
Steve Carroll
@SteveCarroll
Mar 13 2016 00:12
NOt sure why...
I've seen several
alpox
@alpox
Mar 13 2016 00:13
Maybe wrong understanding of what an API is or are not sure how it is supposed to work
Maxime Laforet
@Macxim
Mar 13 2016 00:13
This should work @bitgrower
if ((firstName === contacts[i].firstName) && (contacts[i].hasOwnProperty(prop) === true)){ return contacts[i][prop]; }
Steve Carroll
@SteveCarroll
Mar 13 2016 00:13
I imagine the API will let you do it but it's not needed there
alpox
@alpox
Mar 13 2016 00:14
I guess so..
good night then
Steve Carroll
@SteveCarroll
Mar 13 2016 00:21
Later
Anuj Chatterjee
@chattean
Mar 13 2016 00:22
i am struggling with the same thin macxim is doing

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

}
return contprop;
}

it still doesn't work
Jay Varela
@Wahoowa2014
Mar 13 2016 00:24
Hello all. I'm working o "Return Early Pattern for Functions."
Is someone able to help me real quick?
Maxime Laforet
@Macxim
Mar 13 2016 00:46
any luck @chattean ?
Ariel
@abibliophile
Mar 13 2016 00:50
Hi! I'm working on escape sequences in strings and I'm not quite sure what I'm doing wrong
"\\ \t\ \t\ \r\ \n\" is what I have
Anuj Chatterjee
@chattean
Mar 13 2016 00:50
@Macxim no still working with it
Ariel
@abibliophile
Mar 13 2016 00:50
directions are "Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr"
Maxime Laforet
@Macxim
Mar 13 2016 00:52
@chattean I need one last test to pass (the one for "No such contact”)
Anuj Chatterjee
@chattean
Mar 13 2016 00:53
for me lookUp("Sherlock", "likes");
also returns pizza coding and brownie which are not what sherlock likes
Maddah Anass
@unlimiworks
Mar 13 2016 00:53
Hello guys
Anuj Chatterjee
@chattean
Mar 13 2016 00:54
@Macxim would this work else if (contacts[i].firstName != firstName){
@UnlimiWorks Hello
Maxime Laforet
@Macxim
Mar 13 2016 00:55
function lookUp(firstName, prop){
  for(var i=0; i < contacts.length; i++){
    if (firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop) === true){
        return contacts[i][prop];     
    }
    if (contacts[i].hasOwnProperty(prop) === false){
      return "No such property";
    }
  }
}
arakita
@arakita
Mar 13 2016 00:56
This message was deleted
Maddah Anass
@unlimiworks
Mar 13 2016 00:57
Do you guys know why this is giving me null ?
 var drawerState = [[0.01, 10], [0.05, 15], [0.10, 12], [0.25, 5]];
 var funds = drawerState.reduce(function(previous, current) {
    return previous[0] * previous[1] + current[0] * current[1];
  }, [0, 0]);
Anuj Chatterjee
@chattean
Mar 13 2016 00:59
@Macxim y wouldnt you be using else if and else for the other conditions
Maxime Laforet
@Macxim
Mar 13 2016 01:00
No idea.
arakita
@arakita
Mar 13 2016 01:00
Hi, I am doing "Where do I belong". I want to put the second argument into the first argument which is an array. But, instead of returning the new array, it returns the number of elements in the array. Anyone can help me?
function where(arr, num) {
return arr.push(num);
}
where([2, 20, 10], 15);
Anuj Chatterjee
@chattean
Mar 13 2016 01:00
and i have exactly the same thing for my if statemante and it doesnt work
Collin
@collinferry
Mar 13 2016 01:01
@arakita The push method returns the length of the new array: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push
Maddah Anass
@unlimiworks
Mar 13 2016 01:01
@arakita you are returning the result of the function push(), not the array
Maxime Laforet
@Macxim
Mar 13 2016 01:01
@chattean doesn’t work this way either
    if (firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop) === true){
        return contacts[i][prop];     
    }
    else if (contacts[i].hasOwnProperty(prop) === false){
      return "No such property";
    }
    else {
      return "No such contact";
    }
Maddah Anass
@unlimiworks
Mar 13 2016 01:02
@Macxim One should only look for the property if he finds the person :)
Maxime Laforet
@Macxim
Mar 13 2016 01:07
@UnlimiWorks Something like
    if (firstName === contacts[i].firstName){
      if (contacts[i].hasOwnProperty(prop) === true){
        return contacts[i][prop];
      }
      else if (contacts[i].hasOwnProperty(prop) === false){
        return "No such property";
      }
      return "No such contact";
    }
Ariel
@abibliophile
Mar 13 2016 01:10
Hi, I'm working on "escape sequences in strings" and I'm not sure what I'm doing wrong
Maddah Anass
@unlimiworks
Mar 13 2016 01:12
@Macxim That would certainly work :)
Maxime Laforet
@Macxim
Mar 13 2016 01:12
Except it doesn’t :)
Maddah Anass
@unlimiworks
Mar 13 2016 01:13
Let me hop on the assignment again, which one was it ? :P
sigursiguros
@sigursiguros
Mar 13 2016 01:13
thanks @Dave-Melia @Takumar
CamperBot
@camperbot
Mar 13 2016 01:13
sigursiguros sends brownie points to @dave-melia and @takumar :sparkles: :thumbsup: :sparkles:
:star: 2690 | @takumar | http://www.freecodecamp.com/takumar
:star: 292 | @dave-melia | http://www.freecodecamp.com/dave-melia
Maxime Laforet
@Macxim
Mar 13 2016 01:16
it’s Profile Lookup @UnlimiWorks
Garrett
@grrttmrtn
Mar 13 2016 01:16
var Bike = function() {
  // Only change code below this line
};
var myBike = new Bike();
var gear = 0;

myBike.setGear = function(change) {
  gear = change;
};

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

var myCar = new Car();
How does var bike = function() come into play with this?
Maddah Anass
@unlimiworks
Mar 13 2016 01:18
Oh, you have a problem there
@Macxim In your code, it's trying to return 'no such contact' when it finds the person
Maxime Laforet
@Macxim
Mar 13 2016 01:20
@UnlimiWorks
    if (firstName === contacts[i].firstName){
      if (contacts[i].hasOwnProperty(prop) === true){
        return contacts[i][prop];
      }
      else{
        return "No such property";
      }
    }
    else{
      return "No such contact";
    }
no luck :-/
Maddah Anass
@unlimiworks
Mar 13 2016 01:20
Are you writing that inside a loop ?
Maxime Laforet
@Macxim
Mar 13 2016 01:20
sure
Nahum T
@nahomtefera
Mar 13 2016 01:21
Hey guys need some help with basic algorithm
Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.


function chunk(arr, size) {
  // Break it up.


  var newArr = []; 

  newArr.push(arr.slice(0, size));

  newArr.push(arr.slice(size, size + size));



  return newArr;
}

chunk(["a", "b", "c", "d"], 2);
Maxime Laforet
@Macxim
Mar 13 2016 01:21
@UnlimiWorks
  for(var i=0; i < contacts.length; i++){

 ...
  }
Garrett
@grrttmrtn
Mar 13 2016 01:22
@Macxim remove the last else statement from the loop
@Macxim Add it just as return "no such contact" after the loop
Maddah Anass
@unlimiworks
Mar 13 2016 01:22
@Macxim Right. You should only return 'no such contact' when you don't find the person
Maxime Laforet
@Macxim
Mar 13 2016 01:24
Thanks @grrttmrtn and @UnlimiWorks. Could you explain why it hast to be after the loop?
CamperBot
@camperbot
Mar 13 2016 01:24
macxim sends brownie points to @grrttmrtn and @unlimiworks :sparkles: :thumbsup: :sparkles:
:star: 265 | @grrttmrtn | http://www.freecodecamp.com/grrttmrtn
:star: 356 | @unlimiworks | http://www.freecodecamp.com/unlimiworks
Garrett
@grrttmrtn
Mar 13 2016 01:24
Because it is going to be the code that runs when nothing in the loop matches
So you're going to loop looking for criteria
Maddah Anass
@unlimiworks
Mar 13 2016 01:24
@Macxim Basically, with your current code, it returns 'no such contact' after if it doesn't find it the first time
Garrett
@grrttmrtn
Mar 13 2016 01:25
@UnlimiWorks explained it better
Maxime Laforet
@Macxim
Mar 13 2016 01:25
I think I understand.
Maddah Anass
@unlimiworks
Mar 13 2016 01:25
if(contact[0].firstName === firstName) {
  // Do stuff
}
else {
return 'no such contact';
}
that's what it does
Garrett
@grrttmrtn
Mar 13 2016 01:26
var Bike = function() {
  // Only change code below this line
};
var myBike = new Bike();
var gear = 0;

myBike.setGear = function(change) {
  gear = change;
};

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

var myCar = new Car();
Could someone explain how the var Bike = function() plays a part in this code? It's throwing me off
Daniel Bashir
@db7894
Mar 13 2016 01:28
@grrttmrtn It declares a function called Bike (or in this case an object) which contains a few properties
myBike is an instance of Bike
bitgrower
@bitgrower
Mar 13 2016 01:29
@Macxim -- you get Profile Lookup all passed yet? If not ... think about this ... if you have 20 marbles i a bag and want to say there are no black marbles -- how many do you have to look at ?
Daniel Bashir
@db7894
Mar 13 2016 01:30
I'm kind of clueless on what to do with the Falsy Bouncer algorithm, I've looked at the documentation it linked but still can't think of what to do with it... Can anyone help me out?
Maddah Anass
@unlimiworks
Mar 13 2016 01:30
@bitgrower Obviously one, hords are always alike !
bitgrower
@bitgrower
Mar 13 2016 01:31
LOL @UnlimiWorks ... not quite!
Maddah Anass
@unlimiworks
Mar 13 2016 01:31
Welcome back :)
bitgrower
@bitgrower
Mar 13 2016 01:31
@db7894 -- I spent hours on that thing ... the page on Booleans (the first one referenced in the helpful hints, I think) gave me the answer ...
I mean ... I dug in and found out that NaN is a number of all things ... LOL ..
Daniel Bashir
@db7894
Mar 13 2016 01:32
@bitgrower I'll look through it more closely
bitgrower
@bitgrower
Mar 13 2016 01:32
hi @UnlimiWorks - in and out
Maddah Anass
@unlimiworks
Mar 13 2016 01:33
Reposting, but oh well
Do you guys know why this is giving me null ?
 var drawerState = [[0.01, 10], [0.05, 15], [0.10, 12], [0.25, 5]];
 var funds = drawerState.reduce(function(previous, current) {
    return previous[0] * previous[1] + current[0] * current[1];
  }, [0, 0]);
bitgrower
@bitgrower
Mar 13 2016 01:33
@grrttmrtn -- the example of the Car constructor gives you VERY good ideas of what you need to do ... the only thing that really differs is in what you need the functions to do ... but you have a set & get ... so ... not too difficult ...
Garrett
@grrttmrtn
Mar 13 2016 01:34
@bitgrower my code is correct. Just was curious what the point of the Bike function is
Daniel Bashir
@db7894
Mar 13 2016 01:35
@grrttmrtn Think of it like a framework
bitgrower
@bitgrower
Mar 13 2016 01:36
the Bike function is a constructor so you can create new "Bike" objects ... not really touched in depth in this exercise or not really much in any of the FCC js challenges as I recall ... but it is part of js
it's the "object oriented" part of js
Daniel Bashir
@db7894
Mar 13 2016 01:36
It doesn't have anything right now but imagine it as if it were a general frame of a bike with some properties. If you make a new bike (which would be an instance of the original) then that would have all the properties of the original and new ones if you wanted to add those
bitgrower
@bitgrower
Mar 13 2016 01:37
in ANY object oriented programming language, you have "constructors" and they all pretty much serve the same purpose
...and @UnlimiWorks -- dunno ... was gonna throw it into pythontutor & see if anything shows up ...
thaniri
@thaniri
Mar 13 2016 01:39
anyone know why this returns true?
return isNaN("http://bit.ly/IqT6zt");
it should be false
Daniel Bashir
@db7894
Mar 13 2016 01:39
@bitgrower I think I see where you found the answer
thaniri
@thaniri
Mar 13 2016 01:39
wait
im dumb
sorry
Garrett
@grrttmrtn
Mar 13 2016 01:40
@bitgrower @db7894 so what is the need for myBike? Couldn't everything essentially be done within bike itself and cut a variable out?
bitgrower
@bitgrower
Mar 13 2016 01:40
@db7894 ????
Daniel Bashir
@db7894
Mar 13 2016 01:40
@grrttmrtn Technically you could put what you wanted into it, but myBike is just an instance of it, so if you wanted to create multiple instances of bike then it comes in handy
@bitgrower I mean for the Falsy Bouncer thing
bitgrower
@bitgrower
Mar 13 2016 01:40
ahhhh ... awesome
Garrett
@grrttmrtn
Mar 13 2016 01:41
@db7894 Okay, that makes more sense. Thanks!
CamperBot
@camperbot
Mar 13 2016 01:41
grrttmrtn sends brownie points to @db7894 :sparkles: :thumbsup: :sparkles:
:star: 265 | @db7894 | http://www.freecodecamp.com/db7894
Garrett
@grrttmrtn
Mar 13 2016 01:41
@bitgrower Thank you too!
CamperBot
@camperbot
Mar 13 2016 01:41
grrttmrtn sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 837 | @bitgrower | http://www.freecodecamp.com/bitgrower
James Good
@TajYemaj
Mar 13 2016 01:41
oes anyone mind helping me out with a Javascript exercise from codeacademy that utilizes for loops?
Does*
Daniel Bashir
@db7894
Mar 13 2016 01:41
@grrttmrtn No problem
bitgrower
@bitgrower
Mar 13 2016 01:41
@grrttmrtn -- a constructor is a variable factory -- a factory for making similar objects ... :)
Daniel Bashir
@db7894
Mar 13 2016 01:41
@TajYemaj I could try
James Good
@TajYemaj
Mar 13 2016 01:41
Here's what I've got
/*jshint multistr:true */ var text = ["kfjfklkj", "kflsjfk", "fksjafl", "jifj", "ijsjf", "b", "yueb", "n", "aj", "Jamey", "nfjfsi", "nfkjfl", "jsfueyqo", "wham", "fmfo", "Jamey"]; var myName = "Jamey"; var hits = []; for (var i = 0; i < text.length; i++) { if (text === myName) { for (var j = i; j <= myName.length; j++); { hits.push(j); } } };
oops
bitgrower
@bitgrower
Mar 13 2016 01:43
explain format
CamperBot
@camperbot
Mar 13 2016 01: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 the code.

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

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

James Good
@TajYemaj
Mar 13 2016 01:43
forgot how to put the block of code in
that!
Maddah Anass
@unlimiworks
Mar 13 2016 01:43
I think i found the problem :) the previous variable denotes the accumulator, not the previous element
@bitgrower
James Good
@TajYemaj
Mar 13 2016 01:43
/*jshint multistr:true */
var text = ["kfjfklkj", "kflsjfk", "fksjafl", "jifj", "ijsjf", "b", "yueb", "n", "aj", "Jamey", "nfjfsi", "nfkjfl", "jsfueyqo", "wham", "fmfo", "Jamey"];
var myName = "Jamey";
var hits = [];
for (var i = 0; i < text.length; i++) {
if (text === myName) {
    for (var j = i; j <= myName.length; j++);
   {
    hits.push(j);
   }
 }
};
There we go
Rafael
@rafaelpdl
Mar 13 2016 01:44
Hi Everyone! Can you please give me a help?
Daniel Bashir
@db7894
Mar 13 2016 01:44
@TajYemaj Alright so what are you trying to accomplish with it?
Garrett
@grrttmrtn
Mar 13 2016 01:44
@TajYemaj someone correct me if I'm wrong, but your nested loop I believe you still want var j = 0
Rafael
@rafaelpdl
Mar 13 2016 01:44

I am having difficulty the "Testing Objects for Properties" challenge. It wants me to:

Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".

Garrett
@grrttmrtn
Mar 13 2016 01:44
@rafaelpdl I can try. Post what you've got
Rafael
@rafaelpdl
Mar 13 2016 01:45

My code is this:

// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here

var changeMe;

var result = myObj.hasOwnProperty("checkProp");

if (result===true) {

changeMe=myObj.checkProp;

}

else if (result===false) {
 changeMe="Not Found";

}

return changeMe;
}

// Test your code by modifying these values
checkObj("gift");

Daniel Bashir
@db7894
Mar 13 2016 01:45
@TajYemaj I think you also want to make the "j<=myName.length" into just a less than sign so it doesn't go past the length
Rafael
@rafaelpdl
Mar 13 2016 01:45
Ooops
James Good
@TajYemaj
Mar 13 2016 01:45
I'm just going to copy the instructions from their site.

Okay! Last loopy step: add another for loop, this time inside the body of your if statement (between the if's {}s).

This loop will make sure each character of your name gets pushed to the final array. The if statement says: "If we find the first letter of the name, start the second for loop!" This loop says: "I'm going to add characters to the array until I hit the length of the user's name." So if your name is 11 letters long, your loop should add 11 characters to hits if it ever sees the first letter of myName in text.

Daniel Bashir
@db7894
Mar 13 2016 01:45
Like change <= to just <
Rafael
@rafaelpdl
Mar 13 2016 01:45
How do I post the entire thing here with a black background?
James Good
@TajYemaj
Mar 13 2016 01:45
I have just a basic understanding of for loops
But I don't know how to use them to pick out one piece of data from an array
Garrett
@grrttmrtn
Mar 13 2016 01:46
@rafaelpdl explain format
aww
Daniel Bashir
@db7894
Mar 13 2016 01:46
@TajYemaj So you're trying to create a new array with your name in it?
James Good
@TajYemaj
Mar 13 2016 01:46
let alone pin-point the first letter of the data and then push the rest of the information into a new array
Garrett
@grrttmrtn
Mar 13 2016 01:46
won't work for me
James Good
@TajYemaj
Mar 13 2016 01:46
Yeah pretty much
but
the first for loop has to find my name in the first array
bitgrower
@bitgrower
Mar 13 2016 01:47

I think i found the problem :) the previous variable denotes the accumulator, not the previous element

thanks, @UnlimiWorks -- that sounds about right ... :)

CamperBot
@camperbot
Mar 13 2016 01:47
bitgrower sends brownie points to @unlimiworks :sparkles: :thumbsup: :sparkles:
:star: 357 | @unlimiworks | http://www.freecodecamp.com/unlimiworks
Daniel Bashir
@db7894
Mar 13 2016 01:47
Ah, i see
James Good
@TajYemaj
Mar 13 2016 01:47
then the second for loop will push the characters to the new array
Daniel Bashir
@db7894
Mar 13 2016 01:47
@TajYemaj I'll take another look at it
James Good
@TajYemaj
Mar 13 2016 01:47
They kind of pushed me off a cliff here
Daniel Bashir
@db7894
Mar 13 2016 01:47
Ok I see
James Good
@TajYemaj
Mar 13 2016 01:48
because before this part of the lesson all I learned was how to increment up or down with for loops.
Daniel Bashir
@db7894
Mar 13 2016 01:48
Do you know how to refer to a specific part of text?
Rafael
@rafaelpdl
Mar 13 2016 01:48
@grrttmrtn Hi. How did you say that I could put the format here?
Daniel Bashir
@db7894
Mar 13 2016 01:48
Like it you want to refer to the first item, second, etc.
James Good
@TajYemaj
Mar 13 2016 01:48
If you mean selecting data in an array then yes, if not then no.
bitgrower
@bitgrower
Mar 13 2016 01:48
explain format
CamperBot
@camperbot
Mar 13 2016 01:48

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

bitgrower
@bitgrower
Mar 13 2016 01:48
@rafaelpdl ^^^^^
Daniel Bashir
@db7894
Mar 13 2016 01:49
@TajYemaj Like the notation arr[i] for the ith member of an array
James Good
@TajYemaj
Mar 13 2016 01:49
myArray[2]
yeah
I understand that
Daniel Bashir
@db7894
Mar 13 2016 01:50
Ok cool so that's what I think you want to be using in the first for loop
Rafael
@rafaelpdl
Mar 13 2016 01:50
Thank you!
Garrett
@grrttmrtn
Mar 13 2016 01:50
@rafaelpdl okay a few things we need to work on
Daniel Bashir
@db7894
Mar 13 2016 01:50
@TajYemaj Your if loop doesn't seem right... What do you want it to check?
Rafael
@rafaelpdl
Mar 13 2016 01:50
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  var changeMe;
  var result = myObj.hasOwnProperty("checkProp");

  if (result===true) {
    changeMe=myObj.checkProp;
  } 
  else if (result===false) {
     changeMe="Not Found";
  }

  return changeMe;
}

// Test your code by modifying these values
checkObj("gift");
Garrett
@grrttmrtn
Mar 13 2016 01:51
@rafaelpdl first take a look at the example and see how they are checking true or false and start with that
Rafael
@rafaelpdl
Mar 13 2016 01:51

Hi Guys. Can someone help me? I need to "Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found"."

But I am getting the errors:
checkObj("gift") should return "pony".
checkObj("pet") should return "kitten".

Garrett
@grrttmrtn
Mar 13 2016 01:52
@rafaelpdl Yes, start with looking at how they are checking true/false in the example in comparison to your method
James Good
@TajYemaj
Mar 13 2016 01:52
The second for loop is supposed to increment and push each letter of my name into the new array
Daniel Bashir
@db7894
Mar 13 2016 01:52
@TajYemaj Right, but what do you want the if statement to do?
Sorry, didn't mean to call it an if loop up there :p
James Good
@TajYemaj
Mar 13 2016 01:53
The if statement says: "If we find the first letter of the name, start the second for loop!"
Daniel Bashir
@db7894
Mar 13 2016 01:53
@TajYemaj So you want it to find letters in your name
How do you want it to do that
James Good
@TajYemaj
Mar 13 2016 01:53
So, I see what your getting at with including something along the lines of myArray[0] to the first for loop
but with that problem description, it seems that's not the case, because they want me to find the first letter of my name in the array.
Garrett
@grrttmrtn
Mar 13 2016 01:55
@rafaelpdl Have you found anything?
Daniel Bashir
@db7894
Mar 13 2016 01:55
Right, but for it to get all the way through your name and make a new array, it can't stop at the first letter. Does that make sense?
James Good
@TajYemaj
Mar 13 2016 01:55
They don't have that same kind of tool for singling out a specific character in a variable as they do arrays.
Rafael
@rafaelpdl
Mar 13 2016 01:56

@grrttmrtn Thank you for the tip. In the problem it just says:

myObj.hasOwnProperty("top"); // true
myObj.hasOwnProperty("middle"); // false

I tried to change a bit my code, to what I will post following, but it still gives the same error. I am also confused why to the "False" case it doesnt give me an error, but to the "True" ones it does.

CamperBot
@camperbot
Mar 13 2016 01:56
rafaelpdl sends brownie points to @grrttmrtn :sparkles: :thumbsup: :sparkles:
James Good
@TajYemaj
Mar 13 2016 01:56
That's the for loop portion of it though, I still haven't solved how to write an if statement that recognizes the first letter of my name, and then determines if the rest of it actually is my name.
CamperBot
@camperbot
Mar 13 2016 01:56
:star: 267 | @grrttmrtn | http://www.freecodecamp.com/grrttmrtn
Garrett
@grrttmrtn
Mar 13 2016 01:57
@TajYemaj your first loop is going to look for your name. The second loop will look for the first letter of your name
Rafael
@rafaelpdl
Mar 13 2016 01:57
function checkObj(checkProp) {
  // Your Code Here
  var changeMe;


  if (myObj.hasOwnProperty(checkProp)===true) {
    changeMe=myObj.checkProp;
  } 
  else if (myObj.hasOwnProperty(checkProp)===false) {
     changeMe="Not Found";
  }

  return changeMe;
}
James Good
@TajYemaj
Mar 13 2016 01:57
In the event of there being any other pieces of data that start with J
Daniel Bashir
@db7894
Mar 13 2016 01:58
First let's figure out how you're going to search through the initial array
Ghost
@ghost~56bd2077e610378809c105cd
Mar 13 2016 01:58
what do you have so far @TajYemaj ?
Garrett
@grrttmrtn
Mar 13 2016 01:58
@TajYemaj your first loop finds your name, your nested loop will find the J in your name as when you return your value you will reference the name in the array. But @db7894 is correct, you need to work on your first loop
@rafaelpdl so if we look at those examples, we are testing true/false simply with hasOwnProperty(checkProp) so you do not need the ===true or ===false
Ghost
@ghost~56bd2077e610378809c105cd
Mar 13 2016 01:59
are you doing to search the text for your name challenege at the code academy?
James Good
@TajYemaj
Mar 13 2016 02:00
/*jshint multistr:true */
var text = ["kfjfklkj", "kflsjfk", "fksjafl", "jifj", "ijsjf", "b", "yueb", "n", "aj", "Jamey", "nfjfsi", "nfkjfl", "jsfueyqo", "wham", "fmfo", "Jamey"];
var myName = "Jamey";
var hits = [];
for (var i = 0; i < text.length; i++) {
if (text === myName) {
    for (var j = i; j <= myName.length; j++);
   {
    hits.push(j);
   }
 }
};
I haven't changed anything yet.
@Rogue00 yes
Daniel Bashir
@db7894
Mar 13 2016 02:00
So let's fix up your if statement first
Describe in your own words what you want it to check for
Rafael
@rafaelpdl
Mar 13 2016 02:01
@grrttmrtn Wow, I totally missed that! Thanks very much for your help! :) I did some other modification and now it worked! :)
CamperBot
@camperbot
Mar 13 2016 02:01
rafaelpdl sends brownie points to @grrttmrtn :sparkles: :thumbsup: :sparkles:
:warning: rafaelpdl already gave grrttmrtn points
Ghost
@ghost~56bd2077e610378809c105cd
Mar 13 2016 02:02
your if statement should be looking for the first letter if your name...not the myName variable
Daniel Bashir
@db7894
Mar 13 2016 02:02
@Rogue00 Let's try to let him figure it out :smile:
Ghost
@ghost~56bd2077e610378809c105cd
Mar 13 2016 02:02
captilization is important @TajYemaj
ok
@db7894
James Good
@TajYemaj
Mar 13 2016 02:02
I did have J in there before
Michael Mazzone
@GitMazzone
Mar 13 2016 02:02
Can someone take a look at my portfolio code on Dropbox? I'm using onepage-scroll.js and there are 4 sections that were previously working before I injected the onepage-scroll.js script and css, now it's only showing one section as a full page and not scrolling at all
Daniel Bashir
@db7894
Mar 13 2016 02:03
@TajYemaj So can you explain the purpose of your if loop? I know you know what it's supposed to do, but try to explain it
So we can work on translating that into code
Ghost
@ghost~56bd2077e610378809c105cd
Mar 13 2016 02:03
learning javascript is hard
Daniel Bashir
@db7894
Mar 13 2016 02:03
Yes it is
James Good
@TajYemaj
Mar 13 2016 02:03
Hai
The if statement is supposed to find the first letter of my name as the first for loop increments through the first array.
Daniel Bashir
@db7894
Mar 13 2016 02:04
Right
So what do you want to check in the first array?
James Good
@TajYemaj
Mar 13 2016 02:04
But I don't know how to pin-point that first letter precisely, which is why I made var myName.
Garrett
@grrttmrtn
Mar 13 2016 02:04
@rafaelpdl glad you got it figured out!
Ghost
@ghost~56bd2077e610378809c105cd
Mar 13 2016 02:04
you need var myName
James Good
@TajYemaj
Mar 13 2016 02:05
okay
Garrett
@grrttmrtn
Mar 13 2016 02:05
@TajYemaj Your first loop is going to find your name
Then once you've found that name
You're going to look inside your name for the letter J
it's multiple parts to find the singular letter
James Good
@TajYemaj
Mar 13 2016 02:05
I can't use something along the lines of myName[0] right?
Garrett
@grrttmrtn
Mar 13 2016 02:05
@TajYemaj you're close
James Good
@TajYemaj
Mar 13 2016 02:05
That doesn't work for variables
Daniel Bashir
@db7894
Mar 13 2016 02:05
@TajYemaj It's a string right now if I remember correctly
James Good
@TajYemaj
Mar 13 2016 02:06
yeah
Daniel Bashir
@db7894
Mar 13 2016 02:06
But you can do that notation for the first array
Think about it this way, you want to check each member of the first array to see if it's your name. Right?
James Good
@TajYemaj
Mar 13 2016 02:06
yeah
Daniel Bashir
@db7894
Mar 13 2016 02:07
So how do you want your if statement to do that
Garrett
@grrttmrtn
Mar 13 2016 02:07
@db7894 doesn't he technically want his for loop to do that not his if statement
Daniel Bashir
@db7894
Mar 13 2016 02:07
His for loop has a variable that cycles through but the if loop is supposed to do the checking
@TajYemaj How would you change the if statement to do that
James Good
@TajYemaj
Mar 13 2016 02:09
if (i === myName) ?...
Daniel Bashir
@db7894
Mar 13 2016 02:09
Not quite
You're using i which is good
But remember that i on its own is just a variable
So how can you utilize it to check the members of the first array
James Good
@TajYemaj
Mar 13 2016 02:09
if (i === myName.length)
noo..
Daniel Bashir
@db7894
Mar 13 2016 02:10
But you're not checking for lengths, correct?
You want to see if one of the elements of the array is your first name
Do you remember the notation for referring to an element of an array?
James Good
@TajYemaj
Mar 13 2016 02:10
myArray[0]
Daniel Bashir
@db7894
Mar 13 2016 02:11
Right so that would refer to the first element
So since your array is named text, what would text[0] be
James Good
@TajYemaj
Mar 13 2016 02:11
but I wouldn't set it to automatically refer to myName in the array
Daniel Bashir
@db7894
Mar 13 2016 02:11
@TajYemaj You're searching the array for your name
James Good
@TajYemaj
Mar 13 2016 02:12
text[myName]
Daniel Bashir
@db7894
Mar 13 2016 02:12
@TajYemaj Like you're looking at each element of the array from beginning to end and trying to see if it's your name or not
@TajYemaj But you can't refer to an element of the array like that
You need to have a number in the brackets
James Good
@TajYemaj
Mar 13 2016 02:12
ohh..
Daniel Bashir
@db7894
Mar 13 2016 02:12
So how do you check each element in the array
Remember your for loop and the variable
James Good
@TajYemaj
Mar 13 2016 02:13
I needed to change the first for loop right
Daniel Bashir
@db7894
Mar 13 2016 02:13
The if statement
Because it's not checking for what you want it to
James Good
@TajYemaj
Mar 13 2016 02:13
the for loop was correct?!
Daniel Bashir
@db7894
Mar 13 2016 02:14
Yup
James Good
@TajYemaj
Mar 13 2016 02:14
fack
Daniel Bashir
@db7894
Mar 13 2016 02:14
So how are you going to use the contents of your for loop in the if loop
Remember that when you're referring to the element of array it has to be a number
James Good
@TajYemaj
Mar 13 2016 02:14
if (text[] === myName)
Daniel Bashir
@db7894
Mar 13 2016 02:15
Right
So what do you want to put in the brackets
James Good
@TajYemaj
Mar 13 2016 02:15
i
Daniel Bashir
@db7894
Mar 13 2016 02:15
There we go! :smile:
Just so I know you understand, why do you want to put i in the brackets?
James Good
@TajYemaj
Mar 13 2016 02:16
because the value of i will change as it increments
as it searches through the contents of the array
Daniel Bashir
@db7894
Mar 13 2016 02:16
Great
James Good
@TajYemaj
Mar 13 2016 02:16
now the second for loop is effed too
Daniel Bashir
@db7894
Mar 13 2016 02:16
So your for loop now does what
Ok let's look at it
Can you repost your code?
James Good
@TajYemaj
Mar 13 2016 02:17
var text = ["kfjfklkj", "kflsjfk", "fksjafl", "jifj", "ijsjf", "b", "yueb", "n", "aj", "Jamey", "nfjfsi", "nfkjfl", "jsfueyqo", "wham", "fmfo", "Jamey"];
var myName = "Jamey";
var hits = [];
for (var i = 0; i < text.length; i++) {
if (text[i] === myName) {
    for (var j = i; j <= myName.length; j++);
   {
    hits.push(j);
   }
 }
};
I think I'll have a difficult time with this portion
iamlimo
@iamlimo
Mar 13 2016 02:17
This Basic Algorithm Challenges are too difficult
Daniel Bashir
@db7894
Mar 13 2016 02:17
So remind me of what the second for loop is supposed to do
James Good
@TajYemaj
Mar 13 2016 02:17
How to get it to increment through a string and push each individual character into the second array
Daniel Bashir
@db7894
Mar 13 2016 02:17
Ok
So is it supposed to increment through your name?
Or what string
James Good
@TajYemaj
Mar 13 2016 02:18
Yeah
Daniel Bashir
@db7894
Mar 13 2016 02:18
@iamlimo Tell me about it... :p
James Good
@TajYemaj
Mar 13 2016 02:18
once the if statement finds my name
Daniel Bashir
@db7894
Mar 13 2016 02:18
@TajYemaj The original string or the new one
James Good
@TajYemaj
Mar 13 2016 02:18
it's supposed to increment through myName
and push each character to the new array
iamlimo
@iamlimo
Mar 13 2016 02:18
@db7894 I just feel really stupid now
They are like other challenges but with out guidance or explanation on like other challenges
Daniel Bashir
@db7894
Mar 13 2016 02:19
@iamlimo Which one are you on? I might be able to help since I have 4 or so left
@TajYemaj Alright so can you remind me what the whole thing is supposed to do? It feels redundant that one would be finding your name in the array and the one within it just searches through your name for letters
iamlimo
@iamlimo
Mar 13 2016 02:20
@db7894 oh great
function largestOfFour(arr) {
  // You can do this!
  var newArray = 0;
  for ( var i = 0; i < newArray.length; i++){
    var arrayNew = arr.map( function(val){
      if (newArray <)
  }
  return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Daniel Bashir
@db7894
Mar 13 2016 02:21
@iamlimo Ahh this one...
iamlimo
@iamlimo
Mar 13 2016 02:21
@db7894 yes
Jeremy Benson
@jb840w
Mar 13 2016 02:21
Trying to finish the Profile Lookup, can't seem to get the No such contact portion to work
for (var i = 0; i < contacts.length; i++) {
        while (contacts[i].firstName === firstName) {
            if (contacts[i][prop]) {
              return contacts[i][prop];     
            } else {
              return "No such property";               
            } 
        }

    }
Daniel Bashir
@db7894
Mar 13 2016 02:21
So let's look at that first for loop
James Good
@TajYemaj
Mar 13 2016 02:21
@db7894 You pretty much summed it up. I can't see the use in this code, but that's what they want me to do.
/*jshint multistr:true */
var text = ["kfjfklkj", "kflsjfk", "fksjafl", "jifj", "ijsjf", "b", "yueb", "n", "aj", "Jamey", "nfjfsi", "nfkjfl", "jsfueyqo", "wham", "fmfo", "Jamey"];
var myName = "Jamey";
var hits = [];
for (var i = 0; i < text.length; i++) {
if (text[i] === myName) {
    for (var i = 0; i < myName.length; i++);
   {
    hits.push(j);
   }
 }
};
oops
gotta change push(j) to i
but how would that look
Xinyang Li
@li-xinyang
Mar 13 2016 02:22
Hey guys, I am doing seek and destroy and having this filter is not a function issue. Any hint? (Code below)
function destroyer(arr) {
  var target = arr[0];

  arr.forEach(function(value, index) {
    if (index !== 0) {
      target = target.filter(function(fVal) {
        if (fVal !== value) {
          return fVal;
        }
      });
    }
  });
  return target;
}
Daniel Bashir
@db7894
Mar 13 2016 02:22
@TajYemaj If it's supposed to cycle through your name then maybe you want to change your name into an array and cycle through it
It seems fairly ok at the moment
Ghost
@ghost~56bd2077e610378809c105cd
Mar 13 2016 02:22
the idea is to find your name somwhere within a body of text
James Good
@TajYemaj
Mar 13 2016 02:23
It's gotta be bad cause it keeps freezing that tab when I run it
Daniel Bashir
@db7894
Mar 13 2016 02:23
@iamlimo So what do you want to search through? Let's sort that out first
Xinyang Li
@li-xinyang
Mar 13 2016 02:23
I write my own test and this func does pass all of them.
var assert = require('chai').assert;
var algorithem = require('./13_SeekAndDestroy');

describe('Seek and Destroy', function() {
  var testCase = [
    [
      [1, 2, 3, 1, 2, 3], 2, 3
    ],
    [
      [1, 2, 3, 5, 1, 2, 3], 2, 3
    ],
    [
      [3, 5, 1, 2, 2], 2, 3, 5
    ],
    [
      [2, 3, 2, 3], 2, 3
    ],
    [
      ["tree", "hamburger", 53], "tree", 53
    ]
  ];
  var answerCase = [
    [1, 1],
    [1, 5, 1],
    [1],
    [],
    ['hamburger']
  ];
  describe('destroyer', function() {
    it('return correct array', function() {
      for (var i = 0; i < testCase.length; i++) {
        assert.deepEqual(algorithem.destroyer(testCase[i]), answerCase[i]);
      }
    });
  });
});
Daniel Bashir
@db7894
Mar 13 2016 02:24
Hold on @iamlimo @TajYemaj I'm really sorry but I have to go! If either of you still need help later just let me know but hopefully someone else can offer help as well
iamlimo
@iamlimo
Mar 13 2016 02:24
@db7894 oh ok. later
Ghost
@ghost~56bd2077e610378809c105cd
Mar 13 2016 02:24
i think your var text should look more like this @TajYemaj
var text = "Remember that one time you me and Scott \
went to the store to buy milk.";
youre supposed to be finding your name in he text
the*
Daniel Bashir
@db7894
Mar 13 2016 02:25
@iamlimo But think about what you want your for loops to search through and how you want to make them search through it
The array element notation I mentioned to taj might help you out with that
Ghost
@ghost~56bd2077e610378809c105cd
Mar 13 2016 02:25
in my version... if (text[i] === "S")
your var myName needs to be somewhere within the body of var text so the script can find it .. im sorry but i cant see from your image if it is or not @TajYemaj
James Good
@TajYemaj
Mar 13 2016 02:28
thanks @db7894 @Rogue00
CamperBot
@camperbot
Mar 13 2016 02:28
tajyemaj sends brownie points to @db7894 and @rogue00 :sparkles: :thumbsup: :sparkles:
:star: 269 | @rogue00 | http://www.freecodecamp.com/rogue00
:star: 266 | @db7894 | http://www.freecodecamp.com/db7894
James Good
@TajYemaj
Mar 13 2016 02:29
I kind of messed this exercise up and made it more difficult than it needed to be..
Ghost
@ghost~56bd2077e610378809c105cd
Mar 13 2016 02:29
ive done that as well
im not that far in front of your learning javascript
James Good
@TajYemaj
Mar 13 2016 02:29
I'm re-doing this portion of the javascript lesson
Ghost
@ghost~56bd2077e610378809c105cd
Mar 13 2016 02:29
i had to leave the challenges at fcc and begin at the code academy before i began to understand it
James Good
@TajYemaj
Mar 13 2016 02:29
I went through it months ago, and I just came back to it, but it skipped the first four steps that codeacademy walked me through.
var text was never meant to be an array!
Ghost
@ghost~56bd2077e610378809c105cd
Mar 13 2016 02:30
that one was consfusing
James Good
@TajYemaj
Mar 13 2016 02:30
I'm going through fcc too, but I'm also using the odinproject
Ghost
@ghost~56bd2077e610378809c105cd
Mar 13 2016 02:30
no...var text should be a string
i am as well
James Good
@TajYemaj
Mar 13 2016 02:30
yeah
iamlimo
@iamlimo
Mar 13 2016 02:31
Hi guys, i wanted to ask if it's good to search google for answers to the Basic Algorithms. Wow. I left codeacademy because it was getting stricter to get help @Rogue00 @TajYemaj
James Good
@TajYemaj
Mar 13 2016 02:31
Hopefully the Headfirst Javascript book has excellent descriptions.
Ghost
@ghost~56bd2077e610378809c105cd
Mar 13 2016 02:31
theres a lot of resources...basic javascript seems a little easier to pick up over there than here
James Good
@TajYemaj
Mar 13 2016 02:31
I haven't gotten to Basic Algorithms yet.
Ghost
@ghost~56bd2077e610378809c105cd
Mar 13 2016 02:32
im not sure about the algorithyms because i havent started them ye...but google has been pretty good for everything else :)
1ety
@1ety
Mar 13 2016 02:33
What is missing from the following code?
function palindrome(str) {
  // Good luck!
  var removeChar = str.replace(/[^A-Z0-9]/ig, "").toLowerCase();

  var checkPalindrome = removeChar.split('').reverse().join('');

  return removeChar===checkPalindrome;  
}
palindrome("eye");
Xinyang Li
@li-xinyang
Mar 13 2016 02:33
I think I have just figured out why it does not work. It is becuase the array is the only argument passed in the function, all other parameters are actually optional.
Michael Mazzone
@GitMazzone
Mar 13 2016 02:33
Can someone take a look at my portfolio code on Dropbox? I'm using onepage-scroll.js and there are 4 sections that were previously working before I injected the onepage-scroll.js script and css, now it's only showing one section as a full page and not scrolling at all
bitgrower
@bitgrower
Mar 13 2016 02:34
@iamlimo -- searching is a highly recommended way to look for help ... :)
Xinyang Li
@li-xinyang
Mar 13 2016 02:34
@1ety you might want to change your regex to /[^a-z0-9]/gi
no you are corret
Brian
@BrianCodes33
Mar 13 2016 02:35
I'm having trouble understanding nested for loops (i.e. multi dimensional arrays and how to implement them) . can someone help>
bitgrower
@bitgrower
Mar 13 2016 02:36
@BrianBorin -- you do the preceding array exercises and feel comfortable with them ?
Brian
@BrianCodes33
Mar 13 2016 02:36
Think so @bitgrower
Nesting For Loops
@bitgrower have you done this exercise
Ghost
@ghost~56bd2077e610378809c105cd
Mar 13 2016 02:37
thats where i got hung up in the basic javascript at fcc @BrianBorin i'm now taking the lessons at code academy to gain a better understanding
Xinyang Li
@li-xinyang
Mar 13 2016 02:37
iamlimo
@iamlimo
Mar 13 2016 02:37
@Rogue00 Codeacademy here I come
Daniel Bashir
@db7894
Mar 13 2016 02:38
I actually have 5 more minutes but can anyone help me with the falsy bouncer algorithm really quickly? My algorithm seems to work for removing all falsy values except for "" (even though I added in something for it)
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var newArr = [];
  for (i = 0; i < arr.length; i++) {
    if (arr[i] !== false && arr[i] !== "\"\"") {
      newArr.push(arr[i]);
    }
  }
  return newArr;
}

bouncer([7, "ate", "", false, 9]);
Ghost
@ghost~56bd2077e610378809c105cd
Mar 13 2016 02:38
Jordan Meyer
@Jordanmeyer89
Mar 13 2016 02:38
I had no idea it was gitter I have been wondering why it is called glitter for so long
Xinyang Li
@li-xinyang
Mar 13 2016 02:38
@db7894 try convert value into boolean using wrapper object Boolean(val)
This message was deleted
Boolean('') gives you false
Daniel Bashir
@db7894
Mar 13 2016 02:39
@li-xinyang So would I put that in my if statement?
Xinyang Li
@li-xinyang
Mar 13 2016 02:40
Yes and that should be the only condition you need to check
Daniel Bashir
@db7894
Mar 13 2016 02:40
So something like this?
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var newArr = [];
  for (i = 0; i < arr.length; i++) {
    if (arr[i] !== Boolean("")) {
      newArr.push(arr[i]);
    }
  }
  return newArr;
}

bouncer([7, "ate", "", false, 9]);
Xinyang Li
@li-xinyang
Mar 13 2016 02:41
BTW, try Array.filter which makes your code much clean
Daniel Bashir
@db7894
Mar 13 2016 02:41
Seems to have the same issue
Xinyang Li
@li-xinyang
Mar 13 2016 02:41
No, some thing like this.
Daniel Bashir
@db7894
Mar 13 2016 02:41
@li-xinyang I looked at the documentation but still don't understand it :worried:
Xinyang Li
@li-xinyang
Mar 13 2016 02:41
```
if (Boolean(val) !== false)
if (Boolean(val) !== false)
It is not hard, it is high level function provided by JS.
Daniel Bashir
@db7894
Mar 13 2016 02:43
Ah, I see... Thanks @li-xinyang
I'll look at it again, I don't think I understood .filter() too well but I'll look at that
CamperBot
@camperbot
Mar 13 2016 02:43
db7894 sends brownie points to @li-xinyang :sparkles: :thumbsup: :sparkles:
:star: 269 | @li-xinyang | http://www.freecodecamp.com/li-xinyang
Xinyang Li
@li-xinyang
Mar 13 2016 02:43
which talks about how to use high order function like filter, map and reduce
Brian
@BrianCodes33
Mar 13 2016 02:44
@li-xinyang i am not learning java, i am trying to learning javascript
Xinyang Li
@li-xinyang
Mar 13 2016 02:44
@BrianBorin but the concept is the same
basic thing two-dimension nested loop as Excel sheet
samamsam
@samsamam
Mar 13 2016 02:46
Hi Coders Iam having difficulty with the Escape Sequence in Strings in Javascript help would be appreciated I have this var myStr = "\" \ \" \" \t \" \" \t \" \" \r \" \" \n \""; but it does not work
Xinyang Li
@li-xinyang
Mar 13 2016 02:46
you have row and col. For example, you can use outer loop control the row and use inner loop to control col. Then it is pretty much similar to regular one dimension array.
Brian
@BrianCodes33
Mar 13 2016 02:47
but why cant they be separate arrays?
samamsam
@samsamam
Mar 13 2016 02:47
Its the topic Escape Sequence in Strings from boot camp
Xinyang Li
@li-xinyang
Mar 13 2016 02:47
@samsamam my suggesttion is always use '' for your string in JS which make your life much easy when you need to handle " in your string.
@samsamam Yes, I have done one before
Andre Jensen
@andrejensen302
Mar 13 2016 02:48
Anybody here finish the "escape sequences in strings" waypoint? I'm just a little confused on the instructions :/
Brian
@BrianCodes33
Mar 13 2016 02:48
why can't i have one array control the col and the other control the row? why do they have to be nested?
Xinyang Li
@li-xinyang
Mar 13 2016 02:50
@andrejensen302 You see the table with code and output?
@andrejensen302 just convert backslash tab tab carriage-return new-line into code and you can pass the test
samamsam
@samsamam
Mar 13 2016 02:50
var myStr = "\' \ \' \' \t \' \' \t \' \' \r \' \' \n \'"; tried this
@li-xinyang
Xinyang Li
@li-xinyang
Mar 13 2016 02:50
you do not need to escape \
or using ' for \
for example '\t' for tab
'\\' for backslash
bitgrower
@bitgrower
Mar 13 2016 02:51

in answer to your question, @BrianBorin -- yes, and I've helped many people here with that problem

...as to why it's nested ... it's a common programming construct ... and it allows for you to have very very deeply nested arrays if you should need them ...

Xinyang Li
@li-xinyang
Mar 13 2016 02:52
you also need to separted all these by space
samamsam
@samsamam
Mar 13 2016 02:52
@li-xinyang thanks it works
CamperBot
@camperbot
Mar 13 2016 02:52
samsamam sends brownie points to @li-xinyang :sparkles: :thumbsup: :sparkles:
:star: 270 | @li-xinyang | http://www.freecodecamp.com/li-xinyang
Xinyang Li
@li-xinyang
Mar 13 2016 02:52
@samsamam pleasure
Brian
@BrianCodes33
Mar 13 2016 02:52
@bitgrower can you help me with this specific exercise to gain an understanding
bitgrower
@bitgrower
Mar 13 2016 02:53
I'm not quite sure what understanding you are seeking, @BrianBorin ... :)
Brian
@BrianCodes33
Mar 13 2016 02:53
This message was deleted
bitgrower
@bitgrower
Mar 13 2016 02:54
so Brian -- did you do the challenge where you summed up all the elements in an array ?
Brian
@BrianCodes33
Mar 13 2016 02:54
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++) {
    return product;
  }
}}
// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr
am i on the right track?
Andre Jensen
@andrejensen302
Mar 13 2016 02:54
@li-xinyang Seriously?? That's it?? Well I feel like a dummy.. Thank you!!
CamperBot
@camperbot
Mar 13 2016 02:54
andrejensen302 sends brownie points to @li-xinyang :sparkles: :thumbsup: :sparkles:
:star: 271 | @li-xinyang | http://www.freecodecamp.com/li-xinyang
Andre Jensen
@andrejensen302
Mar 13 2016 02:54
@li-xinyang I got it to work
Garrett
@grrttmrtn
Mar 13 2016 02:55
@BrianBorin the way that is currently, product is always going to return as 1
Brian
@BrianCodes33
Mar 13 2016 02:55
i know can you help explain to me where to go with this problem
bitgrower
@bitgrower
Mar 13 2016 02:56
Brian
@BrianCodes33
Mar 13 2016 02:56
yes
bitgrower
@bitgrower
Mar 13 2016 02:57
so if I gave you an array, myArr = [3,4,5]; you would be comfortable writing the code to sum up the value of the members ?
Liam Bang
@Liam345
Mar 13 2016 02:58
function destroyer(arr) {
  // Remove all the values
 var args=[];
  for (var i=1;i<arguments.length;i++){
    args[i-1]=arguments[i];
  }

  for (var i=0;i<args.length;i++){
arr=arr.filter(function(val){
               return val!==args[i];
               });
  }


        return arr;
}

destroyer([1,2,3,1,2,3],2,3);
Hi this is mycode for seek and destroy. It works fine. But someone in the chat before said that filter does not require a for loop to filter out the element in arrays. How do I do that?
Brian
@BrianCodes33
Mar 13 2016 02:58
var total = 0;
for (var i=0; i<myArr.length; i++) {
   total += myArr
}
bitgrower
@bitgrower
Mar 13 2016 02:58
because the problem you want to solve is very close to that one except for 2 things...
  1. nested for loops (that is, you need to access a 2D array)
  2. you accumulate a product instead of a sum
okay ... if you were to make a product ? @BrianBorin ?
Brian
@BrianCodes33
Mar 13 2016 02:59
total *= myArr
bitgrower
@bitgrower
Mar 13 2016 02:59
well, not quite ... you need to initialize total to a different value :)
otherwise your product is gonna be 0
Brian
@BrianCodes33
Mar 13 2016 03:00
product *= myArr where product is = 1
is that right?
bitgrower
@bitgrower
Mar 13 2016 03:01
well, not quite
Brian
@BrianCodes33
Mar 13 2016 03:01
hmm
bitgrower
@bitgrower
Mar 13 2016 03:01
so in your summation, your summation is not quite right either -- you're not accessing each element of the array
you're going thru the for loop, but you need to use an INDEX to access each element within it
Brian
@BrianCodes33
Mar 13 2016 03:02
var product = 1;
for (var i=0; i<myArr.length; i++) {
   product += myArr
}
*=
Mariya
@mariyadiminsky
Mar 13 2016 03:03
I've been trying for the past many hours to recreate a basic login page that logs the user in with the username "this" and "isawesome", otherwise it will show warnings but no matter what I do, the form just won't log in. Can someone please advice on what's wrong with my code? My jquery isn't working either, I really have tried everything... and btw my code looks fine in Brackets but someone on plunker wont show: https://plnkr.co/edit/6EwON2GKAD2yzyjy6pJo?p=preview
Brian
@BrianCodes33
Mar 13 2016 03:03
var product = 1;
for (var i=0; i<myArr.length; i++) {
   product *= myArr[i]
}
bitgrower
@bitgrower
Mar 13 2016 03:03
YAY!!!!!
okay ...
so ... now we have a 2-D array ...
now ... an array consists of a bunch of elements ... your elements can be ANYTHING ... they can be numbers, strings, objects, functions (and any mix of these) .. as well as .. arrays ...
so ... no matter what elements I have in an array, they still get indexed the same way ...

myArr = [ 3,4,5]

myArr[1] = what ?

Juwdohr
@Juwdohr
Mar 13 2016 03:06
hey anyone know how to round a calculated number? Getting a long string from:
(temp-32)*(5/9)
bitgrower
@bitgrower
Mar 13 2016 03:06
look up Math on MDN, @Jarvis-327
(and your formula is not quite right, btw)
oh wait -- you're going the other way around ... nvm
Brian
@BrianCodes33
Mar 13 2016 03:07
@bitgrower i get that arrays can store different data types
Daniel J. Bray
@kekkerslawl
Mar 13 2016 03:07
can someone explain to me why this does not terminate when num=0
function convert(num) {
    //declare variables and arrays to hold the roman numbers
    var romanNumber = '';
    var arabicNumber = [ 0, 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000 ];
    var romanNumbers = [ '', 'I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M' ];

    //cycle through the arrays and determine the correct roman number for the arabic number
        while (num!==0){

          for (var i = 0; i<arabicNumber.length;i++){
            if(arabicNumber[i]>num){
                romanNumber+=romanNumbers[i-1];
                num-=arabicNumber[i-1];
                i=0;
            }
        }
    }


 return romanNumber;
}

convert(36);
bitgrower
@bitgrower
Mar 13 2016 03:07
yeah ... but what is myArr[1] in my example above, @BrianBorin ?
Brian
@BrianCodes33
Mar 13 2016 03:08
4
arakita
@arakita
Mar 13 2016 03:08
@UnlimiWorks @collinferry Thank you so much. I really really appreciate your help. I will be more careful next time. Thanks a lot.
CamperBot
@camperbot
Mar 13 2016 03:08
arakita sends brownie points to @unlimiworks and @collinferry :sparkles: :thumbsup: :sparkles:
:star: 358 | @unlimiworks | http://www.freecodecamp.com/unlimiworks
:star: 366 | @collinferry | http://www.freecodecamp.com/collinferry
Juwdohr
@Juwdohr
Mar 13 2016 03:08
@kekkerslawl it needs to go in reverse order.
Brian
@BrianCodes33
Mar 13 2016 03:09
@bitgrower myarr[1] = 4
Mariya
@mariyadiminsky
Mar 13 2016 03:09
I've been trying for the past many hours to recreate a basic login page that logs the user in with the username "this" and "isawesome", otherwise it will show warnings but no matter what I do, the form just won't log in. Can someone please advice on what's wrong with my code? My jquery isn't working either, I really have tried everything... and btw my code looks fine in Brackets but someone on plunker wont show: https://plnkr.co/edit/6EwON2GKAD2yzyjy6pJo?p=preview
bitgrower
@bitgrower
Mar 13 2016 03:09

cool ... so ...

if I have a 2-D array my2darr = [ [3,4,5], [9,10,11], ['b', 'a', 'c']];

what would my2darr[1] be equal to ?

Juwdohr
@Juwdohr
Mar 13 2016 03:10
[9,10, 11] @bitgrower
Brian
@BrianCodes33
Mar 13 2016 03:10
@Jarvis-327 that was for me! Haha jk I knew the answer
my2darr1 = 11
bitgrower
@bitgrower
Mar 13 2016 03:10

super ... so let's make it easy on ourselves ...

let's set my1darr = my2darr[1];

oops ... actually, @BrianBorin -- @Jarvis-327 is correct
now ... do you understand WHY ?
Brian
@BrianCodes33
Mar 13 2016 03:11
yes @bitgrower
Daniel J. Bray
@kekkerslawl
Mar 13 2016 03:11
@Jarvis-327 thanks. I got it to work starting with the highest numbers and roman numerals, but it takes a whole lot more iterations to complete. I can num down to 0 alot faster going in that order, but it won't terminate when num=0
CamperBot
@camperbot
Mar 13 2016 03:11
kekkerslawl sends brownie points to @jarvis-327 :sparkles: :thumbsup: :sparkles:
:star: 287 | @jarvis-327 | http://www.freecodecamp.com/jarvis-327
bitgrower
@bitgrower
Mar 13 2016 03:12
good, what's my2darr[2], then @BrianBorin
Brian
@BrianCodes33
Mar 13 2016 03:12
'b', 'a', 'c'
Jeremy Benson
@jb840w
Mar 13 2016 03:12

Hey all, I'm still having trouble with Profile Lookup

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

I can't seem to figure out how to insert the code to verify "No such contact"

bitgrower
@bitgrower
Mar 13 2016 03:13
well ... ['b', 'a', 'c'] .. let's not forget the brackets ... :)
Brian
@BrianCodes33
Mar 13 2016 03:13
yes @bitgrower
bitgrower
@bitgrower
Mar 13 2016 03:13
so ... if I set my1darr = my2darr[2] -- what doe my1darr equal ?
Brian
@BrianCodes33
Mar 13 2016 03:13
same thing
bitgrower
@bitgrower
Mar 13 2016 03:14
or, what is it ...
Brian
@BrianCodes33
Mar 13 2016 03:14
['b', 'a', 'c']
bitgrower
@bitgrower
Mar 13 2016 03:14
okay ... so, how would I address 'a' ?
Brian
@BrianCodes33
Mar 13 2016 03:14
my2darr[2][1]
bitgrower
@bitgrower
Mar 13 2016 03:15
awesome ...
Brian
@BrianCodes33
Mar 13 2016 03:15
that isn't that hard.
bitgrower
@bitgrower
Mar 13 2016 03:15
now ... in your nested loops ... you have i & j
Brian
@BrianCodes33
Mar 13 2016 03:15
yes @bitgrower
bitgrower
@bitgrower
Mar 13 2016 03:15
where would you put them to access an element in your 2d array ?
Juwdohr
@Juwdohr
Mar 13 2016 03:16
@bitgrower Hey looked it up on MDN, and it doesn't do it when I use the function.
Brian
@BrianCodes33
Mar 13 2016 03:16
don't understand your question.
where would i put them>
bitgrower
@bitgrower
Mar 13 2016 03:16
actually -- you have another big issue in your code @BrianBorin ...
you need to use the parameter you've been passed, not the name of the function
@Jarvis-327 ... sorry ... not sure what you are referring to ?
Brian
@BrianCodes33
Mar 13 2016 03:17
ahh
bitgrower
@bitgrower
Mar 13 2016 03:17
so what do you think? You think you can solve the challenge now ?
Brian
@BrianCodes33
Mar 13 2016 03:17
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++) {
    return product;
  }
}}
// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
bitgrower
@bitgrower
Mar 13 2016 03:18
well ... don't you have to multiply the product by something ?
go back and look at how you multiplied all the elements of a 1d array
Brian
@BrianCodes33
Mar 13 2016 03:18
    return product *= arr[i][j];
bitgrower
@bitgrower
Mar 13 2016 03:19
okay ... just one more problem I think ...
one slight issue here ...
what happens your very FIRST time thru your loop ?
Juwdohr
@Juwdohr
Mar 13 2016 03:19
@bitgrower You told me to look at math on mdn to figure out how to round a function.
bitgrower
@bitgrower
Mar 13 2016 03:20
(sorry, I may have missed this on our other examples) ...
@Jarvis-327 -- look up Math.round()
Brian
@BrianCodes33
Mar 13 2016 03:21
@bitgrower grrr frustrated
bitgrower
@bitgrower
Mar 13 2016 03:21
what happens when you execute a return statement ...
it's like a "go to jail" card in monopoly ...
Brian
@BrianCodes33
Mar 13 2016 03:22
it gives the function a value which i plug into the paramater?
Fyrequelle
@Fyrequelle
Mar 13 2016 03:22
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line


  var lookup = {

    alpha: "Adams",
    bravo: "Boston",
    charlie: "Chicago",
    delta: "Denver",
    echo: "Easy",
    foxtrot: "Frank"

  };

  result = lookup[val];

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

// Change this value to test
phoneticLookup("bravo");
I just finished this piece of code for "Using Objects for Lookups" and I have no idea why it works. It passed the test, but did I even do it right?
bitgrower
@bitgrower
Mar 13 2016 03:23

what if I just said

`function myFunc () {
var x = 1;
return x;
var y;
}

or ...

`function myFunc () {
var x = 1;
return x;
var y =2;
alert(y);
}

looks like it to me @Fyrequelle
Mariya
@mariyadiminsky
Mar 13 2016 03:24
I've been trying for the past many hours to recreate a basic login page that logs the user in with the username "this" and "isawesome", otherwise it will show warnings but no matter what I do, the form just won't log in. Can someone please advice on what's wrong with my code? My jquery isn't working either, I really have tried everything... and btw my code looks fine in Brackets but someone on plunker wont show: https://plnkr.co/edit/6EwON2GKAD2yzyjy6pJo?p=preview I am trying to recreate this, I tried their code and it works in Brackets: http://www.formget.com/javascript-login-form/
bitgrower
@bitgrower
Mar 13 2016 03:24
sorry ... @Mashadim --
Mariya
@mariyadiminsky
Mar 13 2016 03:25
@bitgrower for what?
bitgrower
@bitgrower
Mar 13 2016 03:25
sorry I can't be of help to you on your problem
Mariya
@mariyadiminsky
Mar 13 2016 03:26
@bitgrower You dont need to apologize for that lol, thanks.
CamperBot
@camperbot
Mar 13 2016 03:26
mashadim sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 838 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 13 2016 03:26
yeah, but I just want to let you know ...
dang it ... I have such a hard time switching rooms in gitter ...
Garrett
@grrttmrtn
Mar 13 2016 03:35
@Mashadim never used plunker before so I might be missing something..but I don't see anything that would be validating password and username
Liam Bang
@Liam345
Mar 13 2016 03:35
function destroyer(arr) {
  // Remove all the values
 var args=[];
  for (var i=1;i<arguments.length;i++){
    args[i-1]=arguments[i];
  }

  for (var i=0;i<args.length;i++){
arr=arr.filter(function(val){
               return val!==args[i];
               });
  }


        return arr;
}


destroyer([1,2,3,1,2,3],2,3);

Hi this is mycode for seek and destroy. It works fine. But someone in the chat before said that filter does not require a for loop to filter out the element in arrays. How do I do that?

@bitgrower

Garrett
@grrttmrtn
Mar 13 2016 03:36
you may need a server side language for actual login too.
bitgrower
@bitgrower
Mar 13 2016 03:36
lol @liam -- they are right !!!! I have one solution which kinda does what you are doing ....
however ... for this exercise, since you have basically 2 arrays, it's not quite as bad as it might be otherwise (and not as bad as what I did, at least I think, I have to go review that challenge sometime...)
I think if you want to do logins with js you need to use something like OAuth ... but I'm not sure -- the concept of security when you have client side capabilities to change the code kinda doesn't make complete sense to me ... :)
1ety
@1ety
Mar 13 2016 03:46
why is the following code doesn't run?
function factorialize(num) {

  int result =1;

  for(int i = 1; i<=num;i++){

    result = result*i;
  }
    return result;
}
Moisés Man
@moigithub
Mar 13 2016 03:46
no int on javscript...
replace with var
bitgrower
@bitgrower
Mar 13 2016 03:50
LOL !!!! this ain't c !
1ety
@1ety
Mar 13 2016 03:50
Thank you @moigithub
CamperBot
@camperbot
Mar 13 2016 03:50
1ety sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 749 | @moigithub | http://www.freecodecamp.com/moigithub
1ety
@1ety
Mar 13 2016 03:52
What is missing or wrong in this code?
function palindrome(str) {
  // Good luck!
  var removeChar = str.replace(/[^A-Z0-9]/ig, "").toLowerCase();

  var checkPalindrome = removeChar.split('').reverse().join('');

  return removeChar===checkPalindrome;  
}
palindrome("eye");
Moisés Man
@moigithub
Mar 13 2016 03:54
before return add console.log(.....) ur 2 variables.. n check the difference on console tab/dev tools
1ety
@1ety
Mar 13 2016 03:55
It says Error: SyntaxError: unfinished multi-Line comment.
What does it means?
Moisés Man
@moigithub
Mar 13 2016 03:56
tahts all ur code ??
clear the log n run code again...
Dylan
@dhcodes
Mar 13 2016 03:57
@1ety is it thinking your regex is a comment?
Moisés Man
@moigithub
Mar 13 2016 03:57
probably is a message from old code ?
Dylan
@dhcodes
Mar 13 2016 03:59
@1ety I just ran it in my palindrome ex and it completed
maybe copy it to your clipboard, click your cookies, and paste it back in
1ety
@1ety
Mar 13 2016 03:59
@dhcodes I wish I new. Do you have any suggestion how to change it?
Moisés Man
@moigithub
Mar 13 2016 03:59
yea code looks good.. probably browser need some refresh :)
1ety
@1ety
Mar 13 2016 04:02
Thank you @dhcodes . After Reset it runs ok.
CamperBot
@camperbot
Mar 13 2016 04:02
1ety sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star: 408 | @dhcodes | http://www.freecodecamp.com/dhcodes
Muhammed Shafi
@shafimpk
Mar 13 2016 04:11
var myStr = "<a href="www.example.com" 'target=_blank'>Link</a>";
var myStr = "<a href="www.example.com" 'target=_blank'>Link</a>";
please tell me the problem in this.
1- You should have two single quotes ' and four double quotes "
2- Only remove the backslashes \ used to escape quotes.
these are the issues I get
V Bhargav Chowdary
@bhargav4
Mar 13 2016 04:12
var myStr = "<a href="www.example.com" target='_blank'>Link</a>";
Dylan
@dhcodes
Mar 13 2016 04:14
@shafimpk what challenge is that?
Muhammed Shafi
@shafimpk
Mar 13 2016 04:14
@dhcodes Quoting Strings with Single Quotes
Catalin Scripcariu
@CatalinScr
Mar 13 2016 04:14
@shafimpk use this model :
var myStr = "<a href='www.example.com' 'target=_blank'>Link</a>";
Muhammed Shafi
@shafimpk
Mar 13 2016 04:15
@bhargav4 its not working
@CatalinScr but it says like You should have two single quotes ' and four double quotes "
Moisés Man
@moigithub
Mar 13 2016 04:15
if outside quotes are single quotes.. then inside need to be double quotes...
or viceversa... else they will "conflict" (unless u escape the inner quotes)
Catalin Scripcariu
@CatalinScr
Mar 13 2016 04:16
@shafimpk when you have already double quotes in interior use one quotes
Dylan
@dhcodes
Mar 13 2016 04:16
@shafimpk write it as it would be normally
and then add single quotes to the outside
ex. <a href = "www.example.com" ...
@shafimpk I think @CatalinScr is close but not quite
Ron Cruz
@Ronolibert
Mar 13 2016 04:17
function largestOfFour(arr) {
  var largestNums = [];
  var largest = 0;
  for (var i = 0; i < arr.length; i++){
    for (var j = 0; j < arr[i].length; j++){
      if( largest < arr[i][j]){
          largest = arr[i][j];
      }
    }
    largestNums.push(largest);
  }
  return largestNums;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
does anyone know why this doesn't work for one of the tests o.o
It works for all the other arrays, except for the second value in this array [[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]
Catalin Scripcariu
@CatalinScr
Mar 13 2016 04:19
help Quoting Strings with Single Quotes
CamperBot
@camperbot
Mar 13 2016 04:19

:point_right: challenge quoting strings with single quotes [wiki]

Quoting Strings with Single Quotes

String values in JavaScript may be written with single or double quotes, so long as you start and end with the same type of quote. Unlike some languages, single and double quotes are functionally identical in Javascript.

"This string has \"double quotes\" in it"

The value in using one or the other has to do with the need to escape quotes of the same type. If you have a string with many double quotes, this can be difficult to read and write. Instead, use single quotes:

'This string has "double quotes" in it. And "probably" lots of them.'

:pencil: read more about challenge quoting strings with single quotes on the FCC Wiki

Robert Richey
@0x0936
Mar 13 2016 04:19
@Ronolibert reset largest back to zero after each outer loop iteration
Ron Cruz
@Ronolibert
Mar 13 2016 04:20
OH
Alfred Thomas Torres
@sup3rpr0xy
Mar 13 2016 04:20
‘''
Ron Cruz
@Ronolibert
Mar 13 2016 04:20
Thanks, forgot about that
Alfred Thomas Torres
@sup3rpr0xy
Mar 13 2016 04:21
Hi, need help with 'Confirm the Ending’. I’m supposed to compare the last character of the two strings. Here’s my code
function end(str, target) {
  var a = str.substr(str.length - 1);
  var b = target.substr(target.length - 1);

  if (a === b) {
    return true;
  } else {
    return false;
  }

  return str;
}

end("where do you go from hereddf", "hereddf”);
uriznik
@uriznik
Mar 13 2016 04:22
This message was deleted
Catalin Scripcariu
@CatalinScr
Mar 13 2016 04:22
@shafimpk var myStr = '<a href="http://www.example.com" target="_blank">Link</a>';
Alfred Thomas Torres
@sup3rpr0xy
Mar 13 2016 04:23
help Confirm the Ending
CamperBot
@camperbot
Mar 13 2016 04:23

:point_right: algorithm confirm the ending [wiki]

Explanation:

The function is a whole Boolean operation. You need to return true if the first argument ends with the second argument. This means that for the problem script, it should return true for the end('Bastian', 'n'); case.

:pencil: read more about algorithm confirm the ending on the FCC Wiki

Moisés Man
@moigithub
Mar 13 2016 04:23
@sup3rpr0xy not only the last.. but ... depends on the whole second argument
Dylan
@dhcodes
Mar 13 2016 04:23
@CatalinScr that's it
@sup3rpr0xy you don't need to use a substr for target because the target is the letter you're trying to match
Catalin Scripcariu
@CatalinScr
Mar 13 2016 04:24
first I was thinking at other problem. Sorry for that.
help No repeats please
CamperBot
@camperbot
Mar 13 2016 04:25

:point_right: algorithm no repeats please [wiki]

Problem Explanation:

  • This task requires us to look at each possible permutation of a string. This is best done using a recursion function. Being able to build a function which collects all permutations of a string is a common interview question, so there is no shortage of tutorials out there on how to do this, in many different code languages.
  • This task can still be daunting even after watching a tutorial. You will want to send each new use of the function 3 inputs: 1. a new string (or character array) that is being built, 2. a position in your new string that's going to be filled next, and 3. an idea of what characters (more specifically positions) from the original string have yet to be used. The pseudo code will look something like this:

    ```
    var str = ???;
    perm(current position in original string, what's been used in original string, current string build thus far){
    if(current string is finished) {
    print current string;
    }else{
    for(var i = 0; i < str.length; i++) {

    if(str[i] has not been used) {
      put str[i] into the current position;
      mark str[i] as used
      perm(current position in original string, what's been used in original string, current string build thus far)
      unmark str[i] as used because another branch in the tree for i + 1 will still likely use it;
    }

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

1ety
@1ety
Mar 13 2016 04:26
Is the following expression says to replace any letter or digit with and empty space?
str.replace(/[^A-Z0-9]/ig
 str.replace(/[^A-Z0-9]/ig, "")
Catalin Scripcariu
@CatalinScr
Mar 13 2016 04:28
@1ety you can test this with http://regexr.com/
V Bhargav Chowdary
@bhargav4
Mar 13 2016 04:31

regex

i want to test if all elements in a string are numbers.
How do i do that
which str method do i use?
1ety
@1ety
Mar 13 2016 04:31
My question is: Does the expression str.replace(/[^A-Z0-9]/ig, "") means to replace any letter or digit of the string to empty space?
Dylan
@dhcodes
Mar 13 2016 04:33
@bhargav4 \d+
go through the exercises at www.regexone.com
they help a lot
Catalin Scripcariu
@CatalinScr
Mar 13 2016 04:33
@1ety if you will put space in double quotes
V Bhargav Chowdary
@bhargav4
Mar 13 2016 04:33
@dhcodes thanks
CamperBot
@camperbot
Mar 13 2016 04:33
bhargav4 sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star: 409 | @dhcodes | http://www.freecodecamp.com/dhcodes
V Bhargav Chowdary
@bhargav4
Mar 13 2016 04:58
help Validate US Telephone Numbers
CamperBot
@camperbot
Mar 13 2016 04:58

:point_right: algorithm validate us telephone numbers [wiki]

Problem Explanation:

  • The task is not that hard to understand, implementing it is the hardest part. You have a to validate an US phone number. This means there is a certain amount of numbers required, while you don't need to put the country code, you will still need the area code and use one of the few formats allowed.
:pencil: read more about algorithm validate us telephone numbers on the FCC Wiki
Fyrequelle
@Fyrequelle
Mar 13 2016 04:59
Can someone help me with the "Accessing Nested Arrays in JSON" challenge?
Matt Reynolds
@mareynolds
Mar 13 2016 05:00
somehow this isn't returning the desired result. I want myBike.getGear() to return 4 after calling myBike.setGear(4)
var Bike = function() {
  // Only change code below this line.
  var gear;
  this.setGear = function(gear) {
    this.gear = gear;
  };
  this.getGear = function() {
    return gear;
  };
};
var myBike = new Bike();
V Bhargav Chowdary
@bhargav4
Mar 13 2016 05:01
@Fyrequelle yes where are you stuck
paste your code here
Fyrequelle
@Fyrequelle
Mar 13 2016 05:03
Never mind. I got it after a lot of googling and trial and error.
Thanks though.
Matt Reynolds
@mareynolds
Mar 13 2016 05:03
Lucky charm
@luckycharm223
Mar 13 2016 05:10
any body know show to convert Celsius to fahrenheit?
Junn Eric
@juntyms
Mar 13 2016 05:11
@luckycharm223 var fahrenheit; fahrenheit = (celsius * (9/5)) + 32;
Lucky charm
@luckycharm223
Mar 13 2016 05:12
thank you @juntyms
CamperBot
@camperbot
Mar 13 2016 05:12
luckycharm223 sends brownie points to @juntyms :sparkles: :thumbsup: :sparkles:
:star: 255 | @juntyms | http://www.freecodecamp.com/juntyms
Muhammed Shafi
@shafimpk
Mar 13 2016 05:13
@CatalinScr @dhcodes thanks!
CamperBot
@camperbot
Mar 13 2016 05:13
shafimpk sends brownie points to @catalinscr and @dhcodes :sparkles: :thumbsup: :sparkles:
:star: 410 | @dhcodes | http://www.freecodecamp.com/dhcodes
:star: 341 | @catalinscr | http://www.freecodecamp.com/catalinscr
Muhammed Shafi
@shafimpk
Mar 13 2016 05:13
i figured it out myself
V Bhargav Chowdary
@bhargav4
Mar 13 2016 05:14
@acctg4code paste full code here
Junn Eric
@juntyms
Mar 13 2016 05:14

@acctg4code `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() {

// this is a private property
var gear = 1;

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

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

};

var myCar = new Car();

var myBike = new Bike();
`

Matt Reynolds
@mareynolds
Mar 13 2016 05:17
thanks @juntyms !
CamperBot
@camperbot
Mar 13 2016 05:17
acctg4code sends brownie points to @juntyms :sparkles: :thumbsup: :sparkles:
:star: 256 | @juntyms | http://www.freecodecamp.com/juntyms
Garrett
@grrttmrtn
Mar 13 2016 05:28
@juntyms don't use this
@juntyms make sure you're going private not public
asaki444
@asaki444
Mar 13 2016 05:28
Hey I am on the ceaser cipher
function rot13(str) {
  //created array
  //store unicode value
  //store letter
  var letter = "";
  //for loop to find unicode with array
  for (var i = 0; i < str.length; i++){
    var val = str.charCodeAt(i);
    if(65 >= val >= 90){
      if(val > 77){
    letter += String.fromCharCode(val-13);
      }
      else{
        letter += String.fromCharCode(val+13);
      }
  }
    else{
      letter += String.fromCharCode(val);
    }
}
  return letter;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Matt Reynolds
@mareynolds
Mar 13 2016 05:32
@grrttmrtn what would be better to use in this case than "this.setGear" ?
Garrett
@grrttmrtn
Mar 13 2016 05:32
@acctg4code variable.setGear
Matt Reynolds
@mareynolds
Mar 13 2016 05:36
I see. I don't think they've taught that yet in FCC, all I've seen so far is "var XXX" and "this.XXX" for public vs private variables
Garrett
@grrttmrtn
Mar 13 2016 05:38
@acctg4code it's taught in the setGear, getGear challenge
They tell you not to use this
there's some other stuff in that code that is messed up too
Jeremy
@YoJer
Mar 13 2016 05:47
Hey guys, I'm trying to use an API for random quotes. Any idea why this script works in codepen, but not when I make it locally on my computer and open it in browser? P.s. I'm importing jquery in the bottom of the body in my html:
  $.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function(a) {
    $("body").append(a[0].content + "<p>&mdash; " + a[0].title + "</p>")
  });
Jeremy
@YoJer
Mar 13 2016 05:57
Nevermind, only works for wordpress users
Catalin Scripcariu
@CatalinScr
Mar 13 2016 06:05
@Jchasee try to use FreeCodeCamp/HelpFrontEnd room
Greg
@madcoyote
Mar 13 2016 06:14
So when I run this code I made for the 'replacing If Else Chains with Switch" exercise, everything comes back good but it gives me a few errors saying not to use any else, if, and to have at least four break statements....but my code already does this, I have no if or else and I have 5 break statements...... Is this thing mesing with me?
Garrett
@grrttmrtn
Mar 13 2016 06:16
@madcoyote post code please
Greg
@madcoyote
Mar 13 2016 06:17

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

switch (val){

   case bob: 
   return "Marley";
   break;

}

   case 42:{
   return "the Answer";
   break;
 }

   case 1:{
   return "there is no #1";       
   break;
 }
   case 99:{
   return "Missed me so much";
   break;

}

   case 7{
   return "Ate Nine";
   break;

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

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

switch (val){

   case bob: 
   return "Marley";
   break;

}

   case 42:{
   return "the Answer";
   break;
 }

   case 1:{
   return "there is no #1";       
   break;
 }
   case 99:{
   return "Missed me so much";
   break;

}

   case 7{
   return "Ate Nine";
   break;
cannelflow
@cannelflow
Mar 13 2016 06:19
@madcoyote which exercise?
Greg
@madcoyote
Mar 13 2016 06:19
Replacing If Else Chains with Switch
cannelflow
@cannelflow
Mar 13 2016 06:20
can you paste it in single box
@madcoyote
DJ
@qualitymanifest
Mar 13 2016 06:20
@madcoyote don't return the values, assign them to answer
Greg
@madcoyote
Mar 13 2016 06:20
I'm not good at this lol
cannelflow
@cannelflow
Mar 13 2016 06:20
@madcoyote it is case "bob" not case bob
@madcoyote you can always try
Greg
@madcoyote
Mar 13 2016 06:21
doing that now... ok...
cannelflow
@cannelflow
Mar 13 2016 06:21
  do like case 42:
      answer="The Answer";
      break;
 not like 
   case 42:{
   return "the Answer";
   break;
 }
@madcoyote
@qualitymanifest is right :point_up: March 13, 2016 11:50 AM @madcoyote
DJ
@qualitymanifest
Mar 13 2016 06:23
@madcoyote the other problems are smaller. you're missing a { after case bob. and "bob" is a string so it should be case "bob"
then, even smaller problems - it should be The Answer not the Answer (notice the capital T)
Greg
@madcoyote
Mar 13 2016 06:29

switch (val){

   case "bob": {
   answer= "Marley";
   break;
   }

 case 42:{
   answer="The Answer";
   break;
 }

   case 1:{
   answer ="There is no #1";       
   break;
   }
   case 99:{
   answer= "Missed me by this much!";
   break;
   }

 case 7: {
   answer ="Ate Nine";
   break;

}
}

and its good!! thanks everyone!!!
lyrehs
@lyrehs
Mar 13 2016 06:39
thanks @osterbergmarcus for your help with Checkpoint: Golf Code. Ha ha. I think that if I were a golfer this would have clicked with me a lot faster. Am I correct in thinking now that "par" would be the sane as "num" or "val" in the if/else if statements?
CamperBot
@camperbot
Mar 13 2016 06:39
lyrehs sends brownie points to @osterbergmarcus :sparkles: :thumbsup: :sparkles:
:star: 219 | @osterbergmarcus | http://www.freecodecamp.com/osterbergmarcus
V Bhargav Chowdary
@bhargav4
Mar 13 2016 06:47
help symmetric difference
CamperBot
@camperbot
Mar 13 2016 06:47

:point_right: algorithm symmetric difference [wiki]

Problem Explanation:

Symmetric Difference is the difference between two sets.

So in the Symmetric Difference Algorithm you would work through the arrays of numbers something like this -

sym(A, B, C) Translates to sym(sym(A,B),C)

Or in plain English - First find the Symmetric Difference of Set A and Set B. Then find the Symmetric Difference of this new set and Set C.

So -

sym([1, 2, 5], [2, 3, 5], [3, 4, 5])

would equal

[1,4,5]

Here's a nice video tutorial (with an awful fake British accent!) -

YouTube - Symmetric Difference
:pencil: read more about algorithm symmetric difference on the FCC Wiki

Artem
@foolishhare
Mar 13 2016 06:48

function myFunction() {
'use strict';
var myVar = "jjj";

console.log(myVar);
}
myFunction();

// run and check the console
// myVar is not defined outside of myFunction

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

Does anybody know why it not worked?
Instructions
Declare a local variable myVar inside myFunction
help global variable
CamperBot
@camperbot
Mar 13 2016 06:51

:point_right: global variables [wiki]

you should ALWAYS use var to declare your variables (to make locally) else it will install GLOBALLY

http://www.w3.org/wiki/JavaScript_best_practices#Avoid_globals

http://c2.com/cgi/wiki?GlobalVariablesAreBad
:pencil: read more about global variables on the FCC Wiki

Artem
@foolishhare
Mar 13 2016 06:52
Thanks
V Arun Kumar
@arunvkumr
Mar 13 2016 06:53
@foolishhare can you tell whats the error you are getting?
Artem
@foolishhare
Mar 13 2016 06:56
No global myVar variable
In task
Stefan
@st3fun1
Mar 13 2016 06:58
help caesar cipher
CamperBot
@camperbot
Mar 13 2016 06:58
no wiki entry for: caesar cipher
Artem
@foolishhare
Mar 13 2016 06:59
"Local Scope and Functions" that tutorial called
Stefan
@st3fun1
Mar 13 2016 06:59
help caesars cipher
CamperBot
@camperbot
Mar 13 2016 06:59

:point_right: algorithm caesars cipher [wiki]

Problem Explanation:

  • You need to write a function, which will take string encoded with
    Caesar cipher as a parameter and decode it.
  • The one used here is ROT13 where the value of the letter is
    shifted by 13 places.
    e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
  • You have to shift it back 13 positions, such that 'N' ↔ 'A'.
:pencil: read more about algorithm caesars cipher on the FCC Wiki
V Arun Kumar
@arunvkumr
Mar 13 2016 07:00
@foolishhare your code looks fine.. i dont understand what's wrong.
post your code again.. with formating.
listen what camperbot has to say..
bot format
CamperBot
@camperbot
Mar 13 2016 07:01

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

V Arun Kumar
@arunvkumr
Mar 13 2016 07:01
@foolishhare :point_up: March 13, 2016 12:31 PM
Artem
@foolishhare
Mar 13 2016 07:02
Jesus! I done it... Problem was in myVar. I was didnt nesseary give some value for string

function myFunction() {
'use strict';
var myVar;

console.log(myVar);
}
myFunction();

That variant is worked)

function myFunction() {
'use strict';
var myVar;

console.log(myVar);
}
myFunction();

function myFunction() {
'use strict';
var myVar;

console.log(myVar);
}
myFunction();

function myFunction() {
'use strict';
var myVar;

console.log(myVar);
}
myFunction();
```

bot format
CamperBot
@camperbot
Mar 13 2016 07:03

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

V Arun Kumar
@arunvkumr
Mar 13 2016 07:03
@foolishhare use back ticks the one above tab..```
Artem
@foolishhare
Mar 13 2016 07:04
function myFunction() {
  'use strict';
  var myVar;

  console.log(myVar);
}
myFunction();
Wow!
It worked!
function myFunction() {
  'use strict';
  var myVar = "PPP";

  console.log(myVar);
}
myFunction();
And that dont work
Ariel
@abibliophile
Mar 13 2016 07:07
Hi! I'm working on "Stand In Line", one of the beginning JavaScript challenges
The challenge is to write a function queue that adds a number (item) to the end of the array (arr), removes the first element of the array, and then return the removed element
I know the first bit is to use arr.push(item);
then arr.pop();
but how do you refer to the number you removed?
V Arun Kumar
@arunvkumr
Mar 13 2016 07:12
@foolishhare both works for me though :smile:
@abibliophile pop will remove the last element not the first... to remove first element you need an different function
read about shift function
@abibliophile
Ariel
@abibliophile
Mar 13 2016 07:18
riiiight thanks @arunkumrv
CamperBot
@camperbot
Mar 13 2016 07:18
abibliophile sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 355 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Ariel
@abibliophile
Mar 13 2016 07:18
but how do i refer to the number that was removed?
V Arun Kumar
@arunvkumr
Mar 13 2016 07:19
@abibliophile you're welcome... now to your ques to refer to that number. The shift function returns the removed value so you have to store in other variable.
Ariel
@abibliophile
Mar 13 2016 07:20
hmm.. i remember that was in one of the former challenges. let me go back and look.
hmm, no, still need help, if that's okay
xxihawkxx
@xxihawkxx
Mar 13 2016 07:22
can anyone help me with my code?

function convert(celsius) {
// Only change code below this line
var fahrenheit;
fahrenheit = (celsius*9/2) + 32;
// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

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

V Arun Kumar
@arunvkumr
Mar 13 2016 07:23
@abibliophile like..
var newVariable = arr.shift(); <-- here you are storing the returned value into newVariable.
return newVariable; <-- here you are returning the variale newVariable.
either that :point_up_2: or :point_down: , both works :smile:
return arr.shift();<-- here you are directly returning the returned variable.
you should know how both of them works...
Ariel
@abibliophile
Mar 13 2016 07:24
oooh thanks! for some reason javascript is much harder for me to comprehend than html and i'm having trouble wrapping my head around simple concepts but i'm sure they'll stick better with time and practice! thanks again for all your help.
V Arun Kumar
@arunvkumr
Mar 13 2016 07:25
@xxihawkxx is the formula right?
xxihawkxx
@xxihawkxx
Mar 13 2016 07:25
@arunkumrv I guess so! Its the one provided in the instructions
Ariel
@abibliophile
Mar 13 2016 07:26
it seems wrong? I thought it was times 9 divided by 5
V Arun Kumar
@arunvkumr
Mar 13 2016 07:26
ya is 9 div by 5 @xxihawkxx
xxihawkxx
@xxihawkxx
Mar 13 2016 07:26
@abibliophile Oh damn! Yes yes.
@abibliophile @arunkumrv Thanks, it worked. Stupid of me to not rectify that! Thanks
CamperBot
@camperbot
Mar 13 2016 07:27
xxihawkxx sends brownie points to @abibliophile and @arunkumrv :sparkles: :thumbsup: :sparkles:
V Arun Kumar
@arunvkumr
Mar 13 2016 07:27
@abibliophile ya it's takes time.. just keep practicing and try to code daily. :smile:
CamperBot
@camperbot
Mar 13 2016 07:27
:star: 188 | @abibliophile | http://www.freecodecamp.com/abibliophile
:star: 356 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
xxihawkxx
@xxihawkxx
Mar 13 2016 07:27
@arunkumrv Yeah, i try to be regular :D
V Arun Kumar
@arunvkumr
Mar 13 2016 07:28
@xxihawkxx you're welcome. happy coding :grinning:
Ariel
@abibliophile
Mar 13 2016 07:28
it's fun so it's worth it! :D @xxihawkxx @arunkumrv
Sidharth Kriplani
@sidkrip
Mar 13 2016 07:39
help needed with the bonfire Caesers Cipher
CamperBot
@camperbot
Mar 13 2016 07:39
no wiki entry for: needed with the bonfire caesers cipher
Sidharth Kriplani
@sidkrip
Mar 13 2016 07:40
@arunkumrv have you done the bonfire Caesars Cipher?
Jay
@JayDaGrappler
Mar 13 2016 07:40
I'm also on the 'Stand In Line' task. When I run arr.shift(); and return arr.shift(); it's removing the values 1 and 2 from testArr [1,2,3,4,5], it's returning a value of 2 rather than 1. Why is it removing two values rather than just the first?
V Arun Kumar
@arunvkumr
Mar 13 2016 07:41
@sidkrip yes i have. you need any help?
Sidharth Kriplani
@sidkrip
Mar 13 2016 07:42
yes I will paste my code here:
function rot13(str) { // LBH QVQ VG!

  var reg=new RegExp(/([A-Z])/g);
  var arra=[];
  var array=[];
  array=str.split('');
  for (var i=0; i<array.length; i++) {
    if (array[i]===reg) {
      arra.push(convert(arr[i]));
    }
    else continue;
  }
  return arra;
}

function convert(str) {
  var cca=str.charCodeAt();
  var fccp=String.fromCharCode(cca+13);
  var fccm=String.fromCharCode(cca-13);
  if (cca<=77) {
    str=fccp;
  }
  else {
    str=fccm;
  }
  return str;  
}
J Player
@Heyjp
Mar 13 2016 07:42
@JayDaGrappler then only return arr.shift();
Sidharth Kriplani
@sidkrip
Mar 13 2016 07:42
the convert part works fine. The first function, the main one has some problem
@arunkumrv
Jay
@JayDaGrappler
Mar 13 2016 07:43

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

arr.shift();
arr.push(item);

return arr.shift(); // Change this line

J Player
@Heyjp
Mar 13 2016 07:43
remove the arr.shift() below // Your code here
Jay
@JayDaGrappler
Mar 13 2016 07:44
Okay, I'll give it a try. Thanks @Heyjp
CamperBot
@camperbot
Mar 13 2016 07:44
jaydagrappler sends brownie points to @heyjp :sparkles: :thumbsup: :sparkles:
:star: 333 | @heyjp | http://www.freecodecamp.com/heyjp
V Arun Kumar
@arunvkumr
Mar 13 2016 07:46
@sidkrip instead of array[i]===reg try using match or test function. because that statement always return false.
Jay
@JayDaGrappler
Mar 13 2016 07:46
Worked like a charm. So, just so I understand... By having arr.shift(); above and in the return value it still shifted another value off the array?
Sidharth Kriplani
@sidkrip
Mar 13 2016 07:46
@arunkumrv like?
J Player
@Heyjp
Mar 13 2016 07:48
Yes, basically you were calling arr.shift() twice so it was moving 2 values from the start, when you return arr.shift() it still removes the first value from the array, but it shows the value that was removed.
V Arun Kumar
@arunvkumr
Mar 13 2016 07:48
array[i] is an array element that holds an value and reg is just an expression.. they can never be equal. you need someother functions like test and match which takes reg as parameters to check..
read them up
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/match
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test
Jay
@JayDaGrappler
Mar 13 2016 07:49
I'll keep that in mind for the future. Thank again!
Abd-afeez Abd-hamid Adedamola
@Itsdenty
Mar 13 2016 07:50
please help i am stuck here, dont know what i did wrongly
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

// Change these values to test your function
lookUp("Akira", "likes");
V Arun Kumar
@arunvkumr
Mar 13 2016 07:51
@sidkrip :point_up: March 13, 2016 1:18 PM and inside if condition array is spelled arr.
@Itsdenty why i.hasOwnProperty,i[firstName]?
Abd-afeez Abd-hamid Adedamola
@Itsdenty
Mar 13 2016 07:54
yeah, should have been contacts[i] right? @arunkumrv
V Arun Kumar
@arunvkumr
Mar 13 2016 07:55
@Itsdenty ya.. contacts[i].
@Itsdenty also remove the else-if clause of no such contact.. it's breaking your loop whenever the firstname doesn't match without checking all entries in contacts.
bot profile
CamperBot
@camperbot
Mar 13 2016 07:57

:point_right: checkpoint profile lookup [wiki]

Checkpoint: Profile Lookup

Instructions

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

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

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

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

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

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

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

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

V Arun Kumar
@arunvkumr
Mar 13 2016 07:58
@Itsdenty you need one more condition for no such property.. read the desc of challenge :point_up: March 13, 2016 1:27 PM
Abd-afeez Abd-hamid Adedamola
@Itsdenty
Mar 13 2016 08:00
ok, thanks @arunkumrv i will review my code
CamperBot
@camperbot
Mar 13 2016 08:00
itsdenty sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 357 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Mar 13 2016 08:01
you're welcome :+1:
@sidkrip how's it going?
mudi thareja
@tharejamudit
Mar 13 2016 08:07
need some help in couting cards challenge
*counting
V Arun Kumar
@arunvkumr
Mar 13 2016 08:08
bot counting
CamperBot
@camperbot
Mar 13 2016 08:08

:point_right: checkpoint counting cards [wiki]

Checkpoint: Counting Cards

About Blackjack

In the casino game Blackjack, a player can gain an advantage over the house by keeping track of the relative number of high and low cards remaining in the deck. This is called Card Counting.

Having more high cards remaining in the deck favors the player. Each card is assigned a value according to the table below. When the count is positive, the player should bet high. When the count is zero or negative, the player should bet low.

Value Cards
+1 2, 3, 4, 5, 6
0 7, 8, 9
-1 10, 'J', 'Q', 'K','A'

Instructions

You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.

Example Output:

:pencil: read more about checkpoint counting cards on the FCC Wiki

mudi thareja
@tharejamudit
Mar 13 2016 08:09
i am getting null output
V Arun Kumar
@arunvkumr
Mar 13 2016 08:09
@tharejamudit share your code.. :smile:
mudi thareja
@tharejamudit
Mar 13 2016 08:10
```
V Arun Kumar
@arunvkumr
Mar 13 2016 08:11
bot format
CamperBot
@camperbot
Mar 13 2016 08:11

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

mudi thareja
@tharejamudit
Mar 13 2016 08:12
```js
var count = 0;

function cc(card) {
  // Only change code below this line
  switch(card){
    case 2:
      if(card==2){
         count++;
        return count+"Bet",+count;
      }
      break;
    case 3:
      if(card==3){
        count++;
        return card+"Bet",+card;
      }
      break;
    case 4:
      if(card==4){
        card++;
        return card+"Bet",+card;
      }
      break;
    case 5:
      if(card==5){
        card++;
        return card+"Bet",+card;
      }
      break;
    case 6:
      if(card==6){
        card++;
        return card+"Bet",+card;
      }
      break;
    case 7:
      if(card==7){
        card=0;
        return card+"Hold",+card;
      }
      break;
    case 8:
      if(card==8){
        card=0;
        return card+"Hold",+card;
      }
      break;
    case 9:
      if(card==9){
        card=0;
        return card+"Hold",+card;
      }
      break;
    case 10:
      if(card==10){
        card--;
        return card+"Hold",+card;
      }
      break;
    case "J":
      if(card=="J"){
        card--;
        return card+"Hold",+card;
      }
      break;
    case "Q":
      if(card=="Q"){
        card--;
        return card+"Hold",+card;
      }
      break;
      case "K":
      if(card=="K"){
        card--;
        return card+"Hold",+card;
      }
      break;
      case "A":
      if(card=="A"){
        card--;
        return card+"Hold",+card;
      }
      break;   

  }

  return "Change Me";
  // 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');
fixit it now
sorry *fixing it now
bitgrower
@bitgrower
Mar 13 2016 08:14
you need to adjust the card count in the switch statement, then after you are out of the switch statement, evaluate the count to decide what message to output
you also don't need to check in each case statement for the case "value" ...
V Arun Kumar
@arunvkumr
Mar 13 2016 08:15

@tharejamudit

case 2:
      if(card==2){

why you are using if inside case?

bitgrower
@bitgrower
Mar 13 2016 08:15
:point_up: March 13, 2016 12:14 AM @tharejamudit
mudi thareja
@tharejamudit
Mar 13 2016 08:18
or i should just use if else only
Sunil Choudhury
@linuschoudhury
Mar 13 2016 08:18
Have a problem in Title case a string algorithm challenge

```function titleCase(str) {
str = str.split(' ');
for(var i=0; i<str.length; i++){
for(var j = 0; j<str[i].length; j++) {
if(j===0)
str[i]=str[i].toUpperCase();
else
str[i]=str[i].toLowerCase();
}
str= str.join(' ');
}
return str;
}

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

function titleCase(str) {
  str = str.split(' ');
  for(var i=0; i<str.length; i++){
    for(var j = 0; j<str[i].length; j++) {
      if(j===0)
        str[i]=str[i].toUpperCase();
      else
        str[i]=str[i].toLowerCase();
    }
    str= str.join(' ');
  }
  return str;
}

titleCase("I'm a little tea pot");
Titlecase a string algo
showing an error
Type-Error: 1 is read only
uriznik
@uriznik
Mar 13 2016 08:21
This message was deleted
Markus Kiili
@Masd925
Mar 13 2016 08:35
@linuschoudhury During the loop, you transform the array back to string. Then you try to use it as an array later.
Maciej Bembenista
@macbem
Mar 13 2016 08:39
hey, could anyone help me out with JSON?
[{"name":"Poland","capital":"Warsaw","altSpellings":["PL","Republic of Poland","Rzeczpospolita Polska"],"relevance":"1.25","region":"Europe","subregion":"Eastern Europe","translations":{"de":"Polen","es":"Polonia","fr":"Pologne","ja":"ポーランド","it":"Polonia"},"population":38484000,"latlng":[52.0,20.0],"demonym":"Polish","area":312679.0,"gini":34.1,"timezones":["UTC+01:00"],"borders":["BLR","CZE","DEU","LTU","RUS","SVK","UKR"],"nativeName":"Polska","callingCodes":["48"],"topLevelDomain":[".pl"],"alpha2Code":"PL","alpha3Code":"POL","currencies":["PLN"],"languages":["pl"]}]
this is what I get via an API. How can I access it with javascript? I can't figure it out because of the [ ]
I tried
json.name
json[0].name
V Arun Kumar
@arunvkumr
Mar 13 2016 08:40
@linuschoudhury you are defining a j loop but where are you using the variable j?
Maciej Bembenista
@macbem
Mar 13 2016 08:40
nothing worked
rocket
@rengas
Mar 13 2016 08:45
I am trying the title case a sentence . I have this following code
''' str=str.toLowerCase().split("");
str[0] =str[0].toUpperCase();
var str1=str.join().replace(/[\,]/g,"");
console.log(str1); '''
CamperBot
@camperbot
Mar 13 2016 08:45
:bulb: to format code use backticks! ``` more info
rocket
@rengas
Mar 13 2016 08:45
str[0] =str[0].toUpperCase();
var str1=str.join().replace(/[\,]/g,"");
console.log(str1);
V Arun Kumar
@arunvkumr
Mar 13 2016 08:45
@noczesc i'm not goot with json api clients but let me know if this works..
$.getJSON("api-link" +var + "?callback=?", function(json) {
inside the function you can use `json[0].name`.
}
*good
rocket
@rengas
Mar 13 2016 08:46
when I console log . I get the correct result but cant pass the way point
Maciej Bembenista
@macbem
Mar 13 2016 08:46
@arunkumrv I already fetched the json, I just needed to access it, but I figured it out - I had a typo. Thanks for trying to help anyway! And yeah, your solution would work
CamperBot
@camperbot
Mar 13 2016 08:46
noczesc sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 358 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Mar 13 2016 08:47
@noczesc thanks for the info. :grinning: :+1:
CamperBot
@camperbot
Mar 13 2016 08:47
arunkumrv sends brownie points to @noczesc :sparkles: :thumbsup: :sparkles:
:star: 349 | @noczesc | http://www.freecodecamp.com/noczesc
sigursiguros
@sigursiguros
Mar 13 2016 08:56
HI can someone explain what's happening here? I'm having trouble understanding the filter function
var uniqueProducts = array.filter(function(elem, i, array) {
return array.indexOf(elem) === i;
}
);
var uniqueProducts = array.filter(function(elem, i, array) {
        return array.indexOf(elem) === i;
    }
);
bitgrower
@bitgrower
Mar 13 2016 09:01
@sigursiguros -- the gold standard is to check the mdn page on array.filter ... but, basically, array filter returns a new array filtering OUT any members for which your callback routine returns false ...
Darryl Leong
@darryleong95
Mar 13 2016 09:03

hey guys, im wondering if someone can help shed some light on this question i have; my query is how does where you input 'return true' affect the outcome and how come in some cases you dont have to write else/if. taking the code below for example. If i placed 'return true' one bracket above, it wouldnt work, can anyone explain this to me? much appreciated.

function mutation(arr) {
var arr1= arr[0].toLowerCase();
var arr2= arr[1].toLowerCase();
for ( var j=0; j<arr2.length; j++){
var check = arr1.indexOf(arr2[j]);
if (check === -1){
return false;
}
}
return true;
}
mutation(["Mary", "Army"]);

bitgrower
@bitgrower
Mar 13 2016 09:08
when your code hits a return statement it exits your function ... period.
Irina Sokolovskaja
@ierhyna
Mar 13 2016 09:16
wiki Validate US Telephone Numbers
CamperBot
@camperbot
Mar 13 2016 09:16

:point_right: algorithm validate us telephone numbers [wiki]

Problem Explanation:

  • The task is not that hard to understand, implementing it is the hardest part. You have a to validate an US phone number. This means there is a certain amount of numbers required, while you don't need to put the country code, you will still need the area code and use one of the few formats allowed.
:pencil: read more about algorithm validate us telephone numbers on the FCC Wiki
Fatah N
@fatahn
Mar 13 2016 09:17
@darryleong95 your return true is within the for loop while return true is inside your main function. No. If you don't need to run any code on the else side, you don't need an else clause.[SO answer]

hey guys I am attempting Falsy Bouncer but having trouble passing last two tests.

bouncer([false, null, 0, NaN, undefined, ""]) should return [].

bouncer([1, null, NaN, 2, undefined]) should return [1, 2].
here is my code:

function bouncer(arr) { function isFalsy(value) { return value != new Boolean(false); } arr = arr.filter(isFalsy); return arr; } bouncer([false, null, 0, NaN, undefined, ""]);\

Darryl Leong
@darryleong95
Mar 13 2016 09:23
@nfatah thanks man, i think i understand a little better now.appreciate it
CamperBot
@camperbot
Mar 13 2016 09:23
darryleong95 sends brownie points to @nfatah :sparkles: :thumbsup: :sparkles:
:star: 265 | @nfatah | http://www.freecodecamp.com/nfatah
Ron Cruz
@Ronolibert
Mar 13 2016 09:32
to format the code so its easier to read
put it in between ```
above and below your copy and pasted code
``` above and
``` below
sigursiguros
@sigursiguros
Mar 13 2016 09:50
thanks @bitgrower
CamperBot
@camperbot
Mar 13 2016 09:50
sigursiguros sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 839 | @bitgrower | http://www.freecodecamp.com/bitgrower
sigursiguros
@sigursiguros
Mar 13 2016 09:50
function inventory(arr1, arr2) {
  var length = arr1.length;
  for (var i=0; i<arr2.length; i++){
    for (var j=0; j<length; j++){
      if (arr2[i][1] === arr1[j][1]){
      arr1[j][0] += arr2[i][0];
      }
    else {
      arr1.push(arr2[i]);
    }
    }
  }
      // All inventory must be accounted for or you're fired!
    return arr1;
}

// Example inventory lists
var curInv = [
    [21, "Bowling Ball"],
    [2, "Dirty Sock"],
    [1, "Hair Pin"],
    [5, "Microphone"]
];

var newInv = [
    [2, "Hair Pin"],
    [3, "Half-Eaten Apple"],
    [67, "Bowling Ball"],
    [7, "Toothpaste"]
];

inventory(curInv, newInv);
HI guys, why is my code returning more arrays than it should. This is the inventory update algo.
mattgrind
@mattgrind
Mar 13 2016 09:52
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) {
  var property=collection.id.prop;
  if(value!==""&&prop!=="tracks")
    property=value;
  else if(prop=="tracks"&&value!=="")
    property.push(value);
  else if(value==="")
    property.value="";
  return collection;
}

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

Hello, can anyone help me understand why I am getting this error: TypeError: Cannot read property 'prop' of undefined?

thanks

Ron Cruz
@Ronolibert
Mar 13 2016 09:53
look at the note for that exercise
I remember having the same problem haha
I think the note says, make sure to use bracket notation when you're dealing with variables
mattgrind
@mattgrind
Mar 13 2016 09:54
yesss, i tried several times with bracket notation but ill mess around with it again. thanks for the tip!
Ron Cruz
@Ronolibert
Mar 13 2016 09:54
try using bracket notation for the id too
Jeremy
@YoJer
Mar 13 2016 09:55
Hey guys, can someone explain this code:
data: {sentence: $("#boxArea").val()},
the sentence in data = the value in th