These are chat archives for FreeCodeCamp/HelpJavaScript

7th
Aug 2016
Promise Tochi
@Promhize
Aug 07 2016 00:04

function getIndexToIns(arr, num) {
  // Find my place in this sorted array.


    return arr.sort(function(a,b){return a-b;}).reduce(
        function(a,b,i,array){
            if(num > b && (num <= array[i+1] || i === array.length-1)){
                a = i+1;
            }else if(num === b){
               a= i;
            }
            return a;
        }, 0
    );



}

getIndexToIns([2, 5, 10], 15);
with reduce
Stephen James
@sjames1958gm
Aug 07 2016 00:08
@Promhize Doesn't access past the end of the array? array[3] ?
Gary Siu
@GarySiu
Aug 07 2016 00:11
@kirahmadlare do you mean [].forEach?
King Mhar Bayato
@kirahmadlare
Aug 07 2016 00:12
@GarySiu hello no, the for each loop. or how t o solve the mutation challenge.. still stuck with it.
Promise Tochi
@Promhize
Aug 07 2016 00:13
@sjames1958gm yeah thats true but the i === array.length-1 normalizes it
Brenda Kaing
@brendak
Aug 07 2016 00:15

If anyone can help me figure out why this code doesn't work (instructions in the comment) - that would be helpful!

https://gist.github.com/brendak/d424e64a9e64e77c28c27371260788a5

John Magee
@jemagee
Aug 07 2016 00:16
@brendak What errors does it throw on the console? That sort('') looks fishy to me
Gary Siu
@GarySiu
Aug 07 2016 00:17
beline
@beline2005
Aug 07 2016 00:17

