These are chat archives for FreeCodeCamp/HelpJavaScript

23rd
Jan 2017
ECC
@ECC716
Jan 23 2017 00:02
Hi again, folks. Working on "Nesting for Loops", using a For loop to iterate through nested arrays and multiply together all the entries. Here's my code:

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 *= j;
}
}
// Only change code above this line
return product;
}

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

Aaron
@apalm1341
Jan 23 2017 00:03
anyone good with java here??
ECC
@ECC716
Jan 23 2017 00:04
No matter how I modify the statement after the second loop--"product = j", "product = arr[i[j]]"--the function returns 1
FjuryX
@FjuryX
Jan 23 2017 00:07
function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes == 1){
    return "Hole-in-one";
  } else if (strokes <= par-2){
    return "Eagle";
  } else if (strokes == par -1){
    return "Birdie";
  } else if (strokes == par){
    return "Par";
  } else if (strokes == par+ 1){
    return "Bogey";
  } else if (strokes == par+ 2){
    return "Double Bogey";
  } else{
    return "Go Home!";
  }

  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
i have failure with the first if statement can someone help me, why?
Rico042002
@rico042002
Jan 23 2017 00:07
Hey guys
@FjuryX Better to use a switch statement
Rico042002
@rico042002
Jan 23 2017 00:13
What happened to this room, it used to be one of the busiest ones!
FjuryX
@FjuryX
Jan 23 2017 00:16
sure sure, but it was for testing my skills in else if ;) switch came after it @rico042002
@rico042002 but if u fill in my lines of code, u see the Hole in one fails, why?
I dont get it
CoryCMyers
@CoryCMyers
Jan 23 2017 00:22

If someone could confirm or deny my understanding of this I would be incredibly grateful.

function largestOfFour(mainArray) {
  return mainArray.map(function (subArray){
    return subArray.reduce(function (previousLargestNumber, currentLargestNumber) {
      return (currentLargestNumber > previousLargestNumber) ? currentLargestNumber : previousLargestNumber;
    }, 0);
  });
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

There are a couple methods in there I partially understand and wish to confirm. So the Map method takes the targeted Array or Subs and combines them into one main Array, and allows it to then be targeted with a function and named within that function as sub-array. Reduce says that all of the following function will be aimed at taking multiple numbers, and taking them down to one, then the function is a new way of writing an if/else statement?

Marc Symonds
@MarcSymonds
Jan 23 2017 00:27
@ECC716 You have got a greater than sign in this line - for (var i = 0; i > arr.length; i++) { - should be less than.
David Amanze
@GodKingShogun
Jan 23 2017 00:28
someone help me with the falcy bouncy challenge. i am suppose to filter out all the falsy values from the array. i already have my filter code set up but not really sure what to write in it to filter out the falsy values.

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

    });
}



bouncer([7, "ate", "", false, 9]);
ComicCaper
@ComicCaper
Jan 23 2017 00:31
Hi all. I'm trying to do the Intermediate projects with the APIs and I'm really lost. Does anyone have any good API tutorials they can recommend?
Ricardo G.
@Rubenricardo
Jan 23 2017 00:39
hey guys!
does anybody know
how to set the remainder with this instruction?
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
is it something like this?

var remainder;

remainder; 11 % 3;

Suraj
@suraj-davariya
Jan 23 2017 00:41
@Rubenricardo var remainder = 11%3;
it will store the remainder of 11/3 . I hope you got the point.
Ricardo G.
@Rubenricardo
Jan 23 2017 00:43
ok did it
@suraj-davariya thanks
CamperBot
@camperbot
Jan 23 2017 00:43
rubenricardo sends brownie points to @suraj-davariya :sparkles: :thumbsup: :sparkles:
:cookie: 274 | @suraj-davariya |http://www.freecodecamp.com/suraj-davariya
Ricardo G.
@Rubenricardo
Jan 23 2017 00:44
do you have any recommendation on basic java script? like a pdf or somethiong?
Suraj
@suraj-davariya
Jan 23 2017 00:45
@rico042002 i guess because of Sunday night
well, You can go through w3schools . com @Rubenricardo :)
that's the best online resources ever for any programming languages.
Also start going through every methods from w3schools along with freecodecamp
@FjuryX please sort the else-if ladder properly to get correct answer :)
Peter Quin
@pgqu
Jan 23 2017 00:50
I am doing to 'Factorialize a Number' exercise and thought I had solved it, Im getting the correct result for all apart from the test for '0' which the test is asking to return 1 (which slightly confuses me) my code is as follows function factorialize(num) { var sum = num; var numNum = []; for (var i=(num-1); i>0; i--) { numNum.push(i); } for (var e=0; e<numNum.length; e++) { sum *= numNum[e]; } return sum; } Im not really understanding why this should be '1' in the first place and am wondering if this is a bug or if I just missed the maths lesson somewhere?
alican karalar
@alicankaralar
Jan 23 2017 00:50
hey guys i need help over something
Suraj
@suraj-davariya
Jan 23 2017 00:50
@ECC716 what do you wanted to do ? whats the question, can you please repeat that ?
@alicankaralar write here ;)
alican karalar
@alicankaralar
Jan 23 2017 00:51
function titleCase(str) {
var lower = str.toLowerCase();

  var c =[];

  for (var a = 0; a<lower.length; a++) {

    if (lower[a-1]==" " || a===0) { 

    c.push(lower[a].toUpperCase() ) ;}


    else { c.push(lower[a])  ;}

  }

  return  c.join("");
 }
titleCase("I'm a little tea pot");
now this works
its the title casing challenge
i solved it
Suraj
@suraj-davariya
Jan 23 2017 00:51
okay good to go :)
alican karalar
@alicankaralar
Jan 23 2017 00:51
but some other guy told me to do it with .map method
now i tried it but i couldn't come up with a solution
which would make me happy and release me to the next challenge :)
Suraj
@suraj-davariya
Jan 23 2017 00:52
haha
alican karalar
@alicankaralar
Jan 23 2017 00:52
function titleCase(str) {

 str=str.toLowerCase();

  var splat = str.split(" ");

    var cap = splat.map(function(val){ 

      var a = val.length;

      return val[0].toUpperCase();

    });

    return cap.join(" ");



 }
titleCase("I'm a little tea pot");
so the problem is
when i go around with map i don't know how to return the values other than val[0] unchanged
Suraj
@suraj-davariya
Jan 23 2017 00:53
@pgqu
function factorial(n) {
  if (n === 0) {
    return 1;
  }

  // This is it! Recursion!!
  return n * factorial(n - 1);
}
alican karalar
@alicankaralar
Jan 23 2017 00:54
when i do this i can return first letter of each word capitalized, but can't return other letters if i do that
is there a way to write a map function which accomplishes this? :)
Alex
@Joshua-A-Smith
Jan 23 2017 00:55

var Car = function() {
  //Change this constructor
  this.wheels = 4;
  this.seats = 5;
  this.engines = 1;
};

//Try it out here
var myCar = function(wheels, seats, engines) {
  this.wheels = wheels;
  this.seats = seats;
  this.engines = engines; 
};

var myCar = new myCar(3, 1, 2);
Anyone know why my code is wrong?
Suraj
@suraj-davariya
Jan 23 2017 00:57
@alicankaralar
function capitaliseFirstLetters(s) { 
return s.split(" ").map(function(w) { 
return w.charAt(0).toUpperCase() + w.substr(1) 
}).join(" ")
 }
alican karalar
@alicankaralar
Jan 23 2017 00:58
@suraj-davariya thanks! i didn't know charAt() method
CamperBot
@camperbot
Jan 23 2017 00:58
alicankaralar sends brownie points to @suraj-davariya :sparkles: :thumbsup: :sparkles:
:cookie: 275 | @suraj-davariya |http://www.freecodecamp.com/suraj-davariya
alican karalar
@alicankaralar
Jan 23 2017 00:58
what does + w.substr(1) do?
Suraj
@suraj-davariya
Jan 23 2017 00:59

@Joshua-A-Smith

```

var Car = function() {
//Change this constructor
this.wheels = 4;
this.seats = 5;
this.engines = 1;
};

//Try it out here
var myCar = function(wheels, seats, engines) {
this.wheels = wheels;
this.seats = seats;
this.engines = engines;
};

var myCar = new myCar(3, 1, 2);

Anyone know why my code is wrong?

//Try it out here
var myCar = function(wheels, seats, engines) {
this.wheels = wheels,
this.seats = seats,
this.engines = engines
};
```

@Joshua-A-Smith : use Comma ( , ) between the properties...

//Try it out here
var myCar = function(wheels, seats, engines) {
  this.wheels = wheels,
  this.seats = seats,
  this.engines = engines
};
@alicankaralar it will add rest of the string to the previous string. try it without that line ;)
alican karalar
@alicankaralar
Jan 23 2017 01:02
yep but substr(x) does what like does it substract the first letter from the string?
Alexander Huynh
@caesarsalad93
Jan 23 2017 01:02
What does the + mean in front of the d?
.map(function(d,i){return Math.pow(+d,i+p) })
Peter Quin
@pgqu
Jan 23 2017 01:04
I am doing to 'Factorialize a Number' exercise and thought I had solved it, Im getting the correct result for all apart from the test for '0' which the test is asking to return 1 (which slightly confuses me) my code is as follows
function factorialize(num) { var sum = num; var numNum = []; for (var i=(num-1); i>0; i--) { numNum.push(i); } for (var e=0; e<numNum.length; e++) { sum *= numNum[e]; } return sum; } Im not really understanding why this should be '1' in the first place and am wondering if this is a bug or if I just missed the maths lesson somewhere?
Suraj
@suraj-davariya
Jan 23 2017 01:04
@alicankaralar w.charAt(0) just returns the first char of the word.
Peter Quin
@pgqu
Jan 23 2017 01:04

I am doing to 'Factorialize a Number' exercise and thought I had solved it, Im getting the correct result for all apart from the test for '0' which the test is asking to return 1 (which slightly confuses me) my code is as follows

function factorialize(num) {
var sum = num;
var numNum = [];
for (var i=(num-1); i>0; i--) {
          numNum.push(i);
}
for (var e=0; e<numNum.length; e++) {
         sum *= numNum[e];
}
return sum;  
}

Im not really understanding why this should be '1' in the first place and am wondering if this is a bug or if I just missed the maths lesson somewhere?

alican karalar
@alicankaralar
Jan 23 2017 01:04
@suraj-davariya okay Thanks ! :)
CamperBot
@camperbot
Jan 23 2017 01:04
alicankaralar sends brownie points to @suraj-davariya :sparkles: :thumbsup: :sparkles:
:warning: alicankaralar already gave suraj-davariya points
Peter Quin
@pgqu
Jan 23 2017 01:05
sorry, bad formatting before
Suraj
@suraj-davariya
Jan 23 2017 01:07
@pgqu first of all , you can use recursion function to use these types of results.
Johnny
@JohnnyBizzel
Jan 23 2017 01:07

Anyone know much about prototype functions?
How do I access the values passed in here:

var Result = { "win": 1, "loss": 2, "tie": 3 }

function PokerHand(hand) {
}

PokerHand.prototype.compareWith = function(hand){
    // Start your coding here...

   var myHand = this.hand.split(' ');
    var opHand = hand.split(' ');
    if (myHand[0] > opHand[0])
      return Result.win;
    if (this.hand != hand)
      return Result.win;
    return Result.tie;
}

var player = "4S 5H 6H TS AC";
var opponent =  "3S 5H 6H TS AC";
var p = new PokerHand(player);
var o = new PokerHand(opponent);
p.compareWith(o)

.split() is not allowed :/

Suraj
@suraj-davariya
Jan 23 2017 01:07

