These are chat archives for FreeCodeCamp/HelpJavaScript

20th
Jan 2017
CoryCMyers
@CoryCMyers
Jan 20 2017 00:00
Am I understanding that correctly?
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:01
for(var v = arr[0]; func(v) === false; v = arr.shift()) what does this mean???
am i missing something?
Joseph
@revisualize
Jan 20 2017 00:02
@CoryCMyers \W targets all non-word characters. Word Characters are ... A-Z a-z 0-9 _ ... You've also added _ to be selected in the regex. So, anything not A-Z a-z 0-9 gets replaced by '' an empty string.
@CoryCMyers There is no array
@HeebieGeeBee well...
alican karalar
@alicankaralar
Jan 20 2017 00:03
hello
Margaret
@Margaret2
Jan 20 2017 00:04
@CoryCMyers I believe /[\W_]/g targets all characters that are not alphanumeric, and it also targets all underscores
In replace the first parameter defines the values to replace, the second one defines what to replace them with - in this case, nothing :D
Joseph
@revisualize
Jan 20 2017 00:04
@HeebieGeeBee
for ([initialization]; [condition]; [final-expression])
   statement
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:04
i know its a loop
but how does it run
Bardoe Bess
@bardbess
Jan 20 2017 00:04
how about while(func(arr[0]) === false) { arr.shift();} @HeebieGeeBee . same thing.
Joseph
@revisualize
Jan 20 2017 00:05
@HeebieGeeBee So the init is: var v = arr[0]
Margaret
@Margaret2
Jan 20 2017 00:05
what exactly is func
Joseph
@revisualize
Jan 20 2017 00:05
@HeebieGeeBee The condition is: func(v) === false;
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:05
yes i get what each part of the loop is
Joseph
@revisualize
Jan 20 2017 00:05
Then the statement is run.
Johnny
@JohnnyBizzel
Jan 20 2017 00:05

@Margaret2 It's the one where a function is passed in as a parameter
http://coding.citytravelling.me.uk/drop-it.html

Drop the elements of an array (first argument), starting from the front, until the predicate (second argument) returns true.

Bardoe Bess
@bardbess
Jan 20 2017 00:05
while function returns true loop. every loop should alter array.
Joseph
@revisualize
Jan 20 2017 00:05
@HeebieGeeBee Then the final: v = arr.shift()
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:06
but how can that run
Joseph
@revisualize
Jan 20 2017 00:06
Which oddly enough is the same as ... arr[0]
CoryCMyers
@CoryCMyers
Jan 20 2017 00:06
@revisualize I thought the commands like .replace or .toLowerCase only worked when there was an array involved somewhere and targeted?
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:06
and yeah i just did that while loop
Joseph
@revisualize
Jan 20 2017 00:06
@CoryCMyers Read about them.
Margaret
@Margaret2
Jan 20 2017 00:07
@JohnnyBizzel oh, it was a parameter, i thought it was a keyword :sweat_smile:
Jason Luboff
@JLuboff
Jan 20 2017 00:07
@CoryCMyers They work on strings
Joseph
@revisualize
Jan 20 2017 00:07
@HeebieGeeBee v = arr[0] and v = arr.shift() are kind of the same thing.
Margaret
@Margaret2
Jan 20 2017 00:07
@CoryCMyers those are string methods, not array methods
Bardoe Bess
@bardbess
Jan 20 2017 00:07
function dropElements(arr, func) {
  // Drop them elements.
  while(func(arr[0]) === false) { arr.shift();}
  return arr;
}

dropElements([1, 2, 3,4], function(n) {return n < 3; }); // => [1,2,3,4]   why??
Joseph
@revisualize
Jan 20 2017 00:07
@HeebieGeeBee If the condition is not true it just keeps .shift() ing.
Margaret
@Margaret2
Jan 20 2017 00:07
@CoryCMyers each data type in JS (object, array, string, etc.) has certain methods that you can use on it
Adam King
@awking11
Jan 20 2017 00:08
hey everyone! need help with WordBlanks. I passed first two but what do I do for the third requirement that says to "change the words here to test your function?
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:08
yeah so how why is the initialisator and the final expression if its the same thing
CoryCMyers
@CoryCMyers
Jan 20 2017 00:08
@Margaret2 Ah! I guess I was thinking that way since they have just been used with Arrays in the challenges so far
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:08
is that just how ppl used to do while loops or something?
Johnny
@JohnnyBizzel
Jan 20 2017 00:08
@awking11 code so far?
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:09
forget it, got enough to give me headaches anyways
Joseph
@revisualize
Jan 20 2017 00:10
@awking11 Gist by revisualize / FreeCodeCamp - Word_Blanks.js
The function declaration was set up as... function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) giving the function name as wordBlanks
and with four parameter of myNoun, myAdjective, myVerb and myAdverb.
There is more that I could go into (if you want I can) but, I'll sum it up with:
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).
Johnny
@JohnnyBizzel
Jan 20 2017 00:10
@bardbess Does the array get modified?
Bardoe Bess
@bardbess
Jan 20 2017 00:10
nope. just returns the array. :/ thats what i dont understand.
Margaret
@Margaret2
Jan 20 2017 00:10
today i saw this:
while (++i < n)
seems like a good replacement for
for (var i = 0; i < n; i++)
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:12
that doesnt work @bardbess ?
CoryCMyers
@CoryCMyers
Jan 20 2017 00:12
So in that first one it would raise incrementally before checking if i was greater than n yes @Margaret2 while the second one sets up a var i that equals zero, then checks to see if i is less than n, and if it is add one increment and repeats?
Johnny
@JohnnyBizzel
Jan 20 2017 00:12
@bardbess Did you see my solution?
Bardoe Bess
@bardbess
Jan 20 2017 00:12
nevermind :/ test just passed. Not sure what changed. Thanks @JohnnyBizzel @HeebieGeeBee @Margaret2
CamperBot
@camperbot
Jan 20 2017 00:12
bardbess sends brownie points to @johnnybizzel and @heebiegeebee and @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 1259 | @margaret2 |http://www.freecodecamp.com/margaret2
:cookie: 561 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:star2: 1151 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Margaret
@Margaret2
Jan 20 2017 00:12
yeah, i guess you would have to be careful about that initial value for i@CoryCMyers
Adam King
@awking11
Jan 20 2017 00:12
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  result= "my dog is big and ran very quickly";

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks();
Johnny
@JohnnyBizzel
Jan 20 2017 00:12
@bardbess :+1:
@awking11 Lovely. William Shakespeare like!
Adam King
@awking11
Jan 20 2017 00:13
Ha! I know right?
Margaret
@Margaret2
Jan 20 2017 00:13
@awking11 lol you are supposed to add up the parameters, so like "My " + myNoun
Johnny
@JohnnyBizzel
Jan 20 2017 00:13
@awking11 Unfortunately, whatever you put in the function it returns the same string - making it useless!
CoryCMyers
@CoryCMyers
Jan 20 2017 00:14
@Margaret2 Honestly, I am just happy I could read that for loop and know the difference between ++i and i++ :p
Adam King
@awking11
Jan 20 2017 00:14
Ok makes sense.
Margaret
@Margaret2
Jan 20 2017 00:14
@JohnnyBizzel it is what's known as an "ultra-pure" function :trollface:
Margaret
@Margaret2
Jan 20 2017 00:15
@CoryCMyers yeah, good for you! :+1: :D
Johnny
@JohnnyBizzel
Jan 20 2017 00:15
@Margaret2 Ah, yes. I write those all the time :joy:
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:16
well only took like 3 days, but i final have a box that moves around a canvas that fires out a little box that destroys other little boxes if it hits them
Joseph
@revisualize
Jan 20 2017 00:16
@awking11 You're not doing that challenge correctly. It is supposed to teach you how to use parameters
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:17
next step gta 6
Adam King
@awking11
Jan 20 2017 00:17
@JohnnyBizzel Thanks.
CamperBot
@camperbot
Jan 20 2017 00:17
awking11 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1152 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Joseph
@revisualize
Jan 20 2017 00:17
@bardbess Your code crashed my browser.
David Wolf
@RocPix
Jan 20 2017 00:17
any thoughts on this

function palindrome(str) {
  // Good luck!
  var noCaps = str.toLowerCase();

  var expression = /\S/;
  var noWhiteSpace = noCaps.match(expression);
  var backTogetherAgain = noWhiteSpace.join('');
  var prepReverse = backTogetherAgain.split('');
  var flipIt = prepReverse.reverse();
  var backwardString = flipIt.join('');
  if (backwardString == backTogetherAgain) {
    return true;
  }else return false; }