Check for Palindromes
function palindrome(str) {
var arr=[];
var low = str.toLowerCase();
var min = low.replace(/[&\/\#,+()$~%.'":*?<>{}\s]/g, '');
//var mins = min.replace(" ","");
arr = min.split("");
var arrRev = arr.reverse();

if (arr !== arrRev){
return false;
}
else if (arr == arrRev) {
return true;
}
// Good luck!
}

palindrome("nope");

King Mhar Bayato
@kirahmadlare
Aug 07 2016 00:18
@GarySiu Yes, that's correct.
Stephen James
@sjames1958gm
Aug 07 2016 00:18
@beline2005 Does this always return true?
beline
@beline2005
Aug 07 2016 00:18
When I run the code, arr returns "e""p""o""n"
Vatsal Pande
@vatsalpande
Aug 07 2016 00:18
@kirahmadlare
```
Gary Siu
@GarySiu
Aug 07 2016 00:19
@kirahmadlare for each is used with objects, not arrays. (It's use is also discouraged now). You don't need it for this exercise.
Stephen James
@sjames1958gm
Aug 07 2016 00:19
@beline2005 arrRev and arr reference the same array. So they will always be ==
beline
@beline2005
Aug 07 2016 00:19
@sjames1958gm Did you notice what's wrong with my code?
Vatsal Pande
@vatsalpande
Aug 07 2016 00:19
function mutation(arr) {
  var splitStringArray = arr[0].split("").map(mapUpperCase);
  var splitStringSecond =  arr[1].split("");
  var mutated = false;
  splitStringSecond.forEach(iterateEach);

  function mapUpperCase(item){
    return item.toUpperCase();
  } 

  function iterateEach(item){
    //Only check for more if last check returned true. //Value existed
    if(!mutated){
      mutated = splitStringArray.indexOf(item.toUpperCase()) === -1;             
    }  
  }

  return !mutated;
}
Hope this helps
Stephen James
@sjames1958gm
Aug 07 2016 00:19
@beline2005 Turn arrRev back into string and compare to min
King Mhar Bayato
@kirahmadlare
Aug 07 2016 00:19
@vatsalpande let me study your code, thanks again.
CamperBot
@camperbot
Aug 07 2016 00:19
kirahmadlare sends brownie points to @vatsalpande :sparkles: :thumbsup: :sparkles:
:warning: kirahmadlare already gave vatsalpande points
Brenda Kaing
@brendak
Aug 07 2016 00:20
@jemagee it actually logs when I test, but Codewars is saying I am failing 2 tests (code can't handle in wrong order)
SmoothMove2000
@SmoothMove2000
Aug 07 2016 00:20
abAZZALANCH1
Azlan Mukhtar
@azlan
Aug 07 2016 00:20
the better way to help is to help him/her to discover by him/herself
no giving straight answer
Vatsal Pande
@vatsalpande
Aug 07 2016 00:21
I already gave him the hint and he was stuck with a loop. hence gave sample solution
Azlan Mukhtar
@azlan
Aug 07 2016 00:22
ok
beline
@beline2005
Aug 07 2016 00:22
@sjames1958gm Thanks. It works!
CamperBot
@camperbot
Aug 07 2016 00:22
beline2005 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2380 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 07 2016 00:23
@beline2005 arr2 = arr1 - if these are arrays, they will point to the same array.
@beline2005 :+1:
beline
@beline2005
Aug 07 2016 00:24
@sjames1958gm Is that the reason we convert it back to string?
Gary Siu
@GarySiu
Aug 07 2016 00:24
:/
Jeffrowetull
@Jeffrowetull
Aug 07 2016 00:29
Hi all, in the exercise "Multiple Identical Options in Switch Statements" the psuedocode has the phrase result = "1, 2, or 3";. That doesn't work so I used return. Why is "result" used there?
Abhisek Pattnaik
@abhisekp
Aug 07 2016 00:30
@vatsalpande why the IIFE? :point_up: August 7, 2016 5:15 AM
Vatsal Pande
@vatsalpande
Aug 07 2016 00:30
you can remove it. I wrote it as part of my practice. Good practice to not make anything public
Abhisek Pattnaik
@abhisekp
Aug 07 2016 00:31
alrighty :+1:
Azlan Mukhtar
@azlan
Aug 07 2016 00:32
@Jeffrowetull you should replace the result with your own
Chase
@Belax8
Aug 07 2016 00:32
@Jeffrowetull in that example result is just the variable that they assigned the answer to. You will need to assign it to answer
Azlan Mukhtar
@azlan
Aug 07 2016 00:32
and it just variable name
Cascada1
@Cascada1
Aug 07 2016 00:34
I would appreciate any comments on my Twitch.TV project. http://codepen.io/Cascada1/full/dXXRdj/
Jeffrowetull
@Jeffrowetull
Aug 07 2016 00:36
@azlan @Belax8 I used return. How is answer different from return?
Azlan Mukhtar
@azlan
Aug 07 2016 00:37
in the code, try to put this, answer = 'Low';
Chase
@Belax8
Aug 07 2016 00:37
@Cascada1 I think it looks really good. I like the way everything slides in from the side. That's a cool way to load it. The only problem I see is that your nav buttons all slide in on top of each other and it kinda looks weird
Azlan Mukhtar
@azlan
Aug 07 2016 00:37
and check the reuslt
Jeffrowetull
@Jeffrowetull
Aug 07 2016 00:38
@azlan I have, and I see no difference from using return
dimitrije12
@dimitrije12
Aug 07 2016 00:39
function dropElements(arr, func) {
  // Drop them elements.

  for (var i=0;i<arr.length;i++){
    if (func(arr[0])){
      return arr;
    }
   else arr.shift();
  }


}
Chase
@Belax8
Aug 07 2016 00:39
@Jeffrowetull There are two ways to do it. If you put return then you are just returning the string. If you set it to a variable, then it will just return the variable after the switch statement. Its basically the same thing.
dimitrije12
@dimitrije12
Aug 07 2016 00:39
Any help with this function?
Cascada1
@Cascada1
Aug 07 2016 00:40
@Belax8 thanks for the input. I don't know why it does it quite that way but maybe it can be fixed.
CamperBot
@camperbot
Aug 07 2016 00:40
cascada1 sends brownie points to @belax8 :sparkles: :thumbsup: :sparkles:
:cookie: 423 | @belax8 |http://www.freecodecamp.com/belax8
Jeffrowetull
@Jeffrowetull
Aug 07 2016 00:40
@Belax8 Ah I understand now, thanks
CamperBot
@camperbot
Aug 07 2016 00:40
jeffrowetull sends brownie points to @belax8 :sparkles: :thumbsup: :sparkles:
:cookie: 424 | @belax8 |http://www.freecodecamp.com/belax8
dimitrije12
@dimitrije12
Aug 07 2016 00:40
NVM, solved it
Chase
@Belax8
Aug 07 2016 00:41
@Jeffrowetull Anytime.
Juan Carlos Monsalve
@juancmonsalves
Aug 07 2016 00:49
hi
Chase
@Belax8
Aug 07 2016 00:50
@juancmonsalves Hey Juan
shenshao
@shenshao
Aug 07 2016 00:52
blob
Chase
@Belax8
Aug 07 2016 00:55
@shenshao Which challenge is that? Do you have a question about that?
shenshao
@shenshao
Aug 07 2016 00:57
ok, I solved
Todd
@TheOnlyRealTodd
Aug 07 2016 00:59
anyonsee the problem with my code:
(charNumber > 77) ? charNumber -= 13 : charNumber += 13;
Seems like fine ternary use to me
its telling me it expects an expression or function call
an assignment or function call I mean
Gary Siu
@GarySiu
Aug 07 2016 01:01
@TheOnlyRealTodd That's usually a false positive. Does your code run and pass the tests?
Chase
@Belax8
Aug 07 2016 01:01
@TheOnlyRealTodd maybe its mad about the (). maybe try charNumber > 77 ? charNumber -= 13 : charNumber += 13;
Shu1k
@Shu1k
Aug 07 2016 01:01

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit = 9 % 5 + 32;

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

// Change the inputs below to test your code
convertToF(-30);
im really confused. what did i do wrong

Azlan Mukhtar
@azlan
Aug 07 2016 01:02
@TheOnlyRealTodd https://repl.it/CkXW/0
Gary Siu
@GarySiu
Aug 07 2016 01:03
@Shu1k Your code doesn't incorporate celsius in any way?
Azlan Mukhtar
@azlan
Aug 07 2016 01:03
@Shu1k , you are using %, not/
Shu1k
@Shu1k
Aug 07 2016 01:04
@azlan even when i use / still doesnt work
Todd
@TheOnlyRealTodd
Aug 07 2016 01:04
@GarySiu no it doesnt
Azlan Mukhtar
@azlan
Aug 07 2016 01:04
To convert temperatures in degrees Celsius to Fahrenheit, multiply by 1.8 (or 9/5) and add 32
Shu1k
@Shu1k
Aug 07 2016 01:05
@azlan i meant to put celsius= and either way still doesnt work
Todd
@TheOnlyRealTodd
Aug 07 2016 01:05
@azlan looks like it works fine lol
Azlan Mukhtar
@azlan
Aug 07 2016 01:05
fahrenheit = (9 / 5) + 32;
Gary Siu
@GarySiu
Aug 07 2016 01:05
@TheOnlyRealTodd What's your full code?
Shu1k
@Shu1k
Aug 07 2016 01:05
@azlan im aware, still doesnt work
Azlan Mukhtar
@azlan
Aug 07 2016 01:06
Gary Siu
@GarySiu
Aug 07 2016 01:06
er.... still not incorporating celsius in any way
Chase
@Belax8
Aug 07 2016 01:06
@Shu1k fahrenheit = celsius * (9/5) + 32;
Shu1k
@Shu1k
Aug 07 2016 01:07
thanks @Belax8
CamperBot
@camperbot
Aug 07 2016 01:07
shu1k sends brownie points to @belax8 :sparkles: :thumbsup: :sparkles:
:cookie: 425 | @belax8 |http://www.freecodecamp.com/belax8
Azlan Mukhtar
@azlan
Aug 07 2016 01:08
lol, i missed that one
Gary Siu
@GarySiu
Aug 07 2016 01:08
:see_no_evil:
Chase
@Belax8
Aug 07 2016 01:09
Anytime @Shu1k
Joseph
@revisualize
Aug 07 2016 01:21
@shenshao Did you solve your challenge?
Braber01
@Braber01
Aug 07 2016 01:25

so I think I have a logic error in my longest word file.

function findLongestWord(str) {
    var words = str.split(' ');
    var longestWord = words[0].length;
    var nextWord = words[1].length;

    for (var i=0; i< words.length; i++){
        //debugging help
        console.log(words[i]);
        if(longestWord < nextWord) {
          longestWord = nextWord;
         nextWord = words[i+1].length;
    } //end if
}//end for
return longestWord;
}//end function

console.log(findLongestWord("The quick brown fox jumped over the lazy dog"));

it currently returns 5 when it should return six

Joseph
@revisualize
Aug 07 2016 01:27
That's a log of code.
@Braber01 Have you tried visualizing your code in www.pythontutor.com ?
jkrollin14
@jkrollin14
Aug 07 2016 01:28
how can I get a switch statement to accept letters instead of numbers?
Braber01
@Braber01
Aug 07 2016 01:28
Nope I haven't this is the first I've even heard of that website.
omg it supports typescript <3
Joseph
@revisualize
Aug 07 2016 01:29
@Braber01 Your logic is off.
Braber01
@Braber01
Aug 07 2016 01:30
@revisualize I figured that, I just need to figure out who what when where why and how.
Joseph
@revisualize
Aug 07 2016 01:30
hmmm.

var nextWord = words[1].length;
nextWord = words[i+1].length;

This stuff needs to go.

longestWord should just be a number.
start with 0
Azlan Mukhtar
@azlan
Aug 07 2016 01:32
you mixed up string and number
as @revisualize said :smile:
Joseph
@revisualize
Aug 07 2016 01:34
I mean if we're just going to give away answers .... https://repl.it/CkXj/1
Tyler Brown
@pelicanscarecrow
Aug 07 2016 01:34

function orderMyLogic(val) {
if (val < 10) {
return "Less than 10";
} else if (val < 5) {
return "Less than 5";
} else {
return "Greater than or equal to 10";
}
}

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

How would I change the order of logic in the function so that it will return the correct statements in all cases.
Braber01
@Braber01
Aug 07 2016 01:35
@azlan One of the major reazons why I prefer typescript over javascript, strongly typed varibales so it's harder to make those kinds of mistakes.
Joseph
@revisualize
Aug 07 2016 01:35

@azlan

const findLongestWord = (str) => str.replace(/[^A-Z0-9 -]/gi, "").split(" ").reduce((a, b) => b.length > a ? b.length : a, 0);

Why don't you just go all out when you give away answers?

Azlan Mukhtar
@azlan
Aug 07 2016 01:36
my mistake
Braber01
@Braber01
Aug 07 2016 01:36
AHHH the Tentnary OPerator IT BURNS!!!
Joseph
@revisualize
Aug 07 2016 01:36
@azlan Or I mean.. Why not just go shorter?
const findLongestWord = s => Math.max(...s.split(" ").map(w => w.length));
@azlan Hey I can't solve Where art thou... Can you give me the answer?
Tyler Brown
@pelicanscarecrow
Aug 07 2016 01:37
nevermind figured it out
Joseph
@revisualize
Aug 07 2016 01:39
I guess it shows that when people give away answers instead of helping them learn .. It pisses me off. But, what do I know.
Azlan Mukhtar
@azlan
Aug 07 2016 01:40
I'm sorry @Braber01
I shouldn't give the answer
Mrinal Patwardhan
@mrinalusp
Aug 07 2016 01:43
HI Guys
I am faced with a silly issue
i must be doing something really silly
Create a variable myDecimal and give it a decimal value with a fractional part (e.g. 5.7).
This is what i write
var mydecimal = 5.7;
what is wrong here?
Joseph
@revisualize
Aug 07 2016 01:44
myDecimal vs mydecimal
You got to give it the D
Mrinal Patwardhan
@mrinalusp
Aug 07 2016 01:44
oh my god
Thanks @revisualize
CamperBot
@camperbot
Aug 07 2016 01:44
mrinalusp sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1556 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 07 2016 01:44
@mrinalusp :)
/me just told a lady to give something the D. After that teenage boy joke. I'm out.
Gregory Bilecki
@gbilecki
Aug 07 2016 01:48
Hey anyone doing falsy bouncer?
Azlan Mukhtar
@azlan
Aug 07 2016 01:51
@gbilecki, any question about that?
Joseph
@revisualize
Aug 07 2016 01:53
@gbilecki My suggestion. Follow the suggestions from the lesson.
Brenda Kaing
@brendak
Aug 07 2016 01:58
@gbilecki i've done it!
Juan Carlos Monsalve
@juancmonsalves
Aug 07 2016 02:02
I'm having troubble with array access....
I can't master it
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:02

function golfScore(par, strokes) {
// Only change code below this line

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

// Change these values to test
golfScore(5, 4);

Does anyone know how I should go about this?
I know I should do the if/else if statements and I know how to return, but what order?
Joseph
@revisualize
Aug 07 2016 02:03
@pelicanscarecrow Yeah. Write an if using the conditions that are supplied to you.
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:05
Just go down the line?
For example i would say
if (par<=1){ return "Hole-in-one!";}
That went ahead and checked me off.
But,
Stephen James
@sjames1958gm
Aug 07 2016 02:07
@pelicanscarecrow strokes is the number not par
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:07
Oh shit duh
Thanks for the catch @sjames1958gm
CamperBot
@camperbot
Aug 07 2016 02:07
pelicanscarecrow sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2381 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:11
How would I write the code for par?
Gregory Bilecki
@gbilecki
Aug 07 2016 02:11

hey @azlan @revisualize @brendak here is my code...sorry got sucked into a youtube hole watching videos on the filter method:


function bouncer(arr) {

var newArr = arr.filter(function filt(val) {
  if (val === false) {
      return false;
  } else {
 return true;
}
});
}

No spoilers, please -- just need to know WHAT exactly I'm not seeing right.

Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:11
I put else if (strokes){return "Par";
}
Gregory Bilecki
@gbilecki
Aug 07 2016 02:13
@azlan @revisualize @brendak let me get this straight -- does 0, null, NaN, undefined, and "" ALL equal false?
Azlan Mukhtar
@azlan
Aug 07 2016 02:14
yeah, called Falsy in js term
bradulz
@bradulz
Aug 07 2016 02:15
@gbilecki yes if(val) will return false for all those
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:15

function golfScore(par, strokes) {
// Only change code below this line

if (strokes<=1){
return "Hole-in-one!";}
else if (strokes<=2){
return "Eagle";
} else if (strokes<=3){
return "Birdie";
} else if (strokes){
return "Par";
} else if (strokes +1){
return "Bogey";
}

// Only change code above this line
}

// Change these values to test
golfScore(5, 4);

It all worked so far except for the return Bogey..
What do I do differently?
bradulz
@bradulz
Aug 07 2016 02:16
@pelicanscarecrow its not the strokes that decides if a run was a bogey,birdey etc. Its the difference between the par and the strokes
eg. if(par-strokes == -1) return "birdie";
Stephen James
@sjames1958gm
Aug 07 2016 02:17
@pelicanscarecrow Except for hole in one you have to compare strokes to par as per table
@gbilecki Which test is failing?
pauoola
@pauoola
Aug 07 2016 02:18

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

function checkObj(checkProp) {
myObj.hasOwnProperty("gift"); I dont understand what i am missing

Gregory Bilecki
@gbilecki
Aug 07 2016 02:18
@azlan @revisualize @brendak -- ok so I understand it correctly...then WHY is my console output completely blank
they all are still
c0d0er
@c0d0er
Aug 07 2016 02:18
hi, could anybody help me on this:

Understand String Immutability
In JavaScript, String values are immutable, which means that they cannot be altered once created.

For example, the following code:

var myStr = "Bob";
myStr[0] = "J";
cannot change the value of myStr to "Job", because the contents of myStr cannot be altered. Note that this does not mean that myStr cannot be changed, just that the individual characters of a string literal cannot be changed. The only way to change myStr would be to assign it with a new string, like this:

var myStr = "Bob";
myStr = "Job";
Instructions
Correct the assignment to myStr to achieve the desired effect.

Gregory Bilecki
@gbilecki
Aug 07 2016 02:19
should i push the true elements to a new array?
Stephen James
@sjames1958gm
Aug 07 2016 02:19
@pauoola Use checkProp for checking and returning the property
@gbilecki .filter will build the output array based on true/false return.
Azlan Mukhtar
@azlan
Aug 07 2016 02:20
@gbilecki u forgot to return the new array in the above code
c0d0er
@c0d0er
Aug 07 2016 02:20

hi, could anybody help me on this? this is instruction: Understand String Immutability
In JavaScript, String values are immutable, which means that they cannot be altered once created.

For example, the following code:

var myStr = "Bob";
myStr[0] = "J";
cannot change the value of myStr to "Job", because the contents of myStr cannot be altered. Note that this does not mean that myStr cannot be changed, just that the individual characters of a string literal cannot be changed. The only way to change myStr would be to assign it with a new string, like this:

var myStr = "Bob";
myStr = "Job";
Instructions
Correct the assignment to myStr to achieve the desired effect.

this is my code

// Setup
var myStr = "Jello World";

// Only change code below this line
var myStr="Hello";
myStr[0] = "H"; // Fix Me
Norvin Burrus
@ndburrus
Aug 07 2016 02:21
@xiaji1 since pieces of strings cannot be changed (immutability), how can we change its value?
Stephen James
@sjames1958gm
Aug 07 2016 02:21
@xiaji1 You need only one line, you are close with your first line
pauoola
@pauoola
Aug 07 2016 02:22
@sjames1958gm so should I be using checkProp.hasOwnProperty("gift"); instead of myObj.hasOwnProperty("gift");
c0d0er
@c0d0er
Aug 07 2016 02:22

```

// Setup
var myStr = "Jello World";

// Only change code below this line
myStr="Hello";
myStr[0] = "H"; // Fix Me

Stephen James
@sjames1958gm
Aug 07 2016 02:22
@pauoola no, use checkProp instead of "gift"
c0d0er
@c0d0er
Aug 07 2016 02:22
even i change to this, cannot work @ndburrus
@sjames1958gm sorry i dont understand, could you explain?
Norvin Burrus
@ndburrus
Aug 07 2016 02:23
@xiaji1 but we still have this myStr[0] = "H"; in the code...
Stephen James
@sjames1958gm
Aug 07 2016 02:23
@xiaji1 Fix the one line of code, replace with the correct code.
Gregory Bilecki
@gbilecki
Aug 07 2016 02:24

@azlan @sjames1958gm new code looks like this:


function bouncer(arr) {

var newArr = arr.filter(function filt(val) {
  if (val === false || val === "") {
      return false;
  } else {
 return true;
}
});
return newArr;
}

now only first two checks are passing.

added val === "" condition because it threw me back the empty string
pauoola
@pauoola
Aug 07 2016 02:24
@sjames1958gm myObj.hasOwnProperty("checkProp"); and the same for checkObj
Gregory Bilecki
@gbilecki
Aug 07 2016 02:25
this is killing me...i know i'm close
no spoilers tho! :)
Stephen James
@sjames1958gm
Aug 07 2016 02:25
@pauoola "checkProp" is different than checkProp the first is a string the second is a variable
Azlan Mukhtar
@azlan
Aug 07 2016 02:25
@gbilecki val === "" unnecessary, because "" also falsy
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:25
I passed the challenge
but did i pass it right?

function golfScore(par, strokes) {
// Only change code below this line
if (strokes===1){
return "Hole-in-one!";}
else if (strokes===2){
return "Eagle";
} else if (strokes===3){
return "Birdie";
} else if (par===strokes){
return "Par";
} else if (strokes===5){
return "Bogey";

}else if (strokes===6){
return "Double Bogey";
}else
return "Go Home!";
// Only change code above this line
}

// Change these values to test
golfScore(5, 4);

Stephen James
@sjames1958gm
Aug 07 2016 02:26
@pelicanscarecrow No
Gregory Bilecki
@gbilecki
Aug 07 2016 02:26
@azlan -- true, however if i leave it out it throws back the empty string.
Stephen James
@sjames1958gm
Aug 07 2016 02:26
@pelicanscarecrow Example: if (strokes === par -1) return "Birdie";
c0d0er
@c0d0er
Aug 07 2016 02:26
@sjames1958gm you said: Fix the one line of code, replace with the correct code. which one line i should fix? replace which one?
Stephen James
@sjames1958gm
Aug 07 2016 02:27
@xiaji1 The one that says Fix Me
pauoola
@pauoola
Aug 07 2016 02:27
@sjames1958gm Is this what you mean? myObj.hasOwnProperty(checkProp);
Stephen James
@sjames1958gm
Aug 07 2016 02:27
@pauoola Yes!
Gregory Bilecki
@gbilecki
Aug 07 2016 02:27
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:27
@sjames1958gm so plug in the table rather than putting in direct numbers?
c0d0er
@c0d0er
Aug 07 2016 02:27
even i change to myStrxamarin/xamarin-android@a16673d = "J"; no work @sjames1958gm
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:28
I did hole in one correct right?
Stephen James
@sjames1958gm
Aug 07 2016 02:28
@pelicanscarecrow Yes, that is the only one that is not relative to par.
c0d0er
@c0d0er
Aug 07 2016 02:28
@ndburrus you said: but we still have this myStrxamarin/xamarin-android@a16673d = "H"; in the code..., what is the meaning of this?
Azlan Mukhtar
@azlan
Aug 07 2016 02:28
@gbilecki , the problem is the ===
Stephen James
@sjames1958gm
Aug 07 2016 02:29
@xiaji1 The point is you cannot change the contents of the string, you must replace the whole string.
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:29
@sjames1958gm so how would I do the Eagle... the table says <=par-2
Azlan Mukhtar
@azlan
Aug 07 2016 02:29
@gbilecki , === is used to compare exact value, to to compare falsy. try if (val)
c0d0er
@c0d0er
Aug 07 2016 02:29
could you give me the correct answer to show me or give me an example? @sjames1958gm
Stephen James
@sjames1958gm
Aug 07 2016 02:29
@pelicanscarecrow if (strokes <= par -2)
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:30
not else if?
Azlan Mukhtar
@azlan
Aug 07 2016 02:30
@gbilecki *not to compare
Gregory Bilecki
@gbilecki
Aug 07 2016 02:30
false is an exact value i thought
Stephen James
@sjames1958gm
Aug 07 2016 02:30
@pelicanscarecrow else if - sry
Stephen James
@sjames1958gm
Aug 07 2016 02:30
@xiaji1 Just set myStr to the requested string.
Max Omdal
@momja
Aug 07 2016 02:31
currently working on the local weather zipline. Any idea on how to get current location?
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:31
@sjames1958gm would par be else if(par===strokes)
huing
@huing
Aug 07 2016 02:31
blob
Stephen James
@sjames1958gm
Aug 07 2016 02:31
@pelicanscarecrow yes - just follow the table
@momja You can use ip-api.com/json as an API
Gregory Bilecki
@gbilecki
Aug 07 2016 02:32
WTF
WHY DID THAT WORK??
Max Omdal
@momja
Aug 07 2016 02:32
@sjames1958gm awesome that looks super easy thanks!
CamperBot
@camperbot
Aug 07 2016 02:32
momja sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2382 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 07 2016 02:32
@gbilecki What did you do?
Gregory Bilecki
@gbilecki
Aug 07 2016 02:33
@azlan @sjames1958gm this was my winning code:

function bouncer(arr) {

var newArr = arr.filter(function filt(val) {
  if (val) {
      return true;
  } else {
 return false;
}
});
return newArr;
}

bouncer([7, "ate", "", false, 9]);
Stephen James
@sjames1958gm
Aug 07 2016 02:33
@starhui If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.
this has to be coded
Azlan Mukhtar
@azlan
Aug 07 2016 02:34
@gbilecki there you go, and u can simplify the code more
Stephen James
@sjames1958gm
Aug 07 2016 02:34
@gbilecki Yep even easier - just return val no if needed. .filter removes false returns, so return the "falsy" values and they are gone, poof.
pauoola
@pauoola
Aug 07 2016 02:35

Made some changes but still coming up in the red. var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
myObj.hasOwnProperty(checkProp);

if (checkProp != "myObj"); {
return "Not Found";
}
}

