These are chat archives for FreeCodeCamp/HelpJavaScript

21st
Jan 2016
Wenceslao Villegas Marset
@SpiralOut17
Jan 21 2016 00:07
Hi can anyone explain me how this code works?

function factorialize(num) {
if (num === 0) {
return 1;
}
return num * factorialize(num - 1);

}

factorialize(5);

eeflores
@eeflores
Jan 21 2016 00:08
@SpiralOut17 it's a recursive function (it calls itself) until the parameter it sends itself is 0
ulBenson
@ulbenson
Jan 21 2016 00:09
when num===0 it stop will not call itself
Chris Moore
@dooglus
Jan 21 2016 00:15
@SpiralOut17 5! is 5 times 4!, right?
@SpiralOut17 so if you can work out 4!, you just multiply it by 5 to get 5! - that's what the function is doing. with a base case that 0! is 1
5! = 5 * 4!
   = 5 * 4 * 3!
   = 5 * 4 * 3 * 2!
   = 5 * 4 * 3 * 2 * 1!
   = 5 * 4 * 3 * 2 * 1 * 0!
   = 5 * 4 * 3 * 2 * 1 * 1
William Reed
@reforma
Jan 21 2016 00:18
Can anyone explain what i have done wrong here each if statement works but together it does not
//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 (i = 0; i<contacts.length; i ++){

   if (firstName !== contacts[i].firstName)
   {return "No such contact";}

  if (prop !== contacts[i][prop]){
     return "No such property";}

  if (firstName == contacts[i].firstName){ 
return contacts[i][prop];}



   //}
   }
// Only change code above this line
}

// Change these values to test your function
lookUp("Kritian", "lastName");
daniel
@h311o
Jan 21 2016 00:19
What am I missing here? It simply returns the same array that was passed every time.
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var newArray = [];
  newArray = arr.filter(function(val) {
    return (val !== false || val !== null || val !== 0 || val !== "" || val !== undefined || (!val.isNaN()) );
  });
  return newArray;
}

bouncer([7, "ate", "", false, 9]);
Chris Moore
@dooglus
Jan 21 2016 00:19
@reforma you spelled the name wrong on the last line?
William Reed
@reforma
Jan 21 2016 00:20
@dooglus sorry i cant see where
Chris Moore
@dooglus
Jan 21 2016 00:20
Kritian vs. Kristian?
William Reed
@reforma
Jan 21 2016 00:21
Ahh yes - but when i correct that it still does not work
Chris Moore
@dooglus
Jan 21 2016 00:21
@reforma what's the waypoint called?
William Reed
@reforma
Jan 21 2016 00:21
profile lookup
Chris Moore
@dooglus
Jan 21 2016 00:22
@reforma oh, I didn't see that one yet. what's the URL?
Kevin Elser
@CoffeeCodeKevin
Jan 21 2016 00:22
Could someone here take a look at my portfolio so far and help me fix a (hopefully) simple issue I'm having?
William Reed
@reforma
Jan 21 2016 00:22
http://www.freecodecamp.com/challenges/profile-lookup#?solution=%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%2C%0A%5D%3B%0A%0A%0Afunction%20lookUp(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20for%20(i%20%3D%200%3B%20i%3Ccontacts.length%3B%20i%20%2B%2B)%7B%0A%20%20%20%20%0A%20%20%20if%20(firstName%20!%3D%3D%20contacts%5Bi%5D.firstName)%0A%20%20%20%7Breturn%20%22No%20such%20contact%22%3B%7D%0A%20%20%20%0A%20%20if%20(prop%20!%3D%3D%20contacts%5Bi%5D%5Bprop%5D)%7B%0A%20%20%20%20%20return%20%22No%20such%20property%22%3B%7D%0A%20%20%20%0A%20%20if%20(firstName%20%3D%3D%20contacts%5Bi%5D.firstName)%7B%20%0Areturn%20contacts%5Bi%5D%5Bprop%5D%3B%7D%0A%20%20%20%0A%20%20%20%0A%20%20%20%0A%20%20%20%2F%2F%7D%0A%20%20%20%7D%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUp(%22Sherlock%22%2C%20%22lastName%22)%3B%0A
Chris Moore
@dooglus
Jan 21 2016 00:23
@reforma just http://www.freecodecamp.com/challenges/profile-lookup is enough, thanks :)
CamperBot
@camperbot
Jan 21 2016 00:23
dooglus sends brownie points to @reforma :sparkles: :thumbsup: :sparkles:
:star: 228 | @reforma | http://www.freecodecamp.com/reforma
William Reed
@reforma
Jan 21 2016 00:24
i think the problem is that i am asking it to go through the whole database and check when it finds no match return no such contact but obviously if it does not find a match in the first check it stops and returns no such contact
Jessie
@jvhensley
Jan 21 2016 00:24
Asking for help again with this. Anyone? This code is not testing correctly and I can't understand why. It's for Make Unique Objects by Passing Parameters to Our Constructor.
var Car = function(wheels, seats, engines) {
  //Change this constructor
  this.wheels = 4;
  this.seats = 1;
  this.engines = 1;
};

//Try it out here
var myCar = new Car(3, 1, 2);
Chris Moore
@dooglus
Jan 21 2016 00:25
@reforma that's exactly it. if the first contact it looks at doesn't have the right name it will give up instantly and say 'no such contact'
@reforma instead, don't do the 'no such contact' thing inside the loop. inside the loop, return an appropriate response when you do find the right contact. then after the loop, if you get there, you know the contact wasn't found
(because if it was you would have returned already)
William Reed
@reforma
Jan 21 2016 00:27
ahhh yes thank you @dooglus
CamperBot
@camperbot
Jan 21 2016 00:27
reforma sends brownie points to @dooglus :sparkles: :thumbsup: :sparkles:
:star: 314 | @dooglus | http://www.freecodecamp.com/dooglus
William Reed
@reforma
Jan 21 2016 00:27
wil try that now
Chris Moore
@dooglus
Jan 21 2016 00:27
@jvhensley your constructor isn't using the parameters it is passed - it is using the 4, 1, and 1 hardcoded values
@jvhensley ie. your constructor is doing this.wheels = 4; every time, even though you are telling it to build a three-wheeler
Jessie
@jvhensley
Jan 21 2016 00:30
@dooglus thanks, i will consider that for a moment...
hernc
@hernc
Jan 21 2016 00:32
wiki element
CamperBot
@camperbot
Jan 21 2016 00:32

:point_right: waypoint add borders around your elements [wiki]

CSS borders have attributes like style, color and width.

For example, if we wanted to create a red, 5 pixel border around an HTML element, we could use this class: <style> .thin-red-border { border-color: red; border-width: 5px; border-style: solid; } </style>.
:pencil: read more about waypoint add borders around your elements on the FCC Wiki

hernc
@hernc
Jan 21 2016 00:33
wiki js element
CamperBot
@camperbot
Jan 21 2016 00:33
no wiki entry for: js element
hernc
@hernc
Jan 21 2016 00:33
find fn(e)
CamperBot
@camperbot
Jan 21 2016 00:33
find fne
nothing found
Chris Moore
@dooglus
Jan 21 2016 00:33
hernc: as in what arrays are made of?
hernc
@hernc
Jan 21 2016 00:34
yes @dooglus
Chris Moore
@dooglus
Jan 21 2016 00:34
hernc: what do you want to know?
wiki Array
CamperBot
@camperbot
Jan 21 2016 00:34

:point_right: array.isarray [wiki]

Array.isArray

The Array.isArray() method returns true if an object is an array, false if it is not.

:pencil: read more about arrayisarray on the FCC Wiki

hernc
@hernc
Jan 21 2016 00:35
I'm trying to understand the element aspect better


//filter the arr with a callback function to filter out every element that matches  
  return arr.filter(function(element){
  //returns all matches which will be filtered
    return args.indexOf(element) === -1;
Chris Moore
@dooglus
Jan 21 2016 00:35
oh, that word element could just as easily be carrot or most other words
it isn't a special word
hernc
@hernc
Jan 21 2016 00:35
ohhhh
man no wonder i cant find nothing on it
Chris Moore
@dooglus
Jan 21 2016 00:36
it's saying 'here is a function which takes one parameter, let's call it "element"..."
hernc
@hernc
Jan 21 2016 00:36
right
@dooglus thanks. I didn't want to move on till I understood that one last part.
CamperBot
@camperbot
Jan 21 2016 00:37
hernc sends brownie points to @dooglus :sparkles: :thumbsup: :sparkles:
:star: 315 | @dooglus | http://www.freecodecamp.com/dooglus
Chris Moore
@dooglus
Jan 21 2016 00:37
but since it's being passed to Array.filter(), we know it is going to be passed the elements of arr, one at a time, and so it makes sense to call its parameter element
if I was writing that code, I would probably call the parameter e or something, because it's quicker to type. then a month later I would come back to the code and struggle to remember what e stood for...
hernc
@hernc
Jan 21 2016 00:38
yea thats what I'm trying to avoid. jaja
Chris Moore
@dooglus
Jan 21 2016 00:39
it's good that you're doing this properly, not just doing the bare minimum to get through the tests :)
if there's anything else you want to ask about, I can try to help you with it
hernc
@hernc
Jan 21 2016 00:40
thanks I appreciate it that
Nerando Johnson
@nerajno
Jan 21 2016 00:43
friends, family and fiends ( plus that alien and NSA computer ) greetings :smile:
i am doing the multi-dimensional with indexes an i am getting it but i am a bit lost
can i get some help
Eric Saldivar
@esaldivar
Jan 21 2016 00:49
hello having trouble with making object properties private
var Car = function() {
  // this is a private variable
  var speed = 10;

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

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

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

var Bike = function() {

  // Only change code below this line.

};

var myCar = new Car();

var myBike = new Bike();
var gear = 4;
this.setGear = function(change) {
  gear += change; };{
    this.getGear = function() {
      return gear;
    };

}
Simon Situ
@ssitu001
Jan 21 2016 00:54
var collectionCopy = JSON.parse(JSON.stringify(collection));

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


  }
any help please
Jessie
@jvhensley
Jan 21 2016 00:54
@esaldivar you have created your code for var Bike outside of the var Bike curly braces
sciand6
@sciand6
Jan 21 2016 00:56
Not sure how to return a property's value.
Pandarati
@Pandarati
Jan 21 2016 01:02
@ssitu001 I think the problem is in your delete. You are deleting the value of the prop and not the actual property(3rd if statement).
Simon Situ
@ssitu001
Jan 21 2016 01:03
@Pandarati "If value is blank, delete that prop."
Pandarati
@Pandarati
Jan 21 2016 01:04
@nerajno You can try referencing the wiki if you are a bit lost.
wiki Access Multi-Dimensional Arrays With Indexes
CamperBot
@camperbot
Jan 21 2016 01:04

:point_right: waypoint access multi dimensional arrays with indexes [wiki]

Access Multi-Dimensional Arrays With Indexes

One way to think of a multi-dimensional array, is as an array of arrays. When you use brackets to access your array, the first set of bracket refers to the entries in the outer-most array, and each subsequent level of brackets refers to the next level of entries inside.

:pencil: read more about waypoint access multi dimensional arrays with indexes on the FCC Wiki

Pandarati
@Pandarati
Jan 21 2016 01:05
@ssitu001 Can I view all of the code to better help you?
sciand6
@sciand6
Jan 21 2016 01:06
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");
It's not returning "Not Found" for "house"
Eric Saldivar
@esaldivar
Jan 21 2016 01:06
var Car = function() {
  // this is a private variable
  var speed = 10;

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

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

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

var Bike = function() {

  // Only change code below this line.

};

var myCar = new Car();

var myBike = new Bike();
var gear = 10;
this.getGear = function(gear) {
  gear;
};
don't know what's going wrong
Pandarati
@Pandarati
Jan 21 2016 01:07
myObj.hasOwnProperty(checkProp); returns true of false. You may want to use that in the if to see whether the property has the value or not
@sciand6
Simon Situ
@ssitu001
Jan 21 2016 01:08
@Pandarati i figured it out, I had the if statements nested in an object loop :/
Pandarati
@Pandarati
Jan 21 2016 01:08
@esaldivar For this challenge, you should view the wiki. It's very helpful for this one.
wiki Waypoint Make Object Properties Private
CamperBot
@camperbot
Jan 21 2016 01:08

:point_right: waypoint make object properties private [wiki]

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

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

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

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

};

Another example:

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

Pandarati
@Pandarati
Jan 21 2016 01:09
@ssitu001 That's great! Happy coding!
William Reed
@reforma
Jan 21 2016 01:12
can anyone help me with profile lookup
please
Pandarati
@Pandarati
Jan 21 2016 01:13
@reforma Sure. Post your code and I will help to the best of my abilities
William Reed
@reforma
Jan 21 2016 01:13
//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 (i = 0; i<contacts.length; i ++){

if (firstName == contacts[i].firstName){ 
return contacts[i][prop];}

if (contacts.hasOwnProperty(prop) === false)
return "No such Property";}

//else {return "No such contact";}   




// Only change code above this line
}

