22nd
Jan 2017
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:00
@Calabresem19 hmm
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:00
i dont want to remove the event in the call back, i just want it to not run the functions multiple times when you click
Calabresem19
@Calabresem19
Jan 22 2017 00:01
does that make sense to you? @Dueldrawer8
DavidGutierrez94
@DavidGutierrez94
Jan 22 2017 00:01
@forkerino @joreyesl ok I'm going to check, thanks
CamperBot
@camperbot
Jan 22 2017 00:01
davidgutierrez94 sends brownie points to @forkerino and @joreyesl :sparkles: :thumbsup: :sparkles:
taithethai
@taithethai
Jan 22 2017 00:01
so @moigithub what does -4 * -4 equal?
They're both less than 0
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:01
@Calabresem19 yes
Moisés Man
@moigithub
Jan 22 2017 00:01
@Calabresem19 he already have a "multiply function" based on consecutive aditions.. only need to define the final sign
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:02
@moigithub yes
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:02
http://codepen.io/Geeheeb/pen/BpWGKm?editors=1010 if you press restart, sometimes it picks it up as multiple mouseclicks and then resets it multiple times @forkerino
Pieter Stokkink
@forkerino
Jan 22 2017 00:02
@HeebieGeeBee but if you don't remove the eventlistener, the onclick will keep doing its job, listening for clicks.
Sean Kelly
@spkellydev
Jan 22 2017 00:02
hey thanks for the regex101 tip! I finally got my palindrome checker to work
Jor
@joreyesl
Jan 22 2017 00:03
@Dueldrawer8 your current algorithm works fine. But you have to convert both number to positive first. Then after you have your total, you can decide the sign. If you started with 2 positive or 2 negative numbers, the its positive, otherwise the total should be negative.
Moisés Man
@moigithub
Jan 22 2017 00:03
isNum1Negative = num1 <0;
isNum2Negative = num2 <0;
if (isNum1Negative && !isNum2Negative) // mean only 1 of those are negative.. so final sign should be -
@taithethai
i think.... maybe im wrong :P
could use !== probably
taithethai
@taithethai
Jan 22 2017 00:03
hahah
no worries
Pieter Stokkink
@forkerino
Jan 22 2017 00:04
@HeebieGeeBee of course you could set it again once you start the game again. The game is really coming together, btw, nice work!
Sean Kelly
@spkellydev
Jan 22 2017 00:04
Level complete!
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:04
@joreyesl and if only one is negative, the final sign is negative
Jor
@joreyesl
Jan 22 2017 00:04
@Dueldrawer8 yes
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:04
yeah thanks, havent really worked on it much, just trying to understand things like object collision and stuff
RobsonPhoenix
@RobsonPhoenix
Jan 22 2017 00:04

