These are chat archives for FreeCodeCamp/HelpJavaScript

5th
May 2016
Emilio
@philsod
May 05 2016 00:01
This message was deleted
tekac
@tekac
May 05 2016 00:12
var Bike = function() {

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

  //create public methods?
  this.setGear = function() {

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

};
What do I need to add to return getGear 3 & 4 ..including 1?
Sean DiSanti
@badc0ded
May 05 2016 00:14
i can help @GitResumeCoding
what's up?
oh i guess that was a while ago
lol
didn't see timestamp
@tekac i'm sorry i don't understand what you're asking
you would have to call setGear with the gear you want to set it to, then getGear would return it
tekac
@tekac
May 05 2016 00:24
@badc0ded its the Make Object Properties Private task
Sean DiSanti
@badc0ded
May 05 2016 00:25
help make object properties private
CamperBot
@camperbot
May 05 2016 00:25

:point_right: challenge 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 challenge make object properties private on the FCC Wiki

Stephen James
@sjames1958gm
May 05 2016 00:25
@tekac You are close just implement setGear -
Sean DiSanti
@badc0ded
May 05 2016 00:26
right, setGear should take a parameter and assign it to the gear variable
Stephen James
@sjames1958gm
May 05 2016 00:26
@GitResumeCoding Post your code
tekac
@tekac
May 05 2016 00:27
thanks @sjames1958gm @badc0ded
CamperBot
@camperbot
May 05 2016 00:27
tekac sends brownie points to @sjames1958gm and @badc0ded :sparkles: :thumbsup: :sparkles:
:cookie: 326 | @badc0ded |http://www.freecodecamp.com/badc0ded
:cookie: 962 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Sean DiSanti
@badc0ded
May 05 2016 00:27
@sjames1958gm @GitResumeCoding was asking for help like 45 minutes ago
i did the same thing because i didn't see the timestamp
Stephen James
@sjames1958gm
May 05 2016 00:27
@badc0ded Oh, been off line
Sean DiSanti
@badc0ded
May 05 2016 00:27
same, i came in trying to answer anythign on screen and it was just old stuff
lol
no problem @tekac happy to help
Stephen James
@sjames1958gm
May 05 2016 00:30
@tekac :+1:
1ety
@1ety
May 05 2016 00:31
What is wrong with this code?

function factorialize(num) {

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

}

factorialize(5);

Stephen James
@sjames1958gm
May 05 2016 00:32
@1ety nothing apparent - are you failing specific tests?
1ety
@1ety
May 05 2016 00:34
Yes the code doesnt work
Jevaughn Vance
@jvans7
May 05 2016 00:34
algorithm anyone?
Sean DiSanti
@badc0ded
May 05 2016 00:34
what tests are showing red
1ety
@1ety
May 05 2016 00:34
factorialize(0) should return 1.
Sean DiSanti
@badc0ded
May 05 2016 00:34
could you be more specific @jvans7
oh, you just have to write a case to handle that
Stephen James
@sjames1958gm
May 05 2016 00:35
@1ety You don't test for that case- make your first check <= 1 ?
Sean DiSanti
@badc0ded
May 05 2016 00:35
change your num == 1 to <= 1
Stephen James
@sjames1958gm
May 05 2016 00:35
@badc0ded :+1:
Jevaughn Vance
@jvans7
May 05 2016 00:35
recently starting learning it but would like some help explaining it
Stephen James
@sjames1958gm
May 05 2016 00:35
@jvans7 post your question.
Sean DiSanti
@badc0ded
May 05 2016 00:36
an algorithm is a logical set of instructions to accomplish a task
Li
@NLStom
May 05 2016 00:36
hi can anybody explain what is difference between those two code?
Stephen James
@sjames1958gm
May 05 2016 00:36
help algorithm
CamperBot
@camperbot
May 05 2016 00:36

:point_right: algorithm arguments optional [wiki]

Explanation:

It can be quite complicated to understand what needs to be done. There are always many ways to do something when coding but regardless of the algorithm used, we have to create a program that does the following:

  • It has to add two numbers passed as parameters and return the sum.
  • It has to check if any of the numbers are actual numbers, otherwise return undefined and stop the program right there.
  • It has to check if it has one or two arguments passed. More are ignored.
  • If it has only one argument then it has to return a function that uses that number and expects another one, to then add it.

:pencil: read more about algorithm arguments optional on the FCC Wiki

Stephen James
@sjames1958gm
May 05 2016 00:36
I guess that's not it
Li
@NLStom
May 05 2016 00:36

return collection.filter(function (obj){
for(var i=0; i<keys.length;i++){
if(obj.hasOwnProperty([keys[i]])&&obj[keys[i]]===source[keys[i]]){
return true;}
}

});

return collection.filter(function (obj){
for(var i=0; i<keys.length;i++){
if(!obj.hasOwnProperty([keys[i]])||obj[keys[i]]!==source[keys[i]]){
return false;}
}
return true;
});
1ety
@1ety
May 05 2016 00:37
Thank you
Islam Ibakaev
@dagman
May 05 2016 00:37
change your num == 1 to <= 1 @badc0ded why?
Li
@NLStom
May 05 2016 00:37
the first one it's not working, but the logic should be the same
Sean DiSanti
@badc0ded
May 05 2016 00:37
because 0 is less than 1
step through it with your logic
Islam Ibakaev
@dagman
May 05 2016 00:37
@badc0ded but it works
Sean DiSanti
@badc0ded
May 05 2016 00:37
not for 0
for 0 it starts counting backwards
into infinite loop
Islam Ibakaev
@dagman
May 05 2016 00:38
@badc0ded what a u talking about
Sean DiSanti
@badc0ded
May 05 2016 00:38
because 0 != 1
Li
@NLStom
May 05 2016 00:38
I am guessing it's because of the return terminate the for loop
Sean DiSanti
@badc0ded
May 05 2016 00:38
so it returns factorialize(-1) * 0
Stephen James
@sjames1958gm
May 05 2016 00:38
@NLStom It isn't the first one will stop on the first match with true. the second one will only declare true if all match.
@NLStom yes - because the return terminates
Islam Ibakaev
@dagman
May 05 2016 00:39
@badc0ded why?
Jevaughn Vance
@jvans7
May 05 2016 00:39

function reverseString(str) {
var strReverse = str.split("").reverse("").join("");
return strReverse;
}

reverseString("hello");
so for this one why did i had to split the string?

Sean DiSanti
@badc0ded
May 05 2016 00:40
why what @dagman ?
because string doesn't have a reverse function @jvans7
but array does
Stephen James
@sjames1958gm
May 05 2016 00:40
@jvans7 it is easier to split because array has reverse function and string does not.
Shanae
@Shanae2009
May 05 2016 00:40

need a little help. What am I doing wrong here?
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

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

}

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

Li
@NLStom
May 05 2016 00:40
@sjames1958gm Thanks~
CamperBot
@camperbot
May 05 2016 00:40
nlstom sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 963 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Sean DiSanti
@badc0ded
May 05 2016 00:41
@Shanae2009 what test is failing?
Jevaughn Vance
@jvans7
May 05 2016 00:41
thank you both @sjames1958gm @badc0ded
CamperBot
@camperbot
May 05 2016 00:41
:cookie: 327 | @badc0ded |http://www.freecodecamp.com/badc0ded
jvans7 sends brownie points to @sjames1958gm and @badc0ded :sparkles: :thumbsup: :sparkles:
:cookie: 964 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Sean DiSanti
@badc0ded
May 05 2016 00:41
no problem @jvans7 happy to help
Stephen James
@sjames1958gm
May 05 2016 00:41
@Shanae2009 Looks ok - if it is failing maybe refresh browser - or make sure Not found string is exact match.
Islam Ibakaev
@dagman
May 05 2016 00:42
@badc0ded you never hit zero
Erik Villoria
@kire73
May 05 2016 00:42
Working on exact change. I need to return a number with two decimal places. if I use toFixed(2) it converts to a string. If I convert it back to a number, it drops the 0's. What do I do?
Islam Ibakaev
@dagman
May 05 2016 00:42
you dont need num <= 1
Shanae
@Shanae2009
May 05 2016 00:42
@badc0ded checkObj("house") should return "Not Found". is failing
Islam Ibakaev
@dagman
May 05 2016 00:43
num===1 works perfectly
Stephen James
@sjames1958gm
May 05 2016 00:43
@Shanae2009 Case sensitive.
Sean DiSanti
@badc0ded
May 05 2016 00:43
capitalize your "Found"
Stephen James
@sjames1958gm
May 05 2016 00:43
@dagman You need the case of factorial(0);
Islam Ibakaev
@dagman
May 05 2016 00:43
@sjames1958gm why
Stephen James
@sjames1958gm
May 05 2016 00:43
@dagman Because it is one of the tests.
Sean DiSanti
@badc0ded
May 05 2016 00:43
didn't you say that was a failing test?
shoud return 1 for 0
you account for that by checking that num <= 1 instead of == 1
Islam Ibakaev
@dagman
May 05 2016 00:44
@sjames1958gm doesnt num===1 passes test?
Shanae
@Shanae2009
May 05 2016 00:44
@sjames1958gm @badc0ded that worked! Thanks guys!
CamperBot
@camperbot
May 05 2016 00:44
shanae2009 sends brownie points to @sjames1958gm and @badc0ded :sparkles: :thumbsup: :sparkles:
:cookie: 328 | @badc0ded |http://www.freecodecamp.com/badc0ded
:cookie: 965 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Sean DiSanti
@badc0ded
May 05 2016 00:45
no problem, happy to help
Stephen James
@sjames1958gm
May 05 2016 00:45
@Shanae2009 :+1:
Sean DiSanti
@badc0ded
May 05 2016 00:45
@dagman step through it with 0 as the num and see if 1 is returned
Stephen James
@sjames1958gm
May 05 2016 00:45
@dagman How does num === 1 pass the test when num === 0
Sean DiSanti
@badc0ded
May 05 2016 00:46
it is the only way to further demonstrate that i think
Islam Ibakaev
@dagman
May 05 2016 00:46
@badc0ded @sjames1958gm oh i found it factorialize(0) should return 1.
Sean DiSanti
@badc0ded
May 05 2016 00:46
:)
ues
yes
Islam Ibakaev
@dagman
May 05 2016 00:46
but !num works too :smile:
Sean DiSanti
@badc0ded
May 05 2016 00:47
unless it's called with -1
or -2
Stephen James
@sjames1958gm
May 05 2016 00:47
@dagman I'd think by now you'd trust me :crying_cat_face:
Sean DiSanti
@badc0ded
May 05 2016 00:47
etc
i think they're just trying to understand more than being dubious
Islam Ibakaev
@dagman
May 05 2016 00:48
@sjames1958gm !num works perfectly
function factorialize(num) {
  return !num ? 1 : factorialize(num-1)*num;
}
factorialize(5);
Omid
@omidqayoumi
May 05 2016 00:49
recursion :O
Islam Ibakaev
@dagman
May 05 2016 00:50
@omidqayoumi you look scary :worried:
Sean DiSanti
@badc0ded
May 05 2016 00:50
what does factorialize(-1) return?
Islam Ibakaev
@dagman
May 05 2016 00:50
@badc0ded 1
Omid
@omidqayoumi
May 05 2016 00:50
I look scary? @dagman :'(
Islam Ibakaev
@dagman
May 05 2016 00:50
@omidqayoumi but recursion...
@omidqayoumi i mean this -> :O
Omid
@omidqayoumi
May 05 2016 00:51
ohhh =D
I saw that exact thing in a video earlier @dagman
Islam Ibakaev
@dagman
May 05 2016 00:52
@badc0ded so it looks like you can write !num instead num <=1
Sean DiSanti
@badc0ded
May 05 2016 00:52
@dagman what happens if it's then called with -1
Islam Ibakaev
@dagman
May 05 2016 00:53
@badc0ded you ll be returned 1
1ety
@1ety
May 05 2016 00:53
Whats wrong with my code?
Sean DiSanti
@badc0ded
May 05 2016 00:53
with !num ?
Islam Ibakaev
@dagman
May 05 2016 00:53
@1ety dont know
1ety
@1ety
May 05 2016 00:53

function palindrome(word) {
// Good luck!
word = word.toLowerCase();
word = word.replace(/[\s|.|\?|,]/ig, '');
wordb = word.split('');
wordb = wordb.reverse();
if(word == wordb.join('')){
return true;
} else {
return false;
}
}

palindrome("eye");

