These are chat archives for FreeCodeCamp/HelpJavaScript

13th
Jun 2017
Jason Luboff
@JLuboff
Jun 13 2017 00:02
@moigithub Ah true.
rmcendarfer2017
@rmcendarfer2017
Jun 13 2017 00:03
I am stuck on Profile Lookup can I get some help plz
Rick Riggs
@wikiwiggs
Jun 13 2017 00:04
really struggling on the Build A Recipe Box challenge. Code pen doesn't seem to be propagating, my localStorage calls, but if I run the code locally, everything works fine, any clues???
vorousja
@vorousja
Jun 13 2017 00:04
@zeph7 why is my js console not displaying anything. and also, 404...is a bad request?
Rick Riggs
@wikiwiggs
Jun 13 2017 00:06
@rmcendarfer2017 if you have a return in your else statement, you probably need to cut that return statement and paste it after the first for loop
José Alves
@zeph7
Jun 13 2017 00:06
@vorousja 404 means that the request wasn't found. Change the variable link by url
That one setted on $.GetJSON is empty
Rick Riggs
@wikiwiggs
Jun 13 2017 00:08
@rmcendarfer2017 If that's not the problem you are having, then paste your code here, and we will take a look.
vorousja
@vorousja
Jun 13 2017 00:09
how is it empty?
i declared it globally
and then assigned values to it inside the document.ready()
rmcendarfer2017
@rmcendarfer2017
Jun 13 2017 00:11

@wikiwiggs
//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
if(firstName.hasOwnProperty && prop){
return contacts[prop];
}
else{
return 'No such property';
}
// Only change code above this line
}

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

