These are chat archives for FreeCodeCamp/HelpJavaScript

18th
Jan 2016
Ashley
@Ashtheyogi
Jan 18 2016 00:00
I'm not sure what I'm supposed to do
William Reed
@reforma
Jan 18 2016 00:00
ok you need to create a variable called oopsGlobal and assign 5 to it
Ashley
@Ashtheyogi
Jan 18 2016 00:00
okay
William Reed
@reforma
Jan 18 2016 00:00
try and show me what you think it should be
Ashley
@Ashtheyogi
Jan 18 2016 00:01
okay give me a second
but it said create a oopsGlobal without using var keyword
so do I just put it?
William Reed
@reforma
Jan 18 2016 00:01
try
Ashley
@Ashtheyogi
Jan 18 2016 00:02
okay
William Reed
@reforma
Jan 18 2016 00:02
can anyone help me with nesting for loops challenge ?
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i < arr[i]; i** ){
    //product += i;
  }
  // Only change code above this line
  return i;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
i know its only a start but i want to know if i am on the right lines before i start making it work for various arrays
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 00:02
@reforma I'm doing that one right now
William Reed
@reforma
Jan 18 2016 00:03
@Nyarlat-hotep great :)
Ashley
@Ashtheyogi
Jan 18 2016 00:03
var oopsGlobal;
It would be done like this but it's not supposed to be defined as a var
William Reed
@reforma
Jan 18 2016 00:04
@Ashtheyogi you need to take away the var
Ashley
@Ashtheyogi
Jan 18 2016 00:04
okay
Sandy
@sandyvern
Jan 18 2016 00:04
This message was deleted
Ashley
@Ashtheyogi
Jan 18 2016 00:04
oopsGlobal(5);
like this?
William Reed
@reforma
Jan 18 2016 00:05
no you need to use = not ()
Ashley
@Ashtheyogi
Jan 18 2016 00:05
okay
okay I think I got it, I was just intimidated by the instructions
William Reed
@reforma
Jan 18 2016 00:06
@Ashtheyogi no problem its not very clear
Granite1
@Granite1
Jan 18 2016 00:09
I got a problem in javscript can anyone help

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

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