palindrome("0_0 (: /-\ :) 0-0") should return true.
Islam Ibakaev
@dagman
May 05 2016 00:53
@badc0ded yep it works i chked
@1ety is smile supposed to be here?
Stephen James
@sjames1958gm
May 05 2016 00:54
-1 is truthy
1ety
@1ety
May 05 2016 00:55
smiley face is :suppose to be : )
Jevaughn Vance
@jvans7
May 05 2016 00:55
please tell me you guys are talking about the Lesson Factorialize a Number?
Omid
@omidqayoumi
May 05 2016 00:55
recursion too strong
I think we are
Islam Ibakaev
@dagman
May 05 2016 00:56
@badc0ded why?
should return 1
Sean DiSanti
@badc0ded
May 05 2016 00:56
no, because -1 != false
Aparna
@Aparna-S
May 05 2016 00:56
am working on "Introducing JavaScript Object Notation JSON" challenga , can anyone help?
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];
myMusic.artist= "addingartist";
myMusic.title = "shin chan";
myMusic.release_year = 1974;
myMusic.formats = ["html" , "10bootstrap"];
Sean DiSanti
@badc0ded
May 05 2016 00:57
yes we can help, what's not working?
Stephen James
@sjames1958gm
May 05 2016 00:57
@Aparna-S You are supposed to add a second element in the array just using json
Islam Ibakaev
@dagman
May 05 2016 00:57
@badc0ded but why you trying to find factorialize(-1); it makes no sense
Erik Villoria
@kire73
May 05 2016 00:58
anyone know how to keep zeros after a decimal without using toFixed() or otherwise converting to a string?
Aparna
@Aparna-S
May 05 2016 00:58
@sjames1958gm is my code wrong, after "Add Record here" ?
Islam Ibakaev
@dagman
May 05 2016 00:58
@badc0ded you are not going do it in real world
Stephen James
@sjames1958gm
May 05 2016 00:58
@Aparna-S It is not necessarily wrong just not what they are after
Sean DiSanti
@badc0ded
May 05 2016 00:58
@dagman whether the input makes sense to you or not does not affect whether someone will try to put it into your page
Islam Ibakaev
@dagman
May 05 2016 01:00
@badc0ded but it passes all tests on freecodecamp so should be considered as a right decision
Diego Mayer
@Chrono79
May 05 2016 01:00
@sjames1958gm it's wrong, because to be right it should be myMusic[1].artist... etc. Dunno if it'll work that way though.
Aparna
@Aparna-S
May 05 2016 01:00
@sjames1958gm cant get you?
Stephen James
@sjames1958gm
May 05 2016 01:00
@Chrono79 Oh yeah- correct.
Sean DiSanti
@badc0ded
May 05 2016 01:01
the site considers it correct and gave you the point, that doesn't mean that it's the best solution
Aparna
@Aparna-S
May 05 2016 01:01
@Chrono79
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];
myMusic1.artist= "addingartist";
myMusic1.title = "shin chan";
myMusic1.release_year = 1974;
myMusic1.formats = ["html" , "10bootstrap"];
Erik Villoria
@kire73
May 05 2016 01:02
anyone know how to keep zeros after a decimal without using toFixed() or otherwise converting to a string?
Aparna
@Aparna-S
May 05 2016 01:02
still throws error..
Sean DiSanti
@badc0ded
May 05 2016 01:02
if you can think of a test your code doesn't pass within the specification, then it could be better, even if the test wasn't included
Diego Mayer
@Chrono79
May 05 2016 01:03
@Aparna-S That's because as @sjames1958gm said, they want you to put your object where it says: // Add record here
Aparna
@Aparna-S
May 05 2016 01:03
@Chrono79 if the "];" is at the end, it throws error

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

myMusic1.artist= "addingartist";
myMusic1.title = "shin chan";
myMusic1.release_year = 1974;
myMusic1.formats = ["html" , "10bootstrap"];

];

Erik Villoria
@kire73
May 05 2016 01:04
How do I convert strings of numbers to numbers and maintain decimals?
Sean DiSanti
@badc0ded
May 05 2016 01:04
parseFloat
Diego Mayer
@Chrono79
May 05 2016 01:04
@Aparna-S you have to put your object like they've put the first one, separated by a comma
Sean DiSanti
@badc0ded
May 05 2016 01:04
i think
if i remember right
Aparna
@Aparna-S
May 05 2016 01:04
@Chrono79 or do i have to ninitiate myMusic as a var first?
henrywashere
@henrywashere
May 05 2016 01:05
Diego!!! need help with this
Islam Ibakaev
@dagman
May 05 2016 01:05
@kire73 or maybe toPrecision
henrywashere
@henrywashere
May 05 2016 01:05
help counting cards
CamperBot
@camperbot
May 05 2016 01:05

:point_right: challenge 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 challenge counting cards on the FCC Wiki

Islam Ibakaev
@dagman
May 05 2016 01:05
@kire73 or something like that
Diego Mayer
@Chrono79
May 05 2016 01:05
@Aparna-S
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
},
{
//your object, like the above, but change some strings
}];
henrywashere
@henrywashere
May 05 2016 01:05
this is what i wrote but it didnt go through
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:  
    count++;
    break;

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

}      

if (count > 0) {
    return "Bet";  
}
  else if (count < 0)
    return "Hold";
  return "Change Me";
Aparna
@Aparna-S
May 05 2016 01:06
@Chrono79 so we need to do var MyMsic[1] ..and so on same as above, instead of just adding records to a var available?
Erik Villoria
@kire73
May 05 2016 01:06
@dagman still doesn't include decimals if they're 0's
Diego Mayer
@Chrono79
May 05 2016 01:06
@Aparna-S yes, if I understood what you meant
Do it and paste it here again
henrywashere
@henrywashere
May 05 2016 01:07
@Chrono79 need help
Diego Mayer
@Chrono79
May 05 2016 01:07
@henrywashere with what?
henrywashere
@henrywashere
May 05 2016 01:07
help counting cards
CamperBot
@camperbot
May 05 2016 01:07

:point_right: challenge 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 challenge counting cards on the FCC Wiki

henrywashere
@henrywashere
May 05 2016 01:08
the code i wrote is above
daiwik
@daiwik
May 05 2016 01:08
function offlineJson() {

    var offlineUrl = "";
    output = "<ul>";
    for (var i = 0; i < offline.length; i++) {
      var offlineUser = offline[i];
      var url = "https://api.twitch.tv/kraken/channels/" + offlineUser;
      console.log(offlineUser);//help goes through all values- works
      $.getJSON(url, function(stuff) {
        offlineUrl = stuff.url;
        output += "<li><a href='"
        output += offlineUrl;
        output += "'target='_blank'>";
        output += offlineUser;
        output += "</a>";
        output += "Offline";
        output += "</li>";
        output += "</ul>";
        console.log(offlineUser);//help here!!!!! only 1 Value - doesnt work
//offlineUser is always one value and doesn't loop through the offline User array
//Why is that?
      });      
    }
    output = "<ul>";
  }
help plz its makes no sense
CamperBot
@camperbot
May 05 2016 01:08
no wiki entry for: plz its makes no sense
Diego Mayer
@Chrono79
May 05 2016 01:08

@henrywashere

if (count > 0) {
    return "Bet";  
}
  else if (count < 0)
    return "Hold";
  return "Change Me";

this part isn't right

Aparna
@Aparna-S
May 05 2016 01:08
@Chrono79 still errors :(
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];
var myMusic1 = [
{
"artist" : "addingartist",
"title" : "shin chan",
"release_year" : 1974,
"formats" : ["html" ,
"10bootstrap"]
}
];
Diego Mayer
@Chrono79
May 05 2016 01:09
@Aparna-S look at what I posted before and compare with what you did
henrywashere
@henrywashere
May 05 2016 01:09
@Chrono79 which part do i have to change?
Diego Mayer
@Chrono79
May 05 2016 01:10
@henrywashere delete return "Change Me"; it's useless
and read again the instructions, what you have to return and when
Chase Webb
@jerrybaggin
May 05 2016 01:10
im currently on the Slasher Flick challenge and im not sure why my splice method isnt working?

function slasher(arr, howMany) {
  // it doesn't always pay to be first, so early bird doesnt get the worm?

  var empty = []; // holder array I think?

  for(var i = 0; i < arr.length; i++){
    empty = arr.length.splice(howMany[i]).slice(howMany);
  }

  return empty;
}

slasher([1, 2, 3], 2);
henrywashere
@henrywashere
May 05 2016 01:11
thanks @Chrono79
CamperBot
@camperbot
May 05 2016 01:11
henrywashere sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 618 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
May 05 2016 01:11
@jerrybaggin arr.length.splice?
arr.length is a number and howMany is also a number, instead of howMany[i] you should use 0 there
Also, why do you need a loop?
Chase Webb
@jerrybaggin
May 05 2016 01:13
@Chrono79 holy shit I didn't think about that. took out my length and it passed!
henrywashere
@henrywashere
May 05 2016 01:20
@Chrono79 this is what i wrote but it still wouldnt go through
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:  
    count++;
    break;


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

}      

if (count > 0) {
    return count + " Bet";  
}
  else if (count < 0)
    return count + " Hold";
Diego Mayer
@Chrono79
May 05 2016 01:20
@henrywashere almost there, you're missing = on one of the ifs, don't remeber which one, read the instructions again, I think it's in the one with Hold
Thomas G.
@CaptainMurphey
May 05 2016 01:21

//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 lookUpProfile(firstName, prop){
// Only change code below this line

  ////HARDCODE EXAMPLE NO GOOD
  /*console.log("first name is: "+firstName+" prop is: "+ prop);

  if(contacts[0].firstName===firstName|| contacts[1].firstName===firstName|| contacts[2].firstName===firstName||contacts[3].firstName===firstName) {

    console.log("it matches a name");

              for (i=0;i<contacts.length;i++)   {
              console.log(" var i = " + i);
                if(firstName===contacts[i].firstName){
                  console.log(" CONTACT i  is: "+ contacts[i].firstName + contacts[i][prop] );
                  if(contacts[i][prop]===undefined){return "No such property";}
                  else{return contacts[i][prop];}
                }
    }



  }
  else {console.log("no such contact meow");  return "No such contact";}*/

  ///// CORRECT EXAMPLE  

  console.log("first name is: "+firstName+" prop is: "+ prop);

  if(contacts.hasOwnProperty([firstName])){

  for(var i=0;i<contacts.length;i++){
        if(contacts[i].firstName===firstName){
             if(contacts[i].hasOwnProperty([prop])){
              console.log(contacts[i][prop]); return contacts[i][prop];  } 
              else{ console.log("no such property"); return "No such property";}

       } 

   }//for loop end  
  }//end initial if statement
  else { console.log("no such contact"); return "No such contact"; }


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");


//yes @CaptainMurphey , it was covered:
//https://www.freecodecamp.com/challenges/testing-objects-for-properties
im a little confrusticated no matter where I put a check to see if no such contact exsists, it destroys the code, anwhere inside the inner if statement or for loop and it ends the loop without checking the rest of the array for matches, and if I put an if statement to check outside the inner for loop either before or after, it just causes every call to the function to result in No such contact. is this a syntax thing i am missing or am i organizing this wrong?
Aparna
@Aparna-S
May 05 2016 01:22
@Chrono79 so it isnot creating a new var called myMusic[1] , it is just adding objects directly??
Diego Mayer
@Chrono79
May 05 2016 01:22
@CaptainMurphey contacts is an array, it has no properties
@Aparna-S yes, you're modifying the var declaration itself
Thomas G.
@CaptainMurphey
May 05 2016 01:24
@Chrono79 but isint contacts[i] an array as well or is it just an object?
Norvin Burrus
@ndburrus
May 05 2016 01:24
@henrywashere where are the conditions for the cards 7,8,9?
Diego Mayer
@Chrono79
May 05 2016 01:24

@CaptainMurphey this is ok:


  for(var i=0;i<contacts.length;i++){
        if(contacts[i].firstName===firstName){
             if(contacts[i].hasOwnProperty([prop])){
              console.log(contacts[i][prop]); return contacts[i][prop];  } 
              else{ console.log("no such property"); return "No such property";}

       } 

   }

after that just return "No such contact";

Aparna
@Aparna-S
May 05 2016 01:25
@Chrono79 how is that to change myMusic to myMusic1 ??
Thomas G.
@CaptainMurphey
May 05 2016 01:25
@Chrono79 inside the for loop, wont that just cause the loop to end without checking the while array?
Diego Mayer
@Chrono79
May 05 2016 01:26

@Aparna-S

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

like this

Thomas G.
@CaptainMurphey
May 05 2016 01:26
or after the last bracket there? @Chrono79
Diego Mayer
@Chrono79
May 05 2016 01:27
@ndburrus not needed, count isn't modified
Aparna
@Aparna-S
May 05 2016 01:27
@Chrono79 in this case where is mymusic renamed as mymusic1? :(
Diego Mayer
@Chrono79
May 05 2016 01:27
@CaptainMurphey it's after the loop, if it reaches there it means no contact matched
henrywashere
@henrywashere
May 05 2016 01:28
@Chrono79 is this correct?
if (count > 0) {
    return count + " Bet";  
}
  else if (count < 0) {
    return count + " Hold";
}  
  else if (count === 0) {
    return count + " Hold";
}
Norvin Burrus
@ndburrus
May 05 2016 01:28
@CaptainMurphey where you have the first else, why not try an if statement?
Diego Mayer
@Chrono79
May 05 2016 01:28
@Aparna-S it's not renamed, you add an object to your array, so myMusic1 will be equal to your object
@henrywashere yessssss, but you could do it better using <=
Aparna
@Aparna-S
May 05 2016 01:29

@Chrono79
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
},
// Add record here