// Test your code by modifying these values
checkObj("gift");
Can anyone tell me what I am missing?

Stephen James
@sjames1958gm
Aug 07 2016 02:36
@pauoola myObj.hasOwnProperty(checkProp); this returns true/false - use that in an if, also you are not returning the property value
pauoola
@pauoola
Aug 07 2016 02:36
@sjames1958gm I should lose the if else statement
Gregory Bilecki
@gbilecki
Aug 07 2016 02:36
@azlan @sjames1958gm by that logic then, this works too:

function bouncer(arr) {

var newArr = arr.filter(function filt(val) {
  if (val) {
      return true;
}
});
return newArr;
}

bouncer([7, "ate", "", false, 9]);
simplifying it actually helps me understand it more
Azlan Mukhtar
@azlan
Aug 07 2016 02:37
@gbilecki pls read about filter() at MDN again, more understanding
huing
@huing
Aug 07 2016 02:38
but I can't help it out @sjames1958gm
Gregory Bilecki
@gbilecki
Aug 07 2016 02:39
@azlan - - the MDN page doesn't state that it removes false elements by default
Stephen James
@sjames1958gm
Aug 07 2016 02:39
@gbilecki Without return a function returns undefined which is falsey
Gregory Bilecki
@gbilecki
Aug 07 2016 02:40
@sjames1958gm im aware of that--that was never my issue
let me get this straight --- what if(val) is saying inside the callback, correct me if im wrong --- "if this value is false, return the true elements"
Stephen James
@sjames1958gm
Aug 07 2016 02:40
@gbilecki All you needed was return arr.filter( function(v) {return v;});
@gbilecki It is saying if val is truthy keep it.
Abis Mal
@abisthecodermal
Aug 07 2016 02:42
@DarrenfJ @stonefmagiecurata @UsamaHameed @IshtmeetSingh around?
Gregory Bilecki
@gbilecki
Aug 07 2016 02:43
@sjames1958gm because filter (by default) eats false elements -- correct?
Stephen James
@sjames1958gm
Aug 07 2016 02:44
@starhui Inside your if (value !=="" && prop =="tracks") check hasOwnProperty
@gbilecki By design it eats elements where the function returns false
Azlan Mukhtar
@azlan
Aug 07 2016 02:45
or return any falsy
Gregory Bilecki
@gbilecki
Aug 07 2016 02:45
@sjames1958gm that's what i said, essentially, no? :smile:
AzeddineDev
@AzeddineDev
Aug 07 2016 02:48
Hi guys! How many language I sould be focus on? coz, I want to learn many programming languages?
Azlan Mukhtar
@azlan
Aug 07 2016 02:48
filter is a function that call another function to check the elements, if the function return a falsy, then filter will eat the element
@AzeddineDev Just one language
AzeddineDev
@AzeddineDev
Aug 07 2016 02:49
just one!! I started now with javascript, and I want to learn two or three at the same time, is that good idea?
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:49

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val){
case "alpha":
break;
}

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

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

Joseph
@revisualize
Aug 07 2016 02:49
Hi kids.
AzeddineDev
@AzeddineDev
Aug 07 2016 02:49
.
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:49
What have I done wrong.
Gregory Bilecki
@gbilecki
Aug 07 2016 02:49
Everythings a lot more clearer now guys. Thanks a lot @sjames1958gm @azlan.
CamperBot
@camperbot
Aug 07 2016 02:49
:cookie: 13 | @azlan |http://www.freecodecamp.com/azlan
gbilecki sends brownie points to @sjames1958gm and @azlan :sparkles: :thumbsup: :sparkles:
:star2: 2383 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:50
What do I put in the parenthesis next to switch?
Gregory Bilecki
@gbilecki
Aug 07 2016 02:50
@AzeddineDev if you try to catch two cats at once, you'll catch neither.
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:50
And would my case be "alpha":?
huing
@huing
Aug 07 2016 02:50
thanks @sjames1958gm
CamperBot
@camperbot
Aug 07 2016 02:50
starhui sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2384 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 07 2016 02:50
@pelicanscarecrow That is correct - val is the one that you want to test.
AzeddineDev
@AzeddineDev
Aug 07 2016 02:51
@gbilecki ow! you're right!!
Stephen James
@sjames1958gm
Aug 07 2016 02:51
@pelicanscarecrow Is "alpha" an answer?
Joseph
@revisualize
Aug 07 2016 02:51
@gbilecki You know that could just be 1 line of code.
Stephen James
@sjames1958gm
Aug 07 2016 02:51
@pelicanscarecrow Your cases should be numbers
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:51
It says write a switch statement which tests val and sets answer for the following conditions: alpha, beta, gamma, delta.
Okay, should my statement sentence be the alpha
Stephen James
@sjames1958gm
Aug 07 2016 02:52
@pelicanscarecrow No, it says for the condition 1 return "alpha"
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:53
I have a return that is unchangeable set to "answer"
Stephen James
@sjames1958gm
Aug 07 2016 02:53
@pelicanscarecrow So set the answer variable to something useful
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:54

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

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

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

Stephen James
@sjames1958gm
Aug 07 2016 02:54
@pelicanscarecrow You can do that - or answer = "alpha"
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:54
What would I do rather then setting a return in my case?
Addy
@asonder
Aug 07 2016 02:55
Hi, I'm stuck on Mutations. Trying to figure out how to return 'true' if the loop iterates over all of str2. Does anyone know?
while (str1.indexOf(str2[i])!== -1) {
i++;
}
Stephen James
@sjames1958gm
Aug 07 2016 02:55
@pelicanscarecrow Style
Tyler Brown
@pelicanscarecrow
Aug 07 2016 02:55
@sjames1958gm thanks
CamperBot
@camperbot
Aug 07 2016 02:55
pelicanscarecrow sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: pelicanscarecrow already gave sjames1958gm points
FM
@mafelix
Aug 07 2016 02:57
can anyone explain why my table isn't clearing?
properly?
Stephen James
@sjames1958gm
Aug 07 2016 02:57
@asonder can you post the rest of the code?
Addy
@asonder
Aug 07 2016 02:58

function mutation(arr) {
var str1 = arrxamarin/xamarin-android@a16673d.toLowerCase();
var low2 = arr1.toLowerCase();
var str2 = low2.split("");
var i = 0;
while (str1.indexOf(str2[i])!== -1) {
i++;
}
return false;

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

Xihai Luo
@coolsday
Aug 07 2016 02:59
@coolsday
can someone help me with my weather API?
I am getting unsuccessful responses using AJAX to get my current position even though I had it working the other day
Addy
@asonder
Aug 07 2016 02:59
whoa, that is supposed to say "var str1 = arr[0].toLowerCase();"
Stephen James
@sjames1958gm
Aug 07 2016 02:59
@asonder Could you test whether i < str2.length?
@asonder You could use a for loop over str2 and return false if not found and return true after the loop meaning all are found
Addy
@asonder
Aug 07 2016 03:01
@sjames1958gm let me try both of those ideas right now.. i'll let you know
Stephen James
@sjames1958gm
Aug 07 2016 03:01
@coolsday Try connecting over http:// rather than https:// you cannot go to an http:// API from https
Xihai Luo
@coolsday
Aug 07 2016 03:02
@sjames1958gm im pretty sure im connecting over http
Stephen James
@sjames1958gm
Aug 07 2016 03:02
@coolsday You posted a link that is https:// ??
Xihai Luo
@coolsday
Aug 07 2016 03:03
@sjames1958gm thats my codepen for weather API
i was talking about JAX
AJAX
*
Stephen James
@sjames1958gm
Aug 07 2016 03:04
@coolsday Yes, that is what I am talking about if you connect to codepen over https:// you http:// APIs will not work.
jquery-2.2.4.min.js:4 Mixed Content: The page at 'https://codepen.io/coolsday/pen/JKaoxR?editors=1111' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://api.openweathermap.org/data/2.5/weather?lat=0&lon=0&APPID=26662c270f3e028c101f47bc3b54eda2'. This request has been blocked; the content must be served over HTTPS.
Xihai Luo
@coolsday
Aug 07 2016 03:04
@sjames1958gm ohh, ok thanks
CamperBot
@camperbot
Aug 07 2016 03:04
coolsday sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2385 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 07 2016 03:05
@coolsday :+1:
Abis Mal
@abisthecodermal
Aug 07 2016 03:05
thanks @stonefmagiecurata
CamperBot
@camperbot
Aug 07 2016 03:05
manucpp sends brownie points to @stonefmagiecurata :sparkles: :thumbsup: :sparkles:
:cookie: 291 | @stonefmagiecurata |http://www.freecodecamp.com/stonefmagiecurata
Tyler Brown
@pelicanscarecrow
Aug 07 2016 03:07
Does anyone else take notes?
huing
@huing
Aug 07 2016 03:08
blob
Addy
@asonder
Aug 07 2016 03:08
@sjames1958gm any thoughts on why this isn't working? i haven't tried the for loop yet. while (str1.indexOf(str2[i])!== -1) {
i++;
}
if (i < str2.length) { return true; }
else { return false;}
Stephen James
@sjames1958gm
Aug 07 2016 03:09
@asonder Is it failing specific tests?
@starhui Try [value] when hasOwnProperty is false.
Addy
@asonder
Aug 07 2016 03:10
it's failing all the tests that should return true.
Tyler Brown
@pelicanscarecrow
Aug 07 2016 03:11

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val){
case 1:
answer = "Apple";
break;
}

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

// Change this value to test
switchOfStuff(1);