// Change these values to test your function
lookUp("Bob", "numer");
i have managed to get the loop to work
but i cant get it to return no such property correctly
if it is in the loop then it stops after the first check that finds no match
function lookUp(firstName, prop){
// Only change code below this line
 for (i = 0; i<contacts.length; i ++){

if (firstName == contacts[i].firstName){ 
return contacts[i][prop];}

 if (firstName !== contacts[i].firstName){ 
return "No such contact";}
 }
this just returns no such contact no matter what
CharmedSatyr
@CharmedSatyr
Jan 21 2016 01:16
help record collection
CamperBot
@camperbot
Jan 21 2016 01:16

:point_right: checkpoint record collection [wiki]

Checkpoint: Record Collection

Instructions

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

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

For the given id in collection:

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

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

If value is blank, delete that prop.

Always return the entire collection object.

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

:pencil: read more about checkpoint record collection on the FCC Wiki

William Reed
@reforma
Jan 21 2016 01:17
help profile lookup
CamperBot
@camperbot
Jan 21 2016 01:17

: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

Pandarati
@Pandarati
Jan 21 2016 01:18
@reforma I would "sift" with the if statements and return no such contact as a default return
William Reed
@reforma
Jan 21 2016 01:18
@Pandarati thank you
CamperBot
@camperbot
Jan 21 2016 01:18
reforma sends brownie points to @pandarati :sparkles: :thumbsup: :sparkles:
:star: 323 | @pandarati | http://www.freecodecamp.com/pandarati
Eric Saldivar
@esaldivar
Jan 21 2016 01:19
so far ive come up with this :
var Car = function() {
  // this is a private variable
  var speed = 10;

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

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

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

var Bike = function() {

  // Only change code below this line.

};

var myCar = new Car();

var myBike = new Bike();
var gear= 10;
this.getGear= function() {
   return gear;
};
this.setGear=function(num) {
  gear = num;
};
Pandarati
@Pandarati
Jan 21 2016 01:20
@reforma For example: Do first names match? Yes. Does this person have this property. Yes, so let's return it. Else if they didn't. This person doesn't have the property
William Reed
@reforma
Jan 21 2016 01:20
great that makes sence thank you
Pandarati
@Pandarati
Jan 21 2016 01:22
@esaldivar I think you understand the challenge. Just be sure to go over the instructions carefully.
Also, don't be afraid to reset the challenge if you need to.
Nerando Johnson
@nerajno
Jan 21 2016 01:24
any one can help me with Access MultiDimensional Arrays With Indexes
Pandarati
@Pandarati
Jan 21 2016 01:24
@esaldivar Also, just to clarify. You use "this" to make functions public and you declare variables without "var" to make them public.
Chris Moore
@dooglus
Jan 21 2016 01:24
@esaldivar you need to put the bike-related functions inside the Bike function
@esaldivar compare it with the Car() stuff up above
Irving Gonzalez
@irvgonz
Jan 21 2016 01:25
help max
CamperBot
@camperbot
Jan 21 2016 01:25

:point_right: math.max [wiki]

Math.max()

The Math.max() function returns the largest of zero or more numbers.

:pencil: read more about mathmax on the FCC Wiki

Najee Bartley
@ntbartley23
Jan 21 2016 01:29
This is silly but i am confused about the wordBlanks challenge.
Pandarati
@Pandarati
Jan 21 2016 01:32
@ntbartley23 Basically it's like playing madlibs. You are going to make a sentence. Where a noun will go is where you put your Noun variable and it's the same concept for the rest of them
@ntbartley23 You're basically letting the user have their own adjectives, nouns and adverbs while you create a funny story. You will be putting the variables in using concatenation "+"
Alvin
@yonghk1
Jan 21 2016 01:34
function update(id, prop, value) {

  if (value !== "" && prop !== "tracks"){

    collection[prop] = value;    

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



// Alter values below to test your code
update(5439, "artist", "ABBA");
Pandarati
@Pandarati
Jan 21 2016 01:34
@nerajno Are you having trouble with the concept of a multi dimensional array?
Alvin
@yonghk1
Jan 21 2016 01:34
can someone help with this problem? it looks like it's adding "ABBA" after the id...
Pandarati
@Pandarati
Jan 21 2016 01:36
@nerajno You are just referencing an array inside of an array. It basically goes like this:
[[2,4], 3][2, 5]. 
There are 2 arrays here, and I want to get the value 4.

Let's go into the first array [0], and now we have [[2,4], 3].
Ok lets go in the first one again [0][0], and now we have [2, 4]
Now lets get the second element [0][0][1].
Nerando Johnson
@nerajno
Jan 21 2016 01:37
i got it
Pandarati
@Pandarati
Jan 21 2016 01:38
@nerajno That's fantastic :P. Happy Coding!
Eric Saldivar
@esaldivar
Jan 21 2016 01:38
var Bike = function() {

  // Only change code below this line.

var gear= 10;
var myBike = new Bike();
 {
 this.setGear= function (change) {
   gear = change;};
 }
this.getGear= function () {
  return gear;
};
 };
still having trouble
Nerando Johnson
@nerajno
Jan 21 2016 01:38
@Pandarati
@Pandarati thank you
CamperBot
@camperbot
Jan 21 2016 01:38
nerajno sends brownie points to @pandarati :sparkles: :thumbsup: :sparkles:
:star: 324 | @pandarati | http://www.freecodecamp.com/pandarati
Nerando Johnson
@nerajno
Jan 21 2016 01:39
i am still trying to figure out how is it equal to 8
Chris Moore
@dooglus
Jan 21 2016 01:39
@esaldivar the var myBike = new Bike(); bit should be outside the Bike() function
@esaldivar because that's the code that uses the Bike() function to construct a Bike
Eric Saldivar
@esaldivar
Jan 21 2016 01:39
var gear= 10;

 {
 this.setGear= function (change) {
   gear = change;};
 }
this.getGear= function () {
  return gear;
};
 };
var myBike = new Bike();
Steven Ni
@Steven-C-Ni
Jan 21 2016 01:41
// Setup
function abTest(a, b) {
  // Only change code below this line
  if (a < 0)
    return "undefined";
  else if (b < 0) {
  return "undefined";
  }


  // Only change code above this line

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

// Change values below to test your code
abTest(-2,2);
The function is returning "undefined" but it isn't accepted as the answer. Can anyone tell me what is wrong please?
Kimber
@Kimber217
Jan 21 2016 01:43
@Steven-C-Ni what's the name of the waypoint?
Steven Ni
@Steven-C-Ni
Jan 21 2016 01:43
Return Early Pattern for Functions
d wilder
@alhazen1
Jan 21 2016 01:43
@Steven-C-Ni try without quotes
Kimber
@Kimber217
Jan 21 2016 01:43
help Return Early Pattern for Functions
CamperBot
@camperbot
Jan 21 2016 01:43

:point_right: waypoint return early pattern for functions [wiki]

Waypoint: Return Early Pattern for Functions

When a return statement is reached, the execution of the current function stops and control returns to the calling location.

Example

function myFun() {
  console.log("Hello");
  return "World";
  console.log("byebye")
}
myFun();

The above outputs "Hello" to the console, returns "World", but "byebye" is never output, because the function exits at the return statement.
:pencil: read more about waypoint return early pattern for functions on the FCC Wiki

Kimber
@Kimber217
Jan 21 2016 01:44
@Steven-C-Ni are you sure that's the waypoint?
Steven Ni
@Steven-C-Ni
Jan 21 2016 01:44
@Kimber217 Thank you! It's because undefined is a value
CamperBot
@camperbot
Jan 21 2016 01:44
steven-c-ni sends brownie points to @kimber217 :sparkles: :thumbsup: :sparkles:
:star: 251 | @kimber217 | http://www.freecodecamp.com/kimber217
Steven Ni
@Steven-C-Ni
Jan 21 2016 01:44
and not text
Kimber
@Kimber217
Jan 21 2016 01:44
that was actually @alhazen1 who helped - thanks @alhazen1 :)
CamperBot
@camperbot
Jan 21 2016 01:44
kimber217 sends brownie points to @alhazen1 and @alhazen1 :sparkles: :thumbsup: :sparkles:
Steven Ni
@Steven-C-Ni
Jan 21 2016 01:44
yes, that's the one
CamperBot
@camperbot
Jan 21 2016 01:44
:star: 276 | @alhazen1 | http://www.freecodecamp.com/alhazen1
:star: 276 | @alhazen1 | http://www.freecodecamp.com/alhazen1
Steven Ni
@Steven-C-Ni
Jan 21 2016 01:46
@alhazen1 Thank you for your help!
CamperBot
@camperbot
Jan 21 2016 01:46
steven-c-ni sends brownie points to @alhazen1 :sparkles: :thumbsup: :sparkles:
:star: 277 | @alhazen1 | http://www.freecodecamp.com/alhazen1
d wilder
@alhazen1
Jan 21 2016 01:46
@Steven-C-Ni you're welcome!
Kimber
@Kimber217
Jan 21 2016 01:47
help introducing javascript object notation json
CamperBot
@camperbot
Jan 21 2016 01:47

:point_right: waypoint introducing javascript object notation json [wiki]

Waypoint: Introducing JavaScript Object Notation JSON

JavaScript Object Notation or JSON uses the format of JavaScript Objects to store data. JSON is flexible because it allows for Data Structures with arbitrary combinations of strings, numbers, booleans, arrays, and objects.

Here is an example of a JSON object:

var ourMusic = [
  {
    "artist": "Daft Punk",
    "title": "Homework",
    "release_year": 1997,
    "formats": [ 
      "CD", 
      "Cassette", 
      "LP" ],
    "gold": true
  }
];

:pencil: read more about waypoint introducing javascript object notation json on the FCC Wiki

Eric Saldivar
@esaldivar
Jan 21 2016 01:47
var Bike = function() {

  // Only change code below this line.

var gear= 10;

 {
 this.setGear= function (change) {
   gear = change;};
 }
this.getGear= function () {
  return gear;
};
 };
var myBike = new Bike();
cant set these properties public or private, -

mmacedo
@mmacedoeu
Jan 21 2016 01:53
@Kimber217 :clap:
Kimber
@Kimber217
Jan 21 2016 01:54
@mmacedoeu ??
mmacedo
@mmacedoeu
Jan 21 2016 01:54
@Kimber217 :cool: json
Kimber
@Kimber217
Jan 21 2016 01:54
sorry @mmacedoeu i'm confused
Weiwei
@weiweizh
Jan 21 2016 01:57
help Steamroller
CamperBot
@camperbot
Jan 21 2016 01:57

:point_right: bonfire steamroller [wiki]

Explanation:

This problem seems simple but you need to make sure to flatten any array, regardless of the level which is what adds a bit of difficulty to the problem.

:pencil: read more about bonfire steamroller on the FCC Wiki

sciand6
@sciand6
Jan 21 2016 01:58
// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line

var gloveBoxContents = myStorage.car["inside"];// Change this line
I know that it won't let me use spaces after dot notation
Eli Taliafero
@elitaliafero
Jan 21 2016 01:59
help Accessing Objects Properties with Variables
CamperBot
@camperbot
Jan 21 2016 01:59

:point_right: waypoint accessing objects properties with variables [wiki]

Waypoint: Accessing Objects Properties with Variables

Another use of bracket notation on objects is to use a variable to access a property. This can be very useful for iterating through lists of the object properties or for doing the lookup.

Here is an example of using a variable to access a property:

var someProp = "propName";
var myObj = {
  propName: "Some Value"
}

myObj[someProp]; // "Some Value"
Note that we do not use quotes around the variable name when using it to access the property because we are using the value of the variable, not the name
:pencil: read more about waypoint accessing objects properties with variables on the FCC Wiki

Eric Saldivar
@esaldivar
Jan 21 2016 02:02
help Make Object Properties Private
CamperBot
@camperbot
Jan 21 2016 02:02

:point_right: waypoint make object properties private [wiki]

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

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

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

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

};

Another example:

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

KingHam22
@KingHam22
Jan 21 2016 02:17
help Record Collection
CamperBot
@camperbot
Jan 21 2016 02:17

:point_right: checkpoint record collection [wiki]

Checkpoint: Record Collection

Instructions

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

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

For the given id in collection:

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

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

If value is blank, delete that prop.

Always return the entire collection object.

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

:pencil: read more about checkpoint record collection on the FCC Wiki

Yeondam Park
@yeondam88
Jan 21 2016 02:21
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
help me with this! please
CamperBot
@camperbot
Jan 21 2016 02:22
no wiki entry for: me with this please
eeflores
@eeflores
Jan 21 2016 02:22
@yeondam88 what's the problem?
Eric Saldivar
@esaldivar
Jan 21 2016 02:23
i need help with private properties
```
var Bike = function() {

  // Only change code below this line.

var gear= 10;

 {
 this.setGear= function (change) {
   gear = change;};
 }
this.getGear= function () {
  return gear;
};
 };
var myBike = new Bike();
eeflores
@eeflores
Jan 21 2016 02:23
@yeondam88 second for contains i++ should be j++
Yeondam Park
@yeondam88
Jan 21 2016 02:23
when i run this, typerror
cannot read property 'length' of undefined
Irving Gonzalez
@irvgonz
Jan 21 2016 02:23
@yeondam88 maybe remove the .length in the second for loop?
Yeondam Park
@yeondam88
Jan 21 2016 02:24
@eeflores thanks
CamperBot
@camperbot
Jan 21 2016 02:24
yeondam88 sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 455 | @eeflores | http://www.freecodecamp.com/eeflores
eeflores
@eeflores
Jan 21 2016 02:25
@esaldivar remove the brace above this.setGear
@yeondam88 yw
The Zohan
@TheZohan96
Jan 21 2016 02:25
stuck at record collection
dont know what the question means
like how to update prop to the given id
eeflores
@eeflores
Jan 21 2016 02:26
@esaldivar the this.setGear()function seems to be in braces ... doesn't need to be
Eric Saldivar
@esaldivar
Jan 21 2016 02:26
okay trying that
eeflores
@eeflores
Jan 21 2016 02:27
@TheZohan96 the update function will modify the collection array
the first param to the update function will reference one of the elements in the collection array
The Zohan
@TheZohan96
Jan 21 2016 02:27
@eeflores but how do i assign that prop to the respective id..with dot notation ?
eeflores
@eeflores
Jan 21 2016 02:28
@TheZohan96 lots of the code in that one uses bracket notation
collection[id][prop]
The Zohan
@TheZohan96
Jan 21 2016 02:29
@eeflores when to use dot n when bracket ?
KingHam22
@KingHam22
Jan 21 2016 02:29
Im working on record collection too, but the explanations for using dot/brackets doesnt seem to make sence
eeflores
@eeflores
Jan 21 2016 02:30
@TheZohan96 dot notation is used when referring to a member of an object directly
collections.blah - collections has a property called blah
bracket notation is used when using a variable to access a property of an object
The Zohan
@TheZohan96
Jan 21 2016 02:31
okay so call by reference is bracket
call by value is dot ?
eeflores
@eeflores
Jan 21 2016 02:31
if a = "boo" then collections[a] is equal to collections.boo
or collections["boo"]
KingHam22
@KingHam22
Jan 21 2016 02:32
aha there we go.... i dont think code camp explained that bracket notation is only used for variables?
The Zohan
@TheZohan96
Jan 21 2016 02:32
somethings are not clearly xplaind
eeflores
@eeflores
Jan 21 2016 02:32
@TheZohan96 also:
var blahh = {
  "space man" : "one"
}
// can only be accessed using
blahh["space man"];
any clearer?
The Zohan
@TheZohan96
Jan 21 2016 02:34
yep got it man
superlike to you
eeflores
@eeflores
Jan 21 2016 02:34
yw
ulBenson
@ulbenson
Jan 21 2016 02:42
Sum All Odd Fibonacci Numbers
the number sumFibs(1000) seems too large
how to solve?
Eric Saldivar
@esaldivar
Jan 21 2016 02:43

i am seriously stuck

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

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

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

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

var Bike = function() {

  // Only change code below this line.
var gear = 100;
  function addUnit(value) {
    return value;
  } 
  this.setGear = function () {
    return addUnit(gear);
  };
  this.getGear = function () {
    return gear;
  };
};

var myCar = new Car();

var myBike = new Bike();

can someone look at their code for Make Object Properties Private and help me out. Been here for 1 hr.

TuanTM
@TuanTM93
Jan 21 2016 02:44
This message was deleted
I want add value to array use map
newArray = oldArray;
var oldArray = [1,2,3,4,5];
var newArray = [];
newArray = oldArray;
Jasson Cordones
@JassonCordones
Jan 21 2016 02:46
Hey can someone help with Sum All Numbers in a Range?
eeflores
@eeflores
Jan 21 2016 02:47
@esaldivar maybe this.addUnit = function(value)
or is that supposed to be private?
CharmedSatyr
@CharmedSatyr
Jan 21 2016 02:47
help profile lookup
CamperBot
@camperbot
Jan 21 2016 02:47

: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

eeflores
@eeflores
Jan 21 2016 02:49
@esaldivar I just had a look at my solution - passed it before, have to do it again ...
TuanTM
@TuanTM93
Jan 21 2016 02:51
I want add value to array oldArray use map
var oldArray = [1,2,3,4,5];
var newArray = [];

// Only change code below this line.

newArray = oldArray;
eeflores
@eeflores
Jan 21 2016 02:51
@esaldivar I had to modify my solution so that my functions accessed this.gear
Eric Saldivar
@esaldivar
Jan 21 2016 02:52
@eeflores okay. I'm so lost. Watched videos but fCC changed the original challenge
eeflores
@eeflores
Jan 21 2016 02:53
@JassonCordones what's up?
@TuanTM93 which challenge?
(3 for 3) need help @JosephWolfe ?
Brian
@sludge256
Jan 21 2016 02:55
@esaldivar what's addUnit for?
Eric Saldivar
@esaldivar
Jan 21 2016 02:55
@sludge256 i honestly thought it would increase the value of setGear
Chuck Wongus
@YesImChuck
Jan 21 2016 02:55
Hello y'all! I'm trying to remove all of the white space in this string to chack if it is a palindrome. Any idea why it's not working?
function palindrome(str) {
  var pal = str.toLowerCase().replace(/[^\w\s+]/g, "").split("").reverse().join("");
  if (pal === str) {
  return true;
  }
  else
    {
      return false;
    }
}



palindrome("A man, a plan, a canal. Panama");
eeflores
@eeflores
Jan 21 2016 02:55
hello @YesImChuck
Chuck Wongus
@YesImChuck
Jan 21 2016 02:56
Hello @eeflores !
Brian
@sludge256
Jan 21 2016 02:56
@esaldivar for setGear
you want to have a parameter
aka
function(val)
then inside your function
just set the variable gear to this value
Eric Saldivar
@esaldivar
Jan 21 2016 02:57
@sludge256 so like setGear(num)?
hmm.
Brian
@sludge256
Jan 21 2016 02:57
yea whatever you want to call it
eeflores
@eeflores
Jan 21 2016 02:57
@YesImChuck \w corresponds to alphanum and underscores
Eric Saldivar
@esaldivar
Jan 21 2016 02:58
var gear = 100;
  }; 
  this.setGear = function (value) {
    return value;
  };
  this.getGear = function () {
    return gear;

};
updated
Brian
@sludge256
Jan 21 2016 02:58
Aren't you ignoring spaces with ^\s?
or does the ^ only apply to the first one, \w
@esaldivar instead of returning the input value
assign the value to the gear variable
TuanTM
@TuanTM93
Jan 21 2016 02:59
@eeflores , i want add 3 value oldArray, but i not have soulution
eeflores
@eeflores
Jan 21 2016 02:59
@YesImChuck also you'd want to compare the reversed version with one that also takes out the non-alpha lower cased stuff
Brian
@sludge256
Jan 21 2016 02:59
you use getGear when you want to know the gear variable
you use setGear when you want to change the variable
Eric Saldivar
@esaldivar
Jan 21 2016 02:59
value=gear ?
eeflores
@eeflores
Jan 21 2016 03:00
gear = value
Chuck Wongus
@YesImChuck
Jan 21 2016 03:00
@eeflores , thanks. I changed it to .replace(/[.,\s+]/g, "") that fixed it
CamperBot
@camperbot
Jan 21 2016 03:00
yesimchuck sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 456 | @eeflores | http://www.freecodecamp.com/eeflores
eeflores
@eeflores
Jan 21 2016 03:00
good stuff @YesImChuck
Eric Saldivar
@esaldivar
Jan 21 2016 03:00
updated:
var gear = 100;

  this.setGear = function (value) {
    gear=value;
  };
  this.getGear = function () {
    return gear;
  };
};
eeflores
@eeflores
Jan 21 2016 03:01
@TuanTM93 I'm guessing it's the Iterate over arrays challenge
@TuanTM93 you can kinda modify the example they give you in the challenge description ...
TuanTM
@TuanTM93
Jan 21 2016 03:03
@eeflores , i will try to see :)
Nolan A Eliason
@Naeliason
Jan 21 2016 03:05
Hello everyone, I am working on the algorithm challenge where the goal is to capitalize the first letter of every word in a string. So far I can do this up until rejoin the array into a proper string. Here is my code:
function titleCase(str) {
  split = str.split(" ");
  var splitCap = [];
  var finalArray;

  for (i=0;i<split.length;i++){
    for (var j=0; j<split[i].length; j++){
     if (j === 0 ) {
       splitCap.push(split[i][j].toUpperCase()); 

        } else {
          splitCap.push(split[i][j].toLowerCase());

        }
     }  
  }

  finalArray = splitCap.join(""); 

  return finalArray;
}

titleCase("I'm a little tea pot");
The current output is "I'mALittleTeaPot"
Chuck Wongus
@YesImChuck
Jan 21 2016 03:08
Actually, I lied. Everything here seems like it should work, but I'm getting an error that replace isn't a function
function palindrome(str) {

  var newStr = str.toLowerCase().split("").replace(/[.,\s+]/g, "").join("");
  var pal = newStr.reverse();
  if (pal === newStr) {
  return true;
  }
  else
    {
      return false;
    }
}

palindrome("A man, a plan, a canal. Panama");
eeflores
@eeflores
Jan 21 2016 03:09
@YesImChuck the return from split is an array ... didn't the order you have it in originally work?
str -> tolowercase -> replace -> split
Chuck Wongus
@YesImChuck
Jan 21 2016 03:11
I thought it did, but it wasn't working. I jumped the gun on that.
So, join is an array? How do I get it back to a string?
eeflores
@eeflores
Jan 21 2016 03:12
@Naeliason it looks like splitCap is an array of all chars in the string
join is for array to get it back to string
replace is for string. split returns array. can't call replace on array
@Naeliason I think you'd lose all the spaces between words there
Nolan A Eliason
@Naeliason
Jan 21 2016 03:14
@eeflores , correct
eeflores
@eeflores
Jan 21 2016 03:15
@Naeliason after iterating over the word in the split array, you may want to reassign splitCap back to the split array. Don't forget to reinitialise splitCap between words
for each word
Nolan A Eliason
@Naeliason
Jan 21 2016 03:16
@eeflores What do you mean reinitiaise between words?
eeflores
@eeflores
Jan 21 2016 03:18
@Naeliason the j for loop iterates over chars for a word and pushes it onto splitCap. After finishing the j loop splitCap will have a capitalised word - assign that back to split[i] (using join()) then splitCap = [] when iterating over the next word
Rick McDonnell
@mcdonnellcreative
Jan 21 2016 03:19
On Profile Lookup in javascript, I don't understand why I am getting lastName to return, but not the array property for "likes". Here is my code. function lookUp(firstName, prop){
// Only change code below this line
var answer = [];
for (var i = 0; i < contacts.length; i++) {
if (firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
answer = contacts[i][prop];
} else if (!contacts[i].hasOwnProperty(prop)) {
answer = "No such property";
} else {
answer = "No such contact";
}
}
return answer;
// Only change code above this line
}
More pretty version
function lookUp(firstName, prop){
// Only change code below this line
var answer = [];
  for (var i = 0; i < contacts.length; i++) {
    if (firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
      answer = contacts[i][prop];
    } else if (!contacts[i].hasOwnProperty(prop)) {
      answer =  "No such property";
    } else {
      answer =  "No such contact";
    }
  }
  return answer;
// Only change code above this line
}
eeflores
@eeflores
Jan 21 2016 03:20
@mcdonnellcreative put the "No such contact" after the for loop
Jonah Erlich
@jerlich97
Jan 21 2016 03:20
Is anyone able to help me with the JSON nested arrays challenge?
I had the code as
var secondTree = myPlants.trees.listlotus/model#35;
after trying var secondTree = myPlants.treeslotus/model#35;
the thing that says lotus should be a lotus/model#35
square brackets surrounding a 1*
eeflores
@eeflores
Jan 21 2016 03:23
@mcdonnellcreative also you may want to check firstname in the else if
Kimber
@Kimber217
Jan 21 2016 03:23
@jerlich97 i just finished that one
i think, at lesat
Jonah Erlich
@jerlich97
Jan 21 2016 03:24
@Kimber217 any tips?
Kimber
@Kimber217
Jan 21 2016 03:24
wait, it may be a totally different thing
but is it "accessing nested arrays in JSON" waypoint?
Jonah Erlich
@jerlich97
Jan 21 2016 03:25
Yep
Kimber
@Kimber217
Jan 21 2016 03:25
oh yeah
okay well first of all, idk what that lotus/model#35 thing is
Jonah Erlich
@jerlich97
Jan 21 2016 03:25
it's a weird chat bug
Kimber
@Kimber217
Jan 21 2016 03:25
ohhhh
okay :)
Jonah Erlich
@jerlich97
Jan 21 2016 03:25
its [
then 1
Kimber
@Kimber217
Jan 21 2016 03:25
got it!
Jonah Erlich
@jerlich97
Jan 21 2016 03:25
then ]
eeflores
@eeflores
Jan 21 2016 03:26
listlotus/model#35
try list[1]
backticks
Rick McDonnell
@mcdonnellcreative
Jan 21 2016 03:26
@eeflores I am not quite getting it...would I need to put the "No such property " if statement within a second for loop?
Kimber
@Kimber217
Jan 21 2016 03:26
so in myPlants, there are two different "types", right?
kiel barry
@kielbarry
Jan 21 2016 03:26
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
backslash tab tab carriage-return new-line and assign it to myStr
var myStr = "\\t\t\r\n"; // Change this line
Kimber
@Kimber217
Jan 21 2016 03:27
@jerlich97 there are two different types, type: "flowers" and type: "trees"
Jonah Erlich
@jerlich97
Jan 21 2016 03:27
@Kimber217 yep
Kimber
@Kimber217
Jan 21 2016 03:27
both of which are the children of parent myPlants, right?
how would you access the second child using brackets?
@jerlich97 let me know if you want a hint
Jonah Erlich
@jerlich97
Jan 21 2016 03:27
would it be .trees[list]
eeflores
@eeflores
Jan 21 2016 03:28
@mcdonnellcreative :
if(firstname == firstname && hasownproperty) {
return property
} else if (firstname == firstname && !hasownproperty) {
no such property
}
Jonah Erlich
@jerlich97
Jan 21 2016 03:28
@Kimber217 the editor said list would be better as a dot property
.trees.list
Kimber
@Kimber217
Jan 21 2016 03:28
nope - you're trying to get to the second child
it's pretty much the same thing as what you did to get "pine"
@jerlich97 you picking up what i'm putting down?
Jonah Erlich
@jerlich97
Jan 21 2016 03:29
@Kimber217 Still a bit confused
Kimber
@Kimber217
Jan 21 2016 03:29
"trees" is just another property of this second child, we honestly don't really care about "trees"
what we care about is getting to that second big set
Jonah Erlich
@jerlich97
Jan 21 2016 03:29
ohhhh
Kimber
@Kimber217
Jan 21 2016 03:30
so myPlants is the parent table
Jonah Erlich
@jerlich97
Jan 21 2016 03:30
ok i got it
it's lotus/model#35.listlotus/model#35
@Kimber217 Thanks!
CamperBot
@camperbot
Jan 21 2016 03:30
jerlich97 sends brownie points to @kimber217 :sparkles: :thumbsup: :sparkles:
:star: 255 | @kimber217 | http://www.freecodecamp.com/kimber217
eeflores
@eeflores
Jan 21 2016 03:30
@declanPaz spaces between escaped chars
Kimber
@Kimber217
Jan 21 2016 03:30
just make sure you add the parent in the front @jerlich97
no problem, let me know when you get to "records collection" cause i'pm in struggle city with that one
Chuck Wongus
@YesImChuck
Jan 21 2016 03:33
I'm sorry to be a bother about this bonfire, but I have it all figured out except for this one string. Why isn't this returning as true?
function palindrome(str) {

  var newStr = str.toLowerCase().replace(/[.,\s+]/g, "").split("").join("");
  var pal = str.toLowerCase().replace(/[.,\s+]/g, "").split("").reverse().join("");
  if (pal === newStr) {
  return true;
  }
  else
    {
      return false;
    }
}

palindrome("0_0 (: /-\ :) 0-0");
Allan Armstrong
@allanarmstrong
Jan 21 2016 03:34
@YesImChuck you're not removing all non alphanumeric characters
eeflores
@eeflores
Jan 21 2016 03:34
tag
Chuck Wongus
@YesImChuck
Jan 21 2016 03:34
Am I supposed to? I thought I just needed to remove all punctuation.
Kimber
@Kimber217
Jan 21 2016 03:34
has anyone here had any success with help record collection
help record collection
CamperBot
@camperbot
Jan 21 2016 03:35

:point_right: checkpoint record collection [wiki]

Checkpoint: Record Collection

Instructions

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

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

For the given id in collection:

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

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

If value is blank, delete that prop.

Always return the entire collection object.

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

:pencil: read more about checkpoint record collection on the FCC Wiki

Allan Armstrong
@allanarmstrong
Jan 21 2016 03:35
@YesImChuck which are non alphanumeric characters
you've missed a lot of punctuation in your regex
eeflores
@eeflores
Jan 21 2016 03:36
[^a-zA-Z0-9]
Chuck Wongus
@YesImChuck
Jan 21 2016 03:36
Thank you @allanarmstrong and @eeflores that helps a lot.
CamperBot
@camperbot
Jan 21 2016 03:36
yesimchuck sends brownie points to @allanarmstrong and @eeflores :sparkles: :thumbsup: :sparkles:
:warning: yesimchuck already gave eeflores points
:star: 813 | @allanarmstrong | http://www.freecodecamp.com/allanarmstrong
eeflores
@eeflores
Jan 21 2016 03:37
@Kimber217 what's up?
Kimber
@Kimber217
Jan 21 2016 03:38
@eeflores just not really sure what's going on with this problem
tempted to go to spoilers, but resisting
eeflores
@eeflores
Jan 21 2016 03:39
@Kimber217 the update function references the collection object
Yasin Yusuf
@YasinYA
Jan 21 2016 03:39
hi guys
eeflores
@eeflores
Jan 21 2016 03:39
the id param references one of the members of collection -> collection[id]
Yasin Yusuf
@YasinYA
Jan 21 2016 03:40
can anyone tell me what is wrong with this code
$(document).ready(function() {

  function timer() {
    var breakTime = 5;
    var section = 25;
    var start = "Start";
    var stop = "Stop";


    $("#inner1").click(function() {
      var el = getElementsById("par").innerHTML= breakTime;
      breakTime++;
    });
  };

  timer();
});
Kimber
@Kimber217
Jan 21 2016 03:41
@eeflores do i decide which id it is and put that in?
eeflores
@eeflores
Jan 21 2016 03:41
@Kimber217 any specific questions?
@Kimber217 that's specified when the update function is called
Kimber
@Kimber217
Jan 21 2016 03:41
like would i do collection[0] to get into id 2548?
ohhhhh
got it.
thanks @eeflores ...might have more questions soon but going to take a stab at it
CamperBot
@camperbot
Jan 21 2016 03:41
kimber217 sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 457 | @eeflores | http://www.freecodecamp.com/eeflores
eeflores
@eeflores
Jan 21 2016 03:42
ok good luck @Kimber217
Kimber
@Kimber217
Jan 21 2016 03:44
how do i do and/or in this @eeflores ?
&& and ||?
Rick McDonnell
@mcdonnellcreative
Jan 21 2016 03:46
thanks @eeflores
CamperBot
@camperbot
Jan 21 2016 03:46
mcdonnellcreative sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 458 | @eeflores | http://www.freecodecamp.com/eeflores
Eric Saldivar
@esaldivar
Jan 21 2016 03:54
anyone recently finish Make object properties private challenge?
matthew3454
@matthew3454
Jan 21 2016 03:55
I have a question on the waypoint: Global Scope and Functions. Can someone please help?
d wilder
@alhazen1
Jan 21 2016 03:59
@matthew3454 maybe. What do you need help with?
eeflores
@eeflores
Jan 21 2016 04:04
ok I'm back
@Kimber217 that's right
yw @mcdonnellcreative
Joshua Thomas
@Jkthomas88
Jan 21 2016 04:04
switch(val){
case a:
return apple;
break;
is there a reason "a" woudlnt be defined?
eeflores
@eeflores
Jan 21 2016 04:05
@esaldivar how's the challenge going?
Eric Saldivar
@esaldivar
Jan 21 2016 04:05
@eeflores I just passed it. Thanks. Haha only took two hours.
CamperBot
@camperbot
Jan 21 2016 04:05
esaldivar sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 459 | @eeflores | http://www.freecodecamp.com/eeflores
eeflores
@eeflores
Jan 21 2016 04:06
well done @esaldivar
d wilder
@alhazen1
Jan 21 2016 04:07
@Jkthomas88 kind of guessing but maybe should be case "a"
Joshua Thomas
@Jkthomas88
Jan 21 2016 04:08
@alhazen1 thanks, yeah i thought that too, but no luck
CamperBot
@camperbot
Jan 21 2016 04:08
jkthomas88 sends brownie points to @alhazen1 :sparkles: :thumbsup: :sparkles:
:star: 278 | @alhazen1 | http://www.freecodecamp.com/alhazen1
d wilder
@alhazen1
Jan 21 2016 04:08
@Jkthomas88 which exercise is that?
Joshua Thomas
@Jkthomas88
Jan 21 2016 04:09
adding a default option in switch statements
eeflores
@eeflores
Jan 21 2016 04:10
@Jkthomas88 you might want to put "apple" in quotes, as well as "a"
Waldo Lavaut
@w86compositor
Jan 21 2016 04:11
Hello FCC coders...why can´t I resolve any of the NEW challenges in Basic Javascript? Makes me feel like a stupid, honestly. I know the older challenges I just like "imitate" the examples, so...what should I do to learn better and defeat the new challenges?
eeflores
@eeflores
Jan 21 2016 04:13
you have an example @w86compositor ?
d wilder
@alhazen1
Jan 21 2016 04:13
@w86compositor You might want to read over the introductory material on MDN
Waldo Lavaut
@w86compositor
Jan 21 2016 04:13
well...choose any NEW, I just can´t figure out the code
yep, I haven´t read that material
Joshua Thomas
@Jkthomas88
Jan 21 2016 04:14
this is what i have for adding a default option in switch statements
switch (val){
case"a":
return "apple;
break;
case"b":
return"bird";
break;
case"c":
return "cat";
break:
default:
return"stuff";
}
eeflores
@eeflores
Jan 21 2016 04:15
@Jkthomas88 maybe a space after case keyword
and return keyword
Waldo Lavaut
@w86compositor
Jan 21 2016 04:15
@Jkthomas88 , that´s what I can´t figure out hahaha...lol
d wilder
@alhazen1
Jan 21 2016 04:15
@Jkthomas88 missing " on return "apple;
Joshua Thomas
@Jkthomas88
Jan 21 2016 04:15
yeah that was just a typo lol
eeflores
@eeflores
Jan 21 2016 04:15
ooh that too - good catch
Waldo Lavaut
@w86compositor
Jan 21 2016 04:15
so guys....should I read the material first right?
eeflores
@eeflores
Jan 21 2016 04:16
@w86compositor none of the basic javascript ones are coming up as new for me
Alain Holly
@aholly38
Jan 21 2016 04:16
This message was deleted
Joshua Thomas
@Jkthomas88
Jan 21 2016 04:16
yeah ill try the spaces
Alain Holly
@aholly38
Jan 21 2016 04:16
I suppose to retrieve "pine"
'
Waldo Lavaut
@w86compositor
Jan 21 2016 04:16
@eeflores When I look at my Map there are several with the tag New
d wilder
@alhazen1
Jan 21 2016 04:16
@w86compositor I think it is good to have a reference / tutorial beyond the short explanations in each exercise
Waldo Lavaut
@w86compositor
Jan 21 2016 04:16
at least for me
Wilson Heres
@hereswilson
Jan 21 2016 04:17
why doesn't this work for strings?
function diff(arr1, arr2) {

function noMatch(value){

  var index =arr1.indexOf(value);
  if (index==-1)
    {
      return value;
    }
}

 var notIn =arr2.filter(noMatch);

  return notIn;
}

diff(["hello", 2, 3, 5], [1, 2, 3, 4, 5,7]);
eeflores
@eeflores
Jan 21 2016 04:17
@w86compositor could you give me an example of one of them?
Alain Holly
@aholly38
Jan 21 2016 04:17
This message was deleted
Waldo Lavaut
@w86compositor
Jan 21 2016 04:17
@eeflores Let me see...
Richard Joe
@rjoe19
Jan 21 2016 04:17
hi this not compiling

var convert = function (num){

// Create arrays with default conversion with matching indices.
var decimalValue = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000]
var romanNumeral = ['I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M']

// Create a copy of num to work on and an empty string variable for the final roman number
var numCopy = num;
var romanized = '';

while (numCopy > 0) {
    for (var index in decimalValue){
        if (+decimalValue[index] <= numCopy && +decimalValue[+index + 1] > numCopy){
            romanized+= romanNumeral[index];
            numCopy-= decimalValue[index];
        }
    }
}
return romanized;

};

convert(36);

eeflores
@eeflores
Jan 21 2016 04:19
@w86compositor the description does have an example of what they're trying to get you to do ...
Waldo Lavaut
@w86compositor
Jan 21 2016 04:19
@eeflores Exactly
it´s doesnt
it doesn´t
eeflores
@eeflores
Jan 21 2016 04:19
@w86compositor it does have a description of how an object can be defined ...
var obj = {
  "a" : "apple",
  "b" : "bravo"
};
Waldo Lavaut
@w86compositor
Jan 21 2016 04:20
@eeflores Man, I can´t understand...I guess I´ll have to read some documentation first
Alain Holly
@aholly38
Jan 21 2016 04:20
i don't get it I've tried "var secondTree = myPlants.type.trees.list[]"
.listlotus/model#35
eeflores
@eeflores
Jan 21 2016 04:21
@w86compositor ok ask if there's anything specific you'd like to know
Alain Holly
@aholly38
Jan 21 2016 04:21
This message was deleted
Waldo Lavaut
@w86compositor
Jan 21 2016 04:21
@eeflores Thanks!!!!
CamperBot
@camperbot
Jan 21 2016 04:21
w86compositor sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 460 | @eeflores | http://www.freecodecamp.com/eeflores
eeflores
@eeflores
Jan 21 2016 04:21
@aholly38 try backticks
list[1]
inconsistent
@inconsistent
Jan 21 2016 04:23
Eeek I'm stuck. when I enter (-2, 2) or (2,-2) I get undefined for both results but the waypoint still isn't completing.
// Setup
function abTest(a, b) {
  // Only change code below this line
  if (a <= 0){
  return "undefined";
  }
  if (b <= 0){
    return "undefined";
  }  
  // Only change code above this line

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

// Change values below to test your code
abTest(2,-2);
twilightspike
@twilightspike
Jan 21 2016 04:24
Hello everyone, I'm stuck on the practice of Selecting from many options with Switch Statements. Here is my code and I want your help.Thanks.
function myTest(val) {
  var answer = "";
  // Only change code below this line
switch(answer){
  case val===1:
    answer = "alpha";
    break;
  case val===2:
    answer = "beta";
    break;
  case val===3:
    answer = "gamma";
    break;
  case val===4:
    answer = "delta";
    break;
}
  // Only change code above this line  
  return answer;  
}

// Change this value to test
myTest(2);
d wilder
@alhazen1
Jan 21 2016 04:25
@inconsistent try undefined without quotes - is a keyword not a string
Alain Holly
@aholly38
Jan 21 2016 04:25
This message was deleted
d wilder
@alhazen1
Jan 21 2016 04:26
@twilightspike you can't evaluate in switch statement. Should be like case 1: not case ===1;
inconsistent
@inconsistent
Jan 21 2016 04:26
@alhazen1 Genius, is there a way to give you internet fame?
(My first time using the chat!)
rtc31293
@rtc31293
Jan 21 2016 04:26
Hey guys! I'm about to complete the last of the Basic Algorithm challenges! BUT, one thing is holding me back. I wrote my code Caesar's Cipher, but for some reason this code returns an 'L' before every question mark in the expression passed in as an argument. Does anyone know why? Thank you so much!
function rot13(str) { 
  emptyStr = '';
  for (i=0; i < str.length; i++) {
    if (str.charCodeAt(i)+13 <= 90 && str.charCodeAt(i)+13 > 65) {
      emptyStr += String.fromCharCode(str.charCodeAt(i)+13);
    }
    if (str.charCodeAt(i)+13 >90) {
      emptyStr += String.fromCharCode((65+(str.charCodeAt(i) + 13)-91));
    }
    if (str.charCodeAt(i) > 90 || str.charCodeAt(i) < 65) {
      emptyStr += str[i];
    }
  }  
  return emptyStr;
}

rot13("SERR YBIR?");
d wilder
@alhazen1
Jan 21 2016 04:26
@twilightspike also you should be testing val not answer here switch(answer){
there's a way to send 'brownie points'
wiki brownie points
CamperBot
@camperbot
Jan 21 2016 04:28

:point_right: brownie points [wiki]

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

A user profile picture next to a with Brownie Points score

There are three ways you can get Brownie Points:

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

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

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

inconsistent
@inconsistent
Jan 21 2016 04:29
thanks @alhazen1
CamperBot
@camperbot
Jan 21 2016 04:29
inconsistent sends brownie points to @alhazen1 :sparkles: :thumbsup: :sparkles:
:star: 279 | @alhazen1 | http://www.freecodecamp.com/alhazen1
d wilder
@alhazen1
Jan 21 2016 04:29
@inconsistent you're welcome
rtc31293
@rtc31293
Jan 21 2016 04:30
anyone have some thoughts on the code above??
Robbie
@centraleft
Jan 21 2016 04:31
@rtc31293 give me a min
I'll take a look
twilightspike
@twilightspike
Jan 21 2016 04:32
@alhazen1 thanks for your advice and I will go trying. I am confused with the desciption of the practice:"case values are tested with strict equality (===)." I think I may misunderstood, but still I can't get it.
CamperBot
@camperbot
Jan 21 2016 04:32
twilightspike sends brownie points to @alhazen1 :sparkles: :thumbsup: :sparkles:
:star: 280 | @alhazen1 | http://www.freecodecamp.com/alhazen1
rtc31293
@rtc31293
Jan 21 2016 04:32
thanks @centraleft
CamperBot
@camperbot
Jan 21 2016 04:32
rtc31293 sends brownie points to @centraleft :sparkles: :thumbsup: :sparkles:
:star: 308 | @centraleft | http://www.freecodecamp.com/centraleft
d wilder
@alhazen1
Jan 21 2016 04:33
@rtc31293 I'm look at it too. scratching my head
rtc31293
@rtc31293
Jan 21 2016 04:33
thanks @alhazen1
CamperBot
@camperbot
Jan 21 2016 04:33
rtc31293 sends brownie points to @alhazen1 :sparkles: :thumbsup: :sparkles:
:star: 281 | @alhazen1 | http://www.freecodecamp.com/alhazen1
rtc31293
@rtc31293
Jan 21 2016 04:34
@centraleft @alhazen1 note that for some reason if a '?' is include in the string argument, the function will always insert an L before the ?. I don't get what's happening!
twilightspike
@twilightspike
Jan 21 2016 04:35
@alhazen1 As to the second advice, I am not sure if my way of describing question is not appropriate or? Sorry didn't catch your point...
Robbie
@centraleft
Jan 21 2016 04:36
so this line
d wilder
@alhazen1
Jan 21 2016 04:36
@twilightspike No, that was fine. I just offered that up as a resource. The MDN has been a godsend for me
Robbie
@centraleft
Jan 21 2016 04:37
if (str.charCodeAt(i)+13 <= 90 && str.charCodeAt(i) +13 >65{
    emptyStr += String.fromCharCode(str.charCodeAt(i)+13;
the unicode character for '?'
is 63
rtc31293
@rtc31293
Jan 21 2016 04:38
@alhazen1 @centraleft i figured it out!!! the character "?" was evaluating true for the FIRST and LAST IF statements! so the first IF statements added 13 to 63 = 76 = L, and all the last If statement so the charcater was returned
Robbie
@centraleft
Jan 21 2016 04:38
that's evaluating to true
lol
good job mate
rtc31293
@rtc31293
Jan 21 2016 04:38
yeah! @centraleft you got it too! haha thank you for helping @centraleft !
CamperBot
@camperbot
Jan 21 2016 04:38
rtc31293 sends brownie points to @centraleft and @centraleft :sparkles: :thumbsup: :sparkles:
:warning: rtc31293 already gave centraleft points
:warning: rtc31293 already gave centraleft points
Robbie
@centraleft
Jan 21 2016 04:38
np good on you for figuring it out though
Syed Rashid
@rashidindigo
Jan 21 2016 04:38
Hi guys, how do I post formatted code?
Robbie
@centraleft
Jan 21 2016 04:39
explain formatting
CamperBot
@camperbot
Jan 21 2016 04:39

:point_right: code formatting [wiki]

Inline code

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

Code Block

```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 ⏎]

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

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

d wilder
@alhazen1
Jan 21 2016 04:39
@rtc31293 BINGO!
Syed Rashid
@rashidindigo
Jan 21 2016 04:42
function queue(arr, item) {
  // Your code here
  arr.push(item);
  return arr.shift();  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
i keep getting a RangeError: Maximum call stack size exceeded.
Renee Matthews
@rym465
Jan 21 2016 04:45
Hi Everyone :-)
DJ Bondoc
@DJBondoc
Jan 21 2016 04:46
help Testing Objects for Properties
CamperBot
@camperbot
Jan 21 2016 04:46

:point_right: waypoint testing objects for properties [wiki]

Waypoint: Testing Objects for Properties

Sometimes it is useful to check if the property of a given object exists or not. We can use the .hasOwnProperty([propname]) method of objects to determine if that object has the given property name. .hasOwnProperty() returns true or false if the property is found or not.

Example

var myObj = {
  top: "hat",
  bottom: "pants"
};
myObj.hasOwnProperty("top");    // true
myObj.hasOwnProperty("middle");

:pencil: read more about waypoint testing objects for properties on the FCC Wiki

Renee Matthews
@rym465
Jan 21 2016 04:47
I need some help. I'm on challenge# 162 and Im trying to understand what the challenge is asking me to do...
d wilder
@alhazen1
Jan 21 2016 04:47
@srashid11x You may just need to refresh your page. Happened to me once
@rym465 which challenge is that?
Renee Matthews
@rym465
Jan 21 2016 04:50

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

// Your code above this line
return result;
}

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