CamperBot
@camperbot
Jan 18 2016 00:09
:bulb: to format code use backticks! ``` more info
Granite1
@Granite1
Jan 18 2016 00:11
hello
@camperbot hello
@reforma hello
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 00:11
what is the exercise called @Granite1
Granite1
@Granite1
Jan 18 2016 00:11
I will give you a link is that fine with you
I just can't figure it out
William Reed
@reforma
Jan 18 2016 00:12
its essentially a math question @Granite1
what code have you got so far
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 00:13
@Granite1 so you need to make a new variable called fahrenheit. That variable will take whatever celsius is, multiply it by 9/5 and then add 32 to it.
copy what you have if you are still stuck @Granite1
Granite1
@Granite1
Jan 18 2016 00:14
@Nyarlat-hotep so do I put var fahrenheit = 9/5 + 32 right
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 00:15
close. Remeber you have to multiply 9/5 to celsius
William Reed
@reforma
Jan 18 2016 00:15
@Granite1 close but you need to include the celsius value
Granite1
@Granite1
Jan 18 2016 00:15
var fahrenheit = celsius * 9/5 + 32;
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 00:15
@reforma did you figure out the nesting for loops yet?
Granite1
@Granite1
Jan 18 2016 00:15
Thank you
for helping me guys
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 00:16
yessir
William Reed
@reforma
Jan 18 2016 00:16
@Nyarlat-hotep no not yet - i am currently trying to convert the multiple array into a list of values that i might be able to multiply
but no luc
k
have you managed it yet
?
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 00:17
no, trying to figure out what I can do without modifying the return statment
William Reed
@reforma
Jan 18 2016 00:19
@Nyarlat-hotep Giving up for the night good luck though
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 00:19
thanks
Brendan Kinahan
@BKinahan
Jan 18 2016 00:25
@Nyarlat-hotep are you having trouble with something?
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 00:26
yes?
@BKinahan what help do you need?
I'm at the nesting for loops exercise
Sandy
@sandyvern
Jan 18 2016 00:32
Could someone help me with a lesson please? I am on the lesson "Storing Values with the Equal Operator" and can not figure out how to "assign the contents of a to variable b"...to me it sounds like 'var a = var b'...but obviously that seems to be wrong :-(
Brendan Kinahan
@BKinahan
Jan 18 2016 00:33
@sandyvern var is only used when declaring a variable for the first time. Also, assign a to b, not b to a
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 00:33
@BKinahan can you help meh on the nesting for loops exercise?
Cole Perkins
@coleperkins
Jan 18 2016 00:34

Working on Waypoint: Record Collection.

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

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


  return collection;
}

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

Does anyone see what is wrong here?

Brendan Kinahan
@BKinahan
Jan 18 2016 00:34
@Nyarlat-hotep Sure, what do you have so far?
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 00:34
for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; j++) {
      product = arr[i]*[j];
    }
  }
Sandy
@sandyvern
Jan 18 2016 00:35
@BKinahan so would it be 'a = b'?
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 00:35
b = a @sandyvern
Brendan Kinahan
@BKinahan
Jan 18 2016 00:35
@Nyarlat-hotep hm.. it’s almost all fine, but your * is in a strange place :)
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 00:36
@coleperkins you need an if, and two else if statements.
if (value !== "" && prop !== "tracks") {
    collection[id][prop] = value;
Sandy
@sandyvern
Jan 18 2016 00:36
aaaahhh....thank you @Nyarlat-hotep
CamperBot
@camperbot
Jan 18 2016 00:36
sandyvern sends brownie points to @nyarlat-hotep :sparkles: :thumbsup: :sparkles:
:star: 117 | @nyarlat-hotep | http://www.freecodecamp.com/nyarlat-hotep
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 00:36
should be your if
Brendan Kinahan
@BKinahan
Jan 18 2016 00:37
@Nyarlat-hotep what is the value of [j] there? it looks like bracket notation but it doesn’t have an array variable in front of it.
Ray
@rbjr
Jan 18 2016 00:37
help profile lookup
CamperBot
@camperbot
Jan 18 2016 00:37

: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

Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 00:40
@BKinahan I know how to access the values of j, just not how to write it where they are getting multiplied together
Brendan Kinahan
@BKinahan
Jan 18 2016 00:42
@Nyarlat-hotep well, you don’t want to multiply the value of arr[i] with the value of arr[j], because you’ll end up using the arr[i] values several times instead of once each. What you really want to do is multiply each arr[i][j] value by product, which will keep the result out of the loop and give you the overall product in the end.
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 00:44
word, was close to that a few times. Got it though, thanks @BKinahan
CamperBot
@camperbot
Jan 18 2016 00:44
nyarlat-hotep sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 656 | @bkinahan | http://www.freecodecamp.com/bkinahan
Cole Perkins
@coleperkins
Jan 18 2016 00:52

@Nyarlat-hotep

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

// Only change code below this line
function update(id, prop, value) {
  if (collection[id][prop] !== "" && prop !== "tracks") {
    collection[id][prop] = value;
  }  
  else if (prop === "tracks" && collection[id][prop] !== "") {
    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");

I made a few changes, but I am still not getting a pass. Not sure if I am misreading the instructions or simply missing something.

Anyone else have ideas?
Maximilian Schlosser
@maxschlosser
Jan 18 2016 01:03
@coleperkins try collection[id].hasOwnProperty(prop) instead of collection[id][prop] !== ""
Ray
@rbjr
Jan 18 2016 01:04
help caesars cipher
CamperBot
@camperbot
Jan 18 2016 01:04

:point_right: bonfire caesars cipher [wiki]

Problem Explanation:

  • You need to write a function, which will take string encoded with
    Caesar cipher as a parameter and decode it.
  • The one used here is ROT13 where the value of the letter is
    shifted by 13 places.
    e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
  • You have to shift it back 13 positions, such that 'N' ↔ 'A'.
:pencil: read more about bonfire caesars cipher on the FCC Wiki
Zina Astafyeva
@tragetraje
Jan 18 2016 01:05
help Waypoint Make Object Properties Private
CamperBot
@camperbot
Jan 18 2016 01:05

: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

Maximilian Schlosser
@maxschlosser
Jan 18 2016 01:08
help Waypoint seek and destroy
CamperBot
@camperbot
Jan 18 2016 01:08
no wiki entry for: waypoint seek and destroy
Maximilian Schlosser
@maxschlosser
Jan 18 2016 01:08
function destroyer(arr) {
  arr[0] = arr[0].filter(function(val) {
  return val !== 5;
  });
}

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

I get the following error:
TypeError: arr[0].filter is not a function

I copied the filter function from the example so it should work.

Am I declaring the function inside the filter function wrong or am I accessing the array wrong?

Brian
@sludge256
Jan 18 2016 01:12
@maxschlosser You're not calling the method on an array
You're calling it on an element
Kyle Roach
@iRoachie
Jan 18 2016 01:12
This message was deleted
Brian
@sludge256
Jan 18 2016 01:13
oh right I was thinking he was on a different lesson
Micah Bales
@micahbales
Jan 18 2016 01:13
Working on the "Profile Lookup" lesson, and could use a hint. Here's my code:
function lookUp(firstName, prop){
// Only change code below this line
if (contacts[firstName] && contacts[firstName][prop]) {
  return contacts[firstName][prop];
} else if (contacts[firstName][prop] === false) {
  return "No such contact";
} else if (contacts[firstName][prop] === false) {
  return "No such property";
}
Not working at all right now.
Kyle Roach
@iRoachie
Jan 18 2016 01:14
I’m at that challenge as well
Maximilian Schlosser
@maxschlosser
Jan 18 2016 01:14
@sludge256 I found my error. You were right, I am not using it on an array. It's an argument object. The given names are misleading though.
Kyle Roach
@iRoachie
Jan 18 2016 01:14
@maxschlosser You’re actually passing in an array, as well as other values
@iRoachie So the param for the funciton isn’t an array as expected
Maximilian Schlosser
@maxschlosser
Jan 18 2016 01:15

@iRoachie

function destroyer(args) {
  var arr = Array.prototype.slice.call(arguments);
  arr[0] = arr[0].filter(
    function(val) {
      return val !== 5;
    });
  return arr[0];
}

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

this works for some reason x)

Kyle Roach
@iRoachie
Jan 18 2016 01:16
I have no idea
Brian
@sludge256
Jan 18 2016 01:16
Yea with the original function only the first input is passed into the parameter
the rest are accessible with the arguments object
Andrew Bales
@agbales
Jan 18 2016 01:16
@micahbales Have you considered a for loop?
Micah Bales
@micahbales
Jan 18 2016 01:17
@agbales :D I had considered it, but wasn't quite sure what the content would be.
Maximilian Schlosser
@maxschlosser
Jan 18 2016 01:17
I missed the link to this page on the lesson while glancing over the text:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments
Daniel Starr
@dstarr1492
Jan 18 2016 01:18

function palindrome(str) {
str = str.toLowerCase();

str = str.replace(".","");
str = str.replace(" ","");
str = str.replace(",","");

str = str.split("");

var reversed = str.reverse() ;

var result = true;

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

for(x=0; x < str[i].length; x++){

  if (str[i] === reversed[x]) {
    result = true;

  } else  {result = false; 

  }

}

}

return result ;
}

palindrome("eyee");
Can anyone help me?
i'm on the palindromes assignment and i cant get this to return correctly.

Andrew Bales
@agbales
Jan 18 2016 01:18
Looks like for each contact (within the loop), you'll want to "1) check if firstName is an actual contact's firstName. 2) that the given property (prop) is a property of that contact."
Brian
@sludge256
Jan 18 2016 01:18
@maxschlosser JS is a bit different in that you can pass in as many arguments as you want into a function
even if you don't have that many parameters specified
Maximilian Schlosser
@maxschlosser
Jan 18 2016 01:19
@sludge256 I'm used to C so this flexibility feels kinda.. wrong x)
@sludge256 thx - almost forgot the brownie ^^'
CamperBot
@camperbot
Jan 18 2016 01:20
maxschlosser sends brownie points to @sludge256 :sparkles: :thumbsup: :sparkles:
:star: 881 | @sludge256 | http://www.freecodecamp.com/sludge256
Micah Bales
@micahbales
Jan 18 2016 01:20
@agbales Hm... and what if one is correct and the other isn't?
@agbales That is to say, what if one returns true and the other false
Andrew Bales
@agbales
Jan 18 2016 01:20
Sounds like an if/else :)
Micah Bales
@micahbales
Jan 18 2016 01:21
@agbales alright, back to the drawing board. thx.
CamperBot
@camperbot
Jan 18 2016 01:21
micahbales sends brownie points to @agbales :sparkles: :thumbsup: :sparkles:
:star: 281 | @agbales | http://www.freecodecamp.com/agbales
Wesly Jason
@wesly-jason
Jan 18 2016 01:28
// Setup
function abTest(a, b) {
  // Only change code below this line
  if(a < 0 || b < 0)
    return "undefined";
    else

  // 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);
can someone please help me?
the function should immediately exit if a or b is less than 0
exit with a value of undefined
Brian
@sludge256
Jan 18 2016 01:29
undefined is a value
don't return it as a string
Kyle Roach
@iRoachie
Jan 18 2016 01:30
just return;
Brian
@sludge256
Jan 18 2016 01:30
that also works ^
Wesly Jason
@wesly-jason
Jan 18 2016 01:30
@sludge256 ok
Aaron Osteraas
@aosteraas
Jan 18 2016 01:34
wiki seek and destroy
CamperBot
@camperbot
Jan 18 2016 01:34

:point_right: bonfire seek and destroy [wiki]

Explanation:

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

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

Kyle Roach
@iRoachie
Jan 18 2016 01:34
@micahbales Hey i got mine figured out
@micahbales
var contact;

 for(var i=0; i < contacts.length; i++) {
     if(contacts[i].firstName === firstName) {
       contact = contacts[i];
     }
 }

  if(!contact) {
    return "No such contact";
  } else if(!contact[prop]) {
    return "No such property";
  } else {
    return contact[prop];
  }
Darrel Adams
@dadams-510
Jan 18 2016 01:35
Could anyone help me work through accessing Accessing Nested Objects in JSON?
@camperbot help
Kyle Roach
@iRoachie
Jan 18 2016 01:36

@dadams-510 Hey you can combine selectors to get nested objects

object[nested object][nested twice]

Darrel Adams
@dadams-510
Jan 18 2016 01:38
@iRoachie The instructions say to use object notation for properties with a space in their name. Is this the same thing?
Kyle Roach
@iRoachie
Jan 18 2016 01:38
@dadams-510 Yes just remember to put the quotes
object['prop']['nested prop’]
Rumen1982
@Rumen1982
Jan 18 2016 01:40
Convert Celsius to Fahrenheit i need help on this
Darrel Adams
@dadams-510
Jan 18 2016 01:41
@iRoachie This is my code: var gloveBoxContents = myStorage.car["inside"]["glove box"];
Rumen1982
@Rumen1982
Jan 18 2016 01:42

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

// 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 dont know how to put them

Kyle Roach
@iRoachie
Jan 18 2016 01:42
@dadams-510 Yes that’s correct
@Rumen1982 Ramen can you post you’re url so can see the isntructions
Darrel Adams
@dadams-510
Jan 18 2016 01:43
@iRoachie It has a yellow symbol next to it saying "inside" is better written in dot notation.
I think that's what's throwing me off.
d wilder
@alhazen1
Jan 18 2016 01:43
@Rumen1982 where are you stuck?
Kyle Roach
@iRoachie
Jan 18 2016 01:44
@dadams-510 It accomplishes the same thing. You can do dot notation as well
myStorage.car.inside['glove box'];
Rumen1982
@Rumen1982
Jan 18 2016 01:44
You are given a variable celsius representing a temperature in Celsius. Create a variable fahrenheit and apply the algorithm to assign it the corresponding temperature in Fahrenheit.
@iRoachie
Rumen1982
@Rumen1982
Jan 18 2016 01:44
convert(0) should return a number
convert(-30) should return a value of -22
convert(-10) should return a value of 14
convert(0) should return a value of 32
convert(20) should return a value of 68
convert(30) should return a value of 86
Darrel Adams
@dadams-510
Jan 18 2016 01:44
@iRoachie Awesome. Good to know. Thank you
CamperBot
@camperbot
Jan 18 2016 01:44
dadams-510 sends brownie points to @iroachie :sparkles: :thumbsup: :sparkles:
:star: 246 | @iroachie | http://www.freecodecamp.com/iroachie
Kyle Roach
@iRoachie
Jan 18 2016 01:45
@Rumen1982 You need apply the operation to celsius;
  var fahrenheit = celsius * 9/5 + 32;
d wilder
@alhazen1
Jan 18 2016 01:47
@Rumen1982 Yep, this is the math for...Fahrenheit is the temperature in Celsius times 9/5, plus 32.
Rumen1982
@Rumen1982
Jan 18 2016 01:47
i didnt get it
@iRoachie
Kyle Roach
@iRoachie
Jan 18 2016 01:48
@Rumen1982 Post your code so i can see the mistake
Rumen1982
@Rumen1982
Jan 18 2016 01:48
ok i got the math

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

// 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);
@iRoachie

pleease tell me where to put this code
convert(0) should return a number
convert(-30) should return a value of -22
convert(-10) should return a value of 14
convert(0) should return a value of 32
convert(20) should return a value of 68
convert(30) should return a value of 86
d wilder
@alhazen1
Jan 18 2016 01:49
@Rumen1982 between the two lines //Only change code...
Munish Tayal
@munishtayal
Jan 18 2016 01:50
0_0 ( : /-\ : ) 0-0 ......Is this string a palindrome....problem says to proove it a palindrome...plz someone help
Kyle Roach
@iRoachie
Jan 18 2016 01:50

@Rumen1982 You need to add this code in between there

@Rumen1982 You need apply the operation to celsius;

  var fahrenheit = celsius * 9/5 + 32;
Rumen1982
@Rumen1982
Jan 18 2016 01:50
i need to do these things @alhazen1
d wilder
@alhazen1
Jan 18 2016 01:50
@Rumen1982 that is not for you to code - the test will run it for you
biguelo
@biguelo
Jan 18 2016 01:50

function update(id, prop, value) {

if (id in collection){

if (prop in collection[id]){

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

}
return collection;
}

Help no passing test for: update(1245, "tracks", "Addicted to Love"), tracks should have a length of 1
CamperBot
@camperbot
Jan 18 2016 01:51
no wiki entry for: no passing test for update1245 tracks addicted to love tracks should have a length of 1
sloo012
@sloo012
Jan 18 2016 01:51
Hi
I am trying to change font size to my quotes. http://codepen.io/sloo012/pen/vLezaW
Rumen1982
@Rumen1982
Jan 18 2016 01:52
thanks @alhazen1 and @iRoachie
CamperBot
@camperbot
Jan 18 2016 01:52
rumen1982 sends brownie points to @alhazen1 and @iroachie :sparkles: :thumbsup: :sparkles:
:star: 248 | @iroachie | http://www.freecodecamp.com/iroachie
:star: 265 | @alhazen1 | http://www.freecodecamp.com/alhazen1
Brian
@sludge256
Jan 18 2016 01:53
@munishtayal it's a palindrome if you remove everything except letters and numbers
Kyle Roach
@iRoachie
Jan 18 2016 01:53
@biguelo hey you’re checking the wrong values in the if statements
biguelo
@biguelo
Jan 18 2016 01:53
why?
Thanks @iRoachie. Got it...
CamperBot
@camperbot
Jan 18 2016 01:54
biguelo sends brownie points to @iroachie :sparkles: :thumbsup: :sparkles:
:star: 249 | @iroachie | http://www.freecodecamp.com/iroachie
sloo012
@sloo012
Jan 18 2016 01:55
How do I change CSS properties for my quotes? my codepen is here http://codepen.io/sloo012/pen/vLezaW
Kyle Roach
@iRoachie
Jan 18 2016 01:56
@sloo012 in
#quotes p{
  font-size:50px;
  color:green;
}
sloo012
@sloo012
Jan 18 2016 01:57
@iRoachie It doesn't change anything. I've tried
Nevermind!! Got it.
syntax error
Kyle Roach
@iRoachie
Jan 18 2016 01:59
Ahh well glad you got it
sloo012
@sloo012
Jan 18 2016 02:10
yah me too. I was trying to figure out for like an hour. There was an extra semicolon.....
Kyle Roach
@iRoachie
Jan 18 2016 02:10
Haha semicolons are annoying
Michelle
@mjohnstonee
Jan 18 2016 02:11
still having problems with Quoting Strings with Single Quotes
var myStr = "<a href="http://www.example.com" target="_blank">Link</a>";
Kyle Roach
@iRoachie
Jan 18 2016 02:12
@mjohnstonee You have to use single quotes instead of double
@mjohnstonee
var myStr = '<a href="http://www.example.com" target="_blank">Link</a>';
Michelle
@mjohnstonee
Jan 18 2016 02:14
thank you this has been driving me crazy all weekend
Thanks @iRoachie
CamperBot
@camperbot
Jan 18 2016 02:14
mjohnstonee sends brownie points to @iroachie :sparkles: :thumbsup: :sparkles:
:star: 255 | @iroachie | http://www.freecodecamp.com/iroachie
Kyle Roach
@iRoachie
Jan 18 2016 02:14
@mjohnstonee Ha next time don’t be afraid to ask someone :) we’re all learning
Maximilian Schlosser
@maxschlosser
Jan 18 2016 02:15

@mjohnstonee A string with single quotes ignores double quotes and vice versa.

var myStr = "('sometext')";
var myOtherStr='("sometext")';

will contain ('sometext)' (or ("sometext")) while

var myFaultyStr  = "("sometext")";

will only contain (

Rowan Morgan
@Frithan
Jan 18 2016 02:18
hi,
if i have
Michelle
@mjohnstonee
Jan 18 2016 02:20
why is it still not working? var myStr = ''<a href="http://www.example.com" target="_blank">Link</a>";
Rowan Morgan
@Frithan
Jan 18 2016 02:20

hi,
if i have

output.push(temp);

with in the scope of a for loop, this should push whats in temp to the var output, right?

Kyle Roach
@iRoachie
Jan 18 2016 02:20

@mjohnstonee You have to start with single quotes

var myStr = ‘<a

You’re still using double quotes
Michelle
@mjohnstonee
Jan 18 2016 02:22
var myStr = '<a href="http://www.example.com" target="_blank">Link</a>';
Maximilian Schlosser
@maxschlosser
Jan 18 2016 02:22

@Frithan it will be added to the array as a new value.

var output=[1,2,3];
output.push(3);

output will now contain [1,2,3,3]

This will behave the same way in loops.

Kyle Roach
@iRoachie
Jan 18 2016 02:22
@mjohnstonee Yea that’s it
Michelle
@mjohnstonee
Jan 18 2016 02:23
it's not accepting
Aaron Graves
@gravesmeister
Jan 18 2016 02:28
Can someone help me with Passing Values to Functions with Arguments? I don't really understand what it's asking me to do
Pandarati
@Pandarati
Jan 18 2016 02:31
@gravesmeister basically the challenge is asking you to call the function passing in data, so the data can be used inside the function as variables
@mjohnstonee Look at the instructions very carefully. You got this!
Michelle
@mjohnstonee
Jan 18 2016 02:33
thanks again @iRoachie
CamperBot
@camperbot
Jan 18 2016 02:33
mjohnstonee sends brownie points to @iroachie :sparkles: :thumbsup: :sparkles:
:warning: mjohnstonee already gave iroachie points
Michelle
@mjohnstonee
Jan 18 2016 02:33
I had an extra space
Michael
@msulock
Jan 18 2016 02:33
Hello! How do I get code I paste in here to look pretty instead of just plain text?
Pandarati
@Pandarati
Jan 18 2016 02:33
@bbbeans wiki format code
wiki format code
CamperBot
@camperbot
Jan 18 2016 02:34
no wiki entry for: format code
Pandarati
@Pandarati
Jan 18 2016 02:34
wiki formatting code
CamperBot
@camperbot
Jan 18 2016 02:34
no wiki entry for: formatting code
Maximilian Schlosser
@maxschlosser
Jan 18 2016 02:34
help format code
CamperBot
@camperbot
Jan 18 2016 02:34
no wiki entry for: format code
Aaron Graves
@gravesmeister
Jan 18 2016 02:34
I've read the instructions days ago and finally just quit before I got upset. So I've been learning Javascript from a book that is breaking it down pretty well and I come back here and It makes just as much sense as it did days ago. Which is none. @Pandarati @mjohnstonee
Maximilian Schlosser
@maxschlosser
Jan 18 2016 02:34
help formatting
CamperBot
@camperbot
Jan 18 2016 02:34

: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

Maximilian Schlosser
@maxschlosser
Jan 18 2016 02:34
x)
Michael
@msulock
Jan 18 2016 02:34
thanks @maxschlosser
CamperBot
@camperbot
Jan 18 2016 02:34
bbbeans sends brownie points to @maxschlosser :sparkles: :thumbsup: :sparkles:
:star: 268 | @maxschlosser | http://www.freecodecamp.com/maxschlosser
Michael
@msulock
Jan 18 2016 02:36
function destroyer(arr) {

 function destroy(value){
       return value !== 3 & value !==2;
ooooooo
Aaron Graves
@gravesmeister
Jan 18 2016 02:36
I really think that the way free code camp words some things just doesn't work very well for me so I may have to learn from a different source that makes a lot more sense and then come back and do the waypoints
d wilder
@alhazen1
Jan 18 2016 02:36
@gravesmeister Are you stuck on a particular FCC exercise?
Aaron Graves
@gravesmeister
Jan 18 2016 02:37
Passing Values to Functions with Arguments
@alhazen1 sorry I sometimes forget to tag people in responses
Michael
@msulock
Jan 18 2016 02:38

ok this is for "seek and destroy"

function destroyer(arr) {

 function destroy(value){
       return value !== 3 & value !==2;       
  }  
  return arguments[0].filter(destroy);   
}

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

I would love to be able to have the hard-coded 2 and 3 in the destroy() function be set to argument objects, but that doesn't seem possible

any suggestions?
Maximilian Schlosser
@maxschlosser
Jan 18 2016 02:39
@bbbeans There is a link about Argument objects in the description
Aaron Osteraas
@aosteraas
Jan 18 2016 02:39
this is what i'm currently stuck on as well
Michael
@msulock
Jan 18 2016 02:39
@maxschlosser read that a bunch
Maximilian Schlosser
@maxschlosser
Jan 18 2016 02:39
@bbbeans You can turn the arguments into an array and then iterate over that using a for loop
d wilder
@alhazen1
Jan 18 2016 02:41
// Example
function ourFunction(a, b) {
  console.log(a - b);
}
ourFunction(10, 5); // Outputs 5
This is their example. they wrote a function 'ourFunction' that takes two parameters.
You are calling it with two arguments 10 and 5
@gravesmeister
mokong
@mokong
Jan 18 2016 02:42
I have a problem on chapter "Seek and Destroy"
Aaron Graves
@gravesmeister
Jan 18 2016 02:43
Ok that makes a bit more sense I think. Let me try something
Maximilian Schlosser
@maxschlosser
Jan 18 2016 02:43

@bbbeans

You can refer to a function's arguments within the function by using the arguments object. This object contains an entry for each argument passed to the function, the first entry's index starting at 0.

If you want to refer to the third argument of the function you can access it with arguments[2], as if you were accessing the values of an array.

mokong
@mokong
Jan 18 2016 02:43
how can I send a image?
Screen Shot 2016-01-18 at 10.42.37.png
Maximilian Schlosser
@maxschlosser
Jan 18 2016 02:45
@mokong Try pasting your code between triple backticks, you won't have to link images then.
help formatting
CamperBot
@camperbot
Jan 18 2016 02:45

: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

Aaron Graves
@gravesmeister
Jan 18 2016 02:45
Still don't fully get it though. The second our function is assigning values to the 1st function ourFunction?
Michael
@msulock
Jan 18 2016 02:45
@maxschlosser what is the difference between making the arguments into an array `<var args = Array.prototype.slice.call(arguments);>' and just using the arguments[1] idea?
Aaron Graves
@gravesmeister
Jan 18 2016 02:45
@alhazen1
mokong
@mokong
Jan 18 2016 02:45
I can’t get what it mean, since the function destroyer have a parameter arr, it’s a array,
Michael
@msulock
Jan 18 2016 02:45
<var args = Array.prototype.slice.call(arguments);>
var args = Array.prototype.slice.call(arguments);
mokong
@mokong
Jan 18 2016 02:46
but the call of the func is not an array
Michael
@msulock
Jan 18 2016 02:46
sorry just trying the formatting
gerbermein
@gerbermein
Jan 18 2016 02:46
Hi guys, I'm doing the Palindromes task - I passed it but I'm wondering if there area any other ways to make my code more effective/neater without including multiples of String.replace();
I eliminated part of the code, I hope it still makes sense.
function palindrome(str) {
  str = str.toLowerCase().replace(/,/g, "").replace(".", "").replace(/ /g,"").replace(/_/g, "").replace(/-/g, "").replace("(","").replace(")", "");
}
//Match these as true
//0_0 (: /-\ :) 0-0
//A man, a plan, a canal. Panama
palindrome("0_0 (: /-\ :) 0-0");
Maximilian Schlosser
@maxschlosser
Jan 18 2016 02:47
@bbbeans arguments is not an array. The members can be accessed with indexing and it has the length property, but you can't call any array functions on it, e.g. arguments.map() won't work.
Michael
@msulock
Jan 18 2016 02:47
@maxschlosser thanks! you da man
CamperBot
@camperbot
Jan 18 2016 02:47
bbbeans sends brownie points to @maxschlosser :sparkles: :thumbsup: :sparkles:
:warning: bbbeans already gave maxschlosser points
Michael
@msulock
Jan 18 2016 02:47
doh
Aaron Osteraas
@aosteraas
Jan 18 2016 02:48
I could use a hand on seek and destroy, i'm not sure what to try from here
function destroyer(arr) {
  // convert arguments into array
  var args = Array.prototype.slice.call(arguments);

  // filter through each value in args[0]
  args = args[0].filter(function(val){
    for(var i = 1; i < args.length; i++){
      if(args[i] === val){
        return val;
      }
    }
  });
  return args;
}
d wilder
@alhazen1
Jan 18 2016 02:48
@gravesmeister generally I hate quoting these guys but this is a fairly gentle introduction to the function / parameter concept. http://www.w3schools.com/js/js_functions.asp
Devyn Hedin
@djhedin
Jan 18 2016 02:48
Can anyone help me real quick with regular expressions? I'm sure the answer is obvious but I can't see it.
Maximilian Schlosser
@maxschlosser
Jan 18 2016 02:48
@gerbermein Regex has character classes, for example
/[a-zA-Z/g will match all letters in a String.
Michael
@msulock
Jan 18 2016 02:48
seek and destroy is giving everyone fits ;)
gerbermein
@gerbermein
Jan 18 2016 02:49
@maxschlosser Ah, I see. I'll try googling more on Regex, I'll come back later if I need more help :)
Maximilian Schlosser
@maxschlosser
Jan 18 2016 02:49
@djhedin What is your question?
Aaron Graves
@gravesmeister
Jan 18 2016 02:49
@alhazen1 Their tutorials rarely help me very much but I'll read it. What you showed me earlier makes sense but they way fcc instructs is really difficult for me to understand sometimes what exactly they are looking for. I'll check out the link you posted and see if I can't nail this. I'll be back, thanks
CamperBot
@camperbot
Jan 18 2016 02:49
gravesmeister sends brownie points to @alhazen1 :sparkles: :thumbsup: :sparkles:
:star: 266 | @alhazen1 | http://www.freecodecamp.com/alhazen1
Nafeez Imtiaz
@devNafeez
Jan 18 2016 02:51

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("dog", "big", "ran", "quickly");