Stephen James
@sjames1958gm
Aug 07 2016 03:11
@asonder That seems backwards. Should i be >= str2.length if all of str2 is in str1 (hope I have the correct challenge :)))
Tyler Brown
@pelicanscarecrow
Aug 07 2016 03:12
What needs to be changed? switchOfStuff("a") should have a value of "apple"?
Abis Mal
@abisthecodermal
Aug 07 2016 03:12
also hasOwnProperty is a check, so it returns true or false @starhui
Stephen James
@sjames1958gm
Aug 07 2016 03:13
@pelicanscarecrow Check your conditions, last challenge it was mapping numbers to strings, this time . . . (also make sure your case is correct "apple")
Tyler Brown
@pelicanscarecrow
Aug 07 2016 03:13
am I mapping strings to strings?
Stephen James
@sjames1958gm
Aug 07 2016 03:14
@pelicanscarecrow Yes
Joshua Johnson
@Blind-Playa
Aug 07 2016 03:14
Hey guys I need help with some basic algorithm stuff anyone up for it?
Stephen James
@sjames1958gm
Aug 07 2016 03:14
@Blind-Playa Ask away
Tyler Brown
@pelicanscarecrow
Aug 07 2016 03:14
@sjames1958gm okay, how would I go about that?
Switch(val) is correct right?
Stephen James
@sjames1958gm
Aug 07 2016 03:14
@pelicanscarecrow Instead of 1 put 'a'
Tyler Brown
@pelicanscarecrow
Aug 07 2016 03:15
I tried that, but I did not make it a string...... so close.
Stephen James
@sjames1958gm
Aug 07 2016 03:15
@pelicanscarecrow MIssed it by this much :)
@pelicanscarecrow Are you using chrome ?
Joshua Johnson
@Blind-Playa
Aug 07 2016 03:16
Im checking for palindromes and it tells me to remove special chars like %,^!. I have an idea on how to do this, but that would require making an object with all of the letters of the alphabet and number 0 through 9 so i think im wrong
Stephen James
@sjames1958gm
Aug 07 2016 03:16
@Blind-Playa Consider Regex and string .replace
pauoola
@pauoola
Aug 07 2016 03:16
@sjames1958gm is this what you mean if (checkProp = false); {
return "Not Found";
}
Joshua Johnson
@Blind-Playa
Aug 07 2016 03:17
okay, ive never used regex but i do know i have to use .replace() thanks!
Stephen James
@sjames1958gm
Aug 07 2016 03:17
@Blind-Playa :+1:
Joshua Johnson
@Blind-Playa
Aug 07 2016 03:17
oh wait yeah i have
regular expressions lol
Stephen James
@sjames1958gm
Aug 07 2016 03:18
@pauoola
if (myObj.hasOwnProperty(checkProp) {
  // return the value for checkProp on myObj
}
else {
  return "Not Found";
}
Tyler Brown
@pelicanscarecrow
Aug 07 2016 03:18
@sjames1958gm yes
Addy
@asonder
Aug 07 2016 03:18
@sjames1958gm you're right. i tried it using both > and < and accidentally pasted it as < in my message. Still not working, but i'm trying some different things. thanks for the help!
CamperBot
@camperbot
Aug 07 2016 03:18
asonder sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2386 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 07 2016 03:19
@pelicanscarecrow if on windows F12 will open the devtools including a console which will output errors that you don't see in the FCC console.
There are a number of videos later in the Map on devtools that I highly suggest you view
Xihai Luo
@coolsday
Aug 07 2016 03:20
hi, I am just wondering whats the purpose of using the document.ready function in JS?
abhilash
@abhimau5
Aug 07 2016 03:20
Hey friends, need help in Return Early Pattern for Functions
how will i get undefined in output
Stephen James
@sjames1958gm
Aug 07 2016 03:21
@coolsday If you are using js to manipulate HTML, waiting for document.ready ensures that the HTML is loaded prior to trying to modify it.
pauoola
@pauoola
Aug 07 2016 03:21
@sjames1958gm Thank you
CamperBot
@camperbot
Aug 07 2016 03:21
pauoola sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2387 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 07 2016 03:21
@pauoola :+1:
Joseph
@revisualize
Aug 07 2016 03:21
@sjames1958gm You're missing a ) in that if condition.
:P
Stephen James
@sjames1958gm
Aug 07 2016 03:22
@revisualize Ise confused
@abhimau5 return undefined;
abhilash
@abhimau5
Aug 07 2016 03:23
thanks @sjames1958gm
CamperBot
@camperbot
Aug 07 2016 03:23
abhimau5 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2388 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Suraj Prasad
@suraj18gts
Aug 07 2016 03:25
shall anybody tell
Modify the existing declarations and assignments so their names use camelCase
how can i modify the existing declaration
????
Stephen James
@sjames1958gm
Aug 07 2016 03:26
@suraj18gts The declarations are the three lines at the top and the assignments are the three at the bottom
Azlan Mukhtar
@azlan
Aug 07 2016 03:26
@coolsday to use API from codepen, you have to use service with https, ip-api.com doesn't prove https. So you have to find other service
Addy
@asonder
Aug 07 2016 03:26
FYI @sjames1958gm it wasn't working because i didn't have greater than OR equal to. Duh. Thanks again!
CamperBot
@camperbot
Aug 07 2016 03:26
asonder sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: asonder already gave sjames1958gm points
Stephen James
@sjames1958gm
Aug 07 2016 03:26
@asonder oops
Suraj Prasad
@suraj18gts
Aug 07 2016 03:27
ya but.....................
alhajit21
@alhajit21
Aug 07 2016 03:28
what steps I need to solve convert to Fahrenheit. I know I need a if statement but don't know what to put inside
Azlan Mukhtar
@azlan
Aug 07 2016 03:29
@alhajit21 just like normal arithmetic
Stephen James
@sjames1958gm
Aug 07 2016 03:29
@alhajit21 No if statement needed - take the formula and use the parameter celsius to convert the formula to code
alhajit21
@alhajit21
Aug 07 2016 03:30

@azlan // my code function convertToF(celsius) {
var fahrenheit = 122;
celsius=fahrenheit;
// Only change code below this line
if(celsius = fahrenheit){

// Only change code above this line
return fahrenheit;
}
}
// Change the inputs below to test your code
convertToF(50);

Azlan Mukhtar
@azlan
Aug 07 2016 03:30
@alhajit21 what is the formula?
Stephen James
@sjames1958gm
Aug 07 2016 03:30
@alhajit21 I would reset that code before continuing
Norvin Burrus
@ndburrus
Aug 07 2016 03:31
@alhajit21 The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.
we can rewrite the equation/formula to: Fahrenheit is (=) Celsius times() 9/5, plus (+) 32.
which is F = C
9/5 + 32,
or F = C(9/5) + 32.
Azlan Mukhtar
@azlan
Aug 07 2016 03:31
celsius=fahrenheit; here you make it Celsius equal to Fahrenheit
@alhajit21 your task here to convert the math formula into code
Tyler Brown
@pelicanscarecrow
Aug 07 2016 03:35

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

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

I am not sure about what is wrong about this code
alhajit21
@alhajit21
Aug 07 2016 03:36

// my code function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
celsius = 9*5+32;
celsius = fahrenheit;
// Only change code above this line
return fahrenheit;
}

// Change the inputs below to test your code
convertToF(30);

Azlan Mukhtar
@azlan
Aug 07 2016 03:37
celsius = 9*5+32; the value of the celsius in your code always same
Norvin Burrus
@ndburrus
Aug 07 2016 03:37
@alhajit21 we need F in the equation/code, here: celsius = 9*5+32; :sparkles:
1p2r3a
@1p2r3a
Aug 07 2016 03:37

// Example
var ourArray = ["Stimpson", "J", "cat"];
ourArray.shift(); // ourArray now equals ["J", "cat"]
ourArray.unshift("Happy");
// ourArray now equals ["Happy", "J", "cat"]

// Setup
var myArray = [["John", 23], ["dog", 3]];
myArray.shift();
myArray.unshift(["paul",35]);

can anyone find the erorr
i hope i done correctly
Azlan Mukhtar
@azlan
Aug 07 2016 03:38
@pelicanscarecrow the task doesn't want you to use if/else, look at the hint
Tyler Brown
@pelicanscarecrow
Aug 07 2016 03:38
I do see that.
Stephen James
@sjames1958gm
Aug 07 2016 03:38
@1p2r3a What is the answer supposed to be?
Tyler Brown
@pelicanscarecrow
Aug 07 2016 03:38
should I use switch?
Azlan Mukhtar
@azlan
Aug 07 2016 03:38
@pelicanscarecrow use single line boolean test
1p2r3a
@1p2r3a
Aug 07 2016 03:38
var myArray = [["paul", 35], ["dog", 3]];
this was the answer to be
Stephen James
@sjames1958gm
Aug 07 2016 03:39
@pelicanscarecrow You are supposed to convert the code similarly from the top box on the left to the bottom box
Juan Carlos Monsalve
@juancmonsalves
Aug 07 2016 03:39
Profile Lookup challenge was very difficult to me. It cost 2 hours to me..
Tyler Brown
@pelicanscarecrow
Aug 07 2016 03:40
Got it
Anna
@Anntol
Aug 07 2016 03:41
@1p2r3a are you sure paul, not Paul in task description?
Juan Carlos Monsalve
@juancmonsalves
Aug 07 2016 03:41
Working with objects and array is very complex to me.... :-1:
Greg Watson
@AeonBackflash
Aug 07 2016 03:42
I'm stuck on the record collection JS . I'm not sure what I've done wrong.
Stephen James
@sjames1958gm
Aug 07 2016 03:42
@1p2r3a Paul or paul?
Greg Watson
@AeonBackflash
Aug 07 2016 03:42
This is what I have so far...

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

return collection;
}

I think I've made a real mess of this.
Juan Carlos Monsalve
@juancmonsalves
Aug 07 2016 03:43
Same thing to me....
some hints: Use collection[id][prop] to access some value
Greg Watson
@AeonBackflash
Aug 07 2016 03:45
I like dot notation better, but it probably is what I'm doing wrong.
Azlan Mukhtar
@azlan
Aug 07 2016 03:46
dot notation easier to type :)
Juan Carlos Monsalve
@juancmonsalves
Aug 07 2016 03:46
If you want to add values to an array use collection[id][prop].push(value) when exist
Tyler Brown
@pelicanscarecrow
Aug 07 2016 03: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);

Juan Carlos Monsalve
@juancmonsalves
Aug 07 2016 03:47
and... collection[id][prop]=[value] when doesn't exists
Not sure what this lesson and the challenge have in common.
Julio Herrera
@julrom
Aug 07 2016 03:48
@AeonBackflash You can use dot notation instead of [], but when you want to refer variables pass as an arg you have to use [variableX]
Greg Watson
@AeonBackflash
Aug 07 2016 03:48
As soon as I did that, I satisfied a few of the conditions.
Azlan Mukhtar
@azlan
Aug 07 2016 03:48
@pelicanscarecrow in a function, you can exit it from multiple place
Greg Watson
@AeonBackflash
Aug 07 2016 03:49
@julrom Thanks!
CamperBot
@camperbot
Aug 07 2016 03:49
aeonbackflash sends brownie points to @julrom :sparkles: :thumbsup: :sparkles:
:cookie: 264 | @julrom |http://www.freecodecamp.com/julrom
Juan Carlos Monsalve
@juancmonsalves
Aug 07 2016 03:49

@AeonBackflash It was very difficult to me. Somebody helps me to...Read and try by yourself

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

return collection;
}

Tyler Brown
@pelicanscarecrow
Aug 07 2016 03:49
I get that, but how would I modify the function? @azlan
I dont understand how I would code this at all.
Joseph
@revisualize
Aug 07 2016 03:50
@juancmonsalves if(collection[id][prop]) { That part is not correct.
Azlan Mukhtar
@azlan
Aug 07 2016 03:51
@pelicanscarecrow the function asked for number, if someone give string as parameter, you dont want to process it, so you exit early and say something about the error
it's about control
Tyler Brown
@pelicanscarecrow
Aug 07 2016 03:52
Understood, but what would I type?
Juan Carlos Monsalve
@juancmonsalves
Aug 07 2016 03:52
@revisualize but It's works fine....
Brandon Bowers
@Bowers96
Aug 07 2016 03:53
Please help!

// Example
function ourRandomRange(ourMin, ourMax) {

  return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
}

ourRandomRange(1, 9);

// Only change code below this line.

function randomRange(myMin, myMax) {
    return Math.floor(Math.random() * (myMax - myMin)) + myMin; // Change this line
}
// Change these values to test your function
var myRandom = randomRange(5, 15);
The highest random number that can be generated by randomRange should be equal to your maximum number, myMax.
That is my error....
Tyler Brown
@pelicanscarecrow
Aug 07 2016 03:55

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

undefined (a<0);
undefined (b<0);

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

lol thats the smartest thing ive came up with and its obviously wrong.
Brandon Bowers
@Bowers96
Aug 07 2016 03:56
Anybody?
Joseph
@revisualize
Aug 07 2016 03:56
@juancmonsalves It should be using .hasOwnProperty
Juan Carlos Monsalve
@juancmonsalves
Aug 07 2016 03:57
@revisualize thanks
CamperBot
@camperbot
Aug 07 2016 03:57
juancmonsalves sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1557 | @revisualize |http://www.freecodecamp.com/revisualize
Brandon Bowers
@Bowers96
Aug 07 2016 03:57
// Example
function ourRandomRange(ourMin, ourMax) {

  return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
}

ourRandomRange(1, 9);

// Only change code below this line.

function randomRange(myMin, myMax) {
    return Math.floor(Math.random() * (myMax - myMin)) + myMin; // Change this line

}

// Change these values to test your function
var myRandom = randomRange(5, 15);
What am I missing guys?
The highest random number that can be generated by randomRange should be equal to your maximum number, myMax.
That is the only thing I am missing.
Azlan Mukhtar
@azlan
Aug 07 2016 03:58
@pelicanscarecrow your should test the value a and b, if one of them or both are negative, then just return undefined, no need to continue with the math functions
"Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined."
Abis Mal
@abisthecodermal
Aug 07 2016 03:58

guys, need your opinion


function sumAll(arr) {
  var sum=0;
  for (var i=Math.min(arr[0],arr[1]);i<=Math.max(arr[0],arr[1]);i++){
    sum+=i;
  }
  return sum;
}

sumAll([1, 4]);

How can I optimize it further?

Tyler Brown
@pelicanscarecrow
Aug 07 2016 03:58

// Setup
function abTest(a, b) {
// Only change code below this line
console.log(-a,-b);
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);

Joseph
@revisualize
Aug 07 2016 03:58
@manucpp Yes.
Tyler Brown
@pelicanscarecrow
Aug 07 2016 03:59
This did not work either.
Azlan Mukhtar
@azlan
Aug 07 2016 03:59
@pelicanscarecrow how to check if the value is negative?
Brandon Bowers
@Bowers96
Aug 07 2016 04:00
No help lol....
Got it anyways.
Tyler Brown
@pelicanscarecrow
Aug 07 2016 04:00
What would you type?? @azlan
console.log?
Abis Mal
@abisthecodermal
Aug 07 2016 04:00
The challenge asks me to use Array.prototype.reduce(). Where, how and why should I use it?
Tyler Brown
@pelicanscarecrow
Aug 07 2016 04:00
if?
Azlan Mukhtar
@azlan
Aug 07 2016 04:01
yes
Tyler Brown
@pelicanscarecrow
Aug 07 2016 04:01
if(a<0) return undefined
Joseph
@revisualize
Aug 07 2016 04:01
@manucpp You shouldn't.
@manucpp Are you trying to do Sum All Numbers in a Range?
Abis Mal
@abisthecodermal
Aug 07 2016 04:02
Yes :)
Joseph
@revisualize
Aug 07 2016 04:02
@manucpp Are you trying to optimize your code better? Cause it looks like your current code works.
Tyler Brown
@pelicanscarecrow
Aug 07 2016 04:02