{
"artist": "addingartist",
"title": "shin chan",
"release_year": 1974,
"formats": ["html" ,
"10bootstrap"]
}
];

henrywashere
@henrywashere
May 05 2016 01:29
ah i see
Diego Mayer
@Chrono79
May 05 2016 01:29
also, no need for condition in the else
henrywashere
@henrywashere
May 05 2016 01:29
thanks @Chrono79
CamperBot
@camperbot
May 05 2016 01:29
:warning: henrywashere already gave chrono79 points
henrywashere sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Aparna
@Aparna-S
May 05 2016 01:29
here where is myMusic1 used? :( sorry to ask so many questions
Zachary Baltrus
@ztbaltrus
May 05 2016 01:29

// Setup
var a = 7;
var b = 2;

// Only change code below this line

Norvin Burrus
@ndburrus
May 05 2016 01:29
@Chrono79 ok, what if the count = 0?
Zachary Baltrus
@ztbaltrus
May 05 2016 01:30

// Setup
var a = 7;
var b = 2;

// Only change code below this line

Thomas G.
@CaptainMurphey
May 05 2016 01:30
@Chrono79 holy crap that was too easy, dang dude ive been working on this problem like all last night and most of today, i feel dumb now that I realize that wasn't even really complicated...... thanks for pointing that out though
CamperBot
@camperbot
May 05 2016 01:30
captainmurphey sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 619 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
May 05 2016 01:30
@ndburrus look, if it's not greater than 0, then it's <= 0 isn't it?
@CaptainMurphey no problem
Norvin Burrus
@ndburrus
May 05 2016 01:30
@diego, but the code doesnt say <=, if im not mistaken...'
Diego Mayer
@Chrono79
May 05 2016 01:31
this is starting to feel like simultaneous chess matches ;)
@ndburrus The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative. The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
Norvin Burrus
@ndburrus
May 05 2016 01:32
@Chrono79 ok
Zachary Baltrus
@ztbaltrus
May 05 2016 01:32

// Setup
var a = 7;
var b = 2;

// Only change code below this line
having trouble to put the contents of var a to var b

Diego Mayer
@Chrono79
May 05 2016 01:33
@ztbaltrus how do you put some value in a var?
Norvin Burrus
@ndburrus
May 05 2016 01:33
@ztbaltrus ok, the value of 7 is assigned to a. the value of 2 is assigned to b. what follows next? hint: another assignment is needed.
Diego Mayer
@Chrono79
May 05 2016 01:33
@ztbaltrus don't declare the vars again, just use them
Zachary Baltrus
@ztbaltrus
May 05 2016 01:34
@ndburrus @Chrono79 wouldnt it be var b = a?
Diego Mayer
@Chrono79
May 05 2016 01:34
without var
Norvin Burrus
@ndburrus
May 05 2016 01:34
@@zach b is already declared as a var, so the var is not needed
DamianMitchell
@DamianMitchell
May 05 2016 01:35
Question: can I write assignment(=) to a for with an array loop that consist of a boolean (a === b) notion
Zachary Baltrus
@ztbaltrus
May 05 2016 01:35
@ndburrus @Chrono79 so would i just write b = a?
Andrew Charlebois
@andrewchar
May 05 2016 01:35
how to start coding a tic tac toe game? ekk
Diego Mayer
@Chrono79
May 05 2016 01:36
@DamianMitchell write that in code form, because I didn't understand what you want
Norvin Burrus
@ndburrus
May 05 2016 01:36
@zach... try it !! :)
Diego Mayer
@Chrono79
May 05 2016 01:36
and my cat is nibbling my fingers
Zachary Baltrus
@ztbaltrus
May 05 2016 01:36
@ndburrus haha didnt work
DamianMitchell
@DamianMitchell
May 05 2016 01:36
@Chrono79 if (contact[i].firstName === firstName && contacts[i].hasOwnProperty(prop)===true = contactsi)
Norvin Burrus
@ndburrus
May 05 2016 01:37
@ztbaltrus which one is that?
DamianMitchell
@DamianMitchell
May 05 2016 01:37
I ha to try it?
Zachary Baltrus
@ztbaltrus
May 05 2016 01:37
@ndburrus b = a lol
Diego Mayer
@Chrono79
May 05 2016 01:37
@DamianMitchell as it is, no it won't work
GitResumeCoding
@GitResumeCoding
May 05 2016 01:38
@sjames1958gm @badc0ded thank you for the responses, I was still confused, but think I got it going nicely, and moved onward. I'm going to revisit the concept though when I get to the end of this section. But, the following code does not work. Yet, if I change it to return results = lookup[val] (which is not allowed due to return results being beyond the add code here line) it works.


function phoneticLookup(val){
  var result = "";

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

  results = lookup[val];
return result;
}
phoneticLookup("charlie");
CamperBot
@camperbot
May 05 2016 01:38
gitresumecoding sends brownie points to @sjames1958gm and @badc0ded :sparkles: :thumbsup: :sparkles:
:cookie: 966 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:cookie: 331 | @badc0ded |http://www.freecodecamp.com/badc0ded
Zachary Baltrus
@ztbaltrus
May 05 2016 01:38
@ndburrus I know this shouldnt be hard, but I am not understanding this.
DamianMitchell
@DamianMitchell
May 05 2016 01:39
ok... @Chrono79 I know that this will function all the way to where "true" is, yet, I didn't see how I couldn't write if (contact[i].firstName === firstName && contacts[i].hasOwnProperty(prop)===true = contactsi)
GitResumeCoding
@GitResumeCoding
May 05 2016 01:39
@badc0ded @sjames1958gm it was this waypoint https://www.freecodecamp.com/challenges/using-objects-for-lookups
Diego Mayer
@Chrono79
May 05 2016 01:39
@GitResumeCoding results instead of result
results = lookup[val]; <- here
return result;
Norvin Burrus
@ndburrus
May 05 2016 01:39
@ztbaltrus i just ran the code, and it works
var a = 7;
var b = 2
b = a;
console.log(b);
DamianMitchell
@DamianMitchell
May 05 2016 01:40
@Chrono79 Thanks
CamperBot
@camperbot
May 05 2016 01:40
damianmitchell sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 620 | @chrono79 |http://www.freecodecamp.com/chrono79
GitResumeCoding
@GitResumeCoding
May 05 2016 01:40
@Chrono79 OMG! lol <facepalm>
Zachary Baltrus
@ztbaltrus
May 05 2016 01:40
@ndburrus its not letting me pass
Norvin Burrus
@ndburrus
May 05 2016 01:40
@GitResumeCoding Welcome... you're on fire!! :)
@ztbaltrus refresh browser?
Zachary Baltrus
@ztbaltrus
May 05 2016 01:41
still not working
Norvin Burrus
@ndburrus
May 05 2016 01:42
@ztbaltrus result
7
@ztbaltrus paste ur code...
Diego Mayer
@Chrono79
May 05 2016 01:42

@ztbaltrus are you sure you've done this 2 things?
Instructions
Assign the value 7 to variable a.

Assign the contents of a to variable b.

Zachary Baltrus
@ztbaltrus
May 05 2016 01:43

// Setup
var a = 7;
var b = 2;

// Only change code below this line
b = a;

Diego Mayer
@Chrono79
May 05 2016 01:43
@ztbaltrus
// Setup
var a;
var b = 2;

// Only change code below this line
ONLY CHANGE CODE BELOW THIS LINE <- is there for a reason
Zachary Baltrus
@ztbaltrus
May 05 2016 01:44
yes i did that too and it did not work
Norvin Burrus
@ndburrus
May 05 2016 01:44
@ztbaltrus what is the challenge name?
Zachary Baltrus
@ztbaltrus
May 05 2016 01:45
@ndburrus Storing Values with the Assignment Operator
@Chrono79 are you on that challenge?
Diego Mayer
@Chrono79
May 05 2016 01:46
@ztbaltrus
// Setup
var a;
var b = 2;

// Only change code below this line
a = 7;
b = a;
Norvin Burrus
@ndburrus
May 05 2016 01:46
@ztbaltrus
// Setup
var a;
var b = 2;

// Only change code below this line
a = 7;
b = a;
Zachary Baltrus
@ztbaltrus
May 05 2016 01:46
@Chrono79 SMH :(
@Chrono79 @ndburrus thank you
CamperBot
@camperbot
May 05 2016 01:47
ztbaltrus sends brownie points to @chrono79 and @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 621 | @chrono79 |http://www.freecodecamp.com/chrono79
:cookie: 315 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
May 05 2016 01:47
@ztbaltrus go get'em!! :)
Lizzy
@DevElisabeth
May 05 2016 01:47
Hi all! Feeling very confused in the Word Blanks Javascript challenge as to what exactly I should be doing and wishing there were more instructions. I've been concocting all kinds of concatenations to no avail o_o Help please!
Zachary Baltrus
@ztbaltrus
May 05 2016 01:47
@Chrono79 @ndburrus I may need some more help soon
Coy Sanders
@coymeetsworld
May 05 2016 01:47
hi @veganlizzy can you post what you have?
Zachary Baltrus
@ztbaltrus
May 05 2016 01:48
@veganlizzy IM VEGAN TOO!
Norvin Burrus
@ndburrus
May 05 2016 01:48
@ztbaltrus fire when ready.... :+1:
Diego Mayer
@Chrono79
May 05 2016 01:48
@veganlizzy read Mad Libs link if you didn't, it will help you understand what you have to do
Norvin Burrus
@ndburrus
May 05 2016 01:49
@veganlizzy basically, the challenge requires using the result var and the wordBlanks vars to create the required string
Lizzy
@DevElisabeth
May 05 2016 01:50

@coymeetsworld Hi Coy! My most recent attempt looks like this: function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
var myNoun = "cat";
var myAdjective = "little";
var myVerb = "hit";
var myAdverb = "slowly";
result += "The " + myAdjective + " " + myNoun + " " + myVerb + " " + myAdverb + ".";

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
result += "The " + "big" + " " + "dog" + " " + "ran" + " " + "quickly" + ".";

Diego Mayer
@Chrono79
May 05 2016 01:50
@ndburrus don't forget to add spaces and words that make the whole sentence make sense
Coy Sanders
@coymeetsworld
May 05 2016 01:51
@veganlizzy remove the variable declarations myNoun,myAdjective, myVerb , and myAdverb
also the last line
you should be good after that
var myNoun = "cat";
var myAdjective = "little";
var myVerb = "hit";
var myAdverb = "slowly";
you don't need those
Norvin Burrus
@ndburrus
May 05 2016 01:52
@veganlizzy where is the identification of wordBlanks as a function?
Coy Sanders
@coymeetsworld
May 05 2016 01:52
also what @Chrono79 said about adding spaces @veganlizzy
between the variables, change "" to " "
Diego Mayer
@Chrono79
May 05 2016 01:53
@veganlizzy when you call your function like this wordBlanks("dog", "big", "ran", "quickly");
myNoun is "dog", myAdjective is "big" and so on, they are the parameters of your function
if you do what you did, you are overwriting them and your function will return always the same sentence
Lizzy
@DevElisabeth
May 05 2016 01:54
@coymeetsworld That totally worked thank you :D! I am so confused tho because of the explicit instructions to somehow include "cat" "little" "hit" and "slowly" @ndburrus thanks for your help but the puzzle is solved :)
CamperBot
@camperbot
May 05 2016 01:54
veganlizzy sends brownie points to @coymeetsworld and @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 316 | @ndburrus |http://www.freecodecamp.com/ndburrus
:cookie: 732 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 05 2016 01:54
np @veganlizzy, look at @Chrono79's explanation
Norvin Burrus
@ndburrus
May 05 2016 01:55
@veganlizzy ok, best! :)
Coy Sanders
@coymeetsworld
May 05 2016 01:55
"cat", "little", "hit", "slowly" are arguments you pass into the function wordBlanks

your function definition is
wordBlanks(myNoun, myAdjective, myVerb, myAdverb)
so
wordBlanks("cat", "little", "hit", "slowly");

means that myNoun will be cat, myAdjective will be little, myVerb will be hit, and myAdverb will be slowly

Lizzy
@DevElisabeth
May 05 2016 01:56
Thanks @Chrono79 ! Will read that now :D
CamperBot
@camperbot
May 05 2016 01:56
veganlizzy sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 622 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
May 05 2016 01:57
you're welcome
Fernando Souza
@fernandosouza
May 05 2016 02:04
Hi everyone. I've just join FreeCodeCamp. I'm a front-end developer. I hope I can help you and learn from you as well.
Lizzy
@DevElisabeth
May 05 2016 02:05
@coymeetsworld that part makes sense, but weirdly I completed the challenge a few moments ago without including that change in my final code.. I think I found my first bug! I went back to the page and it was reading an error but when I changed wordBlanks("dog", "big", "ran", "quickly") to the wordBlanks("cat", "little", "hit", "slowly") there was a second exclamation of success. Something seems fishy..
Chase Webb
@jerrybaggin
May 05 2016 02:05
can anyone tell me why this isnt a function? var lowerCasefirst = arr[0].tolowerCase();
Diego Mayer
@Chrono79
May 05 2016 02:06
Welcome Fernando
Chase Webb
@jerrybaggin
May 05 2016 02:06
this is my error.
w124gb
@w124gb
May 05 2016 02:06
help Comparison with the Greater Than Operator
CamperBot
@camperbot
May 05 2016 02:06