palindrome("_eye");
Pieter Stokkink
@forkerino
Jan 20 2017 00:18
@HeebieGeeBee :smile:
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:18
lol
Johnny
@JohnnyBizzel
Jan 20 2017 00:18
@RocPix Overkill?
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:18
@RocPix no thoughts
thats not the strangest palindrome solution ive seen
not even in the past couple of hours
David Wolf
@RocPix
Jan 20 2017 00:20
it seems to always return true
Johnny
@JohnnyBizzel
Jan 20 2017 00:20
@RocPix You seem to be testing the non-letters http://pythontutor.com/javascript.html#mode=edit
Put your code in and see what happens
Pieter Stokkink
@forkerino
Jan 20 2017 00:21
yeah, you might want to read up on function chaining a bit, @RocPix
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:21
what are you hoping your regex is doing?
Bardoe Bess
@bardbess
Jan 20 2017 00:21
haha. i blame the function you passed in :P @revisualize
David Wolf
@RocPix
Jan 20 2017 00:22
@JohnnyBizzel thanks will try it . the expression is using a capital S trigger
CamperBot
@camperbot
Jan 20 2017 00:22
rocpix sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1153 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:22
what does capital S do? @RocPix
Joseph
@revisualize
Jan 20 2017 00:23
@bardbess i blame the developer.
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:24
but is that what you want to do?
alican karalar
@alicankaralar
Jan 20 2017 00:25
hey guys
i need help at factorialize a number challenge
i need some direction
Bardoe Bess
@bardbess
Jan 20 2017 00:25
haha, i dont recommend you use that code in production @revisualize I just look at the tests
David Wolf
@RocPix
Jan 20 2017 00:25
i thought so i even tried /\S+/g to make it global
alican karalar
@alicankaralar
Jan 20 2017 00:25
i do a for loop but i can't figure how to go ahead
and keep multiplying the number with the previous value
can anybody help ?
David Wolf
@RocPix
Jan 20 2017 00:27
@alicankaralar one sec friend
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:27
what will noCaps.match(expression) return @RocPix
CherryPlaysRoblox
@CherryPlaysRoblox1
Jan 20 2017 00:27
Make a loop and in the ()s add something that will multiply the number @alicankaralar
David Wolf
@RocPix
Jan 20 2017 00:28
@alicankaralar
  while(x > 2) {
    num *= (x - 1);
    x--;
@HeebieGeeBee can't seem to get consol.log to work on this challenge so i have no idea
@alicankaralar i hope that gets you in the right direction
alican karalar
@alicankaralar
Jan 20 2017 00:30
i guess so im trying right now
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:30
you should be able to console.log
but im gonna suggest that its probably not what youre wanting it to return
davidcampbell1798
@davidcampbell1798
Jan 20 2017 00:31
how do I make it so a should be assigned to b with =
Pieter Stokkink
@forkerino
Jan 20 2017 00:31
or try here @RocPix
Johnny
@JohnnyBizzel
Jan 20 2017 00:31

@RocPix Hard work finding the right code but this might do the trick:

function palindrome(str) {
  // Good luck!
  var noCaps = str.toLowerCase();

  var noWhiteSpace = noCaps.replace(/[\W_]+/g, '');
  var prepReverse = noWhiteSpace.split('');
  var flipIt = prepReverse.reverse();
  var backwardString = flipIt.join('');
  if (backwardString == prepReverse.join('')) {
    return true;
  }else return false; }
palindrome("_eye");

And you know you can chain operations together?

David Wolf
@RocPix
Jan 20 2017 00:32
yes
was making it easier to follow
NathanDavey
@NathanDavey
Jan 20 2017 00:34
Okay, I'm stuck on [196] "Return Early Pattern for Functions"
'''
function abTest(a, b) {
// Only change code below this line
if (a || b < 0) {
var c;
return c;
}
// Only change code above this line
return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}
'''
CamperBot
@camperbot
Jan 20 2017 00:35
:bulb: to format code use backticks! ``` more info
alican karalar
@alicankaralar
Jan 20 2017 00:35
thanks @RocPix it helped a lot
CamperBot
@camperbot
Jan 20 2017 00:35
alicankaralar sends brownie points to @rocpix :sparkles: :thumbsup: :sparkles:
:cookie: 242 | @rocpix |http://www.freecodecamp.com/rocpix
NathanDavey
@NathanDavey
Jan 20 2017 00:35
oops
David Amanze
@GodKingShogun
Jan 20 2017 00:35
SENSEI OSHIETE
can someone look at my code. i am on the truncate a string challenge. my code looks fine to me
function truncateString(str, num) {
  // Clear out that junk in your trunk
  if (num<=3) {
    return str.slice(0,num) + "...";
  } else if (num>3) {
    return str.slice(0,num-3) + "...";
  }

}
NathanDavey
@NathanDavey
Jan 20 2017 00:36
function abTest(a, b) {
  // Only change code below this line
if (a || b < 0) {
  var c;
  return c;
}
   // Only change code above this line
 return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}
yay
David Amanze
@GodKingShogun
Jan 20 2017 00:37
@NathanDavey did you need help with a problem
Pieter Stokkink
@forkerino
Jan 20 2017 00:37
@NathanDavey that is not how || works
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:38
@GodKingShogun why dont you ever compare num with str?
Pieter Stokkink
@forkerino
Jan 20 2017 00:38
also you can return undefined immediately, without creating an undefined variable @NathanDavey
David Amanze
@GodKingShogun
Jan 20 2017 00:38
@HeebieGeeBee i dont understand
NathanDavey
@NathanDavey
Jan 20 2017 00:38
you mean just return;
?
David Amanze
@GodKingShogun
Jan 20 2017 00:39
@HeebieGeeBee nvm i get you
@GodKingShogun thanks senpai
CamperBot
@camperbot
Jan 20 2017 00:39
sorry godkingshogun, you can't send brownie points to yourself! :sparkles: :sparkles:
Pieter Stokkink
@forkerino
Jan 20 2017 00:39
@NathanDavey yes, or return undefined; if you want to make it explicit
AJ
@OmegaBlaac
Jan 20 2017 00:41
Omg im stuck on Word Blanks 😱
David Wolf
@RocPix
Jan 20 2017 00:41
@JohnnyBizzel thank you, I read info from your link. i think it will work if i use replace as you did :+1:
CamperBot
@camperbot
Jan 20 2017 00:41
rocpix sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:warning: rocpix already gave johnnybizzel points
David Wolf
@RocPix
Jan 20 2017 00:42
@OmegaBlaac show your code
Pieter Stokkink
@forkerino
Jan 20 2017 00:44
ok. night night people.
David Wolf
@RocPix
Jan 20 2017 00:46
@OmegaBlaac

  result = "My " + myAdjective + " " +
Johnny
@JohnnyBizzel
Jan 20 2017 00:46
@RocPix Indeed it will ;)
David Amanze
@GodKingShogun
Jan 20 2017 00:46
@HeebieGeeBee senpai are you still there
David Wolf
@RocPix
Jan 20 2017 00:46
and so on :fire:
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:47
barely
David Amanze
@GodKingShogun
Jan 20 2017 00:47
@HeebieGeeBee lol. im still not moving on to the next challenge

function truncateString(str, num) {
  // Clear out that junk in your trunk
  if (str.length===num) {
    return str;
  } else if (num<=3) {
    return str.slice(0,num) + "...";
    } else {
    return str.slice(0,num-3) + "...";
  } 

}
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:48
well thats cus the code isnt right
what are each of the steps in the challenge
David Amanze
@GodKingShogun
Jan 20 2017 00:49
@HeebieGeeBee lol figured that much. this is the last objective i am not getting
truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2) should return "A-tisket a-tasket A green and yellow basket".
Moisés Man
@moigithub
Jan 20 2017 00:49
what would hapen if str.len < num ?
truncateString("aaaa",10);
which is the same thing as the example u posting here :point_up: 19 de enero de 2017 19:49
@GodKingShogun
David Amanze
@GodKingShogun
Jan 20 2017 00:50
@moigithub are you asking me senpai
HeebieGeeBee
@HeebieGeeBee
Jan 20 2017 00:52
he is
sorry im gonna go bed but youre not doing everything the challenge asks you to
need to tweak a few things
David Amanze
@GodKingShogun
Jan 20 2017 00:53
@moigithub ok got it thanks
CamperBot
@camperbot
Jan 20 2017 00:53
godkingshogun sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2555 | @moigithub |http://www.freecodecamp.com/moigithub
David Amanze
@GodKingShogun
Jan 20 2017 00:54
@HeebieGeeBee good night SENPAI
NathanDavey
@NathanDavey
Jan 20 2017 00:54
Yea I need help. It will return undefined but it will not return the rest of the code.
function abTest(a, b) {
  // Only change code below this line
if (a || b < 0) {
return undefined;
}
   // Only change code above this line
return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}
Moisés Man
@moigithub
Jan 20 2017 00:55
@NathanDavey ur code saying...
if a have a truthy value OR b is less than 0 ....
samsmith453
@samsmith453
Jan 20 2017 00:55
Hey guys! Does anyone know why this adding code returns a number 0.00000000003 less than the actual sum?
var cid = [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]];

var cidtotal = 0;
for(var i=0; i<cid.length; i++){
    cidtotal+=cid[i][1];
  }
  return cidtotal;

//returns: 335.4099999999999999997
NathanDavey
@NathanDavey
Jan 20 2017 00:56
hmmmm, well not sure what that means, but i'll change it, lol
Raymond Duckworth
@raymondxduckworth
Jan 20 2017 00:56

Hi all, I'm kind of new here. I have a quick question, and hopefully someone can help me answer it.
I'm doing the Objects section on FCC, and this is my first time seeing keys being strings. Why is this? Is there some relevance, or advantage to doing this?

For example, in FCC, sometimes they do this:

var myObj = {
"name": "Jack"
};

INSTEAD OF

var myObj = {
name: "Jack"
};

Thank you all! ^_^

Moisés Man
@moigithub
Jan 20 2017 00:56
falsy values.. are undefined, null, 0, NaN, "" (empty string)
everything else are truthy @NathanDavey
Johnny
@JohnnyBizzel
Jan 20 2017 00:56
@samsmith453 Use rounding or convert everthing to pennies ( multiply by 100)
NathanDavey
@NathanDavey
Jan 20 2017 00:57
i guess that was it
samsmith453
@samsmith453
Jan 20 2017 00:57
@JohnnyBizzel hi Johnny, in the actual challenge the array is part of a function so the values will keep changing.
NathanDavey
@NathanDavey
Jan 20 2017 00:57
how would i say if a OR b is < 0 ?
Johnny
@JohnnyBizzel
Jan 20 2017 00:58
@samsmith453 I know, I used a rounding function. It's a pain in the backside.
Some solutions I saw they just *100
samsmith453
@samsmith453
Jan 20 2017 00:58
@JohnnyBizzel why does it happen? It happens when I tested on code pen too?
Vizij
@Vizij
Jan 20 2017 00:59
@NathanDavey if (a < 0 || b < 0)
Johnny
@JohnnyBizzel
Jan 20 2017 00:59
@samsmith453 Good question, it is how computers store decimals. Better for you to research this as it's not a simple explanation.
samsmith453
@samsmith453
Jan 20 2017 01:00
@JohnnyBizzel oh okay. Is there a name for the problem?
NathanDavey
@NathanDavey
Jan 20 2017 01:00
aaaaah thank you! @Vizij
CamperBot
@camperbot
Jan 20 2017 01:00
nathandavey sends brownie points to @vizij :sparkles: :thumbsup: :sparkles:
:cookie: 317 | @vizij |http://www.freecodecamp.com/vizij
Johnny
@JohnnyBizzel
Jan 20 2017 01:00
@samsmith453 This is my rounding function:
function rounded(number, precision) {
    var factor = Math.pow(10, precision);
    var tempNumber = number * factor;
    var roundedTempNumber = Math.round(tempNumber);
    return roundedTempNumber / factor;
}
NathanDavey
@NathanDavey
Jan 20 2017 01:01
Oooo brownie points thank you too! @moigithub
CamperBot
@camperbot
Jan 20 2017 01:01
nathandavey sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2556 | @moigithub |http://www.freecodecamp.com/moigithub
samsmith453
@samsmith453
Jan 20 2017 01:01
@JohnnyBizzel Thanks for the code Johnny! Are code camp expecting that?
CamperBot
@camperbot
Jan 20 2017 01:01
samsmith453 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1154 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
samsmith453
@samsmith453
Jan 20 2017 01:02
@JohnnyBizzel surely there is a way that a computer can just add some numbers?
samsmith453
@samsmith453
Jan 20 2017 01:03
@JohnnyBizzel ahh thank you!
CamperBot
@camperbot
Jan 20 2017 01:03
samsmith453 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:warning: samsmith453 already gave johnnybizzel points
Johnny
@JohnnyBizzel
Jan 20 2017 01:03

@samsmith453

There's no such thing as an integer in JavaScript, so you have to be a little careful with your arithmetic if you're used to math in C or Java.

samsmith453
@samsmith453
Jan 20 2017 01:04
@JohnnyBizzel right okay. Interesting!
Johnny
@JohnnyBizzel
Jan 20 2017 01:04
@samsmith453 I prefer strongly typed languages!
samsmith453
@samsmith453
Jan 20 2017 01:05
@JohnnyBizzel what languages fall into that category?
Johnny
@JohnnyBizzel
Jan 20 2017 01:06
@samsmith453 More reading for you :D https://en.wikipedia.org/wiki/Strong_and_weak_typing
samsmith453
@samsmith453
Jan 20 2017 01:06
@JohnnyBizzel haha I'll get stuck in !
Johnny
@JohnnyBizzel
Jan 20 2017 01:07

http://stackoverflow.com/questions/2690544/what-is-the-difference-between-a-strongly-typed-language-and-a-statically-typed

Javascript is also rather weakly type but because there are so few types and because you can't really construct new types. "Adam Gent"

reidkiss2
@reidkiss2
Jan 20 2017 01:09
Hello, I am stuck in Converting Celsius to Fahrenheit challenge, is there anyone who can help ?
Joseph
@revisualize
Jan 20 2017 01:14
What is the math?
reidkiss2
@reidkiss2
Jan 20 2017 01:15

...This is what it says 'To test your learning, you will create a solution "from scratch". Place your code between the indicated lines and it will be tested against multiple test cases.

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.

You are given a variable celsius representing a temperature in Celsius. Use the variable fahrenheit already defined and apply the algorithm to assign it the corresponding temperature in Fahrenheit.

Note
Don't worry too much about the function and return statements as they will be covered in future challenges. For now, only use operators that you have already learned.'

In the text editor it says this : 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);

Joseph
@revisualize
Jan 20 2017 01:16
Okay. What is the math?
reidkiss2
@reidkiss2
Jan 20 2017 01:16
I don't know what you mean
Joseph
@revisualize
Jan 20 2017 01:16
What is the mathematic expression to convert Celsius to Fahrenheit?
reidkiss2
@reidkiss2
Jan 20 2017 01:17
temp in celcius times 9/5 plus 32
Joseph
@revisualize
Jan 20 2017 01:17
Celsius
Turn that into an actual math expression.
reidkiss2
@reidkiss2
Jan 20 2017 01:18
C x 9/5 + 32 = F
Joseph
@revisualize
Jan 20 2017 01:18
What do you have now?
reidkiss2
@reidkiss2
Jan 20 2017 01:18
like that ?
Raymond Duckworth
@raymondxduckworth
Jan 20 2017 01:19

Hi all, I'm kind of new here. I have a quick question, and hopefully someone can help me answer it.
I'm doing the Objects section on FCC, and this is my first time seeing keys being strings. Why is this? Is there some relevance, or advantage to doing this?

For example, in FCC, sometimes they do this:

var myObj = {
  "name": "Jack"
};

INSTEAD OF

var myObj = {
  name: "Jack"
};

Thank you all! ^_^

Joseph
@revisualize
Jan 20 2017 01:19
@reidkiss2 not quite. You left out a bunch of characters.
reidkiss2
@reidkiss2
Jan 20 2017 01:19
ohh :/
i'm struggling with this section
Joseph
@revisualize
Jan 20 2017 01:19
Also in computer math x doesnt mean times ... * does.
reidkiss2
@reidkiss2
Jan 20 2017 01:20
yes
that, i know.
Joseph
@revisualize
Jan 20 2017 01:20
Okay. Try again.
:)
Learning is a struggle sometimes.
reidkiss2
@reidkiss2
Jan 20 2017 01:21
Celsius * (9/5) + (32) = Fahrenheit ?
i hate struggling , lol
Joseph
@revisualize
Jan 20 2017 01:21
Great.
reidkiss2
@reidkiss2
Jan 20 2017 01:21
but i don't really understand what they're asking me to do in this exercise :/
Joseph
@revisualize
Jan 20 2017 01:21
Except in JS you need to do the assignment the other way around.
Flip the expression around the =
reidkiss2
@reidkiss2
Jan 20 2017 01:22
ok. . .so, Fahrenheit = (32) + (9/5) * Celsius ?
Joseph
@revisualize
Jan 20 2017 01:22
That works. Now variables are case sensitive.
reidkiss2
@reidkiss2
Jan 20 2017 01:23
so i should use the lowercase ?
Joseph
@revisualize
Jan 20 2017 01:23
You should follow case sensitivity. If they are lowercase then yes.
oshane-willy99
@oshane-willy99
Jan 20 2017 01:23
Can anyone help me with nesting for loops please??
reidkiss2
@reidkiss2
Jan 20 2017 01:24
ok. thank you
Jamil Akhtar
@frontender007
Jan 20 2017 01:24
@oshane-willy99 sure, what's the problem?
reidkiss2
@reidkiss2
Jan 20 2017 01:24
but what exactly do they want me to do in this exercise ?
Joseph
@revisualize
Jan 20 2017 01:24
Now look at what you have and reread the instructions.
reidkiss2
@reidkiss2
Jan 20 2017 01:24
@revisualize ok
Joseph
@revisualize
Jan 20 2017 01:24
You did it.
reidkiss2
@reidkiss2
Jan 20 2017 01:24
hmm... let me see
Ozan Araz
@haraldur12
Jan 20 2017 01:25
does anyone know how to store a value taken from a request in a variable? when i query the data through a function i am not able to store the value outside the function because of the scope
Joseph
@revisualize
Jan 20 2017 01:25
Use a global.
Jamil Akhtar
@frontender007
Jan 20 2017 01:25
@haraldur12 declare the variable outside and then assign the returned value
Ozan Araz
@haraldur12
Jan 20 2017 01:25
but if it is within the function i cannot call it outside?
Jamil Akhtar
@frontender007
Jan 20 2017 01:26
inside the function
reidkiss2
@reidkiss2
Jan 20 2017 01:26
@revisualize thank you! i really did not understand the wording in the instructions
CamperBot
@camperbot
Jan 20 2017 01:26
reidkiss2 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
Ozan Araz
@haraldur12
Jan 20 2017 01:26
the problem is it is nested
CamperBot
@camperbot
Jan 20 2017 01:26
:star2: 3058 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jan 20 2017 01:26
Yes you can.
reidkiss2
@reidkiss2
Jan 20 2017 01:26
oh cool. i was going to ask you how do i send the brownie points. i guess now i know!
Ozan Araz
@haraldur12
Jan 20 2017 01:26
let me show you my problem in a second
Joseph
@revisualize
Jan 20 2017 01:26
@reidkiss2 you need to learn how to read words and turn them into code.
If you want to get a job doing this shit.
reidkiss2
@reidkiss2
Jan 20 2017 01:27
funny as you just dissed me i was about to send this : 'you are a great help Joseph! hopefully when i advance i can help people too '
cool.
Jamil Akhtar
@frontender007
Jan 20 2017 01:27
@revisualize any clue about prime numbers?
reidkiss2
@reidkiss2
Jan 20 2017 01:27
have a nice day :)
Joseph
@revisualize
Jan 20 2017 01:27
I didnt diss anyone.
What?
so i am parsing the response inside the ajax call
Joseph
@revisualize
Jan 20 2017 01:29
It isnt a diss stating that someone needs to learn how to read words and turn them into code. It is part of the spec process. ... even I struggle with it.
Ozan Araz
@haraldur12
Jan 20 2017 01:29
however what i am wondering is how could i bring it outside the function
Joseph
@revisualize
Jan 20 2017 01:29
@reidkiss2 sorry you saw it as an insult.
Anyhow.
Ozan Araz
@haraldur12
Jan 20 2017 01:30
@reidkiss2 you have been stackoverflown.
not dissed-
Ok wait. I am stupid.
I am actually able to access the variables since I am assigning them inside the function again
oshane-willy99
@oshane-willy99
Jan 20 2017 01:31

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

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

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

Ozan Araz
@haraldur12
Jan 20 2017 01:32
so actually to tweet the quote when I call the variable again I have the string inside it
Stephen James
@sjames1958gm
Jan 20 2017 01:32
@oshane-willy99 So if i is 0 how will it be > arr.length?
Review the sample code and compare to yours.
Jamil Akhtar
@frontender007
Jan 20 2017 01:32
@oshane-willy99 whats wrong ?
DRJcoder
@DRJcoder
Jan 20 2017 01:33
I need help in this excersise Escape Sequences in Strings
Ozan Araz
@haraldur12
Jan 20 2017 01:33
it should be the other way around @oshane-willy99
Jamil Akhtar
@frontender007
Jan 20 2017 01:33
@DRJcoder what is it ?
Randy Goldsmith
@Dueldrawer8
Jan 20 2017 01:33
function findSmallestNumberAmongMixedElements(arr) {
  // your code here
  var newArr = [];
  if(arr.length > 0){
    for(var i = 0; i < arr.length; i++){

      if(typeof(arr[i]) === 'number'){
          newArr.push(arr[i]);

      }

  }
    return Math.min.apply(null, newArr);
  }
  else{
      return 0;
  }
}
if an array contains no numbers.. it should return 0.. how do i create a statement that says if an array contains no numbers?
DRJcoder
@DRJcoder
Jan 20 2017 01:33

myStr should have encoded text with the proper escape sequences and no spacing.

myStr should have one newline character \n

myStr should have one carriage return character \r

that is the quetion
Joseph
@revisualize
Jan 20 2017 01:33
What is the text?
Jamil Akhtar
@frontender007
Jan 20 2017 01:34
@oshane-willy99 your first for loop increment should be i++ not i*=i
Ozan Araz
@haraldur12
Jan 20 2017 01:35
@Dueldrawer8 if arr.length 0
DRJcoder
@DRJcoder
Jan 20 2017 01:35
When you guys have the answer just reply me
Joseph
@revisualize
Jan 20 2017 01:35
@DRJcoder hey!
What is the text?
Randy Goldsmith
@Dueldrawer8
Jan 20 2017 01:35
@haraldur12 huh?
DRJcoder
@DRJcoder
Jan 20 2017 01:36
I just send it
Joseph
@revisualize
Jan 20 2017 01:36
I have the answer. But, I am not going to just give it to you.
Stephen James
@sjames1958gm
Jan 20 2017 01:36
@Dueldrawer8 Use filter to eliminate the non-numbers
DRJcoder
@DRJcoder
Jan 20 2017 01:36

myStr should have encoded text with the proper escape sequences and no spacing.

myStr should have one newline character \n

myStr should have one carriage return character \r

Joseph
@revisualize
Jan 20 2017 01:36
No.
That isnt the text.
Tead the instructions.
oshane-willy99
@oshane-willy99
Jan 20 2017 01:36
@frontender007 yeah i changed it i just wanted to try something else because i tried that ...but good to know
Stephen James
@sjames1958gm
Jan 20 2017 01:36
@DRJcoder copy the string provided then replace the four key words with the values from the table
@Dueldrawer8 return newArr.length > 0 ? Math.min.apply(null, newArr) : 0;
Jamil Akhtar
@frontender007
Jan 20 2017 01:37
@oshane-willy99 do you just have to sum all them numbers ?
Randy Goldsmith
@Dueldrawer8
Jan 20 2017 01:37
@sjames1958gm and how would i do that? using pop?
Ozan Araz
@haraldur12
Jan 20 2017 01:38
@Dueldrawer8 the thing is your code seems alright but you have to refactor it
i just ran it on jsbin
Stephen James
@sjames1958gm
Jan 20 2017 01:38
@Dueldrawer8 var newArr = arr.filter(function(val) { return typeof(val) === "number"; });
oshane-willy99
@oshane-willy99
Jan 20 2017 01:39
@frontender007 no I should Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of ar
Randy Goldsmith
@Dueldrawer8
Jan 20 2017 01:39
@sjames1958gm ah that makes sense thank you
CamperBot
@camperbot
Jan 20 2017 01:39
dueldrawer8 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5432 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
DRJcoder
@DRJcoder
Jan 20 2017 01:39
i did that but still saying that myStr should have encoded txt with the proper escape sequences and no spacing. and should have two correctly escaped backslash characters
Randy Goldsmith
@Dueldrawer8
Jan 20 2017 01:39
@haraldur12 it works.. for everything but an array with no numbers in it..and thanks
CamperBot
@camperbot
Jan 20 2017 01:39
:cookie: 291 | @haraldur12 |http://www.freecodecamp.com/haraldur12
dueldrawer8 sends brownie points to @haraldur12 :sparkles: :thumbsup: :sparkles:
DRJcoder
@DRJcoder
Jan 20 2017 01:39
.
Stephen James
@sjames1958gm
Jan 20 2017 01:39
@Dueldrawer8 When you have an array and want another array with less values think filter.
Jamil Akhtar
@frontender007
Jan 20 2017 01:39
@oshane-willy99 yeah you're right
Stephen James
@sjames1958gm
Jan 20 2017 01:40
@DRJcoder remove all spaces? You can share your code.
Randy Goldsmith
@Dueldrawer8
Jan 20 2017 01:40
@sjames1958gm ill try and remember that
Ozan Araz
@haraldur12
Jan 20 2017 01:40
function func(arr) {
  // your code here
  var newArr = [];
  if(arr.length > 0){
    for(var i = 0; i < arr.length; i++){

      if(typeof(arr[i]) === 'number'){
          newArr.push(arr[i]);

      }
    return Math.min.apply(null, newArr);

  }
  }else{
      return 0;
  }
}
console.log(func([]));
if you run this? what happens
DRJcoder
@DRJcoder
Jan 20 2017 01:40
var myStr ='FirstLine\rSecondLine\nThirdLine';
that is my code
Noah Overcash
@smileytechguy
Jan 20 2017 01:40
I need help with Smallest Common Multiple
Here is my code:

function smallestCommons(arr) {
  var list = [];
  for (var i = Math.min(arr[0], arr[1]); i <= Math.max(arr[0], arr[1]); i++) {
    list.push(i);
  }
  for (var i=list.length-1; i>=0; i--) {
    for (var j=i-1; j>=0; j--) {
      if (list[i]/(list[j]*1.0) == Math.floor(list[i]/(list[j]*1.0))) {
        list.splice(j,1);

      }
    }
  }
  return list.reduce(function(a,b) {
    return a*b;
  });
}


smallestCommons([1,13]);
Stephen James
@sjames1958gm
Jan 20 2017 01:41
@DRJcoder Appears you didn't replace the four keywords, only two.
DRJcoder
@DRJcoder
Jan 20 2017 01:41
what do you mean
Ozan Araz
@haraldur12
Jan 20 2017 01:41
@Dueldrawer8 have you seen the code?
Noah Overcash
@smileytechguy
Jan 20 2017 01:41

[1,5] returns 60, from [3,4,5] which is correct

[1,13] returns 8648640, which is incorrect
It derived that from [7,8,9,10,11,12,13]

Randy Goldsmith
@Dueldrawer8
Jan 20 2017 01:42
@haraldur12 says func is not defined
alican karalar
@alicankaralar
Jan 20 2017 01:42
hello
Jamil Akhtar
@frontender007
Jan 20 2017 01:42
@smileytechguy which challenge is it?
alican karalar
@alicankaralar
Jan 20 2017 01:42

'code' function palindrome(str) {
// Good luck!

var searchJunk = /\W+/gi;

var strJunk = str.match(searchJunk);

var strArray = str.split("");

var filteredArray =strArray.filter(function(val) {

return val===strJunk;

});

var reverseFirst = filteredArray.reverse();

var joinThen = reverseFirst.join("");

var compareNow = joinThen.toLowerCase();

if (compareNow === reverseFirst ) {

return true;

}

else {

return false;}

}

palindrome("e%%%%ye");

function palindrome(str) {
// Good luck!

var searchJunk = /\W+/gi;

var strJunk = str.match(searchJunk);

var strArray = str.split("");

var filteredArray =strArray.filter(function(val) {

return val===strJunk;

});

var reverseFirst = filteredArray.reverse();

var joinThen = reverseFirst.join("");

var compareNow = joinThen.toLowerCase();

if (compareNow === reverseFirst ) {

return true;

}

else {

return false;}

}

palindrome("e%%%%ye");

Joseph
@revisualize
Jan 20 2017 01:43
@DRJcoder Here.
alican karalar
@alicankaralar
Jan 20 2017 01:43
oh crap sorry i spammed here
Joseph
@revisualize
Jan 20 2017 01:43
@DRJcoder Here you go.. It seems you skipped past reading the instructions
blob
And went straight down to the tests.
Noah Overcash
@smileytechguy
Jan 20 2017 01:43
Smallest common multiple @frontender007
Jamil Akhtar
@frontender007
Jan 20 2017 01:43
@smileytechguy can you give the link ?
Stephen James
@sjames1958gm
Jan 20 2017 01:44
@alicankaralar I believe that match will return an array so val === strJunk will not work.
You could use str.replace(regex, '')
alican karalar
@alicankaralar
Jan 20 2017 01:44

code
function palindrome(str) {
// Good luck!

var searchJunk = /\W+/gi;

var strJunk = str.match(searchJunk);

var strArray = str.split("");

var filteredArray =strArray.filter(function(val) {

return val===strJunk;

});

var reverseFirst = filteredArray.reverse();

var joinThen = reverseFirst.join("");

var compareNow = joinThen.toLowerCase();

if (compareNow === reverseFirst ) {

return true;

}

else {

return false;}

}

palindrome("e%%%%ye");
code

oh okay
@sjames1958gm
Stephen James
@sjames1958gm
Jan 20 2017 01:45
@smileytechguy your code is not going to give the smallest common multiple
Jamil Akhtar
@frontender007
Jan 20 2017 01:45
@alicankaralar just check other numbers and letters , that should be your regex
Noah Overcash
@smileytechguy
Jan 20 2017 01:45
@sjames1958gm got that bit. what can i do to fix it?
Stephen James
@sjames1958gm
Jan 20 2017 01:47
@smileytechguy your code isn't trying to find the smallest common multiple, so not sure what to tell you.
Use a different algorithm
alican karalar
@alicankaralar
Jan 20 2017 01:47

`
function palindrome(str) {
// Good luck!

var searchJunk = /\W+/gi;

var strJunk = str.match(searchJunk);

var strArray = str.split("");

var filteredArray =strArray.filter(function(val) {

return val===strJunk;

});

var reverseFirst = filteredArray.reverse();

var joinThen = reverseFirst.join("");

var compareNow = joinThen.toLowerCase();

if (compareNow === reverseFirst ) {

return true;

}

else {

return false;}

}

palindrome("e%%%%ye");
`

GOD SORRY
lol
Noah Overcash
@smileytechguy
Jan 20 2017 01:47
@sjames1958gm can you help me with the theory behind it?
@alicankaralar add a ```js on a line before your code and ``` at the end next time
Garo
@Garabed96
Jan 20 2017 01:48
ya why isnt working
Stephen James
@sjames1958gm
Jan 20 2017 01:48
@smileytechguy There is one way where you try multiples of the largest number until all the numbers evenly divide.
Or you can use the GCD method, which can be found on wikipedia
Garo
@Garabed96
Jan 20 2017 01:49
@Garabed96
vab= " "; arry = []; arry = reverseString("Greetings from Earth").split("").reverse("").join(""); for(i=0; i < arry.length;i++){vab += arry[i];} vab.toString();
Stephen James
@sjames1958gm
Jan 20 2017 01:49
@alicankaralar You can edit that post to add two ` at the beginning and end
Garo
@Garabed96
Jan 20 2017 01:49
how do i convert an array back into a function
Joseph
@revisualize
Jan 20 2017 01:50
@Garabed96 What?
Garo
@Garabed96
Jan 20 2017 01:50
function reverseString(str) {
  return str;
}

 vab= " ";
arry = [];
arry = reverseString("Greetings from Earth").split("").reverse("").join("");
for(i=0; i < arry.length;i++){
  vab += arry[i];
}
vab.toString();
Jamil Akhtar
@frontender007
Jan 20 2017 01:51
@Garabed96 vab is already a string , isn't?
Garo
@Garabed96
Jan 20 2017 01:51
i made it a string
but it didnt work
Jamil Akhtar
@frontender007
Jan 20 2017 01:52
@frontender007 why are you doing toString(); ?
Garo
@Garabed96
Jan 20 2017 01:52
i think .join() messes it up
trying to convert it into a string
Joseph
@revisualize
Jan 20 2017 01:53
@Garabed96 You're actually not modifying your function at all.
Jamil Akhtar
@frontender007
Jan 20 2017 01:53
@Garabed96 are you just trying to reverse the string ?
Manuel Almeida
@netstudenton
Jan 20 2017 01:53
Hello
Garo
@Garabed96
Jan 20 2017 01:53
@revisualize my code has to be in the func?
is that the problem?
yes @frontender007
Jamil Akhtar
@frontender007
Jan 20 2017 01:54
@Garabed96 you could just return a string spliting it into words then reverse it and then join it
chaining all these methods
Joseph
@revisualize
Jan 20 2017 01:54
@Garabed96 Yes.
Garo
@Garabed96
Jan 20 2017 01:55
facepalm
David Wolf
@RocPix
Jan 20 2017 01:55
ahha i got it
function palindrome(str) {
  // Good luck!
  var noCaps = str.toLowerCase();

  var noWhiteSpace = noCaps.replace(/[\W_]+/g, '');
  var forwardString = noWhiteSpace.split('');
  var prepReverse = forwardString;
  var flipIt = prepReverse.reverse();
  var backwardString = flipIt.join('');
  if (backwardString == noWhiteSpace) {
    return true;
  }else return false; }
palindrome("race, car");
Jamil Akhtar
@frontender007
Jan 20 2017 01:55
@RocPix great
David Wolf
@RocPix
Jan 20 2017 01:56
@frontender007 ty
CamperBot
@camperbot
Jan 20 2017 01:56
rocpix sends brownie points to @frontender007 :sparkles: :thumbsup: :sparkles:
:cookie: 293 | @frontender007 |http://www.freecodecamp.com/frontender007
Jamil Akhtar
@frontender007
Jan 20 2017 01:57
@RocPix happy coding :)
David Wolf
@RocPix
Jan 20 2017 01:57
ok ive earned the right to sleep now. to tomorrow!! :clap:
Jamil Akhtar
@frontender007
Jan 20 2017 01:58
@RocPix you probably be coding in the dreams. lol, gud night
David Wolf
@RocPix
Jan 20 2017 01:59
:smile:
Xyrus Pangyarihan
@xyruspangyarihan
Jan 20 2017 01:59
can someone help me in the section Using Objects for Lookups
Under basic javascript
Jamil Akhtar
@frontender007
Jan 20 2017 01:59
sure whats the problem?
David Wolf
@RocPix
Jan 20 2017 02:01
@xyruspangyarihan show your code ...
night all
Jamil Akhtar
@frontender007
Jan 20 2017 02:02
@xyruspangyarihan what is wrong with your code ?
Devin Miller
@edwin0258
Jan 20 2017 02:02
@xyruspangyarihan Code pls
Xyrus Pangyarihan
@xyruspangyarihan
Jan 20 2017 02:03

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

