These are chat archives for FreeCodeCamp/HelpJavaScript

6th
Jun 2017
Joe Devlin
@NorthDecoder
Jun 06 2017 00:00
@klondikepanther I understand. You are using console.log in several places. It is not immediately clear which item is getting logged, so put an identifier in your console log like: console.log( "myVariable: "+myVariable); also consider using console.dir(myVariable) if you know you are looking at an object.
Fareed F
@IamFareel
Jun 06 2017 00:00
so I solved the Iterate Through an Array with a For Loop challenge but i still dont fully understand it. I dont understand i < myArr.length;
Jonatan Roytgarts
@jonatan-roytgarts
Jun 06 2017 00:00
Anyone has finished Check for Palindromes?
D-C0DE
@D-C0DE
Jun 06 2017 00:02
trying to output "Hi world" to the console log and I was sure everything was correct, as simple as it seems. this is what I have

function reusableFunction () {
console.log("Hi world");
}

reusableFunction();

Jonatan Roytgarts
@jonatan-roytgarts
Jun 06 2017 00:02
@IamFareel myArr.length returns how many elements the array has
Raymond
@Raymondshen
Jun 06 2017 00:02
@IamFareel it took me a while to understand that problem too haha. but im not really the expert to explain it.
Fareed F
@IamFareel
Jun 06 2017 00:03
so since var myArr = [ 2, 3, 4, 5, 6]; has 5 elements, arr.length would be 5? @jonatan-roytgarts ?
cooperterwin
@cooperterwin
Jun 06 2017 00:03
How do I return a false string value when a .hasOwnProperty doesn't return true?
Sarah
@aggibabi
Jun 06 2017 00:04
image.png
Manish Giri
@Manish-Giri
Jun 06 2017 00:04
@cooperterwin it tells you what to return in that case..
Sarah
@aggibabi
Jun 06 2017 00:04
Any suggestions for what I am doing?
Manish Giri
@Manish-Giri
Jun 06 2017 00:05
@aggibabi did you change line 17?
cooperterwin
@cooperterwin
Jun 06 2017 00:05
@Manish-Giri yes it says to return the value from the object when true, I'm just unsure of how to set a string to return when false
Manish Giri
@Manish-Giri
Jun 06 2017 00:06
what does it say to return when false?
@cooperterwin
cooperterwin
@cooperterwin
Jun 06 2017 00:06
"Not Found"
Manish Giri
@Manish-Giri
Jun 06 2017 00:06
so return that
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:06
@IamFareel , are you able to scroll up? could could run over the convo I had with @Raymondshen and see if that helps?
cooperterwin
@cooperterwin
Jun 06 2017 00:07
return "Not Found";
Ignore that
Sarah
@aggibabi
Jun 06 2017 00:07
@ @Manish-Giri I did
Pradeep Ghimiré
@fred-pdp
Jun 06 2017 00:07

function factorialize(num) {

for ( var n = 1; n < num; n++){
num = n*num;

}

return num;
}

factorialize(5);

Manish Giri
@Manish-Giri
Jun 06 2017 00:07
@aggibabi why?
Sarah
@aggibabi
Jun 06 2017 00:08
TO conceptualize
but I can put back the other array. It still doesn't work
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:08
@aggibabi largest needs resetting to 0 for each iteration of first loop
Joe Devlin
@NorthDecoder
Jun 06 2017 00:09
@klondikepanther Does your function run only once on document ready?
$(document).ready(function() { 
$("#search").on("click", function() {
Raymond
@Raymondshen
Jun 06 2017 00:09
// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line
for (var i = 0; i < myArr.length; i++) {
  var total =0;
 total += myArr[i];

}
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:09
@aggibabi I mean for the first for loop
Raymond
@Raymondshen
Jun 06 2017 00:09
@AJ-Brommy not sure why it becomes 6? im trying to get 20/
Manish Giri
@Manish-Giri
Jun 06 2017 00:09
@aggibabi the problem is with the .push() statement
line 13
you're pushing only once with the latest value in largest
where as the challenge requires the largest value from EACH sub array.
Thom
@klondikepanther
Jun 06 2017 00:10
@NorthDecoder yes I think so.
Manish Giri
@Manish-Giri
Jun 06 2017 00:11
@Raymondshen var total =0;
declare this outside the loop.
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:11
@Raymondshen you are declaring a var in each iteration reseting the total everytime
Manish Giri
@Manish-Giri
Jun 06 2017 00:11
it becomes 0 + 6, for the last time
so you get 6
@Raymondshen
Raymond
@Raymondshen
Jun 06 2017 00:11
@Manish-Giri @AJ-Brommy oh
so it has to be in a global scope
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:12
@aggibabi yes your .push needs to go at the end of the first for loop
@Raymondshen global to the function yes
Joe Devlin
@NorthDecoder
Jun 06 2017 00:12
@klondikepanther It seems like when I click on the search button no function is being called.
Raymond
@Raymondshen
Jun 06 2017 00:13
@AJ-Brommy why cant it be local?
cooperterwin
@cooperterwin
Jun 06 2017 00:13
@Manish-Giri I'm still confused. I'm told to return a property value when a .hasOwnProperty is true, but then also return "Not Found" if it is false, so I'm unsure how to code two different returns
Manish Giri
@Manish-Giri
Jun 06 2017 00:13
use an if/else
@cooperterwin
if( //property found) {
return value;
}
else 
   return "not found";
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:14
@Raymondshen as I said, it resets it everytime it iterates. because everytime it is executed total is set to 0; so local to the loop cannot work.
Raymond
@Raymondshen
Jun 06 2017 00:14
@AJ-Brommy i understand the localscope variables can be used within the function but with global scope it can be used for other functions too.
Long Nguyen
@longnt80
Jun 06 2017 00:14
@Raymondshen doesn't matter if it's global or local, it has to be outside the loop or it will get back to 0 at every turn of the loop
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:15
@Raymondshen I meant local to the function, so it is global to all loops etc "within" that function.
Cesar Fernandez
@Diamond713
Jun 06 2017 00:15
How would you convertToF(-30) should return a value of -22
Manish Giri
@Manish-Giri
Jun 06 2017 00:15
@Diamond713 there's a formula on the left
Thom
@klondikepanther
Jun 06 2017 00:16
@NorthDecoder so you can't see the objects in the dev tools? or is that a different issue?
Raymond
@Raymondshen
Jun 06 2017 00:16
@AJ-Brommy ahhh so when its within the function the variable is dead set to the data and if its global the function will only take the variables data once?
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:16
@Raymondshen if you declare the var total = 0; inside your function, it will be local to that function, so other functions cannot use it, but it will be global to anything inside that function. I don't know if I am making sense of making it worse? lol
SopheaS
@SopheaS
Jun 06 2017 00:16
Hi guys! i need help on my 228 task.

var Bike = function() {

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

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

};

var myCar = new Car();
var myBike = new Bike();
myBike.setGear(4);

Cesar Fernandez
@Diamond713
Jun 06 2017 00:17
@manishgiri This one? 9/5 + 32
Long Nguyen
@longnt80
Jun 06 2017 00:17
@Raymondshen no, it doesn't matter if total is global or local
Manish Giri
@Manish-Giri
Jun 06 2017 00:17
@SopheaS gear += a;
should be just =
SopheaS
@SopheaS
Jun 06 2017 00:17
ok
Raymond
@Raymondshen
Jun 06 2017 00:17
@longnt80 oh
@AJ-Brommy oh i see.
Long Nguyen
@longnt80
Jun 06 2017 00:18
when you put total = 0 inside the loop, it will become 0 again
SopheaS
@SopheaS
Jun 06 2017 00:18
@Manish-Giri thank you so much
CamperBot
@camperbot
Jun 06 2017 00:18
sopheas sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5855 | @manish-giri |http://www.freecodecamp.com/manish-giri
Leonardo Martinez
@ulosturedge
Jun 06 2017 00:18
Hey guys need some help writing literals
Sarah
@aggibabi
Jun 06 2017 00:18
image.png
Manish Giri
@Manish-Giri
Jun 06 2017 00:18
@SopheaS :+1:
Raymond
@Raymondshen
Jun 06 2017 00:18
@longnt80 @AJ-Brommy ahhhh i get it now haha thanks guys :)
CamperBot
@camperbot
Jun 06 2017 00:18
:warning: raymondshen already gave aj-brommy points
:cookie: 327 | @longnt80 |http://www.freecodecamp.com/longnt80
raymondshen sends brownie points to @longnt80 and @aj-brommy :sparkles: :thumbsup: :sparkles:
Sarah
@aggibabi
Jun 06 2017 00:18
So what is going on there?
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:18
@Raymondshen I'm not sure what you are saying. True global, you would declare a var outside the function.
cooperterwin
@cooperterwin
Jun 06 2017 00:19
@Manish-Giri The If/else is telling me there is an illegal return statement
Manish Giri
@Manish-Giri
Jun 06 2017 00:19
@cooperterwin show code
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:19
@Raymondshen :+1: oki doki
Leonardo Martinez
@ulosturedge
Jun 06 2017 00:19
FirstLine
/secondLine/
ThirdLine
Raymond
@Raymondshen
Jun 06 2017 00:19
@AJ-Brommy yeah i notice that im doing a loop and forgot its not within a function but i understand now that if i indicate the variable inside the loop the variable will be reseted to 0
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:19
@aggibabi at the "end" of the first for ;)
Leonardo Martinez
@ulosturedge
Jun 06 2017 00:20
var myStr = "FirstLine\n\SecondLine\\rThirdLine"
doesn't work...
Manish Giri
@Manish-Giri
Jun 06 2017 00:21
wasn't there a period at the end?
@ulosturedge
Cesar Fernandez
@Diamond713
Jun 06 2017 00:21
Ey @Manish-Giri how do i put the formula on the left side
Manish Giri
@Manish-Giri
Jun 06 2017 00:21
or a ;
@ulosturedge
Long Nguyen
@longnt80
Jun 06 2017 00:21

@Raymondshen

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

// Only change code below this line
var total = 0;
for (var i = 0; i < myArr.length; i++) {
 total =0;
 total += myArr[i];

}

for example, total is global in this case but you will get total reset to 0 at every turn

AJ Brommy
@AJ-Brommy
Jun 06 2017 00:21
@Raymondshen sorry i thought you were using functions lol.. in this case then it would require a global variable
Leonardo Martinez
@ulosturedge
Jun 06 2017 00:21
lol thanks Manish...
Manish Giri
@Manish-Giri
Jun 06 2017 00:21
@Diamond713 how what?
the formula is on the left already.
Raymond
@Raymondshen
Jun 06 2017 00:22
@longnt80 yes because its inside the loop? if its outside the loop the total wouldnt be reset right?
Long Nguyen
@longnt80
Jun 06 2017 00:22
yes
Raymond
@Raymondshen
Jun 06 2017 00:22
@AJ-Brommy yeah hahha thanks again
CamperBot
@camperbot
Jun 06 2017 00:22
raymondshen sends brownie points to @aj-brommy :sparkles: :thumbsup: :sparkles:
:warning: raymondshen already gave aj-brommy points
cooperterwin
@cooperterwin
Jun 06 2017 00:22
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");
@Manish-Giri
Cesar Fernandez
@Diamond713
Jun 06 2017 00:22
Oh ok
Raymond
@Raymondshen
Jun 06 2017 00:22
@longnt80 I see, I get it now :)
@longnt80 thank you for the clarification.
CamperBot
@camperbot
Jun 06 2017 00:22
raymondshen sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:warning: raymondshen already gave longnt80 points
Manish Giri
@Manish-Giri
Jun 06 2017 00:23
@cooperterwin if(checkObj === true) {
here
you're checking if the function name is true?
what will that do?
cooperterwin
@cooperterwin
Jun 06 2017 00:24
Here are the instructions
Long Nguyen
@longnt80
Jun 06 2017 00:24
@Raymondshen here's a website that you can paste your code and it will run through each step so you can see how your code is working
http://pythontutor.com/visualize.html#mode=display
cooperterwin
@cooperterwin
Jun 06 2017 00:24
Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".
I know I'm doing it wrong
Keon Samuel
@keonsam
Jun 06 2017 00:24
or if(checkObj)
Manish Giri
@Manish-Giri
Jun 06 2017 00:24

@cooperterwin

to test myObj for checkProp.

Raymond
@Raymondshen
Jun 06 2017 00:24
@longnt80 thank you
CamperBot
@camperbot
Jun 06 2017 00:24
raymondshen sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:warning: raymondshen already gave longnt80 points
Manish Giri
@Manish-Giri
Jun 06 2017 00:24
@cooperterwin myObj.hasOwnProperty(checkProp);
this is what you need to check for
and if you close the } after this line
function checkObj(checkProp) {
  // Your Code Here
  myObj.hasOwnProperty(checkProp);
}
your function has nothing else
so the illegal return
error
Keon Samuel
@keonsam
Jun 06 2017 00:25
or if(checkObj) return whatever
no curly braces
Thom
@klondikepanther
Jun 06 2017 00:27
@NorthDecoder ooohhh.... whatever I have going on dosent get to the second API call
Joe Devlin
@NorthDecoder
Jun 06 2017 00:27
@klondikepanther Ok. I saved the pen to my own codepen account it seems to do something differently now. Will you give me a hint to the link to the wikipedia API you are using.
Thom
@klondikepanther
Jun 06 2017 00:29
@NorthDecoder is this what you are looking for? https://www.mediawiki.org/wiki/API:Main_page
Joe Devlin
@NorthDecoder
Jun 06 2017 00:30
@klondikepanther The error is
TypeError: data.query.pages[id].redirects is undefined,
however
data is defined, what about the stuff right after it. query.pages[id].redirects
cooperterwin
@cooperterwin
Jun 06 2017 00:30
Still not getting it @Manish-Giri
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  myObj.hasOwnProperty(checkProp);

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

// Test your code by modifying these values
checkObj("gift");
Manish Giri
@Manish-Giri
Jun 06 2017 00:31
@cooperterwin return myObj.checkProp;
use bracket notation
. notation doesn't work for variables
Thom
@klondikepanther
Jun 06 2017 00:31
@NorthDecoder the [id] should be taken from the idArray
cooperterwin
@cooperterwin
Jun 06 2017 00:31
Thank you for your help!
Sarah
@aggibabi
Jun 06 2017 00:32
image.png
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:33
@cooperterwin you can comment out the line below where it says // your code here... and you don't need === true, if (myObj.hasOwnProperty(checkProp)) will return true or false accordingly
Sarah
@aggibabi
Jun 06 2017 00:33
image.png
I am almost there. But don't quite get this part.
Thom
@klondikepanther
Jun 06 2017 00:33
@NorthDecoder nope the id i took from the object so it should be ok
Sarah
@aggibabi
Jun 06 2017 00:33
@AJ-Brommy @Manish-Giri thanks for the help btw
CamperBot
@camperbot
Jun 06 2017 00:33
aggibabi sends brownie points to @aj-brommy and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 274 | @aj-brommy |http://www.freecodecamp.com/aj-brommy
:star2: 5856 | @manish-giri |http://www.freecodecamp.com/manish-giri
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:34
@aggibabi same as earlier, you need to reset your "largest" at the beginning of each iteration of the parent for loop
Manish Giri
@Manish-Giri
Jun 06 2017 00:34
@aggibabi move line 15 up
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:35
@aggibabi yes I think you have too many brackets {}}
@aggibabi if you indent you code neatly so you can see where each level is helps
Manish Giri
@Manish-Giri
Jun 06 2017 00:37
@aggibabi try to post your code here, so I can try it out
hard to do that in screenshot
Joe Devlin
@NorthDecoder
Jun 06 2017 00:37
@klondikepanther What should data.query return?
Fareed F
@IamFareel
Jun 06 2017 00:37
For the Nesting For Loops challenge i'm following the example provided but it keeps returning with 1
Sarah
@aggibabi
Jun 06 2017 00:37