:point_right: challenge comparison with the greater than operator [wiki]

Challenge: Comparison with the Greater Than Operator

The greater than operator (>) compares the values of two numbers. If the number to the left is greater than the number to the right, it returns true. Otherwise, it returns false.

Like the equality operator, greater than operator will convert data types of values while comparing.

Examples

 5 > 3   // true
 7 > '3' // true
 2 > 3   // false
'1' > 9  // false

:pencil: read more about challenge comparison with the greater than operator on the FCC Wiki

Diego Mayer
@Chrono79
May 05 2016 02:06
@jerrybaggin it's toLowerCase()
Doug
@Spazcool
May 05 2016 02:06
Anyone have any suggested resources for how one uses JS with HTML?
Lizzy
@DevElisabeth
May 05 2016 02:06
@ztbaltrus Cool!! I'm taking a potato break. My brain is under-carbed LOL
Chase Webb
@jerrybaggin
May 05 2016 02:06
@Chrono79 ahh thanks again
CamperBot
@camperbot
May 05 2016 02:06
jerrybaggin sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 623 | @chrono79 |http://www.freecodecamp.com/chrono79
w124gb
@w124gb
May 05 2016 02:07
I can not for the life of me figure out to get all the requirements green in Comparison with the Greater Than Operator
Diego Mayer
@Chrono79
May 05 2016 02:07
@w124gb paste your code
w124gb
@w124gb
May 05 2016 02:08
whats the way to paste correctly.
Diego Mayer
@Chrono79
May 05 2016 02:08
help format
CamperBot
@camperbot
May 05 2016 02:08

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Coy Sanders
@coymeetsworld
May 05 2016 02:09
interesting @veganlizzy, im going afk too but if you want to post your code again i can see why it passed, it may not be a bug
w124gb
@w124gb
May 05 2016 02:09
function testGreaterThan(val) {
  if (val>12) {  // Change this line
    return "Over 100";
  }

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

  return "10 or Under";
}

// Change this value to test
testGreaterThan(99);
Diego Mayer
@Chrono79
May 05 2016 02:09
@w124gb read the message and what you have inside your ()
Fernando Souza
@fernandosouza
May 05 2016 02:09
@jerrybaggin. Is the array arr an string? It it is try toLowerCase() instead.
w124gb
@w124gb
May 05 2016 02:09
but i have to change the numbers im comparing val to meet different requirements
Diego Mayer
@Chrono79
May 05 2016 02:10
@w124gb 12 is not 100 and 999 is not 10
w124gb
@w124gb
May 05 2016 02:10
ok. ill paste the code with those numbers too.
Nate
@nateReiners
May 05 2016 02:10

help with Profile Lookup. What am I doing Wrong here? ````
//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 lookUpProfile(firstName, prop){
// Only change code below this line
for(i = 0; i < contacts.length; i++) {
if(firstName === contacts[i].firstName) {
for(j = 0; j < 3; j++) {
if(prop === contacts[i][j]) {
return contacts[i].firstName;
}}
} else if(firstName !== contacts[i].firstName) {
return "No such contact"
} else if(prop !== contacts[i]) {
return "No such property"
}
// Only change code above this line
}
}
// Change these values to test your function
lookUpProfile("Akira", "likes");
````

CamperBot
@camperbot
May 05 2016 02:10
no wiki entry for: with profile lookup what am i doing wrong here setupvar 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 lookupprofilefirstname prop only change code below this linefori 0 i contactslength i iffirstname contactsifirstname forj 0 j 3 j ifprop contactsij return contactsifirstname else iffirstname contactsifirstname return no such contact else ifprop contactsi return no such property only change code above this line change these values to test your functionlookupprofileakira likes
Doug
@Spazcool
May 05 2016 02:11
@w124gb what about using && in the if statement?
Nate
@nateReiners
May 05 2016 02:11
Sorry. Help wiht profile lookup what am I doing wrong here?

//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 lookUpProfile(firstName, prop){
// Only change code below this line
for(i = 0; i < contacts.length; i++) {
  if(firstName === contacts[i].firstName) {
    for(j = 0; j < 3; j++) {
      if(prop === contacts[i][j]) {
            return contacts[i].firstName;
      }}
  } else if(firstName !== contacts[i].firstName) {
    return "No such contact"
  } else if(prop !== contacts[i]) {
    return "No such property"
}
// Only change code above this line
}
}
// Change these values to test your function
lookUpProfile("Akira", "likes");
w124gb
@w124gb
May 05 2016 02:12
well i swear i tried it the "correct" way before and it did not work! but this time it did. Live and learn and keep trying... thanks @Spazcool @Chrono79
CamperBot
@camperbot
May 05 2016 02:12
w124gb sends brownie points to @spazcool and @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 282 | @spazcool |http://www.freecodecamp.com/spazcool
:cookie: 624 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
May 05 2016 02:12
@nateReiners this is wrong:
for(j = 0; j < 3; j++) {
if(prop === contacts[i][j]) {
return contacts[i].firstName;
}}
} else if(firstName !== contacts[i].firstName) {
return "No such contact"
} else if(prop !== contacts[i]) {
return "No such property"
}
Nate
@nateReiners
May 05 2016 02:12
wait that is whack. shared wrong code -_- jeeezz lemme get the code i had before I went wonky on it
Fernando Souza
@fernandosouza
May 05 2016 02:13
@nateReiners. What is the error message?
Nate
@nateReiners
May 05 2016 02:14
One moment. Let me re-ask in a clearer way once I get the code I actually meant to share. Sorry for that. One sec...
Diego Mayer
@Chrono79
May 05 2016 02:14
@fernandosouza I doubt there is an error message, the output is wrong I guess
Fernando Souza
@fernandosouza
May 05 2016 02:14
Let me run this code here.
PlusOne77
@amps55
May 05 2016 02:16
Hello,
Diego Mayer
@Chrono79
May 05 2016 02:16
hi
PlusOne77
@amps55
May 05 2016 02:18
I'm trying to install webgoat on my VM running kali Linux and I'm getting this error message: The JVM in $JAVA_HOME isn't version 1.6. Can anyone assist me with this issue?
Nate
@nateReiners
May 05 2016 02:18
So when I run this it only works for returning "No Such Property" for lookUpProfile("Bob", "number") and lookUpProfile("Akira", "Address"). It fails to return "Vos" for lookUpProfile("Kristian", "lastName") and fails to return "[Intriguing Cases", "Violin"] for lookUpProfile("Sherlock", "likes").