// Only change code below this line
/ switch(val) {
case "alpha":
result = "Adams";
break;
case "bravo":
result = "Boston";
break;
case "charlie":
result = "Chicago";
break;
case "delta":
result = "Denver";
break;
case "echo":
result = "Easy";
break;
case "foxtrot":
result = "Frank";
}
/

val = {
"alpha": result = "Adams",
"bravo": result = "Boston",
"charlie": result = "Chicago",
"delta": result = "Denver",
"echo": result = "Easy",
"foxtrot": result = "Frank"
};

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

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

this is my code and i dunno whats wrong with it
i cant use switch case or if statements. i need to use a lookup table
and my code is wrong
Jamil Akhtar
@frontender007
Jan 20 2017 02:04
you actually need to change the switch to an object called lookup = {};
Devin Miller
@edwin0258
Jan 20 2017 02:05
@xyruspangyarihan You've got some typos
  1. / switch(val) {
  1. } /
Jamil Akhtar
@frontender007
Jan 20 2017 02:05
and you don't need val = { .... };
Devin Miller
@edwin0258
Jan 20 2017 02:05
@frontender007 It works fine
He just needs to fix typos
Xyrus Pangyarihan
@xyruspangyarihan
Jan 20 2017 02:06
@frontender007 i dont get it
Devin Miller
@edwin0258
Jan 20 2017 02:06
@xyruspangyarihan Fix your typos :thumbsup:
Edgar Pan
@edgaryp
Jan 20 2017 02:06
@xyruspangyarihan did you type in / in front of switch(val){?
Devin Miller
@edwin0258
Jan 20 2017 02:06
sigh
Xyrus Pangyarihan
@xyruspangyarihan
Jan 20 2017 02:06
@edwin0258 yeah thats a / / maybe there was a problem when i pasted it here
/asterisk asterisk/
why cant i show the asterisk hahaha
Devin Miller
@edwin0258
Jan 20 2017 02:07
Well, If I remove the typos you're program works fine for me lol.
Xyrus Pangyarihan
@xyruspangyarihan
Jan 20 2017 02:07
@frontender007 what do i need
@frontender007 if i dont need val = { }
Stephen James
@sjames1958gm
Jan 20 2017 02:07
@xyruspangyarihan You need to remove the switch or it won't pass (even commented out).
an object just as "alpha" : "Adams" for the property / values. you are supposed to name the object lookup (see instructions)
Jamil Akhtar
@frontender007
Jan 20 2017 02:07
@edwin0258 @xyruspangyarihan , you don't need extra code in there
Xyrus Pangyarihan
@xyruspangyarihan
Jan 20 2017 02:07
@sjames1958gm oohh is that so
Jamil Akhtar
@frontender007
Jan 20 2017 02:07
just turn your switch into an object
Xyrus Pangyarihan
@xyruspangyarihan
Jan 20 2017 02:08
@frontender007 how can i turn the switch into an object
Jamil Akhtar
@frontender007
Jan 20 2017 02:08
var lookup = { "property" : "value"},
Xyrus Pangyarihan
@xyruspangyarihan
Jan 20 2017 02:09
@frontender007 okay i'll try
Jamil Akhtar
@frontender007
Jan 20 2017 02:09
then at the bottom assign result to lookup passing val into it
Jack
@jh0l
Jan 20 2017 02:09
@xyruspangyarihan to define result you could use the syntax result = lookup[val]
Dylan Hsiao
@greedylan
Jan 20 2017 02:09
what does << operator do? found that in a for loop
for (j = i << 1; j <= max; j += i){}
Joseph
@revisualize
Jan 20 2017 02:09
@greedylan Let's find the list of operators
Devin Miller
@edwin0258
Jan 20 2017 02:10
@greedylan bitwise.
it um
Shifts a in binary representation b (< 32) bits to the left, shifting in zeroes from the right. @greedylan
Joseph
@revisualize
Jan 20 2017 02:10
@greedylan That page doesn't have it.
Jamil Akhtar
@frontender007
Jan 20 2017 02:10
never seen one in for loops until today
Jamil Akhtar
@frontender007
Jan 20 2017 02:11
I mean being used in for loop
Xyrus Pangyarihan
@xyruspangyarihan
Jan 20 2017 02:12
@Jhollond thanks a lot man
CamperBot
@camperbot
Jan 20 2017 02:12
xyruspangyarihan sends brownie points to @jhollond :sparkles: :thumbsup: :sparkles:
:cookie: 330 | @jhollond |http://www.freecodecamp.com/jhollond
Xyrus Pangyarihan
@xyruspangyarihan
Jan 20 2017 02:12
@frontender007 thanks a lot man
CamperBot
@camperbot
Jan 20 2017 02:12
xyruspangyarihan sends brownie points to @frontender007 :sparkles: :thumbsup: :sparkles:
:cookie: 294 | @frontender007 |http://www.freecodecamp.com/frontender007
Dylan Hsiao
@greedylan
Jan 20 2017 02:13
@Jhollond @edwin0258 @revisualize not sure if I am reading English but thank you
CamperBot
@camperbot
Jan 20 2017 02:13
greedylan sends brownie points to @jhollond and @edwin0258 and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 331 | @jhollond |http://www.freecodecamp.com/jhollond
:cookie: 556 | @edwin0258 |http://www.freecodecamp.com/edwin0258
:star2: 3059 | @revisualize |http://www.freecodecamp.com/revisualize
Jamil Akhtar
@frontender007
Jan 20 2017 02:13
@xyruspangyarihan welcome
Xyrus Pangyarihan
@xyruspangyarihan
Jan 20 2017 02:13
@frontender007 @Jhollond it works now. not freakin stuck anymore haha
Jack
@jh0l
Jan 20 2017 02:13
@greedylan do you know how binary numbers work yet?
Jamil Akhtar
@frontender007
Jan 20 2017 02:13
@xyruspangyarihan keep moving forward
Joseph
@revisualize
Jan 20 2017 02:13
Anyone know what time it is?
Jamil Akhtar
@frontender007
Jan 20 2017 02:14
@revisualize lol
sleep time
Garo
@Garabed96
Jan 20 2017 02:14
@frontender007 lol i spend a good two hours on this and the code is 1 fucking line
Joseph
@revisualize
Jan 20 2017 02:14
It is rum time!
Garo
@Garabed96
Jan 20 2017 02:14
pardon my french but wtf
i feel like a r tard haha
Jamil Akhtar
@frontender007
Jan 20 2017 02:14
@Garabed96 it happens to everyone
Dylan Hsiao
@greedylan
Jan 20 2017 02:14
yeah but what is bit we are talking about here? @Jhollond
Jamil Akhtar
@frontender007
Jan 20 2017 02:15
just keep trying you'll get better with time
Jack
@jh0l
Jan 20 2017 02:15
@greedylan okay say you have a variable like in the for loop i = 32
Jamil Akhtar
@frontender007
Jan 20 2017 02:15
@Garabed96 thing matter is that you got it :)
Jack
@jh0l
Jan 20 2017 02:17
@greedylan in binary you represent the decimal number 32 as 100000
Manuel Almeida
@netstudenton
Jan 20 2017 02:20
Hello i'm trying to do the lest Intermediate challenge. My code passed almost all test except the last on indicated in the last line.
what wrong did I do?
function addTogether(x) {
    if (arguments.length<=2){

        if(arguments.length===2 && (typeof(arguments[0])=='number' && typeof(arguments[1])=='number')){
            return arguments[0]+arguments[1];
        }
           if(arguments.length===1 && (typeof(arguments[0])=='number')){
            return function(y){
                return y+x;
            };
        }
    }
return undefined;
}