This question is confusing to me. Any hints?
this is for "Word Blanks"
Maximilian Schlosser
@maxschlosser
Jan 18 2016 02:52
@devNafeez Build a string from the arguments.
Munish Tayal
@munishtayal
Jan 18 2016 02:52
the solution should be like thi "the big dog ran very quickly" @devNafeez hope u get the hint
Pandarati
@Pandarati
Jan 18 2016 02:52
@devNafeez You're going to be building a string using the arguments you passed. It's like MadLibs. You create a story and where you noun would be you would insert it there and etc
d wilder
@alhazen1
Jan 18 2016 02:54
@aosteraas That challenge was a bear. They suggested using Array.filter() which worked for me. Understanding Array.filter() took some reading though.
Michael
@msulock
Jan 18 2016 02:56
What is the difference between
for( i = 0; i<4; i++)
and
for(var i = 0; i<4; i++)
Thanks!
is there a difference?
Kyle Roach
@iRoachie
Jan 18 2016 02:57
@bbbeans first one doesn’t work. You declare variables with the var keyword
Maximilian Schlosser
@maxschlosser
Jan 18 2016 02:57
@bbbeans The second statement creates a new variable which will then be incremented. If you're using the first one, you need to declare i beforehand.
Aaron Graves
@gravesmeister
Jan 18 2016 02:57
@alhazen1 Well I understand more than I did a week ago but I'm not understanding it fully
Is it bad that Javascript makes me want to punch something?
d wilder
@alhazen1
Jan 18 2016 02:58
@gravesmeister Are you not understanding the concept of function?
Maximilian Schlosser
@maxschlosser
Jan 18 2016 02:58
var i = 0;
for( i = 0; i<4; i++) {
   //your code here
}


for(var i = 0; i < 4; i++){
  //your code here
}
are equivalent. just make sure the first i isn't modified anywhere else in your code.
Aaron Graves
@gravesmeister
Jan 18 2016 02:59
I fully understand function. I'm not understanding how to assign arguments to the parameters I guess.
Michael
@msulock
Jan 18 2016 02:59
i see, this site http://www.w3schools.com/js/js_loop_for.asp has all these for() loops without declaring a variable so I was confused
Aaron Graves
@gravesmeister
Jan 18 2016 02:59
and the whole console.log thing is escaping me also
Kyle Roach
@iRoachie
Jan 18 2016 03:00
@bbbeans It’s because they declared i before
Aaron Graves
@gravesmeister
Jan 18 2016 03:00
Actually the console.log is the action that takes place with the arguments are initiated?
Michael
@msulock
Jan 18 2016 03:00
they must have, but they don't say they did on that page I don't think @iRoachie
Kyle Roach
@iRoachie
Jan 18 2016 03:00
@bbbeans Yea click on the try for yourself
Michael
@msulock
Jan 18 2016 03:00
oh yah
there is it
strange that part isn't included in the first page code block though
@iRoachie thanks
CamperBot
@camperbot
Jan 18 2016 03:01
bbbeans sends brownie points to @iroachie :sparkles: :thumbsup: :sparkles:
:star: 260 | @iroachie | http://www.freecodecamp.com/iroachie
Maximilian Schlosser
@maxschlosser
Jan 18 2016 03:02

@gravesmeister

function myFunc(a, b, c){
 //your code here
}

myFunc(1,2,3,4,5,6);

The values will automatically be assigned to the paramaters in the brackets.

You will be able to access the first three values with a, b and c. To work with the other values passed to the functions you'd have to use the Arguments object which will be introduced later.

d wilder
@alhazen1
Jan 18 2016 03:02
@gravesmeister Ohhhhhhh! Console log is something only sneaky programmers see. It is just a way to print output on webpage behind the scenes into developer tools. Most of the answers in FCC are output to console behind the scenes so the server can check htem. this time we actually explicitly code that.
Aaron Osteraas
@aosteraas
Jan 18 2016 03:02
@alhazen1 perhaps my understanding of array.filter() needs some work, no surprise there haha
d wilder
@alhazen1
Jan 18 2016 03:02
@gravesmeister I would not sweat the console.log thing much for now
Aaron Graves
@gravesmeister
Jan 18 2016 03:03
ok @alhazen1
// Example
function ourFunction(a, b) {
  console.log(a - b);
}
ourFunction(10, 5); // Outputs 5

// Only change code below this line.
function myFunction(a, b) {
  console.log(a - b);
}
myFunction(3, 16);
d wilder
@alhazen1
Jan 18 2016 03:06
@gravesmeister Yep, that looks right to me.
Aaron Graves
@gravesmeister
Jan 18 2016 03:06
It must not be though
myFunction(1,2) should output 3
myFunction(7,9) should output 16
Call myFunction after you define it.
Are all in the red
d wilder
@alhazen1
Jan 18 2016 03:07
@gravesmeister Wait - need to add, not subtract the two arguments
Aaron Graves
@gravesmeister
Jan 18 2016 03:08
The objectives I think are really throwing me off
Chuck Wongus
@YesImChuck
Jan 18 2016 03:10
Hi every one! I am doing the switch statement waypoint. Is there a reason that I am getting an error that says: Unreachable 'break' after 'return'?

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

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

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

Michael
@msulock
Jan 18 2016 03:10

@aosteraas the function that you use with filter() needs to be something that returns "true" for everything you want to include in the filtered array....you don't have that function in your code. see how

function isBigEnough(value) {
  return value >= 10;
}
var filtered = [12, 5, 8, 130, 44].filter(isBigEnough);

uses a function called "isBigEnough"

Aaron Graves
@gravesmeister
Jan 18 2016 03:11
@alhazen1 How do I add the two arguments?
Maximilian Schlosser
@maxschlosser
Jan 18 2016 03:11
@YesImChuck remove the break; statements after your return statements
Darrel Adams
@dadams-510
Jan 18 2016 03:12
Looking up objects using bracket notation is going to be the bane of my existence.
having trouble with "Accessing Object Properties with Variables"
Maximilian Schlosser
@maxschlosser
Jan 18 2016 03:12
@YesImChuck The break statements is used to "break out" of the switch statements block while the return statement will leave the function.
Chuck Wongus
@YesImChuck
Jan 18 2016 03:13
I gotcha
d wilder
@alhazen1
Jan 18 2016 03:13
@aosteraas I went back and looked at your code again. Ithink you are filtering on the wrong array. Probably should filter on arr and inside filter test against each of the args. Those that do not match return 'true' so get included in the new array and those that do match return false and do not get included in a new array. When all is done, return that new array.
Chuck Wongus
@YesImChuck
Jan 18 2016 03:14
Thanks @maxschlosser
CamperBot
@camperbot
Jan 18 2016 03:14
yesimchuck sends brownie points to @maxschlosser :sparkles: :thumbsup: :sparkles:
:star: 271 | @maxschlosser | http://www.freecodecamp.com/maxschlosser
Darrel Adams
@dadams-510
Jan 18 2016 03:14
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj[16];       // Change this Line
var player = "Montana";   // Change this Line
d wilder
@alhazen1
Jan 18 2016 03:14
@gravesmeister
Aaron Graves
@gravesmeister
Jan 18 2016 03:15
Yes
Chuck Wongus
@YesImChuck
Jan 18 2016 03:15
Sorry, @maxschlosser, but the waypoint requires the break;
d wilder
@alhazen1
Jan 18 2016 03:15
This message was deleted
Aaron Graves
@gravesmeister
Jan 18 2016 03:15
I have no idea how to procede
Michael
@msulock
Jan 18 2016 03:16
What's the goal there @dadams-510 ?
Darrel Adams
@dadams-510
Jan 18 2016 03:16
Use the playerNumber variable to lookup player 16 in testObj using bracket notation.
Aaron Osteraas
@aosteraas
Jan 18 2016 03:16
@alhazen1 ahhhhhh i think i get what you're saying, time to tinker some more
Michael
@msulock
Jan 18 2016 03:16
need to "return" something?
Chuck Wongus
@YesImChuck
Jan 18 2016 03:16
Never, figured it out.
Michael
@msulock
Jan 18 2016 03:16
you are just creating a variable
d wilder
@alhazen1
Jan 18 2016 03:16
// Only change code below this line.
function myFunction(a, b) {
  console.log(a + b);
}
myFunction(3, 16);
Just change that - to a +
@gravesmeister
Darrel Adams
@dadams-510
Jan 18 2016 03:17
@bbbeans Instructions don't have a return requirement.
playerNumber should be a number
you should use bracket notation to access testObj.
Michael
@msulock
Jan 18 2016 03:18
need quotes around 16?
Aaron Graves
@gravesmeister
Jan 18 2016 03:18
The instructions talk about how to add arguments to the parameters but not how to add numbers together and then add them to the parameters.
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 03:18
@gravesmeister what exercise are you on?
Aaron Graves
@gravesmeister
Jan 18 2016 03:18
// Example
function ourFunction(a, b) {
  console.log(a - b);
}
ourFunction(10, 5); // Outputs 5

// Only change code below this line.
function myFunction(a, b) {
  console.log(a + b);
}
myFunction(3, 16);
Darrel Adams
@dadams-510
Jan 18 2016 03:18
@bbbeans I'm on Accessing Objects Properties with Variables.
Aaron Graves
@gravesmeister
Jan 18 2016 03:19
It doesn't accept it @alhazen1
@Nyarlat-hotep Passing Values to Functions with Arguments
Nobuyuki Fujioka
@nfabacus
Jan 18 2016 03:20
quick question, please.
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 03:21
so in your code @gravesmeister I dont see you using console.log() for your a and b parameters
Nobuyuki Fujioka
@nfabacus
Jan 18 2016 03:21

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

function checkObj(checkProp) {
if (myObj.hasOwnProperty(checkProp)===true) {
return myObj.checkProp;
} else {

return "Not Found";
}
}

Could you tell me why this is not working?

Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 03:21
it looks like it's commented out @gravesmeister
Aaron Graves
@gravesmeister
Jan 18 2016 03:21
@Nyarlat-hotep Which is weird because It's not
elp1987
@elp1987
Jan 18 2016 03:21
@nfabacus @camperbot explain format
explain format
CamperBot
@camperbot
Jan 18 2016 03:22

: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

Aaron Graves
@gravesmeister
Jan 18 2016 03:22
I think javascript is going to ruin me
Michael
@msulock
Jan 18 2016 03:22
@dadams-510 you know how to use brackets, but not doing what they want
playerNumber just needs to be set to a number, the number of the player you want to access later
Nobuyuki Fujioka
@nfabacus
Jan 18 2016 03:23
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  if (myObj.hasOwnProperty(checkProp)===true) {
    return myObj.checkProp;
  } else {

  return "Not Found";
  }
}
Michael
@msulock
Jan 18 2016 03:23
then use the object playerNumber instead of the actual number to grab the right guy from testObj
d wilder
@alhazen1
Jan 18 2016 03:23
@gravesmeister Maybe save your work onto a doc somewhere and refresh / reset the screen?? that looks exactly like mine and it worked.
Maximilian Schlosser
@maxschlosser
Jan 18 2016 03:23
@YesImChuck try assigning the result to a string and then returning it at the end of the function
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 03:24
@nfabacus you don't need ===true. That will happen anyways. Also return this
Aaron Graves
@gravesmeister
Jan 18 2016 03:24
@alhazen1 with the a + b in the console log?
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 03:24
    return myObj[(checkProp)];
@nfabacus
Nobuyuki Fujioka
@nfabacus
Jan 18 2016 03:24
ok, but why? normally, I can call object with .property?
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 03:25
I can't say why
Aaron Graves
@gravesmeister
Jan 18 2016 03:25
I'll be back
@alhazen1 Thanks. I just refreshed chrome and it accepted it.
CamperBot
@camperbot
Jan 18 2016 03:26
gravesmeister sends brownie points to @alhazen1 :sparkles: :thumbsup: :sparkles:
Michael
@msulock
Jan 18 2016 03:26
@dadams-510, the goal is to set the variable player to the right name without using a number, instead calling the playerNumber object that you set to that number
CamperBot
@camperbot
Jan 18 2016 03:26
:warning: gravesmeister already gave alhazen1 points
Aaron Graves
@gravesmeister
Jan 18 2016 03:26
Ok I'm going to try the next lesson. Thanks guys
Maximilian Schlosser
@maxschlosser
Jan 18 2016 03:26
@nfabacus if i'm not mistaken .property is "static", ie can't be changed while the script is running, while [property] is dynamic and will be replaced with the correct value
d wilder
@alhazen1
Jan 18 2016 03:27
@gravesmeister yes, should add. Exactly as the example except addition not subtraction
elp1987
@elp1987
Jan 18 2016 03:27

@gravesmeister
in ourFunction(a, b) there are two parameters; a and b are parameters and could take 'anything'
when a and b take specific values, then that's what you call arguments

in that exercise, for examples, you are defining ourFunction as subtracting two objects, it should look like this

function ourFunction(a, b){
    a - b;
   console.log( a - b);
return a - b
}
Nyarlat-hotep
@Nyarlat-hotep
Jan 18 2016 03:27
has anyone completed profile lookup exercise?
Darrel Adams
@dadams-510
Jan 18 2016 03:27
@bbbeans So... would it be like this?
var playerNumber = testObj[16]; 
var player = playerNumber;
Michael
@msulock
Jan 18 2016 03:27
easier
playerNumber just needs to be set to a number
first and foremost
Maximilian Schlosser
@maxschlosser
Jan 18 2016 03:27

@elp1987

function ourFunction(a,b){
   return a-b;
}

should work

Darrel Adams
@dadams-510
Jan 18 2016 03:28
@bbbeans I got it now.
Michael
@msulock
Jan 18 2016 03:28
testObj[16] accesses the name "Montana"
Nobuyuki Fujioka
@nfabacus
Jan 18 2016 03:28
ok...
elp1987
@elp1987
Jan 18 2016 03:28
@maxschlosser agree
d wilder
@alhazen1
Jan 18 2016 03:28
@gravesmeister Bummer! That was a tough lesson to learn but sometimes the tutorial just quits working. Refresh usually fixes it but sometimes you have to reset the lesson which erases all your code
Michael
@msulock
Jan 18 2016 03:28
they want you to do that without actually having to use the number 16
Nobuyuki Fujioka
@nfabacus
Jan 18 2016 03:29
interesting.
this works though.
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

alert(myObj.gift);
Darrel Adams
@dadams-510
Jan 18 2016 03:29
@bbbeans
var playerNumber = 16;
var player = testObj[playerNumber];
makes sense. Thanks! @bbbeans
CamperBot
@camperbot
Jan 18 2016 03:29
dadams-510 sends brownie points to @bbbeans :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for bbbeans
Michael
@msulock
Jan 18 2016 03:30
some of those challenges it is just hard to figure out what they want, even when you understand how the code works
Maximilian Schlosser
@maxschlosser
Jan 18 2016 03:30
@nfabacus Yes, because the property gift exists.
var prop = "gift";
var myObj = {
  gift: "pony"
};