function largestOfFour(arr) {
// You can do this!
var largest = 0;
var arr1 =[];
for( var i= 0; i <arr.length; i++){ for(var j =0; j < arr[i].length; j++){ if(arr[i][j] > largest){
largest = arr[i][j];
}
}
arr1.push(largest);
}
return arr1;
}

largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

@Manish-Giri ^
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:38
for(var i =0; i < arr.length; i++){
    for(var j = 0; j < arr.length[i]; j++){
        // example
    }
}
@aggibabi
Sarah
@aggibabi
Jun 06 2017 00:38
@AJ-Brommy reset my largest?
Ravi Kishore Thella
@ravikishorethella
Jun 06 2017 00:39
@Diamond713 fahrenheit = (celsius * 9/5) + 32;
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:39
@aggibabi largest will become 27, on the second subset you will be checking if they are higher than 27, which they are not, but you want to find the highest in the new subset
Manish Giri
@Manish-Giri
Jun 06 2017 00:39
@aggibabi there's a logic error in your code
if(arr[i][j] > largest){
        largest = arr[i][j];
       }
[13, 27, 18, 26]
this is your first sub array
after you finish iterating it, largest will be 27
[4, 5, 1, 3]
Thom
@klondikepanther
Jun 06 2017 00:40
@northdecoder data.query should return, if this makes sense, the unopened object. are data and query the same thing? did i define my query as data?
Manish Giri
@Manish-Giri
Jun 06 2017 00:40
this is your next sub array
and this line if(arr[i][j] > largest){
Cesar Fernandez
@Diamond713
Jun 06 2017 00:40
Thanks Ravi got it!!!
Manish Giri
@Manish-Giri
Jun 06 2017 00:40
checks if anything in that sub array is larger than 27
which is not
so largest remains 27
you see the bug?
@aggibabi
Sarah
@aggibabi
Jun 06 2017 00:41
Yes. Just don't know how to fix it yet. @Manish-Giri
Hammad
@newnewb
Jun 06 2017 00:41
guys any help with the "Search & Replace"?
NOTE: Preserve the case of the original word when you are replacing it. For example if you mean to replace the word "Book" with the word "dog", it should be replaced as "Dog"
Manish Giri
@Manish-Giri
Jun 06 2017 00:41
@aggibabi do you know how to use .map()?
Hammad
@newnewb
Jun 06 2017 00:41
how can i do this?
Sarah
@aggibabi
Jun 06 2017 00:41
@Manish-Giri yes
but I want to get better with my for loops
SopheaS
@SopheaS
Jun 06 2017 00:42
@aggibabi how can you capture your screen and put it in here?
I do not know how to do it can you please help me?
Sarah
@aggibabi
Jun 06 2017 00:42
@SopheaS I have a PC. there is 'prt sc' button on my keyboard
then paste
it copies it to your clipboard
Manish Giri
@Manish-Giri
Jun 06 2017 00:43
@aggibabi okay, then you can use .sort()
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:43
 for( var i= 0; i <arr.length; i++){       
    largest = 0;
    for(var j =0; j < arr[i].length; j++){
      if(arr[i][j] > largest){
        largest = arr[i][j];   
      }
    }
    arr1.push(largest);
  }
@aggibabi
Manish Giri
@Manish-Giri
Jun 06 2017 00:44
  1. sort each sub array from largest to smallest
  2. as you iterate through each sub array, push the first element into arr1
  3. return arr1
done.
Joe Devlin
@NorthDecoder
Jun 06 2017 00:44
@klondikepanther I am finding that codepen is cacheing the page, that I must do a hard refresh for any changes to take effect after saving.
Manish Giri
@Manish-Giri
Jun 06 2017 00:44
@aggibabi
James Kirby
@JamesKirby17
Jun 06 2017 00:45

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

return [arr] + 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));
can someone plz help me write this quee im so confused

SopheaS
@SopheaS
Jun 06 2017 00:45
@aggibabi I tried but it did not work.
Fareed F
@IamFareel
Jun 06 2017 00:45
For the Nesting For Loops challenge I dont see an array defined, it only says var product = 1;
so when I write the loop condition as i < arr.length; what array is it looking at?
James Kirby
@JamesKirby17
Jun 06 2017 00:45
i already changed the line that syas change this line
Sarah
@aggibabi
Jun 06 2017 00:45
@AJ-Brommy putting the variable largest inside the first loop. What is the logic behind that?
It works, but I want to know hy
why*
Manish Giri
@Manish-Giri
Jun 06 2017 00:46
so that you start afresh with largest
for every sub array
Sarah
@aggibabi
Jun 06 2017 00:46
@SopheaS try pasting it to a word document first
Manish Giri
@Manish-Giri
Jun 06 2017 00:46
@aggibabi
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:46
@aggibabi i told you, and @Manish-Giri explained it another way! Because you need to reset it before it moves onto the next subset.
SopheaS
@SopheaS
Jun 06 2017 00:47
@aggibabi yes and then?
Sarah
@aggibabi
Jun 06 2017 00:47
ok @AJ-Brommy @Manish-Giri thanks.
CamperBot
@camperbot
Jun 06 2017 00:47
aggibabi sends brownie points to @aj-brommy and @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: aggibabi already gave aj-brommy points
:warning: aggibabi already gave manish-giri points
Thom
@klondikepanther
Jun 06 2017 00:47
@NorthDecoder I think that is code pens default setting but it can be changed in the settings under behaviour
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:47
Without it, it stays the largest of "all" arrays. You are looking for the largest in a sub array @aggibabi
Sarah
@aggibabi
Jun 06 2017 00:47
@SopheaS just to see that it worked. It should paste here. It sometimes takes a little while to load
@AJ-Brommy ohhh yes ok. thanks
CamperBot
@camperbot
Jun 06 2017 00:48
aggibabi sends brownie points to @aj-brommy :sparkles: :thumbsup: :sparkles:
:warning: aggibabi already gave aj-brommy points
SopheaS
@SopheaS
Jun 06 2017 00:48
ok it works on Ms word
James Kirby
@JamesKirby17
Jun 06 2017 00:48

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

return [arr] + 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));
can someone plz help me write this quee im so confused