addTogether(2)([3]);  //<====== THIS TEST CAN'T PASS
Joseph
@revisualize
Jan 20 2017 02:20
@netstudenton Currying
Garo
@Garabed96
Jan 20 2017 02:21
@frontender007 thank you
CamperBot
@camperbot
Jan 20 2017 02:21
garabed96 sends brownie points to @frontender007 :sparkles: :thumbsup: :sparkles:
:cookie: 295 | @frontender007 |http://www.freecodecamp.com/frontender007
Jamil Akhtar
@frontender007
Jan 20 2017 02:21
@Garabed96 Bienvenue
Jack
@jh0l
Jan 20 2017 02:22
@greedylan if you do this in the js console i = 32; i << 1 i will then equal 64
Joseph Uchenna
@afrikhero
Jan 20 2017 02:22

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

return arr[0];
}

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

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

Manuel Almeida
@netstudenton
Jan 20 2017 02:22
@revisualize excuse me what do you mean ?
Ricardo G.
@Rubenricardo
Jan 20 2017 02:23
ok
im lost on java
Jack
@jh0l
Jan 20 2017 02:23
@greedylan because you've moved the 1 from the position of 32 to 64 in the binary number
Ricardo G.
@Rubenricardo
Jan 20 2017 02:23
var a; = 7;
var b; = 7;
is there anything wrong with that?
Joseph Uchenna
@afrikhero
Jan 20 2017 02:23
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed. I need rescue. This my instruction
Dylan Hsiao
@greedylan
Jan 20 2017 02:24
I totally got it now @Jhollond
Joseph
@revisualize
Jan 20 2017 02:25
@netstudenton Google: Currying
@netstudenton I don't just say random words when people ask questions.
Jamil Akhtar
@frontender007
Jan 20 2017 02:25
@afrikhero assign the result of shifting an item from the array and return that variable
Jack
@jh0l
Jan 20 2017 02:25
@Rubenricardo only used semicolons when they tell you :)
Joseph Uchenna
@afrikhero
Jan 20 2017 02:27
@frontender007 I don't get I used .shift() then how do I assign it and return. Pls rescue me
Manuel Almeida
@netstudenton
Jan 20 2017 02:28
@revisualize --'
Jack
@jh0l
Jan 20 2017 02:28
@afrikhero could we see your code pls
Jamil Akhtar
@frontender007
Jan 20 2017 02:28
@afrikhero return the array shift() then
Xyrus Pangyarihan
@xyruspangyarihan
Jan 20 2017 02:28
@afrikhero var removedFromMyArray = myArray.shift();
Manuel Almeida
@netstudenton
Jan 20 2017 02:29
@revisualize you're rude man
Joseph
@revisualize
Jan 20 2017 02:29
@netstudenton Need more info?
@netstudenton Am I?
@netstudenton How can I help you?
@netstudenton How can I explain something to you that I don't understand completely?
@netstudenton No one else has answered you.
@netstudenton The only thing I know.. That is called Currying.
@netstudenton For me to explain it to you.. I'd need to google it.
Manuel Almeida
@netstudenton
Jan 20 2017 02:30
@revisualize I need to use that
Joseph Uchenna
@afrikhero
Jan 20 2017 02:30