alert(myObj.prop);
//shouldn't work

alert(myObj[prop]);
//should work, parentheses around prop might be missing
@nfabacus [prop] will be replaced with ["gift"] when the script runs
Darrel Adams
@dadams-510
Jan 18 2016 03:32
@bbbeans The this waypoint needs some love
Christian Garza
@C-Garza
Jan 18 2016 03:32

I don't
<var Bike = function() {

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

woops
This is make object properties private, and it passes all the tests except the last one myBike.getGear(4). It keeps outputting 2, which I don't even know where that comes from. Could someone help me pls? =P
var Bike = function() {

  // Only change code below this line.
  var gear = 10;
  this.getGear = function () {
    return getGear;
  };
  this.setGear = function() {
    return setGear;
  };
};
Maximilian Schlosser
@maxschlosser
Jan 18 2016 03:39
@C-Garza You are neither returning the gear not setting it. getGear should return the value of gear while setGear should be used to change it.
Rena
@rsugihara
Jan 18 2016 03:39
I need help with "Testing Objects for Properties"! I'm really confused with how to execute return from true/false.
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

}

// Test your code by modifying these values
checkObj("gift");
Maximilian Schlosser
@maxschlosser
Jan 18 2016 03:40
@rsugihara change myObj.prop; to myObj[prop] . You need to pass a property name to myObj.hasOwnProperty instead of an empty string
Michael
@msulock
Jan 18 2016 03:43
function destroyer(arr) {


  var args = Array.prototype.slice.call(arguments);  

 function destroy(value){
          for(var i = 1; i < args.length; i++)
         return value !== args[i];  

  }  

  return args[0].filter(destroy);  

}
This doesn't filter out multiple arguments like I want it to
:(
i think it is an issue with the return statement in the for() loop
Christian Garza
@C-Garza
Jan 18 2016 03:45
@maxschlosser I got it now, thank you!
CamperBot
@camperbot
Jan 18 2016 03:45
c-garza sends brownie points to @maxschlosser :sparkles: :thumbsup: :sparkles:
:star: 272 | @maxschlosser | http://www.freecodecamp.com/maxschlosser
Maximilian Schlosser
@maxschlosser
Jan 18 2016 03:46
@bbbeans try putting the statement after the for oop in { }
Michael
@msulock
Jan 18 2016 03:47
yeah i tried that, no dice
barf
Maximilian Schlosser
@maxschlosser
Jan 18 2016 03:48
@bbbeans try using an anonymous function, that worked for me
arr[0] = arr[0].filter(
      function(val) {
        return val != arr[i];
      });
Vignesh
@vignesh12187
Jan 18 2016 03:49
Accessing Objects Properties with Variables
var playerNumber = 16; // Change this Line
var player = testObj[16];
can somone help me this
Michael
@msulock
Jan 18 2016 03:50
@maxschlosser are you using [i] without a loop? looks like i need to read about anonymous functions maybe
Maximilian Schlosser
@maxschlosser
Jan 18 2016 03:50
@bbbeans i sent you a private message with the correct version x)
Michael
@msulock
Jan 18 2016 03:53
lord I have no idea why yours works and mine doesn't. thanks for your help @maxschlosser
CamperBot
@camperbot
Jan 18 2016 03:53
bbbeans sends brownie points to @maxschlosser :sparkles: :thumbsup: :sparkles:
:star: 274 | @maxschlosser | http://www.freecodecamp.com/maxschlosser
Michael
@msulock
Jan 18 2016 03:53
still want mine to work!
Rena
@rsugihara
Jan 18 2016 03:53
@maxschlosser I just tried with myObj[checkProp] since prop is not defined. Now the code only works when I pass a specific property name that exists or when I pass one that doesn't, but not both if that makes sense.
Michael
@msulock
Jan 18 2016 03:53
not sure why you need to put filter() inside the loop
Pandarati
@Pandarati
Jan 18 2016 03:54
Can someone explain "Arguments Optional"? The function thing is very confusing.
Maximilian Schlosser
@maxschlosser
Jan 18 2016 03:55
@bbbeans filter returns an array. I am applying a different filter each time the loop is called while you want all filters to work at the same time
Michael
@msulock
Jan 18 2016 03:59
that makes sense. thanks again @maxschlosser
CamperBot
@camperbot
Jan 18 2016 03:59
bbbeans sends brownie points to @maxschlosser :sparkles: :thumbsup: :sparkles:
:warning: bbbeans already gave maxschlosser points
Maximilian Schlosser
@maxschlosser
Jan 18 2016 03:59

@bbbeans i found you problem i think.

for(var i = 1; i < 10; i++){
  return i;
}

Will leave the function as soon as it encounters return;i and don't finish the loop. (i.e. return 1)

You need to use an if-clause like

for(var i = 1; i < args.length; i++){
   if(val == arr[i]){
     return true;
   }
}
return false; //note that return false is outside of the for loop.

which will return true only if val equals arr[i], if val equals none of the values the function returns false

Michael
@msulock
Jan 18 2016 04:00
function destroyer(arr) {


  var args = Array.prototype.slice.call(arguments);  
  var i=0;

  for(var i = 1; i < args.length; i++){
     function destroy(value){
         return value != args[i];  
            }   
  args[0]= args[0].filter(destroy);  
}
return args[0];
}
not as clean as yours, but it worked
basically is yours, just not as concise
d wilder
@alhazen1
Jan 18 2016 04:01
@bbbeans I think it how / when your return statement is called in that loop. It returns on every iteration but so only iterates once. Try testing for a false condition before your return, then if you have looped through all possibilities return true
@bbbeans I guess I was wrong!
Aaron Graves
@gravesmeister
Jan 18 2016 04:11
Can anyone help me with "Stand in line?"
Rena
@rsugihara
Jan 18 2016 04:12
@gravesmeister I may be able to. I just did it a couple of days ago!
Aaron Graves
@gravesmeister
Jan 18 2016 04:12
@rsugihara Ok Great. I just don't really understand what to do after the first objective. I'm only guessing at this point and my guessing is getting me nowhere
Rena
@rsugihara
Jan 18 2016 04:14
@gravesmeister Show me what you have so far?
Aaron Graves
@gravesmeister
Jan 18 2016 04:15
Hold on. I have to redo it. I was getting frustrated and reset the code
function queue([2], 1) {
  // Your code here

  return item;  // Change this line
}

// Test Setup
var testArr = [5,6,7,8,9];

// 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'm not very far because I don't really even understand what I'm doing other than following the bouncing ball
Maximilian Schlosser
@maxschlosser
Jan 18 2016 04:16
@gravesmeister
function queue(arr, item) {
  // Your code here

}
you need that structure
Aaron Graves
@gravesmeister
Jan 18 2016 04:17
ok
Maximilian Schlosser
@maxschlosser
Jan 18 2016 04:17
@gravesmeister Do you know how a function call works?
Aaron Graves
@gravesmeister
Jan 18 2016 04:18
I'm getting there
Andrew Bales
@agbales
Jan 18 2016 04:18
Working on search & replace. This works when it's not trying to adapt for case variations...
function myReplace(str, before, after) {

 var newWord = '';

 if (before === before.toTitleCase()) {
   newWord = after.charAt(0).toTitleCase();
 } else if (before === before.toLowerCase()) {
   newWord = after.charAt(0).toLowerCase()
 }

  var updatedString = str.replace(before, newWord);

  return updatedString;
}

myReplace("A quick brown fox Jumped over the lazy dog", "Jumped", "leaped");
Rena
@rsugihara
Jan 18 2016 04:19
@gravesmeister First you need to "push" the item to the array, which adds the item at the end of the array. Then you "shift" the array, which removes the first number off the array.
Now you want that removed number to be "return"ed. The code for this exercise is actually a lot simpler than you might be thinking.
Maximilian Schlosser
@maxschlosser
Jan 18 2016 04:21
@gravesmeister Do you have any programming experience?
Aaron Graves
@gravesmeister
Jan 18 2016 04:22
It always is because half the time I don't get it.
No
@maxschlosser None
Dylan Pagillo
@DylanNeil
Jan 18 2016 04:24
Return Early Pattern for Functions: having a really hard time with this one
Rena
@rsugihara
Jan 18 2016 04:25
@gravesmeister Do you recall how push and shift work?
Aaron Graves
@gravesmeister
Jan 18 2016 04:25
Barely. I might have to go refresh @rsugihara
Do most people have programming experience when they start FCC? @maxschlosser
Rena
@rsugihara
Jan 18 2016 04:27
@gravesmeister Yes go ahead and do that, it'll help a lot! There's a few sections for them under "manipulating arrays with".
Kyle Roach
@iRoachie
Jan 18 2016 04:27
@rsugihara Push adds an item to the end of an array. Shift removes the first item
Aaron Graves
@gravesmeister
Jan 18 2016 04:27
Ok thanks @rsugihara
CamperBot
@camperbot
Jan 18 2016 04:27
gravesmeister sends brownie points to @rsugihara :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for rsugihara
Maximilian Schlosser
@maxschlosser
Jan 18 2016 04:27

@gravesmeister Ok. I'll try to explain what the script is doing in the background when you call a function and keep it simple, I'm studying IT though so tell me if it's too complicated.

function myFunc(a, b){
   b = a + b; 
   return b; //returns b
}

c = myFunc(1, 2);  
/*Anytime you call the function, the parameter list of your call will be compared to the parameter list of the function and the values will be assigned in the correct order. This means the a in myFunc is now 1, the b in myFunc is now 2. Therefore c has the value 3.*/

The push function takes an element and "pushes" (appends) it to the back of an array without changing the index.
The shift function returns the first element of an array, deletes it and then shifts the arrays contents one towards the zero index.

@gravesmeister I don't know, i just started yesterday x) I'm progressing really fast because I know most of this stuff already
Aaron Graves
@gravesmeister
Jan 18 2016 04:30
@maxschlosser Yeah well this is my second time through the Javascript part. I'm wondering if I don't need to go through it a third time. Just keep doing it until it all sticks. I got through HTML, CSS and Bootstrap really fast because it actually made sense. This feels like I'm learning chinese.
Ch.Rama Krishna
@ramakrishnach14
Jan 18 2016 04:31
hello everybody can you help me out in this profile lookup challenge and my code is

//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
var checkloop,checkprop;

checkprop=contacts.hasOwnProperty(prop);
for(i=0; i<contacts.length ; i++) {
if(contacts[i][name]==firstName){
checkloop = i;
}
}
if(contacts[checkloop][firstName]==firstName) {
if(checkprop === true){
return contacts[checkloop][prop];
} else {
return "No such contact";
}
} else {
return "No such Property";
}
// Only change code above this line
}

// Change these values to test your function
lookUp("Kristian", "lastName");

d wilder
@alhazen1
Jan 18 2016 04:36
This message was deleted
TuanTM
@TuanTM93
Jan 18 2016 04:37
i can fix help me bug:
function lookUp(firstName, prop){
// Only change code below this line
for(var i = 0; i<contacts.length; i++){
var firstNa = contacts[i].firstName;
var propNa = contacts[i].hasOwnProperty(prop);
console.log("FirstName:"+firstNa);
if(propNa === true){
// console.log("property:"+ )
if(firstName !== firstNa){
console.log("A dung roi");
console.log("Dau xanh:"+ contacts[i][prop]);
return contacts[i][prop];
}else{
console.log("sai firstName");
return "No such contact";
}
}else{
console.log("sai property");
return "No such property";
}
}
// Only change code above this line
}
d wilder
@alhazen1
Jan 18 2016 04:38
This message was deleted
Maximilian Schlosser
@maxschlosser
Jan 18 2016 04:39
@gravesmeister I recommend looking for a book or a tutorial intended for beginners at coding if you have problems understanding function calls, return values and parameters. Imo, it is not intended to learn everything using only this page, since the tutorials are too short and don't explain much. The challenges are a great way to keep track of your progress though.
d wilder
@alhazen1
Jan 18 2016 04:39
This message was deleted
Maximilian Schlosser
@maxschlosser
Jan 18 2016 04:39
help formatting
CamperBot
@camperbot
Jan 18 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

Andrew Bales
@agbales
Jan 18 2016 04:41
Figured it out (search & replace)! In case you're wondering, one way to do this is by comparing the first character with a .toUpperCase() version.
Raymond To
@rayto510
Jan 18 2016 04:43
function factorialize(num) {
  if (num === 0) {
    return num == 1;
  }
  else {
    var i = 1;
    while (i < num) {
    num = num * (num - i);
      i++;
    }
  }
  return num;
}

factorialize(5);
help please!
CamperBot
@camperbot
Jan 18 2016 04:43

:point_right: bonfire no repeats please [wiki]

Problem Explanation:

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

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

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

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

TuanTM
@TuanTM93
Jan 18 2016 04:43
who cant view problem me, if(firstNa === firstName) not activity:
function lookUp(firstName, prop){
// Only change code below this line
for(var i = 0; i<contacts.length; i++){
var firstNa = contacts[i].firstName;
var propNa = contacts[i].hasOwnProperty(prop);
console.log("FirstName:"+firstNa);
if(propNa === true){
// console.log("property:"+ )
if(firstName === firstNa){
// console.log("A dung roi");
console.log("Correct:"+ contacts[i][prop]);
return contacts[i][prop];
}else{
console.log("wrong firstName");
return "No such contact";
}
}else{
console.log("wrong property");
return "No such property";
}
}
// Only change code above this line
}
Maximilian Schlosser
@maxschlosser
Jan 18 2016 04:43
@rayto510 What happens in the line num = num * (num - i);
Raymond To
@rayto510
Jan 18 2016 04:44
@maxschlosser num gets assigned to the current number times the number less than 1
Kyle Roach
@iRoachie
Jan 18 2016 04:45
@rayto510 Hey ray you need to have a variable to keep track of when you multiply
This message was deleted
Raymond To
@rayto510
Jan 18 2016 04:46
@iRoachie Why?
Maximilian Schlosser
@maxschlosser
Jan 18 2016 04:46
@rayto510 What happens when you reassign num and then multiply with it again?
Kyle Roach
@iRoachie
Jan 18 2016 04:47
@rayto510
function factorialize(num) {
  var result = 1;
  for(var i = 1; i <= num; i++) {
    bum *= i;
  }

  return result;
}

factorialize(5);
Raymond To
@rayto510
Jan 18 2016 04:47
@maxschlosser Ohhh. It gets multiplied by the number that was last assigned.
Maximilian Schlosser
@maxschlosser
Jan 18 2016 04:48
@rayto510 :wink:
TuanTM
@TuanTM93
Jan 18 2016 04:48
who can see my problem, first condition if not activity:
function lookUp(firstName, prop){
// Only change code below this line
for(var i = 0; i<contacts.length; i++){
var firstNa = contacts[i].firstName;
var propNa = contacts[i].hasOwnProperty(prop);
console.log("FirstName:"+firstNa);
if(propNa === true){
// console.log("property:"+ )
if(firstName === firstNa){
// console.log("A dung roi");
console.log("Correct:"+ contacts[i][prop]);
return contacts[i][prop];
}else{
console.log("wrong firstName");
return "No such contact";
}
}else{
console.log("wrong property");
return "No such property";
}
}
// Only change code above this line
}
Maximilian Schlosser
@maxschlosser
Jan 18 2016 04:49
@TuanTM93 Hey Tuan, try formatting your code using triple backticks so it's readable.
help formatting
CamperBot
@camperbot
Jan 18 2016 04:49

: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