//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 lookUpProfile(firstName, prop){
// Only change code below this line
for(i = 0; i < contacts.length; i++) {
  if(contacts[i].firstName === firstName && contacts[i].prop) {
    return contacts[i].prop;
  } else if(firstName !== contacts[i].firstName) {
    return "No such contact";
  } else if(prop !== contacts[i]) {
    return "No such property";
}
// Only change code above this line
}
}
// Change these values to test your function
lookUpProfile("Akira", "likes");
also fails to return an array of Harry's likes
mstankey
@mstankey
May 05 2016 02:19
How do you paste the whole code bock like that?
block*
Diego Mayer
@Chrono79
May 05 2016 02:20
@nateReiners you have to return No such contact once you have searched the whole contacs list
like this
CamperBot
@camperbot
May 05 2016 02:20

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Norvin Burrus
@ndburrus
May 05 2016 02:20
@fernandosouza Welcome !! :)
Nate
@nateReiners
May 05 2016 02:20
@Chrono79 So just put that return outside of my if loop?
Diego Mayer
@Chrono79
May 05 2016 02:21
@nateReiners yes, this is also wrong:
  } else if(firstName !== contacts[i].firstName) {
    return "No such contact";
// I meant this
  } else if(prop !== contacts[i]) {
    return "No such property";
Nate
@nateReiners
May 05 2016 02:22
@Chrono79 should I just have 3 separate if loops going on here?
Diego Mayer
@Chrono79
May 05 2016 02:22
@nateReiners also you can't use dot notation with var names
no, only one loop is enough
Nate
@nateReiners
May 05 2016 02:23
ok, let me have a try. @Chrono79 Thanks! I'll let you know if I need anymore help
CamperBot
@camperbot
May 05 2016 02:23
natereiners sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 625 | @chrono79 |http://www.freecodecamp.com/chrono79
mstankey
@mstankey
May 05 2016 02:24
Ok, so I'm on the "Check for Palindromes" problem and I'm stuck. I removed the spaces, periods, commas, and made everything lowercase, then reversed it and compared the two to see if they're equal or not. But it won't show false ever.
function palindrome(str) {
  // Good luck!
  var noSpace = str.replace(/\s+/g,'');
  var noComma = noSpace.replace(/,/g,'');
  var noPeriod = noComma.replace(/./g,'');
  var lower = noPeriod.toLowerCase();
  var rev = lower.split('').reverse().join('');
  if (rev === lower){
    return true;
  } else {
    return false;
  }
}
palindrome("eye");
What am I doing wrong?
Diego Mayer
@Chrono79
May 05 2016 02:24
@nateReiners no problem, read again the instructions and you'll figure out how your ifs should be written
@mstankey your regex
mstankey
@mstankey
May 05 2016 02:25
@Chrono79 All of it?
Diego Mayer
@Chrono79
May 05 2016 02:25
you have to keep letters and numbers, so why not [^a-z0-9]/gi
[^ means not the following things
a-z0-9 are letters and numbers
g is global, don't return just the first match
i is case insensitive (if you don't use it, you have to add A-Z to the inside of the brackets
mstankey
@mstankey
May 05 2016 02:27
I forgot about the carot
Thank you! @Chrono79
CamperBot
@camperbot
May 05 2016 02:27
mstankey sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 626 | @chrono79 |http://www.freecodecamp.com/chrono79
mstankey
@mstankey
May 05 2016 02:28
While what you showed me is much more efficient, what about mine was broken? just for learning purposes
Diego Mayer
@Chrono79
May 05 2016 02:28
@mstankey the . in regex means any char, if you want it to mean dot you have to escape it like this \.
also you were missing a lot of other chars like (!? etc. when there are so many, the better you can do is negate a few instead
mstankey
@mstankey
May 05 2016 02:29
Ah, that makes sense. Thank you @Chrono79
CamperBot
@camperbot
May 05 2016 02:29
mstankey sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: mstankey already gave chrono79 points
Thomas Mullen
@t-mullen
May 05 2016 02:32
Help a dev out? var timeString = preceding.match([0-9]{1,2}:[0-9]{2}); gives me Uncaught SyntaxError: missing ) after argument list
CamperBot
@camperbot
May 05 2016 02:32
no wiki entry for: a dev out var timestring precedingmatch0-9120-92 gives me uncaught syntaxerror missing after argument list
Thomas Mullen
@t-mullen
May 05 2016 02:33
Thanks for trying CamperBot
blueyedfox
@blueyedfox
May 05 2016 02:33

Hi! I'm a little confused with the Factorialize a Number waypoint here. When I enter the numbers from the test into the function, I get the right results (120 for 5 etc.), but the tests don't pass anyway. Here's a screenshot.

alt

Diego Mayer
@Chrono79
May 05 2016 02:34
@RationalCoding aren't you forgetting the backslashes?
Thomas Mullen
@t-mullen
May 05 2016 02:34
I need to escape everything, don't I?
Daniel Guenther
@danthemango
May 05 2016 02:35
@blueyedfox what's up with that ", 1" there? it's got a red line under it
Diego Mayer
@Chrono79
May 05 2016 02:35
@RationalCoding I mean the other slashes
var timeString = preceding.match(/[0-9]{1,2}:[0-9]{2}/);
Thomas Mullen
@t-mullen
May 05 2016 02:36
oh beauty. Totally forgot about needing those
Thanks @Chrono79
CamperBot
@camperbot
May 05 2016 02:36
rationalcoding sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 627 | @chrono79 |http://www.freecodecamp.com/chrono79
Coy Sanders
@coymeetsworld
May 05 2016 02:36
@blueyedfox try defining arr inside the function
Diego Mayer
@Chrono79
May 05 2016 02:36
also, that regex isn't right
@RationalCoding
var timeString = preceding.match(/^(1[0-2]|[0-9]):[0-5][0-9]$/); try this one
blueyedfox
@blueyedfox
May 05 2016 02:36
@danthemango the red line says semicolon missing, but there should be one there, as far as i understood from the reduce array waypoint
Daniel Guenther
@danthemango
May 05 2016 02:37
it seems extraneous, why did you put that there?
Uziel Pineda
@uzielpineda
May 05 2016 02:38
This message was deleted
blueyedfox
@blueyedfox
May 05 2016 02:38
@coymeetsworld that way everything works. except for the zero which delivers a "TypeError: Type Error"
Coy Sanders
@coymeetsworld
May 05 2016 02:39
the challenges don't like global variables @blueyedfox
for 0 you need to make a special case
to return 1
when you put arr inside the function do rest of tests pass?
Anurag Lahon
@anuraglahon16
May 05 2016 02:39
how to repeat a string...how many times any idea...by using math??
blueyedfox
@blueyedfox
May 05 2016 02:40
@coymeetsworld yes, thanks, i made the arr local, now all the tests pass except for the zero.
what makes the zero special?
CamperBot
@camperbot
May 05 2016 02:40
blueyedfox sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 734 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 05 2016 02:40
its just what 0! is
Anurag Lahon
@anuraglahon16
May 05 2016 02:40
@blueyedfox did u get d answer?
lorenzopieri
@lorenzopieri
May 05 2016 02:41
anyone for US Validation with Regex?
Coy Sanders
@coymeetsworld
May 05 2016 02:41
i forget why exactly but there is some interesting math behind it
lorenzopieri
@lorenzopieri
May 05 2016 02:41
I'm pretty much gonna destroy the PC
Daniel Guenther
@danthemango
May 05 2016 02:41
@blueyedfox 0! = 1 in real life, but in your case it doesn't exactly work
Anurag Lahon
@anuraglahon16
May 05 2016 02:41
@coymeetsworld math is behind it
Coy Sanders
@coymeetsworld
May 05 2016 02:41
@blueyedfox if you see 1 or 0 just return one
Diego Mayer
@Chrono79
May 05 2016 02:42
@RationalCoding for 24hs format: var timeString = preceding.match(/^(2[0-3]|1?[0-9]):[0-5][0-9]$/);
Randall Fine
@randallfine
May 05 2016 02:43
I just solved Chunky Monkey My solutions are correct vs the tests but for some reason it's not passing. posting my code here before I report it as a bug to make sure it's not my code.
var arr2= [];
function chunkArrayInGroups(arr, size) {
  // Break it up.
  while (arr.length > 0){
  arr2.push(arr.splice(0, size));
  }
  return arr2;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3);
Diego Mayer
@Chrono79
May 05 2016 02:44
@Randallfine why you declare arr2 outside your function?
Randall Fine
@randallfine
May 05 2016 02:44
Is that not correct?
Uziel Pineda
@uzielpineda
May 05 2016 02:45
Hey guys stuck on Checkpoint record collection, does anyone know what I'm missing?
https://www.freecodecamp.com/challenges/record-collection
function updateRecords(id, prop, value) {

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





  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Diego Mayer
@Chrono79
May 05 2016 02:45
try to do it inside
blueyedfox
@blueyedfox
May 05 2016 02:45
@coymeetsworld do you mean i literally write an if statement about the zero?
Coy Sanders
@coymeetsworld
May 05 2016 02:45
yes
Diego Mayer
@Chrono79
May 05 2016 02:45
@lorenzopieri I can help you
Coy Sanders
@coymeetsworld
May 05 2016 02:45
or for 1 if you want, your code will work with 1 but why bother if you can just return 1?
actually can do it for 2 also
but main thing is doing it for 0, your code won't work for 0
blueyedfox
@blueyedfox
May 05 2016 02:46
wow, i'd never, ever, ever have thought about that.
Randall Fine
@randallfine
May 05 2016 02:46
Thank you @Chrono79 .
CamperBot
@camperbot
May 05 2016 02:46
randallfine sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 628 | @chrono79 |http://www.freecodecamp.com/chrono79
Coy Sanders
@coymeetsworld
May 05 2016 02:47
yeah its an edge condition @blueyedfox
Randall Fine
@randallfine
May 05 2016 02:47
I thought the function would still use the var even if it was global
Coy Sanders
@coymeetsworld
May 05 2016 02:47
some times have to think about them
Diego Mayer
@Chrono79
May 05 2016 02:47
@Randallfine sometimes the tests check not only the result
blueyedfox
@blueyedfox
May 05 2016 02:47
@coymeetsworld thanks so much, everything's working now! ^)
CamperBot
@camperbot
May 05 2016 02:47
blueyedfox sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: blueyedfox already gave coymeetsworld points
dontchaknow
@dontchaknow
May 05 2016 02:48
function convertHTML(str) {
    var strCopy;
    var jscriptChars = [/&/g, /</g, />/g, /\"/g, /'/g];
    var htmlChars = ["&amp", "&lt;", "&gt;", "&quot;", "&apos;"];
    for (var i = 0; i < jscriptChars.length; i++) {
        strCopy = str.replace(jscriptChars[i], htmlChars[i]);
    }
    return strCopy;
}
not sure why this isn't working
blueyedfox
@blueyedfox
May 05 2016 02:48
@anubhavmundra yes
Coy Sanders
@coymeetsworld
May 05 2016 02:48
np @blueyedfox, just keep in mind the challeneges don't typically like global variables
dontchaknow
@dontchaknow
May 05 2016 02:48
I completed the challenge with a switch statement but this seems more concise but not working.
Coy Sanders
@coymeetsworld
May 05 2016 02:48
unless they define it themselves of course
so try to avoid them if you can, its also good programming practice to avoid global variables when you can
Dylan
@dhcodes
May 05 2016 02:49
@dontchaknow you need a ; at the end of &amp for one
but i'm not sure otherwise why it wouldn't
blueyedfox
@blueyedfox
May 05 2016 02:49
@coymeetsworld that makes sense, i'll try to keep an eye out for that
dontchaknow
@dontchaknow
May 05 2016 02:49
=(
Dylan
@dhcodes
May 05 2016 02:49
cool way of doing it for sure
Diego Mayer
@Chrono79
May 05 2016 02:50
@dontchaknow you don't have to escape "
dontchaknow
@dontchaknow
May 05 2016 02:51
I added ; and removed the escape. still not working though.
Blake Harris
@bharris62
May 05 2016 02:53
i am trying to do the local weather app, and my browsers keep blocking open weather and saying its insecure, how do i fix that?
dontchaknow
@dontchaknow
May 05 2016 02:53
it's something about the loop that's off because I tried the hardcoded version just as a test and it works
Diego Mayer
@Chrono79
May 05 2016 02:53
@dontchaknow you have to use always the same var inside the loop
if you use str, you loose the changes
or you can drop strCopy and use always str
dontchaknow
@dontchaknow
May 05 2016 02:54
i thought assigning a copy of str to strCopy would store the changes
using str alone and return str doesnt work either
Diego Mayer
@Chrono79
May 05 2016 02:55
@dontchaknow you are in the next loop overwriting it
function convertHTML(str) {
    var jscriptChars = [/&/g, /</g, />/g, /"/g, /'/g];
    var htmlChars = ["&amp;", "&lt;", "&gt;", "&quot;", "&apos;"];
    for (var i = 0; i < jscriptChars.length; i++) {
        str = str.replace(jscriptChars[i], htmlChars[i]);
    }
    return str;
}

convertHTML("Hamburgers < Pizza < Tacos");
try it
dontchaknow
@dontchaknow
May 05 2016 02:56
ah that works
i wonder why strCopy doesn't
because I do overwrite it 5 times but only the changed version should stick
Diego Mayer
@Chrono79
May 05 2016 02:57
because you were overwriting it the next step with str and another replace, str remained the same
dontchaknow
@dontchaknow
May 05 2016 02:58
oh yeah I see what you mean
thanks
Diego Mayer
@Chrono79
May 05 2016 02:58
no problem
good night
Jevaughn Vance
@jvans7
May 05 2016 03:04
hey guys recently finished the basic javaScipt lessons but still a bit shaky any videos recommendation or any other stuff? thanks
Billy Ralph
@bralph20
May 05 2016 03:05
Screen Shot 2016-05-04 at 8.03.35 PM.png
Can someone help me please? I'm stuck with this switch.
Jevaughn Vance
@jvans7
May 05 2016 03:07
what the name of the lesson @bralph20
Billy Ralph
@bralph20
May 05 2016 03:08
@jvans7 Adding a default option in Switch statements
Jevaughn Vance
@jvans7
May 05 2016 03:09
@bralph20 you code looks good but try removing the brackets
on your conditions
no wait
hold on!
y is there a case d
Billy Ralph
@bralph20
May 05 2016 03:13
I don't know. I got rid of case d and removed all the brackets but its still not working.
Jevaughn Vance
@jvans7
May 05 2016 03:13
i know it wouldn't work
from condition a to c your are good
but what happens at the end of a switch statement?
mstankey
@mstankey
May 05 2016 03:15

Ok, so now I'm on the "Title Case a Sentence" and decided to do it with regex, but can't figure out now to get the sentence with the ' to work correctly.

function titleCase(str) {
  return str.replace(/\w+/g,function(text){
    return text.charAt(0).toUpperCase() + text.substr(1).toLowerCase();
  });
}
titleCase("I'm a little tea pot");

What can I add to make it detect the ' correctly?

Jevaughn Vance
@jvans7
May 05 2016 03:16
if there's not matching case statements are found what happens?
Glenn
@gmerdan
May 05 2016 03:16
This message was deleted
CamperBot
@camperbot
May 05 2016 03:16
:bulb: to format code use backticks! ``` more info
Glenn
@gmerdan
May 05 2016 03:17
I am relatively new to this and am struggling why this isnt working. Can someone provide some insight? This code does not render as true when var str and target should.
  if (str.substr(str.length - target.length, target) == target) {
    return true;
       } else {
       return false;
       }
Billy Ralph
@bralph20
May 05 2016 03:17
@jvans7 I have no idea. I'm trying to figure that out
Jevaughn Vance
@jvans7
May 05 2016 03:18
@bralph20 no problem I will help you get there
buiphuking
@buiphuking
May 05 2016 03:18
hi guys, when we design a web, just front-end, we use javascript instead html better or html better ?
Jevaughn Vance
@jvans7
May 05 2016 03:18
read you instructions and look at the example and tell what you see?
Billy Ralph
@bralph20
May 05 2016 03:19
@jvans7 I need to add a default statement. I'm just not sure how to write that.
I found this on w3schools
default:
text = "Looking forward to the Weekend";
Jevaughn Vance
@jvans7
May 05 2016 03:21
yes correct a default statement is needed at the end of the switch statement
and yes it's written just like that
Billy Ralph
@bralph20
May 05 2016 03:21

Cool. The default statement I wrote is

default:
text = "stuff";

but thats not working.

This is what I'm trying to solve
Write a switch statement to set answer for the following conditions:
"a" - "apple"
"b" - "bird"
"c" - "cat"
default - "stuff"
Jevaughn Vance
@jvans7
May 05 2016 03:22
replace text with answer
answer=
Billy Ralph
@bralph20
May 05 2016 03:23
I got it! Thank you so much @jvans7
CamperBot
@camperbot
May 05 2016 03:23
bralph20 sends brownie points to @jvans7 :sparkles: :thumbsup: :sparkles:
:cookie: 252 | @jvans7 |http://www.freecodecamp.com/jvans7
Jevaughn Vance
@jvans7
May 05 2016 03:23
just like you did with the other conditions
no problem I know it's tough
Billy Ralph
@bralph20
May 05 2016 03:24
Seriously!
Glenn
@gmerdan
May 05 2016 03:24
Anyone who was looking into my question earlier. I resolved it by removing the str.substr from the if statement. I guess I was trying to do too much in the if statement...but I still dont understand why it wouldnt work.
whoa nevermind my mistake!
mstankey
@mstankey
May 05 2016 03:26

Is there a way to make regex skip apostrophes? it's not working correctly in my code.

function titleCase(str) {
  return str.replace(/\w+/g,function(text){
    return text.charAt(0).toUpperCase() + text.substr(1).toLowerCase();
  });
}
titleCase("I'm a little tea pot");

What can I add to make it detect or skip the ' correctly?

mstankey
@mstankey
May 05 2016 03:31
In case anyone is curious. I figured it out. I needed to add brackets to the regex and add an ' after the \w.
function titleCase(str) {
  return str.replace(/[\w']+/g,function(text){
    return text.charAt(0).toUpperCase() + text.substr(1).toLowerCase();
  });
}

titleCase("I'm a little tea pot");
Li
@NLStom
May 05 2016 03:35
I am really confuse with regex...
mstankey
@mstankey
May 05 2016 03:35
It's tough
Li
@NLStom
May 05 2016 03:36
I was doing search and replace... I just other method to do that rather than use regex... I am such coward lol
use
mstankey
@mstankey
May 05 2016 03:36
I started to with this one, but there were just too many lines. regex can make it like half the lines
Li
@NLStom
May 05 2016 03:44
String.prototype.substr() in the MDN , but when we use the function we use String.substr()
what is prototype here stand for?
Javier
@sh1g
May 05 2016 03:58

Hello all!

Why does this give me a -1. Shouldn't it exist

function truthCheck(collection, pre) {
    console.log(collection.indexOf(pre)); // -1
}

truthCheck([{"single": "yes"}], "single");
ChloeHewitt
@ChloeHewitt
May 05 2016 04:01
Does anyone remember this challenge?
// Setup
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "H"; // Fix Me
so stuck
Coy Sanders
@coymeetsworld
May 05 2016 04:02
yeah I do @ChloeHewitt
Li
@NLStom
May 05 2016 04:02
@sh1g yo, collection it's a object, so it return false
Coy Sanders
@coymeetsworld
May 05 2016 04:02
that challenge is to show you that a String is immutable, meaning you can't change parts of it, so that last line doesn't work
what you need to do is set myStr to a new value, not just the first character
Li
@NLStom
May 05 2016 04:03
@sh1g indexof only work on string I belive
ChloeHewitt
@ChloeHewitt
May 05 2016 04:03
so confuuuusing @coymeetsworld haha
Coy Sanders
@coymeetsworld
May 05 2016 04:03
which part?
ChloeHewitt
@ChloeHewitt
May 05 2016 04:04
I don't know it just doenst click with me, I read the answer code and I didnt really get that either haha
thanks anyway!
Coy Sanders
@coymeetsworld
May 05 2016 04:04
did you look at the explanation on the challenge?
Javier
@sh1g
May 05 2016 04:04
@NLStom Thank you! that explains it =D
CamperBot
@camperbot
May 05 2016 04:04
sh1g sends brownie points to @nlstom :sparkles: :thumbsup: :sparkles:
:cookie: 286 | @nlstom |http://www.freecodecamp.com/nlstom
Coy Sanders
@coymeetsworld
May 05 2016 04:04
basically you can't alter parts of the string like that
"individual characters of a string literal cannot be changed"
if you want myStr to be Hello World you have to assign it to "Hello World"
can't change a single character
Li
@NLStom
May 05 2016 04:05
hey guys... I think I should be right for this one...
ChloeHewitt
@ChloeHewitt
May 05 2016 04:06
So would this be right?

// Setup
var myStr = "Jello World";

// Only change code below this line

var myStr = "Hello World";

myStr[0] = "H"; // Fix Me
Li
@NLStom
May 05 2016 04:07
Screen Shot 2016-05-05 at 12.04.12 PM.png
Coy Sanders
@coymeetsworld
May 05 2016 04:07
yes but remove that last line @ChloeHewitt
basically that doesn't work, which is the point
Li
@NLStom
May 05 2016 04:07
This message was deleted
Coy Sanders
@coymeetsworld
May 05 2016 04:08
you have to assign myStr to "Hello World" all together, like you did in the 2nd line
3rd line will give you an error
Billy Halim
@billyhalim
May 05 2016 04:08
Hello, may I ask about Youtube API for Javascript here ?
Li
@NLStom
May 05 2016 04:08
Screen Shot 2016-05-05 at 12.07.47 PM.png
ChloeHewitt
@ChloeHewitt
May 05 2016 04:08
thanks! @coymeetsworld
CamperBot
@camperbot
May 05 2016 04:08
chloehewitt sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 735 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 05 2016 04:09
no problem @ChloeHewitt, thats what they mean when they say a String is immutable, can't modify it in any way
but what you can do instead is assign the variable to a new string with what you want it to say
you don't want to hardcode "gl" into your code @NLStom
Li
@NLStom
May 05 2016 04:10
@coymeetsworld I know it's kind of cheating ...
@coymeetsworld but I thought we only care about the first work right?
word*
Coy Sanders
@coymeetsworld
May 05 2016 04:11
there's only one word you translate
per call
Li
@NLStom
May 05 2016 04:11
vowel sound is AEIOU
Coy Sanders
@coymeetsworld
May 05 2016 04:12
what you want to do @NLStom is if the word doesn't start with a vowel, you want to move all consonants from the beginning up to the vowel and put them at the end and add 'ay' to it
so glove you would remove gl (next char is o), put it at the end, and add ay, so ove + gl + ay
paragraphs would be aragraphs + p + ay
Li
@NLStom
May 05 2016 04:13
my question is what is a consonants, I thought consonants is the first letter start with not vowel(aeiou)...
@coymeetsworld never thought it can be composed by two letters...
Coy Sanders
@coymeetsworld
May 05 2016 04:13
yes thats what a consonant is, a non-vowel
no a consonant is a single character that is non-vowel
what you have to do is KEEP removing consonants until you reach a vowel
Li
@NLStom
May 05 2016 04:14
@coymeetsworld oh I see!!!
I know the problem now ! thanks . I didn't understand the problem correctly let me go change my code hahaha
Coy Sanders
@coymeetsworld
May 05 2016 04:15
yeah so like the word "strobe" you would remove, s, t, r, then at o you stop
so it would be obe + str + ay
ok gl
Ibukun
@ioluwayo
May 05 2016 04:19
hey guys, in need of some help with a javascript challenge
Alexis
@alexisgcn
May 05 2016 04:22
@ioluwayo show it
Ibukun
@ioluwayo
May 05 2016 04:22
do i need more than 1 parameter in my fucntion if the function could be called with more than 1 argument. Pretty much, could my only parameter be an array containing all the argument values
@alexisgcn 1 sec
Screen Shot 2016-05-05 at 12.23.26 AM.png
got it? I am not yet farmiliar with this chat thing.
Martialis39
@Martialis39
May 05 2016 04:26
hello all!
good morning
Alexis
@alexisgcn
May 05 2016 04:26
use ```js
write your code inside and below your code write ```
Ibukun
@ioluwayo
May 05 2016 04:28
@alexisgcn okay, so i should write my code and then include``` below it?
Alexis
@alexisgcn
May 05 2016 04:30
yes that is the way you can paste your code here
Ibukun
@ioluwayo
May 05 2016 04:33
okay. i will make some changes to my code and then paste it here.Thanks a bunch.
Javier
@sh1g
May 05 2016 04:38
I think Everything Be True is broken. I even tested by using the solution and it won't work.
so I guess I have to hardcode to continue
Martialis39
@Martialis39
May 05 2016 04:40
help sorted union
CamperBot
@camperbot
May 05 2016 04:40

:point_right: algorithm sorted union [wiki]

Problem Explanation:

  • The program has to return a new array of unique values from two original arrays in the order they show up. So there is not sorting required, and no duplicates.
:pencil: read more about algorithm sorted union on the FCC Wiki
Javier
@sh1g
May 05 2016 04:43
I realized my mistake. I wasn't looking for null
Li
@NLStom
May 05 2016 04:48
@coymeetsworld I did it
Tatiana Perry
@tjperry07
May 05 2016 04:49

I have what is probably a silly question: https://www.freecodecamp.com/challenges/escape-sequences-in-strings How did you guys solve this? I guess I don't understand what it's asking. I have

var myString = "\\b \t \t \r \n";

Coy Sanders
@coymeetsworld
May 05 2016 04:49
nice job @NLStom
Ibukun
@ioluwayo
May 05 2016 04:49

function destroyer(arr) {
// i am trying to remove all the elements from
// arr[0] that are of the same value as the other
//arguments.
var refValues=[];
for (i=1;i<arr.length;i++)
{
refValues[i-1]=arr[i];
}
//now refValues contains the other arguments.
var firstArg=arr[0]; //this guy now contains the arr to be fixed.
var result;
result=firstArg.filter(); // how do I use this filter method to compare the
// contents of firstArg and refValues?
return result;
}

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

Li
@NLStom
May 05 2016 04:49
Screen Shot 2016-05-05 at 12.48.05 PM.png
Ibukun
@ioluwayo
May 05 2016 04:50

@alexisgcn function destroyer(arr) {
// i am trying to remove all the elements from
// arr[0] that are of the same value as the other
//arguments.
var refValues=[];
for (i=1;i<arr.length;i++)
{
refValues[i-1]=arr[i];
}
//now refValues contains the other arguments.
var firstArg=arr[0]; //this guy now contains the arr to be fixed.
var result;
result=firstArg.filter(); // how do I use this filter method to compare the
// contents of firstArg and refValues?
return result;
}

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

Coy Sanders
@coymeetsworld
May 05 2016 04:50
nice
Alexis
@alexisgcn
May 05 2016 04:51
@ioluwayo you missed ```js at the beginning
Ibukun
@ioluwayo
May 05 2016 04:51

```function destroyer(arr) {
// i am trying to remove all the elements from
// arr[0] that are of the same value as the other
//arguments.
var refValues=[];
for (i=1;i<arr.length;i++)
{
refValues[i-1]=arr[i];
}
//now refValues contains the other arguments.
var firstArg=arr[0]; //this guy now contains the arr to be fixed.
var result;
result=firstArg.filter(); // how do I use this filter method to compare the
// contents of firstArg and refValues?
return result;
}

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

Coy Sanders
@coymeetsworld
May 05 2016 04:51
hi @tjperry07 you're close
Ibukun
@ioluwayo
May 05 2016 04:51
function destroyer(arr) {
  // i am trying to remove all the elements from
  // arr[0] that are of the same value as the other
  //arguments.
  var refValues=[];
  for (i=1;i<arr.length;i++)
    {
      refValues[i-1]=arr[i];
    }
  //now refValues contains the other arguments.
  var firstArg=arr[0]; //this guy now contains the arr to be fixed.
  var result;
  result=firstArg.filter(); // how do I use this filter method to compare the
                            // contents of firstArg and refValues? 
  return result;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Coy Sanders
@coymeetsworld
May 05 2016 04:51
just first escape sequence is wrong, instead of backspace do backslash
Ibukun
@ioluwayo
May 05 2016 04:51
@alexisgcn
@alexisgcn got it now, thanks!!!
function destroyer(arr) {
  // i am trying to remove all the elements from
  // arr[0] that are of the same value as the other
  //arguments.
  var refValues=[];
  for (i=1;i<arr.length;i++)
    {
      refValues[i-1]=arr[i];
    }
  //now refValues contains the other arguments.
  var firstArg=arr[0]; //this guy now contains the arr to be fixed.
  var result;
  result=firstArg.filter(); // how do I use this filter method to compare the
                            // contents of firstArg and refValues? 
  return result;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
CamperBot
@camperbot
May 05 2016 04:52
:cookie: 284 | @alexisgcn |http://www.freecodecamp.com/alexisgcn
ioluwayo sends brownie points to @alexisgcn :sparkles: :thumbsup: :sparkles:
Li
@NLStom
May 05 2016 04:53
@coymeetsworld I go check the answer on wiki... I have no hard time to understand what their code doing....
Martialis39
@Martialis39
May 05 2016 04:53
help convert html entities
CamperBot
@camperbot
May 05 2016 04:53

:point_right: algorithm convert html entities [wiki]

Problem Explanation:

  • You have to create a program that will convert HTML entities from string to their corresponding HTML entities. There are only a few so you can use different methods.

:pencil: read more about algorithm convert html entities on the FCC Wiki

Li
@NLStom
May 05 2016 04:53
@coymeetsworld should I be worry about...
Coy Sanders
@coymeetsworld
May 05 2016 04:53
worry about what? not understanding it?
Li
@NLStom
May 05 2016 04:54
@coymeetsworld yes...
@coymeetsworld apparently they use much less code to do the same job...
Coy Sanders
@coymeetsworld
May 05 2016 04:54
worry is probably a strong word, but you should try and understand what's going on
well that's because they use some functional programming which you learn later
thats the problem with using their code, you may not be in a place to understand what's going on, there are other ways to solve the problems
Li
@NLStom
May 05 2016 04:55
@coymeetsworld functional programming.... I have never heard about it...
Coy Sanders
@coymeetsworld
May 05 2016 04:55
try to understand as much as you can, because if you keep taking shortcuts just to get through the challenges you're going to have a harder time especially at the later stages
yeah it comes later, its some powerful functions you can use later on
Li
@NLStom
May 05 2016 04:56
@coymeetsworld Ok, Thanks a lot. You are a wonderful person~ I will move on and at same time try to read their code again.
CamperBot
@camperbot
May 05 2016 04:56
nlstom sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 737 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 05 2016 04:57
yeah np @NLStom, not the worst thing in the world to not understand everything but just don't try to make a habit out of it
tekac
@tekac
May 05 2016 05:23

function factorialize(num) {
  var num1 = 1 * 2 * 3 * 4 * 5;
  return num1;
}

factorialize(5);
it wanted me to return the factorial of the number provided. which is 5. so I did. now its giving me that 10 20 and 0 should return various things, but I only have 5
Dhrubo Hasan
@dhrubo55
May 05 2016 05:23
can someone help me with the profile lookup problem. don't know what is wrong here.

//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 lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0; i<contacts.length; i++){
if(contacts[i][firstName]==firstName){
if(contacts[i].hasOwnProperty(prop)){
return contacts[prop];
}
}
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");

tekac
@tekac
May 05 2016 05:24
help format
CamperBot
@camperbot
May 05 2016 05:24

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Dhrubo Hasan
@dhrubo55
May 05 2016 05:29

//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 lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0; i<contacts.length; i++){
  if(contacts[i][firstName]==firstName){
    if(contacts[i].hasOwnProperty(prop)){
      return contacts[prop];
    }
  }
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
can someone help me. can not seem to get it
Coy Sanders
@coymeetsworld
May 05 2016 05:30
your return statement is wrong
also you don't account for the "No such property" or "No such contact" situation
Dhrubo Hasan
@dhrubo55
May 05 2016 05:31
how to account for no such property
Coy Sanders
@coymeetsworld
May 05 2016 05:31
if it doesn't have the property then, there is no such property
Jevaughn Vance
@jvans7
May 05 2016 05:33
@coymeetsworld I've completed the basic javaScript section but i think i'm still shakey. Any video tutorials recommendations to help better understand or anything other stuff. Thanks
CamperBot
@camperbot
May 05 2016 05:33
jvans7 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 738 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 05 2016 05:34
you'll learn more as you do algorithms @jvans7
and the projects
Jevaughn Vance
@jvans7
May 05 2016 05:35
algorithms is giving me a nightmare already i'm on the second one lol
Coy Sanders
@coymeetsworld
May 05 2016 05:36

I haven't gotten into these resources yet so I can't necessarily recommend them, but I have them bookmarked and will probably go through em after I finish all the projects:
http://eloquentjavascript.net/
https://github.com/getify/You-Dont-Know-JS
http://www.javascriptenlightenment.com/JavaScript_Enlightenment.pdf

Some of them are mentioned on the FCC blog "25 Free resources for new JavaScript Developers"
https://medium.freecodecamp.com/25-free-resources-for-new-javascript-developers-11342cf1f4df#.4iesn91wd

yeah the algorithms are challenging
MDN is your friend
Jevaughn Vance
@jvans7
May 05 2016 05:37
thanks man
Coy Sanders
@coymeetsworld
May 05 2016 05:37
np good luck on them
tekac
@tekac
May 05 2016 05:37
@jvans7 I'm with you man!! I'm on factorialize
Jevaughn Vance
@jvans7
May 05 2016 05:38
@tekac i feel you man. alot of research for ideas
Eli
@elisspace
May 05 2016 05:46
Okay, rookie question: if you see TypeError: Cannot set property 'prop' of undefined
what have I done wrong?
Chris Cullen
@123xylem
May 05 2016 05:47

Is there a way of me not reversing string when I create Rev STR? It means I have to rereverse string again at the bottom which is silly :) ```js
function palindrome(str) {
str =str.toLowerCase().replace(/[\W_]/g, ''); //make str lowercase and take out non a-z
str= str.split(""); //split string into array of chars

var revstr= str.reverse(); //create new array reversed

revstr =revstr.join(); // make that array a string to compare to original string
str =str.reverse().join(); //

if(str === revstr){
return true;}

else {return false;}

return str;
}

palindrome("nope");
```

function palindrome(str) {
str =str.toLowerCase().replace(/[\W_]/g, ''); //make str lowercase and take out non a-z
str= str.split(""); //split string into array of chars
var revstr= str.reverse(); //create new array reversed
revstr =revstr.join(); // make that array a string to compare to original string
str =str.reverse().join(); //
if(str === revstr){
return true;}
else {return false;}
return str;
}
palindrome("nope");
Is there a way of me not reversing str when I create revstr? ^^^
Im not sure why str gets reversed when I create revstr
Robert Richey
@0x0936
May 05 2016 06:03
@123xylem once you have a sanitized string - first line in your function - you can simply return the result of comparing str with it's reverse (as a hint)
Martialis39
@Martialis39
May 05 2016 06:04
hello all, quick question about Spinal Tap Case
whats a good way to check fo rcapital letter?
DJ
@qualitymanifest
May 05 2016 06:05
@123xylem str isn't getting reversed when you create revstr. you're explicitly doing it here: str =str.reverse().join()
Chris Cullen
@123xylem
May 05 2016 06:06
@qualitymanifest If you take out that last bit str =str.reverse().join() and return string youll see its reversed
That was me rereversing it
Mariya
@mariyadiminsky
May 05 2016 06:07
Anyone looking to learn ES6 consider following this series :) https://medium.freecodecamp.com/learn-es6-the-dope-way-i-const-let-var-ae828580472b#.fd4f3b82y
DJ
@qualitymanifest
May 05 2016 06:08

@123xylem ah. yes. i've been away from the computer for too long - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse

The reverse method transposes the elements of the calling array object in place, mutating the array, and returning a reference to the array.

so follow @0x0936 's advice - compare the clean string with itself reversed. cleanStr === cleanStr.split('').reverse().join(''); (will return true or false depending on whether they match) @123xylem
Reginald Holt
@Reggiereg83
May 05 2016 06:13

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

// Do not change code below this line

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

is that a right code???
a should be defined and have a value of 6 thats the question
Coy Sanders
@coymeetsworld
May 05 2016 06:14
whats the challenge?
Reginald Holt
@Reggiereg83
May 05 2016 06:14
help plzz i've been stuck on this for days lol
CamperBot
@camperbot
May 05 2016 06:14
no wiki entry for: plzz ive been stuck on this for days lol
Reginald Holt
@Reggiereg83
May 05 2016 06:15
Understanding Uninitialized Variables
Martialis39
@Martialis39
May 05 2016 06:15
@coymeetsworld Whats the challenge bro :)
Coy Sanders
@coymeetsworld
May 05 2016 06:16
@Reggiereg83 you want a to equal 6 after the equations are done
and b to equal 15
after all the code is done
so what you have a would equal 7 and b would equal 20
you need to change a so that a+1 =6
and b so that b+5 will equal 15
c is ok
Reginald Holt
@Reggiereg83
May 05 2016 06:18
thanks @coymeetsworld
CamperBot
@camperbot
May 05 2016 06:18
reggiereg83 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 739 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 05 2016 06:18
no problem @Reggiereg83
make sense?
Reginald Holt
@Reggiereg83
May 05 2016 06:18
yup sure did
Coy Sanders
@coymeetsworld
May 05 2016 06:18
cool
Sergio
@campossrg
May 05 2016 06:20

Hello,

I need some help with "Profile lookup". I can´t finish it.

I can not find where exactly I´m having the problem.

Does someone see where it is?

Thank you!

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

// Change these values to test your function
lookUpProfile("Akira", "likes");

How do I copy the screen here to be readed?
Coy Sanders
@coymeetsworld
May 05 2016 06:21
help format
CamperBot
@camperbot
May 05 2016 06:21

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Coy Sanders
@coymeetsworld
May 05 2016 06:21
@campossrg you have a few problems with your script
first you need to find a contact with the name you're looking for first
then from there see if that contact has the property you're looking for (use the hasOwnProperty method)
start with that
Sergio
@campossrg
May 05 2016 06:23

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

// Change these values to test your function
lookUpProfile("Akira", "likes");`

Oh! Okey! You are right
I´ll use hasOwnProperty method
Thank you for your tips @coymeetsworld
CamperBot
@camperbot
May 05 2016 06:24
campossrg sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 740 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 05 2016 06:24
np @campossrg good luck
Sergio
@campossrg
May 05 2016 06:29
function lookUpProfile(firstName, prop){
// Only change code below this line
  if(contacts.hasOwnProperty(firstName)){
    for(var j=0; j<contacts[firstName].length; j++){
      if(contacts[firstName][j]==prop) return contacts[firstName][j];
    }
  }
  else return "No such property";
  return "No such contact";
// Only change code above this line
}
Hi again! Is possible to use contacts[firstName] to access the full lenght of propertys?
Chris Cullen
@123xylem
May 05 2016 06:33
@qualitymanifest thnx @0x0936
CamperBot
@camperbot
May 05 2016 06:33
123xylem sends brownie points to @qualitymanifest and @0x0936 :sparkles: :thumbsup: :sparkles:
:star2: 1152 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
:star2: 1300 | @0x0936 |http://www.freecodecamp.com/0x0936
Hung Truong
@hungtruong97
May 05 2016 06:41
function largestOfFour(arr) {
  // You can do this!

  var array = [];
  var i = 0;
  while (i < arr.length) {
    for (j=1 ; j<arr[i].length; j++) {
      largest = arr[i][0];
      if (arr[i][j] > largest) {
        largest = arr[i][j];
      } else largest = largest;


    } 
    array.push(largest);
    i++;
  }

  return array;
}
James Becker
@james-becker
May 05 2016 06:41
Has anyone finished Smallest Common Multiple Bonfire?
And can maybe break down the solution for me? I'm having a hard time understanding the logic...
Chris Cullen
@123xylem
May 05 2016 06:41
Was I anywhere near getting this right to return largest number of arraywith map? I think I will just use forloops now but Im curious
function largestOfFour(arr) {
  var largest=0;
  for (i=0;i<arr.length;i++){
    for(j=0;j<arr[i].length;j++){
largest = arr.map(function(size){
                      return size.length;
                      });}}
  return largest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Hung Truong
@hungtruong97
May 05 2016 06:41
hi all, I tried this code but it only returned the first element of each array. Where it is wrong?
Jevaughn Vance
@jvans7
May 05 2016 06:43
what lesson is that?
Bhavesh
@bbhavesh
May 05 2016 06:48

Hi All
Need help with "Return Early Pattern for Functions"

Instructions
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.

Below is my Code:
// Setup
function abTest(a, b) {
// Only change code below this line
if (a, 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);

abTest(2,2) should return a number
abTest(2,2) should return 8
abTest(-2,2) should return undefined = M not this one right
abTest(2,-2) should return undefined
abTest(2,8) should return 18
abTest(3,3) should return 12
Jevaughn Vance
@jvans7
May 05 2016 06:51
you cant combine a and be
b*
Bhavesh
@bbhavesh
May 05 2016 06:53
@jvans7 OK
So how do we write
if you could pls show
Jevaughn Vance
@jvans7
May 05 2016 06:56
if
(a < 0 || b < 0) {
Bhavesh
@bbhavesh
May 05 2016 06:57
@jvans7 Hey it worked.. Thank you :-)
CamperBot
@camperbot
May 05 2016 06:57
bbhavesh sends brownie points to @jvans7 :sparkles: :thumbsup: :sparkles:
:cookie: 260 | @jvans7 |http://www.freecodecamp.com/jvans7
Jevaughn Vance
@jvans7
May 05 2016 06:57
np
Pedro Jose
@samael205
May 05 2016 07:03
the propietes of an object on JavaScript, not are private, right?
i can say, object.propiete = value?
I tried my best but could't accept
Coy Sanders
@coymeetsworld
May 05 2016 07:09
@xiao-jing it's trying to say that i++ and i = i + 1 are equivalent
Chris Cullen
@123xylem
May 05 2016 07:10
```js
Jorge
@liberaltech
May 05 2016 07:10
has anyone been able to use the wiki api to get images along with your results
Coy Sanders
@coymeetsworld
May 05 2016 07:10
so you want to replace the myVar = myVar + 1 using the ++ operator instead
xiao-jing
@xiao-jing
May 05 2016 07:10
I understand but could not meet all of the requirement
Chris Cullen
@123xylem
May 05 2016 07:10
Why is it that My top solution doesnt work but the bottom one does? They Both say the same thing in a roundabout way dont they???
function confirmEnding(str, target) {

if(str.substr(-target.length) == target)
  {return true;}


    return str;
}

confirmEnding("Bastian", "n");

 function confirmEnding(str, target) {
  return str.substr(-target.length) === target;
}
xiao-jing
@xiao-jing
May 05 2016 07:10
always one is wrong
I am a Chiese and English is poor ,hope you can understand me
Chris Cullen
@123xylem
May 05 2016 07:11
O its because I have return str there :( ... dummy
Coy Sanders
@coymeetsworld
May 05 2016 07:13
@xiao-jing can you post your code?
myVar = myVar + 1; needs to be changed
xiao-jing
@xiao-jing
May 05 2016 07:19
Yes.this cann't be pass
I cann't understand this meaing
myVar = myVar should be changed????
Gleb Silantjev
@hotborsh
May 05 2016 07:20

Hello everyone. Doing Mutations Bonfire right now, can someone please look into my code and tell where's the error?
function mutation(arr) {
var muta = arr1.toLowerCase().split("");
var k = 0;
for (var i = 0; i < muta.length; i++){
if (arr[0].indexOf(muta[i]) > -1) {
k += 0;
}
else {
k++;
}
if (k === 0) {
return true;
}
else {
return false;
}
}
}

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

Coy Sanders
@coymeetsworld
May 05 2016 07:20
yes @xiao-jing
Gleb Silantjev
@hotborsh
May 05 2016 07:20
oh, let me fix it
function mutation(arr) {
  var muta = arr[1].toLowerCase().split("");
  var k = 0;
  for (var i = 0; i < muta.length; i++){
    if (arr[0].indexOf(muta[i]) > -1) {
      k += 0;
    }
    else {
      k++;
    }
   if (k === 0) {
      return true;
    }
   else {
      return false;
    }
  }
}

mutation(["hello", "hey"]);
I'm getting true, even though there's no "y" in hello
That's the Mutation Bonfire
Darryl Gibson
@n2diy
May 05 2016 07:24

think I found a bug in the replacing else/if chains with switch.

I deleted all the else if statements, but I'm still being told I can't use them. Everything else is passing.

Taras Yaremkiv
@Y-Taras
May 05 2016 07:25
Hello to everyone. I've got strange <b>SyntaxError: missing while after do-loop body. </b> How should I fix that?
function sumFibs(num) {
    var arr = [];
    var i = 0;
    var sum = 0;
    do {
        if (i <= 1) {
            arr.push(i);
            console.log('arr[', i, ']', arr[i]);
        } else {
            arr.push(arr[i - 1] + arr[i - 2]);
            console.log('arr[', i, ']', arr[i]);

        }
        if (arr[i] > num) {
            break;
        }
        if ((arr[i] % 2) !== 0) {
            sum += arr[i];
        }
        i += 1;
    } while (i);
    return sum;
}
sumFibs(4);
Coy Sanders
@coymeetsworld
May 05 2016 07:27
i is set to 0
oh wait nvm
Wangach
@Wangach
May 05 2016 07:29

Hey everyone!!! Can someone please help me with this:

// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
   var lookup = {
     "alpha" : "Adams",

     "bravo": "Boston",

     "charlie": "Chicago",

     "delta": "Denver",

     "echo": "Easy",

     "foxtrot": "Frank"
  };


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

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

Instructions===>Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.

Returns nothing after run.. What could be the hitch?
Coy Sanders
@coymeetsworld
May 05 2016 07:31
@Wangach its because you're just returning an empty string
you need to modify result based on the lookup object you created
@Y-Taras idk whats wrong w/ your code, try refreshing your browser? looks fine to me
Taras Yaremkiv
@Y-Taras
May 05 2016 07:33
@coymeetsworld made hard refresh - the same error. I doubt if reboot will help)
Coy Sanders
@coymeetsworld
May 05 2016 07:35
no probably not reboot
give me a sec ill try to put it in see what it gives me
Wangach
@Wangach
May 05 2016 07:37
@coymeetsworld Its not possible for me to define the variable result since I am not supposed to change that code , neither am I supposed to modify the return value.....

stranded

Coy Sanders
@coymeetsworld
May 05 2016 07:38
yes you can change it @Wangach :)
@Y-Taras im getting diff error, SyntaxError: Unexpected token;
Darryl Gibson
@n2diy
May 05 2016 07:39

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

switch (val) {
case "bob":
answer = "Marley";
break;

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

case 1:
answer = "There is no #1";
break;

case 99:
answer = "Missed me by this much!";
break;

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

default:
answer = "";
}

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

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

Why is this giving me can't use else or if errors?

Coy Sanders
@coymeetsworld
May 05 2016 07:40
thats a strange one @Y-Taras idk what the problem is, it works fine when i put it in codepen it looks like
maybe something you should report
Devin
@turingalad
May 05 2016 07:41
Total side-track, but I'm curious about how to get a text editor to look like the ones here in freecodecamp. I just downloaded Sublime on my mac, and I have Pluma on my Ubuntu laptop. Is there a particular theme/syntax that's (nearly) identical?
Taras Yaremkiv
@Y-Taras
May 05 2016 07:42
@coymeetsworld in Chrome I get Unexpected token; but in mozilla other
Coy Sanders
@coymeetsworld
May 05 2016 07:43
yeah I'm using Chrome
whoa
Taras Yaremkiv
@Y-Taras
May 05 2016 07:44
I think it just doesn't like the break
Coy Sanders
@coymeetsworld
May 05 2016 07:44
try removing the line break between here:
            arr.push(arr[i - 1] + arr[i - 2]);
            console.log('arr[', i, ']', arr[i]);
<!-- here -->
        }
Taras Yaremkiv
@Y-Taras
May 05 2016 07:47
@coymeetsworld nothing helps. I removed the break at all - the same error.
Coy Sanders
@coymeetsworld
May 05 2016 07:47
you sure? it worked for me
also remove console.logs too perhaps
function sumFibs(num) {
    var arr = [];
    var i = 0;
    var sum = 0;
    do {
        if (i <= 1) {
            arr.push(i);
        } else {
            arr.push(arr[i - 1] + arr[i - 2]);
        }
        if (arr[i] > num) {
            break;
        }
        if ((arr[i] % 2) !== 0) {
            sum += arr[i];
        }
        i += 1;
    } while (i);
    return sum;
}
sumFibs(4);
try submitting that
aamir
@aamirngr
May 05 2016 07:49

function palindrome(str) {

str=str.replace(/,| |/g,"");
str=str.replace(".","");
str=str.replace("\","/");
str=str.replace("(",")");
str=str.replace("_","-");

str=str.toLowerCase();
a=str.split("");
a=a.reverse();
str1=a.join("");
if(str==str1)
{return true;}
else{ return false;}
}

palindrome("eye");

Taras Yaremkiv
@Y-Taras
May 05 2016 07:50
@coymeetsworld your variant works, thanks
CamperBot
@camperbot
May 05 2016 07:50
y-taras sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 744 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
aamir
@aamirngr
May 05 2016 07:50
how to share code
Coy Sanders
@coymeetsworld
May 05 2016 07:50
yeah idk why it does, you can report a bug if you want and they can try to get that fixed
Wangach
@Wangach
May 05 2016 07:51
Is there sth wrong with my way of modifying variable result in my code? @coymeetsworld

// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  result = lookup.val;
   var lookup = {
     "alpha" : "Adams",

     "bravo": "Boston",

     "charlie": "Chicago",

     "delta": "Denver",

     "echo": "Easy",

     "foxtrot": "Frank"
  };


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

// Change this value to test
phoneticLookup("charlie");
aamir
@aamirngr
May 05 2016 07:51
@Wangach can you tell me how you share that code i am new
Coy Sanders
@coymeetsworld
May 05 2016 07:51
2 things @Wangach, you want to assign result after the definition of lookup.
it doesn't know what lookup is yet
also its not lookup.val, need to use bracket notation to get the value
Ian Smith
@TOAOIanSmith
May 05 2016 07:52
Anyone willing to help me with Seek and Destroy?
Taras Yaremkiv
@Y-Taras
May 05 2016 07:52
@coymeetsworld well seems it's not a great bug, better not to worry admins)
Wangach
@Wangach
May 05 2016 07:53
@aamirngr You use markdown
Coy Sanders
@coymeetsworld
May 05 2016 07:53
it's not a worry, they would want to know @Y-Taras to make their product more robust
aamir
@aamirngr
May 05 2016 07:53
yea i clicked on mark down
Wangach
@Wangach
May 05 2016 07:53
start with the signs ``` paste your code after and then close with the same marks
Taras Yaremkiv
@Y-Taras
May 05 2016 07:53
@coymeetsworld ok then
Coy Sanders
@coymeetsworld
May 05 2016 07:54
its not like they are all going to drop what they're doing and fix it lol, but someone can come in and fix it. Technically you could fix it if you wanted to
aamir
@aamirngr
May 05 2016 07:54
thnx
Coy Sanders
@coymeetsworld
May 05 2016 07:54
help format
CamperBot
@camperbot
May 05 2016 07:54

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Wangach
@Wangach
May 05 2016 07:54
W/come
Mateusz
@kharimek
May 05 2016 07:54
'''
CamperBot
@camperbot
May 05 2016 07:54
:bulb: to format code use backticks! ``` more info
Mateusz
@kharimek
May 05 2016 07:55

'''
var i = 0;
while (i < contacts.length) {

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

i++;

}
'''
Hi there! I stucked in "Profile Lookup" Lesson. Can anyone take a look on my code?

CamperBot
@camperbot
May 05 2016 07:55
:bulb: to format code use backticks! ``` more info
Ian Smith
@TOAOIanSmith
May 05 2016 07:56

here's my attempt

    arguments[0].filter(function filt(e){
        if(e == arguments[1]) return false;
        else if(e == arguments[2]) return false;
        return true;
    });

when I use arguments in my inner function, it uses it the argument that filter gives it, but I want it to use the arguments of the function that is trying to filter. Help please

aamir
@aamirngr
May 05 2016 07:56
function palindrome(str) {

  str=str.replace(/,| |/g,"");
  str=str.replace(".","");
   str=str.replace("\\","/");
  str=str.replace("(",")");
  str=str.replace("_","-");


  str=str.toLowerCase();
  a=str.split("");
  a=a.reverse();
  str1=a.join("");
  if(str==str1)
  {return true;}
 else{ return false;}
}

palindrome("eye");
Wangach
@Wangach
May 05 2016 07:56
@coymeetsworld I have already defined lookup in that code
Coy Sanders
@coymeetsworld
May 05 2016 07:56
yeah, but you are referring to lookup BEFORE its defined
var x = y;
var y = 10;
That code wouldn't work because when x is trying to assign itself to the value of y, the code doesn't know what y is yet at that point in time
aamir
@aamirngr
May 05 2016 07:57
palindrome("0_0 (: /-\ :) 0-0") should return true.
this condition is not getting satisfied
Coy Sanders
@coymeetsworld
May 05 2016 07:58
so you need to define x after y:
var y = 10;
var x = y; //ok, since y is defined at this point
Wangach
@Wangach
May 05 2016 07:58
@coymeetsworld OMG had totally not seen that coming!!!! Thanks!!!
CamperBot
@camperbot
May 05 2016 07:58
wangach sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:cookie: 745 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 05 2016 07:58
np, but also need to fix how you're assigning result too, use bracket notation instead of dot notation
Wangach
@Wangach
May 05 2016 07:59
Got it! Thanks!
aamir
@aamirngr
May 05 2016 07:59
please help me guyz
Coy Sanders
@coymeetsworld
May 05 2016 08:00
your str.replace functions aren't correct @aamirngr
first argument is what you're trying to replace, and second argument is what you're replacing it with
Ian Smith
@TOAOIanSmith
May 05 2016 08:01
I need someone to help me with the filter() function
Coy Sanders
@coymeetsworld
May 05 2016 08:01
also, you have a variable a, and you haven't defined it
Martialis39
@Martialis39
May 05 2016 08:01
@TOAOIanSmith Whats the issue sir, maybe i can help
Ian Smith
@TOAOIanSmith
May 05 2016 08:02
Alright, so, I'm doing the seek and destroy challenge
and I can't seem to get around the scope of using filter
Darth Skywalker
@adityaparab
May 05 2016 08:02
@TOAOIanSmith Please share code.
Ian Smith
@TOAOIanSmith
May 05 2016 08:02
I have my function:
function destroyer(arr) {
  // Remove all the values
  return arr;
}
and called with:
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
I need to filter out all the other arguments after the array
when I use filter in my function, I don't know how to use those other arguments to check anything...
for say...
Chris Cullen
@123xylem
May 05 2016 08:03
help chunky monkey
CamperBot
@camperbot
May 05 2016 08:03

:point_right: algorithm chunky monkey [wiki]

Explanation

Our goal for this Algorithm is to split arr (first argument) into smaller chunks of arrays with the length provided by size (second argument). There are 4 green checks (objectives) our code needs to pass in order to complete this Algorithm:

  1. (['a', 'b', 'c', 'd'], 2) is expected to be [['a', 'b'], ['c', 'd']]
  2. ([0, 1, 2, 3, 4, 5], 3) is expected to be [[0, 1, 2], [3, 4, 5]]
  3. ([0, 1, 2, 3, 4, 5], 2) is expected to be [[0, 1], [2, 3], [4, 5]]
  4. ([0, 1, 2, 3, 4, 5], 4) is expected to be [[0, 1, 2, 3], [4, 5]]

Click More information under the Algorithm title and read the helpful links if you haven't yet.

:pencil: read more about algorithm chunky monkey on the FCC Wiki

plotterbaboom
@plotterbaboom
May 05 2016 08:04
@aamirngr you should use the JavaScript functions recommended in the code https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
Ian Smith
@TOAOIanSmith
May 05 2016 08:04
arguments[0] = arguments[0].filter(function filt(e){
        if(e == super.arguments[1]) return false;
        else if(e == super.arguments[2]) return false;
        return true;
    });
plotterbaboom
@plotterbaboom
May 05 2016 08:04
Use regex
Ian Smith
@TOAOIanSmith
May 05 2016 08:04
My arguments are only working for my inner function
plotterbaboom
@plotterbaboom
May 05 2016 08:04
Find a regex editor online and find the correct regex to enter into your replace function
CamperBot
@camperbot
May 05 2016 08:04
find a regex editor online and find the correct regex to enter into your replace function
nothing found
Ian Smith
@TOAOIanSmith
May 05 2016 08:05
Is that directed towards me?
plotterbaboom
@plotterbaboom
May 05 2016 08:05