@Jhollond
function nextInLine(arr, item) {
arr = [1,2,3,4,5];
item = 6;
// Your code here
arr.push(item);
arr.shift();

return arr[0];
}

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

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

Joseph
@revisualize
Jan 20 2017 02:31
@netstudenton I'm sorry that you're seeing my lack of knowledge as rude.
Jamil Akhtar
@frontender007
Jan 20 2017 02:31
Joseph
@revisualize
Jan 20 2017 02:31
@netstudenton I'll gladly shut the hell up.
Jamil Akhtar
@frontender007
Jan 20 2017 02:32
@afrikhero don't do arr.shift() on one line and then return arr[0]
just return arr shift();
Joseph
@revisualize
Jan 20 2017 02:33

The push() method adds one or more elements to the end of an array and returns the new length of the array.

The pop() method removes the last element from an array and returns that element.

The shift() method removes the first element from an array and returns that element.

The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.

Xyrus Pangyarihan
@xyruspangyarihan
Jan 20 2017 02:33
@revisualize @netstudenton don't fight you guys. we're all happy coders here hahahaha
Joseph
@revisualize
Jan 20 2017 02:33
@xyruspangyarihan I don't know how I was rude.
Joseph Uchenna
@afrikhero
Jan 20 2017 02:34

@frontender007 u mean
function nextInLine(arr, item) {
arr = [1,2,3,4,5];
item = 6;
// Your code here
arr.push(item);

return arr.shift();
}

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

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

Joseph
@revisualize
Jan 20 2017 02:34
@afrikhero Why are you overwriting your parameters?
Jamil Akhtar
@frontender007
Jan 20 2017 02:34
@afrikhero exactly
Joseph
@revisualize
Jan 20 2017 02:34
@xyruspangyarihan I'm honestly trying to help a guy learn about a subject that I don't understand.
Jamil Akhtar
@frontender007
Jan 20 2017 02:34
think he's just doing as test purposes
Joseph
@revisualize
Jan 20 2017 02:35
@xyruspangyarihan In fact, @netstudenton is further along in FreeCodeCamp than I am.
Xyrus Pangyarihan
@xyruspangyarihan
Jan 20 2017 02:36
@revisualize yeah maybe @netstudenton just misinterpreted what you said
hahahaha tis okay
Joseph Uchenna
@afrikhero
Jan 20 2017 02:37
@frontender007 instruction pane is showing error
Jamil Akhtar
@frontender007
Jan 20 2017 02:38
@afrikhero link your challenge code here please ?
Ricardo G.
@Rubenricardo
Jan 20 2017 02:40
hello
Manuel Almeida
@netstudenton
Jan 20 2017 02:40
Can't understand why he supposed I don't know what currying is .
The currying is not the problem but instead it's is required in the challenge.
Ricardo G.
@Rubenricardo
Jan 20 2017 02:40
can anyone help me with this instruciton
a should be assigned to b with =
var a = var b;
im putting it like that but it doenst work
on java zript
??
Joseph Uchenna
@afrikhero
Jan 20 2017 02:42
@Rubenricardo declare variable a and assign it to b like this var a = b
Ricardo G.
@Rubenricardo
Jan 20 2017 02:43
it says that b is no funciton

var a = 7;

var b = 7;

var a = b