Ch.Rama Krishna
@ramakrishnach14
Jan 18 2016 04:51

`//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
var checkloop,checkprop;

checkprop=contacts.hasOwnProperty(prop);
for(i=0; i<contacts.length ; i++) {
if(contacts[i][firstName]===firstName){
checkloop = i;
}
}
if(contacts[checkloop][firstName]==firstName) {
if(checkprop === true){
return contacts[checkloop][prop];
} else {
return "No such contact";
}
} else {
return "No such Property";
}
// Only change code above this line
}

// Change these values to test your function
lookUp("Sherlock", "likes");`

Kyle Roach
@iRoachie
Jan 18 2016 04:51
@ramakrishnach14 Please format code so we can see
help formatting
CamperBot
@camperbot
Jan 18 2016 04:51

: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

Fritzgerald Simon
@fsimon1
Jan 18 2016 04:53
// 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);
can anyone help with this?
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
TuanTM
@TuanTM93
Jan 18 2016 04:53
This message was deleted
Fritzgerald Simon
@fsimon1
Jan 18 2016 04:53
these are the instructions and my code so far
Kyle Roach
@iRoachie
Jan 18 2016 04:53
@fsimon1 Hey just change your line to return;
Maximilian Schlosser
@maxschlosser
Jan 18 2016 04:53
@fsimon1 undefined isn't a string
Fritzgerald Simon
@fsimon1
Jan 18 2016 04:54
ahh gotcha thanks!
TuanTM
@TuanTM93
Jan 18 2016 04:54
This message was deleted
Maximilian Schlosser
@maxschlosser
Jan 18 2016 04:54
``
Alain Holly
@aholly38
Jan 18 2016 05:03
Im struggling here any guidance will help

var count = 0;

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

switch (card) {

case 2:
case 3:
case 4:
case 5:
case 6:
  count = 5;
  card = " Bet";
  break;

case 7:
case 8:
case 9:
  count = 0;
  card = " Hold";
  break;

case 10:
case "J":
case "Q":
case "K":
case "A":
  count = -5;
  card = " Hold";
  break; 

case 3:
case 2:
case"A":
case 10:
case "K":
  count = -1;
  card = " Hold";

}

return count + card;
// Only change code above this line
}

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