function nextInLine(arr, item) {
arr.push(item);
arr.shift();

return ; // Change this line

How do I return the element that was removed?
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:05
so you thinki just use removeEventListener() @forkerino ?
was really hoping to be working on sprites by now
taithethai
@taithethai
Jan 22 2017 00:05
@moigithub if a less than 0, and b greater than 0, you'd get a positive on your script
Jor
@joreyesl
Jan 22 2017 00:05

@RobsonPhoenix 2 ways

var a = arr.shift();
return a;

or simply

return arr.shift();
Moisés Man
@moigithub
Jan 22 2017 00:06
taithethai
@taithethai
Jan 22 2017 00:06
but you're both on the right track
what if you compared the boolean value to see if they are equal to each other?
RobsonPhoenix
@RobsonPhoenix
Jan 22 2017 00:07
@joreyesl Thanks, tried that and it's not really working =/
CamperBot
@camperbot
Jan 22 2017 00:07
robsonphoenix sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
taithethai
@taithethai
Jan 22 2017 00:07
False == False is true, True == True is true , False == True is false.
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:07
@joreyesl so why doesnt this work?
function multiply(num1, num2) {
// 4 * 7 is just 4 + 4 + 4 + 4 + 4 + 4 + 4
var total = 0;
for(var i = 0; i < num2; i++){
if(num1 < 0 && num2 < 0){
total+= Math.abs(num1);
}
else if(num1 < 0 || num2< 0){
total+= -(num1);
}
else{
total+= num1;
}
}

}

multiply(4, 7);
Jor
@joreyesl
Jan 22 2017 00:07
@RobsonPhoenix odd that should work, what error does it give?
Pieter Stokkink
@forkerino
Jan 22 2017 00:08
@HeebieGeeBee Yes. That should work. I did something similar in the Simon game.
taithethai
@taithethai
Jan 22 2017 00:08
well
Jor
@joreyesl
Jan 22 2017 00:09
@Dueldrawer8 make sure you are using positive numbers for your iteration. What if num2 is negative?
for(var i = 0; i < num2; i++){
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:09
ah
i < Math.abs(num2)
weird..it passes all the built in test besides one that says "should not use the mulitply operator" "expected true to be false"
Jor
@joreyesl
Jan 22 2017 00:11
@Dueldrawer8 but your innitial code was fine. you just had to decide the sign after the loop
RobsonPhoenix
@RobsonPhoenix
Jan 22 2017 00:11

@joreyesl It's showing something like this for my (testArr , 6)
Before: [1,2,3,4,5]
2
After: [3,4,5,6]

I wanted to show the number 1 and the after to be: [2,3,4,5,6]

HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:11
document.getElementById('restart').addEventListener('click', function() {
console.log(event);
document.getElementById('restart').removeEventListener('click', function() {
clearInterval(animateInterval);
ctx.clearRect(0, 0, ctxWidth, ctxHeight);
initCanvas();
});

});
when i do this it does the one click but doesnt reset the canvas @forkerino
Jor
@joreyesl
Jan 22 2017 00:12
@RobsonPhoenix repost your new code, it looks like you are .shift() twice
RobsonPhoenix
@RobsonPhoenix
Jan 22 2017 00:13

@joreyesl The full code:
function nextInLine(arr, item) {

arr.push(item);
arr.shift();

return arr.shift(); // Change this line
}

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

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

nvm Just got it :P
Jor
@joreyesl
Jan 22 2017 00:13
@RobsonPhoenix yes you are .shift() twice.
Ok, np :thumbsup:
Moisés Man
@moigithub
Jan 22 2017 00:14
@HeebieGeeBee soo ur code.. should be able to "restart" only 1 time ?
RobsonPhoenix
@RobsonPhoenix
Jan 22 2017 00:14
@joreyesl Just learned a precious lesson Thanks (Y) ^^
CamperBot
@camperbot
Jan 22 2017 00:14
robsonphoenix sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:warning: robsonphoenix already gave joreyesl points
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:14
no i dont want it to only restart once
RRRmHHH
@rrrmhhh
Jan 22 2017 00:14
hello
Joseph
@revisualize
Jan 22 2017 00:14
Hu
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:15
i just want it to only restart once on each mouse click cus when you hold the mouse down for too long it fires the function multiple times
Pieter Stokkink
@forkerino
Jan 22 2017 00:15
@HeebieGeeBee removeEventListener only takes a function if you are removing a specific function from the eventlisteners available on that element. Try it like so:
document.getElementById('restart').addEventListener('click', function() {
console.log(event);
document.getElementById('restart').removeEventListener('click');
clearInterval(animateInterval);
ctx.clearRect(0, 0, ctxWidth, ctxHeight);
initCanvas();
});
and then add it back in somewhere else, for example as soon as the first move is made.
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:16
i tried doing it like that and i get console error saying removeEventListener needs two arguments
Moisés Man
@moigithub
Jan 22 2017 00:16
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:16
@joreyesl so @moigithub @joreyesl @taithethai thank you
CamperBot
@camperbot
Jan 22 2017 00:16
dueldrawer8 sends brownie points to @joreyesl and @moigithub and @taithethai :sparkles: :thumbsup: :sparkles:
:star2: 2570 | @moigithub |http://www.freecodecamp.com/moigithub
Pieter Stokkink
@forkerino
Jan 22 2017 00:17
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:17
me no hablo espanol @moigithub
Moisés Man
@moigithub
Jan 22 2017 00:18
u can click on the world icon and change to whatever language u speak :P
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:18
just kidding
Pieter Stokkink
@forkerino
Jan 22 2017 00:18
@HeebieGeeBee then you probably need to name your callback function.
Moisés Man
@moigithub
Jan 22 2017 00:18
but.. if u wanna make it work multiple times.. probalby u NO need to remove the event listener
Pieter Stokkink
@forkerino
Jan 22 2017 00:18
or perhaps this would work?
Jor
@joreyesl
Jan 22 2017 00:19
@Dueldrawer8
function multiply(num1, num2) {
// 4 * 7 is just 4 + 4 + 4 + 4 + 4 + 4 + 4
var total = 0;
for(var i = 0; i < num2; i++){ // make sure num2 is positive for obv reason
total+= num1;  // make sure num1 is positive. will make it easier for our if statements
}
if(...) // if both num1 and num2 are positive or both negative then simply return total

}
taithethai
@taithethai
Jan 22 2017 00:20
I mean, he already sent the thanks. I guess he's got it figured out.
@joreyesl
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:20
once: A Boolean indicating that the listener should be invoked at most once after being added. If it is true, the listener would be removed automatically when it is invoked., how do i add this to the addEventListener function
Jor
@joreyesl
Jan 22 2017 00:21
@taithethai yea, was already in the process of writting it before he send it.
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:21
@joreyesl in the else statement i cant use the * operator though
well waht i had passed the test but theres a bug..
Jor
@joreyesl
Jan 22 2017 00:21
@Dueldrawer8 oh rip, forgot about that
Long Vu
@longorjames
Jan 22 2017 00:22
I got stuck on this, I think there's a small error in the code but can't find it.
It's for this Selecting from many options with Switch Statements
Pieter Stokkink
@forkerino
Jan 22 2017 00:22
@HeebieGeeBee that might work, add the third argument: { once : true }
Long Vu
@longorjames
Jan 22 2017 00:22

function caseInSwitch(val) {
// Only change code below this line
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
// Only change code above this line
}

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

Moisés Man
@moigithub
Jan 22 2017 00:22
function x(){
a=1
return -a;   // negative
}
@joreyesl @Dueldrawer8
x() // -1
RRRmHHH
@rrrmhhh
Jan 22 2017 00:23
h
Joseph
@revisualize
Jan 22 2017 00:23
@longorjames you dont have a switch. Just a bunch of case statement.s
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:23
function multiply(num1, num2) {
// 4 * 7 is just 4 + 4 + 4 + 4 + 4 + 4 + 4
var total = 0;
for(var i = 0; i < num2; i++){
if(num1 < 0 && num2 < 0){
total+= Math.abs(num1);
}
else if(num1 < 0 || num2< 0){
total+= -(num1);
}
else{
total+= num1;
}
}

}

multiply(4, 7);
for some reason this works.. but if you make the first num negative and the second positive.. it should be -28 and not 28..when i console.log it.. it prints out multiply(-4, 7) as 28..and when i press submit...it says all the test pass.. lol
RRRmHHH
@rrrmhhh
Jan 22 2017 00:24
hi
Long Vu
@longorjames
Jan 22 2017 00:24
function caseInSwitch(val) {
// Only change code below this line
switch (num){
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
}
// Only change code above this line
}
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:24
oops wrong code
Coy Sanders
@coymeetsworld
Jan 22 2017 00:24
@longorjames take a look at your switch statement
Long Vu
@longorjames
Jan 22 2017 00:24
oh change num to val now
Coy Sanders
@coymeetsworld
Jan 22 2017 00:24
:ok_hand:
Long Vu
@longorjames
Jan 22 2017 00:24
@coymeetsworld thanks
CamperBot
@camperbot
Jan 22 2017 00:24
longorjames sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1897 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:24
 var total = 0;
for(var i = 0; i < Math.abs(num2); i++){
if(num1 < 0 || num2 < 0){
total+= -num1;
}
else{
total+= num1;
}
}
}

multiply(4, -7);
Joseph
@revisualize
Jan 22 2017 00:24
@longorjames the parameter is val not num
Coy Sanders
@coymeetsworld
Jan 22 2017 00:25
np @longorjames
Joseph
@revisualize
Jan 22 2017 00:25
:/
Lol
Pieter Stokkink
@forkerino
Jan 22 2017 00:25
@Dueldrawer8 because of your else if. It just adds -(-4) 7 times in that case.
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:25
    document.getElementById('restart').addEventListener('click', function() {
console.log(event);

clearInterval(animateInterval);
ctx.clearRect(0, 0, ctxWidth, ctxHeight);
initCanvas();

}, {once = true} );
yeah ive tried like this but its saying syntax error?
Harout Payaslyan
@hpaya
Jan 22 2017 00:25

function switchOfStuff(val) {
// Only change code below this line
switch (val) {

case a:
break;

case b:
break;

case c:
break;

default:
return"stuff";
}

// Only change code above this line
}

// Change this value to test
switchOfStuff(a);
why is my code returning a is not defined? thanks
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:26
@forkerino see my updated snippet of code with just an if else statment
Joseph
@revisualize
Jan 22 2017 00:26
You have a variable in your argument
Pieter Stokkink
@forkerino
Jan 22 2017 00:26
@Dueldrawer8 same problem.
Moisés Man
@moigithub
Jan 22 2017 00:26
@HeebieGeeBee where u got this "once" parameter ?
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:26
@forkerino ah yes true just looked at that
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:27
Joseph
@revisualize
Jan 22 2017 00:27
@hpaya you have a as your argument. An undefinded variable
taithethai
@taithethai
Jan 22 2017 00:27
(num1 < 0 == num2 < 0)
Harout Payaslyan
@hpaya
Jan 22 2017 00:27
oh
thanks you
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:28
@taithethai true
Joseph
@revisualize
Jan 22 2017 00:29
Thanks @me
CamperBot
@camperbot
Jan 22 2017 00:29
revisualize sends brownie points to @me :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for me
Jor
@joreyesl
Jan 22 2017 00:29
@Dueldrawer8 problem is this statment total+= -(num1); if num1=-4 so -(-4) is positive
taithethai
@taithethai
Jan 22 2017 00:29
@Dueldrawer8 you'll have to change some if your code around
Moisés Man
@moigithub
Jan 22 2017 00:29
@HeebieGeeBee IF its an object.. should use : to separate key:value pairs
Harout Payaslyan
@hpaya
Jan 22 2017 00:29
thanks @revisualize
CamperBot
@camperbot
Jan 22 2017 00:29
hpaya sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3074 | @revisualize |http://www.freecodecamp.com/revisualize
taithethai
@taithethai
Jan 22 2017 00:29
but here are 3 test cases for what I gave you:
2 2
-1 2
-1 -1
@Dueldrawer8
What do each of those evaluate to in
(num1 < 0 == num2 < 0)
Moisés Man
@moigithub
Jan 22 2017 00:31
@HeebieGeeBee OR.. another way.. put ur function outside..
set the listener
call the function
then no need to use "once"
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:31
 document.getElementById('restart').addEventListener('click', function() {
console.log(event);

clearInterval(animateInterval);
ctx.clearRect(0, 0, ctxWidth, ctxHeight);
initCanvas();

}, {once: true});
yeah it got it done, saw that just as you said it @moigithub, thanks @moigithub and @forkerino
CamperBot
@camperbot
Jan 22 2017 00:31
heebiegeebee sends brownie points to @moigithub and @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2571 | @moigithub |http://www.freecodecamp.com/moigithub
Pieter Stokkink
@forkerino
Jan 22 2017 00:31
@HeebieGeeBee Hope it works now as you want it. :+1:
taithethai
@taithethai
Jan 22 2017 00:31
are the numbers besides the names your brownie points or current level?
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:32
@joreyesl yes..trying to think of a way to fix that
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:32
yeah works really nicely
Joseph
@revisualize
Jan 22 2017 00:32
Brownie points
Moisés Man
@moigithub
Jan 22 2017 00:32
function clear() {
console.log(event);
clearInterval(animateInterval);
ctx.clearRect(0, 0, ctxWidth, ctxHeight);
initCanvas();
}
clear();
should do the same...
taithethai
@taithethai
Jan 22 2017 00:32
@Dueldrawer8 lmk when you read my comment
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:33
@taithethai true, false, and true
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:33
@moigithub cool thanks
CamperBot
@camperbot
Jan 22 2017 00:33
heebiegeebee sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: heebiegeebee already gave moigithub points
taithethai
@taithethai
Jan 22 2017 00:34
@Dueldrawer8 does that fit a pattern with the final numbers being positive or negative?
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:34
yes.. positives are true..
and negatives are false
taithethai
@taithethai
Jan 22 2017 00:34
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:35
@taithethai have to change my code around as you said lol.. so i would have to add the negative sign after.. right?
taithethai
@taithethai
Jan 22 2017 00:35
right
make sure you abs numbers in your for loop
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:36
@taithethai but wait
taithethai
@taithethai
Jan 22 2017 00:36
then add the neg symbol last if necessary
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:36
@taithethai 1 and 7 would be false..
taithethai
@taithethai
Jan 22 2017 00:36
hm?
is 1 > 0? True
is 7 > 0? True
True == True is True.
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:37
ah gotcha nvm
taithethai
@taithethai
Jan 22 2017 00:37
and as you last said, True means positive
Jor
@joreyesl
Jan 22 2017 00:37
@Dueldrawer8 try total+= num1 < 0 ? num1 : -num1;
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:37
true === "true" is false
taithethai
@taithethai
Jan 22 2017 00:38
@HeebieGeeBee but that's not the case we're working on
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:38
lol i know just messing about
taithethai
@taithethai
Jan 22 2017 00:38
lol. I had to scroll back to verify I didn't mistype. Thanks for that.
Edin
@sombrerox
Jan 22 2017 00:39
Guys why is "* If there is no property at the key, it should return an empty array. " not working with my code:
function getAllButLastElementOfProperty(obj, key) {
if (obj[key][0] === "undefined" || typeof obj[key] !== "object" || obj.hasOwnProperty([key]) === false){

return [];

}

obj[key].pop();

return obj[key];

}

var objx = {
key2: [1, 2, 3]
};

getAllButLastElementOfProperty(objx, "key2");
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:39
@joreyesl it doesnt work if both num1 and num2 are negatibe
Kraig Carr
@Praiseit
Jan 22 2017 00:39
Hey guys. I struggled to complete the Convert Celsius to Fahrenheit challenge. Are there JavaScript supplements I should be taking going down the waypoints?
Jor
@joreyesl
Jan 22 2017 00:40
@Dueldrawer8 but that is caught by your 1st if statement
taithethai
@taithethai
Jan 22 2017 00:40
@Praiseit have you been bumrushing the objective, or are you reading the text?
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:40
@Praiseit youre going to have to read and research lots outside of the challenges
in order to get through them
taithethai
@taithethai
Jan 22 2017 00:40
For the most part, as long as you're not skipping straight to the objective (I am guilty of this), you should be fine with minimal Google-Fu
Kraig Carr
@Praiseit
Jan 22 2017 00:41
Mmm, I guess its a little bit of both. I read the text and descriptions, make sure to type it out myself and it makes sense for the moment. When I get to the challenge that uses what I just learned before, I guess it all just flies out of my head.
jturner11
@jturner11
Jan 22 2017 00:41
hey guys
taithethai
@taithethai
Jan 22 2017 00:41
hi @jturner11
Jor
@joreyesl
Jan 22 2017 00:42
@jturner11 sure, post the question
jturner11
@jturner11
Jan 22 2017 00:42
I'm on this challenge
Write Reusable JavaScript with Functions
taithethai
@taithethai
Jan 22 2017 00:42
@Praiseit Try obtaining a notebook and taking notes
jturner11
@jturner11
Jan 22 2017 00:42
this is my code

// Example
function ourReusableFunction() {
console.log("Heyya, World");
}

ourReusableFunction();

// Only change code below this line
function reusableFunction() {
console.log("Hi World");
}

Edin
@sombrerox
Jan 22 2017 00:42
HEEEEEEEEEEEEEEEEEEEEEEEELP
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:42
@joreyesl and that statement goes in place of my second else if statement?
jturner11
@jturner11
Jan 22 2017 00:42
so i believe everything is right i just need to call the function
Jor
@joreyesl
Jan 22 2017 00:43
@Dueldrawer8 no that is what happens if your 2nd else if statment is true.
taithethai
@taithethai
Jan 22 2017 00:43
so call the function. It all looks correct. @jturner11
@sombrerox can you put it in chat? I like to highlight code as I read it. Here, have these. 
Jor
@joreyesl
Jan 22 2017 00:44
@jturner11 looks good, now you just have to make a call to it
jturner11
@jturner11
Jan 22 2017 00:44
what lesson would i have to look over to find out how to do that
ive forgotten
taithethai
@taithethai
Jan 22 2017 00:44
well, what's the name of your function that you wrote?
jturner11
@jturner11
Jan 22 2017 00:45
reusuableFunction
Edin
@sombrerox
Jan 22 2017 00:45
@taithethai
function getAllButLastElementOfProperty(obj, key) {
if (obj[key][0] === "undefined" || typeof obj[key] !== "object" || obj.hasOwnProperty([key]) === false){

return [];

}

obj[key].pop();

return obj[key];

}

var objx = {
key2: [1, 2, 3]
};

getAllButLastElementOfProperty(objx, "key2");
jturner11
@jturner11
Jan 22 2017 00:45
@taithethai reusuableFunction
taithethai
@taithethai
Jan 22 2017 00:45
@jturner11 that's almost all of it. Here, you forgot these ()
jturner11
@jturner11
Jan 22 2017 00:46
oh yeah my mistake
so i need to type something in there
taithethai
@taithethai
Jan 22 2017 00:46
So, all together now, what's the name of your function, @jturner11
jturner11
@jturner11
Jan 22 2017 00:46
reusableFunction()
Jor
@joreyesl
Jan 22 2017 00:46

@jturner11 example:

function someFunction() {
// does something
}

if I want to call that function then I would type

someFunction();
taithethai
@taithethai
Jan 22 2017 00:47
Cool. Now just throw that at the bottom of your box. You should be golden
@jturner11
jturner11
@jturner11
Jan 22 2017 00:47
got it i understand now thats why they have included the ourReusableFunction below theres
theirs
taithethai
@taithethai
Jan 22 2017 00:47
hahah, yep.
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:47
@joreyesl @taithethai thank you both again
CamperBot
@camperbot
Jan 22 2017 00:47
:warning: dueldrawer8 already gave taithethai points
dueldrawer8 sends brownie points to @joreyesl and @taithethai :sparkles: :thumbsup: :sparkles:
:warning: dueldrawer8 already gave joreyesl points
taithethai
@taithethai
Jan 22 2017 00:48
@Dueldrawer8 npnp
jturner11
@jturner11
Jan 22 2017 00:48
thank you to the both of you !! @taithethai @joreyesl really appreciate it!!
CamperBot
@camperbot
Jan 22 2017 00:48
jturner11 sends brownie points to @taithethai and @joreyesl :sparkles: :thumbsup: :sparkles:
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:48
undefined is a keyword @sombrerox
CamperBot
@camperbot
Jan 22 2017 00:48
Jor
@joreyesl
Jan 22 2017 00:48
@Dueldrawer8 @jturner11 np, good luck
Edin
@sombrerox
Jan 22 2017 00:49
@HeebieGeeBee oh shit i thought i used typeof before
taithethai
@taithethai
Jan 22 2017 00:49
@sombrerox gimme a sec
I don't actually know js
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:49
obj.hasOwnProperty([key]) and you dont need the [] around key here
Edin
@sombrerox
Jan 22 2017 00:49
@HeebieGeeBee it's still the same
@HeebieGeeBee ye i know about that, i was just experimenting, it gives me the same error every time
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:50
what challenge is this?
and what are you trying to do?
taithethai
@taithethai
Jan 22 2017 00:50
it's homework lol @HeebieGeeBee
Edin
@sombrerox
Jan 22 2017 00:50
@HeebieGeeBee its hackreactor training course
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:50
and what error message are you getting
Edin
@sombrerox
Jan 22 2017 00:50
@HeebieGeeBee http://prnt.sc/dyoj5v
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:50
@sombrerox yes it is..you must of done it also?
Edin
@sombrerox
Jan 22 2017 00:51
@Dueldrawer8 done what ?
Randy Goldsmith
@Dueldrawer8
Jan 22 2017 00:51
@sombrerox hack reactor training
taithethai
@taithethai
Jan 22 2017 00:52
@HeebieGeeBee Idr, does JS have errorhandling?
Jor
@joreyesl
Jan 22 2017 00:52
@sombrerox yea the problem is that your check for undefine is not working. Look at the suggestion @HeebieGeeBee gave you
taithethai
@taithethai
Jan 22 2017 00:52
rather, idk, does JS have errorhandling? @joreyesl @HeebieGeeBee
Edin
@sombrerox
Jan 22 2017 00:53
@joreyesl no man, that part of the condition is ok, the last part is an issue where .hasOwnProperty() === false
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:53
@taithethai i wouldnt know
Edin
@sombrerox
Jan 22 2017 00:53
@joreyesl the first part with undefined is checking if it's an empty array and its fine
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:54
youre comparing to a string @sombrerox though
Edin
@sombrerox
Jan 22 2017 00:54
@HeebieGeeBee is there any difference between using undefined and "undefined" when checking ?
Jor
@joreyesl
Jan 22 2017 00:54
@sombrerox yes
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:54
yes one is just a string
Edin
@sombrerox
Jan 22 2017 00:54
@HeebieGeeBee yea, but that's the return value that you get
Jor
@joreyesl
Jan 22 2017 00:54
unless you are using typeof you dont want to use a string
Edin
@sombrerox
Jan 22 2017 00:55
@HeebieGeeBee wait a second
Jor
@joreyesl
Jan 22 2017 00:55
@taithethai i'm not sure either. Usually just debug using console.log
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:56
undefined is a falsy value, "undefined", is just a string undefined
Edin
@sombrerox
Jan 22 2017 00:57
yes, i understand you, but it worked normally before

@HeebieGeeBee try this in a console:

var arr1 = [];

typeof arr1[0] === "undefined";

taithethai
@taithethai
Jan 22 2017 00:57
I think it was python you could just catch the error, and then say, hey, you got this error, and I will give this line as a return
but you can do anything in python, I guess.
Edin
@sombrerox
Jan 22 2017 00:58
@HeebieGeeBee so typeof basically returns a string "undefined" and normally you just get undefined primitive
Jor
@joreyesl
Jan 22 2017 00:58
@sombrerox yes, typeof returns a string, which is why you can compare it to 'undefined', but if you do arr1[0] you have to check againts the actual keyword
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 00:59
youre using typeof to campare against object
compare
@taithethai console in dev tools will throw up most errors
well maybe not most but a lot
Edin
@sombrerox
Jan 22 2017 01:01
@HeebieGeeBee it doesn't matter, if its empty it returns undefined
@HeebieGeeBee all i have to do is check if the array in that object is empty
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 01:04
well maybe do obj[key] = [];
why do you keep [key] in brackets in the hasOwnProperty function
Edin
@sombrerox
Jan 22 2017 01:07
@HeebieGeeBee my mistake, i started js like a week ago still getting used
but it doesnt affect the error in any way
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 01:08
and i dont think you can just do return []
Jor
@joreyesl
Jan 22 2017 01:09
@HeebieGeeBee you can if you want to return empty array.
@sombrerox the problem is this expression obj[key][0]
David Amanze
@GodKingShogun
Jan 22 2017 01:09
i am on the slasher flick problem and i thought it was going to be straight forward but apparently not lol. can someone take a look at my code and tell me whats up

function slasher(arr, howMany) {
// it doesn't always pay to be first
return arr.splice(0, howMany);
}

slasher([1, 2, 3], 2);
Edin
@sombrerox
Jan 22 2017 01:09
@HeebieGeeBee but all the other conditions are good, and i need to return empty array for all 3 conditions, so its fine with first 2
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 01:10
ok
Margaret
@Margaret2
Jan 22 2017 01:10
@GodKingShogun what is [1,2,3], 2 supposed to output?
Edin
@sombrerox
Jan 22 2017 01:10
@HeebieGeeBee http://prntscr.com/dyos2y here it doesn't change anything, i think it's a bug in the website
Thiago Cruz
@thy705
Jan 22 2017 01:11
Hey guys! Can anybody help with this one? What have I done wrong?
var Car = function() {
// this is a private variable
var speed = 10;

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

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

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

var Bike = function() {

// Only change code below this line.

var gear;

this.getGear = function(change){

gear = change;

};

this.setGear = function(){

return getGear;
};

};

var myCar = new Car();

var myBike = new Bike();
David Amanze
@GodKingShogun
Jan 22 2017 01:11
@Margaret2 it is suppose to output [3]
@thy705 everything lol
Margaret
@Margaret2
Jan 22 2017 01:12
@thy705 gear="change" should be in the setGear function, and you have to return the gear variable for getGear
David Amanze
@GodKingShogun
Jan 22 2017 01:12
@thy705 you only need to copy your code
taithethai
@taithethai
Jan 22 2017 01:12
@Margaret2 an easy way to figure it out is to count by comma. so before the first comma is 0, after the first comma is 1, after the second comma is 2, and so on and so forth.
David Amanze
@GodKingShogun
Jan 22 2017 01:12
@thy705 no need to copy the example too
Jor
@joreyesl
Jan 22 2017 01:12
@GodKingShogun arr.splice(0, howMany); will return the portion that was splice away from the original array
Margaret
@Margaret2
Jan 22 2017 01:12
@taithethai no duh, i know that :D
@taithethai i wanted to know what he was supposed to achieve
David Amanze
@GodKingShogun
Jan 22 2017 01:14
@joreyesl i followed this link the problem gave me and read up on splice and thats how they had it https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
Alexander Huynh
Jan 22 2017 01:14
Howdy yall. What's the difference between these two ways of declaring a method on a constructor function?
var Person = function() {
this.speak = function() {
console.log('hello');
}
Person.prototype.speak = function() {
console.log('hello');
}
}
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 01:14
do the splice bit then after just do return arr @GodKingShogun
Thiago Cruz
@thy705
Jan 22 2017 01:14
@Margaret2 many thanks Margaret!!
CamperBot
@camperbot
Jan 22 2017 01:14
thy705 sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 1316 | @margaret2 |http://www.freecodecamp.com/margaret2
Edin
@sombrerox
Jan 22 2017 01:15
@thy705 you are changing local gear variable from another function
taithethai
@taithethai
Jan 22 2017 01:15
@Margaret2 oops, my bad. I thought you were looking for help. :P my apologies.
David Amanze
@GodKingShogun
Jan 22 2017 01:15
@HeebieGeeBee that worked but can you explain why that is
Margaret
@Margaret2
Jan 22 2017 01:15
lol that's a good tip tho, i'll remember it next time i have to explain it @taithethai
Thiago Cruz
@thy705
Jan 22 2017 01:16
@GodKingShogun I've just figured out how to post the code. Figuring out what to leave out is for another day... lol
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 01:16
cus of what @joreyesl said you were returning the items you splicing out of the array
not what the array was after the splice
David Amanze
@GodKingShogun
Jan 22 2017 01:16
@thy705 the struggle is real lol
@HeebieGeeBee oh ok make sense. thanks SENPAI
CamperBot
@camperbot
Jan 22 2017 01:17
godkingshogun sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
Jor
@joreyesl
Jan 22 2017 01:17

@GodKingShogun

var a = [1,2,3];
var b = a.splice(0,2);

console.log(a); // prints [3]
console.log(b); // prints [1,2]

so if you do return arr.splice(0, howMany); you are returning the portion that was removed. They want to get the portion that remains.

HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 01:18
say ty to him @GodKingShogun
CamperBot
@camperbot
Jan 22 2017 01:18
heebiegeebee sends brownie points to @godkingshogun :sparkles: :thumbsup: :sparkles:
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 01:18
lol oops oh well
David Amanze
@GodKingShogun
Jan 22 2017 01:18
@joreyesl thank you SENPAI
CamperBot
@camperbot
Jan 22 2017 01:18
godkingshogun sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
Jor
@joreyesl
Jan 22 2017 01:18
lol, ty @HeebieGeeBee
CamperBot
@camperbot
Jan 22 2017 01:18
joreyesl sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
taithethai
@taithethai
Jan 22 2017 01:19
Guys. I just learned that I can set syntax in sublime text to javascript by hitting ctrl shift P and typing ssjscr
Coding Machine
@EphremL
Jan 22 2017 01:20
rain drop
Jor
@joreyesl
Jan 22 2017 01:20
:thumbsup:
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 01:21
what does ssjscr do?
taithethai
@taithethai
Jan 22 2017 01:21
@HeebieGeeBee Set Syntax: JavaScript
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 01:22
oh ok
never used sublime
taithethai
@taithethai
Jan 22 2017 01:22
its got a weird search trick that programmers don't want you to know.
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 01:22
im a simpleton i just like brackets
taithethai
@taithethai
Jan 22 2017 01:23
but..but.. pretty colors!
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 01:23
can do pretty colours in brackets too
Jor
@joreyesl
Jan 22 2017 01:23
i think they are pretty similar, but brackets has live preview
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 01:24
not like im doing anythign advanced anyway
and atom just seems a bit slow to me
taithethai
@taithethai
Jan 22 2017 01:24
all the cool kids I know use sublime. That's all I know. haha.
Jor
@joreyesl
Jan 22 2017 01:24
lol
yea I had sublime, now trying out atom.
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 01:25
well if you got 80 euros to spend on a glorified notepad, go for it
taithethai
@taithethai
Jan 22 2017 01:25
They all also happen to use MBPs, buuuuut, they make a buttload of money doing dev work.
Jan 22 2017 01:25
Hey Question here. Can I get some input on this?
taithethai
@taithethai
Jan 22 2017 01:25
unless you're here to poopoo on sublime text. @HeebieGeeBee lol
Jan 22 2017 01:26

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

// Only change code above this line
}

// Change these values to test
golfScore(4, 2);
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 01:26
im not im sure its great, ive never tried it
taithethai
@taithethai
Jan 22 2017 01:26
You have to switch it from if statements to switch, iirc.
@HeebieGeeBee im just giving you shit, lol.
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 01:27
but all code editors are basically just glorifed notepads arent tey
Jan 22 2017 01:27
Oh ok.
Jor
@joreyesl
Jan 22 2017 01:27
taithethai
@taithethai
Jan 22 2017 01:27
switch (val) {
case 1:
break;
case 2:
break;
default:
}
Alexander Huynh
Jan 22 2017 01:28
What does this mean?
var res = 0, c;
what does setting a variable equal to comma separated values do?
taithethai
@taithethai
Jan 22 2017 01:29
@joreyesl what, do you use vim, then?
Jan 22 2017 01:29
Thats Odd that wasnt in any of the previous lessons.
Jor
@joreyesl
Jan 22 2017 01:29
@caesarsalad93 you are just declaring 2 var.
taithethai
@taithethai
Jan 22 2017 01:29
oh
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 01:29
means theres a variable res defined as 0 and another variable c
taithethai
@taithethai
Jan 22 2017 01:29
what's the instructions say to do?
Alexander Huynh
Jan 22 2017 01:29
@joreyesl ohhhhh, I see. Is that just declaring variable c as undefined?
Jor
@joreyesl
Jan 22 2017 01:30

var res = 0, c;

is the same as

var res = 0;
var c;
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 01:30
yeah
Jan 22 2017 01:30
correct
Alexander Huynh
Jan 22 2017 01:30
@joreyesl gracias senor
@joreyesl ty
CamperBot
@camperbot
Jan 22 2017 01:30
caesarsalad93 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
taithethai
@taithethai
Jan 22 2017 01:30
@brenbrad what do we know about if and else if statements so far?
Jor
@joreyesl
Jan 22 2017 01:31
CamperBot
@camperbot
Jan 22 2017 01:31
joreyesl sends brownie points to @caesarsalad93 and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:warning: joreyesl already gave heebiegeebee points
HeebieGeeBee
@HeebieGeeBee
Jan 22 2017 01:31
Jan 22 2017 01:32
well we know that we can chain them together.
taithethai
@taithethai
Jan 22 2017 01:32
Jor
@joreyesl
Jan 22 2017 01:32
@taithethai no, I dont use VIM. i'm not good enough for that lol. But i did map my h,j,k,l keys to arrow keys so that I can navigate code without leaving home position. Thats as close to VIM as i'll get
Alexander Huynh
Jan 22 2017 01:32
@HeebieGeeBee ty
CamperBot
@camperbot
Jan 22 2017 01:32
caesarsalad93 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
taithethai
@taithethai
Jan 22 2017 01:33
so instead of all those ifs, make all but the first else if.
I think they tell you to do that, I may recall incorrectly.
Damián Sánchez
@sanchezdam
Jan 22 2017 01:35
how can I resolve it?
Jan 22 2017 01:36
Ok I did try that already and then changed it back. But i will give it another crack !! Thanks @taithethai
CamperBot
@camperbot
Jan 22 2017 01:36
brenbrad sends brownie points to @taithethai :sparkles: :thumbsup: :sparkles:
taithethai
@taithethai
Jan 22 2017 01:38
@brenbrad what challenge are you on?
Jan 22 2017 01:39
It seems the issue is that no matter what value i put in for par / strokes it always says hole in one
taithethai
@taithethai
Jan 22 2017 01:39
what's the number on the top right?
Jan 22 2017 01:40
194
Jor
@joreyesl
Jan 22 2017 01:40

if ( strokes = 1 )

to do a comparison you need to use ==

Johnny
@JohnnyBizzel
Jan 22 2017 01:40
You may be doing an early return statement?
taithethai
@taithethai
Jan 22 2017 01:40
oh
uhh
@brenbrad here's 6. = = = = = =
Johnny
@JohnnyBizzel
Jan 22 2017 01:41
Jan 22 2017 01:42
LOL!!! ok
Johnny
@JohnnyBizzel
Jan 22 2017 01:42
Coding Machine
@EphremL
Jan 22 2017 01:43
lol i am busting through javascript
Johnny
@JohnnyBizzel
Jan 22 2017 01:43
It recommends using ===
Anh Nguyen
@tiremon112
Jan 22 2017 01:43
//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

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

}
}
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
my brain wants to blow up
Johnny
@JohnnyBizzel
Jan 22 2017 01:44
@EphremL Then try codewars: www.codewars.com/r/SMcpMQ
taithethai
@taithethai
Jan 22 2017 01:44
@brenbrad @JohnnyBizzel is right. It'll let you pass with two, but here's 6 more. = = = = = =
Anh Nguyen
@tiremon112
Jan 22 2017 01:44
Johnny help
Coding Machine
@EphremL
Jan 22 2017 01:44
what is codewars @JohnnyBizzel
Johnny
@JohnnyBizzel
Jan 22 2017 01:44
Who's he?
Jor
@joreyesl
Jan 22 2017 01:45
@tiremon112 make sure you are comparing name with name (contacts[i] === firstName) should be (contacts[i].firstName === firstName)
Johnny
@JohnnyBizzel
Jan 22 2017 01:45
@EphremL Algorithm practice.
Jan 22 2017 01:45
LOL!!! no clue what you guys are saying .. So im missng = i need 6 ?? and i should use this ===
taithethai
@taithethai
Jan 22 2017 01:45
actually
Johnny
@JohnnyBizzel
Jan 22 2017 01:45
@tiremon112 You will exit out of the loop too soon
Anh Nguyen
@tiremon112
Jan 22 2017 01:46
@joreyesl alright that help little bit
taithethai
@taithethai
Jan 22 2017 01:46