// Setup
function abTest(a, b) {
// Only change code below this line
if (a<0||b<0){
return undefined;

}
// Only change code above this line

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

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

Azlan Mukhtar
@azlan
Aug 07 2016 04:02
@pelicanscarecrow yes, something like that
Tyler Brown
@pelicanscarecrow
Aug 07 2016 04:03
It worked though
Azlan Mukhtar
@azlan
Aug 07 2016 04:03
undefine is a keyword
Tyler Brown
@pelicanscarecrow
Aug 07 2016 04:03
I tried it alone it didnt work.
Azlan Mukhtar
@azlan
Aug 07 2016 04:03
This message was deleted
Tyler Brown
@pelicanscarecrow
Aug 07 2016 04:03
It worked with return
how would I declare?
Abis Mal
@abisthecodermal
Aug 07 2016 04:04
Yes it does @revisualize . But since this is my first time with code. I want to pick up good habits along the way
Azlan Mukhtar
@azlan
Aug 07 2016 04:04
i mean, it is uninteded
Joseph
@revisualize
Aug 07 2016 04:04
@manucpp okay.
@manucpp That's my code for the challenge. Including my refactors. From the bottom to the top.
Azlan Mukhtar
@azlan
Aug 07 2016 04:05
@pelicanscarecrow there u go
Abis Mal
@abisthecodermal
Aug 07 2016 04:05
@revisualize What's happening here?
const sumAll = ([x, y]) => (x + y) * (Math.abs(x - y) + 1) / 2;
Joseph
@revisualize
Aug 07 2016 04:06
@manucpp Math.
Azlan Mukhtar
@azlan
Aug 07 2016 04:06
oh man.. i was messed up
lol
it is undefined
i'm sorry @pelicanscarecrow for the confusion
Abis Mal
@abisthecodermal
Aug 07 2016 04:07
@azlan, I have been warned about usage of language mentioning there are 4 year olds here...
Azlan Mukhtar
@azlan
Aug 07 2016 04:07
ops..sorry again
Abis Mal
@abisthecodermal
Aug 07 2016 04:08
Its nice to see people flouting the rules though @azlan :)
Joseph
@revisualize
Aug 07 2016 04:08
You can edit posts. Within 10 minutes.
Abis Mal
@abisthecodermal
Aug 07 2016 04:08
@revisualize Please explain
Joseph
@revisualize
Aug 07 2016 04:08
@azlan Next to the time stamp there are ... you click that.
Azlan Mukhtar
@azlan
Aug 07 2016 04:08
edited
Tyler Brady
@tbrady85
Aug 07 2016 04:08

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

fahrenheit = (celsius(9/5))+32;

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

// Change the inputs below to test your code
convertToF(30);

my fahrenheit to celsius calculator is working properly. What am I doing wrong?
isnt working*
Coy Sanders
@coymeetsworld
Aug 07 2016 04:09
@tbrady85 thats because celsius isn't a function, its a variable
Ishaq Anuoluwapo
@anuoluwapo
Aug 07 2016 04:09

Please help!
I'm here again
cant really figure out what I am doing wrong

var bob = {
    firstName: "Bob",
    lastName: "Jones",
    phoneNumber: "(650) 777-7777",
    email: "bob.jones@example.com"
};

var mary = {
    firstName: "Mary",
    lastName: "Johnson",
    phoneNumber: "(650) 888-8888",
    email: "mary.johnson@example.com"
};

var contacts = [bob, mary];

function list() {
    var contactsLength = contacts.length;
    for (var i = 0; i <= contactsLength; i++) {
        console.log(contacts[i]);
    }
}
function search(lastName){
    for(var i = 0; i <= contacts.length; i++){
        if(contacts[i].lastName === lastName){
            console.log("Bob Jones");
            }
        }
    }
    console.log(search("Jones"));

    function add(firstname, lastname,  phonenumber, eMail){
        contacts[contacts.length] = {
             firstName: firstname,
             lastName: lastname,
             phoneNumber: phonenumber,
             email: eMail
           };
    }
    console.log(add("Anu", "OLuwapo",  "12355555", "alaja@eko.cc"));
    console.log(list());

I keep getting >contact[i] is not defined

Azlan Mukhtar
@azlan
Aug 07 2016 04:09
@tbrady85 the syntax (bracket) seems wrong
fix it just like in normal maths
Anna
@Anntol
Aug 07 2016 04:10
@tbrady85 add multiply in your formula
Joseph
@revisualize
Aug 07 2016 04:10
@tbrady85 You're not doing the multiplication part .
@Anntol :+1:
@manucpp It is just MATH.. Read the rest of my code. Geez.
@manucpp Or do you not understand arrow functions?
Chris Lacaille
@ChrisL108
Aug 07 2016 04:12
This message was deleted
Ishaq Anuoluwapo
@anuoluwapo
Aug 07 2016 04:12

Please help!
I'm here again
cant really figure out what I am doing wrong

var bob = {
    firstName: "Bob",
    lastName: "Jones",
    phoneNumber: "(650) 777-7777",
    email: "bob.jones@example.com"
};

var mary = {
    firstName: "Mary",
    lastName: "Johnson",
    phoneNumber: "(650) 888-8888",
    email: "mary.johnson@example.com"
};

var contacts = [bob, mary];

function list() {
    var contactsLength = contacts.length;
    for (var i = 0; i <= contactsLength; i++) {
        console.log(contacts[i]);
    }
}
function search(lastName){
    for(var i = 0; i <= contacts.length; i++){
        if(contacts[i].lastName === lastName){
            console.log("Bob Jones");
            }
        }
    }
    console.log(search("Jones"));

    function add(firstname, lastname,  phonenumber, eMail){
        contacts[contacts.length] = {
             firstName: firstname,
             lastName: lastname,
             phoneNumber: phonenumber,
             email: eMail
           };
    }
    console.log(add("Anu", "OLuwapo",  "12355555", "alaja@eko.cc"));
    console.log(list());

I keep getting >contact[i] is not defined

Joseph
@revisualize
Aug 07 2016 04:12
STOP SPAMMING!
Azlan Mukhtar
@azlan
Aug 07 2016 04:13
@anuoluwapo pls paste it on gist
Joseph
@revisualize
Aug 07 2016 04:13
@anuoluwapo You posted that code 3 minutes ago. We all saw it. You do NOT need to post it again.
Chris Lacaille
@ChrisL108
Aug 07 2016 04:13
If anyone sees my code lol
Azlan Mukhtar
@azlan
Aug 07 2016 04:13
if the code are long, pls use gist
Joseph
@revisualize
Aug 07 2016 04:14

@manucpp Let me try to explain arrow functions with two little blocks of text

function stringLength (str) {
   return str.length;
}

This code can also be written like this
const stringLength = (str) => str.length;

@anuoluwapo Which FreeCodeCamp.com lesson is that?
Ishaq Anuoluwapo
@anuoluwapo
Aug 07 2016 04:14
hi @revisualize pls help me or give me the link to gist
Joseph
@revisualize
Aug 07 2016 04:15
FreeCodeCamp/HelpJavaScript
Get help on our basic JavaScript and Algorithms Challenges. If you are posting code that is large use Gist - https://gist.github.com/ paste the link here.
@anuoluwapo Are you working on a FreeCodeCamp lesson?
Ken Haduch
@khaduch
Aug 07 2016 04:16
@tbrady85 - you just need to add the * to make it multiply in your equation - you have fahrenheit = (celsius(9/5))+32; You can eliminate the parentheses and write fahrenheit = celsius * 9/5 + 32; It seems that you are trying to use more of a mathematical notation, but that does not work with javascript (or programming languages in general)
Chris Lacaille
@ChrisL108
Aug 07 2016 04:16
Hey guys I am on Symmetric Difference in the algorithms and need help. My problem is taking the result of my first buildSymArray() run and using that value as a argument for another call.. Any advice? Here's the code....
https://gist.github.com/ChrisL108/3f2cb44f8e127dd3369a7b7e213b7fdd
still takes up the screen.. sry
Azlan Mukhtar
@azlan
Aug 07 2016 04:17
atleast we can collapse it
Joseph
@revisualize
Aug 07 2016 04:17
@ChrisL108 It's okay. We can type /collapse
Chris Lacaille
@ChrisL108
Aug 07 2016 04:17
ahh thanks for the pro-tip :smile:
Chris Cullen
@123xylem
Aug 07 2016 04:18
This message was deleted
Joseph
@revisualize
Aug 07 2016 04:18
@123xylem fail. :P
Chris Lacaille
@ChrisL108
Aug 07 2016 04:18
LOL
Puvendran Pillay
@puven12
Aug 07 2016 04:18
how do i do this array = [123, 456, 789]; to array= [321, 456, 987]; ?
Ishaq Anuoluwapo
@anuoluwapo
Aug 07 2016 04:18
shenshao
@shenshao
Aug 07 2016 04:19
so hungry! went to eat
Chris Cullen
@123xylem
Aug 07 2016 04:20
 function display(){}
  if(arr0[0]==arr1[0]&&arr0[1]==arr1[1]){
    answer.push(''+arr0[1]+' ' +arr0[2]+'" '+  ""+ arr1[2] +" "+ "");    //how do i make this display without backspace
  }

  display(total);

  return answer;