Joe Devlin
@NorthDecoder
Jun 06 2017 00:48
@klondikepanther Using console.dir(data.query); I am able to drill down to the ID and cannot find a key called redirects , but I do find redirect singular with no values associated with it.
SopheaS
@SopheaS
Jun 06 2017 00:49
image.png
@aggibabi I got it thank you so much
CamperBot
@camperbot
Jun 06 2017 00:49
sopheas sends brownie points to @aggibabi :sparkles: :thumbsup: :sparkles:
:cookie: 253 | @aggibabi |http://www.freecodecamp.com/aggibabi
Jay
@DatumEight
Jun 06 2017 00:49
Hey Guys, i'm currently working on the condense arrays with ".reduce", i passed it and all but it did not make me declare the arguements even though they kind of seem contextual. in a real-world situation will i need to declare them?
image.png
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:51
@DatumEight you have declared them :P
Jay
@DatumEight
Jun 06 2017 00:52
@AJ-Brommy even though they have no declared value? or is it expected as user input?
Joe Devlin
@NorthDecoder
Jun 06 2017 00:52
@klondikepanther Family just came home, gotta say hello and get ready for dinner ... Good luck!
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:53
@DatumEight I believe it is the way the .reduce() works, it grabs two values, and puts them in there
@DatumEight i think
Raymond
@Raymondshen
Jun 06 2017 00:54
@AJ-Brommy hey AJ i got a question real quick just some clarification again.
Jay
@DatumEight
Jun 06 2017 00:54
@AJ-Brommy so in that case they would be (4,0)?
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:54
@DatumEight i think i need to look it up lol
Jay
@DatumEight
Jun 06 2017 00:55
@AJ-Brommy 4 being the accum, 0 being current value.
cooperterwin
@cooperterwin
Jun 06 2017 00:56
@Manish-Giri @AJ-Brommy able to help with this?
//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 (contacts.hasOwnProperty(firstName) === true && contacts.hasOwnProperty(prop) === true) {
     return contacts[prop];
   }
    else if (contacts.hasOwnProperty(firstName) === false) {
      return "No such contact";
    }
    else {
      return "No such property";
    }

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Thom
@klondikepanther
Jun 06 2017 00:56
@NorthDecoder thanks for your time I got some stuff to work with now!
CamperBot
@camperbot
Jun 06 2017 00:56
klondikepanther sends brownie points to @northdecoder :sparkles: :thumbsup: :sparkles:
:cookie: 315 | @northdecoder |http://www.freecodecamp.com/northdecoder
cooperterwin
@cooperterwin
Jun 06 2017 00:56
regardless of input, i end up with "no such contact"
Raymond
@Raymondshen
Jun 06 2017 00:56

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[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]]);
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:56
@DatumEight i think so
Raymond
@Raymondshen
Jun 06 2017 00:56
@AJ-Brommy what im understanding is that the i = indicates the outside array which has the indexes of 0 1 2? and for j is the inside of each indexes [0] = [1,2]? and j would be 1?
Greg Duncan
@GregatGit
Jun 06 2017 00:56
@cooperterwin remove this line from the loop return "No such property";
Jay
@DatumEight
Jun 06 2017 00:57
@AJ-Brommy thanks
CamperBot
@camperbot
Jun 06 2017 00:57
datumeight sends brownie points to @aj-brommy :sparkles: :thumbsup: :sparkles:
:cookie: 275 | @aj-brommy |http://www.freecodecamp.com/aj-brommy
cooperterwin
@cooperterwin
Jun 06 2017 00:57
@GregatGit Why is that? it says if it finds the name, but the input property doesnt exist, I should return "No such property"
AJ Brommy
@AJ-Brommy
Jun 06 2017 00:58
@Raymondshen 0,1,2 yes
Greg Duncan
@GregatGit
Jun 06 2017 00:58
@cooperterwin this will not loop through the all the contacts - it will check the first one and return something
Raymond
@Raymondshen
Jun 06 2017 00:59
@AJ-Brommy so arr [i][j] would be 0*1 which is 0 and the product is 0?
cooperterwin
@cooperterwin
Jun 06 2017 00:59
So what loop do I set up? @GregatGit
Greg Duncan
@GregatGit
Jun 06 2017 01:00
@cooperterwin your first line needs to be
- if this is the contact do something
// do nothing if its not so you can loop to the next contact
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:01
@DatumEight i think because previousVal is the accumulater that when we add currentVal to it, it then takes the new accumulater, and reuses it with the new value, for the next currentVal. Kinda like a loop.
Greg Duncan
@GregatGit
Jun 06 2017 01:01
@cooperterwin the moment you hit a return the function ends
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:02
@Raymondshen arr[0] would be the first element in an array, if it is another array, and you want the first element for the new sub array, it would be arr[0][0]
@Raymondshen first is always 0 in the array indexes
Raymond
@Raymondshen
Jun 06 2017 01:03
@AJ-Brommy yeah i understand that logic, what im a bit confused on is the nested part.
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:04
@Raymondshen i'm not sure if i have fully understood your query and if i've answered it ? :/
@Raymondshen product needs to start as 1, because anything times 0 = 0, so the answer would always be 0.
Raymond
@Raymondshen
Jun 06 2017 01:06
@AJ-Brommy so for arr[0][1] the "0" would be the first array within the cluster right? Like 0 = [1 , 2] 1=[3,4] 2=[5,6,7]. For [1] it would go into the [1,2]?
Long Nguyen
@longnt80
Jun 06 2017 01:06
@Raymondshen https://repl.it/ISza/2 click Run
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:06
@Raymondshen yes
@Raymondshen and what would it return?
Raymond
@Raymondshen
Jun 06 2017 01:08
1?
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:08
nope
lol
arrays have 0 indexing
Raymond
@Raymondshen
Jun 06 2017 01:08
oh
2
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:08
correct
Raymond
@Raymondshen
Jun 06 2017 01:08
forgot 0 = 1 1 = 2
alrigth i get it now for the nesting part haha it was kind of complicated.
@AJ-Brommy @longnt80 that link u sent me helped! and thank you both again.
CamperBot
@camperbot
Jun 06 2017 01:09
raymondshen sends brownie points to @aj-brommy and @longnt80 :sparkles: :thumbsup: :sparkles:
:warning: raymondshen already gave longnt80 points
:cookie: 276 | @aj-brommy |http://www.freecodecamp.com/aj-brommy
Long Nguyen
@longnt80
Jun 06 2017 01:10
@Raymondshen just use console.log to see the values then you'll understand
Corey Smith
@CoreyCache
Jun 06 2017 01:11
does anyone have a moment to answer a question about creating Objects?
Raymond
@Raymondshen
Jun 06 2017 01:11
@longnt80 yup i was playing with it and it helped me understand it easier becasue your version provided a simplified version which helped :)
Long Nguyen
@longnt80
Jun 06 2017 01:11
@Raymondshen you'll need console.log a lot to debug in more complicated challenges
Raymond
@Raymondshen
Jun 06 2017 01:12
@longnt80 okay thanks for the heads up :D
CamperBot
@camperbot
Jun 06 2017 01:12
raymondshen sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:warning: raymondshen already gave longnt80 points
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:12
@CoreyCache ask away
Corey Smith
@CoreyCache
Jun 06 2017 01:14
My goal is to take some arrays of data and store them into objects. for example creating a persons object with name, age, etc. but i want to create MULTIPLE persons dynamically. like paste some data into a field, then have my function save the data in objects without knowing how many "persons" there will be at first
var persons = {
person1: {
name: "",
age:""
},
person2: {
name: "",
age:""
},
person3: {
name: "",
age:""
}
}
Hernan Mendez
@hernanmendez
Jun 06 2017 01:16
hey so i'm on dataviz on the roguelike project, so far this is what i have https://codepen.io/hernanmendez/pen/owgJgE , the problem is that i want to add an editor mode, but since the white areas are done using 'blocks' each block has it's position on the top-left i don't know if it's not gonna be confusing to do an editor mode
Corey Smith
@CoreyCache
Jun 06 2017 01:16
something like that, but i wont know how many persons there will be at first
Joseph
@revisualize
Jun 06 2017 01:17
@CoreyCache Umm... I have a question.
Corey Smith
@CoreyCache
Jun 06 2017 01:17
furthermore, i want to take some data like this: Corey 23
John 25
Jacob 24
and save them into their own objects
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:17
@CoreyCache doesn't it just get left as person instead of 1 2 or 3. and you access it like you do an array person[1]?
@CoreyCache this may be beyond my current level
Joseph
@revisualize
Jun 06 2017 01:18
@CoreyCache I'm confused.
Hernan Mendez
@hernanmendez
Jun 06 2017 01:18
@CoreyCache persons[putTheNameHere] = {}
Joseph
@revisualize
Jun 06 2017 01:18
@CoreyCache You said you wanted to take an array of people ... Then you made an object.
Corey Smith
@CoreyCache
Jun 06 2017 01:18
hmm yes? lets say i have a tool where i'll paste a list of names and ages, and from that pasted list i want to hit "go" and it saves this data into objects
Hernan Mendez
@hernanmendez
Jun 06 2017 01:19
@CoreyCache give me the array you want to use to give you an example
Long Nguyen
@longnt80
Jun 06 2017 01:19
@CoreyCache oh yeah, in Advanced Algorithm you have to make a function like that to update an object
Corey Smith
@CoreyCache
Jun 06 2017 01:21
lets say i have this data, all at once... Corey 23 Chicago
John 25 Atlanta
Jacob 24 Boston

I want a function, that will turn it into this var people {
person1: {
name: "corey",
age: 23,
city: "chicago"
},
person2: {
name: "John",
age: 25,
city: "Atlanta"
},
person3: {
name: "Jacob",
age: 24,
city: "Boston"
}

}

so person1, person2, that's the part i dont know. do i need to tell my function to create an "infinite" number of persons, because the data could change the next go around
Long Nguyen
@longnt80
Jun 06 2017 01:22
@CoreyCache create a function
function addPeople(name, age, city) {.....
Corey Smith
@CoreyCache
Jun 06 2017 01:23
@longnt80 yes, i guess what i'm not understanding is, how would i access the different people? would it be addPeople[0].name to get the first persons name? or how would that work?
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:23
@CoreyCache infinite no, that would cause big problems!
Hernan Mendez
@hernanmendez
Jun 06 2017 01:23

@CoreyCache for this kind of algorithm is best to use multi-level arrays

like
function updatePersons(arr){
var object={};
for(var i=1;i<=arr.length;i++){
object['person'+i] = {
name = arr[i][0]
}
}

}

ans once you are done you return the object
Baibhav Gautam
@baibhavx
Jun 06 2017 01:23
@CoreyCache you would use the length of the array to find out how many people are there. then you could append a new number before each entry. person1, person2... until all person in the array are accounted for.
Hernan Mendez
@hernanmendez
Jun 06 2017 01:24
i can explain you a little bit more if you get confused with my code @CoreyCache the idea is to learn
Corey Smith
@CoreyCache
Jun 06 2017 01:24
hmm ok that's kinda what i needed to know @baibhavx @hernanmendez
the person1, person2 thing, i wasn't aware if i needed to declare those values before my data is sent to the function, or if i could create them dynamically once the function is run
and the function wouldn't be run until you hit go
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:25
@CoreyCache maybe also there is a way to find the length of the object, like we do in arrays? arr.length? is there an obj.length? that could enable you to know how many persons are in the obj, to enable to run a loop to pull them out?
Baibhav Gautam
@baibhavx
Jun 06 2017 01:25
yeah keys in an objects can be a string and you can dynamically create strings @CoreyCache
Hernan Mendez
@hernanmendez
Jun 06 2017 01:26
@CoreyCache you get it?
Baibhav Gautam
@baibhavx
Jun 06 2017 01:26
@AJ-Brommy you can use Object.keys(yourObjName).length to find out the number of key-value pairs
Corey Smith
@CoreyCache
Jun 06 2017 01:27
i can see that... so lets say there are 5 people. i'll want to end up with 5 sub-objects created for this run. i'll have to "dynamically" create those with a for loop. like @hernanmendez said... with this code or(var i=1;i<=arr.length;i++){
object['person'+i] = {
name = arr[i][0]
}
}
"i" would be the person i'm on, so if there's five people, my loop would stop at five.
Hernan Mendez
@hernanmendez
Jun 06 2017 01:28
wait i have a mistake it would be arr[i-1]
Baibhav Gautam
@baibhavx
Jun 06 2017 01:28
you will want to start from 0 instead of 1
and if you want person1 use i + 1
Corey Smith
@CoreyCache
Jun 06 2017 01:28
this could would gie me object person1, object person2, etc. then i can say object person2.name, object person2,age
Hernan Mendez
@hernanmendez
Jun 06 2017 01:29
@CoreyCache yeah
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:29
@baibhavx so in this case how would we use that? persons.keys(person).length?
Hernan Mendez
@hernanmendez
Jun 06 2017 01:29
using the brackets @AJ-Brommy
Baibhav Gautam
@baibhavx
Jun 06 2017 01:29
no, Object,keys(person).length @AJ-Brommy
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:29
@baibhavx i need to work on my objects for sure
Baibhav Gautam
@baibhavx
Jun 06 2017 01:29
Object.keys(person).length
@AJ-Brommy
cool
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:30
@baibhavx Object is a keyword?
Corey Smith
@CoreyCache
Jun 06 2017 01:30
how do i paste code? i forgot
Baibhav Gautam
@baibhavx
Jun 06 2017 01:30
Not exactly a key word but its the class name for all objects
Hernan Mendez
@hernanmendez
Jun 06 2017 01:30
use ctrl+c and ctrl+v
Keon Samuel
@keonsam
Jun 06 2017 01:30
something like Maths
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:30
@baibhavx OHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH!!!!!!!!!! thanks @baibhavx I get it now, I've just learned something that I am sure will come in handy some day!!
CamperBot
@camperbot
Jun 06 2017 01:30
aj-brommy sends brownie points to @baibhavx :sparkles: :thumbsup: :sparkles:
:cookie: 328 | @baibhavx |http://www.freecodecamp.com/baibhavx
Baibhav Gautam
@baibhavx
Jun 06 2017 01:31
but if you're asking if you would use Object.keys(someName).length, you are correct!
@AJ-Brommy glad it helped :)
Hernan Mendez
@hernanmendez
Jun 06 2017 01:32
@AJ-Brommy you will learn about prototype's in the future for know, worry about getting your FCC's challenges right
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:32
@baibhavx yes that's what i was asking. I wasn't sure if you were writing Object meaning "whatever the object name is". like when we use array's and talk about em we go arr.length. but it could be myarr, etc. but I get it now.
@baibhavx yeah that's cool, its just a curiousity that popped up while thinking about helping @CoreyCache
Corey Smith
@CoreyCache
Jun 06 2017 01:33
(shift+enter for line break) var code = "formatted";
var persons = { person1: { name: "", age:"" }, person2: { name: "", age:"" }, person3: { name: "", age:"" } }
Baibhav Gautam
@baibhavx
Jun 06 2017 01:34
I see @AJ-Brommy, yes Object.keys is a class method, so you can use it for any js object.
Corey Smith
@CoreyCache
Jun 06 2017 01:34
sorry, was trying to get that working
Long Nguyen
@longnt80
Jun 06 2017 01:34
@CoreyCache you can post your code in codepen
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:34
@baibhavx thanks
CamperBot
@camperbot
Jun 06 2017 01:34
aj-brommy sends brownie points to @baibhavx :sparkles: :thumbsup: :sparkles:
:warning: aj-brommy already gave baibhavx points
Baibhav Gautam
@baibhavx
Jun 06 2017 01:39
@CoreyCache to paste in your code surround your code with ```
Joel Korcsmaros
@lossness
Jun 06 2017 01:41
another day another bootcamp course! Can anyone tell me what's wrong with my code:

var nameString = function(name) {
return "Hi, I am" + " " + name;

};
nameString(Max);

I know its not in quotes
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:42
"Max"
Joel Korcsmaros
@lossness
Jun 06 2017 01:42
:D
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:42
lol
Joel Korcsmaros
@lossness
Jun 06 2017 01:42
@AJSclyn thx for reply
CamperBot
@camperbot
Jun 06 2017 01:42
lossness sends brownie points to @ajsclyn :sparkles: :thumbsup: :sparkles:
:cookie: 283 | @ajsclyn |http://www.freecodecamp.com/ajsclyn
Joseph
@revisualize
Jun 06 2017 01:43
@CoreyCache Show me an array and I'll show you how to make it happen.
Joseph
@revisualize
Jun 06 2017 01:48
@CoreyCache Don't have an array?
AJ Brommy
@AJ-Brommy
Jun 06 2017 01:52
Hey guys, I am accomplishing my basic algorithm challenges, but I suspect I should be doing them better?...
Some feedback would be cool...
What are your thoughts about this one...
Is there a better way to write with what we have supposed to of learned so far?
function truncateString(str, num) {
  // Clear out that junk in your trunk
  if(str.length > num && num > 3){
    str = str.slice(0, num-3)+"...";
  }
  else if(num <= 3){
    str = str.slice(0, num)+"...";
  }
  //console.log(str);
  return str;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Challenges "Truncate a string"
Joseph
@revisualize
Jun 06 2017 02:02
@AJ-Brommy That's about how I did it.
@AJ-Brommy Except I just had return statements in my if statements.
AJ Brommy
@AJ-Brommy
Jun 06 2017 02:05
:+1:
ok, makes me feel a bit better. Never really sure how I am doing lol.
Joseph
@revisualize
Jun 06 2017 02:05
@AJ-Brommy There really isn't much to that lesson. But, it is actually a useful function.
@AJ-Brommy You'll use something similar in a website that you make.
Stephen James
@sjames1958gm
Jun 06 2017 02:06
@AJ-Brommy If you think about twitter and its 144 character limit this would be applicable
oluwole ilesanmi
@oluwoleilesanmi
Jun 06 2017 02:07
@h1tag thanks bro you pointed me in the right direction and saved me hours of finding a semantic bug
CamperBot
@camperbot
Jun 06 2017 02:07
oluwoleilesanmi sends brownie points to @h1tag :sparkles: :thumbsup: :sparkles:
:cookie: 832 | @h1tag |http://www.freecodecamp.com/h1tag
AJ Brommy
@AJ-Brommy
Jun 06 2017 02:07
@revisualize ok, ta, perhaps I should have shown an earlier lesson then lol, i'm sure some of mine could be better, i think I will go back over them soon.
Joseph
@revisualize
Jun 06 2017 02:08

@AJ-Brommy You'll need to do something like
Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content. It's also called placeholder (or filler) text. It's a convenient tool for mock-ups. It helps to outline the visual elements of a document or presentation, eg typography, font, or layout. Lorem ipsum is mostly a part of a Latin text by the classical author and philosopher Cicero. Its words and letters have been changed by addition or removal, so to deliberately render its content nonsensical; it's not genuine, correct, or comprehensible Latin anymore. While lorem ipsum's still resembles classical Latin, it actually has no meaning whatsoever. As Cicero's text doesn't contain the letters K, W, or Z, alien to latin, these, and others are often inserted randomly to mimic the typographic appearence of European languages, as are digraphs not to be found in the original.

But, then instead output:

Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content. It's also called placeholder (or filler) text. It's a convenient tool for mock-ups. It helps to outline the visual elements of a document or presentation, eg typography, font, or layout. Lorem ipsum is mostly a part of a Latin text by the... [Read more]

Where the [Read more] is actually a link.

oluwole ilesanmi
@oluwoleilesanmi
Jun 06 2017 02:09

can someone help my code passes this test but i cant move to the next stage
'''js function titleCase(str) {

var spliter = str.split(" ");
var replacement = "";

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

for (var j=0; j< spliter[i].length;j++){

  if (j === 0){
    if(i === 0)
    replacement = replacement + spliter[i][0].toUpperCase();
   else
     replacement = replacement +" "+ spliter[i][0].toUpperCase();
  }
  else 
 replacement = replacement + spliter[i][j].toLowerCase();
}

}

return '"'+replacement+'"'+".";

}

titleCase("I'm a little tea poY");
'''

CamperBot
@camperbot
Jun 06 2017 02:09
:bulb: to format code use backticks! ``` more info
Joseph
@revisualize
Jun 06 2017 02:10
@oluwoleilesanmi Have you tried using www.pythontutor.com/javascript.html
Stephen James
@sjames1958gm
Jun 06 2017 02:11
@AJ-Brommy It looks like the tests that they have are insufficient to test every case.
Your code would take the following
truncateString("Ape", 3);
And return "Ape..." which to me seems incorrect. But there is not a test for num <= 3 and but str.length <== to num
@oluwoleilesanmi Why are you adding a "." to the end?
Joseph
@revisualize
Jun 06 2017 02:12
@oluwoleilesanmi Why is your return value "\"I'm A Little Tea Pot\"." ?
AJ Brommy
@AJ-Brommy
Jun 06 2017 02:13
@sjames1958gm "However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string."
oluwole ilesanmi
@oluwoleilesanmi
Jun 06 2017 02:15
@revisualize ok thanks let me check why that is so
CamperBot
@camperbot
Jun 06 2017 02:15
oluwoleilesanmi sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4100 | @revisualize |http://www.freecodecamp.com/revisualize
rod poblete
@rodpoblete
Jun 06 2017 02:21