so here

a = 0

versus

a == 0
Anh Nguyen
@tiremon112
Jan 22 2017 01:46
pop up 3
need 2 more
taithethai
@taithethai
Jan 22 2017 01:46
Do you know the difference? @brenbrad
Jor
@joreyesl
Jan 22 2017 01:47
@tiremon112 as @JohnnyBizzel said. You are exiting too soon. You dont want to return "No such contact" until after you have iterated throught the entire list.
Anh Nguyen
@tiremon112
Jan 22 2017 01:47
@joreyesl so you want me to move it bottom?
Johnny
@JohnnyBizzel
Jan 22 2017 01:48

@tiremon112 You can combine these for starters:

 if (contacts[i] === firstName)
{
if (contacts[i].hasOwnProperty(prop))

to
if (contacts[i].hasOwnProperty(prop) && contacts[i].firstName == firstName) {
after this is true you can return the correct value

Jan 22 2017 01:48
i think so I will go back and review. Thanks @JohnnyBizzel @taithethai
CamperBot
@camperbot
Jan 22 2017 01:48
brenbrad sends brownie points to @johnnybizzel and @taithethai :sparkles: :thumbsup: :sparkles:
:star2: 1166 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Sean Kelly
@spkellydev
Jan 22 2017 01:48
hey would someone mind helping me find out where I went wrong in my array logic?
Johnny
@JohnnyBizzel
Jan 22 2017 01:49
@spkellydev Show us some code please
David Amanze
@GodKingShogun
Jan 22 2017 01:49
if i am using the indexOf() can i search for multiple value
Sean Kelly
@spkellydev
Jan 22 2017 01:49
I need to find the largest number in a subarray, but I've got it to tell me the largest number in the position of all subarrays

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

return largest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
returns
[1000,1001,857,39]
Johnny
@JohnnyBizzel
Jan 22 2017 01:50
@spkellydev To add items to an array use push()
Sean Kelly
@spkellydev
Jan 22 2017 01:50
I should get [5,27,39,1001]
so I should write largest.push(arr[i][j]);
David Amanze
@GodKingShogun
Jan 22 2017 01:51
@spkellydev what is largest [j]
Harout Payaslyan
@hpaya
Jan 22 2017 01:51
var count = 0;

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

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

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Im curious to know what the ? mark does during the return + count (count > 0 ? " Bet" : " Hold”);
Johnny
@JohnnyBizzel
Jan 22 2017 01:51
@spkellydev Do you want to know the clever way to do this *which I did not think of personally
TJ
@tjharris12
Jan 22 2017 01:51
var myStr; // "I am a \"double quoted\" string inside \"double quotes\".";
Sean Kelly
@spkellydev
Jan 22 2017 01:51
to map it?
@JohnnyBizzel should I use map
Anh Nguyen
@tiremon112
Jan 22 2017 01:52
When i did that trick johny 3 of them turn back to red
O.O
Jor
@joreyesl
Jan 22 2017 01:52
@tiremon112 see if this logic makes more sense
-- Loop through list
1. If firstName matches then
a. Check if contact has the given prop, if yes return the prop
b. else return no such property.
--Loop end
2. if there were no matches then its safe to assume that the contact does not exist.
Sean Kelly
@spkellydev
Jan 22 2017 01:52
@GodKingShogun the largest j should be the largest of each subarray
Anh Nguyen
@tiremon112
Jan 22 2017 01:52
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++)
{
if (contacts[i].firstName && contacts[i].hasOwnProperty(prop) === firstName)
{
return contacts[i][prop];
}

else{
return "No such property";
}

}
return "No such contact";
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Johnny
@JohnnyBizzel
Jan 22 2017 01:52
@spkellydev The smart way is to sort each small (sub) array which will give you the value you need to add to the final result array.
Seth Church
@iEnder
Jan 22 2017 01:52
@spkellydev a really easy way to find the max value in an array is with the spread operator
let max = Math.max(...[1,2,3]); // 3
Johnny
@JohnnyBizzel
Jan 22 2017 01:53
@pkmn9060 :clap:
Sean Kelly
@spkellydev
Jan 22 2017 01:53
huh, is that efficient on a larger scale?
Seth Church
@iEnder
Jan 22 2017 01:53
yes it will return the max value of an array regardless of length
Johnny
@JohnnyBizzel
Jan 22 2017 01:54
@pkmn9060 Works for numbers (but not for text I guess)
Nekmese
@Nekmese
Jan 22 2017 01:54

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

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

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

Sean Kelly
@spkellydev
Jan 22 2017 01:54
oh okay - well then would I just need to write a function that uses the Math.max(param)
Nekmese
@Nekmese
Jan 22 2017 01:54
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86
help me with this
CamperBot
@camperbot
Jan 22 2017 01:54
no wiki entry for: me with this
Johnny
@JohnnyBizzel
Jan 22 2017 01:54
Harout Payaslyan
@hpaya
Jan 22 2017 01:54
Can someone tell me what the ? mark does in line
return count + (count > 0 ? " Bet" : " Hold”);
Seth Church
@iEnder
Jan 22 2017 01:55
the "..." part is the spread operator that needs to come before the array
David Amanze
@GodKingShogun
Jan 22 2017 01:55
@Nekmese try to start by writing some code from the information you were given
Johnny
@JohnnyBizzel
Jan 22 2017 01:55
@hpaya It is called a ternary operator
Harout Payaslyan
@hpaya
Jan 22 2017 01:55
Thanks @JohnnyBizzel
CamperBot
@camperbot
Jan 22 2017 01:55
hpaya sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1167 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Nekmese
@Nekmese
Jan 22 2017 01:55
@GodKingShogun i just dont know where to start this
Sean Kelly
@spkellydev
Jan 22 2017 01:55
@pkmn9060 Thanks @JohnnyBizzel @GodKingShogun I'm gonna try to figure out how that works
CamperBot
@camperbot
Jan 22 2017 01:55
spkellydev sends brownie points to @pkmn9060 and @johnnybizzel and @godkingshogun :sparkles: :thumbsup: :sparkles:
:star2: 1168 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Jor
@joreyesl
Jan 22 2017 01:55
@hpaya ternary operation, means if count > 0 is true then return " Bet" else " Hold”
Johnny
@JohnnyBizzel
Jan 22 2017 01:55
Harout Payaslyan
@hpaya
Jan 22 2017 01:56
Thanks @joreyesl @JohnnyBizzel
CamperBot
@camperbot
Jan 22 2017 01:56
hpaya sends brownie points to @joreyesl and @johnnybizzel :sparkles: :thumbsup: :sparkles:
:warning: hpaya already gave johnnybizzel points
David Amanze
@GodKingShogun
Jan 22 2017 01:56
@Nekmese start by reading the instructions carefully and you should be able to write some code
Johnny
@JohnnyBizzel
Jan 22 2017 01:56
@spkellydev Good luck
@Nekmese It's just a simple mathematic equation.
David Amanze
@GodKingShogun
Jan 22 2017 01:57
@Nekmese your giving the conversion equation from Celsius to fahrenheit
you're*
Anh Nguyen
@tiremon112
Jan 22 2017 01:58
@JohnnyBizzel ty
CamperBot
@camperbot
Jan 22 2017 01:58
tiremon112 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1169 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
David Amanze
@GodKingShogun
Jan 22 2017 01:58
@JohnnyBizzel so am i able to call multiple values to search for when i am using indexOf()
Anh Nguyen
@tiremon112
Jan 22 2017 01:58
@JohnnyBizzel if (contacts[i].hasOwnProperty(prop) && contacts[i].firstName == firstName) this didn't work johnny i have to use to old one to pass the challenge
Johnny
@JohnnyBizzel
Jan 22 2017 01:59
@tiremon112 Spoiler alert :exclamation: How I did it: https://jsfiddle.net/JohnnyBizzel/xky73ga9/
@GodKingShogun Really? How so?
Jor
@joreyesl
Jan 22 2017 02:00
wow
David Amanze
@GodKingShogun
Jan 22 2017 02:00
@JohnnyBizzel i was asking if that is possible
Jor
@joreyesl
Jan 22 2017 02:00
@GodKingShogun no you can only search for 1 value
Seth Church
@iEnder
Jan 22 2017 02:00
@GodKingShogun no. it only returns the first instance
David Amanze
@GodKingShogun
Jan 22 2017 02:02
@joreyesl @pkmn9060 i am on the mutations challenge. that is why i am asking. so if i use indexOf(line) and the word is alien will it return true
@JohnnyBizzel chip in to if you know
KUDASAI
Jor
@joreyesl
Jan 22 2017 02:03
@GodKingShogun no because it will try to match the whole string
you have to check each character seperately
Anh Nguyen
@tiremon112
Jan 22 2017 02:05
@JohnnyBizzel Wow johnny that code look way more complex than i thou
ght
David Amanze
@GodKingShogun
Jan 22 2017 02:05
@tiremon112 that is @JohnnyBizzel for you
Seth Church
@iEnder
Jan 22 2017 02:05
@GodKingShogun if your just checking if "alien" is in the string/array then it should work
Johnny
@JohnnyBizzel
Jan 22 2017 02:05
@GodKingShogun I did a loop testing all of the characters.
Seth Church
@iEnder
Jan 22 2017 02:05
indexOf will return -1 if its not in the string/array
David Amanze
@GodKingShogun
Jan 22 2017 02:06
@JohnnyBizzel for the mutation challenge
Johnny
@JohnnyBizzel
Jan 22 2017 02:06
@tiremon112 Does the job though. There are smarter ways to do it.
David Amanze
@GodKingShogun
Jan 22 2017 02:07
@pkmn9060 i am checking to see if the letters of line are in alien and if it is i want it to return true
Jan 22 2017 02:07
OK @JohnnyBizzel Thats what it was .. Thanks for you help on that one
CamperBot
@camperbot
Jan 22 2017 02:07
brenbrad sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
Johnny
@JohnnyBizzel
Jan 22 2017 02:07
@GodKingShogun Loop through each letter of the 2nd array - if it doesn't exist in the 1st array (indexOF) then return

### false

$simples$
Anh Nguyen
@tiremon112
Jan 22 2017 02:08
@JohnnyBizzel what are your thought on derek banas video?
Johnny
@JohnnyBizzel
Jan 22 2017 02:08
@tiremon112 I like him. He gets to the point. And all his code is downloadable.
Seth Church
@iEnder
Jan 22 2017 02:08
@GodKingShogun then youll have to loop though the string and check indexOf character by character
David Amanze
@GodKingShogun
Jan 22 2017 02:09
@JohnnyBizzel if i am using a loop what would i have as the initial value so the code knows to start on the second element of the array
Jor
@joreyesl
Jan 22 2017 02:09
@GodKingShogun you will loops on 2nd str, so arr[1]
Johnny
@JohnnyBizzel
Jan 22 2017 02:10
@GodKingShogun What Jor said
Michael Vinson
@MVinsonCPNB
Jan 22 2017 02:13
Anyone know whats better for animation CSS or JS
I need very specific animation but don't know which one to spend time learning
Garo
@Garabed96
Jan 22 2017 02:17
function largestOfFour(arr) {
// You can do this!
var currNumb ;
var numb = 0;
var greatest = [];
// finds number of inner arrays in the array,
for(i=0;i<arr.length;i++){

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

currNumb = arr[i][j];
if(currNumb > numb){
numb = currNumb;
}

}
greatest += numb;
}
return greatest;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
TaylorPzreal
@TaylorPzreal
Jan 22 2017 02:17
Animate.css is fine
Garo
@Garabed96
Jan 22 2017 02:17
guys for this when i get to the end of my inner for loop Ik im doing something wrong as it doesnt save it to a list of arrays
is there a way i can make my numb variable an array or ?
Seth Church
@iEnder
Jan 22 2017 02:19
@MVinsonCPNB depends on what your trying to do though if your trying to trigger a animation when the user does somthing your gonna have to use some sort of javascript but it can just be adding a class which adds a css animation
David Amanze
@GodKingShogun
Jan 22 2017 02:19
@JohnnyBizzel @joreyesl @pkmn9060 i started the problem from your advise but still not right. take a look and give me some advise por favor
Ctiller93
@Ctiller93
Jan 22 2017 02:19
Heyo everybody.!
David Amanze
@GodKingShogun
Jan 22 2017 02:19

function mutation(arr) {
for (var i=arr[1]; i<arr.length; i++) {
if (i===arr.indexOf(arr[0])) {
return true;
} else {
return fale;
}
}

}
Ctiller93
@Ctiller93
Jan 22 2017 02:20
Typo in false.
Seth Church
@iEnder
Jan 22 2017 02:20
Jor
@joreyesl
Jan 22 2017 02:21
@GodKingShogun you have some of your variables mixed up.
for (var i=arr[1]; i<arr.length; i++) { i should start at 0, and go through the length of arr[1]
Ctiller93
@Ctiller93
Jan 22 2017 02:21
Uh, question: Can someone explain to me why for the palindrome check that "1 eye for of 1 eye." should return false?
Jor
@joreyesl
Jan 22 2017 02:21
@Ctiller93 you have to take numbers into account
Ctiller93
@Ctiller93
Jan 22 2017 02:21
I thought we were supposed to strip out all numbers, spaces and punctuation.
OHHHHH.
Jor
@joreyesl
Jan 22 2017 02:21
@Ctiller93 all special characters and spaces, but not numbers
Ctiller93
@Ctiller93
Jan 22 2017 02:21
All non-alphanumeric characters. Including numbers.
Duh!
Thanks @joreyesl !
CamperBot
@camperbot
Jan 22 2017 02:22
ctiller93 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
Seth Church
@iEnder
Jan 22 2017 02:22
@Garo Look into array methods
TaylorPzreal
@TaylorPzreal
Jan 22 2017 02:22

var count = 0;

function cc(card) {
// Only change code below this line
if(card >= 2 && card <= 6){
count += 1;
} else if (card >= 7 && card <= 10){
count += 0;
} else if (card == 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A'){
count -= 1;
}

console.log(count <= 0 ? count + ' Hold' : count + ' Bet');

return count <= 0 ? count + ' Hold' : count + ' Bet';
// Only change code above this line
}

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

what's the wrong with my code? who could help me,thx

David Amanze
@GodKingShogun
Jan 22 2017 02:22
@joreyesl arr is an array of two elements so i want to start on the second element and check if the second element's letters match the first elements
Seth Church
@iEnder
Jan 22 2017 02:23
@garo there is a way to add a value to an array but += isnt it
Jor
@joreyesl
Jan 22 2017 02:24
@GodKingShogun yes, you want to iterate on the 2nd element. The 2nd element is a str
Johnny
@JohnnyBizzel
Jan 22 2017 02:24
@GodKingShogun I did this:
var charsToTest = arr[1].toLowerCase().split('');
gives me an array of the characters I need to test against the 1st array
I will loop through these to find one which is not in the 1st array
David Amanze
@GodKingShogun
Jan 22 2017 02:25
@JohnnyBizzel can i write that part of the code in my initialize part of my for loop
Johnny
@JohnnyBizzel
Jan 22 2017 02:26
@GodKingShogun Why?
David Amanze
@GodKingShogun
Jan 22 2017 02:26
@JohnnyBizzel so i can loop through each character of the second element
Jor
@joreyesl
Jan 22 2017 02:28

@GodKingShogun ex:
when I have 1 string, I do this

var str = "string";

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

}

but when I have an array of strings I have to do this

var str = ["string1", "string2"];

for(var i = 0; i < str[1].length;i++) {

}
Johnny
@JohnnyBizzel
Jan 22 2017 02:28
@GodKingShogun Did you follow what I did?
@GodKingShogun I did this:
var charsToTest = arr[1].toLowerCase().split('');
gives me an array of the characters I need to test against the 1st array
I will loop through these to find one which is not in the 1st array
TaylorPzreal
@TaylorPzreal
Jan 22 2017 02:28
i found what's wrong with my problem.
David Amanze
@GodKingShogun
Jan 22 2017 02:29
@joreyesl the way i have it would yield the same results right
Johnny
@JohnnyBizzel
Jan 22 2017 02:31
@GodKingShogun I have to go to bed. You are welcome to see how I did it:
http://coding.citytravelling.me.uk/mutation.html
Ctiller93
@Ctiller93
Jan 22 2017 02:31
Hah. Regular expressions are sweeet.
David Amanze
@GodKingShogun
Jan 22 2017 02:31
@JohnnyBizzel i will but you never did tell me if i could skip the variable initialize part and just implement it in my loop initialization like so
 for (var i=arr[1].toLowerCase().split(""); i<arr.length; i++)
Jor
@joreyesl
Jan 22 2017 02:31
@GodKingShogun well lets see what you actually have when you do this
for (var i=arr[1]; i<arr.length; i++) {
var arr = ["hello", "Hello"];

console.log(arr[1]); // prints "Hello"
console.log(arr.length); // prints 2

//so you have the following
for(var i = "Hello"; i < 2; i++) {
}
Johnny
@JohnnyBizzel
Jan 22 2017 02:32
@GodKingShogun Maybe, but I did it another way - a way I understand which is easy to read.
Ctiller93
@Ctiller93
Jan 22 2017 02:32
Though general question, is there an operation that reverses an array without actually acting on the array?
I was able to get by by using .slice() but I'm wondering if there's a cleaner way to accomplish that.
David Amanze
@GodKingShogun
Jan 22 2017 02:33
@JohnnyBizzel ok good night SENPAI
Jor
@joreyesl
Jan 22 2017 02:35
@Ctiller93 thats probably going to be the best method array.slice().reverse() or [...array].reverse()
Ayush Bahuguna
@relentless-coder
Jan 22 2017 02:54
does anyone here use atom? I can't use the jslinting on it
Milos Ratkovic
Jan 22 2017 03:04
Hey guys, anyone here can tell me why my :visited selector doesnt work, here's my codepen : http://codepen.io/Shadow032/full/QdvbbK/
Jake
@neozane1
Jan 22 2017 03:09
hello world
CamperBot
@camperbot
Jan 22 2017 03:09

## welcome to FreeCodeCamp @neozane1!

Jake
@neozane1
Jan 22 2017 03:09
anyone good at title case a sentence algorithm challenge
i can get it split and to upper case im just having problems with selecting the specific char
Garo
@Garabed96
Jan 22 2017 03:11
charAt()
@neozane1
Jake
@neozane1
Jan 22 2017 03:12
so @Garabed96 if i use say charAt(0) that will be the first line of each word in the string correct
Garo
@Garabed96
Jan 22 2017 03:13
no that will be the first character aka letter in the word
if thats what you meant lol
Jake
@neozane1
Jan 22 2017 03:13

a @Garabed96 function titleCase(str) {
var newStr=str.split(" ");
if(newStr){

return newStr.toUpperCase(str.charAt(0));

}else{
return 0;
}

}

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

Garo
@Garabed96
Jan 22 2017 03:14
you should be using a loop
split is splitting the string into an array of strings
Jor
@joreyesl
Jan 22 2017 03:15
@Shadow032 what behavior are you expecting that is not happening?
Garo
@Garabed96
Jan 22 2017 03:15
you'd want to access each string in the array one at a time .. and capitalize the first letter, then proceed to add the rest of ther string to it
Jake
@neozane1
Jan 22 2017 03:15
so if i did i=str.charAt(0);
and @joreyesl im trying to get it to capitalize the first letter of each word in a string
Garo
@Garabed96
Jan 22 2017 03:15
again, str.charAt is not pointing at the string in the array
you'd need something like this str[i] = str[i].charAt(0).toUpperCase();4
str[i] = str[i].charAt(0).toUpperCase();
Jake
@neozane1
Jan 22 2017 03:16
ok so if i did
for(i=0;i<=str.length;i++){
Garo
@Garabed96
Jan 22 2017 03:17
why <=
Jake
@neozane1
Jan 22 2017 03:18
what i thought it was for was iterating thru the loop finding the charAt(0)
Jor
@joreyesl
Jan 22 2017 03:18
@Garabed96
var newStr = str.split(" "); //this is good

for( ) { // loop through the array newStr
//replace each element/word with a capitalized word
}

// combine the array back to a single string and return it.
Jake
@neozane1
Jan 22 2017 03:18
and captializing it
Milos Ratkovic
Jan 22 2017 03:18
@joreyesl So when I click random article for example, it opens up a new random wiki tab, that's ok, but when i come back to my Wiki Viewer that 'random article' get's all blue and has an text-decoration of underline.
Garo
@Garabed96
Jan 22 2017 03:18
@joreyesl ?
mmacedom
@mmacedom
Jan 22 2017 03:19

Hello everyone, I've been working through some of the initial JavaScript challenges (#155) and I'm having some trouble with it. Could anyone of you let me know what I'm missing on it. Thanks in advance.
var result = "";
// Your code below this line
console.log("Look at my" + myAdjective + "goofy" + myNoun + "! it just" + myVerb + "past me and" + myAdverb + "turned back around");

// Your code above this line
return result;
}

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

Garo
@Garabed96
Jan 22 2017 03:19
ya what he said @joreyesl
Jake
@neozane1
Jan 22 2017 03:19
but i only want the first letter captialized so would the for loop capitalize it
Garo
@Garabed96
Jan 22 2017 03:19
strings are immutable
Jake
@neozane1
Jan 22 2017 03:19
them all i mean
Manish Giri
@Manish-Giri
Jan 22 2017 03:19
@mmacedom you need to assign the concatenated string to result, instead of console.log
console.log("Look at my" + myAdjective + "goofy" + myNoun + "! it just" + myVerb + "past me and" + myAdverb + "turned back around");
Garo
@Garabed96
Jan 22 2017 03:20
you cant just change the first letter, you can make a new string with just that letter in it, then u have to attach rest of string
Jor
@joreyesl
Jan 22 2017 03:20
@Shadow032 that is weird, I looked at your pen and for me after i clicked it, it remained the same.
Milos Ratkovic
Jan 22 2017 03:20
@joreyesl I know I can change that by setting up a:visited selector , but it doesnt work. When I click on random article I want it to have same properties as it had before it was visited. And I would like to change some properties for the links I get by searching something. So I can show someone he/she has already viewed that article.
mmacedom
@mmacedom
Jan 22 2017 03:20
@Manish-Giri Thanks for letting me know
CamperBot
@camperbot
Jan 22 2017 03:20
mmacedom sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3911 | @manish-giri |http://www.freecodecamp.com/manish-giri
Milos Ratkovic
Jan 22 2017 03:21
@joreyesl hm. It doesnt work for me. When I click it , it get those default <a> properties, like its all blue with an underline :D
Jake
@neozane1
Jan 22 2017 03:21
ok ill seperate the letters first and then push them back into the string
Milos Ratkovic
Jan 22 2017 03:21
@joreyesl And when you search something and click on one of the results, do the text color change to like darker gray - #444
Jor
@joreyesl
Jan 22 2017 03:22
@Shadow032 yes they turn dark grey. When I click on the random, the link remain the same. What browser are you on?
Milos Ratkovic
Jan 22 2017 03:24
@joreyesl Hmm, I dont know what's going on, I cant even tell how dark that is , I didnt even see that, I just thougth i would point visited like out like darkening the text. Anyway, seems like its up to me. I dont know why it doesnt work in CodePen, I tried it in Notepad++ and it works fine. Seems like a CodePen bug or something
@joreyesl Chrome.
Jor
@joreyesl
Jan 22 2017 03:24
Jerry Purvis
@MessiaHack
Jan 22 2017 03:26

just testing my search box at the moment, and trying to figure out why it's not including the value from my text box in the append function once I click submit

http://codepen.io/MessiaHack/pen/QdNZvR

Jor
@joreyesl
Jan 22 2017 03:26
@Shadow032 Ok i think it has to do with chrome. When I click on the link, it turns blue, then when I change focus to main page again it turns back to normal.
Milos Ratkovic
Jan 22 2017 03:27
@joreyesl I just tried Microsoft Edge and it works actually, the colors at least.... But the text still has underline property after clicking on them
@joreyesl Yep that's exactly what I'm getting.
@Shadow032 Thanks for looking into it. ;)
CamperBot
@camperbot
Jan 22 2017 03:29
sorry shadow032, you can't send brownie points to yourself! :sparkles: :sparkles:
Paulo Tokimatu
@paulotokimatu
Jan 22 2017 03:30
@MessiaHack the only time you assign a value to searchText is after the page loading. You need to assign the value of the input inside the click function of the button
Milos Ratkovic
Jan 22 2017 03:30
@joreyesl oh shiet lmao , thanks for looking into it :)))
CamperBot
@camperbot
Jan 22 2017 03:30
shadow032 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
Paulo Tokimatu
@paulotokimatu
Jan 22 2017 03:30
And do not forget to concatenate the two strings inside the onClick too
mmacedom
@mmacedom
Jan 22 2017 03:32
@Manish-Giri I assigned the string to result, like so... result = "Look at my " + myAdjective + " goofy " + myNoun + "! it just " + myVerb + "past me and " + myAdverb + " turned back around"; however I'm still unable to get it right. What am doing wrong?
Manish Giri
@Manish-Giri
Jan 22 2017 03:33
@mmacedom show the complete code
mmacedom
@mmacedom
Jan 22 2017 03:34