function factorialize(num) {

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

factorialize(5);
@pgqu this is the simplest way.
Alex
@Joshua-A-Smith
Jan 23 2017 01:11
@suraj-davariya Your advice isn't working
Johnny
@JohnnyBizzel
Jan 23 2017 01:13
@Anmar0293 use arr not testArr inside the function. Do that first.
David Amanze
@GodKingShogun
Jan 23 2017 01:14
@JohnnyBizzel senpai can you help me with the search and destroy challenge

function destroyer(arr) {
  // Remove all the values
  return arr.filter(function() {

   });
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Anmar0293
@Anmar0293
Jan 23 2017 01:14
Hello @JohnnyBizzel Thank you for your response. I changed it and it still the same
Johnny
@JohnnyBizzel
Jan 23 2017 01:15
@Anmar0293 You are close. Try using http://pythontutor.com/visualize.html and you may see the problem
@GodKingShogun Nothing in the filter yet :exclamation:
Johnny
@JohnnyBizzel
Jan 23 2017 01:16
@Anmar0293
function nextInLine(arr, item) {
  // Your code here
  Arr.push(item);
  item = Arr[0];
  Arr.shift();
  return item;  // Change this line
}

// Test Setup
var Arr = [5,6,7,8,9];
^^ post code here
David Amanze
@GodKingShogun
Jan 23 2017 01:16
@JohnnyBizzel lol i know that much. im not sure how to access the arguments outside the array
Johnny
@JohnnyBizzel
Jan 23 2017 01:17
@GodKingShogun How do you access items in an array?
Anmar0293
@Anmar0293
Jan 23 2017 01:17
@JohnnyBizzel it doesn't go through. I even copied your code!
Johnny
@JohnnyBizzel
Jan 23 2017 01:17

@Anmar0293 Please note

Arr != arr

Use the function scope level variable. It should be a pure function.

Peter Quin
@pgqu
Jan 23 2017 01:17
Ok, thanks @suraj-davariya i will go over that and make sure i understand, at the moment this is return nearly correctly bu with an added 1, I think as a string on the end. I will work on it and come back once i have it working, thanks for the nudge in the right direction
CamperBot
@camperbot
Jan 23 2017 01:17
pgqu sends brownie points to @suraj-davariya :sparkles: :thumbsup: :sparkles:
:cookie: 276 | @suraj-davariya |http://www.freecodecamp.com/suraj-davariya
David Amanze
@GodKingShogun
Jan 23 2017 01:18
@JohnnyBizzel the two arguments i need to filter are not inside the array
@JohnnyBizzel ill post it again so you dont have to scroll up

function destroyer(arr) {
  // Remove all the values
  return arr.filter(function() {

   });
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Anmar0293
@Anmar0293
Jan 23 2017 01:19
got it! you were right @JohnnyBizzel Arr!= arr
thanks a lot @JohnnyBizzel
CamperBot
@camperbot
Jan 23 2017 01:19
anmar0293 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1175 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Jan 23 2017 01:19
function destroyer(arr) {
 arr[0] is someting
arr[1] is someting else ,etc
  // Remove all the values
  return arr.filter(function() {

   });
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
@Anmar0293 Anytime
Suraj
@suraj-davariya
Jan 23 2017 01:20
@Joshua-A-Smith Sorry bro. I am checking it out
David Amanze
@GodKingShogun
Jan 23 2017 01:20
@JohnnyBizzel destroyer is an array and then two numbers get added outside the array. what ever is outside the array i have to filter out from the array. but not sure how to tell the code that i want to filter out what is outside the array
Moisés Man
@moigithub
Jan 23 2017 01:21
@GodKingShogun did u read about the "helpful links" ?
on the instructions
David Amanze
@GodKingShogun
Jan 23 2017 01:22
@moigithub i read it but i couldn't understand the argument object link very well
@moigithub can you summarize please
Moisés Man
@moigithub
Jan 23 2017 01:22
do u know how to use console.log ?? and devtools ??
console.log(arguments) probably helps
David Amanze
@GodKingShogun
Jan 23 2017 01:23
@moigithub console.log yes but never heard of devtools
Moisés Man
@moigithub
Jan 23 2017 01:24
its a built-in tools on ur browser
F12 on most browsers to open it..
if u go to "console TAB" u will see all the output u put using console.log
Johnny
@JohnnyBizzel
Jan 23 2017 01:25
@GodKingShogun http://pythontutor.com/visualize.htm gives you visual info about the objects.
David Amanze
@GodKingShogun
Jan 23 2017 01:26
@moigithub @JohnnyBizzel still not sure how that ties in to me being able to access what is outside the array so i can filter the array
Johnny
@JohnnyBizzel
Jan 23 2017 01:26

Reposting ...
Anyone know much about prototype functions?
How do I access the values passed in here:

var Result = { "win": 1, "loss": 2, "tie": 3 }

function PokerHand(hand) {
}

PokerHand.prototype.compareWith = function(hand){
    // Start your coding here...

   var myHand = this.hand.split(' ');
    var opHand = hand.split(' ');
    if (myHand[0] > opHand[0])
      return Result.win;
    if (this.hand != hand)
      return Result.win;
    return Result.tie;
}

var player = "4S 5H 6H TS AC";
var opponent =  "3S 5H 6H TS AC";
var p = new PokerHand(player);
var o = new PokerHand(opponent);
p.compareWith(o)

.split() is not allowed :/

Suraj
@suraj-davariya
Jan 23 2017 01:29
@Joshua-A-Smith
var Car = function(wheels,seats,engines) {
  //Change this constructor
  this.wheels = wheels;
  this.seats = seats;
  this.engines = engines;
};

//Try it out here


var myCar = new Car(3,1,2);
Moisés Man
@moigithub
Jan 23 2017 01:29
@GodKingShogun if u dont wanna open devtools.. u can also use this repl.it/languages/javascript
but... neither of those bite.. so dont be scared to use em.. nothing to loose...
best way to learn what those does.. is trying...
function destroyer(arr) {
     console.log(arguments);
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Skullvapor
@Skullvapor
Jan 23 2017 01:32
They are saying that I have to remove all the backlashes and also that I need 2 single quotes and 4 double quotes while getting rid of all the back-slashes but what? var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
var myStr = "<a href='http://www.example.com' target='_blank'>Link</a>";
that
David Amanze
@GodKingShogun
Jan 23 2017 01:33
@moigithub not scared to use then but can you tell me the reason i am using them
Moisés Man
@moigithub
Jan 23 2017 01:33
also that I need 2 single quotes and 4 double quotes @Skullvapor
@GodKingShogun once u test that code u will know WHY
Skullvapor
@Skullvapor
Jan 23 2017 01:34
@moigithub So what
's wrong?
David Amanze
@GodKingShogun
Jan 23 2017 01:34
@moigithub so do i just copy and paste the code i am initial giving or does it have to be completed already
Moisés Man
@moigithub
Jan 23 2017 01:34
count how many SINGLES ' quotes u have
and how many DOUBLES " @Skullvapor
does it match what u posted abvove ?
David Amanze
@GodKingShogun
Jan 23 2017 01:35
@moigithub are you asking me
Skullvapor
@Skullvapor
Jan 23 2017 01:35
@moigithub But to get rid of all the "/ you need to do 4 of the ' because there are 4 of them if that makes sense.
Moisés Man
@moigithub
Jan 23 2017 01:35
@Skullvapor switch all doubles for singles.. and viceversa...
then u will have 4 doubles and 2 singles
David Amanze
@GodKingShogun
Jan 23 2017 01:36
@Skullvapor try copy and pasting your code in between ```
Skullvapor
@Skullvapor
Jan 23 2017 01:36
I'm low-key not stupid.
Moisés Man
@moigithub
Jan 23 2017 01:37
??
Skullvapor
@Skullvapor
Jan 23 2017 01:37
thankyou!
David Amanze
@GodKingShogun
Jan 23 2017 01:38
@moigithub so would i just copy this into devtools

function destroyer(arr) {
  // Remove all the values

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Moisés Man
@moigithub
Jan 23 2017 01:38
reposting....
@GodKingShogun u can also use this repl.it/languages/javascript
function destroyer(arr) {
     console.log(arguments);
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Johnny
@JohnnyBizzel
Jan 23 2017 01:39

I got some help on StackOverflow

var Result = { "win": 1, "loss": 2, "tie": 3 }

function PokerHand(hand) {
 // needs adding
  this.hand = hand;
}

PokerHand.prototype.compareWith = function(opp){
    // Start your coding here...

   var myHand = this.hand.split(' ');
    var opHand = opp.hand.split(' ');
    if (myHand[0] > opHand[0])
      return Result.win;
    if (this.hand != hand)
      return Result.win;
    return Result.tie;
}

var player = "4S 5H 6H TS AC";
var opponent =  "3S 5H 6H TS AC";
var p = new PokerHand(player);
var o = new PokerHand(opponent);
p.compareWith(o)

.split() is now allowed :exclamation:

Moisés Man
@moigithub
Jan 23 2017 01:39
console.log(this.hand) <-- should return a string
cuz split only allowed on string (string method)
Johnny
@JohnnyBizzel
Jan 23 2017 01:41
@moigithub The instructions threw me as it says
// Start your coding here...
implying that you don't need code above that line.
David Amanze
@GodKingShogun
Jan 23 2017 01:41
@moigithub this is what i got in return

clear







Native Browser JavaScript

{ '0': [ 1, 2, 3, 1, 2, 3 ], '1': 2, '2': 3 }
=> undefined
@moigithub what does that mena
Moisés Man
@moigithub
Jan 23 2017 01:42
@JohnnyBizzel console.log is for debuggin purposes.. to find whats /wheres wrong.. once u know what was causing the error u can always remove it
David Amanze
@GodKingShogun
Jan 23 2017 01:42
lol mean*
Johnny
@JohnnyBizzel
Jan 23 2017 01:42
@GodKingShogun Looks like the arguments object
Moisés Man
@moigithub
Jan 23 2017 01:44
destroyer([1, 2, 3, 1, 2, 3], 2, 3); this is HOW u call the function // pass values in this case u passing 1 array and 2 numbers
argument object contains a list of ALL those values u pass
since ur function only have ONE "named parameter" function destroyer(arr) { <-- arr
u wouldnt be able to access those 2, 3 values..
but using the arguments object u can
@GodKingShogun
David Amanze
@GodKingShogun
Jan 23 2017 01:44
@moigithub @JohnnyBizzel still not sure how this helps me solve the destroyer challenge. i already knew that the array was the first argument and the rest were the second and so forth. how do i let my code know that i want to filter out the second and third arguments
Manish Giri
@Manish-Giri
Jan 23 2017 01:50
@GodKingShogun
how do i let my code know that i want to filter out the second and third arguments
David Amanze
@GodKingShogun
Jan 23 2017 01:50
@Manish-Giri hello SENPAI
Manish Giri
@Manish-Giri
Jan 23 2017 01:50
you can do this with arguments, like others have suggested
@GodKingShogun hello :wave:
David Amanze
@GodKingShogun
Jan 23 2017 02:04
@Manish-Giri still not sure what to write in my filter function

function destroyer(arr) {
  // Remove all the values
 for (i=arguments[1]; i<arguments.length; i++) {
  return arr.filter(function(arr) {

  });
 }
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
0
Amit Patel
@AmitP88
Jan 23 2017 02:09
hey guys, I need help getting my modals to work for the menu items on this site: https://amitp88.github.io/Khmer-Family-Cafe/
here's the fiddle I used http://jsfiddle.net/5b01x6g2/1/
sorry, i can't use codepen because due to the amount of code for the site, it would be too much of a pain to get it to work in a codepen
Manish Giri
@Manish-Giri
Jan 23 2017 02:12
@GodKingShogun what's the challenge name
Cindy Xiong
@cindyx123
Jan 23 2017 02:12
can someone please help me tackle the challenge 'return early pattern for functions' step by step. I'm so lost but i want to understand this
Manish Giri
@Manish-Giri
Jan 23 2017 02:12
@cindyx123 your code?
Cindy Xiong
@cindyx123
Jan 23 2017 02:12
if (a <0){
return undefined;
}
else if (b <0){
return underfined;
}
David Amanze
@GodKingShogun
Jan 23 2017 02:13
@Manish-Giri seek and destroy
@cindyx123 undefined is spelled wrong
Manish Giri
@Manish-Giri
Jan 23 2017 02:13
@cindyx123 so instead of having a separate if and else, you need to check for both a and b in the same if condition, using the logical OR operator - ||
David Amanze
@GodKingShogun
Jan 23 2017 02:14
@cindyx123 post your code in between ``` for easy readability
Manish Giri
@Manish-Giri
Jan 23 2017 02:14

here's a quick example

if(firstName === "Cindy" || lastName == "Xiong") {
  console.log("Permission granted");
}

you can guess what this does.

@cindyx123
David Amanze
@GodKingShogun
Jan 23 2017 02:15
@Manish-Giri by the way the challenge i am on is seek and destroy
justinmaines
@justinmaines
Jan 23 2017 02:15
Can someone help give me a start on the lesson "Condense arrays with .reduce"? I have zero clue how to start this.
David Amanze
@GodKingShogun
Jan 23 2017 02:16
@justinmaines look at the example they give you
Manish Giri
@Manish-Giri
Jan 23 2017 02:16
@GodKingShogun okay, so one idea is - have an array out of the remaining arguments passed to your function. Then, while you loop through the arr array, check to see if the current element is present in the array you created in step 1, if it is not present, push this element onto a new array, and continue.
David Amanze
@GodKingShogun
Jan 23 2017 02:16
@justinmaines that should give you an idea of what to do
Cindy Xiong
@cindyx123
Jan 23 2017 02:17
@Manish-Giri that codes says" if first name or last name == cindy or xiong then "permission granted". but can you explain what "console.log()" do?
Manish Giri
@Manish-Giri
Jan 23 2017 02:17
@cindyx123 console.log("Permission granted"); just prints to the console.
once you finish looping, the array where you are pushing the filtered elements, will be your result.
@GodKingShogun
Cindy Xiong
@cindyx123
Jan 23 2017 02:19
@Manish-Giri thanks
CamperBot
@camperbot
Jan 23 2017 02:19
cindyx123 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3915 | @manish-giri |http://www.freecodecamp.com/manish-giri
David Amanze
@GodKingShogun
Jan 23 2017 02:19
@Manish-Giri the arguments that are not in the array are the ones i want to get rid of. that is why i am using filter but i am not sure what to write inside my filter function so the arguments outside the array are removed from the array
@Manish-Giri this is what i have so far

function destroyer(arr) {
  // Remove all the values
 for (i=arguments[1]; i<arguments.length; i++) {
  return arr.filter(); 

 }
}
Stephen James
@sjames1958gm
Jan 23 2017 02:22
@GodKingShogun 1) your loop doesn't look right - you should start i at 1 not arguments[1]
2) filter receives an function that processes each array entry
David Amanze
@GodKingShogun
Jan 23 2017 02:23
@sjames1958gm if i put 1 will it star looping from the 2 outside the array

function destroyer(arr) {
  // Remove all the values
 for (i=arguments[1]; i<arguments.length; i++) {
  return arr.filter(); 

 }
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Stephen James
@sjames1958gm
Jan 23 2017 02:23
@GodKingShogun yes
@GodKingShogun well arguments[i] would
Manish Giri
@Manish-Giri
Jan 23 2017 02:24
@GodKingShogun you can use Array.isArray() to filter out the other arguments.
David Amanze
@GodKingShogun
Jan 23 2017 02:26
@Manish-Giri i thought if i use filter it would only look at the array elements so i dont have to worry about the rest
@sjames1958gm so what do i write in my filter function. thats the last step
Manish Giri
@Manish-Giri
Jan 23 2017 02:29
@GodKingShogun not sure what you mean
Stephen James
@sjames1958gm
Jan 23 2017 02:30
@GodKingShogun THat is the big question, your function needs to return true if the array value is not in the remaining arguments value
LiuLong
@yoyoos
Jan 23 2017 02:30
collectionCopy[id][prop].push(value) is not a function -_-\\
Stephen James
@sjames1958gm
Jan 23 2017 02:30
The for loop is probably not correct at aleast outside of filter function
@yoyoos You may need to check if the tracks array is there or not, btw you should be using collection not collectionCopy
Simeon
@SimeonCodes
Jan 23 2017 02:31
whilst your talking arrays is it possible to empty the original array via passed to a function?
LiuLong
@yoyoos
Jan 23 2017 02:33
class 222
David Amanze
@GodKingShogun
Jan 23 2017 02:33
@sjames1958gm how would you do this problem then
@Manish-Giri i focused extra on my hiragana this week
Stephen James
@sjames1958gm
Jan 23 2017 02:34
@GodKingShogun convert arguments to an array and then use indexOf inside the filter function to test the array values
pepexd627
@pepexd627
Jan 23 2017 02:34
Can anyone give me some advice on this? It just returns the same str value.

function rot13(str) { // LBH QVQ VG!
var string = [];
var x = String.fromCharCode(i) + 13;
var y = String.fromCharCode(i) - 13;

for (var i = 0; i < str.length; i++) {
if (String.fromCharCode(65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77)) {
String.fromCharCode(str.charCodeAt(i) + 13);
return str;
} else {
String.fromCharCode(str.charCodeAt(i) - 13);
return str;
}
}

}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
//fromCharCode returns letter charCodeAt returns code if <=77 + 13 if >=77 - 13

Stephen James
@sjames1958gm
Jan 23 2017 02:36
@pepexd627 You are returning the original str
String.fromCharCode returns a value that you are not capturing.
Not at all sure what if (String.fromCharCode(65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77)) { this is doing
Bardoe Bess
@bardbess
Jan 23 2017 02:36
var abc = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz' :P works a treat.
Simeon
@SimeonCodes
Jan 23 2017 02:37

    var myArray = [{base:"asd", post:"asd"},{base:"asd", post:"asd"},{base:"asd", post:"asd"}];
    console.log(JSON.stringify(myArray));

    function emptyArray(arr){
        console.log('Emptying array...');
        arr = [];
        console.log('Array should now be empty...');        
        console.log(JSON.stringify(myArray));
    }
    emptyArray(myArray);
how would i fix this so that the original array is cleared aswell?
Stephen James
@sjames1958gm
Jan 23 2017 02:38
@pepexd627 Advice is to convert str[i] to a number using charCodeAt - then test if letter or A-M or N-Z adding 13 or subtracting 13 then pushing to string array
pepexd627
@pepexd627
Jan 23 2017 02:38
@sjames1958gm Basically if the char code is at those values I'm trying to return them with 13 added and if they aren't at those values I'd subtract 13
Stephen James
@sjames1958gm
Jan 23 2017 02:39
@pepexd627 YOu need to test the result of str.charCodeAt(i)
Bardoe Bess
@bardbess
Jan 23 2017 02:39
use myArray in your function if you want to manipulate it @SimeonCodes . is that what your asking?
Stephen James
@sjames1958gm
Jan 23 2017 02:39
@pepexd627 You would need to shift() off all the values to change the outer array (you could use pop) but you need something that mutates the existing array
Simeon
@SimeonCodes
Jan 23 2017 02:40
@bardbess kind of, except im wanting to pass the function multiple arrays
pepexd627
@pepexd627
Jan 23 2017 02:40
@sjames1958gm Thank you. I'll get to work.
CamperBot
@camperbot
Jan 23 2017 02:40
pepexd627 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5478 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jan 23 2017 02:40
@pepexd627 good luck
Bardoe Bess
@bardbess
Jan 23 2017 02:41
can you just shift or pop from myArray ? function emptyArray(){ var arr = myArray.shift() @SimeonCodes
LiuLong
@yoyoos
Jan 23 2017 02:42
i need the lession 222 code
return .push(value) is not a funcion
Jor
@joreyesl
Jan 23 2017 02:42
@SimeonCodes you can use .splice(0) and that will remove all the items from the array
Simeon
@SimeonCodes
Jan 23 2017 02:42
@bardbess no because i pass in multiple arrays
Bardoe Bess
@bardbess
Jan 23 2017 02:43
so you want to find the passed in value in myArray and delete it? @SimeonCodes
Simeon
@SimeonCodes
Jan 23 2017 02:43

    var myArray = [{base:"asd", post:"asd"},{base:"asd", post:"asd"},{base:"asd", post:"asd"}];
    var myOtherArray = [{base:"asd", post:"asd"},{base:"asd", post:"asd"},{base:"asd", post:"asd"}];
    //console.log(JSON.stringify(myArray));

    function emptyArray(arr){
        console.log('Emptying array...');
        arr = [];
        console.log('Array should now be empty...');        
        console.log(JSON.stringify(myArray));
    }
    emptyArray(myArray);
    emptyArray(myOtherArray);
Stephen James
@sjames1958gm
Jan 23 2017 02:43
@yoyoos .push(value) isn't valid syntax what does your code look like?
@SimeonCodes your function could use arr.splice(0) in the function as was suggested
Bardoe Bess
@bardbess
Jan 23 2017 02:44
you sure you dont just want to return arr in your function @SimeonCodes ?
Jor
@joreyesl
Jan 23 2017 02:44
@SimeonCodes arr = []; all you are doing here is assigning an empty array to the parameter arr the original array remains intact. try arr.splice(0) instead
LiuLong
@yoyoos
Jan 23 2017 02:45
blob
blob
Bardoe Bess
@bardbess
Jan 23 2017 02:45
also console.table(myArray) might be useful to you @SimeonCodes
alican karalar
@alicankaralar
Jan 23 2017 02:46
hey guys
Stephen James
@sjames1958gm
Jan 23 2017 02:46
@yoyoos Use collection not collectionCopy in the function
alican karalar
@alicankaralar
Jan 23 2017 02:46
Simeon
@SimeonCodes
Jan 23 2017 02:46
yes thanks @joreyesl @sjames1958gm i thought splice would of just taken off one entry, but have tested that now and it works perfect
CamperBot
@camperbot
Jan 23 2017 02:46
simeoncodes sends brownie points to @joreyesl and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5479 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:cookie: 360 | @joreyesl |http://www.freecodecamp.com/joreyesl
alican karalar
@alicankaralar
Jan 23 2017 02:47
function repeatStringNumTimes(str, num) {
  // repeat after me

  var array = [];

  var i = 0;

  while (i<num) { 

    array.push(str);

    i++;
  }

  array=array.join("");

  return array ;
}

repeatStringNumTimes("abc", 3);
Stephen James
@sjames1958gm
Jan 23 2017 02:47
@yoyoos If collection[id].tracks is not set then the push will fail you need to test
LiuLong
@yoyoos
Jan 23 2017 02:47
blob
Simeon
@SimeonCodes
Jan 23 2017 02:47
@bardbess thanks, i never knew that exsisted
alican karalar
@alicankaralar
Jan 23 2017 02:47
this works, but i'd like to know if there is a better way to do it
CamperBot
@camperbot
Jan 23 2017 02:47
simeoncodes sends brownie points to @bardbess :sparkles: :thumbsup: :sparkles:
:cookie: 348 | @bardbess |http://www.freecodecamp.com/bardbess
Stephen James
@sjames1958gm
Jan 23 2017 02:47
@alicankaralar use newStr = "" and use newStr += str
Then you don't need join.
Simeon
@SimeonCodes
Jan 23 2017 02:48
@alicankaralar cheatcode is to use the function repeat()
Suraj
@suraj-davariya
Jan 23 2017 02:48

```
function repeatStringNumTimes(str, num) {
// repeat after me

var array = [];

var i = 0;

while (i<num) {

array.push(str);

i++;

}

array=array.join("");

return array ;
}

repeatStringNumTimes("abc", 3);

```

hint : String.repeat(num);

@alicankaralar
alican karalar
@alicankaralar
Jan 23 2017 02:49
@sjames1958gm @SimeonCodes @suraj-davariya thanks! i'll look into it
CamperBot
@camperbot
Jan 23 2017 02:49
alicankaralar sends brownie points to @sjames1958gm and @simeoncodes and @suraj-davariya :sparkles: :thumbsup: :sparkles:
:cookie: 277 | @suraj-davariya |http://www.freecodecamp.com/suraj-davariya
:cookie: 436 | @simeoncodes |http://www.freecodecamp.com/simeoncodes
:star2: 5480 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Suraj
@suraj-davariya
Jan 23 2017 02:50
@camperbot whats up ?
LiuLong
@yoyoos
Jan 23 2017 02:51
@sjames1958gm is that a bug?
blob
Manish Giri
@Manish-Giri
Jan 23 2017 02:54
@GodKingShogun did you get it?
Stephen James
@sjames1958gm
Jan 23 2017 02:58
@yoyoos No, if prop === "tracks" you need to test if the array is there or not - it is in the instructions
Brittni Willett
@Willow606
Jan 23 2017 03:09
can someone help me with my replace method? It doesn't seem to be working... str.replace(str[i],"&amp;");
JedraPeake
@JedraPeake
Jan 23 2017 03:10
A little confused about this question and what i should be doing, Change the provided string from double to single quotes and remove the escaping. var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
Manish Giri
@Manish-Giri
Jan 23 2017 03:15
@JedraPeake they want you to remove the \" and use single quotes ' instead.
Moisés Man
@moigithub
Jan 23 2017 03:15
@Willow606 the syntax of that specific piece of code looks OK
Brittni Willett
@Willow606
Jan 23 2017 03:16
and yet it's not working
@moigithub thanks for looking
CamperBot
@camperbot
Jan 23 2017 03:16
willow606 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2577 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Jan 23 2017 03:16
probably the error is somewhere else @Willow606
easier to check if u post all ur code
Brittni Willett
@Willow606
Jan 23 2017 03:17

```function convertHTML(str) {
for(i = 0; i < str.length; i++){
if(str[i] === "&"){
str.replace(str[i],"&");
}
}
return str;
}

convertHTML("Dolce & Gabbana");```

oops sec

function convertHTML(str) {
for(i = 0; i < str.length; i++){
if(str[i] === "&"){
str.replace(str[i],"&");
}
}
return str;
}

convertHTML("Dolce & Gabbana");

the & actually reads "&" in the code
Moisés Man
@moigithub
Jan 23 2017 03:19
@Willow606 replace return a new string
soo in order to keep that new value.. u need to reasign it
str = str.replace etc etc
Rahim
@superkaskus
Jan 23 2017 03:19
Hello room
Can someone help me little with the profile lookup challenge? am really struggling for hours now
Brittni Willett
@Willow606
Jan 23 2017 03:20
ah got it thanks @moigithub
CamperBot
@camperbot
Jan 23 2017 03:20
willow606 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: willow606 already gave moigithub points
JedraPeake
@JedraPeake
Jan 23 2017 03:21
@Manish-Giri thanx, i tried that but it didnt work though
CamperBot
@camperbot
Jan 23 2017 03:21
jedrapeake sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3916 | @manish-giri |http://www.freecodecamp.com/manish-giri
Rahim
@superkaskus
Jan 23 2017 03:21

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

if (contacts.hasOwnProperty("firstName")){

return firstName;

}

return "not found";

// Only change code above this line
}

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

Manish Giri
@Manish-Giri
Jan 23 2017 03:21
@JedraPeake show what you tried.
JedraPeake
@JedraPeake
Jan 23 2017 03:22
var myStr = "<a href='http://www.example.com' target='_blank'>Link</a>";
^ @Manish-Giri
Manish Giri
@Manish-Giri
Jan 23 2017 03:23
@JedraPeake what was the challenge name
Robert Bates
@robsimple
Jan 23 2017 03:23
I was never good with math and this instruction is confusing me....
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
JedraPeake
@JedraPeake
Jan 23 2017 03:24
@Manish-Giri Quoting Strings with Single Quotes
Manish Giri
@Manish-Giri
Jan 23 2017 03:24

@JedraPeake

You should have two single quotes ' and four double quotes "

I think they want you to invert the order - use " inside, and ' outside.
Vizij
@Vizij
Jan 23 2017 03:25
@robsimple It's the same as division, except you're using the remainder op (%) in place of division(/) so you get the remainder rather than the quotient
alican karalar
@alicankaralar
Jan 23 2017 03:25

function truncateString(str, num) {
  // Clear out that junk in your trunk //
  //Method A --------------------------------------------------------------------


  if (str.length>num) { 



    // this returns as expected, returning letters (0 to num) + "..."

    //truncateString("Absolutely Longer", 2) should return "Ab...". . Check

    if (num<=3) { return str.substr(0,num)+"..."; }



    //this returns as expected too! returns letters (0 to num) + "..." 

    //truncateString("A-tisket a-tasket A green and yellow basket", 11) should return "A-tisket...".

    // I don't get why it has to return "A-tisket..." rather than "A-tisket a-..."

    else {return str.substr(0,num-3)+"...";}

  }

  else return str;
}

//It doesn't add to the string length for me! 
//so why am i supposed to tweak my code 
//in order to meet that anticipation??

/*
      Note that inserting the three dots to the end 
      will add to the string length.

      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.

*/


truncateString("A-tisket a-tasket A green and yellow basket", 11);
JedraPeake
@JedraPeake
Jan 23 2017 03:25
@Manish-Giri oh okay let me see what i can do thanx a lot
CamperBot
@camperbot
Jan 23 2017 03:25
jedrapeake sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: jedrapeake already gave manish-giri points
alican karalar
@alicankaralar
Jan 23 2017 03:25
can anybody answer my quesion in the notes?
Manish Giri
@Manish-Giri
Jan 23 2017 03:25
@JedraPeake welcome
Robert Bates
@robsimple
Jan 23 2017 03:25
so then it should be 11 % 3
Vizij
@Vizij
Jan 23 2017 03:26
@robsimple Yup~
Robert Bates
@robsimple
Jan 23 2017 03:26
coo thanks @Vizij
CamperBot
@camperbot
Jan 23 2017 03:26
robsimple sends brownie points to @vizij :sparkles: :thumbsup: :sparkles:
:cookie: 327 | @vizij |http://www.freecodecamp.com/vizij
alican karalar
@alicankaralar
Jan 23 2017 03:28
is anybody interested in explaining me :)
i'd like to understand why it has to add
Vizij
@Vizij
Jan 23 2017 03:33
@alicankaralar Because when you add the "...", it becomes part of the measurement, so the length of 11 for the "A-tisket..." example includes the three dots
Brittni Willett
@Willow606
Jan 23 2017 03:34
if(str[i] == /[A-Z]/){
  str = str.replace(str[i], "-");
}
isn't working
Moisés Man
@moigithub
Jan 23 2017 03:35
if u wanna use regex /[A-Z]/
then u need to use regex method to test.. not ===
try .test or .match methods @Willow606
Joseph
@revisualize
Jan 23 2017 03:35
I dont think you can use regex in an if condition.
Yeah.
Brittni Willett
@Willow606
Jan 23 2017 03:35
ok thank you
alican karalar
@alicankaralar
Jan 23 2017 03:35
ah now i get it lol its not due to some javascript inner workings kinda thing, its what they expect of me... lol
@Vizij thank you
CamperBot
@camperbot
Jan 23 2017 03:35
alicankaralar sends brownie points to @vizij :sparkles: :thumbsup: :sparkles:
Brittni Willett
@Willow606
Jan 23 2017 03:35
thanks @moigithub
CamperBot
@camperbot
Jan 23 2017 03:35
willow606 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:cookie: 328 | @vizij |http://www.freecodecamp.com/vizij
:warning: willow606 already gave moigithub points
Brittni Willett
@Willow606
Jan 23 2017 03:37
if(str[i].match(/[A-Z]/) === true){
str = str.replace(str[i], "-");
}
still not working
Chris
@omniprime
Jan 23 2017 03:41
var cut = str.split(" ");
  var biggest = cut[0];
  for (var i = 1; i <= cut.length; i++)
    if (biggest.length < cut[i].length) {
      biggest = cut[i];
    }
  }
  return biggest.length + 1;
}
Anyone have thoughts on why the cut[i] in my if statement is returning undefined?
Brittni Willett
@Willow606
Jan 23 2017 03:43
@omniprime can I see your function call?
Manish Giri
@Manish-Giri
Jan 23 2017 03:44
@omniprime you need a {} after the for loop
Brittni Willett
@Willow606
Jan 23 2017 03:44
wow good eye @Manish-Giri
Manish Giri
@Manish-Giri
Jan 23 2017 03:44
to nest the if inside.
lol, thx @Willow606
CamperBot
@camperbot
Jan 23 2017 03:44
manish-giri sends brownie points to @willow606 :sparkles: :thumbsup: :sparkles:
:cookie: 286 | @willow606 |http://www.freecodecamp.com/willow606
Brittni Willett
@Willow606
Jan 23 2017 03:45
if(str[i].match(/[A-Z]/) === true){
  str = str.replace(str[i], "-");
}
Chris
@omniprime
Jan 23 2017 03:45
That would make sense. I love missing the little things
Brittni Willett
@Willow606
Jan 23 2017 03:45
still not working. :/
Manish Giri
@Manish-Giri
Jan 23 2017 03:45
@Willow606 could you post all of your code pls?
wanna try it in jsbin.
Brittni Willett
@Willow606
Jan 23 2017 03:45
sure

function spinalCase(str) {
for(i = 0; i < str.length; i++){
if(str[i] === " "){
str = str.replace(str[i], "-");
}
if(str[i].match(/[A-Z]/) === true){
str = str.replace(str[i], "-");
}
}
str = str.toLowerCase();
return str;
}

spinalCase("thisIsSpinalTap");

Manish Giri
@Manish-Giri
Jan 23 2017 03:46
@Willow606 so which part isn't working?
Krittiya Clark
@krittiyaclark
Jan 23 2017 03:46
Hey guys - I am start doing the Counting Cards challenge. I am not sure how to write this code. What function do I write? If else?
Manish Giri
@Manish-Giri
Jan 23 2017 03:47
@Willow606 hold on, I'm not seeing where you're splitting the string str anywhere.
Pramod Potdar
@ppmakeitcount
Jan 23 2017 03:47
app.get('/', function(req, res) {
    if (req.session.restos) {
        console.log("r.resto_id");
        req.session.restos.forEach(function(r) {
            Resto.findOne({
                'resto_id': r.resto_id

            }, function(err, doc) {
                if (err) res.send("something went wrong in databas");
                if (doc) {
                    r.going = doc.totalGoing;
                }
            })
        })
    }
    res.render('index', {
        restos: req.session.restos,
        searchterm: req.session.search,
        user: req.user
    })
})
my res.render should execute after the if condition has completely executed. How can i do this? asyn difficult to handle :(
Manish Giri
@Manish-Giri
Jan 23 2017 03:47
@krittiyaclark you can write if/else or switch/case, both works!
Brittni Willett
@Willow606
Jan 23 2017 03:47
@Manish-Giri because I'm not
str[i] works for strings too
Krittiya Clark
@krittiyaclark
Jan 23 2017 03:48
@Manish-Giri Thanks! It is not an easy one.
CamperBot
@camperbot
Jan 23 2017 03:48
krittiyaclark sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3917 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jan 23 2017 03:49
@Willow606 I know it does, lemme look.
Brittni Willett
@Willow606
Jan 23 2017 03:51
I know it's the if statement on line 7 that's messed up I've debugged it that far. :P
Manish Giri
@Manish-Giri
Jan 23 2017 03:53
if that's buggy, and you know it for sure, you can replace that with something like
if(str[i] === str[i].toUpperCase())
meanwhile, I don't quite like changing the string itself while iterating through it, but hold on..still debugging.
Brittni Willett
@Willow606
Jan 23 2017 03:54
perfect! I wasn't sure how else to go about checking for a capital letter
Manish Giri
@Manish-Giri
Jan 23 2017 03:55
@Willow606 here, take a look - https://jsbin.com/fasotud/edit?js,console
I don't think it's even going in the two if your if checks, because I don't see any console logs, the only ones are after the ifs.
scratch that
jsbin is acting up
Brittni Willett
@Willow606
Jan 23 2017 03:57
well it doesn't qualify for the first one but it should for the second one
ooh yeah changing the if statement the way you suggested worked!
Manish Giri
@Manish-Giri
Jan 23 2017 03:58
"This-Is-Spinal-Tap"
"this-is-spinal-tap"
this seems to work
Brittni Willett
@Willow606
Jan 23 2017 03:58
yeah mine's being iffy

function spinalCase(str) {
for(i = 0; i < str.length; i++){
if(str[i] === " "){
str = str.replace(str[i], "-");
}
if(str[i] === str[i].toUpperCase()){
str = str.replace(str[i], "-");
}
}
str = str.toLowerCase();
return str;
}

spinalCase("thisIsSpinalTap");

Robert Bates
@robsimple
Jan 23 2017 03:59
am I even close?
Manish Giri
@Manish-Giri
Jan 23 2017 03:59
@Willow606 "this-s-pinal-ap"
looks like some letters are getting messed up
Brittni Willett
@Willow606
Jan 23 2017 04:00
yeah
it's replacing the capital with the - I need the dash before the capital
Robert Bates
@robsimple
Jan 23 2017 04:00

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

celsius = 9/5 + 32;

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

// Change the inputs below to test your code

convertToF(30);

Manish Giri
@Manish-Giri
Jan 23 2017 04:01
@Willow606
if(str[i] === str[i].toUpperCase()){
  console.log(str[i]);
str = str.replace(str[i], "-");
}
replacing the capital with a - is the problem
Brittni Willett
@Willow606
Jan 23 2017 04:02
yeah don't know how to get it before the capital like a push I guess
Manish Giri
@Manish-Giri
Jan 23 2017 04:02
@robsimple you're converting the celsius to fahrenheit, right?
Robert Bates
@robsimple
Jan 23 2017 04:02
@Manish-Giri yes
Brittni Willett
@Willow606
Jan 23 2017 04:02
@robsimple the mathematical formula is right but what are you putting through that formula? ;)
Manish Giri
@Manish-Giri
Jan 23 2017 04:02
@robsimple so then why this? celsius = 9/5 + 32;
Brittni Willett
@Willow606
Jan 23 2017 04:03
@Manish-Giri don't know how to get it before the capital like a push I guess
Robert Bates
@robsimple
Jan 23 2017 04:03
@Manish-Giri idk I guess I am confused by the instruction..
i thought i was defining the formula before i could resolve the return
Manish Giri
@Manish-Giri
Jan 23 2017 04:04
@Willow606 try this
if(str[i] === str[i].toUpperCase()){
 console.log(str[i]);
 let toReplace = "-" + str[i].toLowerCase();
str = str.replace(str[i], toReplace);
}
@robsimple so, the thing that you want to convert is the celsius variable, and since you're converting C to F, you want to store the result of the conversion here -
var fahrenheit;
Brittni Willett
@Willow606
Jan 23 2017 04:05
ooh good call ty @Manish-Giri
CamperBot
@camperbot
Jan 23 2017 04:05
willow606 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3918 | @manish-giri |http://www.freecodecamp.com/manish-giri
Robert Bates
@robsimple
Jan 23 2017 04:06
so instead of celsius = 9/5 + 32; it should be fahrenheit = 9-5 +32; ???
Manish Giri
@Manish-Giri
Jan 23 2017 04:07
@Willow606 worked?
@robsimple what is the formula you looked up?
Brittni Willett
@Willow606
Jan 23 2017 04:08
@Manish-Giri makes an infinite loop with the rest of the code. -.-

function spinalCase(str) {
for(i = 0; i < length; i++){
if(str[i] === " "){
str = str.replace(str[i], "-");
}
if(str[i] === str[i].toUpperCase()){
var toReplace = "-" + str[i];
str = str.replace(str[i], toReplace);
}
}
str = str.toLowerCase();
return str;
}

spinalCase("thisIsSpinalTap");

Robert Bates
@robsimple
Jan 23 2017 04:08
@Manish-Giri i just changed it to and it returned the first line in the challenge correctly.. so I am in the right direction,
fahrenheit = 9/5 + 32;
Manish Giri
@Manish-Giri
Jan 23 2017 04:08
@Willow606 um, that's new, either way, make the i variable local in your for loop
let me see
@robsimple yes, kind of, but you're still missing the thing you're actually converting
Brittni Willett
@Willow606
Jan 23 2017 04:10
oops length should be str.length
Manish Giri
@Manish-Giri
Jan 23 2017 04:10
Robert Bates
@robsimple
Jan 23 2017 04:10
the return should be -
convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86
Manish Giri
@Manish-Giri
Jan 23 2017 04:11
@robsimple fahrenheit = 9/5 + 32; - the right side of this expression needs to have the celsius variable, else fahrenheit will always have the same value, no matter what value celsius is.
Robert Bates
@robsimple
Jan 23 2017 04:12
OHHH!! ok
righ tot left
Manish Giri
@Manish-Giri
Jan 23 2017 04:12
yes
Brittni Willett
@Willow606
Jan 23 2017 04:12
yeah it's making an infinite loop
Manish Giri
@Manish-Giri
Jan 23 2017 04:13
aren't you missing an if condition for checking for _ values?
Robert Bates
@robsimple
Jan 23 2017 04:13
smh - It just didn't click and now it does..
TY @Manish-Giri
CamperBot
@camperbot
Jan 23 2017 04:13
robsimple sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3919 | @manish-giri |http://www.freecodecamp.com/manish-giri
Robert Bates
@robsimple
Jan 23 2017 04:13
ty @Willow606
CamperBot
@camperbot
Jan 23 2017 04:13
robsimple sends brownie points to @willow606 :sparkles: :thumbsup: :sparkles:
:cookie: 287 | @willow606 |http://www.freecodecamp.com/willow606
Brittni Willett
@Willow606
Jan 23 2017 04:16
don't think so
Brendon Bradley
@brenbrad
Jan 23 2017 04:20

// Setup
function abTest(a, b) {
  // Only change code below this line
   console.log (a,b < 0);
  return "undefined";




  // Only change code above this line

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

// Change values below to test your code
abTest(-2,2);
need some help with this one please
Ezra
@EzraPlato
Jan 23 2017 04:22
Call the processArg function with an argument of 7 and assign its return value to the variable processed. var processed = 0;
function processArg(num) {
return (num + 7) / 7;} I really have no idea what is being asked of me** Any ideas?
Brendon Bradley
@brenbrad
Jan 23 2017 04:24
looks pretty quiet in here
Ezra
@EzraPlato
Jan 23 2017 04:24
yeah. I'm not where you are yet ... so not sure I can help you
Brendon Bradley
@brenbrad
Jan 23 2017 04:25
challenge 200
Ezra
@EzraPlato
Jan 23 2017 04:25
yeah. not there yet
Brendon Bradley
@brenbrad
Jan 23 2017 04:26
what the name of your challenge?
or number rather
lol
Ezra
@EzraPlato
Jan 23 2017 04:26
171
I just really just don't understand the way they are asking the question
Brendon Bradley
@brenbrad
Jan 23 2017 04:27
what the name of it?
Ezra
@EzraPlato
Jan 23 2017 04:27
assignment with a return value
Moisés Man
@moigithub
Jan 23 2017 04:28
challenges do NOT have numbers.. that number represent how many brownie poitns u have
https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Brownie-Points
Nhu Nguyen
@nhu313
Jan 23 2017 04:28
that's really confusing. I don't get what it's asking either
Alen Hu
@Alen-h
Jan 23 2017 04:28
Hello guys, anyone can tell me what this means?
var regex = /[aeiou]/gi;
Brittni Willett
@Willow606
Jan 23 2017 04:29
@Manish-Giri haven't got that far yet, still trying to get this piece to work
Alen Hu
@Alen-h
Jan 23 2017 04:29
I know /gi, but I dont know what is "/[aeiou]"
Manish Giri
@Manish-Giri
Jan 23 2017 04:29
@Willow606 just got back, lemme see
Moisés Man
@moigithub
Jan 23 2017 04:29
Brittni Willett
@Willow606
Jan 23 2017 04:29

function spinalCase(str) {
for(i = 0; i < str.length; i++){
if(str[i] === " "){
str = str.replace(str[i], "-");
}
if(str[i] === str[i].toUpperCase()){
str = str.split("");
str.splice(str[i],0,"-");
str.join("");
}
}
str = str.toLowerCase();
return str;
}

spinalCase("thisIsSpinalTap");

Manish Giri
@Manish-Giri
Jan 23 2017 04:29
@Alen-h it's a character class, it means match any one from within the [ ]
Brittni Willett
@Willow606
Jan 23 2017 04:29
says split is not a function
Alen Hu
@Alen-h
Jan 23 2017 04:30
Cheers guys~
Brittni Willett
@Willow606
Jan 23 2017 04:31

@Manish-Giri switched it back to: function spinalCase(str) {
for(i = 0; i < str.length; i++){
if(str[i] === " "){
str = str.replace(str[i], "-");
}
if(str[i] === str[i].toUpperCase()){
str = str.replace(str[i], " -");
}
}
str = str.toLowerCase();
return str;
}

spinalCase("thisIsSpinalTap");

Edgar Pan
@edgaryp
Jan 23 2017 04:32
Does anybody know how do I empty HTML element #output in JS every time the buttons click? Tried html("") and .empty(), but did not work.
http://codepen.io/edgaryp/pen/qRapvW?editors=1010
CyuSunill
@CyuSunill
Jan 23 2017 04:34
initialize th three variables a b and c with 5 10 and "i am a"
alican karalar
@alicankaralar
Jan 23 2017 04:34
function chunkArrayInGroups(arr, size) {


}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
uhh don't know how to do this at all! some direction would be nice guys, anybody ?
Manish Giri
@Manish-Giri
Jan 23 2017 04:35
@Willow606 okay, I'm trying something different, hold on
Brittni Willett
@Willow606
Jan 23 2017 04:35
@Manish-Giri okie doke
@alicankaralar break it down into small steps, what is it you want the code to do first?
Edgar Pan
@edgaryp
Jan 23 2017 04:36
@alicankaralar while loop will do.
alican karalar
@alicankaralar
Jan 23 2017 04:36
well i want i don't know in that regard, i tried breaking it down :(
CRFerrell77
@CRFerrell77
Jan 23 2017 04:36
hey everyone, how's code treating ya?
alican karalar
@alicankaralar
Jan 23 2017 04:37
the problem is, regarding the arr.length and size, there can be any number of new arrays
Brittni Willett
@Willow606
Jan 23 2017 04:37
@alicankaralar yeah a loop is a good starting place
Nhu Nguyen
@nhu313
Jan 23 2017 04:37
@edgaryp you tried $.output.html(""); and it didn't work?
alican karalar
@alicankaralar
Jan 23 2017 04:37
@Willow606 @edgaryp thanks guys
CamperBot
@camperbot
Jan 23 2017 04:37
alicankaralar sends brownie points to @willow606 and @edgaryp :sparkles: :thumbsup: :sparkles:
:cookie: 266 | @edgaryp |http://www.freecodecamp.com/edgaryp
:cookie: 288 | @willow606 |http://www.freecodecamp.com/willow606
grantknaver
@grantknaver
Jan 23 2017 04:38
I have to use recurs for this assignment dont I?
https://www.freecodecamp.com/challenges/exact-change#?solution=%0Afunction%20checkCashRegister(price%2C%20cash%2C%20cid)%20%7B%0A%20%20%2F%2F%20Here%20is%20your%20change%2C%20ma'am.%0A%20%20var%20answer%20%3D%20%5B%5D%3B%0A%20%20var%20sorted%20%3D%20%5B%5D%3B%0A%20%20for(var%20i%20%3D%200%3B%20i%20%3C%20cid.length%3B%20i%2B%2B)%7B%0A%20%20%20%20answer.push(cid%5Bi%5D%5B1%5D)%3B%0A%20%20if(cid%5Bi%5D%5B1%5D%20%3E%20cid%5Bi%2B1%5D%5B1%5D)%7B%0A%20%20%20%20sorted.push(cid%5Bi%5D%5B1%5D)%0A%20%20%7D%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%7D%0A%20%20var%20cashInDrawer%20%3D%20answer.reduce(function(a%2Cb)%7B%0A%20%20%20%20return%20a%20%2B%20b%3B%20%20%0A%20%20%7D)%3B%0A%20%20var%20changeDo%20%3D%20cash%20-%20price%3B%0A%20%20var%20sortedChange%20%3D%20answer.sort(function(a%2Cb)%7B%0A%20%20%20%20return%20b-a%3B%20%20%0A%20%20%7D)%3B%0A%20%0A%0A%20%20%0A%7D%0A%0A%2F%2F%20Example%20cash-in-drawer%20array%3A%0A%2F%2F%20%5B%5B%22PENNY%22%2C%201.01%5D%2C%0A%2F%2F%20%5B%22NICKEL%22%2C%202.05%5D%2C%0A%2F%2F%20%5B%22DIME%22%2C%203.10%5D%2C%0A%2F%2F%20%5B%22QUARTER%22%2C%204.25%5D%2C%0A%2F%2F%20%5B%22ONE%22%2C%2090.00%5D%2C%0A%2F%2F%20%5B%22FIVE%22%2C%2055.00%5D%2C%0A%2F%2F%20%5B%22TEN%22%2C%2020.00%5D%2C%0A%2F%2F%20%5B%22TWENTY%22%2C%2060.00%5D%2C%0A%2F%2F%20%5B%22ONE%20HUNDRED%22%2C%20100.00%5D%5D%0A%0AcheckCashRegister(19.50%2C%2020.00%2C%20%5B%5B%22PENNY%22%2C%200.01%5D%2C%20%5B%22NICKEL%22%2C%200%5D%2C%20%5B%22DIME%22%2C%200%5D%2C%20%5B%22QUARTER%22%2C%200%5D%2C%20%5B%22ONE%22%2C%201.00%5D%2C%20%5B%22FIVE%22%2C%200%5D%2C%20%5B%22TEN%22%2C%200%5D%2C%20%5B%22TWENTY%22%2C%200%5D%2C%20%5B%22ONE%20HUNDRED%22%2C%200%5D%5D)%3B%0A
Edgar Pan
@edgaryp
Jan 23 2017 04:38
@alicankaralar don't worry about the code, try to think as programer. What's the first step you need to do to close to the result you want?
CRFerrell77
@CRFerrell77
Jan 23 2017 04:39
Can anyone help me with "Stand in Line"?
Edgar Pan
@edgaryp
Jan 23 2017 04:39
@nhu313 yeah I did. I must have done something with my code so html("") is not response.
Jor
@joreyesl
Jan 23 2017 04:39
@alicankaralar well basically you will want to loop through the array, then for every (in this case) 2 elements, you put them into their own subarray.
Edgar Pan
@edgaryp
Jan 23 2017 04:40
@CRFerrell77 What's your question with the task?
CRFerrell77
@CRFerrell77
Jan 23 2017 04:40
write a function, nextInLine which takes an array and a number as arguments, then I have to add a number to the end, and remove one from the front
Brittni Willett
@Willow606
Jan 23 2017 04:41
ooh umm
CRFerrell77
@CRFerrell77
Jan 23 2017 04:42
so i'm thinking push one to the back, and shift one from the front... but I'm not sure how
Brittni Willett
@Willow606
Jan 23 2017 04:42
array.shift(); for removing the first element
Jor
@joreyesl
Jan 23 2017 04:42
@CRFerrell77 yea thats what you want to do, use .push and .shift methods
Brittni Willett
@Willow606
Jan 23 2017 04:42
and yeah push should work too
Edgar Pan
@edgaryp
Jan 23 2017 04:42
@CRFerrell77 the concept is right
alican karalar
@alicankaralar
Jan 23 2017 04:42
thats what i thought initially @edgaryp @joreyesl @Willow606 the problem is i can't proceed after the loop
for example, i want a counter to iterate through array elements, put first 2 elements into a subarray, then go for the next 2, and so on..
CRFerrell77
@CRFerrell77
Jan 23 2017 04:42
...but how is the question... im not sure on formatting
alican karalar
@alicankaralar
Jan 23 2017 04:43
for each 2 elements i need a new array, so defining a variable and pushing the elements inside won't work
Brittni Willett
@Willow606
Jan 23 2017 04:43
I think I made a bunch of arrays for that one @alicankaralar
Edgar Pan
@edgaryp
Jan 23 2017 04:44
@CRFerrell77 let's code. try to push the item into the array. syntax should be like thisIsArray.push(item)
Jor
@joreyesl
Jan 23 2017 04:44
@alicankaralar you can have a counter, then use an if statement to check when you reach 2, then push the current and create a new subarray,
alican karalar
@alicankaralar
Jan 23 2017 04:44
yep but i don't know how to create a sub array i guess? i have no ide
a
CRFerrell77
@CRFerrell77
Jan 23 2017 04:45
Edgar, should I use the testArr var in the programming
Edgar Pan
@edgaryp
Jan 23 2017 04:45
@CRFerrell77 no you don't need subarray
Brittni Willett
@Willow606
Jan 23 2017 04:45
@alicankaralar I made a bunch of new variables at the beginning and made them arrays: var a = [];
Jor
@joreyesl
Jan 23 2017 04:45
@alicankaralar you can just declare it like so var subArr = []
CRFerrell77
@CRFerrell77
Jan 23 2017 04:45
so i am making a new var?
Edgar Pan
@edgaryp
Jan 23 2017 04:46
@CRFerrell77 no
Brendon Bradley
@brenbrad
Jan 23 2017 04:46

```// Setup
function abTest(a, b) {
// Only change code below this line

// Only change code above this line

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

// Change values below to test your code
abTest(-2,2);
```

// Setup
function abTest(a, b) {
  // Only change code below this line





  // Only change code above this line

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

// Change values below to test your code
abTest(-2,2);
Edgar Pan
@edgaryp
Jan 23 2017 04:46
@CRFerrell77 only need to think how to ,push() and .shift().
alican karalar
@alicankaralar
Jan 23 2017 04:47
okay i guess i have to get some rest and turn back when my brain functions again
CRFerrell77
@CRFerrell77
Jan 23 2017 04:47
right, but i have to push an shift ontot the existing array, right?
Brendon Bradley
@brenbrad
Jan 23 2017 04:47
lol that happens to me often @alicankaralar
Brittni Willett
@Willow606
Jan 23 2017 04:47
@Manish-Giri https://www.freecodecamp.com/challenges/spinal-tap-case it's the second one I'm trying to get to validate. :P

function spinalCase(str) {
for(i = 0; i < str.length; i++){
if(str[i] === " "){
str = str.replace(str[i], "-");
}
if(str[i] === str[i].toUpperCase()){
str[i].toLowerCase();
str = str.replace(str[i], " -");
}
if(str[i] === "_"){
str = str.replace(str[i], "-");
}
}
str = str.toLowerCase();
return str;
}

spinalCase("thisIsSpinalTap");

is my code now

Edgar Pan
@edgaryp
Jan 23 2017 04:48
@CRFerrell77 correct. which it will be the argument of the function: arr.
Manish Giri
@Manish-Giri
Jan 23 2017 04:48
seems to be working for most of the test cases
CRFerrell77
@CRFerrell77
Jan 23 2017 04:48
so i would be using testArr.push(item);
..being that testArr is the variable for the problem
Manish Giri
@Manish-Giri
Jan 23 2017 04:49
@CRFerrell77 you should be using arr, not testArr
CRFerrell77
@CRFerrell77
Jan 23 2017 04:49
so just arr.push(item);
Manish Giri
@Manish-Giri
Jan 23 2017 04:49
yeah
CRFerrell77
@CRFerrell77
Jan 23 2017 04:50
ok that seems to have pushed the right number onto the back of the array
Edgar Pan
@edgaryp
Jan 23 2017 04:50
@CRFerrell77 yay correct. arr.push(item);
thierrybgentile
@thierrybgentile
Jan 23 2017 04:50
`for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < arr[i].length; i++) {
product *= arr[i][j];
}
}
CRFerrell77
@CRFerrell77
Jan 23 2017 04:50
and i am adding in an arr.shift(item);
Manish Giri
@Manish-Giri
Jan 23 2017 04:51
@thierrybgentile for (var j = 0; j < arr[i].length; i++)
this should be j++ not i++
thierrybgentile
@thierrybgentile
Jan 23 2017 04:51
oups
for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; i++) {
      product *= arr[i][j];
    }
  }
Edgar Pan
@edgaryp
Jan 23 2017 04:51
@CRFerrell77 right. did you see the big green tick?
CRFerrell77
@CRFerrell77
Jan 23 2017 04:52
i have two out of four ticks now
thierrybgentile
@thierrybgentile
Jan 23 2017 04:52
@Manish-Giri Aah thanks!
CamperBot
@camperbot
Jan 23 2017 04:52
thierrybgentile sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3920 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jan 23 2017 04:52
@Willow606 ah there's still one bug
Edgar Pan
@edgaryp
Jan 23 2017 04:52
@CRFerrell77 that's progress. can you please paste the code?
Manish Giri
@Manish-Giri
Jan 23 2017 04:53
@thierrybgentile welcome
CRFerrell77
@CRFerrell77
Jan 23 2017 04:54

function nextInLine(arr, item) {
arr.push(item);
arr.shift(item);// Your code here

return item; // Change this line
}

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

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

function nextInLine(arr, item) {
arr.push(item);
arr.shift(item);// Your code here

return item; // Change this line
}

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

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

sorry for the double post
grantknaver
@grantknaver
Jan 23 2017 04:54
can anyone answer a quick question about the sort method?
Manish Giri
@Manish-Giri
Jan 23 2017 04:55
@Willow606 just tested, here's the final working soln - https://jsbin.com/muxorof/edit?js,console
@grantknaver shoot
Ezra
@EzraPlato
Jan 23 2017 04:55
What do I have wrong here* var processed = 7;
function processArg(num) {
return (num + 4);
}
processed = process(3);
Edgar Pan
@edgaryp
Jan 23 2017 04:55
@CRFerrell77 in you function, you are returning item. you want to return your result of arr.shift().
John Freeborn
@jfx1026
Jan 23 2017 04:55
hello all, I'm working on 'Convert HTML Entries' project and for some reason my regEx isn't splitting the one story the way I expect - here's my regEx - convertHTML("<>") - this one is losing the lesser than
//find regex and then split string into array at that point
  var findThis = /([&,<>"'])+/g;
  var newStr = str.split(findThis);
  console.log(newStr);
Manish Giri
@Manish-Giri
Jan 23 2017 04:55
@CRFerrell77 .shift() doesn't take any arguments
John Freeborn
@jfx1026
Jan 23 2017 04:56
this is the result of the slpit - ["", ">", ""]
Edgar Pan
@edgaryp
Jan 23 2017 04:56
@CRFerrell77 also .shift() doesn't take in arguments, so leave it as blank.
grantknaver
@grantknaver
Jan 23 2017 04:56
@Manish-Giri Ok right now I am dealing with this array
CRFerrell77
@CRFerrell77
Jan 23 2017 04:56
i just changed return item; to return arr.shift(); and i lost my two green checks
grantknaver
@grantknaver
Jan 23 2017 04:56
[["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1.00], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]
I want to use sort to sort them according to largest to smallest
, but I want to return the string along with the number
basically
Edgar Pan
@edgaryp
Jan 23 2017 04:58
@CRFerrell77 function should be like below
function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  return arr.shift();
}
Manish Giri
@Manish-Giri
Jan 23 2017 04:58
@grantknaver and on what would it sort from largest to smallest?
Brendon Bradley
@brenbrad
Jan 23 2017 04:59
// Setup
function abTest(a, b) {
  // Only change code below this line



  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
grantknaver
@grantknaver
Jan 23 2017 04:59
["ONE", 1.00], ["PENNY", 0.01], ["TEN", 0] and soo on
Brittni Willett
@Willow606
Jan 23 2017 04:59
@Manish-Giri yeah after converting my code to your ideas I'm still hitting an infinite loop
Brendon Bradley
@brenbrad
Jan 23 2017 04:59
I've tried all i can on this piece.. I really cant figure it out
CRFerrell77
@CRFerrell77
Jan 23 2017 04:59
oh that is rediculous. thank you for the help Edgar. I don't know why they would even put the return on a separate line
grantknaver
@grantknaver
Jan 23 2017 04:59
the second part of every array
Brendon Bradley
@brenbrad
Jan 23 2017 04:59
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
grantknaver
@grantknaver
Jan 23 2017 04:59
basically the 1.00, 0.01, and 0
right now I can sort them easily enough but I loose the strings in all the arrays
basically I just return all the numbers sorted from highest to lowest
Edgar Pan
@edgaryp
Jan 23 2017 05:00
@CRFerrell77 you are welcome :)
CRFerrell77
@CRFerrell77
Jan 23 2017 05:01
and on that note I think I have had enough Java for one night
Happy coding everyone
Brittni Willett
@Willow606
Jan 23 2017 05:01
this is JavaScript
Manish Giri
@Manish-Giri
Jan 23 2017 05:01
@Willow606 check your PM.
Brittni Willett
@Willow606
Jan 23 2017 05:01
Java is different. ;)
Ezra
@EzraPlato
Jan 23 2017 05:01
Why are they telling me process is not defined* var processed = 2;
function processArg(num) {
return (num + 7) / 7;
}
processed = process(7);
Manish Giri
@Manish-Giri
Jan 23 2017 05:01
@EzraPlato what is it called? function processArg(num)?
Ezra
@EzraPlato
Jan 23 2017 05:02
@Manish-Giri I'm not sure I understand your question "it?"
Edgar Pan
@edgaryp
Jan 23 2017 05:02
and I am still waiting for answers for my question lol :(
Manish Giri
@Manish-Giri
Jan 23 2017 05:03
@EzraPlato "it" refers to the name of the function, it's processArg
and you have process instead.
Ezra
@EzraPlato
Jan 23 2017 05:03
@Manish-Giri yes
Manish Giri
@Manish-Giri
Jan 23 2017 05:03
which is why you get the not defined error.
Ezra
@EzraPlato
Jan 23 2017 05:03
O!!!!!!!! @Manish-Giri thank you
CamperBot
@camperbot
Jan 23 2017 05:03
ezraplato sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3921 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jan 23 2017 05:04
@edgaryp what was your q again?
@EzraPlato welcome
Edgar Pan
@edgaryp
Jan 23 2017 05:04

@Manish-Giri

Does anybody know how do I empty HTML element #output in JS every time the buttons click? Tried html("") and .empty(), but did not work.
http://codepen.io/edgaryp/pen/qRapvW?editors=1010

Brendon Bradley
@brenbrad
Jan 23 2017 05:04
i had a question too @Manish-Giri please let me know when you are done with the current one
Phillip Troutman
@troutman21
Jan 23 2017 05:05

Hi everyone. I am working on the Card Counting challenge and i was wondering if someone can just confirm that im working in the right direction lol. I know i still have some work to do with the whole returning "bet" or "hold" but is this first part looking correct? var count = 0;

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

}

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

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

Manish Giri
@Manish-Giri
Jan 23 2017 05:05
@brenbrad okay, lol, yours is easier, you just need an if statement that checks if a or b is less than 0, and if it is, return undefined
MarkBales96
@MarkBales96
Jan 23 2017 05:05
Hello, I am working on Make Unique Objects by Passing Parameters to our Constructor, and I have 3 out of the 4 check points using the following code

var Car = function() {
//Change this constructor
this.wheels = 6;
this.seats = 3;
this.engines = 1;
};

//Try it out here
var Car = function(wheels, seats, engines) {
this.wheels = wheels;
this.seats = seats;
this.engines = engines;

};

Brendon Bradley
@brenbrad
Jan 23 2017 05:06
ok that was what i was wondering if i had to use the if statement.. i tried before but must have been wrong
MarkBales96
@MarkBales96
Jan 23 2017 05:06
I can't seem to figure out what I'm doing wrong, because I believe I assigned the values correctly.
Edgar Pan
@edgaryp
Jan 23 2017 05:07
@MarkBales96 try to use argument instead of actual numbers.
Manish Giri
@Manish-Giri
Jan 23 2017 05:07
@edgaryp where are you clearing the element? can't see..
@brenbrad show what you tried then, and tag when responding..
@MarkBales96 show the part where you're creating the object.
Brendon Bradley
@brenbrad
Jan 23 2017 05:08
```// Setup
function abTest(a, b) {
// Only change code below this line
if (a, b <= 0);
return "undefined";
````
MarkBales96
@MarkBales96
Jan 23 2017 05:08
var Car = function(wheels, seats, engines) {
this.wheels = wheels;
this.seats = seats;
this.engines = engines;
Brendon Bradley
@brenbrad
Jan 23 2017 05:08
// Setup function abTest(a, b) { // Only change code below this line if (a, b <= 0); return "undefined";
Manish Giri
@Manish-Giri
Jan 23 2017 05:08
@brenbrad you need to use the || operator to check for two things, , is invalid syntax.
MarkBales96
@MarkBales96
Jan 23 2017 05:08
That's the code I'm using to create the project
Edgar Pan
@edgaryp
Jan 23 2017 05:08
@MarkBales96 yes
Manish Giri
@Manish-Giri
Jan 23 2017 05:08
also, less than zero, not less than equal to zero
Edgar Pan
@edgaryp
Jan 23 2017 05:09
@MarkBales96 what's the message after you coded in?
Manish Giri
@Manish-Giri
Jan 23 2017 05:09
@MarkBales96 you're not using the new operator?
Edgar Pan
@edgaryp
Jan 23 2017 05:09
@Manish-Giri <ul id="output" class="list-group">
Manish Giri
@Manish-Giri
Jan 23 2017 05:10

@MarkBales96

then call your new constructor with three number arguments and assign it to myCar to see it in action.

MarkBales96
@MarkBales96
Jan 23 2017 05:10
@edgaryp can you cleariify? and @Manish-Giri it doesn't display a message after I test the code
Manish Giri
@Manish-Giri
Jan 23 2017 05:10
@MarkBales96 as it says, you need to call the constructor with three arguments, where's the code for that?
MarkBales96
@MarkBales96
Jan 23 2017 05:11
I seem to be terribly confused on this one.
Manish Giri
@Manish-Giri
Jan 23 2017 05:11
@edgaryp have you used .html("") anywhere?
Edgar Pan
@edgaryp
Jan 23 2017 05:11
@MarkBales96 can you please show your code below //Try it out here
Manish Giri
@Manish-Giri
Jan 23 2017 05:11

@MarkBales96 okay well, this is just the constructor

var Car = function(wheels, seats, engines) {
this.wheels = wheels;
this.seats = seats;
this.engines = engines;
};

you still need to use Car to create objects from this.

Edgar Pan
@edgaryp
Jan 23 2017 05:11
@Manish-Giri I have but it did not work so I deleted
MarkBales96
@MarkBales96
Jan 23 2017 05:12
That's the code that I stated earlier. Do I have it in the wrong spot?
Manish Giri
@Manish-Giri
Jan 23 2017 05:12
@edgaryp well I can't do much unless I see it, can I
Brendon Bradley
@brenbrad
Jan 23 2017 05:12
well I think that's all for me im terrible stumped on this one lol
Jor
@joreyesl
Jan 23 2017 05:12
@grantknaver you can pass a sort function as a parameter to define how you want it to sort.
var arr = [["PENNY", 0.01], ["NICKEL", 0], ["ONE", 1.00]];

arr.sort((x,y) => x[1] < y[1]);
Edgar Pan
@edgaryp
Jan 23 2017 05:12
@Manish-Giri sure I can put it in, wait for it.
Manish Giri
@Manish-Giri
Jan 23 2017 05:12
@brenbrad
if(firstName == "Brendan" || lastName == "Bradley") {
....
}
here's the syntax
CoryCMyers
@CoryCMyers
Jan 23 2017 05:13
So I am reading through all the different string methods to get my head a bit around it hopefully, and I am wondering when you would use str.anchor()?
Edgar Pan
@edgaryp
Jan 23 2017 05:13
CoryCMyers
@CoryCMyers
Jan 23 2017 05:14
Would it not be simpler to just make an anchor element in the HTML?
Brendon Bradley
@brenbrad
Jan 23 2017 05:14
ok Ill give it a shot
Manish Giri
@Manish-Giri
Jan 23 2017 05:14
@edgaryp your pen works for me
when I click "online", only 1 channel is displayed
Edgar Pan
@edgaryp
Jan 23 2017 05:15
@MarkBales96 in order to use this, the new keyword needs to be used in the last line. var myCar = new ......
@Manish-Giri I used same api data for All and Online at the moment. So if you click All you will see all members, but when you click Online, it will only show the 1st result.
Brendon Bradley
@brenbrad
Jan 23 2017 05:19
@Manish-Giri like this ?
if (a < 0 || b < 0);
Manish Giri
@Manish-Giri
Jan 23 2017 05:19
@edgaryp I thought your question was .html("") isn't clearing stuff?
@brenbrad yes, now inside the if code block, you need to return undefined
MarkBales96
@MarkBales96
Jan 23 2017 05:23
Okay, I see what you guys mean now! It just took me a minute. Thank you both @Manish-Giri and @edgaryp
CamperBot
@camperbot
Jan 23 2017 05:23
markbales96 sends brownie points to @manish-giri and @edgaryp :sparkles: :thumbsup: :sparkles:
:cookie: 267 | @edgaryp |http://www.freecodecamp.com/edgaryp
:star2: 3922 | @manish-giri |http://www.freecodecamp.com/manish-giri
Brendon Bradley
@brenbrad
Jan 23 2017 05:23
 if (a < 0  ||  b  < 0);
    return undefined;
am i missing brackets or something
@Manish-Giri
Jor
@joreyesl
Jan 23 2017 05:24
@brenbrad remove the ; after if (a < 0 || b < 0);
Brendon Bradley
@brenbrad
Jan 23 2017 05:24
thanks @joreyesl @Manish-Giri
CamperBot
@camperbot
Jan 23 2017 05:24
brenbrad sends brownie points to @joreyesl and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 361 | @joreyesl |http://www.freecodecamp.com/joreyesl
:star2: 3923 | @manish-giri |http://www.freecodecamp.com/manish-giri
NIKHIL
@nikzayn
Jan 23 2017 05:24
hey can u guys just tell me that what are two numbers that just give the product of 5??
Edgar Pan
@edgaryp
Jan 23 2017 05:25
@MarkBales96 you are welcome. this is the best article I have found in regard to how to use this.
http://javascriptissexy.com/understand-javascripts-this-with-clarity-and-master-it/
NIKHIL
@nikzayn
Jan 23 2017 05:31
alt
Ken Haduch
@khaduch
Jan 23 2017 05:31
@nikzayn - wouldn't that be 1 and 5 ?
NIKHIL
@nikzayn
Jan 23 2017 05:32
seriously kill me right now
i thought to be like to be do square root of that
Ken Haduch
@khaduch
Jan 23 2017 05:32
@nikzayn - are you trying to do the least common multiple problem?
NIKHIL
@nikzayn
Jan 23 2017 05:33
no no i was just like you know shit happens sometime
by the way thanks sir...
Ken Haduch
@khaduch
Jan 23 2017 05:34
okay - you're welcome...
NIKHIL
@nikzayn
Jan 23 2017 05:37
:smile:
grantknaver
@grantknaver
Jan 23 2017 05:47
@joreyesl thanks for the help. Quick question what is the => notation called?
CamperBot
@camperbot
Jan 23 2017 05:47
grantknaver sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 362 | @joreyesl |http://www.freecodecamp.com/joreyesl
azariahk7
@azariahk7
Jan 23 2017 05:47

//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
while(contacts.firstName == firstName)
{
}
// Only change code above this line
}
// Change these values to test your function
lookUpProfile("Akira", "likes");

how to solve this??
Long Vu
@longorjames
Jan 23 2017 05:49
for this project: Counting Cards
how does one go about putting sequence in code?
function cc(card) {
// Only change code below this line
switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
count = "5 Bet";
break;
case 7:
case 8:
case 9:
count = "0 Hold";
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count = "-5 Hold";
break;
}
return count;
this is my code but it just does each case once and then returns the value
Manish Giri
@Manish-Giri
Jan 23 2017 05:50
@longorjames inside the switch, you should only increment/decrement count
once outside, you should use an if/else to return count and the string accordingly.
Long Vu
@longorjames
Jan 23 2017 05:52
switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
count = count+1;
break;
case 7:
case 8:
case 9:
count = count+0;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count = count-1;
break;
}
if (count >=1){
return "count Bet";
}
else (count <=0){
return "count Hold"
}
else if (count <=0){
return "count Hold";
}
Jor
@joreyesl
Jan 23 2017 05:54
@grantknaver arrow function
azariahk7
@azariahk7
Jan 23 2017 05:57

//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
while(contacts.firstName == firstName)
{
}
// Only change code above this line
}
// Change these values to test your function
lookUpProfile("Akira", "likes");

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

Joshua Reed
@Flintar
Jan 23 2017 05:58
Having problems with the Convert Celsius to Fahrenheit program. Do I need to run a loop to get all the answers?
Manish Giri
@Manish-Giri
Jan 23 2017 05:58
@Flintar why would you need a loop?
you just need to convert the celsius variable, not each of the numbers from the test cases.
abhinavbhanyara
@abhinavbhanyara
Jan 23 2017 05:58
can someone tell me how 3rd testcase is false in link above
Ogundele Olumide
@Lumexralph
Jan 23 2017 05:58
@Flintar mo need of loop, just the formula operation
Joshua Reed
@Flintar
Jan 23 2017 05:59
ok
ty
Ogundele Olumide
@Lumexralph
Jan 23 2017 06:00
@longorjames return count + string
Joshua Reed
@Flintar
Jan 23 2017 06:01
fahrenheit = (9/5)+32; that should be right?
Ogundele Olumide
@Lumexralph
Jan 23 2017 06:01
@azariahk7 you need a loop to pick each objects in the contacts array, your loop is not doing that
@Flintar don't forget celsius parameter
Joshua Reed
@Flintar
Jan 23 2017 06:01
right ty
Long Vu
@longorjames
Jan 23 2017 06:02
@Lumexralph Thank you
CamperBot
@camperbot
Jan 23 2017 06:02
longorjames sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 822 | @lumexralph |http://www.freecodecamp.com/lumexralph
azariahk7
@azariahk7
Jan 23 2017 06:02
@Lumexralph but how do i pick each object in a loop?
Jor
@joreyesl
Jan 23 2017 06:04
@azariahk7 for(var i = 0; i < contacts.length; i++)
Ogundele Olumide
@Lumexralph
Jan 23 2017 06:05
@azariahk7 have a variable Initialized to 0 and use the length of the array for your loop condition
then you pick each object by contacts[i] at every iteration
abhinavbhanyara
@abhinavbhanyara
Jan 23 2017 06:06
Check if the second argument is truthy on all elements of first argument. function([{"user": "Tinky-Winky", "sex": "male", "age": 0}, {"user": "Dipsy", "sex": "male", "age": 3}, {"user": "Laa-Laa", "sex": "female", "age": 5}, {"user": "Po", "sex": "female", "age": 4}], "age") should return false. Should'nt it is supposed to return true?
azariahk7
@azariahk7
Jan 23 2017 06:06
@joreyesl @Lumexralph and then check each object for firstname and prop?
Jor
@joreyesl
Jan 23 2017 06:06
@azariahk7 yep
Ogundele Olumide
@Lumexralph
Jan 23 2017 06:06
@azariahk7 exactly
azariahk7
@azariahk7
Jan 23 2017 06:07
Thanks :+1: @joreyesl @Lumexralph
CamperBot
@camperbot
Jan 23 2017 06:07
azariahk7 sends brownie points to @joreyesl and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 363 | @joreyesl |http://www.freecodecamp.com/joreyesl
:cookie: 823 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jan 23 2017 06:07
@abhinavbhanyara i don't understand your question
@azariahk7 :+1:
abhinavbhanyara
@abhinavbhanyara
Jan 23 2017 06:08
Problem:Check if the second argument is truthy on all elements of first argument.
test case : function([{"user": "Tinky-Winky", "sex": "male", "age": 0}, {"user": "Dipsy", "sex": "male", "age": 3}, {"user": "Laa-Laa", "sex": "female", "age": 5}, {"user": "Po", "sex": "female", "age": 4}], "age")
Ogundele Olumide
@Lumexralph
Jan 23 2017 06:09
@abhinavbhanyara what have you done?
abhinavbhanyara
@abhinavbhanyara
Jan 23 2017 06:09
What is it supposed to return(True/false)?
Jor
@joreyesl
Jan 23 2017 06:10
@abhinavbhanyara false
abhinavbhanyara
@abhinavbhanyara
Jan 23 2017 06:10
OK here is link to problem
rdollent
@rdollent
Jan 23 2017 06:11
I need help :3
abhinavbhanyara
@abhinavbhanyara
Jan 23 2017 06:11
How @joreyesl
Can you please elaborate
rdollent
@rdollent
Jan 23 2017 06:11
Make a function that looks through an array of objects (first argument) and returns an array of all objects that have matching property and value pairs (second argument). Each property and value pair of the source object has to be present in the object from the collection if it is to be included in the returned array.

For example, if the first argument is [{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], and the second argument is { last: "Capulet" }, then you must return the third object from the array (the first argument), because it contains the property and its value, that was passed on as the second argument.
oops
Ogundele Olumide
@Lumexralph
Jan 23 2017 06:11
@rdollent what help do you need?
rdollent
@rdollent
Jan 23 2017 06:12

Make a function that looks through an array of objects (first argument) and returns an array of all objects that have matching property and value pairs (second argument). Each property and value pair of the source object has to be present in the object from the collection if it is to be included in the returned array.

For example, if the first argument is [{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], and the second argument is { last: "Capulet" }, then you must return the third object from the array (the first argument), because it contains the property and its value, that was passed on as the second argument.

that challenge
Jor
@joreyesl
Jan 23 2017 06:12
@abhinavbhanyara first argument will be the array. You loop through each object there. Check if the property, which will be passed in the 2nd argument, is truthy for each object. In that test case, you see the first object has "age": 0. 0 is a falsy value, so it should return false.
rdollent
@rdollent
Jan 23 2017 06:12
what about the value
how do I know that the value is in the corresponding property
I've only seen where Object.value but that does not tie in to a corresponding property.
abhinavbhanyara
@abhinavbhanyara
Jan 23 2017 06:13
Thanks @joreyesl
CamperBot
@camperbot
Jan 23 2017 06:13
abhinavbhanyara sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 364 | @joreyesl |http://www.freecodecamp.com/joreyesl
Ogundele Olumide
@Lumexralph
Jan 23 2017 06:14
@rdollent tried hasOwnProperty?
abhinavbhanyara
@abhinavbhanyara
Jan 23 2017 06:14
How
rdollent
@rdollent
Jan 23 2017 06:17
@Lumexralph I did, but I can only get to yes, it has those properties
i don't know what to do with
Does this property have this value?
and google isn't helping
__SharifTarver__
@Sharifdesigns22
Jan 23 2017 06:19

``` // Example
var ourArray = [1,2,3];
ourArray1 = 3; // ourArray now equals [1,3,3].

// Setup
var myArray = [1,2,3];

// Only change code below this line.
var myArray = [3,2,3];
ourArray[0] = 3; ``` I really don't understand why this doesn't equal [3.2.3]

Can someone help?
Ogundele Olumide
@Lumexralph
Jan 23 2017 06:20
@Sharifdesigns22 reference myArray[0]
Lukas Balabonas
@balabis
Jan 23 2017 06:20
hey there:)
can some,please, tell me wheres the mistake?
var removed = str.replace(/[\u2000-\u206F\u2E00-\u2E7F\'!"#$%&()*+,-.\/:;<=>?@[]^_`{|}~]\s\W/gi, "");
__SharifTarver__
@Sharifdesigns22
Jan 23 2017 06:22
haha that was so simple, can believe I overlooked that @Lumexralph thanks man
CamperBot
@camperbot
Jan 23 2017 06:22
sharifdesigns22 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 824 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jan 23 2017 06:22
@rdollent you compare their values by a using the property this way Object1.a === Object2. b. .... that's comparing their values
Ogundele Olumide
@Lumexralph
Jan 23 2017 06:23
@balabis your regEx pattern is scary :worried:
rdollent
@rdollent
Jan 23 2017 06:23
@Lumexralph ahhh,reallyy..i didn't know that.
Ogundele Olumide
@Lumexralph
Jan 23 2017 06:23
@Billmike can you paste the code here?
@rdollent :laughing:
Lukas Balabonas
@balabis
Jan 23 2017 06:24
@Lumexralph hwo can i remove all the punctuation ?
Manish Giri
@Manish-Giri
Jan 23 2017 06:24
@Billmike have you tried reading up on how .shift() works?
rdollent
@rdollent
Jan 23 2017 06:25
@Lumexralph okay so all I need to do is look if array1 has properties like array2,,,
Ogundele Olumide
@Lumexralph
Jan 23 2017 06:25
@longorjames you can use W... which will match all non-alphanumeric characters
@rdollent yes
rdollent
@rdollent
Jan 23 2017 06:25
hmmm but the properties aren't like arrays in that sense. array1.length shows that {first:"1", second:"2"} has length 1,,,
Jor
@joreyesl
Jan 23 2017 06:26
@balabis instead of trying to match everything you want to replace, you can simplify by using a negation, i.e. match anything that isnt what you want to keep. ex: /\W|_/g which will match anything non-alphanumeric or is a _.
rdollent
@rdollent
Jan 23 2017 06:26
or does it matter, when i'm just looking at properties
Ogundele Olumide
@Lumexralph
Jan 23 2017 06:26
@rdollent if it does then you push it into an array the object from the source that matched
rdollent
@rdollent
Jan 23 2017 06:26
bah i'll figure it out.
yea that's what i've been doing. pushing it to an array
but i've only been pushing either property, or the value, but not them as a pair
Ogundele Olumide
@Lumexralph
Jan 23 2017 06:26
@rdollent all the best
Billmike
@Billmike
Jan 23 2017 06:26

@Lumexralph here it is... function nextInLine(arr, item) {
// Your code here
arr.push(item);

return arr[0]; // Change this line
}

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

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

Ogundele Olumide
@Lumexralph
Jan 23 2017 06:26
have to rush for work
@Billmike use shift as @Manish-Giri suggested and return the element removed
Billmike
@Billmike
Jan 23 2017 06:28
Tried that already. Doesn't work
Manish Giri
@Manish-Giri
Jan 23 2017 06:28
read the link first
because the way you've used shift is wrong - //arr.shift([0]);
Ogundele Olumide
@Lumexralph
Jan 23 2017 06:31
@Billmike don't use shift with an argument use arr. shift ()... return that
Manish Giri
@Manish-Giri
Jan 23 2017 06:31
^
Lukas Balabonas
@balabis
Jan 23 2017 06:31
thanks @joreyesl
CamperBot
@camperbot
Jan 23 2017 06:31
balabis sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 366 | @joreyesl |http://www.freecodecamp.com/joreyesl
Ayush Bahuguna
@relentless-coder
Jan 23 2017 06:32
what is difference between href="app.css" and href="/app.css" ?
Billmike
@Billmike
Jan 23 2017 06:35
thanks guys @Lumexralph and @Manish-Giri.. The link was really helpful @Manish-Giri
CamperBot
@camperbot
Jan 23 2017 06:35
billmike sends brownie points to @lumexralph and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 825 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 3924 | @manish-giri |http://www.freecodecamp.com/manish-giri
Archit Chandra
@architchandra
Jan 23 2017 06:36
Is this a generic forum or one for the particular FCC exercise I am on?
Sorry, new here. Feeling a bit confused.
Long Vu
@longorjames
Jan 23 2017 06:38

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

// Only change code below this line

var hatValue = testObj.prop1; // Change this line
var shirtValue = testObj.prop2;

does it want me to make testObj.prop1 a string?
or do I just change hat shirt shoes in to prop1, prop2, and prop3?
I changed the hat shirt and shoes into the props but idk if that's what it was really looking for
AudioGen
@AudioGen
Jan 23 2017 06:39
Hi
rdollent
@rdollent
Jan 23 2017 06:39
thanks @Lumexralph
CamperBot
@camperbot
Jan 23 2017 06:39
rdollent sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 826 | @lumexralph |http://www.freecodecamp.com/lumexralph
Long Vu
@longorjames
Jan 23 2017 06:40
@AudioGen hi
Archit Chandra
@architchandra
Jan 23 2017 06:40
@longorjames Only change the line that says 'change this line' in the comments
@longorjames change prop1 so that the vale of the hat is shown
Lukas Balabonas
@balabis
Jan 23 2017 06:41
var removed = str.replace(/\W|_\s/g, "");
this line will still not replace the underscore :( why is that?
Jerome Francisco
@Pinkerton96
Jan 23 2017 06:42
@longorjames replace prop1 with hat and prop2 with shirt
that way you'll be calling them
Archit Chandra
@architchandra
Jan 23 2017 06:43

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

// Only change code below this line

result = lookup[val];

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

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

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

alican karalar
@alicankaralar
Jan 23 2017 06:44

function chunkArrayInGroups(arr, size) {

  var array=[];

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

    array.push(arr.slice(i,i+size));

  }
   return array;

  }




chunkArrayInGroups(["a", "b", "c", "d"], 2);
hey guys, this works, but i want to know if there is a better way to do it?
Sergey Lukin
@not-a-cylon
Jan 23 2017 06:45
@architchandra try doing result=lookup[val] after you declare lookup
Jerome Francisco
@Pinkerton96
Jan 23 2017 06:46
@architchandra yeah i believe it has something to do with the order of your code
Long Vu
@longorjames
Jan 23 2017 06:47
@Pinkerton96 Thanks, for some reason I thought I needed to actually put a string there, so I got confused, I really don't like the instructions or wording on this site somtiems.
sometimes*
Archit Chandra
@architchandra
Jan 23 2017 06:47
@Pinkerton96 @not-a-cylon Damn, so silly of me. Thanks guys!
CamperBot
@camperbot
Jan 23 2017 06:47
architchandra sends brownie points to @pinkerton96 and @not-a-cylon :sparkles: :thumbsup: :sparkles:
:cookie: 327 | @not-a-cylon |http://www.freecodecamp.com/not-a-cylon
:cookie: 240 | @pinkerton96 |http://www.freecodecamp.com/pinkerton96
:cookie: 239 | @pinkerton96 |http://www.freecodecamp.com/pinkerton96
longorjames sends brownie points to @pinkerton96 :sparkles: :thumbsup: :sparkles:
Jerome Francisco
@Pinkerton96
Jan 23 2017 06:49
@longorjames no prob!
@architchandra you're welcome :)
abhijith shenoy
@shenoyabhijith
Jan 23 2017 06:52
token error
how can i fix it ?
Joseph
@revisualize
Jan 23 2017 06:53
@architchandra You can't call an object before you have declared the object. JavaScript is executed top down.
Riktim Mondal
@riktimmondal
Jan 23 2017 06:53
someone please tell me where i am making mistake in Search and Replace problem in intermediate algorithm scripting.here is my code:-

function myReplace(str, before, after) {
var newStr = [];
var a=after[0].toUpperCase()+after.substring(1);
newStr = str.split(" ");
for(var i = 0; i < newStr.length; i++) {
if(newStr[i] === before)
{
if(before[0] === before[0].toUpperCase)
newStr.splice(i, 1, a);
else
newStr.splice(i,1,after);
}}
newStr = newStr.join(" ");
return newStr;

}

Manish Giri
@Manish-Giri
Jan 23 2017 06:55
@Billmike welcome, hope it worked..
abhijith shenoy
@shenoyabhijith
Jan 23 2017 06:57
@Manish-Giri
whats the error here
Manish Giri
@Manish-Giri
Jan 23 2017 06:59

@shenoyabhijith

Uncaught ReferenceError: search is not defined

abhijith shenoy
@shenoyabhijith
Jan 23 2017 07:00
$search ?
Manish Giri
@Manish-Giri
Jan 23 2017 07:00
$('input[name=search]').val();
that, probably
abhijith shenoy
@shenoyabhijith
Jan 23 2017 07:00
how do i fix that
Manish Giri
@Manish-Giri
Jan 23 2017 07:00
you have only one input in your html right?
abhijith shenoy
@shenoyabhijith
Jan 23 2017 07:01
@Manish-Giri yes
Manish Giri
@Manish-Giri
Jan 23 2017 07:01
then select it directly, don't need an attribute selector
@shenoyabhijith
Riktim Mondal
@riktimmondal
Jan 23 2017 07:02
someone please see my post
Manish Giri
@Manish-Giri
Jan 23 2017 07:02
@shenoyabhijith var search = $('input').val();
Joseph
@revisualize
Jan 23 2017 07:03
@riktimmondal You should try to use www.pythontutor.com/javascript.html to visualize
AudioGen
@AudioGen
Jan 23 2017 07:04
@riktimmondal A syntax error I see is that the toUpperCase() method needs the parenthesis
still i have this problem
Dipal Gudhka
@dipalgudhka
Jan 23 2017 07:05
sumAll([1, 4]);
What is this?
AudioGen
@AudioGen
Jan 23 2017 07:07
@dipalgudhka a function containing an array?
Manish Giri
@Manish-Giri
Jan 23 2017 07:07
@shenoyabhijith undefinedapple&format=json&limit=10&origin=*&callback=?
The API for your URL is not being set properly

@shenoyabhijith make this change -

 var url = api+search+joiner;
      console.log(url); 
       $.getJSON(url,function(object){

and now it works -

https://en.wikipedia.org/w/api.php?action=opensearch&search=apple&format=json&limit=10&origin=*&callback=?
Array[4]0: "apple"1: Array[10]2: Array[10]3: Array[10]length: 4__proto__: Array[0]
Dipal Gudhka
@dipalgudhka
Jan 23 2017 07:09
@AudioGen How do I use it?
AudioGen
@AudioGen
Jan 23 2017 07:09
is there more to it than that? That would likely be the function call
Dipal Gudhka
@dipalgudhka
Jan 23 2017 07:11
@AudioGen So in a function, how would i use the values in it?
``js
AudioGen
@AudioGen
Jan 23 2017 07:11
function sumAll(arr){
   //do something with arr
  return something;
}

sumAll([1, 4]);
generic setup there
Dipal Gudhka
@dipalgudhka
Jan 23 2017 07:11
@AudioGen I dont understand
AudioGen
@AudioGen
Jan 23 2017 07:11
Ok
@dipalgudhka The values at the bottom are called 'arguments' and these arguments get passed to the function at the top in the arr area, which is a 'parameter' essentially a placeholder variable
Dipal Gudhka
@dipalgudhka
Jan 23 2017 07:13
@AudioGen lets say i want to access 1, how do i do it?
AudioGen
@AudioGen
Jan 23 2017 07:13
Then in between the brackets you can add blocks off code to alter the parameter
Ogundele Olumide
@Lumexralph
Jan 23 2017 07:13
@dipalgudhka you're calling a function with the name sumAll with an array as argument
AudioGen
@AudioGen
Jan 23 2017 07:13
arr[0];
Dipal Gudhka
@dipalgudhka
Jan 23 2017 07:14
@Lumexralph @AudioGen oh got it
abhijith shenoy
@shenoyabhijith
Jan 23 2017 07:14
i cannot find the url when i console.log
Dipal Gudhka
@dipalgudhka
Jan 23 2017 07:14
@AudioGen :+1: Thanks
CamperBot
@camperbot
Jan 23 2017 07:14
dipalgudhka sends brownie points to @audiogen :sparkles: :thumbsup: :sparkles:
:cookie: 367 | @audiogen |http://www.freecodecamp.com/audiogen
Dipal Gudhka
@dipalgudhka
Jan 23 2017 07:14
@Lumexralph :+1: Thanks
CamperBot
@camperbot
Jan 23 2017 07:14
dipalgudhka sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 827 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jan 23 2017 07:15
@dipalgudhka :+1:
Manish Giri
@Manish-Giri
Jan 23 2017 07:15
Joshua Reed
@Flintar
Jan 23 2017 07:16
var myStr = "FirstLine"/n"\SecondLine\"/r"ThiredLine"; // Change this line (There is something wrong with this code that I am not understanding how to do escaped sequences in strings.
heroiczero
@heroiczero
Jan 23 2017 07:17
@Flintar gotta use \n and \ needs escape quotes
Joshua Reed
@Flintar
Jan 23 2017 07:18
ok
Riktim Mondal
@riktimmondal
Jan 23 2017 07:19
thanks for pointing out my mistake @AudioGen
CamperBot
@camperbot
Jan 23 2017 07:19
riktimmondal sends brownie points to @audiogen :sparkles: :thumbsup: :sparkles:
:cookie: 368 | @audiogen |http://www.freecodecamp.com/audiogen
AudioGen
@AudioGen
Jan 23 2017 07:19
No Prob
vaunie
@vaunie
Jan 23 2017 07:20
I'd really appreciate some help: it's the "Mutations" algorithm, and every test works except the first, which is at the end.

function mutation(arr) {
var even = arr[0].toLowerCase();
var odd = arr1.toLowerCase();

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

}

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

heroiczero
@heroiczero
Jan 23 2017 07:21
@vaunie it will only go through the for loop once when it is !==-1 because of the return true;
abhijith shenoy
@shenoyabhijith
Jan 23 2017 07:23
@Manish-Giri thanks working f9
CamperBot
@camperbot
Jan 23 2017 07:23
shenoyabhijith sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3925 | @manish-giri |http://www.freecodecamp.com/manish-giri
heroiczero
@heroiczero
Jan 23 2017 07:23
@vaunie you want to check if it false first in the loop if it is not false in the loop you can put a return true outside the for loop\
Manish Giri
@Manish-Giri
Jan 23 2017 07:24
Welcome
vaunie
@vaunie
Jan 23 2017 07:25
I changed it and it seems to only work for that particular test array. @heroiczero
Jor
@joreyesl
Jan 23 2017 07:25
@vaunie in your loop you will be checking for when an index is -1, if you find it then you want to return false. But you do not want to return true inside of your loop. If you do then you will exit out of the function prematurely. If index is not -1 then you want to continue on to check the next character. Now where you want to return true is outside of your loop. If the loop completed and it didnt find -1 then its safe to say that every character existed in the first string so you are safe to return true after the loop.
AudioGen
@AudioGen
Jan 23 2017 07:26
@vaunie You have a syntax error for odd. you need to evaluate the 1 index of arr.
Ogundele Olumide
@Lumexralph
Jan 23 2017 07:26
@AudioGen it's correct it's gitter's doing
AudioGen
@AudioGen
Jan 23 2017 07:27
@Lumexralph it's not correct how it's displayed
Andrew Almonte
@adakteen
Jan 23 2017 07:27
Hi guys. I'm having trouble with the Mutations challenge. Can anyone help?
Rajapriyan53
@Rajapriyan53
Jan 23 2017 07: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;j<arr.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]]);

Andrew Almonte
@adakteen
Jan 23 2017 07:28
This is what I have so far..

function mutation(arr) {
var arr0 = arr[0].toLowerCase().split("").sort().join("");
var arr1 = arr1.toLowerCase().split("").sort().join("");

return ((arr0.indexOf(arr1) !== -1) || (arr1.indexOf(arr0) !== -1));

}
mutation(["floor", "for"]);

that "arr1" should be "arr1
AudioGen
@AudioGen
Jan 23 2017 07:29
but it happened with Andrew's post too, so I dunno
Andrew Almonte
@adakteen
Jan 23 2017 07:29
"arr1"
hmm, the one should be in brackets.
AudioGen
@AudioGen
Jan 23 2017 07:29
arr[1];
works with the ticks
arr1
hmmm that's strange
Rajapriyan53
@Rajapriyan53
Jan 23 2017 07:30
@AudioGen