Can someone advise me how to make this function print correctly.? So far it says ["July 1st\" 23rd "] How do i remove the back space?
Ishaq Anuoluwapo
@anuoluwapo
Aug 07 2016 04:20
you can eat me but after you tell me what am doing wrong @shenshao
Azlan Mukhtar
@azlan
Aug 07 2016 04:22
@ChrisL108 your buildSymArray() is not flexible enough to take more that 2 set of arrays
Chris Lacaille
@ChrisL108
Aug 07 2016 04:23
@azlan Yeah I know, I had it in a for loop with buildSysArray(arguments[i], arguments[i-1]) but ran into problems with that as well
Abis Mal
@abisthecodermal
Aug 07 2016 04:24
@revisualize I do not understand arrow functions :(
Joseph
@revisualize
Aug 07 2016 04:25
@manucpp You do now.
Azlan Mukhtar
@azlan
Aug 07 2016 04:25
@ChrisL108 try to redesign the algo on paper first, how you want to do it
bradulz
@bradulz
Aug 07 2016 04:25
@123xylem what you said was confusing. How did you want it to end up?
Chris Lacaille
@ChrisL108
Aug 07 2016 04:25
@manucpp function(a, b) { return a + b; } turns into (a, b) => a + b;
Joseph
@revisualize
Aug 07 2016 04:25
@manucpp Google JS Arrow Functions
@ChrisL108 You're missing the const
bradulz
@bradulz
Aug 07 2016 04:26
without the whitespace or backslash @123xylem ?
Chris Cullen
@123xylem
Aug 07 2016 04:26
@bradulz backslash sorry
["July 1st " 23rd "] instead of ["July 1st\" 23rd "]
Chris Lacaille
@ChrisL108
Aug 07 2016 04:26
@revisualize what do you mean
Abis Mal
@abisthecodermal
Aug 07 2016 04:27

@manucpp Let me try to explain arrow functions with two little blocks of text

function stringLength (str) {
   return str.length;
}

This code can also be written like this
const stringLength = (str) => str.length;

Joseph
@revisualize
Aug 07 2016 04:27
@ChrisL108
function adder(a, b) { return a + b; } turns into const adder = (a, b) => a + b;
bradulz
@bradulz
Aug 07 2016 04:27
@123xylem Did the array have the backslash in it?
Abis Mal
@abisthecodermal
Aug 07 2016 04:27
Thanks @revisualize I have to read and re-read it to wrap my head around it, though
CamperBot
@camperbot
Aug 07 2016 04:27
manucpp sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1558 | @revisualize |http://www.freecodecamp.com/revisualize
bradulz
@bradulz
Aug 07 2016 04:28
does arr02 have a backslash at the end?
Chris Cullen
@123xylem
Aug 07 2016 04:28
@bradulz no i think its something to do with " ' "
Chris Lacaille
@ChrisL108
Aug 07 2016 04:28
@revisualize OH okay I was mistaken.. thought you were responding to earlier question
Joseph
@revisualize
Aug 07 2016 04:28
@manucpp Wrap your head around my solution or arrow functions?
Chris Cullen
@123xylem
Aug 07 2016 04:28
it coud be cancelling the symbol like regex style
Chris Lacaille
@ChrisL108
Aug 07 2016 04:29
@revisualize But i did not know you needed the const.. I've only used in callbacks such as reduce()
Abis Mal
@abisthecodermal
Aug 07 2016 04:29
arrow functions. You solution needs deciphering after I reach a certain programming level. Like a level gazillion warlord or something :) @revisualize
bradulz
@bradulz
Aug 07 2016 04:29
hmm it looks fine to me. what does (''+arr0[1]+' ' +arr0[2]+'\" '+ ""+ arr1[2] +" "+ "") give?
do you wanna give me the whole code and ill tinker with it?
@123xylem
Chris Cullen
@123xylem
Aug 07 2016 04:30
@bradulz yes thanks
CamperBot
@camperbot
Aug 07 2016 04:30
123xylem sends brownie points to @bradulz :sparkles: :thumbsup: :sparkles:
:cookie: 308 | @bradulz |http://www.freecodecamp.com/bradulz
Joseph
@revisualize
Aug 07 2016 04:30
@manucpp Awe.. You think I'm that smart? Really? Cause I feel like a dumb shit all the time.
Ishaq Anuoluwapo
@anuoluwapo
Aug 07 2016 04:31
pls help check for what is wrong with my code https://gist.github.com/anuoluwapo/5848ed628f8bd827ec5da4aec3fc6d4b
Joseph
@revisualize
Aug 07 2016 04:32
@anuoluwapo www.pythontutor.com .. How about you use this to visualize your code.
@anuoluwapo Which FreeCodeCamp.com lesson are you working on?
Chris Lacaille
@ChrisL108
Aug 07 2016 04:33
@revisualize :thumbsup: that works well for visualizing simple for loops and such
bradulz
@bradulz
Aug 07 2016 04:34
@anuoluwapo (var i = 0; i <= contactsLength; i++) should be (var i = 0; i < contactsLength; i++)
Ishaq Anuoluwapo
@anuoluwapo
Aug 07 2016 04:35
am just practicing on my own
Tim
@x-yz
Aug 07 2016 04:36
how come NaN doesnt == NaN in array.filter()?
Joseph
@revisualize
Aug 07 2016 04:37
@x-yz Because it doesn't.
bradulz
@bradulz
Aug 07 2016 04:37
lol
Joseph
@revisualize
Aug 07 2016 04:37
@anuoluwapo Why aren't you doing array.push( { ...object... } );
OOOOHHHHHH! I like this song.
AFK
Tim
@x-yz
Aug 07 2016 04:39
does NaN == NaN always return false?
Joseph
@revisualize
Aug 07 2016 04:39
Does it?
@x-yz Okay. I'll stop being an ass. Yes it does.
@x-yz
blob
@x-yz Are you trying to do Falsy Bouncer?
Ken Haduch
@khaduch
Aug 07 2016 04:41
@x-yz - yes, kind of strange, but that's how it works. I reckoned that if you have two things that are NaN, you have no way to know that they are equal... made sense to me when I thought about it that way.
Tim
@x-yz
Aug 07 2016 04:43
yeah
so i have to use isNaN() but im gonna get false positives on all the strings i reckon
Joseph
@revisualize
Aug 07 2016 04:45
@x-yz No.
@x-yz You have to use Boolean
@x-yz Clearly you understand how filter works.
bradulz
@bradulz
Aug 07 2016 04:45
@123xylem
Puvendran Pillay
@puven12
Aug 07 2016 04:46
https://kobra.io/#/e/-KOYILLpJL6_cIwIfeEI i need help with this code
Ismael Sanchez
@sanchez1179
Aug 07 2016 04:49
var Bike = function() {

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

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

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

};

var myCar = new Car();

var myBike = new Bike();
Can anyone help me and tell me why my set gear is not working . I need it to change the gear number and set the gear number. It's the "Make Object Properties Private" challenge
Tim
@x-yz
Aug 07 2016 04:49
ok so everything that im supposed to filter if passed to a boolean returns false?
Joseph
@revisualize
Aug 07 2016 04:51
@x-yz a boolean vs Boolean
Ken Haduch
@khaduch
Aug 07 2016 04:51
@sanchez1179 - If I remember correctly, you have to set the gear, not add - so you should be changing the value of gear, as in gear = something... what you are doing is adding a value to the function argument move, and that does not change the value of gear at all...
Joseph
@revisualize
Aug 07 2016 04:52
@x-yz https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean
Do not confuse the primitive Boolean values true and false with the true and false values of the Boolean object.
@x-yz The challenge is just 1 line of code.
Ismael Sanchez
@sanchez1179
Aug 07 2016 04:54
@khaduch Thank you sir that solved my issue
CamperBot
@camperbot
Aug 07 2016 04:54
sanchez1179 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1517 | @khaduch |http://www.freecodecamp.com/khaduch
Tim
@x-yz
Aug 07 2016 04:54
one line :(
Joseph
@revisualize
Aug 07 2016 04:54
@x-yz Yeah.. A return statement.
Ken Haduch
@khaduch
Aug 07 2016 04:55
@sanchez1179 :+1: great - good luck!
Tim
@x-yz
Aug 07 2016 04:55
''' arr = arr.filter(function(elem) {
return Boolean(elem);
});
return arr;'''
CamperBot
@camperbot
Aug 07 2016 04:55
:bulb: to format code use backticks! ``` more info
Tim
@x-yz
Aug 07 2016 04:55
arr = arr.filter(function(elem) { return Boolean(elem); }); return arr;
Joseph
@revisualize
Aug 07 2016 04:56
@x-yz Even shorter if you use Boolean
arr.filter(Boolean);
Tim
@x-yz
Aug 07 2016 04:58
wow lol
Joseph
@revisualize
Aug 07 2016 04:59
Sometimes the helpful links are helpful.
Tim
@x-yz
Aug 07 2016 04:59
yeah i guess so
thanks @revisualize
CamperBot
@camperbot
Aug 07 2016 04:59
x-yz sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1560 | @revisualize |http://www.freecodecamp.com/revisualize
Tim
@x-yz
Aug 07 2016 05:01
so next question... can i upload .json files to codepen.io?
or if not is there a good place to stash em? im doing the quote generator thing and i may as well use json
ajax*
Abis Mal
@abisthecodermal
Aug 07 2016 05:09

no one gets 1500+ streaks just like that @revisualize

@manucpp Awe.. You think I'm that smart? Really? Cause I feel like a dumb shit all the time.

Chris Lacaille
@ChrisL108
Aug 07 2016 05:14
Would using regEx to get rid of duplicates in a Array be feasible/good practice?
I know I could use a for loop or something but trying to accomplish this with something like replace(/([0-9]{2})/g, "")... which gets 2 numbers but not 2 'matching' numbers
stonefmagiecurata
@stonefmagiecurata
Aug 07 2016 05:16
@ChrisL108 use indexOf and lastIndexOf to check if the 2 are equal, if they are then there's only one of the elem in the array
Chad Powell
@cjpowellaz
Aug 07 2016 05:24
I am currently working on the "Check for Palindromes" challenge and I cannot get my two statements to work together to remove non-alphanumeric characters and set to lower case. Here is my code:

function palindrome(str) {
// Good luck!

var newStr;
newStr = str.replace(/[^0-9a-zA-Z]/g, "");
str.toLowerCase();
return newStr;

//return true;
}
palindrome("EY3 B@L!");

I can either get it to remove non-alphanumeric or set to lower case, but not both
Chris Lacaille
@ChrisL108
Aug 07 2016 05:26
@cjpowellaz newStr.toLowerCase()? instead of str.toLowerCase() maybe
Diego Mayer
@Chrono79
Aug 07 2016 05:26
@cjpowellaz str.toLowerCase();this does nothing, and why your return newStr?
You need to assign str.toLowerCase(); to str for instance
Chris Cullen
@123xylem
Aug 07 2016 05:26
@khaduch did you figure it out?
I think its some kind of regex thing wheer they cancel the previous symbol
Chris Lacaille
@ChrisL108
Aug 07 2016 05:27
This is a great regEx testing/reference source btw... http://regexr.com/
Chad Powell
@cjpowellaz
Aug 07 2016 05:27
I am returning the newStr to test if parts of the code are working, in the final version it returns true or false
Joseph
@revisualize
Aug 07 2016 05:30
@Chrono79 So, I finally did it.. I finally moved all of the significant lessons over to Github. :D
Chris Lacaille
@ChrisL108
Aug 07 2016 05:31
@revisualize I need to do this.. easier for recruiters and potential hiring companies to see
Joseph
@revisualize
Aug 07 2016 05:31
Though, I do want to redo Title Case a Sentence with more regex. Instead of the sloppy mess that I've made.
@ChrisL108 You do.
Christian
@Neralizer
Aug 07 2016 05:32
need help with basic algorithm, factorializing numbers
```
Joseph
@revisualize
Aug 07 2016 05:32
@Neralizer 5! = 120
Christian
@Neralizer
Aug 07 2016 05:32
function factorialize(num) {
  var factor = [];
  var sum = [];
  for (var i = 1; i <= num; i++){
    factor = num * i;
    sum = factor + num;
  }
  return sum;
}

factorialize(5);
haha I get the math of it
am I doing too much?
Joseph
@revisualize
Aug 07 2016 05:32
Yes.
@Neralizer Yes. You're doing too much and not enough.
Christian
@Neralizer
Aug 07 2016 05:33
am I way off with for loops?
Joseph
@revisualize
Aug 07 2016 05:33
You could use a for loop. I did the first time.
Chad Powell
@cjpowellaz
Aug 07 2016 05:33
I got this to work:

function palindrome(str) {
// Good luck!

str = str.replace(/[^0-9a-zA-Z]/g, "");
str = str.toLowerCase();

return str;

//return true;
}

palindrome("eye");

now to get it to return True or False
Joseph
@revisualize
Aug 07 2016 05:34
@Neralizer For 5! you're supposed to do 1*2*3*4*5 = 120
Christian
@Neralizer
Aug 07 2016 05:34
so if I'm sticking with the for loop, logically I'm saying, when i is between 1 and the number, increase by one
and then multiply the number by i
and then add all of those together
Joseph
@revisualize
Aug 07 2016 05:35
That's a mess.
Christian
@Neralizer
Aug 07 2016 05:35
right?
Abis Mal
@abisthecodermal
Aug 07 2016 05:35
How about now? @revisualize

function sumAll(arr) {
  var sum=0;
  var min=Math.min(arr[0],arr[1]);
  var max=Math.max(arr[0],arr[1]);

 //use 'some of series' formula n*(n+1)/2... where n is upper limit and 1 is lower.

  //Sum from a to b where b>a is

  //(sum of 1 to b)-(sum of 1 to (a-1))*/

  min-=1;

  return ((max*(max+1)/2)-(min*(min+1)/2));
}

sumAll([5,10]);
Joseph
@revisualize
Aug 07 2016 05:35
Make it simple
Christian
@Neralizer
Aug 07 2016 05:35
okay
Joseph
@revisualize
Aug 07 2016 05:35
@manucpp Ummm.. What?
Christian
@Neralizer
Aug 07 2016 05:35
i need to take all the numbers leading up to the number being factorialized
Chris Lacaille
@ChrisL108
Aug 07 2016 05:35
:sparkles: :clap: <-- when you finally beat an advanced algorithm without using anyone else's code snippets
Christian
@Neralizer
Aug 07 2016 05:36
and multiply them by the number being factorialized
and add them altogether
Joseph
@revisualize
Aug 07 2016 05:36
@Neralizer Why are you adding?
There is no freaking + in this statement.
For 5! you're supposed to do 1*2*3*4*5 = 120
Christian
@Neralizer
Aug 07 2016 05:36
hahaha brutal
okay
ah
okay
Chris Lacaille
@ChrisL108
Aug 07 2016 05:36
LOL
Joseph
@revisualize
Aug 07 2016 05:37
Sorry. But, I said that already.
Christian
@Neralizer
Aug 07 2016 05:38
haha no I remember
Joseph
@revisualize
Aug 07 2016 05:38
@manucpp I don't think that's correct.
Christian
@Neralizer
Aug 07 2016 05:38
so is it for (var i = 1; i <= num; i * num)?
Abis Mal
@abisthecodermal
Aug 07 2016 05:38
I used math. Why not? @revisualize
Joseph
@revisualize
Aug 07 2016 05:39
I'm looking.
Christian
@Neralizer
Aug 07 2016 05:39
if so, I'm struggling with the command after the for statement
Abis Mal
@abisthecodermal
Aug 07 2016 05:40
The code works. I am more concerned about the algorithm... the logic
Joseph
@revisualize
Aug 07 2016 05:40
@Neralizer multiplication?
Christian
@Neralizer
Aug 07 2016 05:41
like, why am I using multiplication? or, why don't I try multiplication?
Joseph
@revisualize
Aug 07 2016 05:41
@manucpp
function sumAll(arr) {
  var min = Math.min(arr[0],arr[1]);
  var max = Math.max(arr[0],arr[1]);
  return ((max*(max+1)/2)-(min*(min-1)/2));
}

sumAll([5,10]);
Christian
@Neralizer
Aug 07 2016 05:42
function factorialize(num) {
  var factor = [];
  var sum = [];
  for (var i = 1; i <= num; i++){
    factor = num * i;
  }
  return factor;
}

factorialize(5);
Joseph
@revisualize
Aug 07 2016 05:42
@Neralizer In math 5! is 1*2*3*4*5 = 120
Chris Lacaille
@ChrisL108
Aug 07 2016 05:42
Isn't 'let' (instead of var) supported on all current browsers at this point?
Joseph
@revisualize
Aug 07 2016 05:42
@Neralizer You keep overwriting factor
Abis Mal
@abisthecodermal
Aug 07 2016 05:42
@revisualize
damn! The cancellation of ones. The cons of not using a pen and paper for math...
Thanks @revisualize
CamperBot
@camperbot
Aug 07 2016 05:43
manucpp sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1561 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 07 2016 05:44
@Neralizer Kill this line: var sum = [];
@Neralizer Change this line: var factor = []; to var factor = 1;
@Neralizer Change this line: factor = num * i;
Christian
@Neralizer
Aug 07 2016 05:45
but don't I want to multiply the num * i if it's all the numbers leading up to num?
Joseph
@revisualize
Aug 07 2016 05:45
@Neralizer No.
@Neralizer 5! is 1*2*3*4*5 = 120
i becomes ... 1, 2, 3, 4, 5
Christian
@Neralizer
Aug 07 2016 05:47
right
Joseph
@revisualize
Aug 07 2016 05:47
Because of the... i <= num logic
Christian
@Neralizer
Aug 07 2016 05:47
so... i multiply i by itself?
Joseph
@revisualize
Aug 07 2016 05:47
No.
Christian
@Neralizer
Aug 07 2016 05:47
okay, but we're getting somewhere!
Joseph
@revisualize
Aug 07 2016 05:47
If factor is 1 and i is 1
What happens when you multiply them together?
Abis Mal
@abisthecodermal
Aug 07 2016 05:48
ah! the factorial. @Neralizer
Christian
@Neralizer
Aug 07 2016 05:48
you get 1
LittleBoiTien
@LittleBoiTien
Aug 07 2016 05:48
Hi guys, can someone confirm for me if this is a bug? Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"
Joseph
@revisualize
Aug 07 2016 05:48
Then when i becomes 2 what happens if you multiply factor with i?
Christian
@Neralizer
Aug 07 2016 05:48
2
Joseph
@revisualize
Aug 07 2016 05:48
Then when i becomes 3 what happens if you multiply factor with i?
Then when i becomes 4 what happens if you multiply factor with i?
Christian
@Neralizer
Aug 07 2016 05:49
okay
Joseph
@revisualize
Aug 07 2016 05:49
Then when i becomes 5 what happens if you multiply factor with i?
Christian
@Neralizer
Aug 07 2016 05:49
345
Joseph
@revisualize
Aug 07 2016 05:49
No.
120
Christian
@Neralizer
Aug 07 2016 05:49
if factor is 1
and i is 5
Joseph
@revisualize
Aug 07 2016 05:50
1*2*3*4*5 is 120
Christian
@Neralizer
Aug 07 2016 05:50
then 5 times 1 is 5
Joseph
@revisualize
Aug 07 2016 05:50
Look at the sequence
bitgrower
@bitgrower
Aug 07 2016 05:50
This message was deleted
hey @revisualize
Christian
@Neralizer
Aug 07 2016 05:50
okay, I'm with you now
Joseph
@revisualize
Aug 07 2016 05:50
If factor is 1 and i is 1
What happens when you multiply them together?
Then when i becomes 2 what happens if you multiply factor with i?
Then when i becomes 3 what happens if you multiply factor with i?
Then when i becomes 4 what happens if you multiply factor with i?
Then when i becomes 5 what happens if you multiply factor with i?
1*2*3*4*5 is 120
@bitgrower hi
Christian
@Neralizer
Aug 07 2016 05:51
i see it now
Joseph
@revisualize
Aug 07 2016 05:51
Cause you're doing factor = ... Which is overwriting factor at the end.
You don't want to overwrite factor.
You want to use it.
You have a for statement for a reason.
Christian
@Neralizer
Aug 07 2016 05:52
so I want to return factor?
here's what I have now

function factorialize(num) {
  var factor = 1;
  for (var i = 1; i <= num; i++){
    num = factor * i;
  }
  return factor;
}

factorialize(5);
i had it returning num
Joseph
@revisualize
Aug 07 2016 05:52
@Neralizer NO.
@Neralizer You just created an infinite loop
Chris Cullen
@123xylem
Aug 07 2016 05:52
if(arr0[0]==arr1[0]&&arr0[1]==arr1[1]){
    answer.push(''+arr0[1]+' ' +arr0[2                                 ]+'" '+                        ""+ arr1[2] +" "+ "");    //how do i make this display without backspace
  }
THis outputs what i want but the bit in the middle creates a backslash, like it was regex cancelling the previous symbol.. how do i stop th ebackslash showing?
Joseph
@revisualize
Aug 07 2016 05:53
@Neralizer num should not change.
You need that to stay static.
bitgrower
@bitgrower
Aug 07 2016 05:53
@Neralizer .. factorialize is one of the easiest ways to learn recursion ... :)
Joseph
@revisualize
Aug 07 2016 05:54
@bitgrower Agreed.
First I think you need to solve it this way. Then yo can see how / why recursion works best.
If factor is 1 and i is 1
What happens when you multiply them together?
Then when i becomes 2 what happens if you multiply factor with i?
Then when i becomes 3 what happens if you multiply factor with i?
Then when i becomes 4 what happens if you multiply factor with i?
Then when i becomes 5 what happens if you multiply factor with i?
@Neralizer
Christian
@Neralizer
Aug 07 2016 05:55
i see that, I need to multiply factor and i
bitgrower
@bitgrower
Aug 07 2016 05:56
@123xylem which challenge are you working on ... ?
Joseph
@revisualize
Aug 07 2016 05:56
Do you remember doing this
var num = 5;
num = num + 1; // 6
num += 1; // 7
num++; // 8
Christian
@Neralizer
Aug 07 2016 05:57
yeah, what challenge is that
Joseph
@revisualize
Aug 07 2016 05:57
@Neralizer It was a long time ago. And it was multiple challenges.
What happens if you do multiplication instead?
And maybe change 1 to i and num to factor ??? HINT HINT!
You know... Math stuff.
Math is good. Learn math.
factor *= i
You know...
If factor is 1 and i is 1
What happens when you multiply them together?
Then when i becomes 2 what happens if you multiply factor with i?
Then when i becomes 3 what happens if you multiply factor with i?
Then when i becomes 4 what happens if you multiply factor with i?
Then when i becomes 5 what happens if you multiply factor with i?
Chris Cullen
@123xylem
Aug 07 2016 05:58
@bitgrower friednly date range 322
Joseph
@revisualize
Aug 07 2016 05:59
Because 1*2*3*4*5 = 120
bitgrower
@bitgrower
Aug 07 2016 05:59