vorousja
@vorousja
Jun 13 2017 00:11
@zeph7 forgot to tag you
Kyle
@quesurifn
Jun 13 2017 00:12
Anyone know async await with node?
fdemaa
@fdemaa
Jun 13 2017 00:13
can anyone help me on the counting cards exercise, i dont know where to start
José Alves
@zeph7
Jun 13 2017 00:15
@vorousja the url variable has the api address, the link doesn't
Matt Smith
@Aakduce
Jun 13 2017 00:15
anyone have a clue how to solve this? Escape Sequences in Strings
José Alves
@zeph7
Jun 13 2017 00:16
@vorousja var link = "";
Rick Riggs
@wikiwiggs
Jun 13 2017 00:16
@rmcendarfer2017 sorry had to step away for a few, I'm back though
rmcendarfer2017
@rmcendarfer2017
Jun 13 2017 00:17
@wikiwiggs not a problem at all
Mario Ley Tello
@23marioley
Jun 13 2017 00:17
var Car = function() {
  // this is a private variable
  var speed = 10;

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

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

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

var Bike = function() {
  var gear = 0;

  this.setGear = function(plus) {
    gear += plus;
  };

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

  // Only change code below this line.

};

var myCar = new Car();

var myBike = new Bike();

myBike.setGear(4);
myBike.getGear();
can somebody tell me what's wrong with my code?
Moisés Man
@moigithub
Jun 13 2017 00:17
@23marioley setGear no need to increase just SET
Diego Mayer
@Chrono79
Jun 13 2017 00:18
@moigithub :+1: for the match solution
Long Nguyen
@longnt80
Jun 13 2017 00:18
has any used touchstart and touchend?
Mario Ley Tello
@23marioley
Jun 13 2017 00:18
so it would be, "gear = plus"?
Moisés Man
@moigithub
Jun 13 2017 00:18
y @23marioley
Mario Ley Tello
@23marioley
Jun 13 2017 00:19
to set the value of the argument as the gear
bawsumb
@bawsumb
Jun 13 2017 00:19
@aakduce did you both \n and \r in your line?
Matt Smith
@Aakduce
Jun 13 2017 00:20
@bawsumb yea var myStr = "FristLine\n\SecondLine\rThirdLine";
bawsumb
@bawsumb
Jun 13 2017 00:20
@aakduce "FirstLine\n\SecondLine\\rThirdLine" the back slashes need to have an extra one in front of them
Diego Mayer
@Chrono79
Jun 13 2017 00:21
@Aakduce FirstLine
bawsumb
@bawsumb
Jun 13 2017 00:21
@aakduce \n\ and \\r
Mario Ley Tello
@23marioley
Jun 13 2017 00:21
@moigithub or is there another way?
Diego Mayer
@Chrono79
Jun 13 2017 00:21
@bawsumb @Aakduce use backticks to format the code
\\\ three backslashes
Click more info below
CamperBot
@camperbot
Jun 13 2017 00:22
:bulb: to format code use backticks! ``` more info
Moisés Man
@moigithub
Jun 13 2017 00:22
so it would be, gear = plus? @23marioley
thats correct
bawsumb
@bawsumb
Jun 13 2017 00:22
I was trying to type that but it kept erasing the extra blackslashes lol
Mario Ley Tello
@23marioley
Jun 13 2017 00:24
@moigithub thank you man
CamperBot
@camperbot
Jun 13 2017 00:24
23marioley sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3365 | @moigithub |http://www.freecodecamp.com/moigithub
Matt Smith
@Aakduce
Jun 13 2017 00:24
i dont get it 3 | where?
\\
Diego Mayer
@Chrono79
Jun 13 2017 00:26
Around SecondLine, there should be two, \\ then \nand \r have one more each (your string should have 6 in total)
monkeyfingerz
@monkeyfingerz
Jun 13 2017 00:26
 var a=1;
function factorialize(num) {
  for(var i=1;i<=num.length;i++){
   a*=i;
    i++;
  }


  return a;
}

factorialize(5);
 var a=1;
function factorialize(num) {
  for(var i=1;i<=num.length;i++){
   a*=i;
    i++;
  }


  return a;
}

factorialize(5);
bawsumb
@bawsumb
Jun 13 2017 00:26
\ n \ \SecondLine\ \ \ r (take the spaces out)
monkeyfingerz
@monkeyfingerz
Jun 13 2017 00:26
whoops! why isn't my for loop working?
Matt Smith
@Aakduce
Jun 13 2017 00:27
var myStr = "FirstLine\n\\SecondLine\rThirdLine";
bawsumb
@bawsumb
Jun 13 2017 00:27
you need the extra 2 backslashes after SeconLine and before \r
Matt Smith
@Aakduce
Jun 13 2017 00:28
var myStr = "FirstLine\n\SecondLine\\rThirdLine";
it's not pasting right
bawsumb
@bawsumb
Jun 13 2017 00:29
var myStr = "FirstLine\n\SecondLine\\rThirdLine";
var myStr = "FirstLine\n \ \ SecondLine \ \ \ r ThirdLine"; (take out the spaces)
Matt Smith
@Aakduce
Jun 13 2017 00:31
thanks @bawsumb and @Chrono79
CamperBot
@camperbot
Jun 13 2017 00:31
aakduce sends brownie points to @bawsumb and @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 263 | @bawsumb |http://www.freecodecamp.com/bawsumb
:star2: 4263 | @chrono79 |http://www.freecodecamp.com/chrono79
Matt Smith
@Aakduce
Jun 13 2017 00:31
i didnt get that at all
bawsumb
@bawsumb
Jun 13 2017 00:32
Those multiple backslashes are hard to keep track of sometimes
I need help with my local weather app. I can't get the picture to change with the type of weather https://codepen.io/bawsumb/pen/mmNXjL
I've tried if/else if and switch...please help
vorousja
@vorousja
Jun 13 2017 00:35
@zeph7 that was just to declare a global variable, am i not assigning values correctly later in the if statement with " link = url + lat + ',' + long;"?
monkeyfingerz
@monkeyfingerz
Jun 13 2017 00:36
 var a=1;
function factorialize(num) {
  for(var i=1;i<=num.length;i++){
   a*=i;
    i++;
  }


  return a;
}

factorialize(5);
why isn't my for loop working
Long Nguyen
@longnt80
Jun 13 2017 00:37
has anyone tried touch events?
José Alves
@zeph7
Jun 13 2017 00:40
@vorousja Ahhh...ok then
I have tested again and I found the problem
vorousja
@vorousja
Jun 13 2017 00:41
which is? @zeph7
Diego Mayer
@Chrono79
Jun 13 2017 00:41
@monkeyfingerz num hasn't length property, use num directly and don't use global vars (they keep their values between tests). Make a a local var
monkeyfingerz
@monkeyfingerz
Jun 13 2017 00:42
@Chrono79 thanks
CamperBot
@camperbot
Jun 13 2017 00:42
monkeyfingerz sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4264 | @chrono79 |http://www.freecodecamp.com/chrono79
Stephen James
@sjames1958gm
Jun 13 2017 00:42
@monkeyfingerz Your global variable won't work for FCC tests. Also why i++ twice?
Ayush Kumar
@Gr8ayu
Jun 13 2017 00:43
how many pens can I create in non-pro codepen account ??
Stephen James
@sjames1958gm
Jun 13 2017 00:43
@Gr8ayu Well I have many and haven't hit a limit yet.
Ayush Kumar
@Gr8ayu
Jun 13 2017 00:44
@sjames1958gm more than 50 ??
Stephen James
@sjames1958gm
Jun 13 2017 00:44
@Gr8ayu 33
Ayush Kumar
@Gr8ayu
Jun 13 2017 00:44
@sjames1958gm k thanks
CamperBot
@camperbot
Jun 13 2017 00:44
gr8ayu sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7735 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
José Alves
@zeph7
Jun 13 2017 00:46
@vorousja try the console again console.log(weatherJSON);
Elizabeth Paul
@Kowalatam
Jun 13 2017 00:47
so i am on Caesars Cipher and i dont know how to start
José Alves
@zeph7
Jun 13 2017 00:47
That bring me the object as expected
saven1986
@saven1986
Jun 13 2017 00:48
@saifsmailbox98 thanks
CamperBot
@camperbot
Jun 13 2017 00:48
saven1986 sends brownie points to @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:cookie: 443 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
José Alves
@zeph7
Jun 13 2017 00:48
@Kowalatam use the ASCII code to help you. The String.fromCharCode and atCharCode() will help you
Stephen James
@sjames1958gm
Jun 13 2017 00:49
@Kowalatam You will need a loop over the characters in the string.
If you do something like
var A = "A".charCodeAt();
Then you don't even have know ASCII
Caleb Pearman
@capearman
Jun 13 2017 00:49
Hey campers, I'm on the Seek and Destroy Algorithm challenge. My code isn't returning anything because I'm confused about how to use array.prototype.filter(). How do I fix my code so that filter will work?

function destroyer(arr) {
  //convert input to array
  var inclusiveArr = [].slice.call(arguments);
  //flatten the array
  var convToStr = inclusiveArr.toString();
    //return convToStr;
  var convToArr = convToStr.split(',');
    //return convToArr;
  //isolate args
  var arrLength = arr.length;
    //return arrLength;
  var args = convToArr.splice(arrLength);
    //return args;
  //filter out args from arr
  var filtered = arr.filter(function(args) {
    return arr === args;
  });
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
/*       -------array------  --args--  */
Ayush Kumar
@Gr8ayu
Jun 13 2017 00:50
@capearman this challenge was really annoying for me
Stephen James
@sjames1958gm
Jun 13 2017 00:50
@capearman What's all that convert to string, split, etc.
monkeyfingerz
@monkeyfingerz
Jun 13 2017 00:50
I'm getting the correct answer but it doesn't accept the answer any ideas?
Stephen James
@sjames1958gm
Jun 13 2017 00:50
@monkeyfingerz Are you still using the global?
Elizabeth Paul
@Kowalatam
Jun 13 2017 00:51
Okay. Let me take a moment to think first. @sjames1958gm @zeph7 . thank you
CamperBot
@camperbot
Jun 13 2017 00:51
kowalatam sends brownie points to @sjames1958gm and @zeph7 :sparkles: :thumbsup: :sparkles:
:cookie: 216 | @zeph7 |http://www.freecodecamp.com/zeph7
:star2: 7736 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Ayush Kumar
@Gr8ayu
Jun 13 2017 00:51

```
arr2=arr1.filter(function(Z){
if(I want this Z in arr2 )
{
return true;

}

else return false ;

});

``` @capearman

Stephen James
@sjames1958gm
Jun 13 2017 00:52
@capearman The value passed to your filter function will be each value from arr one at a time.
Your function should return true if you want the value in the output and false otherwise.
monkeyfingerz
@monkeyfingerz
Jun 13 2017 00:52
@sjames1958gm yes
is that the problem
Stephen James
@sjames1958gm
Jun 13 2017 00:52
@monkeyfingerz FCC tests cannot reset the global between tests, so you will accumulate from test to test
monkeyfingerz
@monkeyfingerz
Jun 13 2017 00:54
So @sjames1958gm how do i fix this
Caleb Pearman
@capearman
Jun 13 2017 00:54
@sjames1958gm I'm sorry but I still don't completely understand
Moisés Man
@moigithub
Jun 13 2017 00:55
@monkeyfingerz move ur global variable declaration inside the function.. to make it local
folajubril
@folajubril
Jun 13 2017 00:55
hello campers i need help with the wordblanks challenge... i cant seem to figure out what ive been doing wrong
monkeyfingerz
@monkeyfingerz
Jun 13 2017 00:55
@sjames1958gm thanks you
CamperBot
@camperbot
Jun 13 2017 00:55
monkeyfingerz sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7737 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 13 2017 00:56

@capearman

var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.

var newArray = oldArray.filter(function(val) {
  return val < 6;
});

This will result in [1,2,3,4,5]
because the function returns true when val is < 6

Moisés Man
@moigithub
Jun 13 2017 00:56
@folajubril show code...
Stephen James
@sjames1958gm
Jun 13 2017 00:56
@folajubril Show your code
Ayush Kumar
@Gr8ayu
Jun 13 2017 00:58
is it important to give type="button" in <button>
@sjames1958gm
Caleb Pearman
@capearman
Jun 13 2017 00:58
@sjames1958gm I understand your example, and I've seen it elsewhere, but it doesn't really help me
folajubril
@folajubril
Jun 13 2017 00:58

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

result = myAdjective + myNoun + myVerb + myAdverb;
// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("cat ", "big ", "ran ", "quickly.");

Stephen James
@sjames1958gm
Jun 13 2017 00:58
@capearman So for your code you want to return true if val is not in arguments[1..n]
David
@davidr1992
Jun 13 2017 00:58
Hi, I'm on this challenge and I'm a bit stuck https://www.freecodecamp.com/challenges/profile-lookup
Stephen James
@sjames1958gm
Jun 13 2017 00:59
@folajubril So does catbigranquickly seem like a good sentence
Caleb Pearman
@capearman
Jun 13 2017 00:59
@sjames1958gm I get that, but I just don't know how to do that...
Stephen James
@sjames1958gm
Jun 13 2017 00:59
@capearman Consider you have an array after the [].call.slice - and you can use indexOf to search that array.
David
@davidr1992
Jun 13 2017 00:59
this is what I have
Stephen James
@sjames1958gm
Jun 13 2017 00:59
@davidr1992 You can post your code (leave off the contacts array)
David
@davidr1992
Jun 13 2017 01:00
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i=0; i<contacts.length; i++){
  if (firstName === firstName)
    return firstName;
  else return "No such contact";}

  for (i=0; i<contacts.length; i++){
  if (prop === prop)
    return prop;
  else return "No such property";
}
// Only change code above this line
folajubril
@folajubril
Jun 13 2017 01:00
gone over my codes a couple of times thats whr the confusion led me@sjames1958gm
Caleb Pearman
@capearman
Jun 13 2017 01:00
@sjames1958gm hmmmmm. Okay, I'll try this.
Moisés Man
@moigithub
Jun 13 2017 01:00
@folajubril u need to concatenate extra spaces (or words) between
Stephen James
@sjames1958gm
Jun 13 2017 01:00
@folajubril YOu need to insert " " between words
@davidr1992 You are not using contacts[i] anywhere. that is where the firstName property resides.
@davidr1992 This won't ever be false firstName === firstName
David
@davidr1992
Jun 13 2017 01:01
@sjames1958gm thanks. where should I put it in?
CamperBot
@camperbot
Jun 13 2017 01:01
davidr1992 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7738 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 13 2017 01:02
@davidr1992 When you test for firstName it should be contacts[i].firstName also contacts[i].hasOwnProperty for testing for prop
Rick Riggs
@wikiwiggs
Jun 13 2017 01:03
@davidr1992 you have a problem in your else statement.
David
@davidr1992
Jun 13 2017 01:05
hrm, okay
I'll try and work this out myself
Rick Riggs
@wikiwiggs
Jun 13 2017 01:05
else is a catchall for anything else that does not meet the prior if/if else conditions, so when you call return in the else statement, you will stop iterating in your loop, because return will kick you completely out of your function.
Alex
@ABH2089
Jun 13 2017 01:06
Hey, all, I am having some trouble with the .split function. I use .split to make each word in my string indexed, but when I call string[0], it spits out only the first letter of the first word in my new array. Any ideas what I could be doing wrong?
bawsumb
@bawsumb
Jun 13 2017 01:07
@ABH2089 what is your split condition?
Alex
@ABH2089
Jun 13 2017 01:07
string.split(" ")
Rick Riggs
@wikiwiggs
Jun 13 2017 01:08
@davidr1992 Keep in mind that returns can and should be used when you specifically reach a desired condition, but the return statement in the generic else, you most likely want to move that after your for loop, so if it ever reaches it, you can finally return your fallback value after you have iterated through everything you need to.
Stephen James
@sjames1958gm
Jun 13 2017 01:09
@ABH2089 Are you assigning the split to a variable.
Alex
@ABH2089
Jun 13 2017 01:09
I am not!
Stephen James
@sjames1958gm
Jun 13 2017 01:09
@ABH2089 Dun dun dunnnnn
Alex
@ABH2089
Jun 13 2017 01:10
Thanks!!!
Rick Riggs
@wikiwiggs
Jun 13 2017 01:11
I'm having a problem with getting codepen, or jsfiddle to add my desired entries to localStorage, but when I run everything local from my desktop everything works fine, does anyone have a clue as to why this is happening?
folajubril
@folajubril
Jun 13 2017 01:12
thanks @sjames1958gm
CamperBot
@camperbot
Jun 13 2017 01:12
folajubril sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7739 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 13 2017 01:12
@folajubril :+1:
Alex
@ABH2089
Jun 13 2017 01:12
thanks @sjames1958gm !
CamperBot
@camperbot
Jun 13 2017 01:12
abh2089 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7740 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 13 2017 01:12
@ABH2089 :+1:
Lazarushen
@Lazarushen
Jun 13 2017 01:27
how do i do this please!! "instructions" set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
the value of the remainder should be 2. var remainder=2;
you should use the % operator.????
I dont understand the last instruction.
Stephen James
@sjames1958gm
Jun 13 2017 01:37
@Lazarushen the result of the operation is two - that is how remainder gets to be two.
var quotient = 4 / 2;
For example
Duffy125
@Duffy125
Jun 13 2017 01:38
function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty[checkProp] === true) {
return myObj[checkProp];
} else {
return "Not Found";}
}
return myObj.checkProp
Moisés Man
@moigithub
Jun 13 2017 01:39
hasOwnProperty is a method.. it use ( ) not [ ] @Duffy125
Duffy125
@Duffy125
Jun 13 2017 01:40
oh ok thanks
Elliw Seehorn
@ellsee
Jun 13 2017 01:58

I'm about to sound like an idiot, and I probably am one, but I'm so confused. So... dot notation?

// Setup
var testObj = {
  "hat": "ballcap",
  "shirt": "jersey",
  "shoes": "cleats"
};

// Only change code below this line

var hatValue = "testObj.ballcap";      
var shirtValue = "testObj.jersey";

I know that this is super wrong, but I'm not sure what to do. The goal is for shirtValue to equal jersey and hatValue to equal ballcap

also hatValue should be a string, shirtValue should be a string, and I should use dot notation twice but I at least got that far
codeloopy
@codeloopy
Jun 13 2017 02:01
Hey guys working on the Profile lookup and my code passed the first 3, but not the last 2, the rendering of the error message ... I've looked at this letter by letter and I've got it right ... can someone please look @ my code please

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[i][prop];
} else {
return "no such property";
}
}
}
return "no such contact";

// Only change code above this line
}

Grrrr ... I can't figure out what the issue is
any advise? tnx in advance
Jorge Vargas
@jvsole17
Jun 13 2017 02:04
@ellsee you gotta set the testObj to hat and shirt
Diego Mayer
@Chrono79
Jun 13 2017 02:04
@codeloopy
No such property
No such contact
capitalization matters
codeloopy
@codeloopy
Jun 13 2017 02:06
@Chrono79 WHAAAAAAAT!!!!! srly?
WTH ... HAHA
Holy crap ... what a freaking noob HAHA tnx @Chrono79
CamperBot
@camperbot
Jun 13 2017 02:07
codeloopy sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4265 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 13 2017 02:07
:+1:
Elliw Seehorn
@ellsee
Jun 13 2017 02:08
// Setup
var testObj = {
  "hat": "ballcap",
  "shirt": "jersey",
  "shoes": "cleats"
};

// Only change code below this line

var hat = "hat"
var shirt= "shirt"

var hatValue = "hat.ballcap";      // Change this line
var shirtValue = "shirt.jersey";
@jvsole17 like this?
ok not like that but how?
Stephen James
@sjames1958gm
Jun 13 2017 02:10
@ellsee You need to use testObj with the property to get the value
@ellsee But not inside quotes.
@ellsee "hat.ballcap" this is simply a string that has no relation to the variable hat
Elizabeth Paul
@Kowalatam
Jun 13 2017 02:11

@sjames1958gm hi. so im still confused on the caesars cipher. Here is what i have so far function rot13(str) { // LBH QVQ VG!

for (var i = 0; i < rot13.length; i++){
String.fromCharCode(str.charCodeAt(i)+13);
}
return ;
}

Elliw Seehorn
@ellsee
Jun 13 2017 02:12
@sjames1958gm but it has to be string to pass the challenge
Stephen James
@sjames1958gm
Jun 13 2017 02:12
@ellsee The string comes from the property value in the object
@Kowalatam rot13 is the function so rot13.length is wrong. Should be str.length
Elliw Seehorn
@ellsee
Jun 13 2017 02:13
ok so how do I make testObj hat specifically
@sjames1958gm
Stephen James
@sjames1958gm
Jun 13 2017 02:13
@ellsee testObj.hat - this has the value of "ballcap"
Elizabeth Paul
@Kowalatam
Jun 13 2017 02:13
@sjames1958gm Ohh yeah.. its really past my bed time lol.. :worried:
Elliw Seehorn
@ellsee
Jun 13 2017 02:15
@sjames1958gm ohhhhhhhh I was trying to use ballcap and jersey where hat and shirt shouldve gone thanks my dude
CamperBot
@camperbot
Jun 13 2017 02:15
ellsee sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7741 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Elliw Seehorn
@ellsee
Jun 13 2017 02:15
also thanks @jvsole17 🤙
CamperBot
@camperbot
Jun 13 2017 02:15
ellsee sends brownie points to @jvsole17 :sparkles: :thumbsup: :sparkles:
:cookie: 215 | @jvsole17 |http://www.freecodecamp.com/jvsole17
JohnRagbir
@JohnRagbir
Jun 13 2017 02:15
can anyone help me with the card counting function
i’ve been stuck for dayas
Days*
Stephen James
@sjames1958gm
Jun 13 2017 02:16
@Kowalatam You will want a local variable into which you will build the new string.
inside the loop:
var code = str.charCodeAt(i);
then
if code is between A and M add 13 the convert back to string and add to output variable
else if code is between N and Z subtract 13, convert back to string and add to output variable
else convert back to string and add to output variable.
@ellsee :+1:
Jorge Vargas
@jvsole17
Jun 13 2017 02:16
@ellsee your welcome :smile:
JohnRagbir
@JohnRagbir
Jun 13 2017 02:16

var count = 0;

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

return count + (count > 0? "Bet":"Hold");
// Only change code above this line
}

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

Stephen James
@sjames1958gm
Jun 13 2017 02:16
@JohnRagbir Show your code
@JohnRagbir There should be a space between count and "Bet"
@JohnRagbir Change to " Bet" and " Hold"
Elizabeth Paul
@Kowalatam
Jun 13 2017 02:19
@sjames1958gm thank you. will do that after a nap. :) :+1:
CamperBot
@camperbot
Jun 13 2017 02:19
kowalatam sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7742 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 13 2017 02:19
@Kowalatam :sleeping:
JohnRagbir
@JohnRagbir
Jun 13 2017 02:20
the formatting from copying and pasting removed the space between bet and count and when i changed it to “Bet” and “Hold” it returned “expected ‘:’ and saw ‘and’"
how many spaces do i put?
instead of returning “5 Bet” it returns “5Bet"
Mukul Agrawal
@mukul09
Jun 13 2017 02:22
@JohnRagbir return count+" Bet";
Stephen James
@sjames1958gm
Jun 13 2017 02:22
@JohnRagbir Just one
Jonathan
@jrhayes
Jun 13 2017 02:24
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i < arr.length; i++){
    for (var j = 0; j < arr[i].length; j++) {
      product *= arr;
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Need help...function multiplyAll is suppose to multiply the product var by each number in the sub-arrays of arr.
Mukul Agrawal
@mukul09
Jun 13 2017 02:24
@jrhayes to multiply a number you should do this
product *= arr[i][j];
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:25
@sjames1958gm In my page images are not coming in proper height ? What am I doing wrong ??
JohnRagbir
@JohnRagbir
Jun 13 2017 02:26
i tried to separate it with a single space and it returned that it expects an identifier like ‘:’ and when i put ‘return count + “Bet”; it gave me the same result as before “5Bet"
Jonathan
@jrhayes
Jun 13 2017 02:26
@mukul09 Thanks! How does that account for the sub array though that has 3 values [5,6,7]
CamperBot
@camperbot
Jun 13 2017 02:26
jrhayes sends brownie points to @mukul09 :sparkles: :thumbsup: :sparkles:
:cookie: 435 | @mukul09 |http://www.freecodecamp.com/mukul09
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:28
@jrhayes when you take arr[i].length it gives length 2 for first 2 array and 3 for [5,6,7]
Mukul Agrawal
@mukul09
Jun 13 2017 02:28
@jrhayes look when i=2 then j=0 will be 5 , j=1 will be 6 , j==2 will be 7
Stephen James
@sjames1958gm
Jun 13 2017 02:28
@Gr8ayu I am not familiar with bootstrap carousel.
Jonathan
@jrhayes
Jun 13 2017 02:28
@JohnRagbir 'return count + " " + bet;'
Stephen James
@sjames1958gm
Jun 13 2017 02:29
@JohnRagbir return count + (count > 0 ? " Bet" : " Hold");
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:29
@sjames1958gm ok thnx
CamperBot
@camperbot
Jun 13 2017 02:29
gr8ayu sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7743 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Jonathan
@jrhayes
Jun 13 2017 02:30
@mukul09 ah yes, because its based on the .length
Mukul Agrawal
@mukul09
Jun 13 2017 02:30
@jrhayes yes
Gulsvi
@gulsvi
Jun 13 2017 02:31
@Gr8ayu You'll need to use images that are all the same dimensions - or define each image as a background image of the <div class="item">
And use background-size: cover but they will be cut off
JohnRagbir
@JohnRagbir
Jun 13 2017 02:32
Screen Shot 2017-06-12 at 10.31.04 PM.png
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:33
@SkyC0der isn't there any class like "img-responsive " that can automatically bring them to same size?
Jonathan
@jrhayes
Jun 13 2017 02:33
@JohnRagbir return count + " " + (count > 0 ? "Bet" : "Hold");
Gulsvi
@gulsvi
Jun 13 2017 02:33
@Gr8ayu You can give it a max-height, but that will affect the width. img-responsive will give them all the same width, but not the same height
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:34
@SkyC0der ok thank you
CamperBot
@camperbot
Jun 13 2017 02:34
gr8ayu sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 1685 | @skyc0der |http://www.freecodecamp.com/skyc0der
Gulsvi
@gulsvi
Jun 13 2017 02:34
Unfortunately, there is no way to make two images with different aspect ratios have the same height and width in all screen sizes :(
They'll get distorted or cut off at some point
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:35
@SkyC0der is there any way through which I can assign height according to width
JohnRagbir
@JohnRagbir
Jun 13 2017 02:35
Screen Shot 2017-06-12 at 10.33.49 PM.png
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:35
@SkyC0der like 70% of width ?
JohnRagbir
@JohnRagbir
Jun 13 2017 02:35
isn’t that result exactly what they’re looking for?
Jonathan
@jrhayes
Jun 13 2017 02:36
You've got spaces at the end of them
JohnRagbir
@JohnRagbir
Jun 13 2017 02:36
at the end of bet and hold?
Aditya
@adichouhan
Jun 13 2017 02:37
@JohnRagbir rquire only space on left of bet and hold
JohnRagbir
@JohnRagbir
Jun 13 2017 02:37
oh my gosh. this took me hours for such a small change
Jonathan
@jrhayes
Jun 13 2017 02:37
" Bet " should be " Bet"
Gulsvi
@gulsvi
Jun 13 2017 02:37
@Gr8ayu Yes, but you still have to decide if you prefer to have the images in your carousel all the same height (and different width), all the same width (and different height), or cut off
JohnRagbir
@JohnRagbir
Jun 13 2017 02:37
thank you @jrhayes
CamperBot
@camperbot
Jun 13 2017 02:37
johnragbir sends brownie points to @jrhayes :sparkles: :thumbsup: :sparkles:
:cookie: 216 | @jrhayes |http://www.freecodecamp.com/jrhayes
JohnRagbir
@JohnRagbir
Jun 13 2017 02:37
thank you @adichouhan
CamperBot
@camperbot
Jun 13 2017 02:37
johnragbir sends brownie points to @adichouhan :sparkles: :thumbsup: :sparkles:
:cookie: 210 | @adichouhan |http://www.freecodecamp.com/adichouhan
JohnRagbir
@JohnRagbir
Jun 13 2017 02:38
thank you @sjames1958gm
CamperBot
@camperbot
Jun 13 2017 02:38
johnragbir sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7744 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:38
@SkyC0der cut off
JohnRagbir
@JohnRagbir
Jun 13 2017 02:39
thank you @mukul09
CamperBot
@camperbot
Jun 13 2017 02:39
johnragbir sends brownie points to @mukul09 :sparkles: :thumbsup: :sparkles:
:cookie: 436 | @mukul09 |http://www.freecodecamp.com/mukul09
Gulsvi
@gulsvi
Jun 13 2017 02:39
@Gr8ayu Let me see if I can show what I mean by making them background images with CSS. brb
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:39
@SkyC0der or I think chosing another image would be better
Mukul Agrawal
@mukul09
Jun 13 2017 02:39
@JohnRagbir :+1:
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:41
@SkyC0der I should look for aspect ratio or pixels while selecting image with same dimensions ?
Gulsvi
@gulsvi
Jun 13 2017 02:42
@Gr8ayu Yes, you should get pictures with the same height x width
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:44
@SkyC0der I thought it will cut off in height but its cutting width :satisfied:
@SkyC0der thnx 'll select another image
CamperBot
@camperbot
Jun 13 2017 02:45
gr8ayu sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:warning: gr8ayu already gave skyc0der points
Gulsvi
@gulsvi
Jun 13 2017 02:45
It's doing both - make your screen bigger/smaller lol @Gr8ayu
Ayush Mahajan
@ay2306
Jun 13 2017 02:45
Hey guys. I wanted to ask something.
i am using bootstrap this way
class="col-xs-12 col-md-8"
so is there any way that I could change css (specially allignment) of html when it changes to xs from ls or md
Gulsvi
@gulsvi
Jun 13 2017 02:45
images are hard to get right unless they're all perfect lol
CreateTheHype
@CreateTheHype
Jun 13 2017 02:45
can someone help me with this Switch challenge?
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:46
@SkyC0der oh yeah , I was looking in embedded codepen
now its looking nice
CreateTheHype
@CreateTheHype
Jun 13 2017 02:46
 switch (val) {
    case 1:
      alpha;
       break;
    case 2:
      beta;
       break;
    case 3:
      gamma;
       break;
    case 4:
      delta;
      break;
  }
Mukul Agrawal
@mukul09
Jun 13 2017 02:46
@CreateTheHype share your full code
CreateTheHype
@CreateTheHype
Jun 13 2017 02:47
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case 1:
      alpha;
       break;
    case 2:
      beta;
       break;
    case 3:
      gamma;
       break;
    case 4:
      delta;
      break;
  }

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

// Change this value to test
caseInSwitch(1);
Adam Bohannon
@abohannon
Jun 13 2017 02:47
Can anyone help me understand this challenge? How does the inside function know to assign arr1 and arr2 to first and second. And what is the purpose of the declarations at the bottom? onlyInFirst(arr1, arr2) etc.
function diffArray(arr1, arr2) {
  var newArr = [];
  // Same, same; but different.

  function onlyInFirst(first, second){
    for (var i=0; i < first.length; i++){
      if (second.indexOf(first[i]) === -1){
        newArr.push(first[i]);
      }
    }
  }

  onlyInFirst(arr1, arr2);
  onlyInFirst(arr2, arr1);

 return newArr;

}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:47
@CreateTheHype you must assign value to answer as "alpha"
Mukul Agrawal
@mukul09
Jun 13 2017 02:47
@CreateTheHype if you are returning "answer" , you should assign something to answer
Long Nguyen
@longnt80
Jun 13 2017 02:48
@ay2306 not sure what you meant?
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:49
@abohannon hve you copied this code from somewhere ?
Adam Bohannon
@abohannon
Jun 13 2017 02:49
yes, it's from the FCC forum
it works, i just tested it
Ayush Mahajan
@ay2306
Jun 13 2017 02:50
@longnt80 I mean when I reduce my screen size my different div element occupy whole lines due to col-xs-12
but for general screen mode I have set alignment to right and when it changes from col-md-8 to col-xs-12 I want it to be Centrally aligned
Long Nguyen
@longnt80
Jun 13 2017 02:51
@ay2306 you can use media query to do that
Adam Bohannon
@abohannon
Jun 13 2017 02:51
Are the bottom functions callback functions? And the loop is going through one, then the other?
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:52
@abohannon this function onlyInFirst(arr1,arr2) is ichecking whether elements of arr1 is present in arr2 , if no it is pushing that value to newArray
Ayush Mahajan
@ay2306
Jun 13 2017 02:52
@longnt80 I read about that but I am not understanding at what pixel does it change and how to implement
@longnt80 what to set as max-width?
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:53
@abohannon you should write your own code , that will help you learn better
Long Nguyen
@longnt80
Jun 13 2017 02:53
@ay2306 can you make a quick codepen example of your code?
Adam Bohannon
@abohannon
Jun 13 2017 02:53
@Gr8ayu i was definitely trying for a long time
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:54
@abohannon do you know how to use .filter() .IndexOf()
CreateTheHype
@CreateTheHype
Jun 13 2017 02:54
@mukul09 @Gr8ayu any other tips?
Adam Bohannon
@abohannon
Jun 13 2017 02:55
I've used indexOf before, but never filter
Ayush Mahajan
@ay2306
Jun 13 2017 02:55

wait a minute

<div class="row">
        <div class="otherDetailsRow>
<div col-xs-12 col-md-4">Chances of Rain</div>
<div id="rainChances" class="col-xs-12 col-md-8" style="text-align:right"></div>
</div>
</div>

when someone open it in mobile I want #rainChances to be style="text-align:center"
@longnt80

cacho32
@cacho32
Jun 13 2017 02:56

hey
i'd like to understand why in the factorialize exercise when i declare the variable as general like this i can't validate the exercise:
var a = 1;
function factorialize(num) {
for (var i =1; i<=num; i++) {
a*=i;
}
return a;
}
factorialize(0);

But when i declare it locally i can :
function factorialize(num) {
var a = 1;
for (var i =1; i<=num; i++) {
a*=i;
}
return a;
}
factorialize(0);

Ayush Kumar
@Gr8ayu
Jun 13 2017 02:57
@abohannon .filter and .map are important you will also need .indexOf() in upcoming challenges
Mukul Agrawal
@mukul09
Jun 13 2017 02:57
@CreateTheHype for what??
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:57
@CreateTheHype show code
CreateTheHype
@CreateTheHype
Jun 13 2017 02:58

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

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

// Change this value to test
caseInSwitch(1);
Mukul Agrawal
@mukul09
Jun 13 2017 02:58
@CreateTheHype you should assign the values like alpha, beta to the answer in your switch statement
Ayush Kumar
@Gr8ayu
Jun 13 2017 02:59
@CreateTheHype assign the value "alpha" inside answer . its value not variable
CreateTheHype
@CreateTheHype
Jun 13 2017 02:59
oh it says to only change code above there. ill try that thanks @Gr8ayu @mukul09
CamperBot
@camperbot
Jun 13 2017 02:59
:cookie: 325 | @gr8ayu |http://www.freecodecamp.com/gr8ayu
:cookie: 438 | @mukul09 |http://www.freecodecamp.com/mukul09
CamperBot
@camperbot
Jun 13 2017 02:59
createthehype sends brownie points to @gr8ayu and @mukul09 :sparkles: :thumbsup: :sparkles:
Long Nguyen
@longnt80
Jun 13 2017 03:00
@ay2306 remove the inline style
Junou Cui
@FIRESTROM
Jun 13 2017 03:00
Hey Guys, I got stucked in the escape Sequences in Strings
Ayush Kumar
@Gr8ayu
Jun 13 2017 03:01
@CreateTheHype you dont need to change code out of switch statement
@FIRESTROM show code
Ayush Mahajan
@ay2306
Jun 13 2017 03:01
@longnt80 h1 is inline. why does that matter?
Junou Cui
@FIRESTROM
Jun 13 2017 03:01
How should I write the code to make
FirstLine
\SecondLine\
ThirdLine
this code appear
Long Nguyen
@longnt80
Jun 13 2017 03:01
@ay2306 I don't see any H1
Ayush Kumar
@Gr8ayu
Jun 13 2017 03:02
@FIRESTROM you are asking answer directly . you should try it yourself
@FIRESTROM var a="\\ab" will give \ab
Ayush Mahajan
@ay2306
Jun 13 2017 03:02
@longnt80 html line 34
VinayVijayJoshi
@VinayVijayJoshi
Jun 13 2017 03:02
I am at "Profile Lookup". How do I make console.log to function?
Ayush Kumar
@Gr8ayu
Jun 13 2017 03:03
@VinayVijayJoshi show code
Long Nguyen
@longnt80
Jun 13 2017 03:03
@ay2306 no, in the code you gave me
VinayVijayJoshi
@VinayVijayJoshi
Jun 13 2017 03:03
No displays are coming at console..
Junou Cui
@FIRESTROM
Jun 13 2017 03:03
yeah, and I also know that /n and /r will gives the new line
Moisés Man
@moigithub
Jun 13 2017 03:04
@VinayVijayJoshi press F12 to open ur browser devtools then click on console tab
whatever u console.log(..) should appear there
Ayush Mahajan
@ay2306
Jun 13 2017 03:04
@longnt80 ohhh sorry inline style... my mistake
Junou Cui
@FIRESTROM
Jun 13 2017 03:04
But I'm stucked with this "the string should have encoded text with the proper escape sequences and no spacing."
intervolver
@intervolver
Jun 13 2017 03:04
Does the numerical value .charCodeAt() returns convert directly to the character's unicode hex value?
Ayush Kumar
@Gr8ayu
Jun 13 2017 03:04
show your code @FIRESTROM
@intervolver ascii value
Elizabeth Paul
@Kowalatam
Jun 13 2017 03:05

hi. on caesers cipher. How do i not transform non-alphabetic characters. Here is my code so far.
function rot13(str) { // LBH QVQ VG!
var newStr = "";

for (var i = 0; i < str.length; i++){
var num = str.charCodeAt(i);
if (num <= 77) {
newStr += String.fromCharCode(num + 13);
}

else if (num > 77) {
  newStr += String.fromCharCode(num - 13);
}

else {
  newStr += str[i];
}

}
return newStr;
}

Moisés Man
@moigithub
Jun 13 2017 03:05
@intervolver it return a number on 0..255 range
www.asciitable.com
Long Nguyen
@longnt80
Jun 13 2017 03:05
@ay2306 I remove exessive html:
https://codepen.io/longnt80/full/mmEaZJ/
Junou Cui
@FIRESTROM
Jun 13 2017 03:05
var myStr = "FirstLine\n\SecondLine\\rThridLine";
intervolver
@intervolver
Jun 13 2017 03:05
@moigithub @Gr8ayu thank you !
CamperBot
@camperbot
Jun 13 2017 03:05
intervolver sends brownie points to @moigithub and @gr8ayu :sparkles: :thumbsup: :sparkles:
:cookie: 326 | @gr8ayu |http://www.freecodecamp.com/gr8ayu
:star2: 3366 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Jun 13 2017 03:06
ThridLine spelling @FIRESTROM
Ayush Kumar
@Gr8ayu
Jun 13 2017 03:06
@FIRESTROM write code inside ``` to make it appear as code
CreateTheHype
@CreateTheHype
Jun 13 2017 03:06
got it guys thanks
Jonathan
@jrhayes
Jun 13 2017 03:07

//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
  //check for valid firstName
  var returnName = "";
  var item = "";

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



  //check for valid prop

  //return value

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Not looking for an answer...would just like to know if I'm on the right track or not...
Moisés Man
@moigithub
Jun 13 2017 03:07
@Kowalatam if (num <= 77) { is not enough
u need to be more specific on ur ranges
www.asciitable.com
ie: space is code 32
32 is < 77
mr.huang
@molunrenfei
Jun 13 2017 03:07
var Car = function() {
  // this is a private variable
  var speed = 10;

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

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

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

var Bike = function() {

  // 只能在这一行下面写代码
    var gear = 0;
    this.setGear=function(change){
        gear +=change;
    };
    this.getGear=function(){
        return gear;
    };
};

var myCar = new Car();

var myBike = new Bike();
Ayush Kumar
@Gr8ayu
Jun 13 2017 03:07
@jrhayes i dont think so
Junou Cui
@FIRESTROM
Jun 13 2017 03:08
```var myStr = "FirstLine\n\SecondLine\\rThridLine";
Moisés Man
@moigithub
Jun 13 2017 03:08

ThridLine

spelling

@FIRESTROM

Elizabeth Paul
@Kowalatam
Jun 13 2017 03:08
@moigithub hmm.. thanks
CamperBot
@camperbot
Jun 13 2017 03:08
kowalatam sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3367 | @moigithub |http://www.freecodecamp.com/moigithub
Ayush Kumar
@Gr8ayu
Jun 13 2017 03:09
@FIRESTROM spelling of thirdline is wrong
Jonathan
@jrhayes
Jun 13 2017 03:09
Am I at least correct in how i'm iterating through the array?
Junou Cui
@FIRESTROM
Jun 13 2017 03:09
..........
omg
thanks
lol
wchen71
@wchen71
Jun 13 2017 03:10
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var bNull = Boolean(null);
// var btrue = Boolean(true);


 return arr.filter(function(val){
  return val != null && val != bNull;});

}
bouncer([false, null, 0, NaN, undefined, ""]);
bouncer([1, null, NaN, 2, undefined]);
hello everyone!, i'm trying to figureout the falsy bouncer problem and can't seem to get the last null out of the arrays.
Long Nguyen
@longnt80
Jun 13 2017 03:11
@jrhayes yes and no
Ayush Kumar
@Gr8ayu
Jun 13 2017 03:11
@wchen71 what is value of bNull ??
Jonathan
@jrhayes
Jun 13 2017 03:12
@longnt80 @Gr8ayu thanks
CamperBot
@camperbot
Jun 13 2017 03:12
jrhayes sends brownie points to @longnt80 and @gr8ayu :sparkles: :thumbsup: :sparkles:
:cookie: 327 | @gr8ayu |http://www.freecodecamp.com/gr8ayu
:cookie: 367 | @longnt80 |http://www.freecodecamp.com/longnt80
HappyRedditor59
@HappyRedditor59
Jun 13 2017 03:13
i'm stuck at the Condense arrays with reduce challenge. my code only displays the array [4, 5, 6, 7, 8] instead of the sum of the whole thing. what should i do? this is my code:
var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.
var sum = array.reduce(function(a, b){
  return a + b;
});

singleVal = array;
Ayush Kumar
@Gr8ayu
Jun 13 2017 03:13
@wchen71 you need tp check each value of arr and if any of the value is false then return false
wchen71
@wchen71
Jun 13 2017 03:14
@Gr8ayu i understand it as an initial value of false
@Gr8ayu ok i will try that
Ayush Kumar
@Gr8ayu
Jun 13 2017 03:16
@HappyRedditor59 give link of challenge
Long Nguyen
@longnt80
Jun 13 2017 03:16
@HappyRedditor59 but, are you still Happy?
@longnt80 i'm doing fine man
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:17
@HappyRedditor59 what are you returning ?
Ayush Kumar
@Gr8ayu
Jun 13 2017 03:19
@HappyRedditor59 it code seems to be commented at return statement3
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:19
@HappyRedditor59 you need to assign the sum to single value or you could just call the reduce method directly on single value variable.
// Only change code below this line.
singleVal = array.reduce((a, b) => a + b);
Ayush Mahajan
@ay2306
Jun 13 2017 03:21
Hey campers... will appreciate your review.
https://codepen.io/ayush2306/full/rwLWXz/
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:22
@ay2306 overall is good, but reduce the transparency of fonts little bit.
Long Nguyen
@longnt80
Jun 13 2017 03:23
@HappyRedditor59 https://repl.it/ISo5/4
Ayush Mahajan
@ay2306
Jun 13 2017 03:24
@forwebtech Ohhh okay
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:24

@ay2306 you should to full fill the user stories, one is missing:

User Story: I can see a different icon or background image (e.g. snowy mountain, hot desert) depending on the weather.

Ayush Mahajan
@ay2306
Jun 13 2017 03:24
@Gr8ayu yes it does work that way. Try location of other places.
@Gr8ayu so tag you by mistake
@forwebtech
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:25
wait let me check !
Long Nguyen
@longnt80
Jun 13 2017 03:25
@ay2306 I can't change back to celsius
Ayush Mahajan
@ay2306
Jun 13 2017 03:25
@longnt80 looking into it
ashleyberberich
@ashleyberberich
Jun 13 2017 03:26
```
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:27
@ay2306 yes you are right, but i tried Antarctica it gives me, -48 C | F, the wallpaper is not suitable for that :)
ashleyberberich
@ashleyberberich
Jun 13 2017 03:27
Hey, I'm stumped on this. The instructions say "Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed." Do I write something like testArr[1] and so on?

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

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Ayush Mahajan
@ay2306
Jun 13 2017 03:28
@forwebtech will keep working on improving wallpaper calculation algorithm
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:28
@ashleyberberich well try to use parameters to access that array.
@ay2306 :+1:
Aditya
@adichouhan
Jun 13 2017 03:28
@ashleyberberich read the guidelines carefully answer is within guidelines
Mukul Agrawal
@mukul09
Jun 13 2017 03:29
@ashleyberberich add the item to the array using .push() method and then use .shift() method to remove the first item from the array
HappyRedditor59
@HappyRedditor59
Jun 13 2017 03:29
thanks a lot @longnt80 @Gr8ayu @forwebtech
CamperBot
@camperbot
Jun 13 2017 03:29
happyredditor59 sends brownie points to @longnt80 and @gr8ayu and @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 328 | @gr8ayu |http://www.freecodecamp.com/gr8ayu
:cookie: 669 | @forwebtech |http://www.freecodecamp.com/forwebtech
:cookie: 368 | @longnt80 |http://www.freecodecamp.com/longnt80
Aditya
@adichouhan
Jun 13 2017 03:29
@ashleyberberich use arr.shift() to remove elements
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:29
@ay2306 and one more thing, changing one time your temperature is ok but it will not get to celsius, as i click F it changed but it didn't changed back to C if i click on it.
and i think you need to more clear that changing option style
Greg Duncan
@GregatGit
Jun 13 2017 03:33
@ashleyberberich look at w3schools how they use push and shift and you'll have it
Ccs99817
@ccs99817
Jun 13 2017 03:33

I have no idea to deal with this challenge. "Falsy Bouncer"

Here is my code:

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var x = new Boolean(false);
  var newArr = arr.filter(function(char){
   return char !== false;
  });
}

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

I tried to use this code to eliminate the false in the arr. But, it won't work.

Aizaz Shahid
@aizazshahid
Jun 13 2017 03:33
@ashleyberberich there are links of push and shift in instructions.
@ccs99817 you are just checking for false ones.
Jorge Vargas
@jvsole17
Jun 13 2017 03:34
why do i keep getting total = 0 ?
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:35
@jvsole17 code ?
Curtis Turner
@curtis-turner
Jun 13 2017 03:35
@ccs99817 I'm stuck too wanna work on it together
Jorge Vargas
@jvsole17
Jun 13 2017 03:35
lesson 94
iterate through an array
with a for loop @forwebtech
Ccs99817
@ccs99817
Jun 13 2017 03:36
@forwebtech Are you sure? I guess the system return [7, "ate", "", 9]. But, the system gave nothing!!
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:36
@jvsole17 but can you show your code, it will be helpful ?
Ccs99817
@ccs99817
Jun 13 2017 03:36
@curtis-turner of course!
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:36
@ccs99817 as you didn't return anything, by default functions return undefined
Jorge Vargas
@jvsole17
Jun 13 2017 03:36

var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line
var myArr = [2,3,4,5,6];
var total = 0;

for (var i = 0; i < myArr.length; i++) {
total += myArr[i];
}

i got it now
Curtis Turner
@curtis-turner
Jun 13 2017 03:37
@ccs99817 your code looks good but you just need to add the checks for the other issues
Jorge Vargas
@jvsole17
Jun 13 2017 03:37
i dont know why it kept saying 0 i just kept typing the same thing over and over again
Ccs99817
@ccs99817
Jun 13 2017 03:37

@forwebtech I have return

```

Curtis Turner
@curtis-turner
Jun 13 2017 03:37
@ccs99817 like NaN or undefined I was using a switch statement to check each of the false values
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:38
@ccs99817 you are returning inside that callback.
@jvsole17 why did you re declare your myArr ? as it is already defined.
Ccs99817
@ccs99817
Jun 13 2017 03:39
@forwebtech Oh, I got it. Let me complete it.
Jonathan
@jrhayes
Jun 13 2017 03:39

//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


  //check for valid firstName
  var noContact = "No such contact";
  var noProp = "No such property";
  var searchName = 0;

  for (var h = 0; h < contacts.length; h++) {
     if (contacts[h].firstName == firstName){
       searchName = 1; 
       }
     if (searchName === 0) {
      return noContact;
  }
  //check for valid prop
  for (var i = 0; i < contacts.length; i++) {
  for (var j = 0; j < contacts[i].length; j++) {

     //return value
     if (contacts[i][j] == prop) {
       return contacts[i][j];
        }
     else {
       return noProp;
        }
     }
    }
   }







// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Okay...so this test works though checking for valid firstName...can someone help me with where my check for valid prop is incorrect.
Jorge Vargas
@jvsole17
Jun 13 2017 03:39
@forwebtech think thats a typo
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:40
@jvsole17 did you pass ?
Jorge Vargas
@jvsole17
Jun 13 2017 03:40
@forwebtech yes thanks
CamperBot
@camperbot
Jun 13 2017 03:40
jvsole17 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 670 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:40
@jrhayes can you please tell me why do you need two loops ?
@jvsole17 :+1:
Jorge Vargas
@jvsole17
Jun 13 2017 03:40
@forwebtech i am in nesting for loops
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:41
then remember arr[i][j].
@jrhayes i think you need to check that mdn.io/hasOwnProperty
Jonathan
@jrhayes
Jun 13 2017 03:42
@forwebtech to check each property inside each object???
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:42
@jrhayes got it, please visit that link above
Curtis Turner
@curtis-turner
Jun 13 2017 03:42
@ccs99817 did you figure it out?
Ayush Mahajan
@ay2306
Jun 13 2017 03:43
need help.. cant understand why after converting it to Fahrenhite once, convert option do not work
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:44
@ay2306 did you use one function to change ?
@ay2306 there is one way to do :
function foo() {
    if( element has class  A ) {
      // do that
} else {
   // do that
}
}
Ayush Mahajan
@ay2306
Jun 13 2017 03:47
@forwebtech how can I use one function to change. It treated F and C onClick events seperately..
Jeremy
@JeremyAntonoff
Jun 13 2017 03:48
can someoen tell me why this wont work
function fearNotLetter(str) {
  var answer = "";
  for (var i=0; i <str.length; i++) {
    if (str.charCodeAt(i + 1) - str.charCodeAt(i) == null)  {
      return undefined;
    }
    else if (str.charCodeAt(i + 1) - str.charCodeAt(i) !== 1) {
     answer = String.fromCharCode(str.charCodeAt(i) + 1);
     break;
    }
  }
 return answer;
}

fearNotLetter("bcd");
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:48
@ay2306 well simple, when changed to celsius give it class named celsius and when changed to Fahrenheit, give it fahrenheit, with that you can check !
or any thing which can be use as flag.
Moisés Man
@moigithub
Jun 13 2017 03:49
@JToddFL what value charCodeAt return ?
Ayush Mahajan
@ay2306
Jun 13 2017 03:49
@forwebtech okay i get that. But why my code isnt working. I tried pasting code outside but it still didn't work Why is it stopping after one use?
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:49
@JToddFL how str.charCodeAt(i + 1) - str.charCodeAt(i) == null can be null ?
Ayush Mahajan
@ay2306
Jun 13 2017 03:50
@forwebtech I get that there are other methods to do so... but I want to know whats wrong with mine...
Ccs99817
@ccs99817
Jun 13 2017 03:51
@curtis-turner I almost complete. How to deal with NaN?

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var x = Boolean(NaN);
  var newArr = arr.filter(function(char){
   return char !== "" && char !== false && char !== null && char !== 0 && char !== undefined && char != x;
  });
  return newArr;
}

bouncer([NaN, undefined, ""]);
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:51
@ay2306 ok then point me the line number !
Moisés Man
@moigithub
Jun 13 2017 03:51
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:51
This message was deleted
Ayush Mahajan
@ay2306
Jun 13 2017 03:52
@forwebtech 78 in JS code
Piyush Tiwari
@piyush805
Jun 13 2017 03:54

For #242 "Title case a sentence'.(Convert only first letter of each word in a sentence to upper case). Is following the correct logic?
1> convert entire str to lower case
2> Splitting and storing length of each word in an array
3> storing all characters in another array
4>In characters array, run a for loop where i increases by length of next word and changes corresponding character[i] to Upper case. Loop runs till str.length

It says that that for loop is infinite.

priyanka bhalla
@priyanka-bhalla
Jun 13 2017 03:54

function sumAll(arr) {
return Math.max(10,45);
}

sumAll([1, 4]);

Aizaz Shahid
@aizazshahid
Jun 13 2017 03:54
@ay2306 looks like, you only add the event to fahrenheit.
priyanka bhalla
@priyanka-bhalla
Jun 13 2017 03:54
i need help i dont know what to do with this
Ayush Mahajan
@ay2306
Jun 13 2017 03:54
@forwebtech what does that mean?
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:55
@piyush805 why are you storing length in new array ?

did you define ?

<span id='celsius' class='active_here'>C</span> | <span id='fah'>F</span>

@ay2306

did you assign the function to boths or just one ?
Piyush Tiwari
@piyush805
Jun 13 2017 03:56
@forwebtech for increment i in for loop
Haseeb Arshad
@haseebuchiha
Jun 13 2017 03:56

`
// Only change code below this line

switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
count +=1;
return count + " Bet";
case 7:
case 8:
case 9:
return count +" Hold";
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count -=1;
return count + " Hold";

}