It's the Word Blanks challenge
Syed Rashid
@rashidindigo
Jan 21 2016 04:51
thanks @alhazen1 refreshing the page did it.
CamperBot
@camperbot
Jan 21 2016 04:51
srashid11x sends brownie points to @alhazen1 :sparkles: :thumbsup: :sparkles:
:star: 282 | @alhazen1 | http://www.freecodecamp.com/alhazen1
d wilder
@alhazen1
Jan 21 2016 04:52
@srashid11x I thought your code looked right!
emran26
@emran26
Jan 21 2016 04:53
Hey guys, ive been stuck on this freaking Celsius to F conversion, can anyone help?:

function convert(celsius) {
// Only change code below this line

var cTemp = celsius;
var cToFahrenheit = cTemp * 9/5 + 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);

I feel like I'm forgetting something...
Robbie
@centraleft
Jan 21 2016 04:55
@emran26 explain formatting
jesus
explain formatting
CamperBot
@camperbot
Jan 21 2016 04:55

:point_right: code formatting [wiki]

Inline code

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

Code Block

```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 ⏎]

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

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

Robbie
@centraleft
Jan 21 2016 04:57
@emran26 my guess is your order of ops is messed up
also you don't need
var cTemp = celsius;
you can just use celsius for the calculation
ah actually looks like the problem is in your if statement
emran26
@emran26
Jan 21 2016 04:59
Yeah sorry I don't know how to paste it like you did
Robbie
@centraleft
Jan 21 2016 04:59
thats okay just read the formatting and try and get it figured out
emran26
@emran26
Jan 21 2016 05:00
How do you paste it properly for future reference?
The bot is confusing as well
d wilder
@alhazen1
Jan 21 2016 05:00
@rym465 i'm back
Robbie
@centraleft
Jan 21 2016 05:00
lol I don't think I can explain it better
d wilder
@alhazen1
Jan 21 2016 05:00
wiki Word Blanks
CamperBot
@camperbot
Jan 21 2016 05:00
no wiki entry for: word blanks
Robbie
@centraleft
Jan 21 2016 05:00
you use three backticks, which are on your tilde key
put three on top, on their own line
```
then some code
and then three more on their own line
```
emran26
@emran26
Jan 21 2016 05:01
ok I'll give it a shot
function convert(celsius) {
  // Only change code below this line

  var cToFahrenheit = celsius * 9/5 + 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);
Robbie
@centraleft
Jan 21 2016 05:01
right on
emran26
@emran26
Jan 21 2016 05:01
yeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!
Jesus Vega
@ParagonChuy
Jan 21 2016 05:01
Has anybody completed the Search and Replace algo?
Robbie
@centraleft
Jan 21 2016 05:01
so you are always going to get fahrenheit not defined, because you're not defining fahrenheit in your code
emran26
@emran26
Jan 21 2016 05:02
yeah I figured due to the error
Sara Caudill
@saramichellereeves
Jan 21 2016 05:02
Is there anyone nice enough to help me out on 'Using Objects for Lookups'? I'm quite stuck.
emran26
@emran26
Jan 21 2016 05:02
I'm going to define it now
Robbie
@centraleft
Jan 21 2016 05:02
just change cToFahrenheit to fahrenheit
@ParagonChuy I have yeah
@saramichellereeves post your code or pm it to me
emran26
@emran26
Jan 21 2016 05:02
well you know what confuses me? Sometimes I am not sure WHERE to put code , you know?
Jesus Vega
@ParagonChuy
Jan 21 2016 05:03
@centraleft How did you keep the case?
Robbie
@centraleft
Jan 21 2016 05:03
:satisfied:
Sara Caudill
@saramichellereeves
Jan 21 2016 05:03
@centraleft can do.
emran26
@emran26
Jan 21 2016 05:03
oh my fuck I did it
yeaaaaaaaaaaaaaaaa!
Robbie
@centraleft
Jan 21 2016 05:03
gj mate
it will get easier, just keep your head up
emran26
@emran26
Jan 21 2016 05:03
thanks man!
Robbie
@centraleft
Jan 21 2016 05:03
np
emran26
@emran26
Jan 21 2016 05:03
:D
Robbie
@centraleft
Jan 21 2016 05:05
@ParagonChuy my code is not saved sadly, but I'm pretty sure all I did was check if index 0 of the word to be replaced was a capital letter, and if it was then I made the letter at index 0 of the replacement word uppercase with .toUpperCase()
hold let me see if I can find my solution
yep! I checked if word[0] === word[0].toUpperCase()
hope that helps at all
Jesus Vega
@ParagonChuy
Jan 21 2016 05:08
function myReplace(str, before, after) {
  // Need to keep case now :(((
  var hold = str.split(" ");
  for(i = 0; i < hold.length; i++){
    if(hold[i] === before){
      hold[i] = after;
    }
  }
  return hold.join(' ');
}

myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
That's as far as i got
Sara Caudill
@saramichellereeves
Jan 21 2016 05:09
@centraleft computers acting up so ill put it here (srry)

// 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'
};

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

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

@centraleft

NainaPS
@Navyya
Jan 21 2016 05:09
function myTest(val) {
  // Only change code below this line


  if (val>=10 || val<=20) {
    return "Outside";
  }

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

// Change this value to test
myTest(15);
Robbie
@centraleft
Jan 21 2016 05:10
@saramichellereeves put a line of three backticks above yourcode like this
```
NainaPS
@Navyya
Jan 21 2016 05:10
What is problem with this comparison?
Robbie
@centraleft
Jan 21 2016 05:10
and a line below
```
Jesus Vega
@ParagonChuy
Jan 21 2016 05:10
That looks correct
Sara Caudill
@saramichellereeves
Jan 21 2016 05:10
@centraleft
// 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'
  };

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

// Change this value to test
phoneticLookup("charlie");
Jesus Vega
@ParagonChuy
Jan 21 2016 05:11
Check Github and see if it's a bug
Sara Caudill
@saramichellereeves
Jan 21 2016 05:11
@centraleft aand now i know how to do that, thanks
CamperBot
@camperbot
Jan 21 2016 05:11
saramichellereeves sends brownie points to @centraleft :sparkles: :thumbsup: :sparkles:
Robbie
@centraleft
Jan 21 2016 05:11
phew already sorry guys give me a minute
CamperBot
@camperbot
Jan 21 2016 05:11
:star: 310 | @centraleft | http://www.freecodecamp.com/centraleft
Jesus Vega
@ParagonChuy
Jan 21 2016 05:11
I'll figure out my situation haha but thanks @centraleft
CamperBot
@camperbot
Jan 21 2016 05:11
paragonchuy sends brownie points to @centraleft :sparkles: :thumbsup: :sparkles:
:star: 311 | @centraleft | http://www.freecodecamp.com/centraleft
Robbie
@centraleft
Jan 21 2016 05:11
@ParagonChuy you're gonna want to use &&
check if before[0] === before[0].toUpperCase and work from there
Jesus Vega
@ParagonChuy
Jan 21 2016 05:12
Okay
Robbie
@centraleft
Jan 21 2016 05:12
don't want to give away too much but come back if you're frazzled
Jesus Vega
@ParagonChuy
Jan 21 2016 05:12
I think I get it now
I'll come back in a bit and let you know how it goes
Robbie
@centraleft
Jan 21 2016 05:12
cool, good luck
d wilder
@alhazen1
Jan 21 2016 05:13
@Navyya did anyone get with you on this?
Robbie
@centraleft
Jan 21 2016 05:13
nope lol
looking @saramichellereeves s code
what did you have a problem with? or you figured it out?
NainaPS
@Navyya
Jan 21 2016 05:13
I m still trying it
Jesus Vega
@ParagonChuy
Jan 21 2016 05:13
followed you on github we have almost identical brownie points on here
Robbie
@centraleft
Jan 21 2016 05:14
wow! my first follower lol, I never use github I need to start
d wilder
@alhazen1
Jan 21 2016 05:14
@Navyya what is the name of that exercise?
Jesus Vega
@ParagonChuy
Jan 21 2016 05:14
I do too!
NainaPS
@Navyya
Jan 21 2016 05:14
Comparisons with the Logical Or Operator
@ParagonChuy Comparisons with the Logical Or Operator
sry @alhazen1 Comparisons with the Logical Or Operator
Giuseppe Remolino
@SpartacusRoot
Jan 21 2016 05:15
hi what'is wrong in my code?
istructions
Use sort to sort array from largest to smallest.
var array = [1, 12, 21, 2];

// Only change code below this line.
 array.sort(function(a, b){
   return b - a;

 });
array.sort();
Sara Caudill
@saramichellereeves
Jan 21 2016 05:16
@Navyya I can actually help with this one if everyone is busy :)
Robbie
@centraleft
Jan 21 2016 05:16
you're gonna want to return a - b
and initialize a variable for your sort
var answer = array.sort(function(a, b){
d wilder
@alhazen1
Jan 21 2016 05:17
@Navyya Outside means NOT between 10 and 20
NainaPS
@Navyya
Jan 21 2016 05:17
@saramichellereeves offcourse you should since I am new to this...
Robbie
@centraleft
Jan 21 2016 05:17
  return b - a;
ooops a - b I messed it up ha
Giuseppe Remolino
@SpartacusRoot
Jan 21 2016 05:17
@centraleft a - b return from the smallest to largest
CypherY
@CypherY
Jan 21 2016 05:17
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line


  var lookup = {
          1:"Z",
          2:"Y",
          3:"X",
          4:"W",
          5:"V",
          6:"U",
          7:"T",
          8:"S",
          9:"R",
          10:"Q",
          11:"P",
          12:"O",
          13:"N",
          14:"M",
          15:"L",
          16:"K",
          17:"J",
          18:"I",
          19:"H",
          20:"G",
          21:"F",
          22:"E",
          23:"D",
          24:"C",
          25:"B",
          26:"A"
        };



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

// Change this value to test
phoneticLookup("charlie");
Robbie
@centraleft
Jan 21 2016 05:17
oh you want largest to smallest, did not see that
CypherY
@CypherY
Jan 21 2016 05:17
Instructions
Convert the switch statement into a lookup table called lookup. Use it to lookup val and return the associated string.
Robbie
@centraleft
Jan 21 2016 05:18
@SpartacusRoot alright then just set that statement equal to some variable, and return the variable
CypherY
@CypherY
Jan 21 2016 05:18
I don't know if I am even remotely doing this right...?
Robbie
@centraleft
Jan 21 2016 05:18
the array.sort function doesn't change the array, it creates a new array so you need to store it somewhere
@CypherY you are remotely doing it right lol
but your lookup table is not right at all
emran26
@emran26
Jan 21 2016 05:18
centralleft, are you one of the team members of FCC?
Robbie
@centraleft
Jan 21 2016 05:18
no lol
NainaPS
@Navyya
Jan 21 2016 05:19
@saramichellereeves can you help with it??
Sara Caudill
@saramichellereeves
Jan 21 2016 05:19
@Navyya okay, in the instructions it iays it should return 'outside' if the val is between 10 and 20. meaning it is MORE than 10 , LESS than 20.
Robbie
@centraleft
Jan 21 2016 05:19
I'm truly honored but you overestimate me
d wilder
@alhazen1
Jan 21 2016 05:19
wiki Using Objects for Lookups
CamperBot
@camperbot
Jan 21 2016 05:19

:point_right: waypoint using objects for lookups [wiki]

Waypoint: Using Objects for Lookups

Objects can be thought of as a key/value storage, like a dictionary. If you have tabular data, you can use an object to "lookup" values rather than a switch statement or an if/else chain. This is most useful when you know that your input data is limited to a certain range.

Here is an example of a simple reverse alphabet lookup:

var alpha = {
  1:"Z",
  2:"Y",
  3:"X",
  4:"W",
  ...
  24:"C",
  25:"B",
  26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"

:pencil: read more about waypoint using objects for lookups on the FCC Wiki

emran26
@emran26
Jan 21 2016 05:19
@centraleft I just really appreciate that you're taking the time from your day to chill here and help others.
Robbie
@centraleft
Jan 21 2016 05:19
did they change that waypoint?
Sara Caudill
@saramichellereeves
Jan 21 2016 05:19
@Navyya shoot hold up i think i said that wrong
CypherY
@CypherY
Jan 21 2016 05:19
What are some things that could help?
NainaPS
@Navyya
Jan 21 2016 05:20

@saramichellereeves yes I still tried with this code ```js
function myTest(val) {
// Only change code below this line

if (val>10 || val<20) {
return "Outside";
}

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

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

```

Sara Caudill
@saramichellereeves
Jan 21 2016 05:20
@Navyya switch that around, i said it wrong, my bad
Robbie
@centraleft
Jan 21 2016 05:20
@Navyya flip those around haha
NainaPS
@Navyya
Jan 21 2016 05:21
@saramichellereeves Its fine I had send my both solutions ...but yet they have error ...lol
Robbie
@centraleft
Jan 21 2016 05:21
whats the error?
@emran26 it's just another way to get better
Giuseppe Remolino
@SpartacusRoot
Jan 21 2016 05:21
Dont work
Robbie
@centraleft
Jan 21 2016 05:21
@Navyya try val < 10
20
oops > 20
@SpartacusRoot hold on
NainaPS
@Navyya
Jan 21 2016 05:22
(val<10 || val<20) this yet dont work.. :worried:
Robbie
@centraleft
Jan 21 2016 05:22
not sure that b - a works how you want let me see
val > 20
so close
Giuseppe Remolino
@SpartacusRoot
Jan 21 2016 05:23
@centraleft
var array = [1, 12, 21, 2];

// Only change code below this line.
 var array = array.sort(function(a, b){
   return b - a;

 });
array.sort();
Robbie
@centraleft
Jan 21 2016 05:23
you've got a naming conflict there
NainaPS
@Navyya
Jan 21 2016 05:23
@centraleft @saramichellereeves pls check your solutions and let me know...
Robbie
@centraleft
Jan 21 2016 05:23
try a name like newArray
then you want to return newArray because thats the bit of code this waypoint needs
Giuseppe Remolino
@SpartacusRoot
Jan 21 2016 05:24
@centraleft same thing
Robbie
@centraleft
Jan 21 2016 05:24
like I said, .sort doesn't mutate an array, it makes a new completely separate array
that array needs to have a different name
and it needs to be returned
but I'm not sure b-a is going to work like you want it to
also not sure why you have array.sort() at the bottom
Sara Caudill
@saramichellereeves
Jan 21 2016 05:25
@Navyya send me what you have right now and ill compare to mine
NainaPS
@Navyya
Jan 21 2016 05:26

@saramichellereeves ```js
function myTest(val) {
// Only change code below this line

if (val>=10 || val<=20) {
return "Outside";
}

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

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

```

function myTest(val) {
  // Only change code below this line


  if (val>=10 || val<=20) {
    return "Outside";
  }

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

// Change this value to test
myTest(10);
Robbie
@centraleft
Jan 21 2016 05:26
@SpartacusRoot I just whipped it up and ran it, works great
Giuseppe Remolino
@SpartacusRoot
Jan 21 2016 05:27

@centraleft ```

var array = [1, 12, 21, 2];

// Only change code below this line.
var array = array.sort(function(a, b){
return b - a;

});
array.sort[0];

```
now works it's strange it's a bug?

Robbie
@centraleft
Jan 21 2016 05:27
it's not a bug
Giuseppe Remolino
@SpartacusRoot
Jan 21 2016 05:28
@centraleft thanks
CamperBot
@camperbot
Jan 21 2016 05:28
spartacusroot sends brownie points to @centraleft :sparkles: :thumbsup: :sparkles:
:star: 312 | @centraleft | http://www.freecodecamp.com/centraleft
Robbie
@centraleft
Jan 21 2016 05:28
it worked fine for me, maybe you just needed to refresh
Sara Caudill
@saramichellereeves
Jan 21 2016 05:28
@Navyya okay i see, try (val < 10 || val > 20) no equal signs.
NainaPS
@Navyya
Jan 21 2016 05:29
@saramichellereeves thanks
CamperBot
@camperbot
Jan 21 2016 05:29
navyya sends brownie points to @saramichellereeves :sparkles: :thumbsup: :sparkles:
:star: 213 | @saramichellereeves | http://www.freecodecamp.com/saramichellereeves
NainaPS
@Navyya
Jan 21 2016 05:29
:)
Sara Caudill
@saramichellereeves
Jan 21 2016 05:29
@Navyya no problem! :) :sparkles:
NainaPS
@Navyya
Jan 21 2016 05:29
now tell me @saramichellereeves this will exclude the value 10 and 20??
Robbie
@centraleft
Jan 21 2016 05:30
it will, because there are no equal signs
the numbers from 10 to 20 will be ignored
Sara Caudill
@saramichellereeves
Jan 21 2016 05:30
@Navyya yep :)
Robbie
@centraleft
Jan 21 2016 05:30
if you did <= >= then only 11-19 would be ignored
NainaPS
@Navyya
Jan 21 2016 05:32
alright! :)
Sara Caudill
@saramichellereeves
Jan 21 2016 05:34
@centraleft now that things have died down a bit, do you have any pointers on mine? ha
Robbie
@centraleft
Jan 21 2016 05:36
oh I'm sorry I thought you said you figured it out! lol
hold on
Sara Caudill
@saramichellereeves
Jan 21 2016 05:37
no problemo :p
Robbie
@centraleft
Jan 21 2016 05:37
well your result variable isn't being changed, so you're returning an empty string
you'll need to set it equal to something new, which you can do like this result = thing, no var needed
Sara Caudill
@saramichellereeves
Jan 21 2016 05:38
okay what does that mean exactly?
Robbie
@centraleft
Jan 21 2016 05:39
hm so your function has the right stuff in it, but everytime it runs it isn't doing anything when you want it to return the value of a property
you have an object, and you pass your function a property name
Sara Caudill
@saramichellereeves
Jan 21 2016 05:40
OHHHH okay, it went through! @centraleft thank you!
CamperBot
@camperbot
Jan 21 2016 05:40
saramichellereeves sends brownie points to @centraleft :sparkles: :thumbsup: :sparkles:
:warning: saramichellereeves already gave centraleft points
Robbie
@centraleft
Jan 21 2016 05:40
you're welcome!
NainaPS
@Navyya
Jan 21 2016 05:44
function myTest(val) {
  if  (val < 5)  {
    return " Less than 5";
  } else if (val < 10)  {
    return " Less than 10";
  } else {
    return "Greater than or equal to 10";
  }
}

// Change this value to test
myTest(7);
@centraleft whats issue with this?
the sequence is correct I guess...
Robbie
@centraleft
Jan 21 2016 05:44
you might be getting the wrong results because
you have an extra space at the front of your first two strings
chaitanya ashtekar
@chaitanyaashtekar
Jan 21 2016 05:45
@Navyya whats the error ??
Robbie
@centraleft
Jan 21 2016 05:45
try taking that space out and see what happens
NainaPS
@Navyya
Jan 21 2016 05:45
yup space was the error @centraleft
but why so??
RahulRamesh91
@RahulRamesh91
Jan 21 2016 05:46
Because u have o get he exact same outout as meintioned by the test
output
Robbie
@centraleft
Jan 21 2016 05:46
yep it's gotta match up exactly
computers need you to be very explicit
NainaPS
@Navyya
Jan 21 2016 05:48
ohh ok ok ...thanks @centraleft @RahulRamesh91
CamperBot
@camperbot
Jan 21 2016 05:48
navyya sends brownie points to @centraleft and @rahulramesh91 :sparkles: :thumbsup: :sparkles:
:star: 267 | @rahulramesh91 | http://www.freecodecamp.com/rahulramesh91
:star: 313 | @centraleft | http://www.freecodecamp.com/centraleft
Joshua Thomas
@Jkthomas88
Jan 21 2016 05:51
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch (val){
    case a :
      return apple ;
      break ;
    case b:
      return bird ;
      break;
    case c :
      return cat ;
      break;
    default:
      return stuff;

  }


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

// Change this value to test
myTest(a);
why am i getting the error a is not defined?
RahulRamesh91
@RahulRamesh91
Jan 21 2016 05:51
put a in quotes
'a'
chaitanya ashtekar
@chaitanyaashtekar
Jan 21 2016 05:52
@Jkthomas88 return "apple"
RahulRamesh91
@RahulRamesh91
Jan 21 2016 05:52
yea tht too
Joshua Thomas
@Jkthomas88
Jan 21 2016 05:52
so a and apple should both be in quotes?
RahulRamesh91
@RahulRamesh91
Jan 21 2016 05:52
yep
chaitanya ashtekar
@chaitanyaashtekar
Jan 21 2016 05:52
@RahulRamesh91 "a" is not req as it is a single character
@Jkthomas88 its better if both are in " ";
RahulRamesh91
@RahulRamesh91
Jan 21 2016 05:54
and there is no need for break after return
Joshua Thomas
@Jkthomas88
Jan 21 2016 05:55
```
oh really? I thought you had you had to put a break after ever case
RahulRamesh91
@RahulRamesh91
Jan 21 2016 05:56
return itself breaks away from your statement
so the break is never going to reach
Joshua Thomas
@Jkthomas88
Jan 21 2016 05:58
oohhh I see, so what if i didnt put the command return there and instead just wrote apple for a, would the computer still know to "return" apple for a?
RahulRamesh91
@RahulRamesh91
Jan 21 2016 05:59
if u dont put return set val to apple
like case 'a': val=apple ; break ;
and so on
and return val at the end
apple in quotes btw

function myTest(val) {
var answer = "";
// Only change code below this line
switch (val){
case 'a' :
val ="apple" ;
break;

case 'b':
  val= "bird" ;
  break;

case' c' :
  val= "cat" ;
  break;

default:
  val ="stuff";

}
return val;
}

myTest("a");

sorry tht didnt paste properly
Joshua Thomas
@Jkthomas88
Jan 21 2016 06:01
@RahulRamesh91 Thanks, I get it! I was going about it the wrong way!
CamperBot
@camperbot
Jan 21 2016 06:01
jkthomas88 sends brownie points to @rahulramesh91 :sparkles: :thumbsup: :sparkles:
:star: 268 | @rahulramesh91 | http://www.freecodecamp.com/rahulramesh91
RahulRamesh91
@RahulRamesh91
Jan 21 2016 06:05
@chaitanyaashtekar btw the quotes for case 'a' is still required otherwise a is considered a variable and hence the error a is not defined
chaitanya ashtekar
@chaitanyaashtekar
Jan 21 2016 06:08
@RahulRamesh91 yup..
d wilder
@alhazen1
Jan 21 2016 06:11
Get console.log output in Codepen
May be helpful to someone to run your code or others' somewhere other than in the exercises. I've been using it to run other students' code.
NainaPS
@Navyya
Jan 21 2016 06:17
@chaitanyaashtekar
function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes === 1){
    return "Hole-in-one";
  }
  else if(strokes <= par-2){
    return "Eagle";
  }
  else if (strokes === par-1){
    return "Birdie";
  }
  else if (strokes === par){
    return "Par";
  }
  else if (strokes === par+1){
    return "Bogey";
  }
  else if (strokes === par+2){
    return "Double Bogey";
  }
  else if (strokes >= par+3){
    return "Go Home!";
  }
  else {
    return "Change Me";
  }
  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
what is the error with this Golf Code waypoint?
Denise
@DeniseMoline
Jan 21 2016 06:19
This message was deleted
NainaPS
@Navyya
Jan 21 2016 06:21
Waypoint for Golf Code
Jeremy Roe
@jeremyroe
Jan 21 2016 06:22
This message was deleted
NainaPS
@Navyya
Jan 21 2016 06:22
@saramichellereeves did u complete this?
Jeremy Roe
@jeremyroe
Jan 21 2016 06:26
This message was deleted
Markus Kiili
@Masd925
Jan 21 2016 06:29
@Navyya Your code is not celebrating rare hole-in-ones enough.
RahulRamesh91
@RahulRamesh91
Jan 21 2016 06:30
return"Hole-in-one!" this
NainaPS
@Navyya
Jan 21 2016 06:30
@Masd925 but why?
RahulRamesh91
@RahulRamesh91
Jan 21 2016 06:30
the excalmation
NainaPS
@Navyya
Jan 21 2016 06:30
yup...
thanks @RahulRamesh91
CamperBot
@camperbot
Jan 21 2016 06:30
navyya sends brownie points to @rahulramesh91 :sparkles: :thumbsup: :sparkles:
:warning: navyya already gave rahulramesh91 points
Oliver Jan
@loliverjan
Jan 21 2016 06:34
if anyone working on the contacts lookup problem?
RahulRamesh91
@RahulRamesh91
Jan 21 2016 06:53
where are you stuck @loliverjan
Diksha
@Diksha261
Jan 21 2016 06:55
can somebody show me solution for palindrome....stucked since 3 hours:(
Tim Signore
@Timsig
Jan 21 2016 07:00
Diksha, you have to extract just alpha characters, using a regexp, then make string an array with split(''), reverse the array with .reverse(), then join the array to make new string. Then check if new string is the same as the old one.
Chris Moore
@dooglus
Jan 21 2016 07:21
@Diksha261 can you show up what you have already?
Fidel Severino
@fidelscodes
Jan 21 2016 07:24
Hello
anyone that can help me find a better solution to bonfire Seek and Destroy?
CamperBot
@camperbot
Jan 21 2016 07:25
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Fidel Severino
@fidelscodes
Jan 21 2016 07:26
My solution works but I wanted to get something a bit more adaptable if more arguments are passed
function destroyer(arr) {
  var arg1 = arguments[1],
      arg2 = arguments[2];

  // check for 4th argument
  if (arguments.length === 4) {
    var arg3 = arguments[3];
  }

  var survivorsArr = arr.filter(function(val) {
   return val !== arg1 && val !== arg2 && val !== arg3;
  });

  return survivorsArr;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
I kept trying to do something by iterating over the arguments array with
for (var i = 1; i < arguments.length; i++) {}
Diksha
@Diksha261
Jan 21 2016 07:29
function palindrome(str) {
var newStr = str.replace(/[^A-Za-z0-9.,\s+]/g,"").toLowerCase().split("").reverse().join("");
if(newStr === str){
return true;
}else{
return false;
}
}
palindrome("A man, a plan");
kirbyedy
@kirbyedy
Jan 21 2016 07:29
hey @dooglus sorry for bothering, yesterday you mentioned something about creating a JD, and I did not see if you responded to the question. What is JD ?
Diksha
@Diksha261
Jan 21 2016 07:29
something wrong with the regexp i guess..
Fidel Severino
@fidelscodes
Jan 21 2016 07:31
@Diksha261 try your regex on this page: www.regexr.com
you'll see it's not properly targeting periods and commas
Also there's a way to target just non-alphanumeric characters
check the cheatsheet on that same site :)
NainaPS
@Navyya
Jan 21 2016 07:34
@centraleft
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch(val){
    case 1:
      answer= "apple";
      break;

    case 2:
      answer= "bird";
      break;
    case 3:
      answer= "cat";
      break;
    default:
      answer="Stuff";
  }


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

// Change this value to test
myTest(1);
what is the error ?
Diksha
@Diksha261
Jan 21 2016 07:34
@fidelscodes why don't you show me yours
NainaPS
@Navyya
Jan 21 2016 07:34
this is Adding a default option in Switch statements
@chaitanyaashtekar and @centraleft
Fidel Severino
@fidelscodes
Jan 21 2016 07:38
Look at the use of \W in regexr.com @Diksha261
NainaPS
@Navyya
Jan 21 2016 07:39
@fidelscodes can u help with the code above?
Fidel Severino
@fidelscodes
Jan 21 2016 07:43
@Navyya your code looks alright except you're not following the instructions
NainaPS
@Navyya
Jan 21 2016 07:43
@fidelscodes sorry I dint get...
Fidel Severino
@fidelscodes
Jan 21 2016 07:44
instead of 1, 2, 3..
your cases need to have "a", "b" as options
NainaPS
@Navyya
Jan 21 2016 07:44
ok do i have to name the cases as a ,b,c?
Fidel Severino
@fidelscodes
Jan 21 2016 07:44
yes
NainaPS
@Navyya
Jan 21 2016 07:45
nopes i tried it too ...but it says referenceis not valid
can u pls check the code with yours? @fidelscodes ?
Fidel Severino
@fidelscodes
Jan 21 2016 07:45
"Stuff" should be lowercase
NainaPS
@Navyya
Jan 21 2016 07:46
sorry a is not defined it says
Fidel Severino
@fidelscodes
Jan 21 2016 07:46
paste your new code
NainaPS
@Navyya
Jan 21 2016 07:46
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch(val){
    case 1:

      answer= "apple";
      break;

    case 2:
      answer= "bird";
      break;
    case 3:
      answer= "cat";
      break;
    default:
      answer="stuff";
  }


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

// Change this value to test
myTest(1);
for the new one...
and for a , b, c
Fidel Severino
@fidelscodes
Jan 21 2016 07:47
You're still not using "a", "b", "c" etc as cases
NainaPS
@Navyya
Jan 21 2016 07:48
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch(val){
    case a:

      answer= "apple";
      break;

    case b:
      answer= "bird";
      break;
    case c:
      answer= "cat";
      break;
    default:
      answer="stuff";
  }


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

// Change this value to test
myTest(1);
Fidel Severino
@fidelscodes
Jan 21 2016 07:48
they're passing a string as val
so a should be "a"
NainaPS
@Navyya
Jan 21 2016 07:48
so what should be the corrct one?
ok i will try that too .. @fidelscodes
Fidel Severino
@fidelscodes
Jan 21 2016 07:49
because the function myTest expecting a string
NainaPS
@Navyya
Jan 21 2016 07:50
yup @fidelscodes :)
@thanks @fidelscodes
CamperBot
@camperbot
Jan 21 2016 07:50
navyya sends brownie points to @thanks and @fidelscodes :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for thanks
:star: 401 | @fidelscodes | http://www.freecodecamp.com/fidelscodes
Fidel Severino
@fidelscodes
Jan 21 2016 07:50
:thumbsup:
NainaPS
@Navyya
Jan 21 2016 07:50
thanks @fidelscodes
CamperBot
@camperbot
Jan 21 2016 07:50
navyya sends brownie points to @fidelscodes :sparkles: :thumbsup: :sparkles:
:warning: navyya already gave fidelscodes points
Fidel Severino
@fidelscodes
Jan 21 2016 07:51
You're welcome
Your code was fine all along, just needed to pay closer attention to the instructions ;)
NainaPS
@Navyya
Jan 21 2016 07:53
hmmmmmm u are right ... @fidelscodes
Mohit Nehru
@MohitNehru
Jan 21 2016 08:01
Add a new album to the myMusic JSON object. Add artist and title strings, release_year number, and a formats array of strings.
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1993,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }];
  // Add record here
 { 
"artist": "Daft Punk",
"title": "Homework",
"release_year": 1997,
"formats": [
"CD",
"Cassette",
"LP" ],
"gold": true
}
];
what's wrong here
Allan Armstrong
@allanarmstrong
Jan 21 2016 08:02
@MohitNehru you have two closing ];s
Mohit Nehru
@MohitNehru
Jan 21 2016 08:03
@allanarmstrong it should be 1
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1993,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  // Add record here
 { 
"artist": "Daft Punk",
"title": "Homework",
"release_year": 1997,
"formats": [
"CD",
"Cassette",
"LP" ],
"gold": true
}
Allan Armstrong
@allanarmstrong
Jan 21 2016 08:04
@MohitNehru you need to seperate the two objects using a comma
NainaPS
@Navyya
Jan 21 2016 08:12
@fidelscodes is there any option to remove if/else ??
for the waypoint Returning Boolean Values from Functions
I got it ..
Srinivas
@srinivasgp
Jan 21 2016 08:18
Access the myStorage JSON object to retrieve the contents of the glove box. Only use object notation for properties with a space in their name.