Joseph
@revisualize
Jan 20 2017 02:44
@Rubenricardo How do you assign the value of 7 to a variable num? ... var num = 7;
Now if you want you can use a variable to store values.
Like in mathmatics. num + 3 = 10 What is the value of num?
var x = num + 3; ... That outputs 10
So, you can do several things with variables. But, you need to understand that variables hold values and variables can be used with other variables.
So, how do you assign the value of 5 to a variable x? ... x = 5; (Which is also overwriting the previous value of 10 from above.
How do you assign the value of x to a variable y?
Look at the way things are written. var y = x;
How do you assign the value of 42 to a variable answer? ... What is the answer?
Variables hold values. Just understand that.
Ricardo G.
@Rubenricardo
Jan 20 2017 02:45
oh im starting to get it
@revisualize thanks man
Joseph Uchenna
@afrikhero
Jan 20 2017 02:45
type a = b @Rubenricardo
CamperBot
@camperbot
Jan 20 2017 02:45
rubenricardo sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3060 | @revisualize |http://www.freecodecamp.com/revisualize
Michael Pimentel Jr
@mtpjr88
Jan 20 2017 02:46

Question ...
if passing a parameter like this

function randomNum(myNum, hisNum){

return randomNum(myNum*10, hisNum*2 )
}
myRandomNum(5, 3);

instead of passing an argument couldn't I just declare them as variables first? ie.

var myNum = 5;

var hisNum = 3;

is this bad practice? or just slower?

Ricardo G.
@Rubenricardo
Jan 20 2017 02:46
@afrikhero it still does not let me

var a = 7;

var b = 7;

var a = b;

what am i doing wrong?
Dylan Hsiao
@greedylan
Jan 20 2017 02:47
@mtpjr88 you are calling the function inside a function, i could be wrong but this creates a recursive case?
Joseph Uchenna
@afrikhero
Jan 20 2017 02:48
send your challenge link @Rubenricardo
Adam Wayne
@AdamWayne-dev
Jan 20 2017 02:48
Hey guys, I'm having trouble with this code, it doesn't seem to jump to the next set of numbers within the array, where have I gone wrong?

function largestOfFour(arr) {
  function sortNumber(a,b) {
    return a - b;
}
  var highNum = 0;
  var lowNum = 0;
  for(var i = 0; i < arr.length; i++){
    for(var j = 0; j < arr[i].length; j++){

   arr[i].sort(sortNumber);

  }
  return arr;
}
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
I should state that it sorts the first set of numbers correctly, but then the code just stops.
Jamil Akhtar
@frontender007
Jan 20 2017 02:50
@afrikhero you just have to use the parameters provided with function , you don't have to declare arr and then manually assign a variable item to value
just do push arr(item) and then return arr shift();
delete the array you declare inside your function and item too
@AdamWayne-dev you're not comparing one number to another to see if which one you need to return
Jceciliani
@Jceciliani
Jan 20 2017 02:52
Can anyone see the issue here? I need to "Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable."

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

// Only change code below this line
switch(val) {
case "alpha":
result = "Adams";
break;
case "bravo":
result = "Boston";
break;
case "charlie":
result = "Chicago";
break;
case "delta":
result = "Denver";
break;
case "echo":
result = "Easy";
break;
case "foxtrot":
result = "Frank";
}

var lookup = val;
result[lookup];

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

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

Jamil Akhtar
@frontender007
Jan 20 2017 02:53
inside second for loop declare a variable to 0 and check against the looped value if it is less than or greater than the value
@Jceciliani change the switch statement to an object
like var lookup = {};
then inside it "prop": "val", at the end assign return to lookup by passing the val
Adam Wayne
@AdamWayne-dev
Jan 20 2017 02:54
@frontender007 Thanks, I'll give it a shot
CamperBot
@camperbot
Jan 20 2017 02:54
adamwayne-dev sends brownie points to @frontender007 :sparkles: :thumbsup: :sparkles:
:cookie: 296 | @frontender007 |http://www.freecodecamp.com/frontender007
Joseph Uchenna
@afrikhero
Jan 20 2017 02:55
@frontender007 thanks a million times big brother. Made the changes and it works fine
CamperBot
@camperbot
Jan 20 2017 02:55
afrikhero sends brownie points to @frontender007 :sparkles: :thumbsup: :sparkles:
:cookie: 297 | @frontender007 |http://www.freecodecamp.com/frontender007
Jamil Akhtar
@frontender007
Jan 20 2017 02:55
@afrikhero anytime bro.
Joseph Napoleon
@Joe2718
Jan 20 2017 02:56
Does anyone know to make 0.5 into 0.50 and still keep it a number?
Evan
@etmoore
Jan 20 2017 02:57
for the life of me, I can't figure out why this doesn't work for Profile Lookup:
function lookUpProfile(firstName, prop){
  for (var i = 0; i < contacts.length; i++){
    var contact = contacts[i];
    if (contact.firstName == firstName) {
      if (contact.hasOwnProperty(prop)) return contact.prop;
      else return "No such property";
    }
  }
  return "No such contact";  
}
Jamil Akhtar
@frontender007
Jan 20 2017 02:57
@Joe2718 0.5 + "0"
Jceciliani
@Jceciliani
Jan 20 2017 02:58
@frontender007 I cannot change the return location. I can only change the code above that point
Jamil Akhtar
@frontender007
Jan 20 2017 02:58
@etmoore check hasOwnProperty before you log it after checking firstName
@Jceciliani show your code please ?
Ricardo G.
@Rubenricardo
Jan 20 2017 02:59
@afrikhero
i think its the second one of java
Jceciliani
@Jceciliani
Jan 20 2017 03:00
@frontender007 I tried your suggestions but no luck. this is back to how it was.

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

// Only change code below this line
switch(val) {
case "alpha":
result = "Adams";
break;
case "bravo":
result = "Boston";
break;
case "charlie":
result = "Chicago";
break;
case "delta":
result = "Denver";
break;
case "echo":
result = "Easy";
break;
case "foxtrot":
result = "Frank";
}

var lookup = val;
result[lookup];

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

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

Jamil Akhtar
@frontender007
Jan 20 2017 03:00
you should change switch to this var lookup = { "charlie": "easy", "second": "secondVal", etc
Evan
@etmoore
Jan 20 2017 03:01
sorry @frontender007 , not sure I understand… mind elaborating?
Jamil Akhtar
@frontender007
Jan 20 2017 03:01
var lookup = { "echo": "easy"}
Joseph Uchenna
@afrikhero
Jan 20 2017 03:02

@Rubenricardo
// Setup
var a;
var b = 2;

// Only change code below this line

var a = 7;

b = a;

Jamil Akhtar
@frontender007
Jan 20 2017 03:02
@etmoore contact.firstName === firstName after this line check if the same contact.hasOwnProperty(prop)
Ricardo G.
@Rubenricardo
Jan 20 2017 03:04
haha @afrikhero im sorry dude it still doesn't work
Jamil Akhtar
@frontender007
Jan 20 2017 03:04
@Jceciliani delete switch(val) and replace it with var lookup = and leave everything
Joseph Napoleon
@Joe2718
Jan 20 2017 03:04
var t = 0.5;
var z = t + "0";
var q = typeof(z);
anyone know how to make 0.5 into 0.50 and keep it a number?
Evan
@etmoore
Jan 20 2017 03:05

hmm - I think that's what I have, right?

function lookUpProfile(firstName, prop){
  for (var i = 0; i < contacts.length; i++){
    var contact = contacts[i];
    if (contact.firstName === firstName) {
      if (contact.hasOwnProperty(prop)) return contact.prop;
      else return "No such property";
    }
  }
  return "No such contact";  
}

After I check to make sure the first name matches, I then check to see if the contact has the property with contact.hasOwnProperty(prop)

Jamil Akhtar
@frontender007
Jan 20 2017 03:05
@Jceciliani now you don't need break statements so delete them as well
@Jceciliani result shouldn't be inside the lookup object so delete result = part as well
@Jceciliani you should have now var lookup = { "name": "value" ..... };
Ricardo G.
@Rubenricardo
Jan 20 2017 03:06
does anyone know how to do this
Do not change code above the line
a should have a value of 7
b should have a value of 7?
a should be assigned to b with =
Jamil Akhtar
@frontender007
Jan 20 2017 03:06
then after the closing curly brace of the lookup object assign result to lookup by passing val using square brackets
@Rubenricardo you can assign variables with other variables too
Joseph Uchenna
@afrikhero
Jan 20 2017 03:07

@Rubenricardo it works here. Check your semi colons. U were asked to assign a contents to b. this is it
// Setup
var a;
var b = 2;

// Only change code below this line

a = 7;

b = a;

Jamil Akhtar
@frontender007
Jan 20 2017 03:08
@Jceciliani did you get it?
Ricardo G.
@Rubenricardo
Jan 20 2017 03:08
so how should i add it @afrikhero @frontender007 wuhuuuuuuuu
Gabriela Bazan
@GabrielaLBazan
Jan 20 2017 03:09
Hello! I'd like to ask for some help on "Accessing Objects Properties with Variables"
Jamil Akhtar
@frontender007
Jan 20 2017 03:09
@GabrielaLBazan sure
Ricardo G.
@Rubenricardo
Jan 20 2017 03:09
did it, i was adding var thats whys thanks!! @afrikhero @frontender007
CamperBot
@camperbot
Jan 20 2017 03:09
rubenricardo sends brownie points to @afrikhero and @frontender007 :sparkles: :thumbsup: :sparkles:
:cookie: 175 | @afrikhero |http://www.freecodecamp.com/afrikhero
:cookie: 298 | @frontender007 |http://www.freecodecamp.com/frontender007
Jamil Akhtar
@frontender007
Jan 20 2017 03:09
@Rubenricardo you are not adding anything here just assigning one var s value to another var thats it
Ricardo G.
@Rubenricardo
Jan 20 2017 03:10
yeah i figured it out now
Joseph Uchenna
@afrikhero
Jan 20 2017 03:10
@Rubenricardo hope you've proceeded to the next challenge
Jamil Akhtar
@frontender007
Jan 20 2017 03:10
@Rubenricardo great
Ricardo G.
@Rubenricardo
Jan 20 2017 03:10
i did thanks
Jamil Akhtar
@frontender007
Jan 20 2017 03:10
@GabrielaLBazan what you're having trouble with ?
Joseph Uchenna
@afrikhero
Jan 20 2017 03:11
u r wlc
Gabriela Bazan
@GabrielaLBazan
Jan 20 2017 03:12
Instructions
Use the playerNumber variable to lookup player 16 in testObj using bracket notation.

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16; // Change this Line
var player = playerNumber[testObj]; // Change this Line
console.log(player); // "Montana"

Manish Giri
@Manish-Giri
Jan 20 2017 03:13
@GabrielaLBazan testObj is the object name
playerNumber is the property you're looking up from within the object
Jamil Akhtar
@frontender007
Jan 20 2017 03:13
you just need to assign player to testObj passing in playerNumber
Manish Giri
@Manish-Giri
Jan 20 2017 03:13
playerNumber[testObj]; - you've got this backwards
Jamil Akhtar
@frontender007
Jan 20 2017 03:13
in the brackets
Gabriela Bazan
@GabrielaLBazan
Jan 20 2017 03:13
backwards
got it
thank you @frontender007
CamperBot
@camperbot
Jan 20 2017 03:13
gabrielalbazan sends brownie points to @frontender007 :sparkles: :thumbsup: :sparkles:
:cookie: 299 | @frontender007 |http://www.freecodecamp.com/frontender007
Gabriela Bazan
@GabrielaLBazan
Jan 20 2017 03:13
thank you @Manish-Giri
CamperBot
@camperbot
Jan 20 2017 03:13
:star2: 3891 | @manish-giri |http://www.freecodecamp.com/manish-giri
gabrielalbazan sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
Jamil Akhtar
@frontender007
Jan 20 2017 03:13
@GabrielaLBazan welcome
Neo
@neo112358
Jan 20 2017 03:14
Hi everyone, Please help me. I wanna change 'I'm a good man' into 'I'm A Good Man'. I use match rule '/\b(\w)|\s(\w)\g' . But the result is 'I'M A Good Man'. What's wrong?
Manish Giri
@Manish-Giri
Jan 20 2017 03:14
@GabrielaLBazan :+1:
Jamil Akhtar
@frontender007
Jan 20 2017 03:15
just split the string into words and save it in a variable
Neo
@neo112358
Jan 20 2017 03:16
sorry, writing mistake, match rule is '/\b(\w)|\s(\w)/g'
Jamil Akhtar
@frontender007
Jan 20 2017 03:16
loop through words and then each word change its first letter to uppercase by using word.charAt(0).toUpperCase + word.slice(1)
Neo
@neo112358
Jan 20 2017 03:16
only that way?

function titleCase(str) {
var str1 = str.toLowerCase();
var reg = /\b(\w)|\s(\w)/g;
return str1.replace(reg,function(m){
return m.toUpperCase();});
}

titleCase("i'm a little Tea pot");

here is my code, please help me check it
Jamil Akhtar
@frontender007
Jan 20 2017 03:17
@neo112358 can you link challenge page here?
Joseph
@revisualize
Jan 20 2017 03:18
@etmoore That isn't correct.
@etmoore You're missing a bunch of stuff.
Neo
@neo112358
Jan 20 2017 03:19
I use Chinese version
Cal-culator
@Cal-culator
Jan 20 2017 03:20
Need help with Twitch TV
Jamil Akhtar
@frontender007
Jan 20 2017 03:22
first you should have an array with str splitted into the words
then loop through the words array and change each word to title case
Neo
@neo112358
Jan 20 2017 03:23
ok, I will try your way, THX
Jamil Akhtar
@frontender007
Jan 20 2017 03:24
by doing word.charAt(0).toUpperCase() + word.slice(1);
Neo
@neo112358
Jan 20 2017 03:24
ok, first to hear that method
first time
Jamil Akhtar
@frontender007
Jan 20 2017 03:26
@neo112358 thought you probably know that there are toLowerCase and toUpperCase() methods available for string object
anyway the idea is to change each words first letter to uppercase thus making it titlecase
@Cal-culator what is your problem ?
Cal-culator
@Cal-culator
Jan 20 2017 03:28
@frontender007 the data isn't loading
Jamil Akhtar
@frontender007
Jan 20 2017 03:28
ok let me check
Randy Goldsmith
@Dueldrawer8
Jan 20 2017 03:32
function getLongestWordOfMixedElements(arr) {
  // your code here
  var newArr = [];
  var count = 0;
      for(var i = 0; i < arr.length; i++){
        if(typeof(arr[i]) === 'string'){
            newArr.push(arr[i]);
        }
    }
     newArr.forEach(function(x){
         if(x.length > count){
             count = x;
         }
     });
     return arr.length > 0 ? count : '';
}

getLongestWordOfMixedElements([3, 'word', 5, 'up', 3, 1]);
stuck again.. i need to figure out a way to return an empty string if there are NO strings in the given array..
Amara
@AmaraD92
Jan 20 2017 03:36
I tried searching around but I do not understand this objective.
"Only remove the backslashes \ used to escape quotes."
var myStr = '<a href="http://www.example.com" target="_blank"> Link </a>';
Margaret
@Margaret2
Jan 20 2017 03:36
@AmaraD92 you removed too many backslashes probably
@AmaraD92 what is the name of the challenge
Amara
@AmaraD92
Jan 20 2017 03:37
It's the "Quoting Strings with Single Quotes" challenge
Margaret
@Margaret2
Jan 20 2017 03:37
ok
@AmaraD92 hmmm... it actually looks right to me, try refreshing the page
Corey Pennington
@JuiceyDuecy
Jan 20 2017 03:42
@Dueldrawer8 what lesson is this??
Jamil Akhtar
@frontender007
Jan 20 2017 03:43
@Dueldrawer8 first of delete two variables outside the for loop
then newArr.foreach to return delete that as well
Ezra
@EzraPlato
Jan 20 2017 03:45
What did I do wrong? function fun1() {
// Assign 5 to oopsGlobal Here
oopsGobal = 5;
}
Jamil Akhtar
@frontender007
Jan 20 2017 03:45
now right after for loop opening curly brace you should have a variable to hold the longest word
@EzraPlato use var oopsGlobal may be
Ezra
@EzraPlato
Jan 20 2017 03:45
I can via the instructions "Inside function fun1, assign 5 to oopsGlobal without using the var keyword."
cant
Jamil Akhtar
@frontender007
Jan 20 2017 03:46
@EzraPlato link challenge here please
166

Using var, declare a global variable myGlobal outside of any function. Initialize it with a value of 10.

Inside function fun1, assign 5 to oopsGlobal without using the var keyword.

DigitalTheorist
@DigitalTheorist
Jan 20 2017 03:49
Question on the Returning Boolean Values from Functions challenge. My output is blank but I'd think this code would work. Does the switch operator not compare more than one parameter?
my code
Joseph
@revisualize
Jan 20 2017 03:49
about @revisualize
CamperBot
@camperbot
Jan 20 2017 03:49
:star2: 3060 | @revisualize |http://www.freecodecamp.com/revisualize
DigitalTheorist
@DigitalTheorist
Jan 20 2017 03:50

function isLess(a, b) {
var answer = "";
// Fix this code
switch (a, b) {

case a < b:
  answer = "true";
break;

case a > b:
  answer = "false";
break;

}
return answer;
}

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

Ezra
@EzraPlato
Jan 20 2017 03:52
What's wrong here? I can't use var due to the instructions 166. var myGlobal = 10;
function fun1() {
// Assign 5 to oopsGlobal Here
oopsGobal = 5;
}
Jamil Akhtar
@frontender007
Jan 20 2017 03:52
@DigitalTheorist you should check switch ( a < b )
@EzraPlato challenge link?
Bardoe Bess
@bardbess
Jan 20 2017 03:54
[1.01, 2.05, 3.1, 4.25, 90, 55, 20, 60, 100].reduce(function(a,b){ return (b+a) }) => 335.40999999999997 :( :( bad javascript
Diego Mayer
@Chrono79
Jan 20 2017 03:54
@EzraPlato oopsGlobal <- you missed an l there
DigitalTheorist
@DigitalTheorist
Jan 20 2017 03:54
@frontender007 what do you mean, "check switch".
Cal-culator
@Cal-culator
Jan 20 2017 03:55
@frontender007 Did you see where I went wrong
Bardoe Bess
@bardbess
Jan 20 2017 03:55
Anyone know why reduce is doing this? is it a bug?
Jamil Akhtar
@frontender007
Jan 20 2017 03:55
@DigitalTheorist you should check if a is bigger or b in switch , switch checks for values,
Jamil Akhtar
@frontender007
Jan 20 2017 03:55
@Cal-culator trying to figure it out, as I used jQuery mostly for mine
but its better to use vanilla javascript to solidify your knowledge
Diego Mayer
@Chrono79
Jan 20 2017 03:56
@bardbess it's not a bug, that's how javascript deals with float numbers, sometimes it gives you that sort of results
Ezra
@EzraPlato
Jan 20 2017 03:56
@Chrono79 thank you...Smashing head against whiteboard
CamperBot
@camperbot
Jan 20 2017 03:56
:star2: 3182 | @chrono79 |http://www.freecodecamp.com/chrono79
ezraplato sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Bardoe Bess
@bardbess
Jan 20 2017 03:57
? but why not just 335.4 ? @Chrono79 where does the 0999999* come from?
Bardoe Bess
@bardbess
Jan 20 2017 03:58
if I add the values 1.01 + 2.05 + 3.1 + 4.24 + 90 + 55 + 20 + 60 + 100 i dont have any problems => 335.4
thanks @Chrono79
CamperBot
@camperbot
Jan 20 2017 03:58
bardbess sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3183 | @chrono79 |http://www.freecodecamp.com/chrono79
Bardoe Bess
@bardbess
Jan 20 2017 04:00
geez. well thats totally unexpected
Jamil Akhtar
@frontender007
Jan 20 2017 04:01
@EzraPlato at the top declare your oopsGlobal variable but without var
and fix the spellings of oopsGlobal inside the func1
Bardoe Bess
@bardbess
Jan 20 2017 04:02
guess ill do reduce(function(a,b){ return (Math.floor((b+a)*100))/100}); seems like a hack though.
Joseph
@revisualize
Jan 20 2017 04:02
It works.
@bardbess By the way.
zuber
@jkdjf
Jan 20 2017 04:03
i have just git stuck in escape sequence in string in javascript
Joseph
@revisualize
Jan 20 2017 04:03
I rewrote your code that broke my browser earlier.
@jkdjf What do you have currently?
zuber
@jkdjf
Jan 20 2017 04:03
only javascript
Joseph
@revisualize
Jan 20 2017 04:04
@jkdjf Well, I'm glad that it is JavaScript. You are in the HelpJavaScript room.
zuber
@jkdjf
Jan 20 2017 04:04
so help me
Joseph
@revisualize
Jan 20 2017 04:04
@jkdjf So show me what you have.
Show me the code.
Show me what you've done.
Show me where you're having issues.
Help me help you.
CamperBot
@camperbot
Jan 20 2017 04:05
no wiki entry for: me help you
Bardoe Bess
@bardbess
Jan 20 2017 04:05
@revisualize its all good It passed the tests. working on 'Exact Change` now :)
zuber
@jkdjf
Jan 20 2017 04:06
"ln lr \" like this i have written in code
Joseph
@revisualize
Jan 20 2017 04:07
@jkdjf Okay. If you look at the instructions it gives you a string to assign to the variable myStr.
@jkdjf You have to assign 'FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine' to the variable myStr.
As per the instructions.
But, you have to replace the words with the proper escape sequences.
@bardbess
function dropElements(arr, func) {
  while (arr.length > 0) {
     if (func(arr[0])) { break; }
     arr.shift();
  }
  return arr;
}
zuber
@jkdjf
Jan 20 2017 04:09
wha is this
this i snot my issue
Joseph
@revisualize
Jan 20 2017 04:09
@jkdjf Do you see what I'm talking about in the instructions?
Bardoe Bess
@bardbess
Jan 20 2017 04:09
haha
Joseph
@revisualize
Jan 20 2017 04:09
@jkdjf That code block was for someone else.
zuber
@jkdjf
Jan 20 2017 04:10
ok
Bardoe Bess
@bardbess
Jan 20 2017 04:10
was for me. @jkdjf
Joseph
@revisualize
Jan 20 2017 04:10
@jkdjf Have you read the instructions?
zuber
@jkdjf
Jan 20 2017 04:10
why do not you show some hints
Joseph
@revisualize
Jan 20 2017 04:10
@jkdjf Did you find the string that you need to escape and assign to myStr?
@jkdjf Because, I'm a jerk and I don't want to show you hints.
@jkdjf Is that what you want to hear?
zuber
@jkdjf
Jan 20 2017 04:11
where should i write it, \
revisualize @revisualize goes afk. Emergency :toilet: run.
Bardoe Bess
@bardbess
Jan 20 2017 04:11
thanks @revisualize . Im ok with my solution. im not expecting it to be tested against anything but the test cases in the system so I didnt worry about checks. altough for the fibonache one in think I did put a limit on my loop - but thats because i kept crashing my browser. haha
CamperBot
@camperbot
Jan 20 2017 04:11
bardbess sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3061 | @revisualize |http://www.freecodecamp.com/revisualize
Garo
@Garabed96
Jan 20 2017 04:12
function palindrome(str) {
  // Good luck!
  placeHolder = str;
  re = /\S+/gi;

  while(str){
    placeHolder.toLowerCase();
    placeHolder.split("").reverse("").join("");
    placeHolder.replace(" ", "");
    placeHolder.replace(/\w/g, '');
    if(str === placeHolder){
      return true;
    } else return false;
  }
Joseph
@revisualize
Jan 20 2017 04:12
I suddenly need to take a :ship: on the :toilet:
yeah.
That's what I got to do.
Garo
@Garabed96
Jan 20 2017 04:12
hey guys fro this code
does it look like im on the right track?
zuber
@jkdjf
Jan 20 2017 04:13
hi garo
Joseph
@revisualize
Jan 20 2017 04:13
There are several ways to solve the challenge.
Garo
@Garabed96
Jan 20 2017 04:14
hi zub
im trying to see if i got the logic though
zuber
@jkdjf
Jan 20 2017 04:14
you don't want to show me some hints
yeah
Garo
@Garabed96
Jan 20 2017 04:14
placeHolder.replace(/\ /g, "");
wut>
zuber
@jkdjf
Jan 20 2017 04:14
garo are helping me
you
Garo
@Garabed96
Jan 20 2017 04:15
um whats the question....
If I'm able to
zuber
@jkdjf
Jan 20 2017 04:15
Escape Sequences in Strings
i m not being able to write code in that
Garo
@Garabed96
Jan 20 2017 04:15
is that the q name
Ezra
@EzraPlato
Jan 20 2017 04:15

What did I do wrong? Another typo? Am I dislexic?
// Setup
var outerWear = "T-Shirt";

function myOutfit() {
// Only change code below this line
var myOutfit = "sweater";

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

myOutfit();

zuber
@jkdjf
Jan 20 2017 04:15
waht is way the of write
Ezra
@EzraPlato
Jan 20 2017 04:16
Should return sweater
Garo
@Garabed96
Jan 20 2017 04:16
FirstLine\n\\SecondLine\\\r\ThirdLine
idk how i could help u with that without the answer tbh
Joseph
@revisualize
Jan 20 2017 04:17
You have to assign 'FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine' to the variable myStr.
But, you have to replace the words with the proper escape sequences.
How do you escape a newline? With: \n
How do you escape a backslash? With: \\
How do you escape a carriage-return? With \r
So, you have break the problem down.
FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
FirstLine\nbackslashSecondLinebackslashcarriage-returnThirdLine
FirstLine\n\\SecondLinebackslashcarriage-returnThirdLine
FirstLine\n\\SecondLine\\carriage-returnThirdLine
FirstLine\n\\SecondLine\\\rThirdLine
And you assign that to myStr as a string.
@Garabed96 You actually did it wrong.
Garo
@Garabed96
Jan 20 2017 04:18
@revisualize it works...
Joseph
@revisualize
Jan 20 2017 04:18
@Garabed96 Okay.
Garo
@Garabed96
Jan 20 2017 04:18
whats wrong with it
oh u mean for my code
or are you talking about the answer i gave him?
Joseph
@revisualize
Jan 20 2017 04:19
@Garabed96 You have a \ before ThirdLine which doesn't need to be there.
John Roper
@jroper19
Jan 20 2017 04:19
var count = 0;

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


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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Can anyone tell me the purpose of the "var count" line in this?
Joseph
@revisualize
Jan 20 2017 04:19
@Garabed96 I'm just posting the answer because the guy is an ass and impatient.
@jroper19 Yeah. It is a global variable.
@jroper19 It tells you about the global variable in the instructions.
Garo
@Garabed96
Jan 20 2017 04:20
@revisualize thanks for letting me know
CamperBot
@camperbot
Jan 20 2017 04:20
garabed96 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3062 | @revisualize |http://www.freecodecamp.com/revisualize
Garo
@Garabed96
Jan 20 2017 04:20
seemed redundant
good that i k the right way now
Joseph
@revisualize
Jan 20 2017 04:21
@jroper19 I've taken the time to rewrite the instructions for that challenge.
Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.
Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
John Roper
@jroper19
Jan 20 2017 04:21
@revisualize Yeah, I've read it a couple times but i dont kmow what its actually doing lol
Joseph
@revisualize
Jan 20 2017 04:22
@jroper19 It's a global variable.
@jroper19 It needs to stay persistent each time the function runs.
Anyone know why my current console.log equation is evaluating to false?
John Roper
@jroper19
Jan 20 2017 04:23
@revisualize Alright, let me give this another shot. Thanks much!
CamperBot
@camperbot
Jan 20 2017 04:23
jroper19 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3064 | @revisualize |http://www.freecodecamp.com/revisualize
a.n.ita
@Coding-Mama
Jan 20 2017 04:27
hello world
CamperBot
@camperbot
Jan 20 2017 04:27

welcome to FreeCodeCamp @Coding-Mama!

a.n.ita
@Coding-Mama
Jan 20 2017 04:27
How is everyone?
paiztee
@paiztee
Jan 20 2017 04:28
++
grantknaver
@grantknaver
Jan 20 2017 04:31

function smallestCommons(arr) {
  for(var i= arr[0]+1; i < arr[1]; i++){arr.push(i);}
  var sortedArray = arr.sort(function(a,b){return b-a;});
  var loop = 2; 
  var base = sortedArray[0]*loop;
  var baseRemainder = function(element){
    return base % element === 0;  
  };
  var filterMul = sortedArray.filter(baseRemainder);

  do{
    if(filterMul){
      return base;  
    }
    loop++;
  }
  while(!filterMul);


}


smallestCommons([1,5]);
what am I missing here.
here is the assignment
tgitari
@tgitari
Jan 20 2017 04:33

var a = 3;
var b = 17;
var c = 12;

// Only modify code below this line

a = a + 12;
b = 9 + b;
c = c + 7;

What I'm I missing
grantknaver
@grantknaver
Jan 20 2017 04:33
Im looking to take one index multiply it by times an increasing number (loop)
a.n.ita
@Coding-Mama
Jan 20 2017 04:33
Okay, well have a good night everyone.
cjljohnson
@cjljohnson
Jan 20 2017 04:34
how do i access the this.workTime from inside the setInterval function? http://codepen.io/cjljohnson/pen/MJpbrX
grantknaver
@grantknaver
Jan 20 2017 04:34
Im looking to take index one of sortedArray and multiply it by the number of loops.
Than filter it by base remainder element.
if I get 0 for all indexes of sortedArray it is supposed to return the base.
any ideas guys
grantknaver
@grantknaver
Jan 20 2017 04:44
anyone there
eeflores
@eeflores
Jan 20 2017 04:45
question?
(thinking ...)
grantknaver
@grantknaver
Jan 20 2017 04:46
cool thanks. It seems to make to me
could be my var position maybe...
eeflores
@eeflores
Jan 20 2017 04:47
var arr = [3, 4, 5];
for(var i = 0; i < 10; i++) {
  console.log(arr[0] * i);
}
number of loops?
grantknaver
@grantknaver
Jan 20 2017 04:49
I used the wrong method it supposed to be every(). I needed to test for true or false, and not filter
jmgumina
@jmgumina
Jan 20 2017 04:49
Hi All, I am haveing some trouble with the escape sequence in strings solution this is my code
grantknaver
@grantknaver
Jan 20 2017 04:49

function smallestCommons(arr) {
  for(var i= arr[0]+1; i < arr[1]; i++){arr.push(i);}
  var sortedArray = arr.sort(function(a,b){return b-a;});
  var loop = 2; 
  var base = sortedArray[0]*loop;
  var baseRemainder = function(element){
    return base % element === 0;  
  };
  var filterMul = sortedArray.every(baseRemainder);

  do{
    if(filterMul){
      return base;  
    }
    loop++;
  }
  while(!filterMul);


}


smallestCommons([1,5]);
jmgumina
@jmgumina
Jan 20 2017 04:49
var myStr = "\FirstLine\t\SecondLine\t\rThirdLine\r\n";
Hi All, I am haveing some trouble with the escape sequence in strings solution this is my code
eeflores
@eeflores
Jan 20 2017 04:50
@grantknaver sorry, I'm having horror flashbacks for that challenge
@grantknaver I'm planning to revisit that in the future
grantknaver
@grantknaver
Jan 20 2017 04:51
number of loops... well you have it set to be less than 10, but only have 3 elements in arr... will cause a problem
Garo
@Garabed96
Jan 20 2017 04:51
function palindrome(str) {
  // Good luck!
    str.toLowerCase();
    str.replace(/\ /g, "");
    str.replace(/\,/g, '');
    str.replace(/\./g, '');
      str.replace(/\w/gi, '');
        //var placeHolder = str;
    if(str === str.split("").reverse("").join("") ){
      return true;
    } else return false;  
}
palindrome("eye");
eeflores
@eeflores
Jan 20 2017 04:52
@jmgumina no tab after SecondLine
Garo
@Garabed96
Jan 20 2017 04:52
why is this not working
grantknaver
@grantknaver
Jan 20 2017 04:52
@eeflores dang
eeflores
@eeflores
Jan 20 2017 04:52
@jmgumina need to escape \
Garo
@Garabed96
Jan 20 2017 04:53
did i properly replace comma period and _ : - )... with those replace lines?
grantknaver
@grantknaver
Jan 20 2017 04:53
I will have to get help hopefully
eeflores
@eeflores
Jan 20 2017 04:53
@Garabed96 all the String functions return a value - something like str = str.toLowerCase();
@grantknaver there's supposedly an efficient way to do that challenge which I have to make time to learn
grantknaver
@grantknaver
Jan 20 2017 04:54
its all good I will just check in a bit later and hopefully catch someone who can help
Neo
@neo112358
Jan 20 2017 04:54

function titleCase(str) {
var str1 = str.toLowerCase().split("");
for(var i=0; i<str1.length; i++){
str[i]=str1[i].charAt(0).toUpperCase + str1[i].slice(1);
}

return str1.join("");
}

titleCase("i'm a little Tea pot");

please tell me what's wrong with my code above, THX!
eeflores
@eeflores
Jan 20 2017 04:55
@neo112358 the split is not splitting on space
same with join - not joining with space
Neo
@neo112358
Jan 20 2017 04:56
ok, I see
THX
Garo
@Garabed96
Jan 20 2017 04:56
str = str.replace(/\,/g, '');
str =str.replace(/./g, '');
is there a way to put this in 1 line
either or work but they dont work together :s
eeflores
@eeflores
Jan 20 2017 04:57
str = str.replace(/[.,]/g, "");
Ken Haduch
@khaduch
Jan 20 2017 04:57
@Garabed96 - I'd have to look at this in detail, but I think that you are replacing your word characters with the \w - that would remove all alphabetic, numeric and underscore? You might really want \W - which is the non-word characters
eliecerthoms
@eliecerthoms
Jan 20 2017 04:57
@eeflores killin it
Garo
@Garabed96
Jan 20 2017 04:57
ur right @khaduch \
eeflores
@eeflores
Jan 20 2017 04:58
what you probably want is str = str.replace(/[^a-z0-9 ]/g, "");
Neo
@neo112358
Jan 20 2017 04:58
I have added a space, but there is also an error said 'cannot assign to read only property '0' of string 'i'm a little Tra pot''
Garo
@Garabed96
Jan 20 2017 04:58
wat does that ^ do
upper case is removed?
eeflores
@eeflores
Jan 20 2017 04:58
upper case removed when you did toLowerCase
tgitari
@tgitari
Jan 20 2017 04:59
Whats wrong with my code var myStr= "I am a, \"double quoted\" string inside \"double quotes\"."; // Change this line
Ken Haduch
@khaduch
Jan 20 2017 04:59
@Garabed96 - in fact, if you use the \W along with _ you can get both. @eeflores has a good idea, too - replacing everything that is not an alpha or number with nothing.
Garo
@Garabed96
Jan 20 2017 04:59
ya but what does that line do that u linked
ohh
eeflores
@eeflores
Jan 20 2017 04:59
yep what @khaduch said
Garo
@Garabed96
Jan 20 2017 05:03
@khaduch @eeflores thank you but that doesnt replace everything thats not alpha or number
CamperBot
@camperbot
Jan 20 2017 05:03
garabed96 sends brownie points to @khaduch and @eeflores :sparkles: :thumbsup: :sparkles:
:cookie: 919 | @eeflores |http://www.freecodecamp.com/eeflores
:star2: 2319 | @khaduch |http://www.freecodecamp.com/khaduch
CoryCMyers
@CoryCMyers
Jan 20 2017 05:03

So out of curiousity what is the difference between


function findLongestWord(str) {
  var strSplit = str.split(' ');
  var longestWord = 0;
  for(var i = 0; i < strSplit.length; i++){
    if(strSplit[i].length > longestWord){
    longestWord = strSplit[i].length;
     }
  }
  return longestWord;
}

and


function findLongestWord(str) {
  var strSplit = str.split(' ');
  var longestWord = 0;
  for(var i = 0; i < strSplit.length; i++){
    if(strSplit[i].length > longestWord){
    longestWord = strSplit[i].length;
  return longestWord;
         }
     }
}
Garo
@Garabed96
Jan 20 2017 05:03
does it>
cuz some of the compiling gives errors like My age is 0, 0 si ega ym.
which should work if it did get rid of everything
CoryCMyers
@CoryCMyers
Jan 20 2017 05:03
What does the difference in the location of the return line make?
uriznik
@uriznik
Jan 20 2017 05:04
@CoryCMyers second one returns before it's gone through all the words?
@CoryCMyers you need to check every word because the last one may be the longest
CoryCMyers
@CoryCMyers
Jan 20 2017 05:06
@uriznik Ok, I thought that might be it but I was not sure. I thought the Loop ran through everything before working ot the end, but if it is part of the function brackets, it is going to fire yes?
Ken Haduch
@khaduch
Jan 20 2017 05:06

@grantknaver - I"m trying to understand your smallestCommons code - I think that you want to sort your array first, before you make (what looks like) an array with the full range of values? Also, you are doing your push back onto arr, which is probably going to cause trouble. Well, maybe not, unless the arguments are in the reverse numeric order, then your for loop might go awry?

Anyway - my approach was the the number that you are generating multiples of would be the larger of the two values - so for the [1, 5] case, you should be generating multiples of 5? I probably should run through your code and see what you're getting, but it's late for me... maybe I'll try for 5 minutes...

CoryCMyers
@CoryCMyers
Jan 20 2017 05:06
Regardless of the if statement in front of it
@uriznik Thanks
CamperBot
@camperbot
Jan 20 2017 05:06
corycmyers sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles:
:cookie: 490 | @uriznik |http://www.freecodecamp.com/uriznik
Ken Haduch
@khaduch
Jan 20 2017 05:08
@CoryCMyers - if you return as soon as you find a word that longer than your current longest word, without looking at all the words, then it might not get the correct answer. You want to check all of the words, which looks like that would be what your first case is going to do - return the word after the loop is complete.
oops, you might have already gotten the answer, I didn't scroll back down to the bottom...
DigitalTheorist
@DigitalTheorist
Jan 20 2017 05:08
@jroper19 Hey I’m on that challenge as well. Would you like to take a shot at pair programming it?
Ken Haduch
@khaduch
Jan 20 2017 05:10
@Garabed96 - @Garabed96 - I used this: .replace(/[\W_]/ig, '') for my replace function. It means: "anything that is not a word character \W or an underscore".
eeflores
@eeflores
Jan 20 2017 05:11
@Garabed96 what's your code now?
Garo
@Garabed96
Jan 20 2017 05:13
i replaced all my lines with that one u elft
said*
function palindrome(str) {
  // Good luck!
   //str += str.toLowerCase();
   //str = str.replace(/\ /g, '');

  // takes out eveything that isnt an alpha character or numbers 
   str = str.replace(/[^0-9a-z]/gi, "");
    if(str === str.split("").reverse("").join("") ){
      return true;
    } else if(str !== str.split("").reverse("").join("") ){
      return false;
      } 
}
palindrome("eye");
it must be my if statement i guess ? only 2 conditions dont work
nvm
eeflores
@eeflores
Jan 20 2017 05:14
@Garabed96 do str = str.toLowerCase() first
Garo
@Garabed96
Jan 20 2017 05:14
got it thanks
DigitalTheorist
@DigitalTheorist
Jan 20 2017 05:14
Anyone interested in pair programming the counting cards challenge?
CoryCMyers
@CoryCMyers
Jan 20 2017 05:14
@khaduch Thank yoU!
CamperBot
@camperbot
Jan 20 2017 05:14
corycmyers sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2320 | @khaduch |http://www.freecodecamp.com/khaduch
Garo
@Garabed96
Jan 20 2017 05:14
ya i realized the cap M in one of the erros probs got deleted bc of it
@eeflores thx
CamperBot
@camperbot
Jan 20 2017 05:14
garabed96 sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:warning: garabed96 already gave eeflores points
eeflores
@eeflores
Jan 20 2017 05:15
probably need to get rid of the spaces in the string too
Garo
@Garabed96
Jan 20 2017 05:16
what space?
oh
eeflores
@eeflores
Jan 20 2017 05:17
nah it's all good
Garo
@Garabed96
Jan 20 2017 05:17
that was a pain in the ass
solved by 1 line again
lol
eeflores
@eeflores
Jan 20 2017 05:17
that regexp should get rid of spaces too
Jamil Akhtar
@frontender007
Jan 20 2017 05:27
can anybody help me with prim numbers challenge ?
John Roper
@jroper19
Jan 20 2017 05:29
@DigitalTheorist Never done that before. Still lost honestly lol
Ogundele Olumide
@Lumexralph
Jan 20 2017 05:30
@DigitalTheorist i can't but let's see if we can solve it here
@frontender007 done anything?