Hello Campers, I have doubts with my Caesars Cipher Challenge code. Here my script:

function rot13(str) { // LBH QVQ VG!
  var str2 = "", num = 0;
  for (var i = 0; i < str.length; i++) {
    num = str.charCodeAt(i);
    if (num < 65 && num > 90)
      num += String.fromCharCode(str.charCodeAt(i));
    if (num < 78)
      num += 13;
    else 
      num -= 13;
    str2 += String.fromCharCode(num);
  }
  return str2;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC"); // return FREE-CODE-CAMP

Returns the deciphered message but with hyphens FREE-CODE-CAMP :worried:

AJ Brommy
@AJ-Brommy
Jun 06 2017 02:22
return FREE-CODE-CAMP? isn't it supposed to?
rod poblete
@rodpoblete
Jun 06 2017 02:24
@AJ-Brommy Must return with spaces without the dashes FREE CODE CAMP
AJ Brommy
@AJ-Brommy
Jun 06 2017 02:24
oh
cshippen
@cshippen
Jun 06 2017 02:25
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
this does not make sense to me any help?
AJ Brommy
@AJ-Brommy
Jun 06 2017 02:25
@rodpoblete can't you just use replace on return?
replace("-"," ")
I don't know to be fair I haven't gotten this far yet. I don't understand much of what is going on in there
rod poblete
@rodpoblete
Jun 06 2017 02:26
@AJ-Brommy dont worry. Its OK ;)
AJ Brommy
@AJ-Brommy
Jun 06 2017 02:27
@rodpoblete damn, it seems like I should have the necessary knowledge as I will be on this one soon!! I'm on Chunky Monkey... I'm actually confused tho, i thought it looked simple at first lol
oluwole ilesanmi
@oluwoleilesanmi
Jun 06 2017 02:29
@revisualize please why do you think that is so from my code they were added
in the end '"'+replacement+'"'+"."
Joseph
@revisualize
Jun 06 2017 02:30
@oluwoleilesanmi I ran your code.
@oluwoleilesanmi I saw what was output from your code being ran.
You don't need the '"' +
@oluwoleilesanmi just return replacement + "."
AJ Brommy
@AJ-Brommy
Jun 06 2017 02:36
@rodpoblete any tips? ideas? I cannot see how with slice and push I can achieve the result :/
rod poblete
@rodpoblete
Jun 06 2017 02:42
@AJ-Brommy Takes the technique taught by FCC Read-Search-Ask
You have to have the patience to read and understand the documentation.
Take it easy, code is hard
AJ Brommy
@AJ-Brommy
Jun 06 2017 02:44
I'm reading documentation, I don't think my understanding of slice or push is a problem. It's just I'm using loops and ifs etc and I just had a sneaky suspicion there is an easier way to do what I am about to.
rod poblete
@rodpoblete
Jun 06 2017 02:44
@AJ-Brommy that's very good. Is part of the growth and maturation of your code
@AJ-Brommy With practice we are refactoring our algorithms faster. And the way we think about the solution as well.
oluwole ilesanmi
@oluwoleilesanmi
Jun 06 2017 02:50
@revisualize
Victoria Zambrano
@vzambrano98
Jun 06 2017 02:51
hey guys, anyone have a moment to talk about some stuff?
I am working on the calculator and just going through some of the logic behind it all.
I am trying to work on the CE button and I ran into a little problem
if (typeOf array[i] !== 'number'){
this line of code (in a while loop) throws an "Unexpected identifier" error....is this too much for typeOf to handle?
Caleb Cox
@CalebCox
Jun 06 2017 02:51

I'm currently working on the Twitch API project and i've got it outputting JSON data to HTML but it's only displaying stream data from streamers that are online. The console is showing me that it cannot read property of 'game' null for my if statements

if (json.stream.game === null)

I'm unsure as to what the problem is.

VinayD
@vinayd001
Jun 06 2017 02:52
how to add a new element, already having one in an array #javaSript
Victoria Zambrano
@vzambrano98
Jun 06 2017 02:52
@CalebCox post up the link to the codepen, maybe someone can see what's going on :)
Caleb Cox
@CalebCox
Jun 06 2017 02:53
@vzambrano98 i'm working within a local environment currently, the code isn't available via codepen. I'll add it to one and post the link
Victoria Zambrano
@vzambrano98
Jun 06 2017 02:54
@CalebCox oh I see
VinayD
@vinayd001
Jun 06 2017 02:54
@planigan reply man
how to add a new element, already having one in an array #javaSript
Caleb Cox
@CalebCox
Jun 06 2017 02:57
@vzambrano98 I figured it out! The JSON data given during null or undefined is no longer under $.stream.game it's under .stream, fixing that path resolved the issue.
Victoria Zambrano
@vzambrano98
Jun 06 2017 02:58
@CalebCox yay :clap:
Bill Stroud
@Lanhawk59
Jun 06 2017 02:58
@cshippen var remainder;
remainder = 11 % 3;
slavastarikov
@slavastarikov
Jun 06 2017 02:59
hi all for some reason I'm stuck on the Basic Javascript / Golf Code exercise. if someone could take a look
Screen Shot 2017-06-05 at 7.57.00 PM.png
my else if statements have been working in previous exercises but for some reason not in this one
Victoria Zambrano
@vzambrano98
Jun 06 2017 03:05
@slavastarikov look up how to make comparisons in javascript. notice how they never use a single '='. When a single '=' is used it's to define a variable or make an assignment. comparisons use two or three.
slavastarikov
@slavastarikov
Jun 06 2017 03:05
ah i should have used ==
yes!
thank you victoria
Victoria Zambrano
@vzambrano98
Jun 06 2017 03:05
@slavastarikov :+1:
slavastarikov
@slavastarikov
Jun 06 2017 03:05
got it right before you posted haha, thanks @vzambrano98 !
CamperBot
@camperbot
Jun 06 2017 03:05
slavastarikov sends brownie points to @vzambrano98 :sparkles: :thumbsup: :sparkles:
:cookie: 298 | @vzambrano98 |http://www.freecodecamp.com/vzambrano98
Angelo Hijada
@aymodez
Jun 06 2017 03:07
hey all
AJ Brommy
@AJ-Brommy
Jun 06 2017 03:08

Any ideas why this doesn't create an array with 2 sub arrays? resultArr should be [[a,b],[c,d]]


function chunkArrayInGroups(arr, size) {
  // Break it up.
  var resultArr = [];
  var subArr = [];
  var counter = 0;

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

    if(counter < size){
      subArr.push(arr[i]);
      counter++;
      //console.log(subArr);
    }
    else{
      // Add the sub Array to the parent Array and reset the counter
      // And reset the subArr
      resultArr.push(subArr);
      subArr = [];
      counter = 0;
      //console.log(subArr);
    }

  }
  //console.log(resultArr);
  return resultArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

I realise there is probably a better way, but right now this is how I've done it, to me it should work. But it doesn't. So I am confused, and would like to understand :(

Angelo Hijada
@aymodez
Jun 06 2017 03:10

Been stuck on this challenge for a couple hours now. Can't seem to figure this out:
How do I remove this if/else statement and still have it return true or false?

function isLess(a, b) {
// Fix this code
if (a < b) {
return true;
} else {
return false;
}
}

// Change these values to test
isLess(10, 15);

Mukul Agrawal
@mukul09
Jun 06 2017 03:12
@aymodez whats the name of the challenge?
Angelo Hijada
@aymodez
Jun 06 2017 03:12
@mukul09 Returning Boolean Values from Functions
AJ Brommy
@AJ-Brommy
Jun 06 2017 03:13
return a < b;
this is the same thing
Mukul Agrawal
@mukul09
Jun 06 2017 03:14
@aymodez just do it like this return a<=b;
AJ Brommy
@AJ-Brommy
Jun 06 2017 03:15
This way you are returning the result of a being less than b. if it is true it will return true. if it is false it will return false :)
Angelo Hijada
@aymodez
Jun 06 2017 03:16

wow. i kept writing:

function isLess {

erased that line and voila!
thanks @AJ-Brommy @mukul09
CamperBot
@camperbot
Jun 06 2017 03:16
aymodez sends brownie points to @aj-brommy and @mukul09 :sparkles: :thumbsup: :sparkles:
:cookie: 279 | @aj-brommy |http://www.freecodecamp.com/aj-brommy
:cookie: 365 | @mukul09 |http://www.freecodecamp.com/mukul09
Mukul Agrawal
@mukul09
Jun 06 2017 03:17
@aymodez :+1:
__SharifTarver__
@Sharifdesigns22
Jun 06 2017 03:17

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

for (var i = 0; i < arr.length; i++) {
for(var j = 0; i < arr[i].length; j++)
{
console.log([i][j]);
product *= [i][j];
}
}

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

// Modify values below to test your code
multiplyAll([1,2],[3,4],[5,6]);
```
What's wrong with my code? Nesting for loops challenge.

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

  for (var i = 0; i < arr.length; i++) {
    for(var j = 0; i < arr[i].length; j++)
    {
      console.log([i][j]);
      product *= [i][j];
    }
  }


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

// Modify values below to test your code
multiplyAll([1,2],[3,4],[5,6]);
AJ Brommy
@AJ-Brommy
Jun 06 2017 03:18
@Sharifdesigns22 you haven't stated which array to pull values from
[i][j] has no meaning
Mukul Agrawal
@mukul09
Jun 06 2017 03:18
@Sharifdesigns22 product *= arr[i][j];
Victoria Zambrano
@vzambrano98
Jun 06 2017 03:20
@AJ-Brommy plug your code into pythontutor.com
basically whats happening is you are using one of the turns in your loop to manipulate result array, causing nothing to happen to the letter 'c'
maybe you could consider another way to check for counter? perhaps a nested if statement?
__SharifTarver__
@Sharifdesigns22
Jun 06 2017 03:20
Oh okay, it still doesn't work after stating which array to pull from
Victoria Zambrano
@vzambrano98
Jun 06 2017 03:21
@AJ-Brommy i'm not a pro, i'm just throwing out ideas.
ArchivalBoat50
@ArchivalBoat50
Jun 06 2017 03:21
Hey guys quick question here, I am doing the "Show the local weather" project, and I have my api for the weather what can i do to implement it into my pen?
AJ Brommy
@AJ-Brommy
Jun 06 2017 03:21
@vzambrano98 thats cool, its all helpful, it kinda matches the results i am getting, but I still don't understand lol
pls help
AJ Brommy
@AJ-Brommy
Jun 06 2017 03:22
@vzambrano98 oh i think i get it, when it comes to c, it misses the part where it should get put into the subarray
@vzambrano98 and just skips to adding to the parent and ressetting, but that i value gets lost.
Aditya Soni
@adist98
Jun 06 2017 03:23
please take a look at the code and tell me what is wrong with it
Victoria Zambrano
@vzambrano98
Jun 06 2017 03:23
@AJ-Brommy Yes!
AJ Brommy
@AJ-Brommy
Jun 06 2017 03:23
@vzambrano98 thanks, been scratching my head for ages!
CamperBot
@camperbot
Jun 06 2017 03:23
aj-brommy sends brownie points to @vzambrano98 :sparkles: :thumbsup: :sparkles:
:cookie: 299 | @vzambrano98 |http://www.freecodecamp.com/vzambrano98
Victoria Zambrano
@vzambrano98
Jun 06 2017 03:23
@AJ-Brommy no problem :)
Aditya Soni
@adist98
Jun 06 2017 03:24
'''
'''
CamperBot
@camperbot
Jun 06 2017 03:24
:bulb: to format code use backticks! ``` more info
Aditya Soni
@adist98
Jun 06 2017 03:25

'''

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

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

// Change this value to test
caseInSwitch(1);
'''

CamperBot
@camperbot
Jun 06 2017 03:25
:bulb: to format code use backticks! ``` more info
Aditya Soni
@adist98
Jun 06 2017 03:25
please tell me what is wrong with my code
AJ Brommy
@AJ-Brommy
Jun 06 2017 03:25
@vzambrano98 made some changes... and doesn't work.. haha.. still you have gotten me to the next step, something to play with thanks
CamperBot
@camperbot
Jun 06 2017 03:25
aj-brommy sends brownie points to @vzambrano98 :sparkles: :thumbsup: :sparkles:
:warning: aj-brommy already gave vzambrano98 points
AJ Brommy
@AJ-Brommy
Jun 06 2017 03:26
(4) does that need to be there?
Nikola
@NikolaPerisic
Jun 06 2017 03:26
hi ppl, could someone give me a hint why this callback function within filter() method does't filter out things from args array? I managed to use filter() method to filter a single element, but here I need to filter an array that includes two or more elements, so I got stuck....
function destroyer(arr) {
  var args = [];
  var newArr = [];
  for (var i = 1; i < arguments.length; i++) {
    args.push(arguments[i]);
  }
  newArr = arguments[0].filter(function(element){
    var x = [];
    for (var j = 0; j < args.length; j++) {
      if (element !== args[j]) {
        x.push(element);
      }
    }
    return x;
  });
  return newArr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
AJ Brommy
@AJ-Brommy
Jun 06 2017 03:26
case 2 you have 3 of them! @adist98
__SharifTarver__
@Sharifdesigns22
Jun 06 2017 03:26
@mukul09 ^^
AJ Brommy
@AJ-Brommy
Jun 06 2017 03:28
@adist98
case 1:
return "alpha";
break;
case 2:
return "beta";
break;
case 3:
return "gamma";
break;
case 4:
return "delta";
break;
}
__SharifTarver__
@Sharifdesigns22
Jun 06 2017 03:28

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

for (var i = 0; i < arr.length; i++) {
for(var j = 0; i < 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]);

Aditya Soni
@adist98
Jun 06 2017 03:28

@AJ-Brommy my new code looks like this
'''
function caseInSwitch(val) {
var answer = "";
// Only change code below this line

switch (4) {
case 1:
answer = "alpha";
break;
case 2:
answer = "beta";
break;
case 3:
answer = "gamma";
break;
case 4:
answer = "delta";
break;
}

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

// Change this value to test
caseInSwitch(1);
'''

CamperBot
@camperbot
Jun 06 2017 03:28
:bulb: to format code use backticks! ``` more info
Benny
@swc19960312
Jun 06 2017 03:29
myStr 应该包含被转义的字符, 并且按照 反斜杠 制表符 退格符 回车符 换行符 的顺序用空格分开 怎么写?
AJ Brommy
@AJ-Brommy
Jun 06 2017 03:30
(4) == ( val) @adist98
Mukul Agrawal
@mukul09
Jun 06 2017 03:30
@Sharifdesigns22 in second loop j<arr[i].length and your have written i<arr[i].length
AJ Brommy
@AJ-Brommy
Jun 06 2017 03:31
@adist98 it needs to be the value that is passed into the function, which is passed to the switch, to pull out the correct case
Aditya Soni
@adist98
Jun 06 2017 03:31
@AJ-Brommy what do you mean
Gulsvi
@gulsvi
Jun 06 2017 03:31
@swc19960312 Use "text " + myVariable + " more text" to write with spaces
AJ Brommy
@AJ-Brommy
Jun 06 2017 03:31
switch (val)
Gulsvi
@gulsvi
Jun 06 2017 03:31
Note the spaces between the quotation marks
Aditya Soni
@adist98
Jun 06 2017 03:31
@AJ-Brommy got it
thanks
AJ Brommy
@AJ-Brommy
Jun 06 2017 03:32
:)
__SharifTarver__
@Sharifdesigns22
Jun 06 2017 03:37
thanks! @mukul09
CamperBot
@camperbot
Jun 06 2017 03:37
sharifdesigns22 sends brownie points to @mukul09 :sparkles: :thumbsup: :sparkles:
:cookie: 366 | @mukul09 |http://www.freecodecamp.com/mukul09
doridarien
@doridarien
Jun 06 2017 03:42
``
function rot13(str) {
  // Split str into a character array
  return str.split('')
  // Iterate over each character in the array
    .map.call(str, function(char) {
      // Convert char to a character code
      x = char.charCodeAt(0);
      // Checks if character lies between A-Z
      if (x < 65 || x > 90) {
        return String.fromCharCode(x);  // Return un-converted character
      }
      //N = ASCII 78, if the character code is less than 78, shift forward 13 places
      else if (x < 78) {
        return String.fromCharCode(x + 13);
      }
      // Otherwise shift the character 13 places backward
      return String.fromCharCode(x - 13);
    }).join('');  // Rejoin the array into a string
}

Could anyone explaint me
if (x < 65 || x > 90) {
return String.fromCharCode(x); // Return un-converted character
}
//N = ASCII 78, if the character code is less than 78, shift forward 13 places
else if (x < 78) {
return String.fromCharCode(x + 13);
}

this part?

Victoria Zambrano
@vzambrano98
Jun 06 2017 03:50
@NikolaPerisic because filter's functions have to return a boolean. so the return must be true or false. false will filter it out and true will leave it in there. does that make sense?

@NikolaPerisic here's a good example of how to write a good filter function

function isBigEnough(value) {
  return value >= 10;
}

var filtered = [12, 5, 8, 130, 44].filter(isBigEnough);
// filtered is [12, 130, 44]

from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter?v=control

Nikola
@NikolaPerisic
Jun 06 2017 03:55
@vzambrano98 ok thanks, I'm considering different approach
Proconsul
@proconsu1
Jun 06 2017 04:07

@doridarien

if (x < 65 || x > 90) {
return String.fromCharCode(x); // Return un-converted character

this is saying that if the character is outside the range of unicode values for A (unicode 65) to Z (unicode 90), to just leave it alone and return the character without alteration

@doridarien

//N = ASCII 78, if the character code is less than 78, shift forward 13 places
else if (x < 78) {
return String.fromCharCode(x + 13);

this code, which will only run if the preceding if is false, i.e. if the unicode value was in the range 65-90, then checks if the code is less than 78, which is the unicode for N. that would mean it is in the first half of the alphabet, so according to the cypher we should add 13 to its unicode value in order to return its counterpart letter from the second half of the alphabet

Valdovas1
@Valdovas1
Jun 06 2017 04:17
Hello peeps !

function chunkArrayInGroups(arr, size) {
// Break it up.
for (var i = 0; i < arr.length; i++){

  return arr.slice(0, size);

} if (arr.length > size){
var pushaz = [];
return pushaz.push();
}
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

what is wrong with this code as it is not working
Proconsul
@proconsu1
Jun 06 2017 04:20
@Valdovas1 you are returning the sliced version of the array in the first iteration of the for loop, which ends the loop before it can run a second iteration
@Valdovas1 do you really want to return the results of the slice? or do you need to do something else with it first?
heidisdad2
@heidisdad2
Jun 06 2017 04:25
guys i am struggling here got to module 172 and i am lost
image.png
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.<----that is my instructions....can anyone offer a little guidance please. this is my first time asking for help
Proconsul
@proconsu1
Jun 06 2017 04:29
@heidisdad2 just a quick chat tip: it's easier if you post your code using the triple backticks markdown ``` instead of posting captures. that way we can cut and paste from your code.
ok. now to the challenge....
@heidisdad2 first off you want to break this into steps based on the instructions. so the first step the instructions tell you to take is to take that supplied number item and add it onto the end of the array arr right?
heidisdad2
@heidisdad2
Jun 06 2017 04:31
ahh ok lets see if i can figure that out
Baibhav Gautam
@baibhavx
Jun 06 2017 04:33
undefined should be outside quote @adist98
so return undefined instead of "undefined" @adist98
Proconsul
@proconsu1
Jun 06 2017 04:34
@adist98 yep. look at the hint
Aditya Soni
@adist98
Jun 06 2017 04:34
thanks @baibhavx
CamperBot
@camperbot
Jun 06 2017 04:34
adist98 sends brownie points to @baibhavx :sparkles: :thumbsup: :sparkles:
:cookie: 329 | @baibhavx |http://www.freecodecamp.com/baibhavx
heidisdad2
@heidisdad2
Jun 06 2017 04:37
proconsul--- var item = testArr + (testArr.length + 1); like this? how do you cut and paste from the triple brackets?
Proconsul
@proconsu1
Jun 06 2017 04:38
@heidisdad2 not quite. there is a particular method for when you want to .push a value onto the end of an array. do you recall it?
heidisdad2
@heidisdad2
Jun 06 2017 04:38
yeah, thanks. i was getting confused with that push method. i am going to go back and review.
Proconsul
@proconsu1
Jun 06 2017 04:40
@heidisdad2 if the documentation fails to make sense to you, just ask back. happy to explain if needed
Paurush
@Paurush0506
Jun 06 2017 04:41
how to enter next line in single string
Proconsul
@proconsu1
Jun 06 2017 04:42
@Paurush0506 not sure what you mean. are you trying to insert a line break, aka newline, into a string. or are you trying to add one string onto the end of another?
Paurush
@Paurush0506
Jun 06 2017 04:43
yes
line break
Proconsul
@proconsu1
Jun 06 2017 04:43
@Paurush0506 that is the escape code \n
heidisdad2
@heidisdad2
Jun 06 2017 04:43
@proconsu1 i think i got it..."var item = testArr.push(testArr.length + 1);" ?
without the quotes
Paurush
@Paurush0506
Jun 06 2017 04:43
how to use it
example maybe
Proconsul
@proconsu1
Jun 06 2017 04:44
@heidisdad2 closer. but what are you trying to accomplish with this bit: (testArr.length + 1)?
@Paurush0506 var str = 'this is a string. \n this is the second line of the string'
Proconsul
@proconsu1
Jun 06 2017 04:46
@heidisdad2 the syntax of the .push method is kinda like this arrayBeingPushedOnto.push(valueBeingPushedOntoTheArray);
Aditya Soni
@adist98
Jun 06 2017 04:47
where is the mistake
?
anirudh duggal
@anirudhdggl
Jun 06 2017 04:47
how do I compare strings?
heidisdad2
@heidisdad2
Jun 06 2017 04:48
yeah, wasn't i supposed to add the next number onto the array?
Proconsul
@proconsu1
Jun 06 2017 04:48
@adist98 the first mistake is the way you set your if conditions
Aditya Soni
@adist98
Jun 06 2017 04:49
there are two conditions seperately
is it wrong?
Proconsul
@proconsu1
Jun 06 2017 04:49
@adist98 @anirudhdggl you compare strings or other values by using logical operators like == === != and so on
anirudh duggal
@anirudhdggl
Jun 06 2017 04:50
but it doesn't seem to work @proconsu1
lemme send my code
Proconsul
@proconsu1
Jun 06 2017 04:50
@anirudhdggl post your code
Aditya Soni
@adist98
Jun 06 2017 04:50
@proconsu1
anirudh duggal
@anirudhdggl
Jun 06 2017 04:50

//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
  var i=0;
  if(contacts[i][0]==firstName){
    if(contacts[i][1]==prop){
      console.log(contacts[i][1]);
    }
    else if(contacts[i][2]==prop){
      console.log(contacts[i][2]);
    }
    else if(contacts[i][3][1]==prop){
      console.log(contacts[i][3][1]);
    }
    else if(contacts[i][3][2]==prop){
      console.log(contacts[i][3][2]);
    }
    else if(contacts[i][3][3]==prop){
      console.log(contacts[i][3][3]);
    }
    else{
      console.log("No such property");
    }
  }
  else {
    console.log("No such contact");
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
heidisdad2
@heidisdad2
Jun 06 2017 04:51
@anirudhdggl how did you post that screen?
Joseph
@revisualize
Jun 06 2017 04:51
@anirudhdggl You aren't accessing the object properties correctly.
anirudh duggal
@anirudhdggl
Jun 06 2017 04:51
it basically compares the firstName and prop to the first name and property of the contacts array and then displays the property's value
Joseph
@revisualize
Jun 06 2017 04:52

@anirudhdggl Break the problem down:

var oneContact =   {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    }

How would you access the firstName?

anirudh duggal
@anirudhdggl
Jun 06 2017 04:52
@heidisdad2 add to your screen, switch to compose mode and press enter. then write your code in between the two different lines containing
@revisualize oneContact[1];
Joseph
@revisualize
Jun 06 2017 04:52
@anirudhdggl No.
@anirudhdggl Objects aren't arrays
Proconsul
@proconsu1
Jun 06 2017 04:53
@heidisdad2 posting code is best done using the triple backtick method. the little icon like M+ to the right of your test entry space is the help button for the markdown codes
Joseph
@revisualize
Jun 06 2017 04:53
@adist98 You're not making your if conditions correctly.
anirudh duggal
@anirudhdggl
Jun 06 2017 04:53
Oops!! @revisualize
Aditya Soni
@adist98
Jun 06 2017 04:53
how do i do that @revisualize
anirudh duggal
@anirudhdggl
Jun 06 2017 04:53
then how...??
Joseph
@revisualize
Jun 06 2017 04:53
@anirudhdggl You're the one doing the learning.

@adist98 How to write an if conditional statements with OR and AND operators:
I am seeing a large number of people writing if conditions using OR and AND operators incorrectly.
Here is an example of what I'm seeing:

if (param1 == "a" || "c" || "e") { // incorrect
   var output = "Odd lowercase alpha character"; 
}

What I think people think is that it will compare param1 to "a" then compare param1 to "c" then compare param1 to "e"
However, that's not actually what the computer is processing.

if conditions need to be evaluated to true for the if statement to run:

if ((condition1) || (condition2) || (condition3) {
    // true statement
}

And how we would code that up from our example above where we're trying to get the odd character from a parameter (param1):

if (param1 == "a" || param1 == "c" || param1 == "e") {
   var output = "Odd lowercase alpha character"; 
}

I'm also seeing people writing and statements like this:

if (param1 == "a" && param1 == "e") {
}

The problem with this is the fact that a variable can't really be two strings or two different numbers at the same time.

anirudh duggal
@anirudhdggl
Jun 06 2017 04:54
haha ok done!
thanks @revisualize
CamperBot
@camperbot
Jun 06 2017 04:54
anirudhdggl sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4101 | @revisualize |http://www.freecodecamp.com/revisualize
Baibhav Gautam
@baibhavx
Jun 06 2017 04:54
@adist98 you aren't correctly using the if statement. Check out this example,
if(score > 79 && score < 90) { //correct way to do this
  return 'B';
}
heidisdad2
@heidisdad2
Jun 06 2017 04:54
function nextInLine(arr, item) {
// Your code here
var item2 = testArr.push(testArr.length + 1);
item = testArr.shift();
return item; // Change this line
}
function nextInLine(arr, item) {
// Your code here
var item2 = testArr.push(testArr.length + 1);
item = testArr.shift();
return item; // Change this line
}
Joseph
@revisualize
Jun 06 2017 04:55
@anirudhdggl Look, I'm not trying to be rude. I just want to put you in line to learn this material instead of just focusing on getting the correct answer
@heidisdad2 You're using the global variable... Which isn't correct.
heidisdad2
@heidisdad2
Jun 06 2017 04:55
function nextInLine(arr, item) {
// Your code here
var item2 = testArr.push(testArr.length + 1);
item = testArr.shift();
return item; // Change this line
}
Joseph
@revisualize
Jun 06 2017 04:55

@heidisdad2
Stand In Line is a CheckPoint where you're supposed to:
Write a function nextInLine which has two parameters
an array (arr) and a number (item).
That part has been done for you here:

function nextInLine(arr, item) { }

With that function declaration you have a function name of nextInLine. You have two parameters arr which represents an array passed into the function and item that represents a number passed to the function.
A few example function calls:

nextInLine([4,3,2] , 1) the values passed to arr is [4,3,2] and the value passed to item is 1

nextInLine([2,4,6,8] , 10) ... arr is [2,4,6,8] & item is 10

nextInLine([2,3,5,7,11] , 13) ... arr is [2,3,5,7,11] & item is 13 (first 5 and 6th prime numbers)

nextInLine([] , 0) ... arr is [] & item is 0

This part is an example using a Global Variable as a parameter to another function call.
var myArr = [1,3,5,7]; nextInLine(myArr , 9) ... arr is a reference to the global variable myArr with the value of [1,3,5,7] & item is 9
When you modify arr inside of your function you're actually modifying the value of the global variable because of the reference passing. Note: This doesn't work like this when you pass primitives.

Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Again the two parameters for the nextInLine function are arr & item.

Per the instructions: 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.

You need to add the number (item) to the end of an array (arr).
You also need to remove the first element from an array (arr).

Then you need to have your function return the removed element from the array arr.

heidisdad2
@heidisdad2
Jun 06 2017 04:55
sorry guys i am trying to figure out this compose mode
Proconsul
@proconsu1
Jun 06 2017 04:55
@heidisdad2 still need to address this bit here: testArr.length + 1 this should be whatever variable or value you are trying to .push onto the given array
heidisdad2
@heidisdad2
Jun 06 2017 04:56
ohh, got it. thanks proconsul
Joseph
@revisualize
Jun 06 2017 04:56

If you are posting code that is large, Please use Gist - https://gist.github.com/ then please paste the link here.
...
How to do code block format: ..... PLEASE try with a small block of code before you try to make a bigger one.
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code
```js [SHIFT+ENTER]
// your code here
``` [CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

...
You can also do inline code formatting:
A string of text with a `variable` or `other bit of code`.
Output:
A string of text with a variable or other bit of code.

@heidisdad2 Anyhow. If you could take the time to read that huge block of text that I posted about Stand in line.. That'd be great.
anirudh duggal
@anirudhdggl
Jun 06 2017 04:57
@heidisdad2 do one thing, the press the button above tab button thrice, and on the right side of your text area where you are typing write now click the topmost icon to switch to compose mode, the return to the text are and press enter.
after that just insert you code in between the two ``````.
@revisualize I know that you are doing this so that I may learn it the better way
Joseph
@revisualize
Jun 06 2017 05:00
@anirudhdggl So, let's back up a little and have a brief discussion about array elements.
Aditya Soni
@adist98
Jun 06 2017 05:00
var count = 0;

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

  }else if((card = 10) || (card = 'J') || (card = 'Q') || (card = 'K') || (card = 'A')) {
    count += -1;
  }

  if (count>0){
  return "Bet";
  }else{
    return "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');
Joseph
@revisualize
Jun 06 2017 05:00
@adist98 = is assignment.
heidisdad2
@heidisdad2
Jun 06 2017 05:00
function nextInLine(arr, item) { // Your code here var item2 = testArr.length + 1; item = testArr.push(item2); return item; // Change this line }
Aditya Soni
@adist98
Jun 06 2017 05:00
Please tell me whats wrong
okay
Joseph
@revisualize
Jun 06 2017 05:00
@heidisdad2 You should NOT be using testArr in your function.
Aditya Soni
@adist98
Jun 06 2017 05:01

var count = 0;

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

  }else if((card == 10) || (card == 'J') || (card == 'Q') || (card == 'K') || (card == 'A')) {
    count += -1;
  }

  if (count>0){
  return "Bet";
  }else{
    return "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');
heidisdad2
@heidisdad2
Jun 06 2017 05:01
sorry guys, i am not trying to be rude. i was trying to use that compose screen
Aditya Soni
@adist98
Jun 06 2017 05:01
Now, i think it is okay
Proconsul
@proconsu1
Jun 06 2017 05:01
@adist98 yep. that's what i meant earlier about using logical operators like == and ===
Joseph
@revisualize
Jun 06 2017 05:01
@adist98 Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.
...
Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
...
...
Things to note: You should NOT be returning based on the value of the card. The value of card should only be adding or subtracting 1 from the global variable count.
The value of the global variable count is used to determine the return statement.
@adist98 Your return statements aren't correct.
Aditya Soni
@adist98
Jun 06 2017 05:02
okay
Joseph
@revisualize
Jun 06 2017 05:02
@anirudhdggl Sorry, I got distracted a little.
heidisdad2
@heidisdad2
Jun 06 2017 05:03
function nextInLine(arr, item) {
  // Your code here
  var item2 = testArr.length + 1;
  item = testArr.push(item2);
  return item;  // Change this line
}
ahhhhhaha
Proconsul
@proconsu1
Jun 06 2017 05:03
@heidisdad2 you are making progress on it. now the next bit to deal with is the variables you created. you didn't really need to create any new variables for this one. the two parameters they gave you, arr and item, are sufficient to your needs
heidisdad2
@heidisdad2
Jun 06 2017 05:03
thanks @anirudhdggl
CamperBot
@camperbot
Jun 06 2017 05:03
heidisdad2 sends brownie points to @anirudhdggl :sparkles: :thumbsup: :sparkles:
:cookie: 212 | @anirudhdggl |http://www.freecodecamp.com/anirudhdggl
anirudh duggal
@anirudhdggl
Jun 06 2017 05:04
@revisualize I guess by using myContact.firstName I can access it?
Joseph
@revisualize
Jun 06 2017 05:04
@anirudhdggl So, Arrays are a series of elements accessible by their index value. Array elements can hold a value of anything that JavaScript allows. An array element can be a number, string, another array, object, even a function .. the list goes on and on anything that you can store in a variable. Can be stored in an array element.
@anirudhdggl So, when you store an Object in the array element. You have to access the array element.. Then you access the Object just like you'd access any other object property.

Let's say you have an object.

var myFriend = {
        "firstName": "Happy",
        "lastName": "Feet",
        "number": "-i",
        "likes": ["rhythm", "dancing", "soul"]
    }

You'd access the firstName with.. myFriend.firstName; or myFriend["firstName"];

@anirudhdggl Now, if you had that in an array.
heidisdad2
@heidisdad2
Jun 06 2017 05:06

function nextInLine(arr, item) {
  // Your code here
    item = arr.push(item);
  return item;  // Change this line
}
this worked
Joseph
@revisualize
Jun 06 2017 05:06
Let's say you have an object.
var arrOfFriends = [
    {
        "firstName": "Happy",
        "lastName": "Feet",
        "number": "-i",
        "likes": ["rhythm", "dancing", "soul"]
    }
];
@heidisdad2 That shouldn't solve the challenge.
anirudh duggal
@anirudhdggl
Jun 06 2017 05:07
@revisualize But how do I compare the properties...by == operator?
Proconsul
@proconsu1
Jun 06 2017 05:07
@heidisdad2 Here are the particular bits that need attention:
item = arr.push(item);
you dont want to reassign the modified array to overwrite item do you? no, you just want the new array with the new content pushed onto it. for that you dont need any assignement at all
Joseph
@revisualize
Jun 06 2017 05:07
@anirudhdggl To access the zero element in array and get the firstName... You'd first need to do ... arrOfFriends[0]
Proconsul
@proconsu1
Jun 06 2017 05:07
@heidisdad2 and the next bit we'll tackle once that one is under your belt
Joseph
@revisualize
Jun 06 2017 05:07
@anirudhdggl That would get you the whole array element.
@anirudhdggl Then you can access arrOfFriends[0].firstName;
@anirudhdggl You just do a comparison.
heidisdad2
@heidisdad2
Jun 06 2017 05:08

function nextInLine(arr, item) {
  // Your code here
    item = arr.push(item);
    item = arr.shift(item);  
  return item;  // Change this line
}
you guys are the best
thanks @revisualize and @proconsu1
CamperBot
@camperbot
Jun 06 2017 05:08
heidisdad2 sends brownie points to @revisualize and @proconsu1 :sparkles: :thumbsup: :sparkles:
:cookie: 179 | @proconsu1 |http://www.freecodecamp.com/proconsu1
:star2: 4102 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 06 2017 05:08
arrOfFriends[0].firstName === "Happy"
@heidisdad2 You don't supply an argument to the .shift() method call.
anirudh duggal
@anirudhdggl
Jun 06 2017 05:09
@revisualize So basically I have an array of objects and to compare them I need to access the object through its index and then use dot operator to access the property and compare it?
Proconsul
@proconsu1
Jun 06 2017 05:09
@heidisdad2 hint: you can modify an array in place without an assignment. you could have changed this: item = arr.push(item); to this: arr.push(item);
Aditya Soni
@adist98
Jun 06 2017 05:09
```

var count = 0;

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

  }else if((card == 10) || (card == 'J') || (card == 'Q') || (card == 'K') || (card == 'A')) {
    count += -1;
  }

  if (count>0){
  return "Bet";
  }else{
    return "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');
```
heidisdad2
@heidisdad2
Jun 06 2017 05:09
i dont know why that was so hard for me. but now i have a better understanding
Joseph
@revisualize
Jun 06 2017 05:09
@adist98 Your return statements still are not correct.
Aditya Soni
@adist98
Jun 06 2017 05:09
i need to return count, how do i do that
in the same line
Joseph
@revisualize
Jun 06 2017 05:09
@adist98 return count
Proconsul
@proconsu1
Jun 06 2017 05:09
@heidisdad2 it only comes one bit at a time. we all got there the same way you are doing. :-)
Joseph
@revisualize
Jun 06 2017 05:10
@anirudhdggl Sure.
Aditya Soni
@adist98
Jun 06 2017 05:10
do i add return count to the same line @revisualize
Joseph
@revisualize
Jun 06 2017 05:10
@adist98 return count
@adist98 That's the answer to your question.
Proconsul
@proconsu1
Jun 06 2017 05:10
@heidisdad2 honestly, i cannot even pretend if have "gotten there" yet. i am only maybe a week ahead of you in experience
anirudh duggal
@anirudhdggl
Jun 06 2017 05:10
Okay lemme try it @revisualize
thanks @revisualize
CamperBot
@camperbot
Jun 06 2017 05:10
anirudhdggl sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: anirudhdggl already gave revisualize points
Joseph
@revisualize
Jun 06 2017 05:10
@adist98 The question you're really trying to ask is .. How do I return count and add a string to the return statement?
@adist98 That would be String Concatenation.
Aditya Soni
@adist98
Jun 06 2017 05:11
yep
Sandeep Yadav
@sandeepyadav097
Jun 06 2017 05:11
hello everyone can someone tell me whats wrong in my this code

function filteroff(obj)
{
//return val!==0 || val!== undefined || typeof(val)==='string' || val!==0 || val!==isNaN() || val!=="";

return typeof(obj)==='string' && obj!== undefined && typeof(obj) === 'number' && !isNaN(obj);

}

function bouncer(arr) {
// Don't show a false ID to this bouncer.

var filtered=arr.filter(filteroff);
return filtered;
}

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

Joseph
@revisualize
Jun 06 2017 05:11
@adist98 "Hello" + "World" .... outputs: "HelloWorld"
Sandeep Yadav
@sandeepyadav097
Jun 06 2017 05:12
someone
this is the falsy bouncer problem
Aditya Soni
@adist98
Jun 06 2017 05:12
@revisualize return count + "Bet";
Joseph
@revisualize
Jun 06 2017 05:12
@adist98 Sure. But... You're missing something.
@adist98 1Bet
Aditya Soni
@adist98
Jun 06 2017 05:12
return count + " " + "bet"
Proconsul
@proconsu1
Jun 06 2017 05:13
@sandeepyadav097 the point of that particular challenge is to introduce you to the Boolean(expression) operation
Joseph
@revisualize
Jun 06 2017 05:13
@adist98 What happened to the B?
Markus Kiili
@Masd925
Jun 06 2017 05:13
@sandeepyadav097 typeof doesn't help too much here, since many types have truthy and falsy values. isNaN() doesn't test for NaN.
Aditya Soni
@adist98
Jun 06 2017 05:13
yeah ``` return count + " " + "Bet";
Joseph
@revisualize
Jun 06 2017 05:13
@adist98 Did you solve the challenge?
Valdovas1
@Valdovas1
Jun 06 2017 05:13
@proconsu1 I should split it into the array first as it seems
Aditya Soni
@adist98
Jun 06 2017 05:13
No
@revisualize
Markus Kiili
@Masd925
Jun 06 2017 05:14
@sandeepyadav097 Also a simple if(val){...} tests for truthy value.
Joseph
@revisualize
Jun 06 2017 05:14
@adist98 Okay. Did you fix your other return statement?
Aditya Soni
@adist98
Jun 06 2017 05:14
i am working on it @revisualize
Sandeep Yadav
@sandeepyadav097
Jun 06 2017 05:14
i dont get it what to do with the boolean operation??
Aditya Soni
@adist98
Jun 06 2017 05:14
var count = 0;

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

  }else if((card == 10) || (card == 'J') || (card == 'Q') || (card == 'K') || (card == 'A')) {
    count += -1;
  }
}
  if (count>0){
  return count + " " + "Bet";
  }else{
    return count + " " + "Hold";
  }

  // Only change code above this line


// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Proconsul
@proconsu1
Jun 06 2017 05:14
@sandeepyadav097 you don't need to, no. the argument being passed to the function is already an array
Aditya Soni
@adist98
Jun 06 2017 05:14
Here is the code
@revisualize
Markus Kiili
@Masd925
Jun 06 2017 05:15
@sandeepyadav097 It is the Boolean function that coerces all values to type Boolean. Truthy values to true and falsy to false.
heidisdad2
@heidisdad2
Jun 06 2017 05:15
one more question for proconsul
Proconsul
@proconsu1
Jun 06 2017 05:15
@heidisdad2 go
Joseph
@revisualize
Jun 06 2017 05:15
@adist98 Okay.
heidisdad2
@heidisdad2
Jun 06 2017 05:16
how did the push function know that the number i wanted to add was going to be the next in the array?
anirudh duggal
@anirudhdggl
Jun 06 2017 05:16
@revisualize the value entered will be the name of the property like last name, etc; how do I compare it?
Aditya Soni
@adist98
Jun 06 2017 05:16
Please check it, it is still not working @revisualize
anirudh duggal
@anirudhdggl
Jun 06 2017 05:16

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

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
consider this code
Proconsul
@proconsu1
Jun 06 2017 05:17
@heidisdad2 that is exactly what the .push method does...it takes the given value in parens and tacks it onto the tail end of the specified array. the opposite of this would be the .unshift method which tacks the value onto the front of the array instead of the back
Joseph
@revisualize
Jun 06 2017 05:18
@adist98 Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
Valdovas1
@Valdovas1
Jun 06 2017 05:18

function chunkArrayInGroups(arr, size) {
// Break it up.
var pushaz = [];
pushaz.push(arr);

}

chunkArrayInGroups(["a", "b", "c", "d"], 2); Opinion ?

heidisdad2
@heidisdad2
Jun 06 2017 05:18
console.log(nextInLine(testArr, 6)) was it this line?
Paurush
@Paurush0506
Jun 06 2017 05:18
ar myStr='FirstLine\n \SecondLine\ \n ThirdLine';
what is error
Joseph
@revisualize
Jun 06 2017 05:18
@adist98 You have all of ryour return stuff outside of the function
@Paurush0506 You're not escaping backslash correctly.
Proconsul
@proconsu1
Jun 06 2017 05:18
@heidisdad2 there are other variant methods for similar operations. .shift removes from the front of the array. .pop removes from the back end of the array
Joseph
@revisualize
Jun 06 2017 05:19
@Paurush0506 You're not escaping the carriage-return correctly.
Aditya Soni
@adist98
Jun 06 2017 05:19
@revisualize worked.
Joseph
@revisualize
Jun 06 2017 05:19
@Paurush0506 You also have spaces in your string when the instructions state to remove them.
Paurush
@Paurush0506
Jun 06 2017 05:19
how to do it
heidisdad2
@heidisdad2
Jun 06 2017 05:19
yeah i went through those modules, but was wondering how it knew what number to add. i guess ```
Aditya Soni
@adist98
Jun 06 2017 05:19
my return statements were outside @revisualize , thanks for all the help
CamperBot
@camperbot
Jun 06 2017 05:19
adist98 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4103 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 06 2017 05:19
@Paurush0506 How do you escape a backslash?
Paurush
@Paurush0506
Jun 06 2017 05:19
even output is not correct
heidisdad2
@heidisdad2
Jun 06 2017 05:20
console.log(nextInLine(testArr, 6));
i think this line is telling it to use that specific array and that specific integer.
Joseph
@revisualize
Jun 06 2017 05:21

@heidisdad2
Stand In Line is a CheckPoint where you're supposed to:
Write a function nextInLine which has two parameters
an array (arr) and a number (item).
That part has been done for you here:

function nextInLine(arr, item) { }

With that function declaration you have a function name of nextInLine. You have two parameters arr which represents an array passed into the function and item that represents a number passed to the function.
A few example function calls:

nextInLine([4,3,2] , 1) the values passed to arr is [4,3,2] and the value passed to item is 1

nextInLine([2,4,6,8] , 10) ... arr is [2,4,6,8] & item is 10

nextInLine([2,3,5,7,11] , 13) ... arr is [2,3,5,7,11] & item is 13 (first 5 and 6th prime numbers)

nextInLine([] , 0) ... arr is [] & item is 0

...
This part is an example using a Global Variable as a parameter to another function call.
var myArr = [1,3,5,7]; nextInLine(myArr , 9) ... arr is a reference to the global variable myArr with the value of [1,3,5,7] & item is 9
When you modify arr inside of your function you're actually modifying the value of the global variable because of the reference passing. Note: This doesn't work like this when you pass primitives.
...

Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Again the two parameters for the nextInLine function are arr & item.

Per the instructions: 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.

You need to add the number (item) to the end of an array (arr).
You also need to remove the first element from an array (arr).

Then you need to have your function return the removed element from the array arr.

Netrunner21
@Netrunner21
Jun 06 2017 05:21
I need some help on Exact Change
Proconsul
@proconsu1
Jun 06 2017 05:21
@heidsdad2 it breaks down like this example: arr.push(item) the arr bit tells it is pushing onto an array named arr. the .push tells it the method, in this case to add a value to the END of that array (as opposed to the front or elsewhere), and the bit in parens (item) tells it to take the value of the variable named item as what it should be adding to the arr array's end
Netrunner21
@Netrunner21
Jun 06 2017 05:21
If anyone is around
Proconsul
@proconsu1
Jun 06 2017 05:23
@Netrunner21 don't know that one by name. but folks are indeed around. whatcha got?
Joseph
@revisualize
Jun 06 2017 05:24
issues with floating point numeric math.
wonder
@wonder2991
Jun 06 2017 05:24
@Valdovas1 don't think that will work
Netrunner21
@Netrunner21
Jun 06 2017 05:24
I have it solved. And yes @revisualize that's what my issue was
Just curious if that's normal
I was one cent off, because it was representing 0.01 as 0.00999999998313
I found a solution for it using toFixed(2);
heidisdad2
@heidisdad2
Jun 06 2017 05:25
@revisualize that was the best answer ever. i just learned a bunch.
Joseph
@revisualize
Jun 06 2017 05:25
@Netrunner21 There's a reason that I knew that was the issue without you saying anything.
Markus Kiili
@Masd925
Jun 06 2017 05:25
@Netrunner21 Only integers <9007199254740992 are guaranteed to have an exact representation as floats (all JS numbers are 64bit floats).
Proconsul
@proconsu1
Jun 06 2017 05:25
@heidisdad2 indeed. you are looking behind the curtain to how the exercise is passing test cases into your function to see if you did it right
Joseph
@revisualize
Jun 06 2017 05:25
@heidisdad2 You know .. I did post that a long time ago in this chat.
30 minutes ago... :point_up: June 5, 2017 9:55 PM
heidisdad2
@heidisdad2
Jun 06 2017 05:26
oh my bad i mustve missed it
lol
Netrunner21
@Netrunner21
Jun 06 2017 05:26
I have learned that recently searching for the solution. Thanks for the input @revisualize and @Masd925
CamperBot
@camperbot
Jun 06 2017 05:26
netrunner21 sends brownie points to @revisualize and @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4104 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 4204 | @masd925 |http://www.freecodecamp.com/masd925
Netrunner21
@Netrunner21
Jun 06 2017 05:26
My other question...
Markus Kiili
@Masd925
Jun 06 2017 05:26
@Netrunner21 No, money is never stored in floats.
Joseph
@revisualize
Jun 06 2017 05:26
@Masd925 We're 100 apart!
@Masd925 I put all of my money in things that float.
Netrunner21
@Netrunner21
Jun 06 2017 05:27
It's not giving me a green checkmark on "insufficient funds" when it clearly correctly returned "Insufficient Funds"
Proconsul
@proconsu1
Jun 06 2017 05:27
capitalization?
Netrunner21
@Netrunner21
Jun 06 2017 05:27
has to be a bug of sorts because the other one requiring Insufficient Funds goes green
both say the same thing, but only one gets the checkmark
@Masd925 what do you mean about money?
Joseph
@revisualize
Jun 06 2017 05:28
@Netrunner21 Strings need to be EXACT!
Markus Kiili
@Masd925
Jun 06 2017 05:28
@revisualize That gap is because you give 2,4% more solid advice.
Joseph
@revisualize
Jun 06 2017 05:29
@Masd925 I give solid advice?
Wat?
Markus Kiili
@Masd925
Jun 06 2017 05:29
@Netrunner21 In Exact change we see what problems can come if you store money in floats.
Netrunner21
@Netrunner21
Jun 06 2017 05:29
@revisualize but they are both exactly the same
Proconsul
@proconsu1
Jun 06 2017 05:29
@revisualize i have found it to be so
Joseph
@revisualize
Jun 06 2017 05:29
Remember when I was dumb shit and annoyed the hell out of you? (Not that that may have changed. But, still.)
Netrunner21
@Netrunner21
Jun 06 2017 05:30
The test returns for both are the same, and my return for both is the same: "Insufficient Funds".
Joseph
@revisualize
Jun 06 2017 05:30
@proconsu1 I've actually pre-typed a bunch of stuff.
Netrunner21
@Netrunner21
Jun 06 2017 05:30
Maybe I need to refresh my browser
Markus Kiili
@Masd925
Jun 06 2017 05:31
@revisualize I just always tell people with more points that camperbot doesn't take the solidity of the advice into account ;)
Karma Drukpa
@coderkarma
Jun 06 2017 05:31
how do i start learning javascript any recommendation
Proconsul
@proconsu1
Jun 06 2017 05:31
@revisualize typed it now or typed it a month ago, good advice === good advice
Markus Kiili
@Masd925
Jun 06 2017 05:31
@coderkarma Avoid W3Schools JS material.
Netrunner21
@Netrunner21
Jun 06 2017 05:31
Nevermind, I got it. Got two answers mixed up
My apologies
Joseph
@revisualize
Jun 06 2017 05:31
Anyhow.
Netrunner21
@Netrunner21
Jun 06 2017 05:32
float problem again lol
one cent over
Markus Kiili
@Masd925
Jun 06 2017 05:32
@Netrunner21 Only really robust way is to turn money amounts into pennies that are safe integers and then turn them back at the end.
Karma Drukpa
@coderkarma
Jun 06 2017 05:33
@Masd925 since i am beginner , i want to learn javascript , which resources and websites have all things to learn .and what do you advice for someone like me who has no coding experience at all.
but i want to learn and practice everyday .
Joseph
@revisualize
Jun 06 2017 05:34
Okay. It's 1034pm here in Seattle.
I need to get myself to :zzz:
Proconsul
@proconsu1
Jun 06 2017 05:35
@revisualize nite
heidisdad2
@heidisdad2
Jun 06 2017 05:35
@revisualize goodnight bro
Sunny Ouyang
@ShennyO
Jun 06 2017 05:36
hey does anyone here know swift?
Joseph
@revisualize
Jun 06 2017 05:37
@ShennyO FreeCodeCamp/HelpJavaScript
Markus Kiili
@Masd925
Jun 06 2017 05:37
@coderkarma Do FCC and have some other source along. Some book or tutorial. MDN is the best place for JS on specific subjects. Don't know about good beginner stuff. I like the book "Speaking javascript" that is free to read online.
Sunny Ouyang
@ShennyO
Jun 06 2017 05:37
@revisualize ?
Aata-allah
@Atalaa
Jun 06 2017 05:38
How can i set a background for a specific city with the API OpenWeatherMap
for weather challenge
Joseph
@revisualize
Jun 06 2017 05:38
@ShennyO This is a room focused on helping people learn JavaScript. There may be someone here that knows Swift. But, that may be very unlikely
Proconsul
@proconsu1
Jun 06 2017 05:39
@coderkarma codeacademy is a little similar to freecodecamp, though not quite as good IMO. but it explains concepts in different ways, which can help if you are having trouble. it also has different exercises
Joseph
@revisualize
Jun 06 2017 05:39
Anyhow. I need to jet. Tomorrow will be the first day that I write my electric bike to work.
Valdovas1
@Valdovas1
Jun 06 2017 05:39

function chunkArrayInGroups(arr, size) {
// Break it up.
var pushaz = [];
var total = pushaz.push(arr);

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

Am i on the right track ?
I
@coderkarma Click that link
Proconsul
@proconsu1
Jun 06 2017 05:41
@Valdovas1 that is essentially going to just put a copy of the source array arr in as the first element of the new array pushaz
Markus Kiili
@Masd925
Jun 06 2017 05:41
@Valdovas1 A loop of some kind is needed.
Proconsul
@proconsu1
Jun 06 2017 05:42
@Valdovas1 yep, and it is not arr you want in those parens
Valdovas1
@Valdovas1
Jun 06 2017 05:42
@Masd925 @proconsu1 I will go with for loop but i have to do something before so it would work.
Proconsul
@proconsu1
Jun 06 2017 05:44
@Valdovas1 did you check the help links in the challenge? one of them points to a method you will find very useful when it comes to figuring out what to .push onto that new array
Valdovas1
@Valdovas1
Jun 06 2017 05:45
@proconsu1 Okey, i will re-read it

var sports = ['soccer', 'baseball'];
var total = sports.push('football', 'swimming');

console.log(sports); // ['soccer', 'baseball', 'football', 'swimming']
console.log(total); // 4

Proconsul
@proconsu1
Jun 06 2017 05:48
Gahh. Get Geo-location. makes my 'nads itch just reading the instructions for this one. i hate it that so many websites want to track my location without any reason that benefits me
Valdovas1
@Valdovas1
Jun 06 2017 05:48
this one ? @proconsu1
Proconsul
@proconsu1
Jun 06 2017 05:49
@Valdovas1 no, i reckon you know about .push already. it's the other help link, the one for the .slice method, that i was trying to steer you towards
Valdovas1
@Valdovas1
Jun 06 2017 05:49
@proconsu1 I see. Misunderstood your suggestion then :)
Proconsul
@proconsu1
Jun 06 2017 05:50
@Valdovas1 partly my fault no doubt. trying to be a little cryptic to avoid giving you solutions instead of hints. prolly overdoing it a bit
Valdovas1
@Valdovas1
Jun 06 2017 05:52
@proconsu1 I understand. Thank you for that :)
CamperBot
@camperbot
Jun 06 2017 05:52
valdovas1 sends brownie points to @proconsu1 :sparkles: :thumbsup: :sparkles:
:cookie: 181 | @proconsu1 |http://www.freecodecamp.com/proconsu1
Proconsul
@proconsu1
Jun 06 2017 05:52
@Valdovas1 :+1:
GAHH! i put my code into the Geo-location code frame and before I even run the durned thing freecodecamp is throwing a popup wanting to track my fewkin location! Guess my code works.....
Valdovas1
@Valdovas1
Jun 06 2017 05:54
@proconsu1 use VPN and put Zambia your location. Fun thing to do
Proconsul
@proconsu1
Jun 06 2017 05:55
@Valdovas1 lol. wonder if I did that but i connected to one my VPN provider's servers in Kenya.....
Valdovas1
@Valdovas1
Jun 06 2017 05:57
hmm..
Proconsul
@proconsu1
Jun 06 2017 05:59
@Valdovas1 i get all kinds of fun stuff honestly when i (very rarely and usually acidentally) allow location to be on while using my VPN, because I never connect to a server in my own country. I live in Everett, WA, USA and almost always connect to a server in Vancouver,BC, CA because i get better response times than with servers in Seattle ;-0
Netrunner21
@Netrunner21
Jun 06 2017 06:05
Just my two cents on Exact Change ... this one really taxed my working memory. I actually had to write down what everything was doing before I wrote the code. Very difficult to think about all of the parts.
Valdovas1
@Valdovas1
Jun 06 2017 06:06
@proconsu1 :D So fun
Proconsul
@proconsu1
Jun 06 2017 06:08
@Netrunner21 yer a better dude than I, Gunga Din. i ran into that problem looonnng before I got as far as you are now...which I still haven't
Valdovas1
@Valdovas1
Jun 06 2017 06:13

function chunkArrayInGroups(arr, size) {
// Break it up.
for (var i = 0; i < size; i++){
return arr.slice(0, size);
} if (i > size){
return arr.push(size);
}

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

opinions ?
Markus Kiili
@Masd925
Jun 06 2017 06:14
@Valdovas1 If you use slice, it is good to increment with i+=size.
and then figure out the slice arguments using i and size.
Inside the loop you should push slices into a result array.
wonder
@wonder2991
Jun 06 2017 06:15

help ```
function mutation(arr) {

for(var i = 0; i< arr[1].length; i++){
if((arr[0].toLowerCase()).indexOf(arr[1][i].toLowerCase())==-1){
return false;
}
else
return true;
}

}

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

Proconsul
@proconsu1
Jun 06 2017 06:16
@Valdovas1 you need to run the entire array do you not? so perhaps i<arr.length instead if i<sizeand then just do the rest of the function (except the final output) inside the loop?
Markus Kiili
@Masd925
Jun 06 2017 06:16
@wonder2991 The logic for returning true is not right.
You cannot return that based on the first looped character.
Valdovas1
@Valdovas1
Jun 06 2017 06:17
@proconsu1 will do a small break and try again later.
Proconsul
@proconsu1
Jun 06 2017 06:17
@Valdovas1 often wise ;-)
Pethaf
@Pethaf
Jun 06 2017 06:18
Ok. What do you people think? Should I make another attempt at implementing Heap's algorithm today?
Proconsul
@proconsu1
Jun 06 2017 06:21
@wonder2991 of course @Masd925 nailed the vital bits, but one general tip. if what you want in the end is to return either true or false, then often (usually?) you can do it by just returning a method or function that itself returns either true or false. example if ( i == 10) { return true}; would return true if i was equal to 10. but so would return (i == 10);
kerafyrm02
@kerafyrm02
Jun 06 2017 06:21
Anyone stuck?
Proconsul
@proconsu1
Jun 06 2017 06:21
@Pethaf if yer eyes aren't bleedin' yet, goferit I say! :-P
kerafyrm02
@kerafyrm02
Jun 06 2017 06:23
Anyone need help?
heidisdad2
@heidisdad2
Jun 06 2017 06:23
proconsul
Proconsul
@proconsu1
Jun 06 2017 06:24
@kerafyrm02 things are a bit slow. lurk a bit. someone will soon
heidisdad2
@heidisdad2
Jun 06 2017 06:24
how many hours a day do you code?
Proconsul
@proconsu1
Jun 06 2017 06:24
@heidisdad2 sup?
@heidisdad2 a fair few, but only because i am striving to learn right now. i only started learning JS about a week ago
Netrunner21
@Netrunner21
Jun 06 2017 06:24
@proconsu1 It's taken a while but I've trained myself to focus on larger tasks. Games like The Talos Principle, The Turing Test, The Adventures of Lolo and Lala were more than just fun and games for me. I forced myself to "see the whole thing in my head" before I attempted to solve the puzzles (after I figured out the basics). Some of the smaller problems on here you can "create as you go" and almost forget what you did at the beginning, and not be sure what the end looks like. The larger ones are too involved, and I've needed a "big picture" idea of what all the stages of problem solving process needed to be. I'd also recommend a game on steam called "Metro". It's a subway building game that puts you in a time crunch, which really makes your mind work faster even when there is no time constraint with other games/projects. It's good brain training.
heidisdad2
@heidisdad2
Jun 06 2017 06:25
i started yesterday
wonder
@wonder2991
Jun 06 2017 06:25
Ok. Let me work on it. Thanks @Masd925 @proconsu1
CamperBot
@camperbot
Jun 06 2017 06:25
wonder2991 sends brownie points to @masd925 and @proconsu1 :sparkles: :thumbsup: :sparkles:
:cookie: 183 | @proconsu1 |http://www.freecodecamp.com/proconsu1
:star2: 4205 | @masd925 |http://www.freecodecamp.com/masd925
Proconsul
@proconsu1
Jun 06 2017 06:25
@Netrunner21 Metro is it? i have Steam up now. will give a shifty
heidisdad2
@heidisdad2
Jun 06 2017 06:25
i want to learn java but i heard this is a good place to start
Proconsul
@proconsu1
Jun 06 2017 06:26
@heidisdad2 caution. Java and JavaScript are not the same thing. but you heard right. this is an excellent place to start
heidisdad2
@heidisdad2
Jun 06 2017 06:26
understand the basics of programming and then try to learn java...is that a good idea?
Markus Kiili
@Masd925
Jun 06 2017 06:26
@heidisdad2 Do you mean javascript? Java is another popular language.
Pethaf
@Pethaf
Jun 06 2017 06:26
@proconsu1 I spent yesterday trying to implement it.
heidisdad2
@heidisdad2
Jun 06 2017 06:26
no i meant java, that is what i want to learn eventually but im just starting out so going with javascript
Markus Kiili
@Masd925
Jun 06 2017 06:27
@heidisdad2 Java is a good and popular language. One of the big ones.
Netrunner21
@Netrunner21
Jun 06 2017 06:27
@proconsu1 yeah. It's for speed really, because you have to focus on a million things at once or your subways overflow and you lose. Talos Principle, also on steam, is more for sequential thought processing. It really feels like programming.
heidisdad2
@heidisdad2
Jun 06 2017 06:27
i tried it and got so confused
Proconsul
@proconsu1
Jun 06 2017 06:27
@heidisdad2 well you cannot learn coding without learning it in the framework of a language. and JS is an excellent choice as your first language to tackle, or so I have been repeatedly told
heidisdad2
@heidisdad2
Jun 06 2017 06:27
realized i am dumber than i thought
Markus Kiili
@Masd925
Jun 06 2017 06:28
@heidisdad2 Learning the basics of programming is hard. It just takes time to learn to think like a computer.
Proconsul
@proconsu1
Jun 06 2017 06:28
@heidisdad2 everyone who has a clue is dumber than they thought. anyone who isn't dumber than they thought is even dumber than that
heidisdad2
@heidisdad2
Jun 06 2017 06:28
@proconsu1 lol
funny but true
Netrunner21
@Netrunner21
Jun 06 2017 06:30