ahhhhh ... that'a s tough one ... :)

(as in: I haven't completed it yet .... I itemized a ton of test cases, had some code in progress ... then they did one of the FCC revamps and I lost my code ... :(

Rahul Nayak
@pragyes31
Aug 07 2016 06:00
Hi, trying to reverse the string with conventional for loops. But the code is not running as expected. can anyone point out the mistake ?
revisualize @revisualize is afk. Need to pull clothes out the dryer.
bitgrower
@bitgrower
Aug 07 2016 06:00
@Neralizer -- throw your code in this javscript playground and you can watch what happens: pythontutor.com/javascript.html
Rahul Nayak
@pragyes31
Aug 07 2016 06:00

function reverseString(str) {
  var newStr="";
  for (var i=str.length-1; i<0; i++) {
    newStr = newStr + str.charAt(i);
  }
  return newStr;
}
reverseString("hello");
Joseph
@revisualize
Aug 07 2016 06:00
@pragyes31 Why are you trying to do that!?
That sucks.
just use the methods.
But okay.
Rahul Nayak
@pragyes31
Aug 07 2016 06:01
@revisualize it does but when I go to interviews, they ask me if I can do it with loops
Joseph
@revisualize
Aug 07 2016 06:01
@pragyes31 www.pythontutor.com ... Visualize your code execution.
I'd be an ass and tell them.. "I'm lazy and I'd rather use stuff built into JavaScript."
Chris Cullen
@123xylem
Aug 07 2016 06:01

@bitgrower


function makeFriendlyDates(arr) {

  var arr0 =arr.shift();//create first date
 arr0= arr0.split("-");

  var arr1=arr.pop();//second date
  arr1=arr1.split("-");
  var answer=[];

  switch (arr0[1]) { //For each case convert them to months
    case "01":
        arr0[1] = "Janurary";
        break;
    case "02":
        arr0[1] = "February";
        break;
    case "03":
        arr0[1] = "March";
        break;
    case "04":
       arr0[1] = "April";
        break;
    case "05":
        arr0[1] = "May";
        break;
    case "06":
        arr0[1] = "June";
        break;
    case "07":
       arr0[1] = "July";
     break;
   case "08":
     arr0[1] ="August";
     break;

   case "09":
     arr0[1] ="September";
     break;

   case "10":
     arr0[1] ="October";
     break;

   case "11":
     arr0[1] ="November";
     break;

   case "12":
     arr0[1] ="December";
     break;


}switch (arr0[2]) { //Then for each day date convert to days. adding appropruate suffix
      case "01":
      case "21":
      case "31":
         arr0[2] =parseInt(arr0[2])+ 'st';
    break;
      case "02":
      case "22":
         arr0[2] =parseInt(arr0[2])+'nd';
    break;
      case "03":
      case "23":
         arr0[2] =parseInt(arr0[2])+ 'rd';
    break;
      default:                                 //With this default that adds "th"
         arr0[2] =parseInt(arr0[2])+ 'th';
    break;
    }            // FIRST DATES


    //Here starts THE SECOND DATEs Conversion------------------------------------------------------    

 switch (arr1[1]) {
    case "01":
        arr1[1] = "January";
        break;
    case "02":
        arr1[1]= "February";
        break;
    case "03":
        arr1[1] = "March";
        break;
    case "04":
       arr1[1] = "April";
        break;
    case "05":
       arr1[1] = "May";
        break;
    case "06":
       arr1[1] = "June";
        break;
    case "07":
       arr1[1] = "July";
     break;
   case "08":
     arr1[1] ="August";
     break;

   case "09":
    arr1[1] ="September";
     break;

   case "10":
     arr1[1] ="October";
     break;

   case "11":
arr1[1] ="November";
     break;

   case "12":
     arr1[1] ="December";
     break;


}switch (arr1[2]) {
      case "01":
      case "21":
      case "31":
         arr1[2] =parseInt(arr1[2])+ 'st';
    break;
      case "02":
      case "22":
         arr1[2] =parseInt(arr1[2])+'nd';
    break;
      case "03":
      case "23":
         arr1[2] =parseInt(arr1[2])+ 'rd';
    break;
      default:
         arr1[2] =parseInt(arr1[2])+ 'th';
    break;

  }

  var arrAns=[];
  var total=[];

   for(i=0;i<arr0.length;i++){//push arr0 into total
    total.push(arr0[i]);}
  for(j=0;j<arr1.length;j++){ // and push arr1
    total.push(arr1[j]);
  }    console.log(total.length);

  function display(){    // function that pushes data into array in a specific display format
  if(arr0[0]==arr1[0]&&arr0[1]==arr1[1]){
    answer.push(''+arr0[1]+' ' +arr0[2]+''+'"'+","+" "+  ""+ arr1[2] +" "+ ""); }
else if(arr0[0]==arr1[0]){
   answer.push(''+arr0[1]+' ' +arr0[2]+''+'"'+","+" "+  ""+ arr1[1] +" "+ arr1[2]+ "'");
}  
    else { answer.push(''+arr0[2]+" " +arr0[1]+' ' +arr0[0]+''+'"'+","+" "+  ""+ arr1[1] +" "+ arr1[2]+" "+ arr1[0] +"");}
  }
  display(total);

  return answer;

}
  makeFriendlyDates(['2014-07-01', '2016-07-23']);

This is working but it just shows a backslash after my first dates " ( i think as some kind of regex thing... ... I m so close to finishing .. DO you know how i can get it to output without the slash or can i just remove it after with some kind of method?

Joseph
@revisualize
Aug 07 2016 06:02
@123xylem
Get help on our basic JavaScript and Algorithms Challenges. If you are posting code that is large use Gist - https://gist.github.com/ paste the link here.
Get help on our basic JavaScript and Algorithms Challenges. If you are posting code that is large use Gist - https://gist.github.com/ paste the link here.
GEEZ!
@123xylem @123xylem @123xylem -------^^^^
Please!
Chris Cullen
@123xylem
Aug 07 2016 06:03
@revisualize @revisualize @revisualize ok dude
@revisualize how do i use it?
Rahul Nayak
@pragyes31
Aug 07 2016 06:04
@revisualize they will show me the door if I tell them that. :P
bitgrower
@bitgrower
Aug 07 2016 06:04
@123xylem No, sorry ... and, since I haven't solved it, I'm not gonna look at what you've done ... sorry ..
Ishaq Anuoluwapo
@anuoluwapo
Aug 07 2016 06:05
var bob = {
    firstName: "Bob",
    lastName: "Jones",
    phoneNumber: "(650) 777-7777",
    email: "bob.jones@example.com"
};

var mary = {
    firstName: "Mary",
    lastName: "Johnson",
    phoneNumber: "(650) 888-8888",
    email: "mary.johnson@example.com"
};

var contacts = [bob, mary];

var list = function(obj){
    for (var i = 0; i < obj.length; i++) {
        console.log(obj[i]);
    }
}
list(contacts)

gives me

Object { firstName: "Bob", lastName: "Jones", phoneNumber: "(650) 777-7777", email: "bob.jones@example.com" }
Object { firstName: "Mary", lastName: "Johnson", phoneNumber: "(650) 888-8888", email: "mary.johnson@example.com" }
undefined
can anyone tell me why?

Christian
@Neralizer
Aug 07 2016 06:05
alright @revisualize
here's where I'm at
get prepared to type no at me
function factorialize(num) {
  var factor = 1;
  for (var i = 1; i <= num; i++){
    num = factor * i;
  }
  return num;
}

factorialize(5);
Joseph
@revisualize
Aug 07 2016 06:06
No.
@Neralizer Do you like infinite loops?
Christian
@Neralizer
Aug 07 2016 06:06
i do, actually
no of course not
Joseph
@revisualize
Aug 07 2016 06:07

@Neralizer

If factor is 1 and i is 1
What happens when you multiply them together?
Then when i becomes 2 what happens if you multiply factor with i?
Then when i becomes 3 what happens if you multiply factor with i?
Then when i becomes 4 what happens if you multiply factor with i?
Then when i becomes 5 what happens if you multiply factor with i?

Christian
@Neralizer
Aug 07 2016 06:07
I'm not getting an infinite loop, I'm getting one
revisualize @revisualize looks through that quote and looks for the usage of num anywhere.
Christian
@Neralizer
Aug 07 2016 06:07
i have factor set to multiply by i
1p2r3a
@1p2r3a
Aug 07 2016 06:08
var myList = [["Chocolate Bar",15],["Ice Cream",23],["Biscuits,12"],["Jokes",32],["Ball",11]];
the error is second elements in each of your sub arrays must all be numbes
Christian
@Neralizer
Aug 07 2016 06:08
and i don't get why it's not working out
1p2r3a
@1p2r3a
Aug 07 2016 06:08
numbers
Matthew Hand
@mmhand123
Aug 07 2016 06:08
factor doesnt change when you set num equal to factor * i
bitgrower
@bitgrower
Aug 07 2016 06:08
@1p2r3a what's the challenge ?
Matthew Hand
@mmhand123
Aug 07 2016 06:08
it stays 1 the whole time
Christian
@Neralizer
Aug 07 2016 06:08
right, but i does
Joseph
@revisualize
Aug 07 2016 06:09

@Neralizer

  var factor = 1;
  for (var i = 1; i <= num; i++){
    num = factor * i;
  }

if num keeps growing.. Doesn't that make it an infinite loop?

Christian
@Neralizer
Aug 07 2016 06:09
i changes from 1 to the number being factorialized
1p2r3a
@1p2r3a
Aug 07 2016 06:09

Create a shopping list in the variable myList. The list should be a multi-dimensional array containing several sub-arrays.

The first element in each sub-array should contain a string with the name of the item. The second element should be a number representing the quantity i.e.

["Chocolate Bar", 15]

There should be at least 5 sub-arrays in the list.

@bitgrower
Joseph
@revisualize
Aug 07 2016 06:09
@Neralizer OH I see.
Matthew Hand
@mmhand123
Aug 07 2016 06:09
the loop is set to end if i <= num, when you go through the loop one time you set num equal to factor (which is 1) x i, making num = i and breaking the loop
Christian
@Neralizer
Aug 07 2016 06:09
so do you want me to come up with a new variable?
bitgrower
@bitgrower
Aug 07 2016 06:09
is this an FCC challenge @1p2r3a ?
1p2r3a
@1p2r3a
Aug 07 2016 06:10
yes
Joseph
@revisualize
Aug 07 2016 06:10
@Neralizer So, Num = 1 * 1 and 1 ... Then i becomes 2 which is greater than 1.
@Neralizer No. I want you to actually use factor like I've said multiple times.

@Neralizer

If factor is 1 and i is 1
What happens when you multiply them together?
Then when i becomes 2 what happens if you multiply factor with i?
Then when i becomes 3 what happens if you multiply factor with i?
Then when i becomes 4 what happens if you multiply factor with i?
Then when i becomes 5 what happens if you multiply factor with i?

factor *= i
bitgrower
@bitgrower
Aug 07 2016 06:10
@Neralizer num is a parameter being passed to you , you really shouldn't be changing it ... :)
Use i & factor ...
@1p2r3a what is the name of the challenge ?
1p2r3a
@1p2r3a
Aug 07 2016 06:11
shopping list
Gaurav Tolani
@Gauravtolani
Aug 07 2016 06:11
can anyone help in ceasar cipher..
?

function rot13(str) { // LBH QVQ VG!
  var String = str;
  for(var i=0;i<String.length;i++){
    if(String.charCodeAt(i)==32){

    }
    else{
     var r = String.charCodeAt(i);
      String[i] = String.fromCharCode(r+13);
    }
  }
  return String;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
I am getting an error... String.fromCharCode is not a function..
Joseph
@revisualize
Aug 07 2016 06:13
@Gauravtolani Correct.
Christian
@Neralizer
Aug 07 2016 06:13
oh my gosh we did it
1p2r3a
@1p2r3a
Aug 07 2016 06:13
anyone find the error
Christian
@Neralizer
Aug 07 2016 06:13
what was that *= operator?
I feel like I haven't looked at that in forever
bitgrower
@bitgrower
Aug 07 2016 06:13
anytime you get "is not a function" it means you are trying to use a method on a data type which does not accept that method
Joseph
@revisualize
Aug 07 2016 06:13
Do you remember doing this
var num = 5;
num = num + 1; // 6
num += 1; // 7
num++; // 8
@Neralizer
Gaurav Tolani
@Gauravtolani
Aug 07 2016 06:14
@bitgrower so what should i do then..?
1p2r3a
@1p2r3a
Aug 07 2016 06:14
@bitgrower
Christian
@Neralizer
Aug 07 2016 06:14
yes, a long time ago, but that was not the *= operator
Joseph
@revisualize
Aug 07 2016 06:14
But, you can do += and -= and *= and /= and %=
Gaurav Tolani
@Gauravtolani
Aug 07 2016 06:14
i converted the english to unicode to check.. added 13 and converted back to english
Christian
@Neralizer
Aug 07 2016 06:15
okay, so take me through the logic
texyh
@texyh
Aug 07 2016 06:15
function lookUpProfile(firstName, prop){
// Only change code below this line
  var found = '';
    for (i=0;i<contacts.length;i++){

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

    }
  return found;
// Only change code above this line
}
Joseph
@revisualize
Aug 07 2016 06:15
@texyh Question...
texyh
@texyh
Aug 07 2016 06:15
some help with this profile lookup
Christian
@Neralizer
Aug 07 2016 06:15
i said factor will equal factor times i?
Joseph
@revisualize
Aug 07 2016 06:16
@texyh If I had a huge contact list of 26 people... Let's say A through Z
@texyh With your code... I'm looking for F.
@texyh What happens when I get to G?
texyh
@texyh
Aug 07 2016 06:16
seems the loop is not working well
Joseph
@revisualize
Aug 07 2016 06:16
G does not equal F
bitgrower
@bitgrower
Aug 07 2016 06:17
@Gauravtolani I am giving you a general principle which applies to programming in javascript in general ... any time you see that error, you need to dig in and see what data type that method needs, and what you need to do to give it a variable which is of that variable type ...
Joseph
@revisualize
Aug 07 2016 06:17
@texyh Because your loop continues past the contact that you're looking for .. You end up overwriting your found variable.
Gaurav Tolani
@Gauravtolani
Aug 07 2016 06:17
ok @bitgrower ... i got the issue.. thank you :-)
CamperBot
@camperbot
Aug 07 2016 06:17
gauravtolani sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1169 | @bitgrower |http://www.freecodecamp.com/bitgrower
texyh
@texyh
Aug 07 2016 06:19
@revisualize kk, i get that,
Christian
@Neralizer
Aug 07 2016 06:19
thanks @revisualize @bitgrower
CamperBot
@camperbot
Aug 07 2016 06:19
neralizer sends brownie points to @revisualize and @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1562 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 1170 | @bitgrower |http://www.freecodecamp.com/bitgrower
texyh
@texyh
Aug 07 2016 06:19
@revisualize but it seems it also otherwise in my previous code,if look for F, it only stops at A
Joseph
@revisualize
Aug 07 2016 06:21
@texyh May I suggest that you try and use www.pythontutor.com to visualize your code execution?
texyh
@texyh
Aug 07 2016 06:22
@revisualize i know python,cant just wrap my head around this js
Joseph
@revisualize
Aug 07 2016 06:23
@texyh Using this tool, you can write Python, Java, JavaScript, TypeScript, Ruby, C, and C++ programs in your Web browser and visualize what the computer is doing step-by-step as it executes those programs.
JavaScript
Visualize
Sometimes I wonder is my usage of the English language obtuse?
@texyh Allow me to help you.
http://www.pythontutor.com/javascript.html#code=//Setup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22,%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22,%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22,%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22,%20%22Coding%22,%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D,%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22,%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22,%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22,%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22,%20%22Magic%22,%20%22Hagrid%22%5D%0A%20%20%20%20%7D,%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22,%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22,%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22,%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22,%20%22Violin%22%5D%0A%20%20%20%20%7D,%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22,%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22,%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22,%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22,%20%22Gaming%22,%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0Afunction%20lookUpProfile(firstName,%20prop%29%7B%0A//%20Only%20change%20code%20below%20this%20line%0A%20%20var%20found%20%3D%20''%3B%0A%20%20%20%20for%20(var%20i%20%3D%200%3Bi%3Ccontacts.length%3Bi%2B%2B%29%7B%0A%0A%20%20%20%20%20%20%20%20if%20(contacts%5Bi%5D.firstName%20%3D%3D%20firstName%20%26%26%20contacts%5Bi%5D.hasOwnProperty(prop%29%29%7B%0A%20%20%20%20%20%20%20%20%20%20%20found%20%3Dcontacts%5Bi%5D%5Bprop%5D%3B%0A%20%20%20%20%20%20%20%20%7Delse%20if(contacts%5Bi%5D.firstName%20%3D%3D%20firstName%20%26%26%20contacts%5Bi%5D.hasOwnProperty(prop%29!%3D%3Dtrue%29%7B%0A%20%20%20%20%20%20%20%20%20found%3D%20%22No%20such%20property%22%3B%0A%20%20%20%20%20%20%20%20%7Delse%7B%0A%20%20%20%20%20%20%20%20%20%20found%3D%20%22No%20such%20contact%22%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%7D%0A%20%20return%20found%3B%0A//%20Only%20change%20code%20above%20this%20line%0A%7D%0AlookUpProfile(%22Harry%22,%22likes%22%29%3B&curInstr=0&mode=display&origin=opt-frontend.js&py=js&rawInputLstJSON=%5B%5D
texyh
@texyh
Aug 07 2016 06:27
@revisualize woow thats cool,will check it out
Joseph
@revisualize
Aug 07 2016 06:27
Yes. It is a wall of link. And I'm sorry for that.
Chris Cullen
@123xylem
Aug 07 2016 06:28
answer.push(''+arr0[2]+" " +arr0[1]+' ' +arr0[0]+''+'"'+","+" "+  ""+ arr1[1] +" "+ arr1[2]+" "+ arr1[0] +"");}