var result = "";
// Your code below this line
result = "Look at my " + myAdjective + " goofy " + myNoun + "! it just " + myVerb + "past me and " + myAdverb + " turned back around";

// Your code above this line
return result;
}

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

Manish Giri
@Manish-Giri
Jan 22 2017 03:35
@mmacedom can you post your challenge URL here? click "run tests " first.
Jor
@joreyesl
Jan 22 2017 03:35
@mmacedom you shouldnt add any extra words there, just + " " between each parameter
mmacedom
@mmacedom
Jan 22 2017 03:36
@joreyesl oh ok
Manish Giri
@Manish-Giri
Jan 22 2017 03:36

@joreyesl that's not right

should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).

Jor
@joreyesl
Jan 22 2017 03:38
i guess i missed that part when I did the challenge. But mine passed with just " " between words.
mmacedom
@mmacedom
Jan 22 2017 03:38
@Manish-Giri the rule you just posted is the exact reason I added the additional words in between the variables. But still it won't let me pass the challenge
Manish Giri
@Manish-Giri
Jan 22 2017 03:38
@mmacedom yeah, i'm looking, hold on
@mmacedom got it, add a space before past
Jor
@joreyesl
Jan 22 2017 03:39
@mmacedom ok i think i see it. you need a space, rip @Manish-Giri caught it already lol
Jerry Purvis
@MessiaHack
Jan 22 2017 03:40
thanks @paulotokimatu
mmacedom
@mmacedom
Jan 22 2017 03:40
@Manish-Giri @joreyesl thank you so much guys. it worked on my end as well. :-)
CamperBot
@camperbot
Jan 22 2017 03:40
messiahack sends brownie points to @paulotokimatu :sparkles: :thumbsup: :sparkles:
mmacedom sends brownie points to @manish-giri and @joreyesl :sparkles: :thumbsup: :sparkles:
:warning: mmacedom already gave manish-giri points
Garo
@Garabed96
Jan 22 2017 03:55
Guys I have like 6-7 more of the intro to algorithms, was just wondering if they implement object oriented into it
9 more*
Kodati Sai Kiran
@saiki96
Jan 22 2017 03:59
http://codepen.io/saiki96/pen/QddmVX
taithethai
@taithethai
Jan 22 2017 04:02
@saiki96 it's the h1 a bit too close to the top?
May be a stylistic choice
it's = isn't*
@saiki96 would you consider fixing the button to an absolute location?
Nataly C.
@cstpk
Jan 22 2017 04:06
@saiki96 well done, i would change the text font and the buttons to look more modern, and maybe centralize h2, but this is just my personal taste
Garo
@Garabed96
Jan 22 2017 04:10
Anyone mind explaining Confirm the ending for me... in algorithms, (everything works except this one) --> confirmEnding("Open sesame", "same") should return true.
I don't get it, do I hard code that part or its supposed to match the last characters of the second argument with the last word in the first argument?
Jesse
Jan 22 2017 04:15
Just threw in some basic J.S. Functions to my codepen http://codepen.io/lookinahead/pen/oBvrQE?editors=0010 Thought it was cool! onClick and onLoad!
Jan 22 2017 04:16
@Garabed96 - the number of characters in the match string is 4 - so you should compare that against the last 4 characters of the source string (whatever they call the arguments.) It's a test that you properly can handle more than a single letter match, I think? I'd have to look at the challenge to make sure.
Daniel Wagener
@SigniorGratiano
Jan 22 2017 04:17