var gloveBoxContents = myStorage['car'].inside;

Could someone please tell me what is wrong is this statement?

Sorry, the statement is:
var gloveBoxContents = myStorage['car'].inside['glove box'];
NainaPS
@Navyya
Jan 21 2016 08:22
// Setup
function abTest(a, b) {
  // Only change code below this line
  if (a<0 || b<0){

    return "undefined";
  }


  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
for the waypoint Return Early Pattern for Functions
this can be the code... can anyone help?
Srinivas
@srinivasgp
Jan 21 2016 08:25
@Navyya write undefined, the keyword and not the string "undefined".\
NainaPS
@Navyya
Jan 21 2016 08:27
thanks @srinivasgp
CamperBot
@camperbot
Jan 21 2016 08:27
navyya sends brownie points to @srinivasgp :sparkles: :thumbsup: :sparkles:
:star: 216 | @srinivasgp | http://www.freecodecamp.com/srinivasgp
NainaPS
@Navyya
Jan 21 2016 08:27
yey
Neil Salumbides
@neil2112
Jan 21 2016 08:27
nice
that's my proplem too i set the undefined as a string
hahaha
fluffystub
@RakshithNM
Jan 21 2016 08:41
i am working on bonfire : Return Largest Numbers in Arrays
i am able to get the largest number in the array. i want to return the sub array that contains the largest element. how do i do that?
anyone?
Hau Harry
@counter1835
Jan 21 2016 08:47
hey guys i am working on lesson 180, my code has an error of maximum call stack size exceeeded

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

arr.push(item);
return arr.shift(); // Change this line
}

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

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