THis is my code which gives me this

["1st July 2014\", july 23rd 2016"]

ALL I WANT TO DO IS remove the \

Joseph
@revisualize
Aug 07 2016 06:28
It's like I'm sitting here telling people to use tools that are not useful for them.
Chris Cullen
@123xylem
Aug 07 2016 06:28
@revisualize geez tracy
;)
Chad Powell
@cjpowellaz
Aug 07 2016 06:35
I am working on "Check for Palindomes", figuring out how to return a boolean:

function palindrome(str) {
// Good luck!

str = str.replace(/[^0-9a-zA-Z]/g, "");
str = str.toLowerCase();

if (str === ) {
return true;
} else {
return false;
}

}

palindrome("eye");

Do I nest a function that would do the "split and reverse" like the Revers a String challenge?
Azlan Mukhtar
@azlan
Aug 07 2016 06:36
if (str === ) check this again
compared to what?
Joseph
@revisualize
Aug 07 2016 06:36
@cjpowellaz You could nest a function if you wanted to .. Or you could just use the method calls.
Chad Powell
@cjpowellaz
Aug 07 2016 06:36
that is where I am stuck, I am not sure what to compare to get my boolean, can I compare to a function?
Joseph
@revisualize
Aug 07 2016 06:37

@cjpowellaz This code:

if (condition) { // True
  return true;
} else { // False
  return false;
}

is quite pointless.
You should just do the comparison in a return statement.

   return condition; // will return true or false.
@cjpowellaz How do you reverse a string?
Chad Powell
@cjpowellaz
Aug 07 2016 06:3