I get an out of -5 Bet
Jordi Vilagut Treserra
@jordivilagut
Jan 18 2016 05:05
Hi! I need very quick help, how would you compare to non-alphanumeric elements in an "IF" statement?
'''jsif(str[i]!=' ')
CamperBot
@camperbot
Jan 18 2016 05:05
:bulb: to format code use backticks! ``` more info
Jordi Vilagut Treserra
@jordivilagut
Jan 18 2016 05:05
'''if(str[i]!=' ')
CamperBot
@camperbot
Jan 18 2016 05:05
:bulb: to format code use backticks! ``` more info
Jordi Vilagut Treserra
@jordivilagut
Jan 18 2016 05:05
```jsif(str[i]!=' ')
```if(str[i]!=' ')
```js
````
Kyle Roach
@iRoachie
Jan 18 2016 05:06
@aholly38 hey can you paste your url so we can see instructions
Jordi Vilagut Treserra
@jordivilagut
Jan 18 2016 05:06
```js
```jsif(str[i]!=' ')'''
CamperBot
@camperbot
Jan 18 2016 05:06
:bulb: to format code use backticks! ``` more info
Alain Holly
@aholly38
Jan 18 2016 05:06
ok
Jordi Vilagut Treserra
@jordivilagut
Jan 18 2016 05:06
jsif(str[i]!=' ')
oh god...
Alain Holly
@aholly38
Jan 18 2016 05:07
http://www.freecodecamp.com/challenges/counting-cards#?solution=var%20count%20%3D%200%3B%0A%0Afunction%20cc(card)%20%7B%0A%20%20%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20%20var%20count%20%3D%200%3B%0A%20%20%0A%20%20switch%20(card)%20%7B%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20case%202%3A%0A%20%20%20%20case%203%3A%0A%20%20%20%20case%204%3A%0A%20%20%20%20case%205%3A%0A%20%20%20%20case%206%3A%0A%20%20%20%20%20%20count%20%3D%205%3B%0A%20%20%20%20%20%20card%20%3D%20%22%20Bet%22%3B%0A%20%20%20%20%20%20break%3B%0A%20%20%20%20%0A%20%20%20%20case%207%3A%0A%20%20%20%20case%208%3A%0A%20%20%20%20case%209%3A%0A%20%20%20%20%20%20count%20%3D%200%3B%0A%20%20%20%20%20%20card%20%3D%20%22%20Hold%22%3B%0A%20%20%20%20%20%20break%3B%0A%20%20%20%20%20%20%0A%20%20%20%20case%2010%3A%0A%20%20%20%20case%20%22J%22%3A%0A%20%20%20%20case%20%22Q%22%3A%0A%20%20%20%20case%20%22K%22%3A%0A%20%20%20%20case%20%22A%22%3A%0A%20%20%20%20%20%20count%20%3D%20-5%3B%0A%20%20%20%20%20%20card%20%3D%20%22%20Hold%22%3B%0A%20%20%20%20%20%20break%3B%20%0A%20%20%20%20%20%20%0A%20%20%20%20case%203%3A%0A%20%20%20%20case%202%3A%0A%20%20%20%20case%22A%22%3A%0A%20%20%20%20case%2010%3A%0A%20%20%20%20case%20%22K%22%3A%0A%20%20%20%20%20%20count%20%3D%20-1%3B%0A%20%20%20%20%20%20card%20%3D%20%22%20Hold%22%3B%0A%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%0A%20%20%20%0A%20%20%7D%0A%20%20%0A%20%20%0A%20%20return%20count%20%2B%20card%3B%0A%20%20%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Add%2Fremove%20calls%20to%20test%20your%20function.%0A%2F%2F%20Note%3A%20Only%20the%20last%20will%20display%0Acc(3)%3B%20cc(2)%3B%20cc(%22A%22)%3B%20cc(10)%3B%20cc(%22K%22)%3B%0A%0A
Jordi Vilagut Treserra
@jordivilagut
Jan 18 2016 05:07

```if(str[i]!=' '){

  if (str[i].charCodeAt(0)-13<65){
  str[i]=str[i].charCodeAt(0)+13;}

  else{str[i]=str[i].charCodeAt(0)-13;}}

else{}

i++;

}```

```if(str[i]!=' '){

  if (str[i].charCodeAt(0)-13<65){
  str[i]=str[i].charCodeAt(0)+13;}

  else{str[i]=str[i].charCodeAt(0)-13;}}

else{}

i++;

}

explain format
CamperBot
@camperbot
Jan 18 2016 05:07

: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 18 2016 05:08
@aholly38 If I remember correctly you want to increment those counts whenever the cards in range are counted. count ++ or count-- and use the total to decide when to bet.
Kyle Roach
@iRoachie
Jan 18 2016 05:08
@aholly38 hey you’re not actually modifying the count correctly. You’re suppose to increment using count++ and decrement using count—
Jordi Vilagut Treserra
@jordivilagut
Jan 18 2016 05:09
```
if(str[i]!=' '){

      if (str[i].charCodeAt(0)-13<65){
      str[i]=str[i].charCodeAt(0)+13;}

      else{str[i]=str[i].charCodeAt(0)-13;}}

    else{}

    i++;
  }
Alain Holly
@aholly38
Jan 18 2016 05:10
let me try that
Jordi Vilagut Treserra
@jordivilagut
Jan 18 2016 05:10
alright, i need help to change the if statement, i want to avoid processing ALL non-alphanumerical elements
Kyle Roach
@iRoachie
Jan 18 2016 05:10
@bcnjordi9 which challenge are you doing this for?
Jordi Vilagut Treserra
@jordivilagut
Jan 18 2016 05:11
now it's only space, i need to sort out also points, exclamation marks, etc
i am doing this for the caesar's cipher challenge
@iRoachie
Kyle Roach
@iRoachie
Jan 18 2016 05:12
@aholly38
switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      break;
    case 7:
    case 8:
    case 9:
      count = 0;
      break;

    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count--;
      break; 
  }

  if(count > 0) {
    return count + " Bet";
  } else {
    return count + " Hold";
  }
Jordi Vilagut Treserra
@jordivilagut
Jan 18 2016 05:12
i tried also this:
Kyle Roach
@iRoachie
Jan 18 2016 05:12
@bcnjordi9 Sorry mate haven’t reached there yet
Jordi Vilagut Treserra
@jordivilagut
Jan 18 2016 05:12
if(str[i]!="[^a-zA-Z0-9]"){

      if (str[i].charCodeAt(0)-13<65){
      str[i]=str[i].charCodeAt(0)+13;}

      else{str[i]=str[i].charCodeAt(0)-13;}}

    else{}

    i++;
  }
but it's not working
alright let's see if anyone else knows
my problem is just i dont know how to declare this; IF "Element to Compare" is "NON-ALPHANUMERICAL" DO ---> SOMETHING
d wilder
@alhazen1
Jan 18 2016 05:17
@bcnjordi9 try the string.match() function!
if(str[i].match([^a-zA-Z0-9])){
I don't know enough to tell if your regexpression is right or not
Chuck Wongus
@YesImChuck
Jan 18 2016 05:19
Hello everyone. I am trying to make secondTree = "pine". I'm not sure what is wrong with my dot notation. Could someone help?

// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];

// Only change code below this line

var secondTree = myPlants.trees1; // Change this line

Alain Holly
@aholly38
Jan 18 2016 05:19
This message was deleted
This message was deleted
Kyle Roach
@iRoachie
Jan 18 2016 05:21
@YesImChuck You need to access the list property
myPlants[1].list[1]
Chuck Wongus
@YesImChuck
Jan 18 2016 05:21
Ohhhhh!!! Thanks @iRoachie
CamperBot
@camperbot
Jan 18 2016 05:21
yesimchuck sends brownie points to @iroachie :sparkles: :thumbsup: :sparkles:
:star: 286 | @iroachie | http://www.freecodecamp.com/iroachie
xgumball
@xgumball
Jan 18 2016 05:23

// Setup
var processed = 0;

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

// Only change code below this line
process(7);
processed = 2;
var process = processed;

i need help
Jordi Vilagut Treserra
@jordivilagut
Jan 18 2016 05:23
thanks @alhazen1 but yes, the problem I have is that I can't figure out the right RegEx
CamperBot
@camperbot
Jan 18 2016 05:23
bcnjordi9 sends brownie points to @alhazen1 :sparkles: :thumbsup: :sparkles:
:star: 268 | @alhazen1 | http://www.freecodecamp.com/alhazen1
d wilder
@alhazen1
Jan 18 2016 05:26
@bcnjordi9 This is what I used
if(str[i].match(/[A-Z]/)){
The problem stated only caps (but I converted all to upper anyways) so anything that was not a letter got passed without changing, anything that was a letter got decoded
Alain Holly
@aholly38
Jan 18 2016 05:27

@iRoachie

I've tried this and doesn't give me the right output for (2,3,4,5,6) which equals "5 Bet"


var count = 0;

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

  switch (card) {


    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      break;

    case 7:
    case 8:
    case 9:
      count = 0;
      break;

    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count--;
      break; 

    case 3:
    case 2:
    case"A":
    case 10:
    case "K":
      count--;
      card = " Hold";



  }

  if (count > 0){

    return count + " Bet";

  }else{

    return count + " Hold";
  }

  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(10); cc("J"); cc("Q"); cc("K"); cc("A");
Kyle Roach
@iRoachie
Jan 18 2016 05:28
@aholly38 Its cause you’re creating another count variable
@aholly38 remove the var count = 0; inside the function
xgumball
@xgumball
Jan 18 2016 05:28
i need help guys
Alain Holly
@aholly38
Jan 18 2016 05:28
I know because the first declared 'var count' won't be seen inside the function
'
d wilder
@alhazen1
Jan 18 2016 05:29
@aholly38
    case 7:
    case 8:
    case 9:
      count = 0; //this looks wrong - sets count back to zero
      break;
xgumball
@xgumball
Jan 18 2016 05:29
i need to assign process to processed ?? how do i do that
Kyle Roach
@iRoachie
Jan 18 2016 05:29
@aholly38 Yes it will. The first count is declared globally
Alain Holly
@aholly38
Jan 18 2016 05:29
@iRoachie
@iRoachie
Jordi Vilagut Treserra
@jordivilagut
Jan 18 2016 05:31
and if(str[i].match(/[A-Z]/)){ works for you @alhazen1, because if I try it it gives me Type Error: 'str[i].match is not a function
d wilder
@alhazen1
Jan 18 2016 05:32
@aholly38
also this block of code looks like a random repeat of above code
//maybe left over from earlier work?
    case 3:
    case 2:
    case"A":
    case 10:
    case "K":
      count--;
      card = " Hold";
Alain Holly
@aholly38
Jan 18 2016 05:32
@iRoachie Thanks, I was confused because the variable "count" declared outside the "function cc()" I thought would not be seen.
CamperBot
@camperbot
Jan 18 2016 05:32
aholly38 sends brownie points to @iroachie :sparkles: :thumbsup: :sparkles:
:star: 289 | @iroachie | http://www.freecodecamp.com/iroachie
Alain Holly
@aholly38
Jan 18 2016 05:32
thanks everyone
Kyle Roach
@iRoachie
Jan 18 2016 05:33
@aholly38 All right man. Remember variables declared outside functions are available everywhere, theyre called global variables
Jordi Vilagut Treserra
@jordivilagut
Jan 18 2016 05:33
of course I can always do that:
if(str[i]!=" " && str[i]!="!"&& str[i]!="?"&& str[i]!="."){

      if (str[i].charCodeAt(0)-13<65){
      str[i]=str[i].charCodeAt(0)+13;}

      else{str[i]=str[i].charCodeAt(0)-13;}}

    else{}
this works, but it's not clean, I'd like the correct substitution for
if(str[i]!=" " && str[i]!="!"&& str[i]!="?"&& str[i]!="."){
a clean expression...
d wilder
@alhazen1
Jan 18 2016 05:35

@bcnjordi9 Yes, I just checked. That was the test I used for 'is it a letter'

and if(str[i].match(/[A-Z]/)){ works for you @alhazen1, because if I try it it gives me Type Error: 'str[i].match is not a function

@bcnjordi9 I didn't see this earlier too. Part of the problem I think is you are putting decoded letters into the coded string. You should probably create a tempString to hold the decoded text and return that when done.
d wilder
@alhazen1
Jan 18 2016 05:40
@bcnjordi9 like...
tempStr += str[i].charCodeAt(0)+13;
Christopher Ngo
@ingochris
Jan 18 2016 05:42
Hey guys!
How's it going?
Calvoxel
@Calvoxel
Jan 18 2016 05:46

Hello, guys, I'm working on "Accessing Objects Properties with Variables", and it requires me to use the playerNumber variable to look up player 16 in testObj using bracket notation. I understand the 2nd half (setting the variable "player"), but I don't understand how to set playerNumber. This is the code: // Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

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

any help?

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

// Only change code below this line;

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

Kyle Roach
@iRoachie
Jan 18 2016 05:50
@Calvoxel It wants you to return the name of the player with a number of 16
Since 16 is a key
we can use bracket notation to get that player
var player = testObj[playerNumber];
Calvoxel
@Calvoxel
Jan 18 2016 05:52
Nope, doesn't work @iRoachie
oh wait
nvm lol I'm smart
I got it, thanks!
Kyle Roach
@iRoachie
Jan 18 2016 05:53
Lol. :)
Irving Gonzalez
@irvgonz
Jan 18 2016 05:59
find JSON
Christopher Ngo
@ingochris
Jan 18 2016 06:00
lol
Irving Gonzalez
@irvgonz
Jan 18 2016 06:01
find object notation
CamperBot
@camperbot
Jan 18 2016 06:01
angelbenoit
@angelbenoit
Jan 18 2016 06:02
how do you get better at algorithms? i keep getting stuck
Kyle Roach
@iRoachie
Jan 18 2016 06:06
Practice!
Sometimes helps to do it on paper
fluffystub
@RakshithNM
Jan 18 2016 06:07
help Accessing Objects Properties with Variables
CamperBot
@camperbot
Jan 18 2016 06:07
no wiki entry for: accessing objects properties with variables
Irving Gonzalez
@irvgonz
Jan 18 2016 06:07

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

shift.myMusic.artist = "Pikachu"; // Add record here
shift.myMusic.tittle = "Electrocute you";
shift.myMusic.release_year = 1998;
shift.myMusic.format = ["cs", "8t", "idk"];

var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1993,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
];

shift.myMusic.artist = "Pikachu"; // Add record here
shift.myMusic.tittle = "Electrocute you";
myMusic.release_year = 1998;
myMusic.format = ["cs", "8t", "idk"];

im having some tech difficulties :worried: :laughing:
fluffystub
@RakshithNM
Jan 18 2016 06:09
help objects
CamperBot
@camperbot
Jan 18 2016 06:09

:point_right: waypoint accessing nested objects in json [wiki]

Waypoint: Accessing Nested Objects in JSON

The properties and sub-properties of JSON objects can be accessed by chaining together the dot or bracket notation.

Here is a nested JSON Object:

```js
var ourStorage = {
"desk": {
"drawer": "stapler"
},
"cabinet": {
"top drawer": {
"folder1": "a file",
"folder2": "secrets"
},
"bottom drawer": "soda"
}
}
ourStorage.cabinet["top drawer"].folder2; // "secrets"
:pencil: read more about waypoint accessing nested objects in json on the FCC Wiki

fluffystub
@RakshithNM
Jan 18 2016 06:10
help objects
CamperBot
@camperbot
Jan 18 2016 06:10

:point_right: waypoint accessing nested objects in json [wiki]

Waypoint: Accessing Nested Objects in JSON

The properties and sub-properties of JSON objects can be accessed by chaining together the dot or bracket notation.

Here is a nested JSON Object:

```js
var ourStorage = {
"desk": {
"drawer": "stapler"
},
"cabinet": {
"top drawer": {
"folder1": "a file",
"folder2": "secrets"
},
"bottom drawer": "soda"
}
}
ourStorage.cabinet["top drawer"].folder2; // "secrets"
:pencil: read more about waypoint accessing nested objects in json on the FCC Wiki

PreStephan
@PreStephan
Jan 18 2016 06:10
Hi guys. I am stuck at 'Using Objects for Lookups' and I believe I need one more line of code. Can someone give me a hint?
// 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;
}
fluffystub
@RakshithNM
Jan 18 2016 06:10
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;       // Change this Line
var player = testObj.playerNumber;   // Change this Line
help me with this guys
CamperBot
@camperbot
Jan 18 2016 06:10
no wiki entry for: me with this guys
fluffystub
@RakshithNM
Jan 18 2016 06:10
my code doesnt pass
@camperbot thanks for your suggestion , it doesnt help me though
Kyle Roach
@iRoachie
Jan 18 2016 06:11
@RakshithNM When using variables you have the use the bracket notation
var player = testObj[playerNumber];
PreStephan
@PreStephan
Jan 18 2016 06:11
Use bracket notation
Warren
@warrenonline
Jan 18 2016 06:11
help record collection
CamperBot
@camperbot
Jan 18 2016 06:11

: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

fluffystub
@RakshithNM
Jan 18 2016 06:12
@iRoachie thanks man
CamperBot
@camperbot
Jan 18 2016 06:12
rakshithnm sends brownie points to @iroachie :sparkles: :thumbsup: :sparkles:
:star: 295 | @iroachie | http://www.freecodecamp.com/iroachie
Irving Gonzalez
@irvgonz
Jan 18 2016 06:12
help json notation
CamperBot
@camperbot
Jan 18 2016 06:12
no wiki entry for: json notation
navin singh dalal
@dalalns
Jan 18 2016 06:12

"""
function mutation(arr) {
var arr2=[];
var arr3=[];
var arr4=[];
for(i=0;i<arr.length;i++){
arr2.push(arr[i].toLowerCase());
}

arr3=arr2[0].split("");
arr4=arr21.split("");

 for(j=0;j<arr4.length;j++){
for(k=0;k<arr3.length;k++)
  {
    if(arr4[j]==arr3[k]){
      return true;
    }
 else{
   return false;
 }
  }

}

}

mutation(["HELLO", "hello"]);
"""

"""
function mutation(arr) {
var arr2=[];
var arr3=[];
var arr4=[];
for(i=0;i<arr.length;i++){
arr2.push(arr[i].toLowerCase());
}

arr3=arr2[0].split("");
arr4=arr21.split("");

 for(j=0;j<arr4.length;j++){
for(k=0;k<arr3.length;k++)
  {
    if(arr4[j]==arr3[k]){
      return true;
    }
 else{
   return false;
 }
  }

}

}

mutation(["HELLO", "hello"]);

"""

please help
Kyle Roach
@iRoachie
Jan 18 2016 06:13
@dalalns what is the function supposed to do?
navin singh dalal
@dalalns
Jan 18 2016 06:14
@iRoachie compare the two arrays and find if albhabets of arr4 is present in arr3
Kyle Roach
@iRoachie
Jan 18 2016 06:15
You mean letters?
Olawale Akinseye
@brainyfarm
Jan 18 2016 06:20
@dalalns ?
Jose Dzireh Chong
@CodingDucky
Jan 18 2016 06:21
This message was deleted

var temp = args.delete(args0);

I know this isn't the correct syntax, but is there a way to make 'temp' equal to everything in args except for args0? I'd like for the indexes to fix themselves, so args1 would be the new temp0

PreStephan
@PreStephan
Jan 18 2016 06:23
Please help. I don't know how to 'search' the lookup.
// 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";

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

// Change this value to test
phoneticLookup("charlie");
navin singh dalal
@dalalns
Jan 18 2016 06:25
@PreStephan use . operator to use the val variable to return desired result eg lookup.val
Nick Robson
@nickrobson
Jan 18 2016 06:25
@PreStephan Use
lookup[key] // => value
lookup['alpha'] // => 'Adams'
lookup['doesnt exist'] // => undefined
@CodingDucky
var temp = args.slice(1);
Jose Dzireh Chong
@CodingDucky
Jan 18 2016 06:26
@nickrobson Thanks
CamperBot
@camperbot
Jan 18 2016 06:26
codingducky sends brownie points to @nickrobson :sparkles: :thumbsup: :sparkles:
:star: 318 | @nickrobson | http://www.freecodecamp.com/nickrobson
fluffystub
@RakshithNM
Jan 18 2016 06:27
help using objects for lookups
CamperBot
@camperbot
Jan 18 2016 06:27

: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

Jose Dzireh Chong
@CodingDucky
Jan 18 2016 06:28
wiki .pop
CamperBot
@camperbot
Jan 18 2016 06:28

:point_right: waypoint manipulate arrays with pop() [wiki]

Manipulate Arrays With pop()

Another way to change the data in an array is with the .pop() function.

.pop() is used to "pop" a value off of the end of an array. We can retrieve this value by performing pop() in a variable declaration.

Any type of variable can be "popped" off of an array.

:pencil: read more about waypoint manipulate arrays with pop on the FCC Wiki

Calvoxel
@Calvoxel
Jan 18 2016 06:29
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1993,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];
How do I add a new "record" to a json?
Chuck Wongus
@YesImChuck
Jan 18 2016 06:31
Hello all! I'm having trouble understanding the math.random() function. I am trying to get myFunction() to generate a random decimal. This is what I have.

function myFunction() {

// Only change code below this line.
var a = math.random();
return 0;

// Only change code above this line.
}

What am I doing incorrectly?
Calvoxel
@Calvoxel
Jan 18 2016 06:32
'''
CamperBot
@camperbot
Jan 18 2016 06:32
:bulb: to format code use backticks! ``` more info
Nick Robson
@nickrobson
Jan 18 2016 06:32
You're returning 0, not a.
@YesImChuck ^
Calvoxel
@Calvoxel
Jan 18 2016 06:32
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1993,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  // Add record here
];
How do I add a new "album"?
Nick Robson
@nickrobson
Jan 18 2016 06:33
@Calvoxel
var album = ...; // I'll let you figure this bit out.
myMusic.push(album); // Add it to the end of the array.
Ksenia Terentyeva
@kseniawinchester
Jan 18 2016 06:33
Hello, who finished this task Drop it
Drop the elements of an array (first argument), starting from the front, until the predicate (second argument) returns true.?
Calvoxel
@Calvoxel
Jan 18 2016 06:33
@nickrobson Thanks!
CamperBot
@camperbot
Jan 18 2016 06:33
calvoxel sends brownie points to @nickrobson :sparkles: :thumbsup: :sparkles:
:star: 320 | @nickrobson | http://www.freecodecamp.com/nickrobson
Chuck Wongus
@YesImChuck
Jan 18 2016 06:34
I'm still getting a reference error. I'm not sure if I completely missed something in a previous waypoint.
Nick Robson
@nickrobson
Jan 18 2016 06:34
@YesImChuck Oh, and it's Math.random(). Capital M.
bonfire drop it
CamperBot
@camperbot
Jan 18 2016 06:35

:fire:Bonfire: Drop it :link:

function drop(arr, func) {
  // Drop them elements.
  return arr;
}

drop([1, 2, 3], function(n) {return n < 3; });

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

more info:  bf details | bf links | hint

navin singh dalal
@dalalns
Jan 18 2016 06:35
Help Mutations
CamperBot
@camperbot
Jan 18 2016 06:35

:point_right: bonfire mutations [wiki]

Problem Explanation:

  • Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array..
:pencil: read more about bonfire mutations on the FCC Wiki
Chuck Wongus
@YesImChuck
Jan 18 2016 06:35
Oh, lol. how did I miss that? Haha. Thanks @nickrobson
CamperBot
@camperbot
Jan 18 2016 06:35
yesimchuck sends brownie points to @nickrobson :sparkles: :thumbsup: :sparkles:
:star: 321 | @nickrobson | http://www.freecodecamp.com/nickrobson
Nick Robson
@nickrobson
Jan 18 2016 06:35
@YesImChuck No problem. Happens to me all the time, so I've gotten used to checking it! :P
navin singh dalal
@dalalns
Jan 18 2016 06:35

"""
function mutation(arr) {
var arr2=[];
var arr3=[];
var arr4=[];
for(i=0;i<arr.length;i++){
arr2.push(arr[i].toLowerCase());
}

arr3=arr2[0].split("");
arr4=arr21.split("");

 for(j=0;j<arr4.length;j++){
for(k=0;k<arr3.length;k++)
  {
    if(arr4[j]==arr3[k]){
      return true;
    }
 else{
   return false;
 }
  }

}

}

mutation(["HELLO", "hello"]);

"""

help
CamperBot
@camperbot
Jan 18 2016 06:36

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

Basic Commands:

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

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

navin singh dalal
@dalalns
Jan 18 2016 06:36
find Mutations
CamperBot
@camperbot
Jan 18 2016 06:36

find mutations

:zero: bonfire mutations

Nick Robson
@nickrobson
Jan 18 2016 06:37
@kseniawinchester You're looking for the first time the predicate returns true, so just filter the array. Then get the first element of that array and find where it is in the original one, and return an array containing all elements after and including that one.
I can post a sample solution if you wish.
Calvoxel
@Calvoxel
Jan 18 2016 06:37

I'm still having an issue. Apparently, for my code, there are requirements that aren't being met:

myMusic[1] should have at least 4 properties
myMusic[1] should contain an artist property which is a string
myMusic[1] should contain a title property which is a string
myMusic[1] should contain a release_year property which is a number
myMusic[1] should contain a formats property which is an array
formats should be an array of strings with at least two elements

Here is my code:

var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1993,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  // Add record here
];
var album = [
  {
    "artist": "Calvo",
    "title": "Pointless",
    "release_year": 2016,
    "formats": [
      "2",
      "3",
      "4" ],
    "gold": true
  }
];
myMusic.push(album);
Ksenia Terentyeva
@kseniawinchester
Jan 18 2016 06:38
@nickrobson it'll be great, cause spend a lot of time for it(
Nick Robson
@nickrobson
Jan 18 2016 06:38
Your album needs to be an object, not an array.
@Calvoxel ^
So get rid of the surrounding [ and ] on the album object.
This message was deleted
one sec
Calvoxel
@Calvoxel
Jan 18 2016 06:39
Ah, thanks!
@nickrobson Thank you
CamperBot
@camperbot
Jan 18 2016 06:39
calvoxel sends brownie points to @nickrobson :sparkles: :thumbsup: :sparkles:
:warning: calvoxel already gave nickrobson points
Nick Robson
@nickrobson
Jan 18 2016 06:41
@kseniawinchester
function drop(arr, func) {
  var filtered = arr.filter(func); // Filter out elements that don't match, so this way the first element is also the first element to match in the input array.
  var first = filtered[0]; // Get the first matching element.
  var index = arr.indexOf(first); // Find where said matching element is in the original array.
  var subarray = arr.slice(index); // Get the subsection of the array containing all elements after and including the element found.
  return subarray;
}

drop([1, 2, 3], function(n) {return n < 3; });
Jose Dzireh Chong
@CodingDucky
Jan 18 2016 06:42
wiki indexof
CamperBot
@camperbot
Jan 18 2016 06:42

:point_right: js array prototype indexof [wiki]

Array.prototype.indexOf()

The indexOf() method returns the first index at which a given element can be found in the array, or -1 if it is not present!!

arr.indexOf(searchElement[, fromIndex = 0])

:pencil: read more about js array prototype indexof on the FCC Wiki

Ksenia Terentyeva
@kseniawinchester
Jan 18 2016 06:42
@nickrobson thanx, I'll try to use that algorithm)
Nick Robson
@nickrobson
Jan 18 2016 06:42
Or if you prefer a shorter answer,
function drop(arr, func) {
    return arr.slice(arr.indexOf(arr.filter(func)[0]));
}
CamperBot
@camperbot
Jan 18 2016 06:42
kseniawinchester sends brownie points to @nickrobson :sparkles: :thumbsup: :sparkles:
:star: 322 | @nickrobson | http://www.freecodecamp.com/nickrobson
Jose Dzireh Chong
@CodingDucky
Jan 18 2016 06:43
wiki push
CamperBot
@camperbot
Jan 18 2016 06:43

:point_right: waypoint manipulate arrays with push() [wiki]

Manipulate Arrays With push()

Not only can you pop() data off of the end of an array, you can also push() data onto the end of an array.

myArray.push(["dog", 3]);

:pencil: read more about waypoint manipulate arrays with push on the FCC Wiki

Katz
@katzabcd
Jan 18 2016 06:48
wiki for
CamperBot
@camperbot
Jan 18 2016 06:48

:point_right: bonfire check for palindromes [wiki]

Explanation:

You have to check if the string you get as an input is a palindrome and return true if it is, and false otherwise.

:pencil: read more about bonfire check for palindromes on the FCC Wiki

Katz
@katzabcd
Jan 18 2016 06:48
wiki loops
CamperBot
@camperbot
Jan 18 2016 06:48

:point_right: for loops explained [wiki]

For Loops

The for statement creates a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement or a set of statements executed in the loop.

The for loop has the following syntax:

for ([initialization]; [condition]; [final-expression]) {
code block to be executed
}

[initialization] is executed before the loop (the code block) starts.

[condition] defines the condition for running the loop (the code block).

[final-expression] is executed each time after the loop (the code block) has been executed.

Example in Javascript:

```
var ourArray = [];
:pencil: read more about for loops explained on the FCC Wiki