return "Change Me";
`

Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"
Jonathan
@jrhayes
Jun 13 2017 03:56
@forwebtech Am i wrong to need 2 loops to iterate over the objects and properties inside? the loops need to return the property "value" if they exist.
Haseeb Arshad
@haseebuchiha
Jun 13 2017 03:56
Can someone please help?
Ayush Mahajan
@ay2306
Jun 13 2017 03:56
@forwebtech to both ofcourse. #celsius start at line 98
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:57
@jrhayes no, you are right but there is a builtin function hasOwnProperty() exist for that. nested loops are unnecessary.
Haseeb Arshad
@haseebuchiha
Jun 13 2017 03:58
?
Jonathan
@jrhayes
Jun 13 2017 03:58
so does it just need to iterate over each object? or just the array
heroiczero
@heroiczero
Jun 13 2017 03:58
@haseebuchiha at the end you should use a if statement to return the Hold or Bet
Ccs99817
@ccs99817
Jun 13 2017 03:59
@forwebtech I dunno how to deal with NaN.
function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  //var x = Boolean (NaN);
  var newArr = arr.filter(function(char){
   return char !== "" && char !== false && char !== null && char !== 0 && char !== undefined && char != NaN;
  });
  return newArr;
}

bouncer([NaN, ""]);
Haseeb Arshad
@haseebuchiha
Jun 13 2017 03:59
@heroiczero what do you mean ?
Aizaz Shahid
@aizazshahid
Jun 13 2017 03:59
@piyush805 here is much simpler algorithm:
1> convert str to lower case, split it into words and store it.
2> make a loop that will iterate the number of words, and with in that just make a proper word having first letter upper case.
3> then join the array into string and return it.
Jonathan
@jrhayes
Jun 13 2017 03:59
@haseebuchiha save your return statement for the end, use breaks.
Haseeb Arshad
@haseebuchiha
Jun 13 2017 03:59
So I should Output using console.log?
@jrhayes
Aizaz Shahid
@aizazshahid
Jun 13 2017 04:00
@ccs99817 !Number.isNaN(char)
Jonathan
@jrhayes
Jun 13 2017 04:01
I could be wrong, but i believe the return statements midway through the switch aren't allowing it to iterate over all the cards. The way you have it setup, it is only iterating 1 card
heroiczero
@heroiczero
Jun 13 2017 04:01
@haseebuchiha return count + " Bet"; and return count +" Hold"; this should be at the end of your function to determine if they should bet or not according to the conditions provided by the instructions
Haseeb Arshad
@haseebuchiha
Jun 13 2017 04:01
@jrhayes all my outputs are wrong now :|
intervolver
@intervolver
Jun 13 2017 04:01
I finally finished Ceaser's Cipher. Would anyone be willing to look at my code and tell my if there is a more elegant way? What I have works, but it's using some messy if/else comparators
Aizaz Shahid
@aizazshahid
Jun 13 2017 04:01
@intervolver sure !
Haseeb Arshad
@haseebuchiha
Jun 13 2017 04:01
@heroiczero ok let me try
Ccs99817
@ccs99817
Jun 13 2017 04:02
@forwebtech yes, it works. but can you give me some reference about isNaN? I wanna know how it work
heroiczero
@heroiczero
Jun 13 2017 04:02
@intervolver post your code.
Piyush Tiwari
@piyush805
Jun 13 2017 04:02
@forwebtech For making first ONLY first letter upper case, there isn't a function, is there?
Aizaz Shahid
@aizazshahid
Jun 13 2017 04:02
Donnie
@Donnie-D
Jun 13 2017 04:02
Lads! I have a question. I know if I do enough google search I might get my answer in the end. BUT I enjoy detailed replies on here and makes me realise how silly I can be with my coding imagination :smile: Can someone explain why the below doesn't work? I know it would work with the array idea (there might be a bucket full of things to correct and consider in order for me to achieve what I am trying here) I would like to learn
function addTo(str) { 

   var string = '123456';
  for(i=0; i<string.length; i++){
    string[i] = string[i] + 20;
  }
  return string;
}

addTo();
Ccs99817
@ccs99817
Jun 13 2017 04:02
@forwebtech thx
CamperBot
@camperbot
Jun 13 2017 04:02
ccs99817 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 671 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
Jun 13 2017 04:02
@piyush805 indeed, .replace() with that use charAt()
intervolver
@intervolver
Jun 13 2017 04:03
@forwebtech okay, here is what is working for me. Problems I have with it are the if / if else / else chain, and the messy comparator math to check the ascii value:
function rot13(str) { // LBH QVQ VG!
  var strArr = str.split("").map(function(val){
    if (val.charCodeAt(0) >= 78 && val.charCodeAt(0) <= 90){
      return String.fromCharCode(val.charCodeAt(0) - 13);
    }
    else if (val.charCodeAt(0) >= 65 && val.charCodeAt(0) < 78){
      return String.fromCharCode(91 - (78 - val.charCodeAt(0)));
    }
    else {
      return val;
    }
  });

  return strArr.join("");
}
Piyush Tiwari
@piyush805
Jun 13 2017 04:03
@forwebtech Oh!On it.
Haseeb Arshad
@haseebuchiha
Jun 13 2017 04:03
@heroiczero I'm confused :(
Aizaz Shahid
@aizazshahid
Jun 13 2017 04:04
@intervolver well i am giving you my link, check it out.
heroiczero
@heroiczero
Jun 13 2017 04:04
@haseebuchiha lets see your whole code
Haseeb Arshad
@haseebuchiha
Jun 13 2017 04:04

`var count = 0;

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

switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
count +=1 ;
break;
case 7:
case 8:
case 9:
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count -=1;
break;

}

return "Change Me";
// Only change code above this line
}

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

`

Aizaz Shahid
@aizazshahid
Jun 13 2017 04:05
@intervolver https://repl.it/HkpV/1
intervolver
@intervolver
Jun 13 2017 04:06
@forwebtech that's a lot cleaner, reading it now
heroiczero
@heroiczero
Jun 13 2017 04:07
@haseebuchiha instead of return "Change Me"; do :point_up: June 12, 2017 11:58 PM
Aizaz Shahid
@aizazshahid
Jun 13 2017 04:08
@haseebuchiha if on cases 7, 8, 9, don't have to do anything then why don't you remove those cases ?
JD Richards
@jdrichardstech
Jun 13 2017 04:09

Iterate Through An Array with a for loop.
Instructions:
Declare and initialize a variable total to 0. Use a for loop to add the value of each element of the myArr array to total.
https://repl.it/Iicu

On FCC this is my result:
test console says: total = 20....error message says: 'total should equal 20'. ?

Jonathan
@jrhayes
Jun 13 2017 04:09
@haseebuchiha now have it return a count and bet or hold based on the count

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


  //check for valid firstName
  var noContact = "No such contact";
  var noProp = "No such property";
  var searchName = 0;
  var searchProp = 0;

  for (var h = 0; h < contacts.length; h++) {
     if (contacts[h].firstName == firstName){
       searchName = 1; 
       }
     if (searchName === 0) {
      return noContact;
  }
  //check for valid prop
  for (var i = 0; i < contacts.length; i++) {
  //for (var j = 0; j < contacts[i].length; j++) {

     //return value
     if (contacts[i].hasOwnProperty(prop)) {
       return contacts[i].hasOwnProperty(prop);
        }
    //  }
    }
    return noProp;
   }







// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
am I using the hasOwnProperty()
correctly?
intervolver
@intervolver
Jun 13 2017 04:10
@forwebtech the only thing I'm not understanding is how you're counting out 13 in either direction
Aizaz Shahid
@aizazshahid
Jun 13 2017 04:11
@jrhayes that's correct !
Markus Kiili
@Masd925
Jun 13 2017 04:11
@jrhayes You are using it correctly but not returning what was asked.
Haseeb Arshad
@haseebuchiha
Jun 13 2017 04:11

`
var count = 0;

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

switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
count +=1 ;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count -=1;

  break;

}

if(count + 1){

return count + " Bet";
}
else
return count + " Hold";
`

Aizaz Shahid
@aizazshahid
Jun 13 2017 04:11
@intervolver little bit math, but you can do it without that modulus
Haseeb Arshad
@haseebuchiha
Jun 13 2017 04:12
@forwebtech @heroiczero tried this
Manish Giri
@Manish-Giri
Jun 13 2017 04:12
@haseebuchiha this is wrong
if(count + 1){
you need to check if count is greater than 0.
Haseeb Arshad
@haseebuchiha
Jun 13 2017 04:12
@Manish-Giri ooooo ok ok let me check
heroiczero
@heroiczero
Jun 13 2017 04:12
@haseebuchiha it has to be a conditional statement
Haseeb Arshad
@haseebuchiha
Jun 13 2017 04:13
it worked
@Manish-Giri @heroiczero @forwebtech @jrhayes thank you guuys sooo much
CamperBot
@camperbot
Jun 13 2017 04:13
haseebuchiha sends brownie points to @manish-giri and @heroiczero and @forwebtech and @jrhayes :sparkles: :thumbsup: :sparkles:
:cookie: 219 | @jrhayes |http://www.freecodecamp.com/jrhayes
:cookie: 672 | @forwebtech |http://www.freecodecamp.com/forwebtech
:star2: 1380 | @heroiczero |http://www.freecodecamp.com/heroiczero
:star2: 5976 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jun 13 2017 04:13
:+1:
Aizaz Shahid
@aizazshahid
Jun 13 2017 04:14
@intervolver i think if you calculate some values manually code % 26 + 65 then you will get it !
intervolver
@intervolver
Jun 13 2017 04:14
@forwebtech so if I understand, since a space 13 points away is always going to be equidistant (because ROT13 is its own inverse), the remainder will always land on the correct spot?
and that would be true if ROT13 wasn't its own inverse?
wouldn't *
Aizaz Shahid
@aizazshahid
Jun 13 2017 04:15
@intervolver yes as 26 / 2 = 13
intervolver
@intervolver
Jun 13 2017 04:15
@forwebtech awesome, thank you for helping me understand that
CamperBot
@camperbot
Jun 13 2017 04:15
intervolver sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 673 | @forwebtech |http://www.freecodecamp.com/forwebtech
intervolver
@intervolver
Jun 13 2017 04:16
maths are not my strong suit here as you might be able to tell :p
Aizaz Shahid
@aizazshahid
Jun 13 2017 04:16
actually thanks to @Masd925 because that part is from him :)
CamperBot
@camperbot
Jun 13 2017 04:16
forwebtech sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4252 | @masd925 |http://www.freecodecamp.com/masd925
Aizaz Shahid
@aizazshahid
Jun 13 2017 04:17
@intervolver math will reduce over lots of code if we are good at maths. otherwise it can be done with some more code !
intervolver
@intervolver
Jun 13 2017 04:18
I'm discovering that's my main barrier to elegance and readability. I can solve a problem, but I end up doing more work than I need to
Aizaz Shahid
@aizazshahid
Jun 13 2017 04:21
@intervolver :+1: its ok, because we shouldn't have to worry about what we haven't, we have to care about what we have !
JD Richards
@jdrichardstech
Jun 13 2017 04:23
@haseebuchiha close your function
@intervolver you and me both!
Ccs99817
@ccs99817
Jun 13 2017 04:25

Seek and Destroy


function destroyer(arr) {
  // Remove all the values
  var lengthOfArr = arr.length;
  //var number = arr[0].length;
  /*for (var i = 1; i<lengthOfArr; i++){*/
    var newArr = arr.filter(function(char){
      for (var i = 1; i<lengthOfArr; i++)
      return char != arr[i];
    });
  return newArr;
}


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

I guess it returns [1,1]. But, it gives [1,3,1,3] ==? WHY?

Markus Kiili
@Masd925
Jun 13 2017 04:26
@ccs99817 You need to use the arguments object for those arguments after the array.
Ccs99817
@ccs99817
Jun 13 2017 04:26
@Masd925 Are you saying that I cannot use for loop?
Markus Kiili
@Masd925
Jun 13 2017 04:26
@ccs99817 arr only holds the passed array, [1, 2, 3, 1, 2, 3] on that call.
Aditya
@adichouhan
Jun 13 2017 04:26

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

}
// Only change code above this line

return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
what is wrong with my code? it says function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(var i=0; i<=arr.length; i++)
{
for(j=0; j<arr[i].length; j++){
product*=arr[i][j];
}

}
// Only change code above this line

return product;
}

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

Markus Kiili
@Masd925
Jun 13 2017 04:26
You can use a for loop.
Ccs99817
@ccs99817
Jun 13 2017 04:29
@Masd925 Thank a lot!!! I can't believe that I made such a mistake.! HAHA...HEHE...he
CamperBot
@camperbot
Jun 13 2017 04:29
ccs99817 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4253 | @masd925 |http://www.freecodecamp.com/masd925
Aditya
@adichouhan
Jun 13 2017 04:29
help me pls
Markus Ivancsics
@ivancsicsmarkus
Jun 13 2017 04:29
@adichouhan Hello!
Aditya
@adichouhan
Jun 13 2017 04:29
@ivancsicsmarkus hi
Markus Ivancsics
@ivancsicsmarkus
Jun 13 2017 04:29
@adichouhan How can I help you?
Jonathan
@jrhayes
Jun 13 2017 04:30

//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

  //check for valid firstName
  var noContact = "No such contact";
  var noProp = "No such property";
  var searchName = 0;
  var searchProp = 0;

  for (var h = 0; h < contacts.length; h++) {
     if (contacts[h].firstName == firstName){
       searchName = 1; 
       }
     if (searchName === 0) {
      return noContact;
  }
  //check for valid prop
  for (var i = 0; i < contacts.length; i++) {
  //for (var j = 0; j < contacts[i].length; j++) {

     //return value
     if (contacts[i].hasOwnProperty(prop)) {
       return contacts[i][prop];
        }
      //}
    }
    return noProp;
   }



// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
anymore advice anyone?
Aditya
@adichouhan
Jun 13 2017 04:30
@ivancsicsmarkus what is wrong with following code?

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

}
// Only change code above this line

return product;
}

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

hey pls someone help me?
Markus Ivancsics
@ivancsicsmarkus
Jun 13 2017 04:33

@adichouhan Say

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

instead of:

for(var i=0; i<=arr.length; i++)
@adichouhan with <= you made an extra round
Aditya
@adichouhan
Jun 13 2017 04:34
@ivancsicsmarkus thx
CamperBot
@camperbot
Jun 13 2017 04:34
adichouhan sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:cookie: 609 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
Aizaz Shahid
@aizazshahid
Jun 13 2017 04:34
@Gr8ayu ?
priyanka bhalla
@priyanka-bhalla
Jun 13 2017 04:37

function sumAll(arr) {
return ;
}

sumAll([10, 25]);
please help

Aizaz Shahid
@aizazshahid
Jun 13 2017 04:38
@priyanka-bhalla where you stuck ? i think you have to return the sum all the numbers
Ken Haduch
@khaduch
Jun 13 2017 04:38
@jrhayes - one big problem - try to answer this question. If you are looking for the contact with the firstName equal to "Sherlock", what will happen in your code?
priyanka bhalla
@priyanka-bhalla
Jun 13 2017 04:38
sumAll([1, 4]) should return a number.
sumAll([1, 4]) should return 10.
sumAll([4, 1]) should return 10.
sumAll([5, 10]) should return 45.
sumAll([10, 5]) should return 45.
they show this error
Aizaz Shahid
@aizazshahid
Jun 13 2017 04:39
@jrhayes you don't need that code,
 for (var h = 0; h < contacts.length; h++) {
     if (contacts[h].firstName == firstName){
       searchName = 1; 
       }
     if (searchName === 0) {
      return noContact;
  }
Ogundele Olumide
@Lumexralph
Jun 13 2017 04:40
@priyanka-bhalla what are the instructions?
Jonathan
@jrhayes
Jun 13 2017 04:40
if firstName is equal to "sherlock" then it will continue to run as intended
Ogundele Olumide
@Lumexralph
Jun 13 2017 04:40
@forwebtech @khaduch Good morning
Ken Haduch
@khaduch
Jun 13 2017 04:40
@jrhayes - the next problem is that you can only look for a valid property when you have a firstName match, and it has to be that you look in the exact contact record that you found the firstName match. So those two conditions - a match on firstName and then the existence or non-existence of the property should all happen within one loop. No second loop is necessary at all.
Aizaz Shahid
@aizazshahid
Jun 13 2017 04:40
@priyanka-bhalla actually that is the range, [min, max] so sum all the numbers between them, like [1,4] should be 1 + 2 +3 +4
@Lumexralph Good morning, :wave:
Ken Haduch
@khaduch
Jun 13 2017 04:41
@Lumexralph - hey there Ogundele! Good morning to you - I'm about to sign off for a bit of sleep... probably will see you in the wee hours of the morning if you're still on board.
Ogundele Olumide
@Lumexralph
Jun 13 2017 04:41
@khaduch all good man, have a good rest
Markus Kiili
@Masd925
Jun 13 2017 04:42
Morning.
Ogundele Olumide
@Lumexralph
Jun 13 2017 04:42
@Masd925 guess who's early today :smirk:
Markus Kiili
@Masd925
Jun 13 2017 04:43
@Lumexralph We early :bird: 's
Ogundele Olumide
@Lumexralph
Jun 13 2017 04:43
@Masd925 :smile: , slept well?
Jonathan
@jrhayes
Jun 13 2017 04:44
@khaduch so something like this?
  for (var h = 0; h < contacts.length; h++) {
     if (contacts[h].firstName == firstName){

        if (contacts[h].hasOwnProperty(prop)) {
        return contacts[h].prop;
       }   
  }
Aizaz Shahid
@aizazshahid
Jun 13 2017 04:44
@jrhayes yes ! but you have to use bracket notation as you are using parameter.
Ogundele Olumide
@Lumexralph
Jun 13 2017 04:44
@jrhayes you need to use bracket notation with a parameter.
Markus Kiili
@Masd925
Jun 13 2017 04:44
@Lumexralph Yeah, but only 5 hours. How about you?
Lenarey S. Torririt
@Lengzki
Jun 13 2017 04:46

I don't know how to do this, can you help me?

  • myArray should only contain [["John", 23]].
  • removedFromMyArray should only contain ["cat", 2].

My code:

// Example
var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop();
// removedFromOurArray now equals 3, and ourArray now equals [1,2]

// Setup
var myArray = [["John", 23], ["cat", 2]].pop();

// Only change code below this line.
var removedFromMyArray = myArray.pop();

Ken Haduch
@khaduch
Jun 13 2017 04:46
@jrhayes - yes, you're getting on the right track. As @Lumexralph points out, since your property name is stored in a variable, you need to you bracket notation to access it - contacts[h].prop will not work - contacts[h][prop] is the correct notation for that. If you are confused, review the lesson on using variables to access object properties - it's an important concept!
Aizaz Shahid
@aizazshahid
Jun 13 2017 04:47
@Gr8ayu took some tests and the result is that, both functions only running for one time, so i think the problem is with re making of the whole elements, may be it removes the event handler that we assign it on the previous one, but you can avoid it by just changing the values of specific objects.
Jonathan
@jrhayes
Jun 13 2017 04:48
@khaduch @Lumexralph Gotcha! thanks!
CamperBot
@camperbot
Jun 13 2017 04:48
jrhayes sends brownie points to @khaduch and @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1924 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 2980 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Jun 13 2017 04:48
@Lengzki - offhand, it looks like a problem in the // Setup line - I don't think that there should be a .pop() in there? You should save your code, reinitialize the lesson, and only change the code below the line. (Of course, I could be remembering this incorrectly - which lesson is it?)
K L Bhanu
@klbm9999
Jun 13 2017 04:48
@Lengzki you are popping two times
Lenarey S. Torririt
@Lengzki
Jun 13 2017 04:49
@khaduch its Manipulate Arrays With pop
@klbm9999 how should I do that?
Ken Haduch
@khaduch
Jun 13 2017 04:50
@Lengzki - yes, remove the .pop() from that line that follows the // Setup
K L Bhanu
@klbm9999
Jun 13 2017 04:50
as @khaduch said. @Lengzki
Lenarey S. Torririt
@Lengzki
Jun 13 2017 04:50
i've remove it
@klbm9999 @khaduch thanks guys
CamperBot
@camperbot
Jun 13 2017 04:51
lengzki sends brownie points to @klbm9999 and @khaduch :sparkles: :thumbsup: :sparkles:
:cookie: 285 | @klbm9999 |http://www.freecodecamp.com/klbm9999
:star2: 2981 | @khaduch |http://www.freecodecamp.com/khaduch
Kelechi Chinaka
@ke1echi
Jun 13 2017 04:52
:wave: @Lumexralph
Tai Jones
@taiJones00
Jun 13 2017 04:56
why isn't no such contact being returned
Markus Kiili
@Masd925
Jun 13 2017 04:57
@taiJones00 You only need those first two if's and then just the returns on correct spots. Nothing else.
Use var on i=0
Aizaz Shahid
@aizazshahid
Jun 13 2017 04:58

@taiJones00

:bulb: To format your code, please follow:
```
put your code here
```

More details..

:bulb: To get more commands:
ctrl + shift + m

you can edit your comment.
K L Bhanu
@klbm9999
Jun 13 2017 04:59
@forwebtech i am gonna copy this message and paste it to all people who dont know how to format it... lol
Aizaz Shahid
@aizazshahid
Jun 13 2017 05:00
:+1:
K L Bhanu
@klbm9999
Jun 13 2017 05:00
i mean you even pasted little light bulbs man...
Matt-South
@Matt-South
Jun 13 2017 05:03
hi everybody, i have a little question and hope someone could help me :3
I'm doin the world blank exercise on javascript and can return a coreect answer, but the system doesn't see this as a correct solution, is there anything more to write ?
intcreate
@intcreate
Jun 13 2017 05:05
can any1 help me the for loop is not working not printing any numbers https://codepen.io/anon/pen/bReRYw?editors=0001
Aizaz Shahid
@aizazshahid
Jun 13 2017 05:05
@Matt-South code ?
Tai Jones
@taiJones00
Jun 13 2017 05:05
for (var i = 0; i < contacts.length; i++)
{
if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop))
{
return contacts[prop];
}
else
{
return "No such property";
}
}
Matt-South
@Matt-South
Jun 13 2017 05:05
@forwebtech oh sorry, how can i do that? (newbie here
Tai Jones
@taiJones00
Jun 13 2017 05:05
I just made it worse
@Masd925
Aizaz Shahid
@aizazshahid
Jun 13 2017 05:06
@intcreate console.log() prints to browser console
intcreate
@intcreate
Jun 13 2017 05:06
yeah its not printing anything out
i tried in codepen
Matt-South
@Matt-South
Jun 13 2017 05:07
@intcreate change the ">" with a "<" in your 'for' loop
Markus Kiili
@Masd925
Jun 13 2017 05:07
@taiJones00 The if's were correct before.
intcreate
@intcreate
Jun 13 2017 05:07
oh lol
@Matt-South thanks
CamperBot
@camperbot
Jun 13 2017 05:07
intcreate sends brownie points to @matt-south :sparkles: :thumbsup: :sparkles:
:warning: @matt-south's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Joel Korcsmaros
@lossness
Jun 13 2017 05:08
hey you gods

var programming = false;

var happy = function() {
if (programming !== true); {
return true;
}
else {
return false;
}

};

can someone take a look at this and tell me whats wrong with my else statement
Tai Jones
@taiJones00
Jun 13 2017 05:09
@Masd925
for (var i = 0; i < contacts.length; i++) { if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) { return contacts[prop]; } else if (contacts[i].firstName != firstName) { return "No such contact"; } else if (contacts[i].hasOwnProperty!=(prop)) { return "No such property"; } }
I updated and only the first if doesn't work now
Markus Kiili
@Masd925
Jun 13 2017 05:10
@taiJones00 Simplest structure is two nested if's for the first name and property existence tests. Then only returns on correct spots.
Matt-South
@Matt-South
Jun 13 2017 05:11
https://codepen.io/Matt-South/pen/XgKgZY this is th code, i really don't see where there is a mistake :/
Markus Kiili
@Masd925
Jun 13 2017 05:12
@Matt-South Check the spaces.
Tai Jones
@taiJones00
Jun 13 2017 05:12
@Masd925 is return contacts[prop] not right? it's not working now
Markus Kiili
@Masd925
Jun 13 2017 05:12
@taiJones00 return contacts[i][prop]
Matt-South
@Matt-South
Jun 13 2017 05:13
@Masd925 thanks
CamperBot
@camperbot
Jun 13 2017 05:13
matt-south sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4254 | @masd925 |http://www.freecodecamp.com/masd925
Tai Jones
@taiJones00
Jun 13 2017 05:13
@Masd925 that didn't work
Markus Kiili
@Masd925
Jun 13 2017 05:13
@taiJones00 Post the code again.
Tai Jones
@taiJones00
Jun 13 2017 05:14
function lookUpProfile(firstName, prop){ // Only change code below this line for (var i = 0; i < contacts.length; i++) { if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) { return contacts[i][prop]; } else if (contacts[i].firstName != firstName) { return "No such contact"; } else if (contacts[i].hasOwnProperty!=(prop)) { return "No such property"; } } // Only change code above this line }
Markus Kiili
@Masd925
Jun 13 2017 05:15
@taiJones00 Put only the firstname test on the first if and the hasOwnProperty check on the second if.
Then figure out where to put the returns.
Tai Jones
@taiJones00
Jun 13 2017 05:16
only use to ifs? if and else if?
shankarkdhanaraj
@shankarkdhanaraj
Jun 13 2017 05:19
@lossness looks like your program will always return true
@lossness it will never execute the 'else' statement
Siddhant Shaw
@Mianto
Jun 13 2017 05:20
@shankarkdhanaraj But some cases that were false were given answer false.
Tai Jones
@taiJones00
Jun 13 2017 05:21
for (var i = 0; i < contacts.length; i++)
{
if (contacts[i].firstName != firstName)
{
return "No such contact";
}
else if (contacts[i].hasOwnProperty!=(prop))
{
return "No such property";
}
else if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop))
{
return contacts[i][prop];
}
}
@Masd925 What you meant?
still the if both true condition won't run
Markus Kiili
@Masd925
Jun 13 2017 05:21
@taiJones00 Just two nested if's. Second condition needs to be contacts[i].hasOwnProperty(prop)
No elses needed.
It is better to use positive tests when possible. They are easier to read and understand.
Siddhant Shaw
@Mianto
Jun 13 2017 05:24
function palindrome(str) {
  var copy = str.replace(/[^A-Za-z0-9]/g,'');
  copy.toLowerCase();
  x = reverseString(copy);
  if(x === copy){
    return true;  
  }
  return false;
}

function reverseString(str) {
  li = str.split('');
  li.reverse();
  return li.join('');
}

palindrome("eye");
folajubril
@folajubril
Jun 13 2017 05:24
hello guys i need help with this stand in line challenge. anybody...
Siddhant Shaw
@Mianto
Jun 13 2017 05:24
Two cases that contains sentences are incorrect..Help..
Markus Kiili
@Masd925
Jun 13 2017 05:25
@Mianto It needs to be copy = copy.toLowerCase(); because strings are immutable.
just copy.toLowerCase() returns a new string you don't use.
return x === copy; is better.
Tai Jones
@taiJones00
Jun 13 2017 05:26
@Masd925 for (var i = 0; i < contacts.length; i++) { if (contacts[i].firstName == firstName) { if (contacts[i].hasOwnProperty(prop)) { return contacts[i][prop]; } } }
drew
@tindrew
Jun 13 2017 05:26
I'm feeling stupid. can anyone tell me what I'm supposed to be doing with this code? (word blanks challenge):

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

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

Tai Jones
@taiJones00
Jun 13 2017 05:26
How could this work with only two iffs
Markus Kiili
@Masd925
Jun 13 2017 05:26
@taiJones00 Figure out places for the other returns.
Tai Jones
@taiJones00
Jun 13 2017 05:27
@Masd925 With only two ifs? What about the no such contact and property
shankarkdhanaraj
@shankarkdhanaraj
Jun 13 2017 05:27
@Mianto I am sorry i don't understand what you are saying. @lossness has set the 'programming' var to be false and hasn't changed it in any way. So every time he calls the function happy it will always return true and will never execute the else statement
Tai Jones
@taiJones00
Jun 13 2017 05:28
for (var i = 0; i < contacts.length; i++)
{
if (contacts[i].firstName == firstName)
{
if (contacts[i].hasOwnProperty(prop))
{
return contacts[i][prop];
}
return "No such property"
}
}
Markus Kiili
@Masd925
Jun 13 2017 05:28
@taiJones00 You return No such property when the first name matches (inside the first if block), but the property doesn't exist (so after the second if block).
Tai Jones
@taiJones00
Jun 13 2017 05:28
I have the property one
Okay I'm getting it now
Markus Kiili
@Masd925
Jun 13 2017 05:28
@taiJones00 The last return belongs after the loop block.
shankarkdhanaraj
@shankarkdhanaraj
Jun 13 2017 05:28
did anyone here complete the Where do I belong in Basic Algorithmic SCripting?
Siddhant Shaw
@Mianto
Jun 13 2017 05:29
@Masd925 Thanks, it worked.
CamperBot
@camperbot
Jun 13 2017 05:29
mianto sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4255 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jun 13 2017 05:29
@Mianto :+1:
@taiJones00 The logic is to return inside the loop when you find the contact and after the loop if you don't.
Tai Jones
@taiJones00
Jun 13 2017 05:30
Okay so why did that only work when I placed it outside the loop
oh okay
shankarkdhanaraj
@shankarkdhanaraj
Jun 13 2017 05:30

function getIndexToIns(arr, num) {
// Find my place in this sorted array.
arr.sort();
return arr;
for (var i = 0; i < arr.length; i++){
if ( num <= arr[i] ) return i;
//if (num > arr[i] && num <= arr[i+1]) { return i+1; }
}
return arr.length;
}

getIndexToIns([5, 3, 20, 3], 5);

Tai Jones
@taiJones00
Jun 13 2017 05:30
thank you @Masd925
CamperBot
@camperbot
Jun 13 2017 05:30
taijones00 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4256 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jun 13 2017 05:30
@shankarkdhanaraj The default sort is not numerical sort.
Joel Korcsmaros
@lossness
Jun 13 2017 05:30
@shankarkdhanaraj seems theres a glitch on chrome where even after i corrected the code it still had the syntax error. Jumped to a dif computer and typed the exact code (not the one i posted) and it worked
Markus Kiili
@Masd925
Jun 13 2017 05:31
@shankarkdhanaraj The solution is much easier if you first push num into arr and then sort.
shankarkdhanaraj
@shankarkdhanaraj
Jun 13 2017 05:31
:) great thanks @Masd925
CamperBot
@camperbot
Jun 13 2017 05:31
shankarkdhanaraj sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4257 | @masd925 |http://www.freecodecamp.com/masd925
shankarkdhanaraj
@shankarkdhanaraj
Jun 13 2017 05:32
thats good to hear @lossness
folajubril
@folajubril
Jun 13 2017 05:32
@Masd925 i need help with the stand in line challenge
Markus Kiili
@Masd925
Jun 13 2017 05:33
@folajubril Are you using the array methods on arr and item?
folajubril
@folajubril
Jun 13 2017 05:34
on arr
Markus Kiili
@Masd925
Jun 13 2017 05:35
Post the code you have done.
Ogundele Olumide
@Lumexralph
Jun 13 2017 05:35
@folajubril you need 2 array methods
@kelechichinaka Bro
folajubril
@folajubril
Jun 13 2017 05:35

function nextInLine(arr, item) {
// Your code here
nextInLine([1,2],3);
arr.push(3);
arr.shift();

return item; // Change this line
}

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

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

Markus Kiili
@Masd925
Jun 13 2017 05:36
@folajubril item holds the number from the function call.
So push item, not 3.
Aizaz Shahid
@aizazshahid
Jun 13 2017 05:36
@folajubril and why are you calling your function within ?
shankarkdhanaraj
@shankarkdhanaraj
Jun 13 2017 05:36
@Masd925 i used a compare function to force a numerical sort...that also works..thank you for your insight
CamperBot
@camperbot
Jun 13 2017 05:36
shankarkdhanaraj sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: shankarkdhanaraj already gave masd925 points
Markus Kiili
@Masd925
Jun 13 2017 05:36
@shankarkdhanaraj :+1:
Ogundele Olumide
@Lumexralph
Jun 13 2017 05:37
@folajubril also shift returns a value it removed from arr it's either you store it or return it
@Masd925 how far with php :smirk: ?
Markus Kiili
@Masd925
Jun 13 2017 05:37
@Lumexralph Have to study hard to avoid that :shit:
Ogundele Olumide
@Lumexralph
Jun 13 2017 05:38
@Masd925 :joy:
Markus Kiili
@Masd925
Jun 13 2017 05:38
Hate is a powerful motivator.
Ogundele Olumide
@Lumexralph
Jun 13 2017 05:38
@Masd925 what're you studying now?
Manish Giri
@Manish-Giri
Jun 13 2017 05:38
@Lumexralph good morning gggm :smiling_imp:
Ogundele Olumide
@Lumexralph
Jun 13 2017 05:38
@Masd925 trust me it can be
Markus Kiili
@Masd925
Jun 13 2017 05:38
@Lumexralph Lately reading about software testing.
folajubril
@folajubril
Jun 13 2017 05:39
so @Lumexralph which array method should i be using to remove the first element of the array
Ogundele Olumide
@Lumexralph
Jun 13 2017 05:39
@Manish-Giri gggggggggggggggggm :smiling_imp: Morning
@folajubril you've already done that
Manish Giri
@Manish-Giri
Jun 13 2017 05:39
for i in range(10):
print :smiling_imp:
Ogundele Olumide
@Lumexralph
Jun 13 2017 05:40
@Masd925 that's interesting, don't know how soon I'll need to study that
Manish Giri
@Manish-Giri
Jun 13 2017 05:40
damn formatting
Ogundele Olumide
@Lumexralph
Jun 13 2017 05:40
@folajubril shift already removes the first element, but you need to return that value
Markus Kiili
@Masd925
Jun 13 2017 05:41
@Lumexralph Just to get some general knowledge about that side. Maybe some SQL and backend enhancing next.
Ogundele Olumide
@Lumexralph
Jun 13 2017 05:42
for word in range(15):
               print gggggggm"
annoying format @Manish-Giri
@Masd925 yeah..... i'm dreaming backend now
Rick Riggs
@wikiwiggs
Jun 13 2017 05:44
Hey all, I'm on the Build a Recipe Box project, and I'm struggling with localStorage, is someone up for it?
Bethany Roberts
@Betanya
Jun 13 2017 05:46
I have a couple questions. Why do we have to have the return answer at the bottom and why did we define the var as answer=""? Then how come it isn't recognizing my breaks when I run the test?
function caseInSwitch(val) {
  var answer = "";

  case 1: return ("alpha");break;
  case 2: return ("beta");break;
  case 3: return ("gamma");break;
  case 4: return ("delta");break;

  return answer;  
}

// Change this value to test
caseInSwitch(1);
Ogundele Olumide
@Lumexralph
Jun 13 2017 05:46
@Betanya you have to assign the string to answer in the switch cases
Bethany Roberts
@Betanya
Jun 13 2017 05:47
@Lumexralph what do you mean?
Ogundele Olumide
@Lumexralph
Jun 13 2017 05:47
@Betanya and your switch statement is not well constructed
Bethany Roberts
@Betanya
Jun 13 2017 05:48
@Lumexralph how? lol
Utkarsh Mishra
@Utkarsh707
Jun 13 2017 05:48
algorithm for "Counting Cards" exercise anyone?
im having trouble in returning card val as a string please help
Ogundele Olumide
@Lumexralph
Jun 13 2017 05:48
@Utkarsh707 show your code
Rick Riggs
@wikiwiggs
Jun 13 2017 05:48
Well here's the run-down of it so far, if someone wants to get a sense of what is goin' on:
Stack Exchange Link to my question
MichaelS17
@MichaelS17
Jun 13 2017 05:51
What type of statements should I write for the Card Counting excersize
Long Nguyen
@longnt80
Jun 13 2017 05:51
switch
MichaelS17
@MichaelS17
Jun 13 2017 05:51
thanks @longnt80
CamperBot
@camperbot
Jun 13 2017 05:51
michaels17 sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 369 | @longnt80 |http://www.freecodecamp.com/longnt80
Markus Kiili
@Masd925
Jun 13 2017 05:53
@MichaelS17 You can use if's, switch, or use a lookup object on the first part and if or ternary on the second part of the code.
Utkarsh Mishra
@Utkarsh707
Jun 13 2017 05:53

@Lumexralph var count = 0;

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

   function ret(card)

{
if(card<=0)
{Str=""+card+"Hold";}
else{Str=""+card+"Bet";}
}

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

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

Ogundele Olumide
@Lumexralph
Jun 13 2017 05:54
@Utkarsh707 when you use declare a function, it has to be called to be activated
@Utkarsh707 that aside, you don't need a function in there
Kelechi Chinaka
@ke1echi
Jun 13 2017 05:56
function doubleChar(str) {
  var output = [];
  str = str.split('');
  for (var i = 0; i < str.length; i++) {
    str[i].repeat(2);
    output.push(str[i]);
  }
  return output.join('');
}
why is this code not repeating
Expected: 'aabbccdd', instead got: 'abcd'
Utkarsh Mishra
@Utkarsh707
Jun 13 2017 05:56
@Lumexralph is it ok if i do return ret();
Ogundele Olumide
@Lumexralph
Jun 13 2017 05:57
@Utkarsh707 switch checks the card based on the cases matched count is incremented or decremented, then when the switch statement is done, you need a conditional statement to check if count is positive > 0 or negative then you return count + string (Bet or Hold)
@kelechichinaka str[i].repeat(2); you're not saving the string repeated, you can do output.push(str[i].repeat(2)); think that should work
Utkarsh Mishra
@Utkarsh707
Jun 13 2017 05:58
@Lumexralph i should use if else
right?
Ogundele Olumide
@Lumexralph
Jun 13 2017 05:59
@Utkarsh707 yes
Bethany Roberts
@Betanya
Jun 13 2017 05:59
@Lumexralph I read the article, I still don't know where I went wrong
Kelechi Chinaka
@ke1echi
Jun 13 2017 05:59
oh..true @Lumexralph
Utkarsh Mishra
@Utkarsh707
Jun 13 2017 06:00
@Lumexralph and how to return card var as a string?
John
@j0hnc
Jun 13 2017 06:01
@Betanya result = "something" and then return
Utkarsh Mishra
@Utkarsh707
Jun 13 2017 06:02

i mean i have to use this skeleton code
var count = 0;

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

return "Change Me";
// Only change code above this line
}

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

Ogundele Olumide
@Lumexralph
Jun 13 2017 06:02
@Utkarsh707 yes
@Betanya you're missing out the switch(expression)part
Kelechi Chinaka
@ke1echi
Jun 13 2017 06:03
i need to bang ma head for that @Lumexralph :smile:
Ogundele Olumide
@Lumexralph
Jun 13 2017 06:03
@kelechichinaka :smile:
Manish Giri
@Manish-Giri
Jun 13 2017 06:04
@Lumexralph has that effect on people
:smirk:
Ogundele Olumide
@Lumexralph
Jun 13 2017 06:05
@Manish-Giri what effect :laughing:
@kelechichinaka @Manish-Giri need to go get ready for work later :wave:
@Manish-Giri sleep bro
Donnie
@Donnie-D
Jun 13 2017 06:05
Come on guys! they say no question is too stupid. Please for once tell me why doesn't it work
function addTo(str) { 

   var string = '123456';
  for(i=0; i<string.length; i++){
    string[i] = string[i] + 20;
  }
  return string;
}

addTo();
John
@j0hnc
Jun 13 2017 06:06
@Donnie-D a string is immutable
Bethany Roberts
@Betanya
Jun 13 2017 06:07
@Lumexralph @j0hnc Thanks for your help, I still don't get it, but I think I will come back to it another time.
CamperBot
@camperbot
Jun 13 2017 06:07
betanya sends brownie points to @lumexralph and @j0hnc :sparkles: :thumbsup: :sparkles:
:cookie: 366 | @j0hnc |http://www.freecodecamp.com/j0hnc
:star2: 1925 | @lumexralph |http://www.freecodecamp.com/lumexralph
Markus Kiili
@Masd925
Jun 13 2017 06:08
@Donnie-D You cannot assign to string characters. You could split the string into an array of characters and change the array elements.
and then perhaps join back to a string or whatever you are doing.
Utkarsh Mishra
@Utkarsh707
Jun 13 2017 06:10
@Utkarsh707 I*
How can a change a var to string to return on console?
Donnie
@Donnie-D
Jun 13 2017 06:11
@j0hnc @Masd925 Although I kinds knew the answer but I wanted to hear from some specialists here. Just wondered if there is any possibility to get this to work besides splitting it into an array etc. BUT YOU GUYS ARE THE REASON THE WORLD SPINS :+1:
Markus Kiili
@Masd925
Jun 13 2017 06:12
@Donnie-D What is the output you wan't?
priyanka bhalla
@priyanka-bhalla
Jun 13 2017 06:12

function sumAll(arr) {
return ;
}

sumAll([1, 9]);

is'nt working
folajubril
@folajubril
Jun 13 2017 06:12
@Lumexralph can you please show me the code for this challenge. i've been stuck here a while now..
Donnie
@Donnie-D
Jun 13 2017 06:12
@Masd925 for the above example i just wanted to add 20 to each index
John
@j0hnc
Jun 13 2017 06:13
the solutions are on github
Donnie
@Donnie-D
Jun 13 2017 06:13
@Masd925 isn't there any number strings in javascript?
Markus Kiili
@Masd925
Jun 13 2017 06:13
@Donnie-D Could you just show the output you wan't from input '123456'
@Donnie-D There are coercion functions Number() and String().
priyanka bhalla
@priyanka-bhalla
Jun 13 2017 06:14
please help
Nadeem Shaik
@707
Jun 13 2017 06:14
Does anyone have the solution for ES6: Write Higher Order Arrow Functions ? I have no idea how to implement it.
John
@j0hnc
Jun 13 2017 06:14
your function just return nothing @priyanka-bhalla
no logic there
folajubril
@folajubril
Jun 13 2017 06:15
@Lumexralph the stand in challenge...
Donnie
@Donnie-D
Jun 13 2017 06:16
@Masd925 sure big brother! So lets say i have a string '1 2 3 4 5 6'. i want to change it into EACH INDEX PLUS 20. So the result shows '21 22 23 24 25 26'
John
@j0hnc
Jun 13 2017 06:16
you'd need to convert to integers I think
Manish Giri
@Manish-Giri
Jun 13 2017 06:16

@707 is it this?

Use arrow function syntax to compute the square of only the positive integers (fractions are not integers) in the array realNumberArray and store the new array in the variable squaredIntegers.

Markus Kiili
@Masd925
Jun 13 2017 06:17
@Donnie-D
function addTo(str) { 

  var result = "";
  for(i=0; i<str.length; i++){
    result += String(Number(str[i]) + 20);
  }
  return result;
}

addTo("123456"); // '212223242526'
Baibhav Gautam
@baibhavx
Jun 13 2017 06:17
@priyanka-bhalla ,
Declare a variable to record the sum of all the number and initialize it to 0, example: var sum = 0;
use a loop to iterate through the array.
add each number to the sum, example sum = sum + array[i]
from outside the loop return the sum
Milamanieva
@Milamanieva
Jun 13 2017 06:17
hey. what is wrong with my code:
var myStr;"FirstLine\n\SecondLine\rThirdLine";
Markus Kiili
@Masd925
Jun 13 2017 06:18
@Donnie-D If you wan't a number returned, you can return Number(result);
Manish Giri
@Manish-Giri
Jun 13 2017 06:18
@Milamanieva you need to assign the string to myStr
and use the right escaping.
Milamanieva
@Milamanieva
Jun 13 2017 06:19
var myStr"FirstLine\n\SecondLine\r\ThirdLine;
John
@j0hnc
Jun 13 2017 06:19
use =
Manish Giri
@Manish-Giri
Jun 13 2017 06:20
@Milamanieva you need = for assignment.
Donnie
@Donnie-D
Jun 13 2017 06:20
@Masd925 so number is the trick/keyword to use if i want to play about with a number string then
Revanth Kumar Reddy
@VoduruRevanth
Jun 13 2017 06:20
Hi , I got stuck with Profile Lookup challenge, Can you please help me with this?
John
@j0hnc
Jun 13 2017 06:21
:ok:
Milamanieva
@Milamanieva
Jun 13 2017 06:21
= in front of myStr? @Manish-Giri
Revanth Kumar Reddy
@VoduruRevanth
Jun 13 2017 06:21

Here is my code
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(firstName === contacts[i].firstName){
if(contacts[i].hasOwnProperty(prop)){
return contacts[i].prop;
}
else{
return "No such property";
}

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

// Only change code above this line
}

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

Manish Giri
@Manish-Giri
Jun 13 2017 06:21
@Milamanieva after it like var myStr = ....
Markus Kiili
@Masd925
Jun 13 2017 06:21