this is my code
nvm it is fixed :smile:
Loo Yen Yi
@looyenyi
Jan 21 2016 08:54
// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[2][3];
how do I make it equal to 8?
This is the instruction: Read from myArray using bracket notation so that myData is equal to 8

Example

var arr = [
[1,2,3],
[4,5,6],
[7,8,9],
[[10,11,12], 13, 14]
];
arr[0]; // equals [1,2,3]
arr[1][2]; // equals 6
arr[3]lotus/model#35; // equals 11

Rich Keyzor
@Web-Dev-Rich
Jan 21 2016 09:01
@looyenyi Don’t forget arrays and subarrays are zero indexed so you are nearly right. Check your second bracket.
Loo Yen Yi
@looyenyi
Jan 21 2016 09:02
I don't understand...
what are the differences between arrays and subarrays?
Diksha
@Diksha261
Jan 21 2016 09:03
sorry for bothering you guys again but still not getting regexr concept in palindrome...
fluffystub
@RakshithNM
Jan 21 2016 09:03
@looyenyi subarrays are nested with your array
@looyenyi var Array=[[a,b,c],[A,B,C]] ; is an array
in this array [a,b,c] and [A,B,C] are sub arrays
Loo Yen Yi
@looyenyi
Jan 21 2016 09:06
okay..
fluffystub
@RakshithNM
Jan 21 2016 09:06
got it? @looyenyi
Loo Yen Yi
@looyenyi
Jan 21 2016 09:06
@RakshithNM Yes, but I still don't understand why [2][3] doesn't equal to 8...
fluffystub
@RakshithNM
Jan 21 2016 09:07
that is because you have indexed the sub-array in a improper way
in the example that i used to explain B is accessed by using Arraylotus/model#35; @looyenyi
myArray[2] points to the third subarray right?
Loo Yen Yi
@looyenyi
Jan 21 2016 09:10
erm...
fluffystub
@RakshithNM
Jan 21 2016 09:10
@looyenyi did not get it?
Loo Yen Yi
@looyenyi
Jan 21 2016 09:10
sorry.. i still don't get it..
fluffystub
@RakshithNM
Jan 21 2016 09:11
```var myData = myArray2;
var myData = myArray[2][3];
Loo Yen Yi
@looyenyi
Jan 21 2016 09:11
I typed that but it doesn't work
fluffystub
@RakshithNM
Jan 21 2016 09:12
@looyenyi var Array=[[a,b,c],[A,B,C]] ; is an array
in this array [a,b,c] and [A,B,C] are sub arrays
you get this?
Loo Yen Yi
@looyenyi
Jan 21 2016 09:12
yes
fluffystub
@RakshithNM
Jan 21 2016 09:13
var firstsubarray = Array[0]; // '[a,b,c]'
you get this?
@looyenyi
Loo Yen Yi
@looyenyi
Jan 21 2016 09:14
ya.. okay..
yes.
fluffystub
@RakshithNM
Jan 21 2016 09:15
var thirdElementFirstSubarray = Array[0][2]; // 'c'
get it?
@looyenyi
Loo Yen Yi
@looyenyi
Jan 21 2016 09:16
oh.. so I have to mention which subarray and the position of element within that subarray?
fluffystub
@RakshithNM
Jan 21 2016 09:16
var thirdElementFirstSubarray = Array0; // 'b'
yes do it and so it to me @looyenyi
even the index of the element in the subarray atarts from 0
sorry for the typo
Loo Yen Yi
@looyenyi
Jan 21 2016 09:17
so if i want to select the second subarray what do I do?
I don't understand the index
fluffystub
@RakshithNM
Jan 21 2016 09:19
@looyenyi
var firstsubarray = Array[0]; // '[a,b,c]'
make something out from this?
Loo Yen Yi
@looyenyi
Jan 21 2016 09:20
Array[0][2] is 'b'?
Sorry I gtg @RakshithNM Thanks so much for your patience. I will be back in a few hours or the next day! :)
CamperBot
@camperbot
Jan 21 2016 09:25
looyenyi sends brownie points to @rakshithnm :sparkles: :thumbsup: :sparkles:
:star: 255 | @rakshithnm | http://www.freecodecamp.com/rakshithnm
Minhazul Islam
@Minhazul-islam
Jan 21 2016 09:38
This message was deleted
This message was deleted
Minhazul Islam
@Minhazul-islam
Jan 21 2016 09:45

What's the error? plz help```
// Setup
var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World";