Yosafat Ariel
@yoskakomba
Jan 18 2016 06:48
Hi guys, need help reviewing my code
I don't know what's wrong with my code
function myTest(val) {
  if(val < 10) {
    return "Less than 10";
  } else if(val < 5) {
    return "Less than 5";
  } else {
    return "Greater than or equal to 10";
  }
}

// Change this value to test
myTest(4);
Katz
@katzabcd
Jan 18 2016 06:49
swap 10 and 5
the test should test for smaller numbers first
before moving on to larger numbers
Yosafat Ariel
@yoskakomba
Jan 18 2016 06:50
@katzabcd thanks, is there a logic explanation so I can understand
CamperBot
@camperbot
Jan 18 2016 06:50
yoskakomba sends brownie points to @katzabcd :sparkles: :thumbsup: :sparkles:
:star: 223 | @katzabcd | http://www.freecodecamp.com/katzabcd
Katz
@katzabcd
Jan 18 2016 06:52
Because if you start the test with 10, any number below 10 will automatically return a less than 10
It will not test for other conditions
hence you got to test from smaller numbers to larger numbers
Yosafat Ariel
@yoskakomba
Jan 18 2016 06:54
@katzabcd thanks a lot, now it makes sense
CamperBot
@camperbot
Jan 18 2016 06:54
yoskakomba sends brownie points to @katzabcd :sparkles: :thumbsup: :sparkles:
Jordi Vilagut Treserra
@jordivilagut
Jan 18 2016 06:54
hint escape sequences
CamperBot
@camperbot
Jan 18 2016 06:54
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
:warning: yoskakomba already gave katzabcd points
Jose Dzireh Chong
@CodingDucky
Jan 18 2016 06:55
function destroyer(arr) {
  //args is the subset
  //temp is the stuff we want to filter out
  //newArr is the set to assign the new stuff to
  var args = [];
  var newArr = [];
  for (var i = 0; i < arguments.length; i++){
    args.push(arguments[i]);
  }
  var temp = args.slice(1);
  args.splice(1);

  for (var p = 0; p < temp.length; p++) {
    if (args.indexOf(temp[p]) >= 0) {
      newArr.push(temp[p]);
    }
  }
  return newArr;
}

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

Not sure why my code doesn't work. Here's my task

You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.

My function in the last line simply returns [] every time

why?
Warren
@warrenonline
Jan 18 2016 06:58
help nesting for loops
CamperBot
@camperbot
Jan 18 2016 06:58

:point_right: waypoint nesting for loops [wiki]

Waypoint: 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.
:pencil: read more about waypoint nesting for loops on the FCC Wiki

Miguel
@Miguel12321
Jan 18 2016 07:00
can someone help me with Golf Code
function golfScore(par, strokes) {
  // Only change code below this line
  if(1){
    return "Hole-in-one";
  }
  else if(par, strokes<=par-2){
    return "Eagle";
  }
  else if(par, strokes par-1){
    return "Birdie";
  }

  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
Yosafat Ariel
@yoskakomba
Jan 18 2016 07:01
Hi guys need help with this challenge
http://www.freecodecamp.com/challenges/counting-cards
I don't understand what to do, is there any simple explanation about this?
Miguel
@Miguel12321
Jan 18 2016 07:01
I don't think I'm doing it right
Katz
@katzabcd
Jan 18 2016 07:02
@Miguel12321 your code should be if(strokes == 1){}
@Miguel12321 You need to test using strokes
navin singh dalal
@dalalns
Jan 18 2016 07:03
I am stuck in this code please help

"""
function mutation(arr) {
var arr2=[];
var arr3=[];
var arr4=[];
for(i=0;i<arr.length;i++){
arr2.push(arr[i].toLowerCase());
}
var arr5=[];
arr3=arr2[0].split("");
arr4=arr21.split("");
for(i=0;i<arr4.length;i++){
var num=arr3.indexOf(arr4[i]);
if(num!=-1){
arr5.push(num);
}
else{
arr5.push(num);
}
}

}

mutation(["hello", "Hello"]);
"""

Miguel
@Miguel12321
Jan 18 2016 07:03
@katzabcd oh ok thanks but what is this == again
CamperBot
@camperbot
Jan 18 2016 07:03
miguel12321 sends brownie points to @katzabcd :sparkles: :thumbsup: :sparkles:
:star: 224 | @katzabcd | http://www.freecodecamp.com/katzabcd
Yosafat Ariel
@yoskakomba
Jan 18 2016 07:03
waypoint counting cards
Jose Dzireh Chong
@CodingDucky
Jan 18 2016 07:03

@CodingDucky

function destroyer(arr) {
  //args is the subset
  //temp is the stuff we want to filter out
  //newArr is the set to assign the new stuff to
  var args = [];
  var newArr = [];
  for (var i = 0; i < arguments.length; i++){
    args.push(arguments[i]);
  }
  var temp = args.slice(1);
  args.splice(1);

  for (var p = 0; p < temp.length; p++) {
    if (args.indexOf(temp[p]) >= 0) {
      newArr.push(temp[p]);
    }
  }
  return newArr;
}

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

I just wanna understand why my code doesn't work
Here's the task:
You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.

Also @yoskakomba it's wiki counting cards
wiki counting cards
CamperBot
@camperbot
Jan 18 2016 07:04

:point_right: checkpoint counting cards [wiki]

Checkpoint: Counting Cards

About Blackjack

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

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

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

Instructions

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

Example Output:

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

Katz
@katzabcd
Jan 18 2016 07:04
@Miguel12321 == is a test to see if the value equates
Miguel
@Miguel12321
Jan 18 2016 07:05
@katzabcd ok thanks
CamperBot
@camperbot
Jan 18 2016 07:05
miguel12321 sends brownie points to @katzabcd :sparkles: :thumbsup: :sparkles:
:warning: miguel12321 already gave katzabcd points
Katz
@katzabcd
Jan 18 2016 07:05
wiki nesting for loops
Miguel
@Miguel12321
Jan 18 2016 07:06
  else if(strokes par-1){
    return "Birdie";
  }
@katzabcd what about this one?
Katz
@katzabcd
Jan 18 2016 07:06
@Miguel12321 you got to add == to every test
should read strokes == par-1
Miguel
@Miguel12321
Jan 18 2016 07:07
@katzabcd oh ok now I understand it thanks
CamperBot
@camperbot
Jan 18 2016 07:07
miguel12321 sends brownie points to @katzabcd :sparkles: :thumbsup: :sparkles:
:warning: miguel12321 already gave katzabcd points
Katz
@katzabcd
Jan 18 2016 07:07
wiki nesting for loops
CamperBot
@camperbot
Jan 18 2016 07:07

:point_right: waypoint nesting for loops [wiki]

Waypoint: 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.
:pencil: read more about waypoint nesting for loops on the FCC Wiki

orr29
@orr29
Jan 18 2016 07:20

var count = 0;

function cc(card) {
// Only change code below this line
if (card == 2 || 3 || 4 || 5 || 6){
count ++;
return count;
} else if (card == 7 || 8 || 9){
return count;
}else {
count--;
return count;
}
// Only change code above this line
}

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

why does this function returns 1?
Chuck Wongus
@YesImChuck
Jan 18 2016 07:23
Hello. Me again. I feel like I'm asking too much help. I might not be picking up JS as well as I thought. I am trying to use the .map method to add 3 to each element of this array. What am I doing wrong?

var oldArray = [1,2,3,4,5];
var newArray = [];

// Only change code below this line.

var plusThree = oldArray.map(function(val){
return val + 3;
});

whats wring in my code
Christopher Ngo
@ingochris
Jan 18 2016 07:40

bonfire truncate

function truncate(str, num) {
  // Clear out that junk in your trunk
  str=str.split(""); //.splice(0,num).join("");
  if (num>3){
  return str.splice(0,num-3).join("")+"...";
  }
  else return str.splice(0,num).join("")+"...";
}

truncate("A-tisket a-tasket A green and yellow basket", 2);

Why ain't this case working:

truncate("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2) should return "A-tisket a-tasket A green and yellow basket".

CamperBot
@camperbot
Jan 18 2016 07:40
Sorry, can't find a bonfire called truncatefunction truncatestr num clear out that junk in your trunk strstrsplit splice0numjoin if num3 return strsplice0num-3join else return strsplice0numjointruncatea-tisket a-tasket a green and yellow basket 2why aint this case workingtruncatea-tisket a-tasket a green and yellow basket a-tisket a-tasket a green and yellow basketlength 2 should return a-tisket a-tasket a green and yellow basket . [ Check the map? ]
Yosafat Ariel
@yoskakomba
Jan 18 2016 07:40

Hi guys need help reviewing my code,
I don't know what's wrong

// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

var secondTree = myPlants.trees.list[1];

Thank you for your help

Christopher Ngo
@ingochris
Jan 18 2016 07:40
bonfire truncate a string
CamperBot
@camperbot
Jan 18 2016 07:40

:fire:Bonfire: Truncate a string :link:

function truncate(str, num) {
  // Clear out that junk in your trunk
  return str;
}

truncate('A-tisket a-tasket A green and yellow basket', 11);

Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a '...' ending.

more info:  bf details | bf links | hint

Christopher Ngo
@ingochris
Jan 18 2016 08:02
hint
CamperBot
@camperbot
Jan 18 2016 08:02
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
hey whats wrong in this
im nt using slice im using concat
so what it is working
it is mandatory to use slice in this example
fluffystub
@RakshithNM
Jan 18 2016 08:35
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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


  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
what is my mistake?
please help
Kyle Roach
@iRoachie
Jan 18 2016 08:36
@tpstps You’re not truncating the string you’re just concating
@RakshithNM @RakshithNM You have to use bracket notation for variables
@RakshithNM js collection[id][prop]
Tarun prakash singh
@tpstps
Jan 18 2016 08:37
but its giving the same output
naa
i have used if else
say me an example where this will nt work smoothly
or will give wring output
Kyle Roach
@iRoachie
Jan 18 2016 08:40
@tpstps what i’m trying to tell you is that you need to do the truncate with substr for the num > 3
fluffystub
@RakshithNM
Jan 18 2016 08:40
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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


  return collection;
}

// Alter values below to test your code
update(1245, "tracks", "Addicted to Love");
@iRoachie even after the change you said it doesnot pass
Kyle Roach
@iRoachie
Jan 18 2016 08:42
Yea cause your code is still wrong, in your second else you’re pushing to tracks
but there’s nothing called tracks!
Tarun prakash singh
@tpstps
Jan 18 2016 08:42
but for only less than 3
Kyle Roach
@iRoachie
Jan 18 2016 08:42
You’re supposed to be pushing to
    collection[id].tracks.push(value);
Tarun prakash singh
@tpstps
Jan 18 2016 08:42
the length of three dots should nt be added
for >3
Aaron Osteraas
@aosteraas
Jan 18 2016 08:43
bonfire where do i belong
CamperBot
@camperbot
Jan 18 2016 08:43

:fire:Bonfire: Where do I belong :link:

function where(arr, num) {
  // Find my place in this sorted array.
  return num;
}

where([40, 60], 50);

Return the lowest index at which a value (second argument) should be inserted into a sorted array (first argument).

more info:  bf details | bf links | hint

Tarun prakash singh
@tpstps
Jan 18 2016 08:43
length will bein crease na
Kyle Roach
@iRoachie
Jan 18 2016 08:43
@tpstps Yea the length, which means you dont -3 in the substr, but it still has to be truncated
fluffystub
@RakshithNM
Jan 18 2016 08:43
@iRoachie i changed tracks to prop. Am i right now?
Aaron Osteraas
@aosteraas
Jan 18 2016 08:43
hint
CamperBot
@camperbot
Jan 18 2016 08:43
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Kyle Roach
@iRoachie
Jan 18 2016 08:44

@RakshithNM

You’re supposed to be pushing to

    collection[id].tracks.push(value);
Tarun prakash singh
@tpstps
Jan 18 2016 08:44
so how to add 3 dots wothoyt changing string length
if i have toadd 3 dots string length will increase na
Kyle Roach
@iRoachie
Jan 18 2016 08:46
@tpstps Read over the instructions again
Jose Dzireh Chong
@CodingDucky
Jan 18 2016 08:47
help caesars cipher
CamperBot
@camperbot
Jan 18 2016 08:47

:point_right: bonfire caesars cipher [wiki]

Problem Explanation:

  • You need to write a function, which will take string encoded with
    Caesar cipher as a parameter and decode it.
  • The one used here is ROT13 where the value of the letter is
    shifted by 13 places.
    e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
  • You have to shift it back 13 positions, such that 'N' ↔ 'A'.
:pencil: read more about bonfire caesars cipher on the FCC Wiki
Jose Dzireh Chong
@CodingDucky
Jan 18 2016 08:47
hint
CamperBot
@camperbot
Jan 18 2016 08:47
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Kyle Roach
@iRoachie
Jan 18 2016 08:47
@CodingDucky caesars kinda hardish, i suggest u read the wikipedia page on Rot13
@CodingDucky it helped me out
fluffystub
@RakshithNM
Jan 18 2016 08:48
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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


  return collection;
}

// Alter values below to test your code
update(2548,"tracks", "");
the last condition is still not satisfied
Kyle Roach
@iRoachie
Jan 18 2016 08:49
@RakshithNM Cause you’re suppose to check if the value is blank at the second else as well
Instructions said If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.
Thats 2 conditions
tracks && val
fluffystub
@RakshithNM
Jan 18 2016 08:50
@iRoachie done. thanks a lot
CamperBot
@camperbot
Jan 18 2016 08:50
rakshithnm sends brownie points to @iroachie :sparkles: :thumbsup: :sparkles:
:star: 309 | @iroachie | http://www.freecodecamp.com/iroachie
Kyle Roach
@iRoachie
Jan 18 2016 08:51
Glad i could help! I’m out for the night/morning
Salad
@Saladg
Jan 18 2016 08:51

Anyone?
var Bike = function() {

// Only change code below this line.
// this is a private variable
var gear;
// these are public methods

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

};

var myCar = new Car();

var myBike = new Bike();
myBike.setGear(4);
myBike.getGear();

Help plz..
one error "myBike.getGear() should return 4 after myBike.setGear(4)."
CamperBot
@camperbot
Jan 18 2016 08:51
no wiki entry for: plzone error mybikegetgear should return 4 after mybikesetgear4
iokonokh
@iokonokh
Jan 18 2016 08:52
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    },
];


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

// Change these values to test your function
lookUp("Akira", "likes");
help
CamperBot
@camperbot
Jan 18 2016 08:53

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