Doing Caesar's Cipher, right now I'm just testing to create an array of character codes. Can someone explain why my conditionals of my if/else statement aren't working? In my mind, str.charCodeAt(i) is equivalent to a number. For example: if str[0] = Z, then (64 < 90 <= 77) should evaluate to false and move on to the next line of the if/else statement. However, my code just runs the first push function no matter what. For example, Z gets pushed into my "ciphered" array as 103, when I want it to be 77.

function rot13(str) { // LBH QVQ VG!
var ciphered = [];

for (i = 0; i < str.length; i++){
if (64 < (str.charCodeAt(i)) <= 77) {
ciphered.push(str.charCodeAt(i) + 13);
} else if (77 < (str.charCodeAt(i)) <= 90) {
ciphered.push(str.charCodeAt(i) - 13);
} else {
ciphered.push(str[i]);
}
}

return ciphered;
}

So, calling the function rot13("ABCDY") returns [78, 79, 80, 81, 102], but I instead want [78, 79, 80, 81, 76].

Jan 22 2017 04:18
@Garabed96 - yes, any of the other tests that should return true are either single letters or whole words - this one is a different condition in that the "target" value is a substring of the last word.
@SigniorGratiano - you cannot write a conditional test as if (64 < (str.charCodeAt(i)) <= 77) { - you cannot " chain" those together. You have to write two separate tests and use && or || to combine them.
Margaret
@Margaret2
Jan 22 2017 04:20
@Garabed96 you have to see if the second argument "same" matches the last letters of the first argument "Open sesame"
Jan 22 2017 04:20
in other words, it would be something like if (64 < (str.charCodeAt(i)) && (str.charCodeAt(i)) <= 77) { @SigniorGratiano
Karan Nandha
@karann7
Jan 22 2017 04:20
hello guys can anyone help me with comparisons of object keys
Margaret
@Margaret2
Jan 22 2017 04:21
and you should not be hard coding each one, you want your function to work for any values you pass in
Karan Nandha
@karann7
Jan 22 2017 04:21
i need the function to return what values are missing from the other object
Garo
@Garabed96
Jan 22 2017 04:22
@Margaret2 @khaduch got it ez, just check if the lengths are equal first
thank you
well make the first args lenght equal...
Jan 22 2017 04:22
@karannandha - do you have code to show what you're doing at this point? You can use Object.keys to get a list of the keys, and then just use .hasOwnProperty and match the values if both objects have the properties.
Jake
@neozane1
Jan 22 2017 04:22

anyone know why charAt isnot working function titleCase(str) {
var strCap=str.split(" ");
for (var i=0;i<=strCap.length;i++){
var placeHolder = strCap[i];
var capLetter= placeHolder.charAt(0).toUpperCase();
placeHolder= capLetter.slice(1, placeHolder.length).toLowerCase();
strCap[i] = capLetter.concat(placeHolder);
}
str = strCap.join(" ");

return str;

}

Karan Nandha
@karann7
Jan 22 2017 04:24

var hello = {
a: 1,
b: 2,
c: 3
}

var bye = {
a: 1,
b: 2,
c: 3,
}

function extend(obj1, obj2) {
keys1 = JSON.stringify(obj1);
keys2 = JSON.stringify(obj2);
if (keys1 === keys2) {
console.log('All the Keys match!');
} else {
console.log('All the keys don\'t match!');
}
}
extend(hello, bye);

@khaduch i need the code to return what keys are missing so that i can put the missing keys from object 2 to object 1
Jan 22 2017 04:27
@neozane1 - the .charAt(0) is working fine - you will get a capitalized letter in the variable. It's what you're doing next that isn't working. You need to look at what .slice does.
Jake
@neozane1
Jan 22 2017 04:28
@khaduch did i slice at the wrong point?
Karan Nandha
@karann7
Jan 22 2017 04:28
@khaduch instead of just saying "all the keys don't match", i need to find out which keys don't match and then take those keys and put only the keys from object 2 to object 1
Jan 22 2017 04:28
@neozane1 - capLetter is only going to have a single uppercased letter in it. You will want to combine that with the remainder of the original word - from letter "1" to the end.
Moisés Man
@moigithub
Jan 22 2017 04:29
@karannandha u can use Object.keys method to get a key list.. then iterate the list and check with hasOwnProperty method to check if the other object have the property on the list
Joseph
@revisualize
Jan 22 2017 04:29
This message was deleted
Jan 22 2017 04:29
@moigithub - I wish I had said that... :) :point_up: January 21, 2017 11:22 PM
Jake
@neozane1
Jan 22 2017 04:29
should i do it with placeHolder.charAt(0)
Joseph
@revisualize
Jan 22 2017 04:29
damn it.. My shit isn't refreshing.
Moisés Man
@moigithub
Jan 22 2017 04:30
abdi rahman
@abdiezy
Jan 22 2017 04:30
little help over here

function diffArray(arr1, arr2) {

var somthing = arr1.concat(arr2);

return somthing.sort().filter(function(item, index, ary) {
return item == ary[index - 1];
});

}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Karan Nandha
@karann7
Jan 22 2017 04:30
@moigithub i can already do that with JSON.stringify() without having to use a loop the problem is i don't know how to get only the keys that are missing
Jan 22 2017 04:31
@neozane1 placeHolder has the original word in it. the capLetter has the first letter capitalized. If you slice off the last part of the word and concatenate it with the capitalized letter, then you should have it.
Jake
@neozane1
Jan 22 2017 04:31
@khaduch ok thanks ill try that
CamperBot
@camperbot
Jan 22 2017 04:31
neozane1 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Jan 22 2017 04:32
@karannandha - as @moigithub (and I) said - use Object.keys to get a list of the keys, then you iterate the list, using a for loop or iteration mechanism of your choice and compare the keys, noting the ones that are missing, etc. You have to examine the objects one key at a time in order to know what's missing or present.
Karan Nandha
@karann7
Jan 22 2017 04:33
@khaduch gotcha so once i iterate over what can i do to note the missing keys?
@khaduch do i make an empty object and populate that with the missing values?
or can i directly paste the missing values to the object being compared?
Daniel Wagener
@SigniorGratiano
Jan 22 2017 04:35
@khaduch Thanks! Still working on completing the challenge but you've helped me get that part of the code running as it should.
CamperBot
@camperbot
Jan 22 2017 04:35
signiorgratiano sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Jan 22 2017 04:35
@karannandha - you compare the keys from the first object to those in the second - if something is missing you can just create it, or you can make an empty object and copy the unique values to it, generating one that has all keys. I'm not sure exactly what you need to return?
@karannandha - is this one of the freecodecamp challenges?
@SigniorGratiano - great! That is a common misconception that people have, to code those types of conditionals. I'm not sure if there is any computer language that supports it, it is definitely a common mathematical equation form. That's probably where the idea comes from.
Karan Nandha
@karann7
Jan 22 2017 04:40
@khaduch no. but i will do what you said. i will use a for loop to check for properties rather than JSON.stringify();
Lyddip
@lydiayhuang
Jan 22 2017 04:43
Hi guys I have a questions
*question
Ogundele Olumide
@Lumexralph
Jan 22 2017 04:43
@lydiayhuang shoot
Lyddip
@lydiayhuang
Jan 22 2017 04:43

Write a function called "or".

Given 2 boolean expressions, "or" returns true or false, corresponding to the || operator.

Notes:

• Do not use the || operator.
• Use ! and && operators instead.
Ogundele Olumide
@Lumexralph
Jan 22 2017 04:43
Lyddip
@lydiayhuang
Jan 22 2017 04:43
this is my code

function or(expression1, expression2) {

if(expression1 !== expression2) {
return true;
} else if (expression1 == expression2 ) {
return true;
} else if (expression1 && expression2 === false) {
return false;
}
}

var output = or(true, false);
console.log(output); // --> true;

Dariusz Sikorski
@dariuszsikorski
Jan 22 2017 04:44
Hello, im using moment.js library...
Lyddip
@lydiayhuang
Jan 22 2017 04:44
so I'm stumped
and it's not working..because when there's 2 false, the function doesn't return false
Jake
@neozane1
Jan 22 2017 04:44

@khaduch its still saying cannot read property even after i did this function titleCase(str) {
var strCap=str.split(" ");//split the string
for (var i=0;i<=strCap.length;i++){
var placeHolder = strCap[i];
var capLetter= placeHolder.charAt(0).toUpperCase();//turn into uppercase

placeHolder= placeHolder.slice(1, placeHolder.length).toLowerCase(); //split string at char 1 to the end of the str

strCap[i] = capLetter.concat(placeHolder);//recombine it with the caps

str = strCap.join(" "); //join the string and strCap
}
return str;

Dariusz Sikorski
@dariuszsikorski
Jan 22 2017 04:45
on firefox moment() returns 4AM and on chrome moment() returns 5am... while acually my local time is 5am, how do i fix the date on firefox
Ogundele Olumide
@Lumexralph
Jan 22 2017 04:45
@lydiayhuang else if (expression1 && expression2 === false) you need to do something like (expre1 === false && expres2 === false)
Lyddip
@lydiayhuang
Jan 22 2017 04:46
ohhhhh
Jan 22 2017 04:47
@neozane1 - I think that .concat() is an array method? You are just trying to concatenate two strings, try +... capLetter + placeHolder.slice(1)
Ayush Bahuguna
@relentless-coder
Jan 22 2017 04:47
where do I ask help for backend stuff?
Lyddip
@lydiayhuang
Jan 22 2017 04:47
@Lumexralph uh..code failed.
Jan 22 2017 04:47
Joseph
@revisualize
Jan 22 2017 04:47
In the back end room.
@lydiayhuang What do you have now?
Jan 22 2017 04:48
@Lumexralph - hey there! :wave:
Ogundele Olumide
@Lumexralph
Jan 22 2017 04:48
@lydiayhuang what are the instructions? you might have logic bugs
Jan 22 2017 04:50
@Lumexralph - almost midnight here... time to call it a night! Have a great day!
Ayush Bahuguna
@relentless-coder
Jan 22 2017 04:50
@revisualize yes, I visited that room, but it is a ghost town. I needed help with basic routing stuff.
Lyddip
@lydiayhuang
Jan 22 2017 04:51

@Lumexralph function or(expression1, expression2) {

if(expression1 === true && expression2 === false) {
return true;
} else if (expression1 === true && expression2 === true ) {
return true;
} else if (expression 1 === false && expression 2 === true) {
return true;
} else if (expression1 === false && expression2 === false) {
return false;
}
}

Ayush Bahuguna
@relentless-coder
Jan 22 2017 04:52
@lydiayhuang you have space between the parameter names in the second else if
Lyddip
@lydiayhuang
Jan 22 2017 04:52
@Lumexralph actually, I passed yeah I saw that
Joseph
@revisualize
Jan 22 2017 04:52
@relentless-coder Good luck.
Lyddip
@lydiayhuang
Jan 22 2017 04:52
@relentless-coder is there an easier way to write the code in less lines?
abdi rahman
@abdiezy
Jan 22 2017 04:52
can anyone tell me where am going wrong

function diffArray(arr1, arr2) {

var somthing = arr1.concat(arr2);

return somthing.sort().filter(function(item, index, ary) {
return item == ary[index - 1];
});

}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Ogundele Olumide
@Lumexralph
Jan 22 2017 04:53
@lydiayhuang i don't understand?
Lyddip
@lydiayhuang
Jan 22 2017 04:53
@relentless-coder or am I just stuck with that many lines?
Lyddip
@lydiayhuang
Jan 22 2017 04:53
@Lumexralph is there a shorter way to write the function with less code?
Joseph
@revisualize
Jan 22 2017 04:53
@lydiayhuang Why aren't you just doing...
function or(e1 , e2) {
return e1 && e2;
}
Or
Jan 22 2017 04:54
back again hoping for some help..
Joseph
@revisualize
Jan 22 2017 04:54
@lydiayhuang Why aren't you just doing...
function or(e1 , e2) {
return e1 || e2;
}
Jan 22 2017 04:54

function caseInSwitch(val) {
// Only change code below this line
switch (val) {
case "alpha":
break;
case "beta":
break;
case "gamma":
break;
case "delta":

}

// Only change code above this line
}

// Change this value to test
caseInSwitch(3);
Ogundele Olumide
@Lumexralph
Jan 22 2017 04:54
Lyddip
@lydiayhuang
Jan 22 2017 04:54
@revisualize I can't use || it's a part of the given
Ayush Bahuguna
@relentless-coder
Jan 22 2017 04:54
@lydiayhuang yes. use || instead of &&.
so something like
if(exp1 === true || exp2 === true) {
return true;
} else {
return false
}
Joseph
@revisualize
Jan 22 2017 04:54
@brenbrad You're not modifying answer
@brenbrad So you're returning ""
Lyddip
@lydiayhuang
Jan 22 2017 04:54
@relentless-coder I can't use || it was part of the given
Jan 22 2017 04:55
ok thanks @revisualize
CamperBot
@camperbot
Jan 22 2017 04:55
brenbrad sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3076 | @revisualize |http://www.freecodecamp.com/revisualize
Lyddip
@lydiayhuang
Jan 22 2017 04:55
@relentless-coder so without using || is it still possible to shorten?
Joseph
@revisualize
Jan 22 2017 04:55
@lydiayhuang What IS the problem?
Ogundele Olumide
@Lumexralph
Jan 22 2017 04:55
@brenbrad your case staetement ... for each case assign the string to anwser case 1 not case "alpha"
Lyddip
@lydiayhuang
Jan 22 2017 04:55

Write a function called "or".

Given 2 boolean expressions, "or" returns true or false, corresponding to the || operator.

Notes:

• Do not use the || operator.
• Use ! and && operators instead.
@revisualize how can I use ! in this instance?
Joseph
@revisualize
Jan 22 2017 04:56
Like this
Jan 22 2017 04:56
thanks @Lumexralph
CamperBot
@camperbot
Jan 22 2017 04:56
brenbrad sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
Ogundele Olumide
@Lumexralph
Jan 22 2017 04:57
@abdiezy somthing.sort().filter how're you sorting without a callback function to sort your array, else it will sort them as a string
Joseph
@revisualize
Jan 22 2017 04:58
function or(e1 , e2) {
if (e1 && e2) return true;
if (e1 && !e2) return true;
if (!e1 && e2) return true;
if (!e1 && !e2) return false;
}
Daniel Wagener
@SigniorGratiano
Jan 22 2017 04:59

I'm doing Caesar's Cipher right now. I need help with a for loop that isn't looping.
Currently I have an array "ciphered" that contains character codes, spaces, and punctuation marks. I want to evaluate the character codes into characters (eg. 65 becomes "A"), keep the spaces and punctuation marks the same, and push everything into an array called "stringy."

 var stringy = [];

for (j = 0; j < ciphered.length; j++) {
if (ciphered[j] > 64 && ciphered[j] < 91) {
stringy.push(String.fromCharCode(ciphered[j]));
} else {
stringy.push(ciphered[j]);
}

return stringy;

WHAT'S RIGHT: Right now, an input ("ciphered") of [78] returns ["N"], an input of [" "] returns [" "], and an input of ["!"] returns ["!"]. That's all good. WHAT'S WRONG: An input [78, 79] returns ["N"], when I want to it return ["N", "O"]. In other words, my for loop runs once and then stops. Anyone know why?

Joseph
@revisualize
Jan 22 2017 04:59
@lydiayhuang Did I win a prize?
Damn. I'm at a restaurant... I really need to go to a different one.
abdi rahman
@abdiezy
Jan 22 2017 05:01
@Lumexralph its working but its not giving me the right answer i think....
Ogundele Olumide
@Lumexralph
Jan 22 2017 05:02
@abdiezy do you know what sort() does without a callback function?
abdi rahman
@abdiezy
Jan 22 2017 05:03
yeah...just passed a callback function its the same
Joseph
@revisualize
Jan 22 2017 05:03
The MDN shows you if you don't know!
@lydiayhuang You still there?
abdi rahman
@abdiezy
Jan 22 2017 05:04
function diffArray(arr1, arr2) {

var somthing = arr1.concat(arr2);

return somthing.sort(function(a, b) {
return a - b;
}).filter(function(item, index, ary) {
return item == ary[index + 1];
});

}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Ogundele Olumide
@Lumexralph
Jan 22 2017 05:05
@SigniorGratiano return stringy; you're returning stringy in the for loop, return it when the for loop is done, your loop executes once because of the return in the loop, which returns the value and stops the function while stopping the loop too
revisualize @revisualize leaves
Daniel Wagener
@SigniorGratiano
Jan 22 2017 05:06
@Lumexralph d'Oh! Thank you!
CamperBot
@camperbot
Jan 22 2017 05:06
signiorgratiano sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
Ogundele Olumide
@Lumexralph
Jan 22 2017 05:07
@SigniorGratiano :+1:
abdi rahman
@abdiezy
Jan 22 2017 05:07
@Lumexralph its returning all the elements that have duplicates in the array.....and i want all the element that don't have duplicates
Daniel Wagener
@SigniorGratiano
Jan 22 2017 05:07
@Lumexralph And I can call that challenge done!
heroiczero
@heroiczero
Jan 22 2017 05:09
@abdiezy you dont really need to sort() it just have to make sure it is not in just have to find if its not in both so maybe indexOf()
Ogundele Olumide
@Lumexralph
Jan 22 2017 05:11
@abdiezy how about you use indexOf and lastIndexOf ?
Alex
@AlexanderRobinson
Jan 22 2017 05:11
hey guys
Make Instances of Objects with a Constructor Function
im stuck on this
var myCar= new Car(this.nickname="Bruce"); this is what i got
Ogundele Olumide
@Lumexralph
Jan 22 2017 05:12
@AlexanderRobinson var myCar= new Car(this.nickname="Bruce") this is wrong
Alex
@AlexanderRobinson
Jan 22 2017 05:12
yes i know
Ogundele Olumide
@Lumexralph
Jan 22 2017 05:12
@AlexanderRobinson var myCar= new Car("Bruce")
Alex
@AlexanderRobinson
Jan 22 2017 05:12
thats why im lost
so itll just add it in ?
Ogundele Olumide
@Lumexralph
Jan 22 2017 05:13
@AlexanderRobinson yes
Alex
@AlexanderRobinson
Jan 22 2017 05:13
Ogundele Olumide
@Lumexralph
Jan 22 2017 05:13
@AlexanderRobinson what are you to do exactly?
Alex
@AlexanderRobinson
Jan 22 2017 05:13
like im ading another piece to it not really just making another car and labvelling bruce
Ogundele Olumide
@Lumexralph
Jan 22 2017 05:14
@abdiezy still there? have you tried it :point_up: January 22, 2017 6:11 AM
@AlexanderRobinson you want to create an instance of the constructor? am not getting your question
heroiczero
@heroiczero
Jan 22 2017 05:15
@AlexanderRobinson should just be var myCar= new Car(); and in new line print myCar.nickname=
Ogundele Olumide
@Lumexralph
Jan 22 2017 05:16
@heroiczero i don't even know how his constructor function is
@abdiezy return ary.indexOf(item) == ary.lastIndexOf(item); that will do what you want if the index of item is same in the array somthing
Alex
@AlexanderRobinson
Jan 22 2017 05:17
@heroiczero thank you
CamperBot
@camperbot
Jan 22 2017 05:17
alexanderrobinson sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
abdi rahman
@abdiezy
Jan 22 2017 05:20
@Lumexralph yeah it worked brownies to you
@Lumexralph send brownie
Ogundele Olumide
@Lumexralph
Jan 22 2017 05:21
@abdiezy you say thanks if you want to give me brownies :laughing:
CamperBot
@camperbot
Jan 22 2017 05:21
lumexralph sends brownie points to @abdiezy :sparkles: :thumbsup: :sparkles:
abdi rahman
@abdiezy
Jan 22 2017 05:22
and thanks of course
Jor
@joreyesl
Jan 22 2017 05:22
@lydiayhuang are you familiar with De Morgan's Law? It states that !(e1 || e2) === !e1 && !e2.
Then we can say e1 || e2 == !!(e1 || e2) == !(!e1 && !e2) so we can can use 1 expression to test for 'or' by
var t = true;
var f = false;

function or(e1 , e2) {
return !(!e1 && !e2);
}

console.log(or(t,t)); // true
console.log(or(t,f)); // true
console.log(or(f,t)); // true
console.log(or(f,f)); // false
Ogundele Olumide
@Lumexralph
Jan 22 2017 05:22
@abdiezy this got me cracking send brownie...... if you don't reference the name it won't work
abdi rahman
@abdiezy
Jan 22 2017 05:24
@Lumexralph am not frequent chat room.....thats why :smile:
Ogundele Olumide
@Lumexralph
Jan 22 2017 05:24
@abdiezy lol, okay try it again :laughing:
abdi rahman
@abdiezy
Jan 22 2017 05:26
@Lumexralph alright
Kodati Sai Kiran
@saiki96
Jan 22 2017 05:42
@taithethai i just wanted everything to be shown in one center since its a tiny application. It was a personal choice. would fix the button to absolute.... thank you for the suggestions
@natalyscosta thank you ......and thanks for the suggestion....of centralizing the h2 tag....will do it for sure...as time was limited due to personal reasons ...i dint give so much attention to styling ...only change the fonts ....that being said ...i would change the styling later for sure.....
CamperBot
@camperbot
Jan 22 2017 05:42
saiki96 sends brownie points to @taithethai and @natalyscosta :sparkles: :thumbsup: :sparkles:
jm4876
@jm4876
Jan 22 2017 05:54
Testing Objects for Properties
Ogundele Olumide
@Lumexralph
Jan 22 2017 05:54
@jm4876 okay.... what question do you have?
RyanWng
@RyanWng
Jan 22 2017 05:55

Hi, guys. If I have a function like this

function createObj(){
return new Promise(function(resolve, reject){
resolve("Done");
});
}

var pms = createObj();

How does this whole process run in terms of JavaScript's event loop?
Thanks.

joopt
@joopt
Jan 22 2017 05:55
can anyone help me
Return true if the given string is a palindrome. Otherwise, return false.
heroiczero
@heroiczero
Jan 22 2017 05:56
@jm4876 hasOwnProperty() method maybe
Ogundele Olumide
@Lumexralph
Jan 22 2017 05:57
@RyanWng Promise is an API in JS for asynchronous code
joopt
@joopt
Jan 22 2017 05:57
function palindrome(str) {
// Good luck!
if (str == str.split('').replace(/ /g, "").toLowerCase().reverse().join("")){

return true;
}
}

palindrome("eye");
tells me str.split(....).replace is not a function
Ogundele Olumide
@Lumexralph
Jan 22 2017 05:57
@joopt (/ /g what do you want to replace? you have not constructed your reg pattern
heroiczero
@heroiczero
Jan 22 2017 05:57
@joopt / /ggotta replace all non-alphanumeric
RyanWng
@RyanWng
Jan 22 2017 05:58
@Lumexralph Yes, But I know. Is it different if I use return new Object(); here?
Ogundele Olumide
@Lumexralph
Jan 22 2017 05:58
@RyanWng yes it's
@RyanWng why are you using Promise?
joopt
@joopt
Jan 22 2017 05:59
@Lumexralph trying to replace the spaces and other symbols
@heroiczero is there a shortcut to replace all non-alphanumerics?
Kodati Sai Kiran
@saiki96
Jan 22 2017 06:00
hello everyone.....can anyone suggest me to access the followers of freecodecamp in twitch?
heroiczero
@heroiczero
Jan 22 2017 06:00
RyanWng
@RyanWng
Jan 22 2017 06:00
If I rephrase my question, I'd say, what's the difference between return 20 and return new Promise(function(resolve, reject){ resolve("Done"); });
@Lumexralph
Ogundele Olumide
@Lumexralph
Jan 22 2017 06:01
@joopt W is for non-alphanumeric character
RyanWng
@RyanWng
Jan 22 2017 06:02
@Lumexralph I am learning Promise, and I got different output order when I used return 20 and return new Promise(function(resolve, reject){ resolve("Done"); }); in the same place of a function.
So I wonder how they work differently in event loop.
heroiczero
@heroiczero
Jan 22 2017 06:02
@joopt but the \W is [^A-Za-z0-9_] so it includes _ you gotta get rid of it so modify the regexp
Ogundele Olumide
@Lumexralph
Jan 22 2017 06:05
@RyanWng return 20 is just returning a value, while the other returns a Promise object instance which will require functions for resolve and reject
Jor
@joreyesl
Jan 22 2017 06:05
@joopt try \W|_/g
Also you want to do the replace and lowercase before you split it
joopt
@joopt
Jan 22 2017 06:06
CamperBot
@camperbot
Jan 22 2017 06:06
joopt sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
joopt
@joopt
Jan 22 2017 06:07
@joreyesl it tells us to split before reversing for the other challenge
@joreyesl how do i know what method to use first?
Jor
@joreyesl
Jan 22 2017 06:09
@joopt well .replace and .toLowerCase are methods used on a string. if you split it first you will get an error. You have to think it through, there really is no way to know exactly what to use first, aside from knowing what methods you can call.
RyanWng
@RyanWng
Jan 22 2017 06:09
@Lumexralph Sorry I didn't present my question well. So if you'd like to have a look at the code here http://jsbin.com/teqihiwafo/edit?js,console , and you run one time with return 29 uncommented and return new Promise(); commented, then run in the other way around, you would find that the two outputs have different order, so that's what I don't quite understand.
joopt
@joopt
Jan 22 2017 06:10
@joreyesl ahhh i see that makes sense thanks a lot
CamperBot
@camperbot
Jan 22 2017 06:10
joopt sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
joopt
@joopt
Jan 22 2017 06:14

@joreyesl 
function palindrome(str) {
// Good luck!
if (str == str.replace(/\W|_/g, "").toLowerCase().split('').reverse().join("")){

return true;
} else {
return false;
}
}

palindrome("eye");


@joreyesl i tried this but its not passing _Car, and Race car
Ogundele Olumide
@Lumexralph
Jan 22 2017 06:15
@RyanWng not seeing the code, seeing something else
@joopt you need to compare the refined str without the non- alphanumeric with reversed form....
Jor
@joreyesl
Jan 22 2017 06:18
@joopt As @Lumexralph said, right now str still contains the special characters and spaces. You should remove those, then compare to the reversed string. .replace and .toLowerCase dont alter the original string. So you need to reassigned the cleaned string back to str.
Ogundele Olumide
@Lumexralph
Jan 22 2017 06:18
@RyanWng i have foo, bar console. logging 42
@RyanWng link didn't get the code you wanted
Ghulam Shabir
@ghulamshabir
Jan 22 2017 06:24
@AidenTheCoder create a new instance of Car using new operator and assign it to myCar then add nickname with value of anything you want using dot notation
AidenYim
@AidenTheCoder
Jan 22 2017 06:25
thx @ghulamshabir
CamperBot
@camperbot
Jan 22 2017 06:25
aidenthecoder sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1737 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
RyanWng
@RyanWng
Jan 22 2017 06:30
@Lumexralph I hate to say that I just lost my connection and also lost the code in JSBin, damn. I'll write again.!!!
RyanWng
@RyanWng
Jan 22 2017 06:39
@Lumexralph are you still there, I just put a new link here, thx. http://jsbin.com/qipadazice/edit?js,console
CamperBot
@camperbot
Jan 22 2017 06:39
ryanwng sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
Smeet Jayshree Thakkar
@smeetthakkar
Jan 22 2017 06:40
Hi, can anyone help me with the Golf challenge
if (strokes >= par + 3) {
return "Go Home!";
} else if (strokes == par + 2) {
return "Double Bogey";
} else if (strokes == par + 1) {
return "Bogey";
} else if (strokes == par) {
return "Par";
} else if (strokes == par - 1) {
return "Birdie";
} else if (strokes <= par - 2) {
return "Eagle";
} else {
return "Hole-in-one!";
}
Here's my code
RyanWng
@RyanWng
Jan 22 2017 06:40
@Lumexralph if you comment retuen 29, you will get a different result
Jor
@joreyesl
Jan 22 2017 06:45
@Tech11 what test are you failing? Try checking for a hole-in-one first. } else if (strokes <= par - 2) { is probably catching the case when strokes = 1
Smeet Jayshree Thakkar
@smeetthakkar
Jan 22 2017 06:48
Yup, I am not getting an output for any of the inputs where the arguments are 1
For example, golfScore (4,1) is incorrect
M just trying to understand what change do I make?
Jor
@joreyesl
Jan 22 2017 06:49
@Tech11 ok try putting if statement at the start to check strokes == 1 then return hole-in-one when that is true
Smeet Jayshree Thakkar
@smeetthakkar
Jan 22 2017 06:50
@joreyesl You say put else if (stroke == 1) return "Hole-in-one!"?? If i do that, there will be a problem with the output for <= par - 2
Okay so the first if statement should be strokes == 1, return "Hole-in-one?
Jor
@joreyesl
Jan 22 2017 06:51
@Tech11 yes!
keep the other statements where they are at. just at that one to the top.
Jan 22 2017 06:51
I am stuck on an issue with cloud9; I can not copy text from a url or text editor, etc; then paste into cloud9. I need to always manually type. Is there a fix around? Really do not want to spend tons of time typing out lines of code from scratch :worried:
Smeet Jayshree Thakkar
@smeetthakkar
Jan 22 2017 06:53
let me revamp the code & get back to you @joreyesl
Jor
@joreyesl
Jan 22 2017 06:53
@Tech11 :thumbsup:
Smeet Jayshree Thakkar
@smeetthakkar
Jan 22 2017 06:54
@joreyesl Ahaa! I got it
if (strokes == 1) {
return "Hole-in-one!";
} else if (strokes <= par - 2) {
return "Eagle";
} else if (strokes == par - 1) {
return "Birdie";
} else if (strokes == par) {
return "Par";
} else if (strokes == par + 1) {
return "Bogey";
} else if (strokes == par + 2) {
return "Double Bogey";
} else {
return "Go Home!";
}
Jor
@joreyesl
Jan 22 2017 06:55
@Tech11 there you go!
Smeet Jayshree Thakkar
@smeetthakkar
Jan 22 2017 06:55
One thing which I still have in my mind is what if we had more conditions
Like persay something beyong >=par + 3
Jor
@joreyesl
Jan 22 2017 06:56
@Tech11 well anything like that gets caught in the else clause
Smeet Jayshree Thakkar
@smeetthakkar
Jan 22 2017 06:56
The last statement I have put here is only an else statement which assumes that after par + 2, anything greater than 2 will be returning "Go Home!"
Absolutely correct, agree with you over it.
However, my concern here is example we had an extra statement where we put > par + 3, returned Go home, but par = 3 returned something else.
Wouldn't it be a little difficult to work upon it.
Anyways, thank you @joreyesl, I really appreciate your help
CamperBot
@camperbot
Jan 22 2017 06:58
tech11 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
Jor
@joreyesl
Jan 22 2017 06:58
you had >= par +3
yea, np. any time :)
Smeet Jayshree Thakkar
@smeetthakkar
Jan 22 2017 07:20
Starting with the switch statements

switch (val) {
case "alpha":
break;

this is my first module of the code

Based on my understanding, switch (num), here num is replaced with val as the argument.
case 1 has to be alpha
What do I put instead of the statement1?
What does break signify?
I need to set val === something, right?
Jor
@joreyesl
Jan 22 2017 07:23
@Tech11 what challenge is this?
Manish Giri
@Manish-Giri
Jan 22 2017 07:23
@Tech11 you probably need to set answer depending on the case value
there must be directions on the right
Smeet Jayshree Thakkar
@smeetthakkar
Jan 22 2017 07:24
selecting from many options with Switch statement @joreyesl
Manish Giri
@Manish-Giri
Jan 22 2017 07:24
and break signifies that when a case value matches, you execute the block of code in that case and exit the switch statement, you don't continue to the next case.
which is what would happen if there were no break
@Tech11
Smeet Jayshree Thakkar
@smeetthakkar
Jan 22 2017 07:25
Ah! okay, so if I need to find a value which is equal to number 5, the execution will happen unless it finds the number, and stop there.
In this challenge, do I need to come up with my own cases? Like what if it equals alpha
and what happens when it is equal to beta
so on
Jor
@joreyesl
Jan 22 2017 07:26
@Tech11 yea switch(num) will test the value of num against each case.
Manish Giri
@Manish-Giri
Jan 22 2017 07:26
instructions on the left
you don't need to invent stuff.
Smeet Jayshree Thakkar
@smeetthakkar
Jan 22 2017 07:27
switch (val === 1) {
case "alpha":
console.log ("The statement is an Alpha");
break;
}
Jor
@joreyesl
Jan 22 2017 07:27
@Tech11 no they tell you each case, ex, when num matches 1 they want you to set answer to "alpha"
Smeet Jayshree Thakkar
@smeetthakkar
Jan 22 2017 07:27
Is this correct?
Jor
@joreyesl
Jan 22 2017 07:28

@Tech11
Instructions

Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"

those are the cases

Smeet Jayshree Thakkar
@smeetthakkar
Jan 22 2017 07:28
Okay, I got it now.
Thank you @Manish-Giri & @joreyesl
CamperBot
@camperbot
Jan 22 2017 07:28
tech11 sends brownie points to @manish-giri and @joreyesl :sparkles: :thumbsup: :sparkles:
:warning: tech11 already gave joreyesl points
:star2: 3912 | @manish-giri |http://www.freecodecamp.com/manish-giri
MarkBales96
@MarkBales96
Jan 22 2017 07:31

Okay, quick question. I'm currently working on Assignment with a Returned Value, and I have the first task complete, but I can't seem to assign ProcessArg to Processed. Here's my code.
// Example
var changed = 0;

function change(num) {
return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 0;

function processArg(num) {
return (num + 3) / 5;
}

// Only change code below this line
var processed = 2;

function processArg(num) {
return (num + 2) / 4;
}

Bryan Reese
@breese8009
Jan 22 2017 07:31
hello
Manish Giri
@Manish-Giri
Jan 22 2017 07:32
@MarkBales96 this is wrong
function processArg(num) {
return (num + 2) / 4;
}
function processArg(num) {
return (num + 3) / 5;
}
look at their example - changed = change(10);
see how they call the change function with a value of 10 and store the result in changed?
that's what you need to dowithprocessArg and processed.
Jor
@joreyesl
Jan 22 2017 07:33
@MarkBales96 You dont have to create the function. Instructions say that you need to call processArg function with an argument of 7 and assign the result to processed
Smeet Jayshree Thakkar
@smeetthakkar
Jan 22 2017 07:33
switch (val) {
case "alpha":
console.log ("The statement is an Alpha");
break;
case "beta":
console.log ("The statement is Beta");
break;

case "gamma":
console.log ("The statement is Gamma");
break;

case "delta":
console.log ("The statement is delta");
break;
Can you temme what m I missing here?
Manish Giri
@Manish-Giri
Jan 22 2017 07:33
@Tech11 you need to assign stuff to answer.
not console.log
Bryan Reese
@breese8009
Jan 22 2017 07:34
// Example
var changed = 0;
function change(num) {
return (num + 5) / 3;
}
changed = change(10);
// Setup
var processed = 0;
function processArg(num) {
return (num + 3) / 5;
}
// Only change code below this line
var processed = 2;
function processArg(num) {
return (num + 2) / 4;
}
Smeet Jayshree Thakkar
@smeetthakkar
Jan 22 2017 07:34
How?
@Manish-Giri
MarkBales96
@MarkBales96
Jan 22 2017 07:34
Thank you @Manish-Giri and @joreyesl
CamperBot
@camperbot
Jan 22 2017 07:34
markbales96 sends brownie points to @manish-giri and @joreyesl :sparkles: :thumbsup: :sparkles:
:star2: 3913 | @manish-giri |http://www.freecodecamp.com/manish-giri
Bryan Reese
@breese8009
Jan 22 2017 07:34
Jor
@joreyesl
Jan 22 2017 07:35

@Tech11 yes, they want you to use the values on the left as the test cases
Instructions

Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"

ex:

case 1:
break;
Smeet Jayshree Thakkar
@smeetthakkar
Jan 22 2017 07:37
Perfect! got through it, thanks again guys
Daniel Jocson
@djocson1
Jan 22 2017 07:38
How do you post the code problems from freecodecamp on this chat?
Jor
@joreyesl
Jan 22 2017 07:38
@djocson1 copy and paste your code in between 


TaylorPzreal
@TaylorPzreal
Jan 22 2017 07:39
// Change these values to test your function lookUpProfile("Akira", "likes");
Daniel Jocson
@djocson1
Jan 22 2017 07:39
@Jor I'll try
woops lol
TaylorPzreal
@TaylorPzreal
Jan 22 2017 07:40
why i dont have code background?
i use 
Jor
@joreyesl
Jan 22 2017 07:41
@TaylorPzreal you can put code between  to format it like you have now. If you want the multiline code formatting you need to paste code between 
Ayayron94
@Ayayron94
Jan 22 2017 07:41
hello everyone, first time here. Could i get some pointers on how to start the "Convert Celsius to Fahrenheit" test?
Daniel Jocson
@djocson1
Jan 22 2017 07:41

I'm having problems accessing the array [Hello] created from the .split any suggestions?

'''
function reverseString(str) {//Is this function creating the string?
var arrayStr = str.split(' '); // Is this how I access the string 'Hello' from the function?
var reverseStr = arrayStr.reverse(); //How do I access an array created from .split?
return reverseStr;
}

reverseString("hello"); '''

CamperBot
@camperbot
Jan 22 2017 07:41
:bulb: to format code use backticks!  more info
Daniel Jocson
@djocson1
Jan 22 2017 07:41
@joreyesl Do i place space between the '?
Jor
@joreyesl
Jan 22 2017 07:42
@djocson1 you used apostrophe, you need backticks, and they have to be on their own line
look at the docs here
TaylorPzreal
@TaylorPzreal
Jan 22 2017 07:42
lookUpProfile("Akira", "likes");
i'm test
FL8Liew
@FL8Liew
Jan 22 2017 07:44
hey guys, i am stucked here
anyone can help? :D
Daniel Jocson
@djocson1
Jan 22 2017 07:44
I'm having problems accessing the array [Hello] created from the .split any suggestions? (sorry for spam)
function reverseString(str) {//Is this function creating the string?
var arrayStr = str.split(' '); // Is this how I access the string 'Hello' from the function?
var reverseStr = arrayStr.reverse(); //How do I access an array created from .split?
return reverseStr;
}
reverseString("hello");
@joreyesl Thanks it worked
CamperBot
@camperbot
Jan 22 2017 07:45
djocson1 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
Jor
@joreyesl
Jan 22 2017 07:46
@djocson1 the problem is your .split(' ') that will try to split the string by ' ' 1 whitespace. If you want to split every character, you want to use .split('') no space!
Jor
@joreyesl
Jan 22 2017 07:53

@FL8Liew inside of the function you will have access to arr and item. arr will be an array that you will be adding and removing a value from and item will the the value they want you to add. The instructions want you to add the value num to the end of the array arr then remove the value at the beginning of the array arr and have that value be returned by the function.

To help with doing this task, try have a look at the functions .push(arg) and .shift().

Daniel Jocson
@djocson1
Jan 22 2017 07:54
@joreyesl okay I'll try that
FL8Liew
@FL8Liew
Jan 22 2017 07:55
@joreyesl ok thanks, I'll try it again
CamperBot
@camperbot
Jan 22 2017 07:55
fl8liew sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
Eugeniu Botnaru
@ebv-gh
Jan 22 2017 07:55

Need some help with with the following challenge: Mutations.
This is my code:


function mutation(arr) {

var bla = function(x){return x.toLowerCase();};
var tar = arr.map(bla);

var i = 0;
var j = 0;
var ar1 = tar[0];
var ar2 = tar[1];

while (0 < ar2.length){
if (ar1.indexOf(ar2[j++]) == -1){
return false;
} else
return true;

}

}

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

it passes every test except mutation(["hello", "hey"])

TaylorPzreal
@TaylorPzreal
Jan 22 2017 07:57
thx, it worked@ @joreyesl
CamperBot
@camperbot
Jan 22 2017 07:57
taylorpzreal sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
Jor
@joreyesl
Jan 22 2017 07:57
@TaylorPzreal :thumbsup:
Ghulam Shabir
@ghulamshabir
Jan 22 2017 07:57
@rumpumpum you are returning true as soon as any letter matches to first string but you are supposed to return true only when all the letters match
Eugeniu Botnaru
@ebv-gh
Jan 22 2017 07:59
@ghulamshabir but isn't ar2[j++] suposed to take care of that?
Jor
@joreyesl
Jan 22 2017 07:59
@rumpumpum few things, while (0 < ar2.length){ will always be true if ar2 is not empty.
also, as @ghulamshabir mentioned, you dont want to return true, until you have checked if all characters in the 2nd string are found in the 1st string.
Joseph
@revisualize
Jan 22 2017 07:59
Hey hey.
I'm at the bar and a little buzzed.
Jor
@joreyesl
Jan 22 2017 08:00
:wave:
Ghulam Shabir
@ghulamshabir
Jan 22 2017 08:01
@rumpumpum no j++ won't run after return in fact the function mutations stops running after return has run
Jor
@joreyesl
Jan 22 2017 08:02
@rumpumpum ar2[j++] will increment after the first call, but the problem is you have an if else statement that both have returns. So you will end up returning from the function in the first iteration, hence you never check the rest of the characters. Remove the else clause and move the return true to after the loop, and fix while (0 < ar2.length){ and you should be good to go. :thumbsup:
Eugeniu Botnaru
@ebv-gh
Jan 22 2017 08:03
@joreyesl @ghulamshabir I see what you're saying, Ill work on that
Naeem Rind
@naeemrind
Jan 22 2017 08:03
can anyone please tell me why i cant filter this table according to serial number ?? https://jsfiddle.net/naeemrind/peqv5g7f/
Daniel Jocson
@djocson1
Jan 22 2017 08:04
@joreyesl you da real deal thanks!
CamperBot
@camperbot
Jan 22 2017 08:05
djocson1 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:warning: djocson1 already gave joreyesl points
RyanWng
@RyanWng
Jan 22 2017 08:06
@naeemrind Would you mind specifying your question?
Naeem Rind
@naeemrind
Jan 22 2017 08:08
@RyanWng I want to search the table using serial numbers, i.e the very first row. but it seems there is an issue with the Javascript code.
Eugeniu Botnaru
@ebv-gh
Jan 22 2017 08:14

@ghulamshabir @joreyesl this is what I came up with:

function mutation(arr) {

var bla = function(x){return x.toLowerCase();};
var tar = arr.map(bla);

var i = 0;
var j = 0;
var ar1 = tar[0];
var ar2 = tar[1];

while (j <= ar2.length){
if (ar1.indexOf(ar2[j++]) == -1){

} return true;

}

}

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

I don’t know how to return false if there is no match.

Ghulam Shabir
@ghulamshabir
Jan 22 2017 08:16
@rumpumpum your return statement will stop loop at first iteration
Satyam Saurabh
@satyam2401
Jan 22 2017 08:18
if(){
return true;}
else{
return false;} @rumpumpum
Ghulam Shabir
@ghulamshabir
Jan 22 2017 08:18
the idea is to return false as soon as a letter does not match that will end loop, if your code gets chance of running after the loop then what do you think what should you return at that point?
Conor Murphy
@cmurphy580
Jan 22 2017 08:24
how would i use recursion on this function until runs =0 ?

function foldArray(array, runs){

//empty array
var result = [];
//first half of the array
var one = array.slice(0, (array.length/2));
//second half of array reversed
var two = array.slice((array.length/2), array.length).reverse();
//if odd function
if (one.length < two.length){
one.push(0);
}
for (var i=0; i<(array.length/2); i++){
result.push(one[i]+two[i]);
}
return result;

//////recursion\\\\\\\

}
Jor
@joreyesl
Jan 22 2017 08:25
@rumpumpum if (ar1.indexOf(ar2[j++]) == -1) checks to see if the letter was not found. So if it returns true, then that means the letter was not found and you should return false. Now for return true, that still not in the right place. It needs to be returned after the entire loop has finished, i.e. it needs to be outside of the loop.
moeahmed24
@moeahmed24
Jan 22 2017 08:26

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

// Only change code below this line
result = {
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank"

};

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

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

Manish Giri
@Manish-Giri
Jan 22 2017 08:27
@moeahmed24 name your object something else instead of result, like lookup.
Eugeniu Botnaru
@ebv-gh
Jan 22 2017 08:33

@joreyesl @ghulamshabir I finaly got it to work, yay :D


function mutation(arr) {

var bla = function(x){return x.toLowerCase();};
var tar = arr.map(bla);

var j = 0;
var ar1 = tar[0];
var ar2 = tar[1];

while (j < ar2.length){
if (ar1.indexOf(ar2[j++]) == -1){
return false;}
}
return true;

}

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