myStr0 = "H"; // Fix Me```

NainaPS
@Navyya
Jan 21 2016 09:46
@Minhazul-islam name of waypoint?
Minhazul Islam
@Minhazul-islam
Jan 21 2016 09:47
@Navyya What is waypoint? plz explain indetails i m novice in js.
Shaun Yap
@shaunyap
Jan 21 2016 09:47
@Minhazul-islam: it should be myStr[0] instead of myStr0
NainaPS
@Navyya
Jan 21 2016 09:47
are tel me heading and the no of it
tell me heading of this assignment??
snobgobbler
@snobgobbler
Jan 21 2016 09:48
could any one tell me where i am going wrong

function myTest(val) {
var answer = "";
// Only change code below this line
switch (val) {
case "a":
return "apple";
break;

case "b":
return "bird";
break;

case "c":
return "cat";
break;

default:
"stuff";

}

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

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

Minhazul Islam
@Minhazul-islam
Jan 21 2016 09:48
@shaunyap Understand String Immutability
NainaPS
@Navyya
Jan 21 2016 09:48
@snobgobbler
waypoint name?
snobgobbler
@snobgobbler
Jan 21 2016 09:49
Adding a default option in Switch statements
NainaPS
@Navyya
Jan 21 2016 09:49
yes
@snobgobbler default:
answer="stuff";
Minhazul Islam
@Minhazul-islam
Jan 21 2016 09:50
@Navyya i wrote it in text editor with [ ] but it's not showing here and still it's not working
NainaPS
@Navyya
Jan 21 2016 09:50
you didnot write
answer....
snobgobbler
@snobgobbler
Jan 21 2016 09:50
thanks @Navyya
CamperBot
@camperbot
Jan 21 2016 09:50
snobgobbler sends brownie points to @navyya :sparkles: :thumbsup: :sparkles:
:star: 14 | @navyya | http://www.freecodecamp.com/navyya
NainaPS
@Navyya
Jan 21 2016 09:51
@Minhazul-islam Click on map and check the assignment heading
or @Minhazul-islam at the top of ur assignment the heading is given they are names of waypoint
Shaun Yap
@shaunyap
Jan 21 2016 09:52
@Minhazul-islam: I checked what I did was just to put it as
myStr = "Hello World"; // Fix Me
Yury
@imbroyury
Jan 21 2016 09:55
hey guys. I'm stuck at "Arguments optional" bonfire. I just can't seem to wrap my mind around "return a function" concept
Minhazul Islam
@Minhazul-islam
Jan 21 2016 09:57
This message was deleted
Yury
@imbroyury
Jan 21 2016 09:57
so far I have something like
but it doesn't work
// an argument from global add function
var a = arguments[0];
return function() {
// check if argument provided to returned function is a number
if (arguments[0] === 'number') {
return arguments[0] + a;
}
kirbyedy
@kirbyedy
Jan 21 2016 09:58
what is the name of the challenge @imbroyury
eeflores
@eeflores
Jan 21 2016 09:58
arguments optional
Minhazul Islam
@Minhazul-islam
Jan 21 2016 09:58

I can't find out what is going wrong? `// Setup
var myStr = "Jello World";

// Only change code below this line

myStr = "Hello World";

myStr[ 0 ] = "H"; // Fix Me`

Yury
@imbroyury
Jan 21 2016 09:59
@kirbyedy "Arguments Optional", sorry
eeflores
@eeflores
Jan 21 2016 09:59
@Minhazul-islam strings are immutable so you can't change one element - you'll have to recreate the string
Shaun Yap
@shaunyap
Jan 21 2016 09:59
@Minhazul-islam: see my previous message, you can't actually change the first letter by using myStr[0]. :)
NainaPS
@Navyya
Jan 21 2016 09:59
haan @Minhazul-islam he is write @shaunyap gave u code
eeflores
@eeflores
Jan 21 2016 10:00
@imbroyury can you show us all your code?
NainaPS
@Navyya
Jan 21 2016 10:00
string should be same as that of above....
David Wolff
@WolffDev
Jan 21 2016 10:01
What am I missing here, from "Using Objects for Lookups" in JavaScript
// 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("charlie");
kirbyedy
@kirbyedy
Jan 21 2016 10:02
This message was deleted
eeflores
@eeflores
Jan 21 2016 10:02
@davidwolff85 return lookup[val];
Yury
@imbroyury
Jan 21 2016 10:02
@eeflores ignore a bunch of console.logs please :)
David Wolff
@WolffDev
Jan 21 2016 10:03
@eeflores isn't it the same as using . (dot) ?
Yury
@imbroyury
Jan 21 2016 10:03
wow guys, quick help please, how do I wrap my code to display like davidwolf's?
kirbyedy
@kirbyedy
Jan 21 2016 10:03
your code
``` your code
than ``` to close it
eeflores
@eeflores
Jan 21 2016 10:03
@davidwolff85 dot notation is a direct reference to a member of an object. bracket notation allows you to use a variable to reference a member of an object
Yury
@imbroyury
Jan 21 2016 10:03
nice
ty
eeflores
@eeflores
Jan 21 2016 10:04
help formatting
CamperBot
@camperbot
Jan 21 2016 10:04

:point_right: code formatting [wiki]

Inline code

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

Code Block

```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 ⏎]

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

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

David Wolff
@WolffDev
Jan 21 2016 10:04
@eeflores thanks, missed that :)
CamperBot
@camperbot
Jan 21 2016 10:04
davidwolff85 sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 461 | @eeflores | http://www.freecodecamp.com/eeflores
Yury
@imbroyury
Jan 21 2016 10:04
This message was deleted
eeflores
@eeflores
Jan 21 2016 10:04
yw
Yury
@imbroyury
Jan 21 2016 10:05
This message was deleted
vital-b
@vital-b
Jan 21 2016 10:05

Could someone help me understand this question, I'm having trouble understanding it:Nesting For Loops
If you have a multi-dimensional array, you can use the same logic as the prior waypoint to loop through both the array and any sub-arrays. Here is an example:

var arr = [
[1,2], [3,4], [5,6]
];
for (var i=0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++) {
console.log(arr[i][j]);
}
}
This outputs each sub-element in arr one at a time. Note that for the inner loop, we are checking the .length of arr[i], since arr[i] is itself an array.

Instructions
Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr

eeflores
@eeflores
Jan 21 2016 10:06
@vital-b any specific question?
Yury
@imbroyury
Jan 21 2016 10:06
please help with Arguments Optional
function add() {
  console.log(arguments);

  console.log(typeof(arguments[0]), typeof(arguments[1]));

  // case if both arguments is provided
  if (arguments.length === 2) {
    // both arguments are numbers -> return sum
    if (typeof(arguments[0]) === 'number' &&
        typeof(arguments[1]) === 'number')
      return arguments[0] + arguments[1];
    // one of arguments is string -> return undefined
    else if (typeof(arguments[0]) !== 'number' ||
        typeof(arguments[1]) !== 'number')
      return undefined;
  }
  // case if one argument is provided
  else if (arguments.length === 1) {
    // check for rickroll
    if (typeof(arguments[0]) !== 'number')
      return undefined;
    // else return function
    else {
      console.log('this is a single number case');
      var a = arguments[0];
      console.log(a);
      return function() {
        if (arguments[0] === 'number') {
          return arguments[0] + a;
        }

      };
    }
  }
  return false;
}
vital-b
@vital-b
Jan 21 2016 10:06
@eeflores could you help me break down the question?
Minhazul Islam
@Minhazul-islam
Jan 21 2016 10:07
@Navyya @shaunyap now I've got it thnx
CamperBot
@camperbot
Jan 21 2016 10:07
minhazul-islam sends brownie points to @navyya and @shaunyap :sparkles: :thumbsup: :sparkles:
:star: 15 | @navyya | http://www.freecodecamp.com/navyya
:star: 267 | @shaunyap | http://www.freecodecamp.com/shaunyap
eeflores
@eeflores
Jan 21 2016 10:08
@imbroyury looks similar to mine ... hold on
Mohit Nehru
@MohitNehru
Jan 21 2016 10:08
Access the myStorage JSON object to retrieve the contents of the glove box. Only use object notation for properties with a space in their name.+
eeflores
@eeflores
Jan 21 2016 10:08
@vital-b 2 for loops: the i for loop is used to access elements in the outer array - contains [1,2], [3,4], [5,6]
Mohit Nehru
@MohitNehru
Jan 21 2016 10:09
// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};
myStorage.car["inside"].glovebox;
// Only change code below this line

var gloveBoxContents = ""; // Change this line
Access the myStorage JSON object to retrieve the contents of the glove box. Only use object notation for properties with a space in their name.
eeflores
@eeflores
Jan 21 2016 10:09
@vital-b for each element in the outer array, the inner for loop iterates through each inner array
Minhazul Islam
@Minhazul-islam
Jan 21 2016 10:09
This message was deleted
eeflores
@eeflores
Jan 21 2016 10:10
@imbroyury the returned function takes a parameter
@imbroyury my returned function is something like this:
function(b) {
  if(typeof(b) === "number") {
    return a + b;
  }
}
Yury
@imbroyury
Jan 21 2016 10:13
@eeflores wow great it worked! I completely forgot about typeof..thanks a lot!
CamperBot
@camperbot
Jan 21 2016 10:13
imbroyury sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 462 | @eeflores | http://www.freecodecamp.com/eeflores
eeflores
@eeflores
Jan 21 2016 10:13
@imbroyury yw
@imbroyury I guess what you had before would've worked, it was just the typeof thing
Yury
@imbroyury
Jan 21 2016 10:14
@eeflores you can actually do it without parameter, the only thing wrong about my code was typeof..thanks a lot again
CamperBot
@camperbot
Jan 21 2016 10:14
imbroyury sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:warning: imbroyury already gave eeflores points
eeflores
@eeflores
Jan 21 2016 10:15
@vital-b all good so far?
NainaPS
@Navyya
Jan 21 2016 10:15
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};
var k = 16;
// Only change code below this line;

var playerNumber= testObj[16];       // Change this Line
var player =testObj[k];   // Change this Line
can any one help with the waypoint Accessing Objects Properties with Variables
eeflores
@eeflores
Jan 21 2016 10:16
@MohitNehru myStorage.car.inside["glove box"];
NainaPS
@Navyya
Jan 21 2016 10:16
@shaunyap ???
eeflores
@eeflores
Jan 21 2016 10:16
@Navyya playerNumber = 16;
@Navyya use playerNumber as a bracketed parameter to testObj
NainaPS
@Navyya
Jan 21 2016 10:17
and @eeflores is rest code correct?
Marion Schleifer
@marionschleifer
Jan 21 2016 10:17

Hi there, I am at the counting card challenge, and I don't know what is wrong with my code:

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

if (count > 0) {
return card + " Bet";

} else {
return card + " Hold";
}

Can anybody help?
NainaPS
@Navyya
Jan 21 2016 10:17
@marionschleifer I have it
Mohit Nehru
@MohitNehru
Jan 21 2016 10:18
Selection_017.jpg
NainaPS
@Navyya
Jan 21 2016 10:18
var count = 0;

function cc(card) {
  // Only change code below this line
 if(card==2||card==3||card==4||card==5||card==6)
{
  count++;
}  
  else if(card==10||card=="J"||card=="Q"||card=="K"||card=="A")
{
  count--;
}  
      if (count >0){
        return count+" Bet";
      }
        else {
          return count+" Hold";
        }

  //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');
eeflores
@eeflores
Jan 21 2016 10:18
@Navyya the challenge is specifically looking for playerNumber to be assigned 16, and player be assigned testObj[playerNumber]
@marionschleifer looks good to me - tried a browser refresh?
@MohitNehru assign the second last line to the last line
NainaPS
@Navyya
Jan 21 2016 10:20
thanks @eeflores
CamperBot
@camperbot
Jan 21 2016 10:20
navyya sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:star: 463 | @eeflores | http://www.freecodecamp.com/eeflores
Marion Schleifer
@marionschleifer
Jan 21 2016 10:21
@Navyya thank you so much :)
CamperBot
@camperbot
Jan 21 2016 10:21
marionschleifer sends brownie points to @navyya :sparkles: :thumbsup: :sparkles:
:star: 16 | @navyya | http://www.freecodecamp.com/navyya
NainaPS
@Navyya
Jan 21 2016 10:21
@marionschleifer did u get the solution?
:) @marionschleifer
Marion Schleifer
@marionschleifer
Jan 21 2016 10:30
i am sorry, but i have another question about the record collection
i have this:

function update(id, prop, value) {

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

Markus Kiili
@Masd925
Jan 21 2016 10:31
@marionschleifer collection[prop] is not correct.
First figure out how to get one record with given id.
Marion Schleifer
@marionschleifer
Jan 21 2016 10:32
@Masd925 Ok, thanks. I'll try again
CamperBot
@camperbot
Jan 21 2016 10:32
marionschleifer sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 759 | @masd925 | http://www.freecodecamp.com/masd925
Rahul Dogra
@rahulsimpact
Jan 21 2016 10:41
How do we play Madlib?
Maxwell Nare
@maxinare
Jan 21 2016 10:51
@rahulsimpact its concatenation, basically u use given words and your own to construct a sentence
NainaPS
@Navyya
Jan 21 2016 10:52
@rahulsimpact its just as fill in the blanks
Shaun Yap
@shaunyap
Jan 21 2016 10:59
@Navyya sorry was away for a bit. did you get your problem solved?
NainaPS
@Navyya
Jan 21 2016 11:06
yup @shaunyap
but have one more:)
// 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"
  };

  lookup."charlie";

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

// Change this value to test
phoneticLookup("charlie");
@shaunyap Using Objects for Lookups waypoint
baldwinbejarasco
@baldwinbejarasco
Jan 21 2016 11:08
result = lookup[val] @Navyya
Goodevening campers I have this problem, can you take a look ?
Shaun Yap
@shaunyap
Jan 21 2016 11:10
@baldwinbejarasco beat me to it. ;)
baldwinbejarasco
@baldwinbejarasco
Jan 21 2016 11:10
blob
Shaun Yap
@shaunyap
Jan 21 2016 11:10
@baldwinbejarasco will try.. i'm still quite ne!
al nmeri
@nmeri17
Jan 21 2016 11:10
sup guys?
function findLongestWord(str) {
  str = str.split(" ");
  str = str.forEach(function (b) {
    return b.length;
  });
  var most = Math.max.apply(null, str);
  return most;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
NainaPS
@Navyya
Jan 21 2016 11:11
@baldwinbejarasco sorry dint get?
al nmeri
@nmeri17
Jan 21 2016 11:11
can anyone point out what's wrong with the code above
Diksha
@Diksha261
Jan 21 2016 11:12

function findLongestWord(str) {
var longestStr = 0;
for (var x=0;x<str.split(' ').length;x++){
if (longestStr < str.split(' ')[x].length){
longestStr = str.split(' ')[x].length;
}
}
return longestStr;
}

findLongestWord("The quick brown fox over the lazy dog");

baldwinbejarasco
@baldwinbejarasco
Jan 21 2016 11:12
outside your lookup object put the result = obJectName[val]; @Navyya
blob
NainaPS
@Navyya
Jan 21 2016 11:13
nah nah dont send screenshots use the code editor
Shaun Yap
@shaunyap
Jan 21 2016 11:14
@baldwinbejarasco: about your problem. you can't push a value directly to collection, but you'll need to figure out collection[prop]
if that makes sense. :)
baldwinbejarasco
@baldwinbejarasco
Jan 21 2016 11:14
does my first statement make sense @shaunyap ?
NainaPS
@Navyya
Jan 21 2016 11:14
haan @baldwinbejarasco @shaunyap I got the solution
Shaun Yap
@shaunyap
Jan 21 2016 11:14
@Navyya: the code you've shared returns 'result' which was set to ""
cool.
NainaPS
@Navyya
Jan 21 2016 11:15
ok and for the statement result= lookup[val]?
@shaunyap ?
it will return all the value of passed vars?
Shaun Yap
@shaunyap
Jan 21 2016 11:16
heh if you've got the answer then it's alright, was trying to lead you down the right path.
:)
NainaPS
@Navyya
Jan 21 2016 11:17
even i was waitning for so that my confusion will be cleared
baldwinbejarasco
@baldwinbejarasco
Jan 21 2016 11:17
your problem wants to RETURN something, since you already have VAR RESULT as a variable use the result var iable to lookup value = result = look[val] @Navyya
NainaPS
@Navyya
Jan 21 2016 11:17
:)
Shaun Yap
@shaunyap
Jan 21 2016 11:18
@baldwinbejarasco your fist statement should be value !== "" && prop !== tracks instead
al nmeri
@nmeri17
Jan 21 2016 11:23
@Diksha261 nice
But you have any idea why my code does not work?
daniel
@h311o
Jan 21 2016 11:26
It removes one of the twos but keeps the other. Why?
function destroyer(arr) {
  // Remove all the values
  // return arr[2];
  var input = arguments[0]; // input = [3,5,1,2,2]
  var remove = [];
  for (var i = 1; i < arguments.length; i++) {
    remove.push(arguments[i]);
  }
  // remove = [2,3,5]

  var output = input; // output = [3,5,1,2,2]
  for (i = 0; i < input.length; i++) { // 0; 1; 2; 3; 4
    for (var j = 0; j < remove.length; j++) { // 0; 1; 2
      if (input[i] === remove[j]) { // 3 = 2; 3 = 3 (!); 3 = 5; ... 
        output.splice(i,1); // from index remove how many?
      }
    }
  }

  return output;
}

destroyer([3, 5, 1, 2, 2], 2, 3, 5);
// destroyer([2, 3, 2, 3], 2, 3);
// destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3);
matthew3454
@matthew3454
Jan 21 2016 11:38
Can someone please help me on the waypoint: Global Scope and Functions?
Brendan Kinahan
@BKinahan
Jan 21 2016 11:39
morning y'all
matthew3454
@matthew3454
Jan 21 2016 11:40
buenas dias
NainaPS
@Navyya
Jan 21 2016 11:40
@matthew3454 what u need in it?
matthew3454
@matthew3454
Jan 21 2016 11:41
myGlobal should be defined
myGlobal should have a value of 10
myGlobal should be declared using the var keyword
oopsGlobal should have a value of 5 @Navyya I need these instructions fulfilled
// Declare your variable here


function fun1() {
  // Assign 5 to oopsGlobal Here
  var myGlobal=global(10);
  oopsGlobal=5;
}

// Only change code above this line
function fun2() {
  var output = "";
  if (typeof myGlobal != "undefined") {
    output += "myGlobal: " + myGlobal;
  }
  if (typeof oopsGlobal != "undefined") {
    output += " oopsGlobal: " + oopsGlobal;
  }
  console.log(output);
}
NainaPS
@Navyya
Jan 21 2016 11:41
@matthew3454
// Declare your variable here
 var myGlobal=10;

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

  oopsGlobal=5;
}

// Only change code above this line
function fun2() {
  var output = "";
  if (typeof myGlobal != "undefined") {
    output += "myGlobal: " + myGlobal;
  }
  if (typeof oopsGlobal != "undefined") {
    output += " oopsGlobal: " + oopsGlobal;
  }
  console.log(output);
}
Brendan Kinahan
@BKinahan
Jan 21 2016 11:41
@matthew3454 declare myGlobal where it says declare your variable here
matthew3454
@matthew3454
Jan 21 2016 11:42
okay
NainaPS
@Navyya
Jan 21 2016 11:42
check my code u will get it @matthew3454
@matthew3454 global should be outside the function
matthew3454
@matthew3454
Jan 21 2016 11:43
@Navyya @BKinahan Thank you!
CamperBot
@camperbot
Jan 21 2016 11:43
matthew3454 sends brownie points to @navyya and @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 17 | @navyya | http://www.freecodecamp.com/navyya
:star: 691 | @bkinahan | http://www.freecodecamp.com/bkinahan
daniel
@h311o
Jan 21 2016 11:45
Has anyone figured out the destroyer function?
Jago Kosolosky
@Jago-Kosolosky
Jan 21 2016 11:46
"Iterate over Arrays with map" I think I set this right but how do I apply it to the oldArray?
'''
var addThree = oldArray.map(function(val){
return val +3;
});
'''
CamperBot
@camperbot
Jan 21 2016 11:46
:bulb: to format code use backticks! ``` more info
Jago Kosolosky
@Jago-Kosolosky
Jan 21 2016 11:46
var addThree = oldArray.map(function(val){
                            return val +3;
                            });
dhavalpatel76126
@dhavalpatel76126
Jan 21 2016 11:50
@camperbot hello
i want to one help
@Jago-Kosolosky helo