Basic Commands:

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

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Shinigami Gökhan
@Bondygio
Jan 18 2016 08:55
Hey guys :)
could someone help me?
kirbyedy
@kirbyedy
Jan 18 2016 08:56
depends :D
Shinigami Gökhan
@Bondygio
Jan 18 2016 08:56
:D ok so I am at the Gold Code
and I really dont understand Golf..
Salad
@Saladg
Jan 18 2016 08:56
@camperbot , what do you mean no wiki entry?
Shinigami Gökhan
@Bondygio
Jan 18 2016 08:56
sorry i meant Golf Code
and my code looks like this
"
if ( par >= par +3){
return "Go Home!";
}
else if ( par + 2){
return "Double Bogey";
}
else if (par +1 ){
return "Bogey";
}
else if (par ){
return "Par";
}
else if (par - 1){
return "Birdle";
}
else if (par <= par -2 ){
return "Eagle";
}
else (par = 1) {
return "Hole-in-one!";
}
return "Change Me";
"
could someone help?? :)
kirbyedy
@kirbyedy
Jan 18 2016 08:58
and what is the exact problem ?
oh wait I see
Shinigami Gökhan
@Bondygio
Jan 18 2016 08:59
and if i change it, like the other way around, i get only 2 right..
kirbyedy
@kirbyedy
Jan 18 2016 08:59
you are using the par instead of strokes
Shinigami Gökhan
@Bondygio
Jan 18 2016 08:59
oh that means?
kirbyedy
@kirbyedy
Jan 18 2016 09:00
par is actually a number that someone said is the average, and the stroke in your case is the number that you actually made the hole
Shinigami Gökhan
@Bondygio
Jan 18 2016 09:00
could you give me an example so I could fix this?
kirbyedy
@kirbyedy
Jan 18 2016 09:01
so for example... par is 4 (because we say so :D ), and than you play golf and you make that hole in lets say 5 (strokes), thats a bogie
Shinigami Gökhan
@Bondygio
Jan 18 2016 09:01
that would mean, I would have to change all my par into strokes ??
kirbyedy
@kirbyedy
Jan 18 2016 09:01
if you make that hole in 3 (strokes) that will give you back the birdie
most probably yes :)
Shinigami Gökhan
@Bondygio
Jan 18 2016 09:02
would it look like this
....
else if ( strokes = -2){
return "Doule Bogey"; }
?
kirbyedy
@kirbyedy
Jan 18 2016 09:05
= means you are assigning the value
== means equal to
and === means explicit equal
Katz
@katzabcd
Jan 18 2016 09:06
wiki constructor
CamperBot
@camperbot
Jan 18 2016 09:06

:point_right: waypoint make instances of objects with a constructor function [wiki]

A function that creates objects is called a constructor_, my favorite way of creating objects when you have to create more than one of the same object. You can also edit the second object to add more properties if needed. This is called creating _instances of an object.

Each new instance of this object inherits all the properties and methods of your original object.

var Car = function() {
   this.wheels = 4;
};

// New instance of Car object.
var myCar = new Car();

//Add the property "engines" to myCar, and make it a number.
myCar.engines = 1;

:pencil: read more about waypoint make instances of objects with a constructor function on the FCC Wiki

fluffystub
@RakshithNM
Jan 18 2016 09:08
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for(var i;i<multiplyAll.length;i++){
    for(var j;j<multiplyAll[i].length;i++){
      product *= multiplyAll[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]]);
can someone tell me my mistake?
kirbyedy
@kirbyedy
Jan 18 2016 09:10
what is the challenge name?
Katz
@katzabcd
Jan 18 2016 09:10
@RakshithNM multiplyAll.length should be changed to arr.length
use arr instead of multiplyALl
@RakshithNM should looks something like for (var i = 0; i < arr.length; i++)
Shinigami Gökhan
@Bondygio
Jan 18 2016 09:12
@kirbyedy I still cant find my mistake :/
if (strokes == 1){
return "Hole-in-one!";
}
else if ( strokes == -2) {
return "Eagle";
}
else if ( strokes == -1 ) {
return "Birdie";
}
else if (strokes ){
return "Par";
}
else if (strokes==+1){
return "Bogey";
}
else if (strokes == +2) {
return "Double Bogey";
}
{
return "Go Home!";
}
Katz
@katzabcd
Jan 18 2016 09:12
@Bondygio you should put in par-2
for Eagle
Aaron Osteraas
@aosteraas
Jan 18 2016 09:13
bonfire where do i belong
CamperBot
@camperbot
Jan 18 2016 09:13

:fire:Bonfire: Where do I belong :link:

function where(arr, num) {
  // Find my place in this sorted array.
  return num;
}

where([40, 60], 50);

Return the lowest index at which a value (second argument) should be inserted into a sorted array (first argument).

more info:  bf details | bf links | hint

Aaron Osteraas
@aosteraas
Jan 18 2016 09:13
bf links
CamperBot
@camperbot
Jan 18 2016 09:13
links:
Aaron Osteraas
@aosteraas
Jan 18 2016 09:13
hint
CamperBot
@camperbot
Jan 18 2016 09:13
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Katz
@katzabcd
Jan 18 2016 09:14
@Bondygio
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 {
   return "Go Home!";
 }
kirbyedy
@kirbyedy
Jan 18 2016 09:15
@Bondygio else if (strokes ){ return "Par";
this is wrong
in the bracket you only have strokes
nothing else
Ahmed Othman
@ahmedgothman
Jan 18 2016 09:16
Hello guys, can anyone help?
kirbyedy
@kirbyedy
Jan 18 2016 09:16
as always... depends with what :D
Ahmed Othman
@ahmedgothman
Jan 18 2016 09:17
function palindrome(str) {
  // Good luck!
   var space = /\s/gi;
  var x = str.replace(space,'');

   x = x.replace("[A-Za-z0-9]",'');

   x = x.toLowerCase();
  //x = str.toLowerCase();
  console.log(x);


  if ( x === reverseString(x) )
    {
    return true;
    }
  else
    {
    return false;
    }
}
fluffystub
@RakshithNM
Jan 18 2016 09:17
@katzabcd it doesnt pass even after the changes

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Shinigami Gökhan
@Bondygio
Jan 18 2016 09:17
that would mean: if (strokes == 1){
return "Hole-in-one!";
}
else if ( strokes <= par -2) {
return "Eagle";
}
else if ( strokes == par -1 ) {
return "Birdie";
}
else if (strokes ){
return "Par";
}
else if (strokes == par+1){
return "Bogey";
}
else if (strokes == par+2) {
return "Double Bogey";
}
else if (storkes >= par+3)
{
return "Go Home!";
Ahmed Othman
@ahmedgothman
Jan 18 2016 09:18
@kirbyedy haha i can't remove the non-alphanumeric characters
kirbyedy
@kirbyedy
Jan 18 2016 09:18
@Bondygio as I said... this if is wrong: } else if (strokes ){ return "Par"; }
you can`t have only strokes in the brackets, you have to compare it with something, otherwise there is no point of the IF function
Shinigami Gökhan
@Bondygio
Jan 18 2016 09:19
ohhh i see .. :( thanks! @kirbyedy
CamperBot
@camperbot
Jan 18 2016 09:19
bondygio sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 285 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
Katz
@katzabcd
Jan 18 2016 09:21
@RakshithNM multiplyAll[i][j] should be arr[i][j]
kirbyedy
@kirbyedy
Jan 18 2016 09:22
@ahmedgothman don't know why are you using all that code, and the if function, this challenge should be a simple 3 line code
Shinigami Gökhan
@Bondygio
Jan 18 2016 09:27
@kirbyedy I was almost right? I only changed two lines, and it was correct.. I only changed the else if ( strokes = par).. and the last one
but Thanks for your help @kirbyedy
CamperBot
@camperbot
Jan 18 2016 09:27
bondygio sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:warning: bondygio already gave kirbyedy points
iokonokh
@iokonokh
Jan 18 2016 09:31
i need some help on the profile lookup waypoint
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    },
];


function lookUp(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
  for (var j = 1; j < contacts.length; i++) {
    if (contacts[i][firstName] == firstName){

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

// Change these values to test your function
lookUp("Akira", "likes");
fluffystub
@RakshithNM
Jan 18 2016 09:36
@iokonokh
//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

  if(contacts.firstName===firstName && contacts.hasOwnProperty(prop)){
  return contacts.firstName;
}
  else if(contacts.firstName!=="firstName"){
    return "No such contact";
    }
  else if(contacts.prop!== prop){
    return "No such Property";
  }
// Only change code above this line
}

// Change these values to test your function
lookUp("Kristian", "lastName");
i did it this way
it doesnt pass though
@katzabcd thank you
CamperBot
@camperbot
Jan 18 2016 09:37
rakshithnm sends brownie points to @katzabcd :sparkles: :thumbsup: :sparkles:
:star: 243 | @katzabcd | http://www.freecodecamp.com/katzabcd
iokonokh
@iokonokh
Jan 18 2016 09:45
@RakshithNM thanks
CamperBot
@camperbot
Jan 18 2016 09:45
iokonokh sends brownie points to @rakshithnm :sparkles: :thumbsup: :sparkles:
:star: 225 | @rakshithnm | http://www.freecodecamp.com/rakshithnm
KoToZ
@Mohamedtareque
Jan 18 2016 09:47

hey guys

i want to know how return work here !!
var myArray = new Array("Wind", "Rain", "Fire");

var sortFn = function(a, b){
  if (a[a.length - 1] < b[b.length - 1]) return -1;
  if (a[a.length - 1] > b[b.length - 1]) return 1;
  if (a[a.length - 1] == b[b.length - 1]) return 0;
}
myArray.sort(sortFn);
Abhisek Pattnaik
@abhisekp
Jan 18 2016 09:59
@Mohamedtareque what do you want to do with that?
You may write the array literal too i.e.
var arr = ['Wind', 'Rain', 'Fire'];
Shruti Hardat
@shrutihardat
Jan 18 2016 10:09
Hello, could someone help me with the task "Record Collection"? I'm unable to implement it because I'm having trouble understanding what I'm supposed to do.
hey see now whats d plm
Shruti Hardat
@shrutihardat
Jan 18 2016 10:17
@katzabcd Thanks :)
CamperBot
@camperbot
Jan 18 2016 10:17
shrutihardat sends brownie points to @katzabcd :sparkles: :thumbsup: :sparkles:
:star: 252 | @katzabcd | http://www.freecodecamp.com/katzabcd
Tarun prakash singh
@tpstps
Jan 18 2016 10:22
hey its working fine in my browser
i have uised concat n logic to replace slice
kalzun
@kalzun
Jan 18 2016 10:25
Hi, I have trouble understanding how the syntax should be for accessing nested array/objects in JSON.
var secondTree = myPlants.trees.pine;
^^gives me undefined.
Oliver Lim
@sirpompous
Jan 18 2016 10:26
Can anyone help me figure out what's wrong? I am on the counting cards challenge and I have no idea what I did wrong.....
Katz
@katzabcd
Jan 18 2016 10:26
@kalzun use myPlants1.type1
Oliver Lim
@sirpompous
Jan 18 2016 10:27

var count = 0;

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

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

Maximilian Schlosser
@maxschlosser
Jan 18 2016 10:27
@TrollCop604 The JSON object is an array containing an object with a type and a list property
sorry wrong person
Katz
@katzabcd
Jan 18 2016 10:28
@TrollCop604 you are supposed to use switch case for this challenge
Maximilian Schlosser
@maxschlosser
Jan 18 2016 10:28
@kalzun The JSON object is an array containing an object with a type and a list property
Oliver Lim
@sirpompous
Jan 18 2016 10:28
ah, I'll try that
kalzun
@kalzun
Jan 18 2016 10:30
Ok, thanks. Should I use dot or brackets [ ] ?
myPlants1.type1;
does not work.
Shinigami Gökhan
@Bondygio
Jan 18 2016 10:30
@Bondygio
hey guys, could you help me? I am stuck and cant find my problem.
switch(val){
case("bob"):
answer ="Marley";
break;
case 42:
answer ="The Answer";
break;
case 1:
answer ="There is no #1";
break;
case 99:
answer ="Missed my by this much!";
break;
default:
answer ="Ate Nine";
hey guys, could you help me? I am stuck and cant find my problem.
switch(val){
case("bob"):
answer ="Marley";
break;
case 42:
answer ="The Answer";
break;
case 1:
answer ="There is no #1";
break;
case 99:
answer ="Missed my by this much!";
break;
default:
answer ="Ate Nine";
shit sorry!
double! :(
sorry
Maximilian Schlosser
@maxschlosser
Jan 18 2016 10:32
@kalzun you need to combine both
@kalzun if you want to access something using the index you need brackets
@kalzun myObj[5].array[3]
Katz
@katzabcd
Jan 18 2016 10:33
wiki for loops
CamperBot
@camperbot
Jan 18 2016 10:33

:point_right: for loops explained [wiki]

For Loops

The for statement creates a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement or a set of statements executed in the loop.

The for loop has the following syntax:

for ([initialization]; [condition]; [final-expression]) {
code block to be executed
}

[initialization] is executed before the loop (the code block) starts.

[condition] defines the condition for running the loop (the code block).

[final-expression] is executed each time after the loop (the code block) has been executed.

Example in Javascript:

```
var ourArray = [];
:pencil: read more about for loops explained on the FCC Wiki

kalzun
@kalzun
Jan 18 2016 10:34
Exactly, and I use brackets with 1 to access the trees this way:
myPlants1
Then, trying to access "pine", through index 1 in "type" this way:
myPlants1.type1;
Ah.. Then I return second LETTER of trees.
Or...?
Maximilian Schlosser
@maxschlosser
Jan 18 2016 10:35
@kalzun what is the name of the array that contains the trees?
kalzun
@kalzun
Jan 18 2016 10:35
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];
Maximilian Schlosser
@maxschlosser
Jan 18 2016 10:36
@kalzun type or list?
kalzun
@kalzun
Jan 18 2016 10:36
So, the type is actually throwing me off here..
Exactly!
Maximilian Schlosser
@maxschlosser
Jan 18 2016 10:36
type is actually just a name
kalzun
@kalzun
Jan 18 2016 10:36
var secondTree = myPlants1.list1;
Ah! Perfect!
Maximilian Schlosser
@maxschlosser
Jan 18 2016 10:37
:thumbsup:
kalzun
@kalzun
Jan 18 2016 10:37
@maxschlosser Thanks a lot!
CamperBot
@camperbot
Jan 18 2016 10:37
kalzun sends brownie points to @maxschlosser :sparkles: :thumbsup: :sparkles:
:star: 276 | @maxschlosser | http://www.freecodecamp.com/maxschlosser
baldwinbejarasco
@baldwinbejarasco
Jan 18 2016 10:37
Goodmorning campers
I have a question :D
blob
Maximilian Schlosser
@maxschlosser
Jan 18 2016 10:39
@baldwinbejarasco try pasting your code between triple backticks ( `` ) so we can easily read it
baldwinbejarasco
@baldwinbejarasco
Jan 18 2016 10:39
How to return "Bet" if card is POSITIVE and "HOLD" if 0 or Negative at the same time ?
Maximilian Schlosser
@maxschlosser
Jan 18 2016 10:40
This message was deleted
baldwinbejarasco
@baldwinbejarasco
Jan 18 2016 10:40
i see @maxschlosser i will try using switch. thank you :D
CamperBot
@camperbot
Jan 18 2016 10:40
baldwinbejarasco sends brownie points to @maxschlosser :sparkles: :thumbsup: :sparkles:
:star: 277 | @maxschlosser | http://www.freecodecamp.com/maxschlosser
Maximilian Schlosser
@maxschlosser
Jan 18 2016 10:42
@baldwinbejarasco you're also using conditions that can never be true. if(a == 3 && a == 4) means "is a equal to 3 and a equal to 4"? You'd have to use || instead of && here
Nick Robson
@nickrobson
Jan 18 2016 10:44
yikes :L
@baldwinbejarasco
return card > 0 ? "Bet" : "Hold";
help conditional
CamperBot
@camperbot
Jan 18 2016 10:45
no wiki entry for: conditionals
Nick Robson
@nickrobson
Jan 18 2016 10:45
help conditional
CamperBot
@camperbot
Jan 18 2016 10:45

:point_right: waypoint use conditional logic with if else statements [wiki]

Waypoint: Use Conditional Logic with If Statemen