These are chat archives for FreeCodeCamp/HelpJavaScript

11th
Jun 2017
Daniel Narilton
@spaganger
Jun 11 2017 00:03
Hi. : https://codepen.io/Vigariuoluvi/pen/QgNyZP?editors=1010
whenever i click on 'add', the button delete shows up and then it disappears though I want it to stay.
Manish Giri
@Manish-Giri
Jun 11 2017 00:06
@Vigariuoluvi
function storeTODO(e){
  e.preventDefault();
you need to pass the function the event object e
and the first line should be the prevent default.
Daniel Narilton
@spaganger
Jun 11 2017 00:07
thank you very much
Adam Bohannon
@abohannon
Jun 11 2017 00:09
Random question: when is it necessary to include code inside $(document).ready(function(){})?
I know it's saying "when the document is ready, do this" but don't I want that to be the case for all my code?
kirontoo
@kirontoo
Jun 11 2017 00:17
@abohannon it's necessary when you want all of the html and css to load before the code executes
Adam Bohannon
@abohannon
Jun 11 2017 00:18
so for example stuff that isn't linked to user interaction can load before and not be placed inside ?
like fetching an API for instance
Sean Robertson
@seanfrobertson
Jun 11 2017 00:19
Java question. With a function, function(variable) { return result }, and then calling with function (5), does the input not automatically assign a value to the variable each time?
Manish Giri
@Manish-Giri
Jun 11 2017 00:20
to result?
Sean Robertson
@seanfrobertson
Jun 11 2017 00:21
e.g. function convertToF(celcius) {
var fahrenheit; fahrenheit=(9/5)*celcius +32;
return fahrenheit. why does calling the function by entering convertToF(30); not assign 30 to celcius?
Manish Giri
@Manish-Giri
Jun 11 2017 00:23
@seanfrobertson it does
Frank McCroy
@fmccroy
Jun 11 2017 00:23
How do you know that it is not? Are you capturing the value returned from convertToF ?
Sean Robertson
@seanfrobertson
Jun 11 2017 00:24
when I don't define celcius, the evaluation results in "celcius not defined"
Elizabeth Paul
@Kowalatam
Jun 11 2017 00:24

Hi. i need help with the mutation exercise . function mutation(arr) {
var newArr = [];
newArr.push(arr[0].toLowerCase());
newArr.push(arr[1].toLowerCase());

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

}
}

Manuel
@manny45
Jun 11 2017 00:24
How do I post a screen shot here so I can show what I need help on?
Manish Giri
@Manish-Giri
Jun 11 2017 00:25
@seanfrobertson the function was setup with celsius
did you change that to celcius?
Sean Robertson
@seanfrobertson
Jun 11 2017 00:25
Yup, i'm an idioit.
Manish Giri
@Manish-Giri
Jun 11 2017 00:25
@Kowalatam you should place the return true outside the loop.
Sean Robertson
@seanfrobertson
Jun 11 2017 00:25
thank you @Manish-Giri
CamperBot
@camperbot
Jun 11 2017 00:25
seanfrobertson sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5941 | @manish-giri |http://www.freecodecamp.com/manish-giri
Elizabeth Paul
@Kowalatam
Jun 11 2017 00:27
@Manish-Giri wow.. been at it for a while. Thank you
CamperBot
@camperbot
Jun 11 2017 00:27
kowalatam sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5942 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jun 11 2017 00:27
@Kowalatam @seanfrobertson :+1:
andrewmparker
@andrewmparker
Jun 11 2017 00:28

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

}

truncateString("A-tisket a-tasket A green and yellow basket", 11); anybody see something wrong in this????

Frank McCroy
@fmccroy
Jun 11 2017 00:32
@andrewmparker Does it pass any of the conditions, or it never works?
andrewmparker
@andrewmparker
Jun 11 2017 00:33
it passes the one above
Frank McCroy
@fmccroy
Jun 11 2017 00:34
@andrewmparker So it works for strings with numbers greater than 3, but not otherwise?
andrewmparker
@andrewmparker
Jun 11 2017 00:34
no it works for everything actually when i run it, but freecodecamp isn't seeming to like it
Frank McCroy
@fmccroy
Jun 11 2017 00:35
@andrewmparker Hmm.. maybe it expects the output in a different format? What is the challenge called?
andrewmparker
@andrewmparker
Jun 11 2017 00:36
truncate a string
Frank McCroy
@fmccroy
Jun 11 2017 00:37
My code looks similar.. but instead of ‘…; I had “…”, although I thought they are more or less interchangeable.
Possibly just refresh the browser
andrewmparker
@andrewmparker
Jun 11 2017 00:37
i will try it and let you know
both of those didn't work @fmccroy
Frank McCroy
@fmccroy
Jun 11 2017 00:40
function truncateString(str, num) {

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

truncateString("A-tisket a-tasket A green and yellow basket", 11);
I think I worked in a different order than you, but otherwise it looks similar.
andrewmparker
@andrewmparker
Jun 11 2017 00:41
that is interesting
Frank McCroy
@fmccroy
Jun 11 2017 00:49
I’m not sure what I did wrong, your code only passes two conditions here when I try to run it
andrewmparker
@andrewmparker
Jun 11 2017 00:50
just copied and pasted yours and ran it and still is not working
Frank McCroy
@fmccroy
Jun 11 2017 00:51
Strange. Copied and pasted mine back in and it passed. :( Maybe we need to reset the challenge and paste again?
andrewmparker
@andrewmparker
Jun 11 2017 00:53
just did that, it is working now. thx @fmccroy
CamperBot
@camperbot
Jun 11 2017 00:53
andrewmparker sends brownie points to @fmccroy :sparkles: :thumbsup: :sparkles:
:cookie: 334 | @fmccroy |http://www.freecodecamp.com/fmccroy
Frank McCroy
@fmccroy
Jun 11 2017 00:54
Cool! If only that was enough motivation to get me to start on “Caesars Cipher”. I keep putting it off. :)
fdemaa
@fdemaa
Jun 11 2017 00:55

why i have 3 items on console, i thought js start counting as 0 right ?

var bucketList = ["felipe ", "demaria ", "como te va a voish"];

var listItem = bucketList.length;

console.log(listItem);

Kyle Holm
@thekholm80
Jun 11 2017 00:56
length is the number of items in array
index starts at 0
two different things
Frank McCroy
@fmccroy
Jun 11 2017 00:56
@fdemaa No, arrays start at zero. Length does not, it starts at one.
fdemaa
@fdemaa
Jun 11 2017 00:56
@thekholm80 @fmccroy thanks guys
CamperBot
@camperbot
Jun 11 2017 00:56
fdemaa sends brownie points to @thekholm80 and @fmccroy :sparkles: :thumbsup: :sparkles:
:cookie: 335 | @fmccroy |http://www.freecodecamp.com/fmccroy
:star2: 1011 | @thekholm80 |http://www.freecodecamp.com/thekholm80
Brian
@BC7
Jun 11 2017 00:56
var invalid = [false,null,0,"",NaN,undefined];

function customFilter(item){
  if(invalid.indexOf(item) >= 0){
    return false;
  }else{
    return true;
  }
}

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

bouncer([7, "ate", "", false, 9]);
Does anyone know why NaN still comes back as true?
Kyle Holm
@thekholm80
Jun 11 2017 00:58
because NaN does not equal NaN
Brian
@BC7
Jun 11 2017 00:59
I feel silly haha. Thanks @thekholm80 !
Kyle Holm
@thekholm80
Jun 11 2017 00:59
:+1:
Manish Giri
@Manish-Giri
Jun 11 2017 00:59
@thekholm80 If I have this
<a className="waves-effect waves-light btn green darken-4"><i className="material-icons left">play_arrow</i>Play</a>
can I do
  <a className="waves-effect waves-light btn green darken-4"><i className="material-icons left">play_arrow</i>{isPlaying ? Pause : Play}</a>
Kyle Holm
@thekholm80
Jun 11 2017 01:01
where is isPlaying coming from?
is it a variable inside the render method?
Manish Giri
@Manish-Giri
Jun 11 2017 01:01
or should it be
{isPlaying} Pause : Play
yeah
 render() {
        let isPlaying = this.props.inPlay;
Kyle Holm
@thekholm80
Jun 11 2017 01:02
if Pause and Play are strings you want to have as text you need to quote them
but you can use string literals with the variable inside the same set of braces
Manish Giri
@Manish-Giri
Jun 11 2017 01:03
so like {isPlaying ? "Pause" : "Play"}
Kyle Holm
@thekholm80
Jun 11 2017 01:03
yeah
Manish Giri
@Manish-Giri
Jun 11 2017 01:03
okay lemm try it out
Kyle Holm
@thekholm80
Jun 11 2017 01:03
that will change the rendered text based on the variable
Curtis Turner
@curtis-turner
Jun 11 2017 01:08
Hey can anyone tell me whats going on in the Palindrome checking Javascript challenge?
CallMeOrange
@EgnaroDev
Jun 11 2017 01:10
@curtis-turner Its like an algorithm to make the word in parameter reversed
Hello --> olleH
Curtis Turner
@curtis-turner
Jun 11 2017 01:11
yes i got that i think there is a bug eyeforofeye is a palindrome and my code returns true for this but in the challenge it says it should return false
Lance Ward
@Lanceward410
Jun 11 2017 01:12
@JamesCzekaj Imagine a video game. Every single thing in the game that you can see or moves... is an object
André
@andregomesp
Jun 11 2017 01:12

Challenge Make Object Properties Private

How do i make getGear call setGear?

var Bike = function() {

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



this.setGear = function(number) {
  var setGear = number;
  return setGear;
};

  this.getGear = function() {
  gear = Bike.setGear();
    return gear;
};
};
Curtis Turner
@curtis-turner
Jun 11 2017 01:14
@andregomesp i think it just Bike.getGear(value); if i remember correct
Abhilash Kumar
@apravink
Jun 11 2017 01:21
Anyone got any suggestions for weather icons?
Preferebly one that is hosted somewhere
teevik
@teevik
Jun 11 2017 01:26
If you want animated ones, https://darkskyapp.github.io/skycons/
Kyle Holm
@thekholm80
Jun 11 2017 01:26
those look awesome
Abhilash Kumar
@apravink
Jun 11 2017 01:27
@teevik Exactly what I was looking for. Thanks :)
CamperBot
@camperbot
Jun 11 2017 01:27
apravink sends brownie points to @teevik :sparkles: :thumbsup: :sparkles:
:cookie: 101 | @teevik |http://www.freecodecamp.com/teevik
Kyle Holm
@thekholm80
Jun 11 2017 01:27
teevik
@teevik
Jun 11 2017 01:27
They work directly with darksky api, if you are using that
Oh, those are fancy
Kyle Holm
@thekholm80
Jun 11 2017 01:29
forked it the other day when @coymeetsworld shared them, haven't really looked at how they work yet
teevik
@teevik
Jun 11 2017 01:29
Is that just css animations?
Kyle Holm
@thekholm80
Jun 11 2017 01:30
one sec, i'll look at the code
yeah, just css animations
teevik
@teevik
Jun 11 2017 01:31
Thats impressive
Kyle Holm
@thekholm80
Jun 11 2017 01:32
really makes me want to learn some more css
CreateTheHype
@CreateTheHype
Jun 11 2017 01:32
any one know why its returning yes even though i have my conditions set to false?
function trueOrFalse(wasThatTrue) {

  // Only change code below this line.

 if (true) {
   return "Yes, that was true";
 }
  return "No, that was false";
}

// Change this value to test
trueOrFalse(false);
Abhilash Kumar
@apravink
Jun 11 2017 01:32
Wow yeah very impressive
@CreateTheHype Add an "else" clause before the second return
Manish Giri
@Manish-Giri
Jun 11 2017 01:34
@CreateTheHype you've got to use wasThatTrue
otherwise it'll always use if(true)
Kyle Holm
@thekholm80
Jun 11 2017 01:36
@Manish-Giri have you seen Lucy (movie)?
Manish Giri
@Manish-Giri
Jun 11 2017 01:36
@thekholm80 I have and let me show you a stat
asked by, yours truly
CreateTheHype
@CreateTheHype
Jun 11 2017 01:37
thanks guys @Manish-Giri @apravink
CamperBot
@camperbot
Jun 11 2017 01:37
createthehype sends brownie points to @manish-giri and @apravink :sparkles: :thumbsup: :sparkles:
:cookie: 116 | @apravink |http://www.freecodecamp.com/apravink
:star2: 5943 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jun 11 2017 01:37

look at that

viewed
172,630 times

@thekholm80
Kyle Holm
@thekholm80
Jun 11 2017 01:37
I saved the link but I don't want spoilers I'm only 42 min in
Manish Giri
@Manish-Giri
Jun 11 2017 01:38
lol
it's very good
tho I still didn't understand the ending
hope you can explain it to me when you're done
Kyle Holm
@thekholm80
Jun 11 2017 01:38
it's 42
i'm sure of it
Manish Giri
@Manish-Giri
Jun 11 2017 01:38
lol
Mubarak Lawal
@Supremehasbrown
Jun 11 2017 01:40
Hey guys, im doing the mutation algorithm challenge

function mutation(arr) {
if (arr[0] == arr[1]){
return arr.indexOf(,0);
} else {
return false;
}
}

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

but im having problems with my if statement
im not sure what to put as the "search value "for my indexOf function
Manish Giri
@Manish-Giri
Jun 11 2017 01:45
@thekholm80 this is what happens when you do too much GOL
 this.play = this.tick.play(this);
        this.pause = this.tick.pause(this);
Kyle Holm
@thekholm80
Jun 11 2017 01:47
lol
Abhilash Kumar
@apravink
Jun 11 2017 01:49
Does anyone know how to add local resources(.js files) to codepen?
Greg Duncan
@GregatGit
Jun 11 2017 01:49
@apravink in setting under JS
@apravink you can also add css scripts as well
Abhilash Kumar
@apravink
Jun 11 2017 01:50
@GregatGit I see the option to add URL's but can I add files that are local on my computer?
Greg Duncan
@GregatGit
Jun 11 2017 01:51
@apravink so you have written some js that you want to add?
Abhilash Kumar
@apravink
Jun 11 2017 01:51
@GregatGit I thought those only take CDN's
@GregatGit Naa its the skycons library from github https://github.com/darkskyapp/skycons
They dont seem to have a CDN that works
Duffy125
@Duffy125
Jun 11 2017 01:56

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

what am I missing
Greg Duncan
@GregatGit
Jun 11 2017 01:57
@apravink try searching codepen for projects that use skycons and if you can find them there try looking at some webpages and see how they used them
Frank McCroy
@fmccroy
Jun 11 2017 01:57
@duffy You are using myOutfit as a function name, and a variable name ??
LordWheelbarrow
@LordWheelbarrow
Jun 11 2017 01:58

// Setup
function phoneticLookup(val) {
var result = "";
My first shout for 'Help'!
// Only change code below this line
var lookup = {
alpha:"Adams",
bravo:"Boston",
charlie:"Chicago",
delta:"Denver",
echo:"Easy",
foxtrot:"Frank"
};

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

Frank McCroy
@fmccroy
Jun 11 2017 01:59
Were you supposed to change the variable outerWear in the function?
Duffy125
@Duffy125
Jun 11 2017 02:00
@fmccroy Thanks I get it know
Greg Duncan
@GregatGit
Jun 11 2017 02:00
@apravink <script src="https://rawgithub.com/darkskyapp/skycons/master/skycons.js"></script>
Johnny O'Sullivan
@johnnyosullivan
Jun 11 2017 02:00
Hey Folks. I solved the Profile Lookup challenge, but just wondering if it could be done differently.
function lookUpProfile(firstName, prop){
// Only change code below this line
  for(var i = 0; i < contacts.length; i++){
    if(contacts[i].firstName === firstName){
      if(contacts[i].hasOwnProperty(prop) === true){
      return contacts[i][prop];
    } else{
    return "No such property";
      }
    }
  }
  return "No such contact";

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
LordWheelbarrow
@LordWheelbarrow
Jun 11 2017 02:01

Oh bother - sorry newbie making mistakes. My first shout for help. How do I look up the value and return the string as 'result'. I managed to make the lookup table, but unsure how to lookup from the table. Thanks: // Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
var lookup = {
alpha:"Adams",
bravo:"Boston",
charlie:"Chicago",
delta:"Denver",
echo:"Easy",
foxtrot:"Frank"
};

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

saven1986
@saven1986
Jun 11 2017 02:02
Why is it that var is used instead of using variable? Will using Variable not be allowed to run?
Johnny O'Sullivan
@johnnyosullivan
Jun 11 2017 02:03
What number is that challenge again @LordWheelbarrow
That's just the syntax @saven1986 as far as I know.
saven1986
@saven1986
Jun 11 2017 02:04
Thanks.
LordWheelbarrow
@LordWheelbarrow
Jun 11 2017 02:05
@johnnyosullivan its "using objects for lookups" - Thanks :)
CamperBot
@camperbot
Jun 11 2017 02:05
lordwheelbarrow sends brownie points to @johnnyosullivan :sparkles: :thumbsup: :sparkles:
:cookie: 227 | @johnnyosullivan |http://www.freecodecamp.com/johnnyosullivan
Johnny O'Sullivan
@johnnyosullivan
Jun 11 2017 02:05
Saving keystrokes is the only explanation I can think of @saven1986
Ok. Let me have a look. I'll try to guide you to the answer without telling you. Took me a while to solve it as well @lordwheelbarrow
Curtis Turner
@curtis-turner
Jun 11 2017 02:06
@johnnyosullivan hey man how ya doing
Johnny O'Sullivan
@johnnyosullivan
Jun 11 2017 02:06
Hey @curtis-turner ! How are you doing? Make anymore progress today?
LordWheelbarrow
@LordWheelbarrow
Jun 11 2017 02:07
@johnnyosullivan I've been trying along the lines of lookup[val] = result;
Abhilash Kumar
@apravink
Jun 11 2017 02:07
@GregatGit Yeah I saw the same thing. rawgit seems like a great resource !. Thanks
CamperBot
@camperbot
Jun 11 2017 02:07
apravink sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 860 | @gregatgit |http://www.freecodecamp.com/gregatgit
Johnny O'Sullivan
@johnnyosullivan
Jun 11 2017 02:08
You're on the right track @LordWheelbarrow
Frank McCroy
@fmccroy
Jun 11 2017 02:08
@LordWheelbarrow Hopefully you meant result = lookup[val] ?
Johnny O'Sullivan
@johnnyosullivan
Jun 11 2017 02:08
You have the right things in the wrong order.
Curtis Turner
@curtis-turner
Jun 11 2017 02:08
@johnnyosullivan yeah im in the algorithms section now working on the Title Case problem
Greg Duncan
@GregatGit
Jun 11 2017 02:08
@johnnyosullivan
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i in contacts){
    if (contacts[i].firstName === firstName){
        return contacts[i][prop] || "No such property";    
    }
  }
  return "No such contact";
// Only change code above this line
}
Curtis Turner
@curtis-turner
Jun 11 2017 02:08
@johnnyosullivan how are things coming on your end
Johnny O'Sullivan
@johnnyosullivan
Jun 11 2017 02:09
@curtis-turner Took it easy today. Just starting Object Oriented programming.
LordWheelbarrow
@LordWheelbarrow
Jun 11 2017 02:10
Aha - Thanks @fmccroy and @johnnyosullivan - always remember the right get assigned to the left - a mistake I make all the time. Ok I'll try again
CamperBot
@camperbot
Jun 11 2017 02:10
lordwheelbarrow sends brownie points to @fmccroy and @johnnyosullivan :sparkles: :thumbsup: :sparkles:
:warning: lordwheelbarrow already gave johnnyosullivan points
:cookie: 336 | @fmccroy |http://www.freecodecamp.com/fmccroy
Lance Ward
@Lanceward410
Jun 11 2017 02:11
```
testing
Johnny O'Sullivan
@johnnyosullivan
Jun 11 2017 02:11
@GregatGit you're dropping some serious knowledge on me there. I don't think I've seen that syntax yet...in FCC or in any of the other tutorials I've taken.
Lance Ward
@Lanceward410
Jun 11 2017 02:12
var thisWorks = true;
Greg Duncan
@GregatGit
Jun 11 2017 02:12
@johnnyosullivan var i in contacts is just another way of writing a for loop
CoderH007
@CoderH007
Jun 11 2017 02:12
Hello there,, I am hoping someone can help me understand what I need to do with this challenge
https://www.freecodecamp.com/challenges/word-blanks
Johnny O'Sullivan
@johnnyosullivan
Jun 11 2017 02:13
I figured @GregatGit. Just never seen it before ...and I've never seen using an OR statement like that before, but it makes sense.
Frank McCroy
@fmccroy
Jun 11 2017 02:13
@CoderH007 You need to create a new string called result, that adds word between your variables, ie “hello”
  • mynoun + “ this is a “ + etc etc
Lance Ward
@Lanceward410
Jun 11 2017 02:14
Yeah that is WAY more simplified than mine when I did that challenge

``` function lookUpProfile(firstName, prop) {
// Only change code below this line

for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop) === true) {

  return contacts[i][prop];

} else if (contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop) === false) {

  return "No such property";
                                                                                             } else { }    

}
return "No such contact";
} ```

Greg Duncan
@GregatGit
Jun 11 2017 02:15

@johnnyosullivan

return contacts[i][prop] || "No such property";

if there is no contacts[i][prop] the || will return "No such property"

CoderH007
@CoderH007
Jun 11 2017 02:15
@fmccroy thank you.. I'll give it a try
CamperBot
@camperbot
Jun 11 2017 02:15
coderh007 sends brownie points to @fmccroy :sparkles: :thumbsup: :sparkles:
:cookie: 337 | @fmccroy |http://www.freecodecamp.com/fmccroy
Frank McCroy
@fmccroy
Jun 11 2017 02:16
@CoderH007 It’s just a giant string concatenation, adding stuff in “ “ to variables
Greg Duncan
@GregatGit
Jun 11 2017 02:17
@johnnyosullivan try making up a funciton the uses the ||
Johnny O'Sullivan
@johnnyosullivan
Jun 11 2017 02:17
@GregatGit so does that syntax tell JS to look for the first the first thing first and what comes after || after?
Lance Ward
@Lanceward410
Jun 11 2017 02:17
Yes
Greg Duncan
@GregatGit
Jun 11 2017 02:17
@johnnyosullivan yes
@johnnyosullivan best to write your own very simple function - then test it to see if it return what you expect
Johnny O'Sullivan
@johnnyosullivan
Jun 11 2017 02:18
Cheers for that lads. I've seen || used before, I just haven't seen the logic applied in this way before.
And definitely not in the middle of a for loop.
Harry Fahringer III
@harryrf
Jun 11 2017 02:21
How do I break my js into separate files and still be able to call it all from one place?
Manish Giri
@Manish-Giri
Jun 11 2017 02:21
@harryrf use export along with require/import.
Harry Fahringer III
@harryrf
Jun 11 2017 02:22
okay, I'll look into that. Thank you.
this still seems to be a pretty young concept according to MDN
I don't absolutely have to do it, I'm just being finicky
Greg Duncan
@GregatGit
Jun 11 2017 02:30
@harryrf it is the way to go
Johnny O'Sullivan
@johnnyosullivan
Jun 11 2017 02:31
silly question. how do you award those brownie points when somebody helps you?
Jorge Vargas
@jvsole17
Jun 11 2017 02:32
yo
can u guys help me whats wrong with my string
var myStr;"FirstLine\n\SecondLine\\rThirdLine";
Johnny O'Sullivan
@johnnyosullivan
Jun 11 2017 02:34
should you be using an = after myStr instead of ;
var myStr = "...."
Kyle Holm
@thekholm80
Jun 11 2017 02:34
@johnnyosullivan click a name and type thanks
CamperBot
@camperbot
Jun 11 2017 02:34
thekholm80 sends brownie points to @johnnyosullivan :sparkles: :thumbsup: :sparkles:
:cookie: 228 | @johnnyosullivan |http://www.freecodecamp.com/johnnyosullivan
Johnny O'Sullivan
@johnnyosullivan
Jun 11 2017 02:34
@thekholm80 thanks
CamperBot
@camperbot
Jun 11 2017 02:34
johnnyosullivan sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1012 | @thekholm80 |http://www.freecodecamp.com/thekholm80
Jorge Vargas
@jvsole17
Jun 11 2017 02:34
ok thanks
Kyle Holm
@thekholm80
Jun 11 2017 02:34
:+1:
Johnny O'Sullivan
@johnnyosullivan
Jun 11 2017 02:34
@GregatGit thanks
CamperBot
@camperbot
Jun 11 2017 02:34
johnnyosullivan sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 861 | @gregatgit |http://www.freecodecamp.com/gregatgit
Jorge Vargas
@jvsole17
Jun 11 2017 02:34
@thekholm80 thanks
CamperBot
@camperbot
Jun 11 2017 02:34
jvsole17 sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1013 | @thekholm80 |http://www.freecodecamp.com/thekholm80
Johnny O'Sullivan
@johnnyosullivan
Jun 11 2017 02:35
@jvsole17 did that work for you?
Adam Faraj
@adamfaraj
Jun 11 2017 02:40
does the filter method always take a function as an argument?
FlashHero
@FlashHero
Jun 11 2017 02:42
@adamfaraj yes, you'll have to pass a function as an argument if you want to filter something out of an array
Adam Faraj
@adamfaraj
Jun 11 2017 02:42
ok @FlashHero check this out
i'm doing the falsy bouncer problem
i came up with this code
//jshint esversion:6

var falsy = [false, null, 0, "", undefined, NaN];
function bouncer(arr) {
   arr = arr.filter(item => !falsy.includes(item));
   return arr;

}

bouncer([7, "ate", "", false, 9]);
everything worked out excellent
i checked what other answers there were and this was an answer
return arr.filter(Boolean);
Boolean is not a function...
so does filter just take any argument?
since Boolean holds all the falsy values
it just works
hmm
console.log(Boolean);
VM214:1 function Boolean() { [native code] }
neat
i guess Boolean is a built in function
FlashHero
@FlashHero
Jun 11 2017 02:49
@adamfaraj yes if you do typeof Boolean it gives you function
jorgeguz15
@jorgeguz15
Jun 11 2017 02:53
finally did the longestword
Sarah
@aggibabi
Jun 11 2017 02:53
heyo
I'm stuck on chunky monkey
jorgeguz15
@jorgeguz15
Jun 11 2017 02:57
not there yet..
intervolver
@intervolver
Jun 11 2017 02:58
Hey, I'm trying to remove spaces and special characters from a string, but I'm having some trouble with .replace() - can someone give me a hint where I'm going wrong?
str.toLowerCase().replace(/[^a-b0-9]/g, '');
Sarah
@aggibabi
Jun 11 2017 02:59
@intervolver I believe you have to escape each one first
@intervolver str.replace(/\/|_|-|:|||(|)|\s|,|./g, "")
should look something like that
intervolver
@intervolver
Jun 11 2017 03:01
I'm trying to use a regexp to exclude everything but a-z and 0-9 so that I don't have to specify every character individually
FlashHero
@FlashHero
Jun 11 2017 03:02
@intervolver i think this should work str.toLowerCase().replace(/[^a-z0-9]/g, '');
you have a-b instead of a-z
Johnny
@jtan3
Jun 11 2017 03:02
@intervolver http://regexr.com/ there's also a video tutorial
intervolver
@intervolver
Jun 11 2017 03:02
@FlashHero >_< d'oh
that was exactly it
@FlashHero thanks
CamperBot
@camperbot
Jun 11 2017 03:03
intervolver sends brownie points to @flashhero :sparkles: :thumbsup: :sparkles:
:cookie: 194 | @flashhero |http://www.freecodecamp.com/flashhero
intervolver
@intervolver
Jun 11 2017 03:03
I can't believe I missed that
FlashHero
@FlashHero
Jun 11 2017 03:04
sometimes little mistakes takes forever to notice it
intervolver
@intervolver
Jun 11 2017 03:05
no kidding, that's been driving me nuts for a half hour now. Maybe coffee is needed
Frank McCroy
@fmccroy
Jun 11 2017 03:05
@intervolver I’ve got Starbucks, need some? :)
intervolver
@intervolver
Jun 11 2017 03:08
thanks, beats the instant around here :p
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:09
Hey,can anybody help me with the counting card test, i 've been trying to solve this test for about an hour but i still have no idea what i'm suppose to do
Frank McCroy
@fmccroy
Jun 11 2017 03:10
@idonthavefriend Do you have any code yet, or you haven’t gotten that far?
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:11

var count = 0;

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

}
if(count>=1){
return count+" Bet";
}else if(count<1){
return count+" Hold";
}
return count;

heres my code so far
Lance Ward
@Lanceward410
Jun 11 2017 03:11
Count=0 sets count to 0, no matter what it is prior to that @idonthavefriend
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:12
okay...
still no idea what i'm suppose to do
Lance Ward
@Lanceward410
Jun 11 2017 03:12
If you draw a 7,8,9, the count doesn't go up or down. It also doesn't reset to 0.
Frank McCroy
@fmccroy
Jun 11 2017 03:12
@idonthavefriend You are supposed to not change the count, not set it to 0 altogether, for those cards.
Lance Ward
@Lanceward410
Jun 11 2017 03:13
So just let it do nothing for those cases
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:13
uhhh
Frank McCroy
@fmccroy
Jun 11 2017 03:14
So for cards 2 through 6, something like count++, for 10 through “a” count--
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:15
so for case 2-6 i change the count to ++?
Lance Ward
@Lanceward410
Jun 11 2017 03:15
or +=1
Either one does the job
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:16
but its suppose to be"5 Bet"
Frank McCroy
@fmccroy
Jun 11 2017 03:16
@idonthavefriend You are increasing and decreasing the count, based on the values
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:17
so since there are 5 cases each cases increase the value to 1?
Frank McCroy
@fmccroy
Jun 11 2017 03:17
That is only one test case: "The function will then 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."
So… bet if positive, hold if zero or negative.
LordWheelbarrow
@LordWheelbarrow
Jun 11 2017 03:17
@idonthavefriend I've been struggling with this one for ages too
Lance Ward
@Lanceward410
Jun 11 2017 03:17
Read again
The hypothetical card sequence "2, 3, 4, 5, 6" would return 5 bet
So if count did this: +1+1+1+1+1
Then you'd have 5 bet
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:19
case 2:
case 3:
case 4:
case 5:
case 6:
count+=1;
Lance Ward
@Lanceward410
Jun 11 2017 03:19
Si
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:19
is this correct?
okay
but it still returning 1 bet for some reason
Lance Ward
@Lanceward410
Jun 11 2017 03:20
I used a simple if/else statement
Instead of switch
But there's multiple ways of doing it
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:21
i got a question:is count suppose to be count=card?
LordWheelbarrow
@LordWheelbarrow
Jun 11 2017 03:21
Can you help me with my code too. I uused an if/else statement, it's outputting the correct count, but not giving hold/bet for + or - numbers:
}
if (count <= 0) {
return count + " Hold";
}
if (count > 0) {
return count + " Bet";
}
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:22
put space m9
" Hold"
oh you already did
sorry
Lance Ward
@Lanceward410
Jun 11 2017 03:22
The count is to be the result of the card sequence. Not the same value of the card
@idonthavefriend Are you asking what you should set your count to?
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:23
so val count=""?
ja
Lance Ward
@Lanceward410
Jun 11 2017 03:24
If no cards have been played yet,
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:24
@LordWheelbarrow it suppose to becount<=1
Lance Ward
@Lanceward410
Jun 11 2017 03:24
What would the count start as
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:24
@Lanceward410 yeah thats wat i'm asking
@LordWheelbarrow *>=
Lance Ward
@Lanceward410
Jun 11 2017 03:25
Read the Hint
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:26
so its not 0 i'm guessing
Lance Ward
@Lanceward410
Jun 11 2017 03:26
It says do not "reset" count to 0
key word reset
to set again
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:27
okay so for case 7-9 i'm not suppose to put 0?
Lance Ward
@Lanceward410
Jun 11 2017 03:27
for 7-9, thhe count doesn't change
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:28
so its still count+=1
Lance Ward
@Lanceward410
Jun 11 2017 03:28
count+=1 adds 1 to the count variable. That is changing the count.
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:29
so count=""?
Lance Ward
@Lanceward410
Jun 11 2017 03:29
If you type nothing at all
Then nothing at all will happen
And the code will move forward
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:30
but you said do not change anything
Lance Ward
@Lanceward410
Jun 11 2017 03:30
I said don't change the count.
I don't know what you are looking at, so I don't know what needs changing or not
Frank McCroy
@fmccroy
Jun 11 2017 03:32
@idonthavefriend He said to not change the Count for those cards
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:33
okay i'm going reset everything,to the beginning ,

switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count+=1;

}

is this correct?
Frank McCroy
@fmccroy
Jun 11 2017 03:34
So far, yes
umm, add the break; under it
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:35
okay
umm
now what
Lance Ward
@Lanceward410
Jun 11 2017 03:35
Now read the directions one more time
Thoroughly
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:36
0hh so am i not suppose to put case 7-9 is that what you mean?
Lance Ward
@Lanceward410
Jun 11 2017 03:36
There are multiple ways to do it. I did not include case 7-9 in mine
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:37
i see
Lance Ward
@Lanceward410
Jun 11 2017 03:37
BECAUSE this implies that if 7, 8, or 9 are assigned to the "card" value and ran through your Switch,
Nothing would happen
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:37
everything is clear now
Lance Ward
@Lanceward410
Jun 11 2017 03:37
rejoice!
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:38
and for the 10, J, Q, K, A i;m suppose to put -=1 right?
Lance Ward
@Lanceward410
Jun 11 2017 03:38
Directions!
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:38
i hope that's a yes
Lance Ward
@Lanceward410
Jun 11 2017 03:39
I just don't want to give it away, I'd like to just rephrase the directions so they're more understandable for you and what you seem to already know
LordWheelbarrow
@LordWheelbarrow
Jun 11 2017 03:39
Any reasons why my code only prints out the count (which is correct) but no Bet - Hold prompt: }
if (count <= 0) {
return count + " Hold";
}
else if (count > 0) {
return count + " Bet";
}
Lance Ward
@Lanceward410
Jun 11 2017 03:40
Well first of all, you can erase the "if(count > 0)" part
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:40
@LordWheelbarrow its >=1 not <=0
Frank McCroy
@fmccroy
Jun 11 2017 03:40
@LordWheelbarrow That part of the code might be okay, but where are you putting it in the program?
Lance Ward
@Lanceward410
Jun 11 2017 03:41
Leaving if(count <=0) { ...
} else {
return count + " Bet";
}
LordWheelbarrow
@LordWheelbarrow
Jun 11 2017 03:41

var count = 0;

function cc(card) {
// Only change code below this line
switch (card) {
case (card = 2):
case (card = 3):
case (card = 4):
case (card = 5):
case (card = 6):
return (count += 1);

case (card = 10):
case (card = "J"):
case (card = "Q"):
case (card = "K"):
case (card = "A"):

return (count -= 1);

}
if (count <= 1) {
return count + " Hold";
}
else if (count > 0) {
return count + " Bet";
}

// Only change code above this line
}

Lance Ward
@Lanceward410
Jun 11 2017 03:41
You don't want to return count +=1
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:42
@LordWheelbarrow you know you can just put case 2-6 right?
Frank McCroy
@fmccroy
Jun 11 2017 03:42
Returning in the case statement is making it skip the rest of the program
Lance Ward
@Lanceward410
Jun 11 2017 03:42
@LordWheelbarrow You should perhaps gtake a look at the last exercise where you completed a Switch statement to see what they look like again
@LordWheelbarrow There are multiple errors in the syntax (aka "code grammer") that need to be cleared up and it would be faster for you to take a step backwards
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:45
@Lanceward410 oh my god
Lance Ward
@Lanceward410
Jun 11 2017 03:45
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:45
lance..
thank you so muc for helping me
LordWheelbarrow
@LordWheelbarrow
Jun 11 2017 03:46
Thanks guys - 'll go and take a look. @idonthavefriend : I so I can shorten my code to case (card = 2-6): // ??
CamperBot
@camperbot
Jun 11 2017 03:46
lordwheelbarrow sends brownie points to @idonthavefriend :sparkles: :thumbsup: :sparkles:
:cookie: 198 | @idonthavefriend |http://www.freecodecamp.com/idonthavefriend
LordWheelbarrow
@LordWheelbarrow
Jun 11 2017 03:46
thanks lance
justarandominternetuser
@idonthavefriend
Jun 11 2017 03:47
case 2:
case 3:
case 4:
case 5:
case 6:
something like that
@LordWheelbarrow
Lance Ward
@Lanceward410
Jun 11 2017 03:52
I use W3schools a lot, I know freecodecamp alone won't be enough. It teaches just about everything, but unless I read extra about some things, I won't retain 100% of it. W3schools has "Try it yourself" buttons for every concept so it's extra practice.
Frank McCroy
@fmccroy
Jun 11 2017 03:57
@Lanceward410 I hope there is a nice JSON section at W3Schools, because these challenges look like a whole bunch of blind cutting and pasting without a real explanation.
Khoa Le
@Zacele
Jun 11 2017 04:18
hey guys
having trouble solving this
the Problem is that: write a function that is remove an non-numeric element out of an array
here is my function
function myFunction(arr){
    arr.forEach(function(x){
    if (typeof x !=='number'){
        arr.splice(arr.indexOf(x),1);
    }    
    });
}
my test array is
police = [1,true,'bla',3,'blo',
          'cocloc',123.33];
and my result is :
```
[1, "bla", 3, "cocloc", 123.33]
why is not remove all of those other non-numeric elements ???
cacho32
@cacho32
Jun 11 2017 04:21
Hello,

How do I get the method to return all of the converted values from Fahrenheit to Celcius instead of just one to validate the convert Celcius to Fahreinheit exercice:function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit=(9/5)*celcius+32;

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

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

Mukul Agrawal
@mukul09
Jun 11 2017 04:23
@cacho32 spelling of celsius
Khoa Le
@Zacele
Jun 11 2017 04:23
could anyone help me with the problem
cacho32
@cacho32
Jun 11 2017 04:23
you mean cutting it out in the last statement?
@mukul09
Khoa Le
@Zacele
Jun 11 2017 04:24
function myFunction(arr){
    arr.forEach(function(x){
    if (typeof x !=='number'){
        arr.splice(arr.indexOf(x),1);
    }    
    });
}


police = [1,true,'bla',3,'blo',
          'cocloc',123.33];
the result is
[1, "bla", 3, "cocloc", 123.33]
Frank McCroy
@fmccroy
Jun 11 2017 04:24
@cacho32 You don’t need to worry about all of the test values, free code camp will run the function over and over for you, with the values. @mukul09 is saying that you spelled “celsius” wrong
Mukul Agrawal
@mukul09
Jun 11 2017 04:24
@cacho32 the spelling of celsius, you have written celcius 2 times in the function
cacho32
@cacho32
Jun 11 2017 04:26
Didn't see that one. Thank you both @fmccroy and @mukul09
CamperBot
@camperbot
Jun 11 2017 04:26
cacho32 sends brownie points to @fmccroy and @mukul09 :sparkles: :thumbsup: :sparkles:
:cookie: 413 | @mukul09 |http://www.freecodecamp.com/mukul09
:cookie: 346 | @fmccroy |http://www.freecodecamp.com/fmccroy
Khoa Le
@Zacele
Jun 11 2017 04:27
@fmccroy @mukul09 could you guys help me with the problem
Frank McCroy
@fmccroy
Jun 11 2017 04:28
@Zacele I’m not sure whats wrong with it, but I would add a bunch of console.log statements to follow each step to see where the problem is.
Khoa Le
@Zacele
Jun 11 2017 04:31
coco = [1,5,'a','b'];
(4) [1, 5, "a", "b"]
myFunction(coco);
 a
undefined
@fmccroy the b they get undefined
Samuel Way
@SWbottier
Jun 11 2017 04:33
Hi All,
How can I split
"im a little tea pot" into
[ [I'm],[a],[little],[tea],[pot] ] ?
thank you.
Joseph
@revisualize
Jun 11 2017 04:34
@SWbottier You can't.
Samuel Way
@SWbottier
Jun 11 2017 04:35
for real? i thought anything is possible
Manish Giri
@Manish-Giri
Jun 11 2017 04:35
@SWbottier split the sentence into an array of words, push each word into an array..
push each array into outer array.
Joseph
@revisualize
Jun 11 2017 04:35
@SWbottier "im a little tea pot".split(' ') makes
Frank McCroy
@fmccroy
Jun 11 2017 04:35
@Zacele What is the name of the challenge you are doing?
Joseph
@revisualize
Jun 11 2017 04:36
@SWbottier => [ 'im', 'a', 'little', 'tea', 'pot' ]
Khoa Le
@Zacele
Jun 11 2017 04:36
is not in the challenge list @fmccroy
just something that bothers me for couple days now@fmccroy
Joseph
@revisualize
Jun 11 2017 04:36
@SWbottier Also, each of those aren't variables.
Kaushik Asp
@Kacppian
Jun 11 2017 04:36
var outerArray = []
"I'm a little tea pot".split(" ").map((word)=>{ outerArray.push(word) });
Joseph
@revisualize
Jun 11 2017 04:36
@Kacppian But, that still doesn't make what they said.
@Kacppian Their string didn't have an "I'm"
it had im
Kaushik Asp
@Kacppian
Jun 11 2017 04:37
even then that should work
wait lemme spin up a jsbin
Manish Giri
@Manish-Giri
Jun 11 2017 04:37
@Kacppian missing the inner arrays..
Kaushik Asp
@Kacppian
Jun 11 2017 04:37
hmm
yeah
Joseph
@revisualize
Jun 11 2017 04:37
@Kacppian But, how do you know to convert "im" to "I'm" ?
Kaushik Asp
@Kacppian
Jun 11 2017 04:38
there's no need to worry about that
simply put im in place of I'm
but that code is wrong
gimme a sec
Manish Giri
@Manish-Giri
Jun 11 2017 04:38
"I'm a little tea pot".split(" ").map((word)=>{ outerArray.push([word])});
Joseph
@revisualize
Jun 11 2017 04:38
But, then how do you convert the values to variables?
Manish Giri
@Manish-Giri
Jun 11 2017 04:39
[["I'm"], ["a"], ["little"], ["tea"], ["pot"]]
Samuel Way
@SWbottier
Jun 11 2017 04:39
well the practice was to turn 1st letter of each word to upper case, so I just thought making every word into an array and .upperCase() every [0] first letter of each array .. ..
Manish Giri
@Manish-Giri
Jun 11 2017 04:39
yeah that code won't cut it..
no need for nested arrays..
Kaushik Asp
@Kacppian
Jun 11 2017 04:40
yeah
Frank McCroy
@fmccroy
Jun 11 2017 04:40
@Zacele Where is “x” coming from? Is it provided by the Foreach ? I would possibly output that, then output the result of the typeOf, and output the array before and after the splice, as well as the final array. Something is not giving the expected value, which is throwing your code off.
Joseph
@revisualize
Jun 11 2017 04:40
@Manish-Giri Those are all strings.
Manish Giri
@Manish-Giri
Jun 11 2017 04:40
@revisualize yup, I'm pretty sure he meant strings as well.
Joseph
@revisualize
Jun 11 2017 04:40

"im a little tea pot" into
[ [I'm],[a],[little],[tea],[pot] ]

Those aren't strings. Those are variables.

Samuel Way
@SWbottier
Jun 11 2017 04:41
yea strings
Manish Giri
@Manish-Giri
Jun 11 2017 04:41
^
Kaushik Asp
@Kacppian
Jun 11 2017 04:41
what?
Joseph
@revisualize
Jun 11 2017 04:41
OH! Well. then. You can.
"I'm a little tea pot".split(" ").map((word)=> [word]);
I said you can't because I thought you wanted to make each value a variable.
@SWbottier I don't understand why you're making
=> [ [ 'I\'m' ], [ 'a' ], [ 'little' ], [ 'tea' ], [ 'pot' ] ]
Seems like a useless construction for a nested array with a single variable.
Samuel Way
@SWbottier
Jun 11 2017 04:43
i mean the string (str) is ("I'm a little tea pot") and after using str.split(' ')
i got ["I'm" , "a" , "little" , "tea" , "pot" ] ....so they are strings right?
and now Im trying to further put each strings into array like
[ [I'm] , [a] , [little] , [tea], [pot] ]
Manish Giri
@Manish-Giri
Jun 11 2017 04:44
each strings into array like
you don't need this
Samuel Way
@SWbottier
Jun 11 2017 04:44
yup yup
okay
so...i should try something else
Kaushik Asp
@Kacppian
Jun 11 2017 04:44
it'll be very inefficient to do that
yeah
Joseph
@revisualize
Jun 11 2017 04:44
"I'm a little tea pot".split(" ").map((word)=> word.split(''));
Samuel Way
@SWbottier
Jun 11 2017 04:45
Okay thank you @revisualize and @Kacppian @Manish-Giri
I'll look into that. Cheers
CamperBot
@camperbot
Jun 11 2017 04:45
swbottier sends brownie points to @revisualize and @kacppian and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 64 | @kacppian |http://www.freecodecamp.com/kacppian
Kaushik Asp
@Kacppian
Jun 11 2017 04:45
what? why do you need that?
CamperBot
@camperbot
Jun 11 2017 04:45
:star2: 5945 | @manish-giri |http://www.freecodecamp.com/manish-giri
:star2: 4143 | @revisualize |http://www.freecodecamp.com/revisualize
meslance
@meslance
Jun 11 2017 04:46
Hey all
Ogundele Olumide
@Lumexralph
Jun 11 2017 04:46
@meslance Hi
@Manish-Giri gggggggm :smiling_imp:
Manish Giri
@Manish-Giri
Jun 11 2017 04:47
@Lumexralph :sunny: :smiling_imp:
Ogundele Olumide
@Lumexralph
Jun 11 2017 04:47
good morning
Joseph
@revisualize
Jun 11 2017 04:47
@SWbottier I still have no idea why anyone would want to turn a string into an array with a nested array with a single element in it.
Ogundele Olumide
@Lumexralph
Jun 11 2017 04:47
@Manish-Giri sleeping well now?
Manish Giri
@Manish-Giri
Jun 11 2017 04:47
nope
even more late now
@Lumexralph
:weary:
Ogundele Olumide
@Lumexralph
Jun 11 2017 04:48
:laughing:
Kaushik Asp
@Kacppian
Jun 11 2017 04:48
@revisualize true that
hello everyone
Ogundele Olumide
@Lumexralph
Jun 11 2017 04:48
@Manish-Giri how much an effort are you giving it?
Manish Giri
@Manish-Giri
Jun 11 2017 04:48
@SWbottier you can't modify strings, but you can modify array elements in place, that might help..
Ogundele Olumide
@Lumexralph
Jun 11 2017 04:48
@Manish-Giri on a second thought, i'll start using strict-mode more
Manish Giri
@Manish-Giri
Jun 11 2017 04:48
@Lumexralph to sleeping on time?
Ogundele Olumide
@Lumexralph
Jun 11 2017 04:49
@Lumexralph to sleeping on time?
yes
Manish Giri
@Manish-Giri
Jun 11 2017 04:50
lol
like 0.0 effort
:smile:
meslance
@meslance
Jun 11 2017 04:50
I'm having trouble with JavaScript. Can someone help me out?
Ogundele Olumide
@Lumexralph
Jun 11 2017 04:51
@Manish-Giri all the best..... you know a code in strict mode will make debugging easier ?
@meslance ask your question
Manish Giri
@Manish-Giri
Jun 11 2017 04:51
@Lumexralph yup
much easier
Joseph
@revisualize
Jun 11 2017 04:51
@meslance Here's what you do. Don't ask to ask. Just ask your question and if someone can help you... they will
Ogundele Olumide
@Lumexralph
Jun 11 2017 04:51
and now I'm in love
meslance
@meslance
Jun 11 2017 04:52
@Lumexralph I'm on Center Celsius to Fahrenheit and don't really understand it at all
Convert*
Ogundele Olumide
@Lumexralph
Jun 11 2017 04:52
@meslance you have a formula, right?
Joseph
@revisualize
Jun 11 2017 04:52
Paste incoming.

There is the function declaration of function convertToF(celsius) { .. You have a function name of convertToF and a parameter of celsius
Parameters are used just like variables. So, inside of the function you can use celsius JUST like any other variable.
If I have this code:

function addThree (num) {
    var result;
    result = num + 3;
    return result;
}

So, when we make the function call of:

addThree(10);

You're calling the function addThree You're also passing a value 10 as an argument.
In the function declaration of function addThree (num) { You see that there is a parameter defined of num
When we do addThree(10) then the value of the parameter num is passed the argument value of ... 10
Then if you follow the code through.. result = num + 3; ... and we know the value of num is 10.
Therefore, if we follow through the function we end up with ... result = 10 + 3; then result = 13; then we return the result.
...
If you then make another function call..

addThree(39);

You can use the same function to follow the operation:
When we do addThree(39) then the value of the parameter num is passed the argument value of ... 39
Then if you follow the code through.. result = num + 3; ... and we know the value of num is now 39.
Therefore, if we follow through the function we end up with ... result = 39 + 3; then result = 42; then we return the result.

If you make the function call of addThree(21) the value of num inside the function is 21.
If you make the function call of addThree(1000) the value of num inside the function is 1000.
If you make the function call of addThree(123456) the value of num inside the function is 123456.
function declaration of function convertToF(celsius) { } making the function call convertToF(55) the parameter celsius inside of the function has a value of 55
function declaration of function convertToF(celsius) { } making the function call convertToF(23) the parameter celsius inside of the function has a value of 23

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

Ogundele Olumide
@Lumexralph
Jun 11 2017 04:53
@Manish-Giri why shouldn't I love strict mode, when JS acts like it doesn't care whatever I do
Hemakshi Sachdev
@hemakshis
Jun 11 2017 04:54
Please help me in Profile Lookup.. I can't understand how to return the property value
Thanks in advance :)
Ogundele Olumide
@Lumexralph
Jun 11 2017 04:54
@meslance take time with @revisualize post, it'll explain it all and teach you more
@hemakshis what property value?
meslance
@meslance
Jun 11 2017 04:55
@revisualize Thank you
CamperBot
@camperbot
Jun 11 2017 04:55
meslance sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4144 | @revisualize |http://www.freecodecamp.com/revisualize
meslance
@meslance
Jun 11 2017 04:55
@Lumexralph Will do
Hemakshi Sachdev
@hemakshis
Jun 11 2017 04:55
properties inside the object..
Ogundele Olumide
@Lumexralph
Jun 11 2017 04:55
@hemakshis you know how to access the value in an object using it's properties, right?
@meslance :+1:
Hemakshi Sachdev
@hemakshis
Jun 11 2017 04:57
yes either by dot notation or using square brackets
Holger Christiansen
@dragour
Jun 11 2017 04:58
Why is workMin.length not bigger than 1 when I press the button to subtract 1 minut . I am getting 023 instead of 23.
var time = function(){
 this.workBreakMin = "5";
 this.workMin = "24";


  this.workHtml = function(){
    if(this.workMin.length > 1){
      document.getElementById("work").innerHTML = this.workMin;
    }else{
      document.getElementById("work").innerHTML = "0"+this.workMin;
    }
  }
  this.breakHtml = function (){
    if(this.workBreakMin.length > 1){
      document.getElementById("break").innerHTML = this.workBreakMin;
    }else{
      document.getElementById("break").innerHTML = "0"+this.workBreakMin;
    }
  }
}

var timer = new time;
timer.workHtml();
timer.breakHtml();

// subtract from worktime
document.getElementById("wNegativ").addEventListener("click", function(){
  timer.workMin--;
  timer.workHtml();
});
Hemakshi Sachdev
@hemakshis
Jun 11 2017 04:58
I am doing something like this:
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++) {
if(firstName == contacts[i].firstName) {
if(contacts[i].hasOwnProperty(prop)){
return contacts[i].prop;
}
return "No such Property";
}
}
return "No such contact";
// Only change code above this line
}
Ogundele Olumide
@Lumexralph
Jun 11 2017 04:58
@hemakshis cool, but when you're dealing with a parameter or variable, use bracket notation
@hemakshis prop is a parameter so dot notation will not work
Hemakshi Sachdev
@hemakshis
Jun 11 2017 05:00
it worked.. thanks @Lumexralph :+1: :)
CamperBot
@camperbot
Jun 11 2017 05:00
hemakshis sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1907 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jun 11 2017 05:01
@hemakshis :+1:
Hemakshi Sachdev
@hemakshis
Jun 11 2017 05:01
What are brownie points? :worried:
Ogundele Olumide
@Lumexralph
Jun 11 2017 05:02
@hemakshis nothing you should worry yourself about, just a cool cbot listening and appreciating how people help eachother
cbot
CamperBot
@camperbot
Jun 11 2017 05:03
you called?
Ogundele Olumide
@Lumexralph
Jun 11 2017 05:03
@hemakshis can you see it's around :smile:
Hemakshi Sachdev
@hemakshis
Jun 11 2017 05:04
oh yes.. cool feature..
meslance
@meslance
Jun 11 2017 05:06
@Lumexralph I'm still having trouble understanding it
Ogundele Olumide
@Lumexralph
Jun 11 2017 05:07
@meslance what's the formula?
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 11 2017 05:08
hey all
I've just started the random quote machine page, any idea on how to store all the quotes and to use it using random function
红色小星
@turboxing
Jun 11 2017 05:09

var array = [1,2,3,4,5,6,7];
var newArray = [];

// 只能在这一行下面写代码

newArray = array.reverse();

ERROR?
Ogundele Olumide
@Lumexralph
Jun 11 2017 05:09
@reddy-bharathkumar most people use an API so you don't need to do that
红色小星
@turboxing
Jun 11 2017 05:10

@turboxing
var array = [1,2,3,4,5,6,7];
var newArray = [];

// 只能在这一行下面写代码

newArray = array.reverse();
ERROR?

@turboxing
var array = [1,2,3,4,5,6,7];
var newArray = [];

// 只能在这一行下面写代码

newArray = array.reverse();
ERROR?

Ogundele Olumide
@Lumexralph
Jun 11 2017 05:10
@turboxing reverse() doesn't not create a new array
meslance
@meslance
Jun 11 2017 05:10
@Lumexralph var fahrenheit = celsius* 9/5 +32; I think
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 11 2017 05:11
@Lumexralph can you give me any ref sites on how to use API's I'm not getting it properly from FCC
Ogundele Olumide
@Lumexralph
Jun 11 2017 05:12
@meslance cool, that's the operation to be done in the function, you don't need to use var again cos fahrenheit has been declared above in your function
红色小星
@turboxing
Jun 11 2017 05:12
OK
thanks
Ogundele Olumide
@Lumexralph
Jun 11 2017 05:13
@reddy-bharathkumar I can think of any now.... sorry but you can google it
@turboxing :+1:
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 11 2017 05:14
@Lumexralph np, anyway thanks :)
CamperBot
@camperbot
Jun 11 2017 05:14
reddy-bharathkumar sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1908 | @lumexralph |http://www.freecodecamp.com/lumexralph
meslance
@meslance
Jun 11 2017 05:15
@Lumexralph OK, I'm kinda getting it. Thank you.
CamperBot
@camperbot
Jun 11 2017 05:15
meslance sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1909 | @lumexralph |http://www.freecodecamp.com/lumexralph
Wisnu Wardha
@WardhaCS
Jun 11 2017 05:18
function isLess(a, b) {
  // Fix this code
  if (a < b) {
    return true;
  } else {
    return false;
  }
}

// Change these values to test
isLess(10, 15);
X) You should not use any if or else statements
What use switch case
Hemakshi Sachdev
@hemakshis
Jun 11 2017 05:20
@WardhaCS just simply return a < b
if it will be true .. true will be returned else false
function isLess(a, b) {
// Fix this code
return a<b;
}
Praveen Saraogi
@raviloop
Jun 11 2017 05:24
```
sortedArray = arr.sort(function(a,b){
    return a-b;
  })
i wanted to know how this code works , what it assign to a and b as a value and how many iterations it go through
Ogundele Olumide
@Lumexralph
Jun 11 2017 05:29
@raviloop sort method callback, takes the first 2 elements of the array and compare their values and continues till it reaches the end of the array and it checks if the result of the callback is positive, 0 or negative, it uses that to sort the array. have you checked the documentation?
Praveen Saraogi
@raviloop
Jun 11 2017 05:30
yaa i read it , but why a-b for ascending? @Lumexralph
Ogundele Olumide
@Lumexralph
Jun 11 2017 05:35
@raviloop
If compareFunction(a, b) is less than 0, sort a to a lower index than b, i.e. a comes first.
If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other, but sorted with respect to all different elements. Note: the ECMAscript standard does not guarantee this behaviour, and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.
If compareFunction(a, b) is greater than 0, sort b to a lower index than a.
compareFunction(a, b) must always return the same value when given a specific pair of elements a and b as its two arguments. If inconsistent results are returned then the sort order is undefined.
Wisnu Wardha
@WardhaCS
Jun 11 2017 05:35
// Setup
function abTest(a, b) {
  // Only change code below this line

  if(a<0 || b<0){
    return "undefined";
  }else

  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
X)abTest(-2,2) should return undefined
Ok)abTest(2,2) should return 8
Ogundele Olumide
@Lumexralph
Jun 11 2017 05:36
@raviloop a - b will result in 0, positive number or negative number, less than 0 or greater than 0....
@WardhaCS undefined is a value in JS remove the quotes
Pieter Stokkink
@forkerino
Jun 11 2017 05:36
@WardhaCS "undefined" is not undefined
Ogundele Olumide
@Lumexralph
Jun 11 2017 05:37
@forkerino he's here now :smile:
Pieter Stokkink
@forkerino
Jun 11 2017 05:38
:laughing:
Ogundele Olumide
@Lumexralph
Jun 11 2017 05:39
@WardhaCS The global undefined property represents the primitive value undefined, one of the primitive data types in JS
@forkerino good morning
meslance
@meslance
Jun 11 2017 05:40
I have no idea what they are asking for in Escape Sequences in Strings
Pieter Stokkink
@forkerino
Jun 11 2017 05:40
@Lumexralph you too
Pieter Stokkink
@forkerino
Jun 11 2017 05:47
@meslance they give you the full string you need to work with. Just make sure to escape the special characters according to the table. Make sure there are no spaces in there
meslance
@meslance
Jun 11 2017 05:48
@forkerino I changed it to this: FirstLine\nSecondLine\rThirdLine
Pieter Stokkink
@forkerino
Jun 11 2017 05:50
@meslance there should be escaped backslashes around SecondLine
Praveen Saraogi
@raviloop
Jun 11 2017 05:51
@Lumexralph thanks
CamperBot
@camperbot
Jun 11 2017 05:51
raviloop sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1910 | @lumexralph |http://www.freecodecamp.com/lumexralph
meslance
@meslance
Jun 11 2017 05:51
@forkerino FirstLine\n\SecondLine\rThirdLine ??
Aakriti
@Aakriti94
Jun 11 2017 05:51
how can i send messages to my mail account from my website on submit button. my form has 3 fields: name, email and message. A send message button as well
Pieter Stokkink
@forkerino
Jun 11 2017 05:54
@meslance not sure, because I'm on my phone and chat also escapes characters.... besides \n and \r, you need two sets of \\
Ogundele Olumide
@Lumexralph
Jun 11 2017 05:59
@meslance you need to escape backslash \\ before and after SecondLine
@forkerino that can be a pain, the mobile app
meslance
@meslance
Jun 11 2017 06:00
Ok, got it now. Didn't realize backslash was \
\*
Ogundele Olumide
@Lumexralph
Jun 11 2017 06:00
@meslance yeah
Pieter Stokkink
@forkerino
Jun 11 2017 06:01
@Lumexralph yeah... it is :joy: Im not one of those people that can type fast on their phone. Fat fingers. Thank god for dictionary suggestions
CamperBot
@camperbot
Jun 11 2017 06:01
forkerino sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1911 | @lumexralph |http://www.freecodecamp.com/lumexralph
Pieter Stokkink
@forkerino
Jun 11 2017 06:02
Apparently you're god now @Lumexralph :smile:
Ogundele Olumide
@Lumexralph
Jun 11 2017 06:03
@forkerino yeah yeah....cbot made it so :joy: .....
Pieter Stokkink
@forkerino
Jun 11 2017 06:04
Blessed be
Ogundele Olumide
@Lumexralph
Jun 11 2017 06:04
cbot should know who God is.....
CamperBot
@camperbot
Jun 11 2017 06:04
you called?
Ogundele Olumide
@Lumexralph
Jun 11 2017 06:04
I'm not God you hear? @camperbot
qreven
@qreven
Jun 11 2017 06:06

```
function reverseString(str) {
return str;
}

reverseString("hello").split("").reverse().join("");

Ogundele Olumide
@Lumexralph
Jun 11 2017 06:07
@qreven do it in the function scope
qreven
@qreven
Jun 11 2017 06:07
ok thank
ill try
but its weird cause its gving me the right answer
Ogundele Olumide
@Lumexralph
Jun 11 2017 06:08
@qreven str.split("").reverse().join("")
@qreven it'll cos the function reverseString returns the string passed to it as argument
qreven
@qreven
Jun 11 2017 06:09

function reverseString(str) {
  return str;
}

reverseString("hello").split("").reverse().join("");
Ogundele Olumide
@Lumexralph
Jun 11 2017 06:11
@qreven
function reverseString(str) {
  return  str.split("").reverse().join("");
}
qreven
@qreven
Jun 11 2017 06:12
i get it
but whats weird my way was giving me the exact same answer
well thanks anyway :)
An-mode
@an-mode
Jun 11 2017 06:18
Hello ! I am trying to convert a string to title case using arrays. I am splitting the string and referencing the first character of the string of each index and applying the toUpperCase function on it. However, I am unable to reflect it in the original string. Can this work?
Ogundele Olumide
@Lumexralph
Jun 11 2017 06:20
@an-mode you need to concatenate the substring too
An-mode
@an-mode
Jun 11 2017 06:21
@Lumexralph Thank You
CamperBot
@camperbot
Jun 11 2017 06:21
an-mode sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1912 | @lumexralph |http://www.freecodecamp.com/lumexralph
An-mode
@an-mode
Jun 11 2017 06:21
Let me try it
Muhammad Faheem Akhtar
@mfaheemakhtar
Jun 11 2017 06:22

Hello, I'm trying to complete the "Exact Change" challenge.

checkCashRegister(19.50, 20.00, [["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1.00], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]) should return "Insufficient Funds".

Cash in register = 1.01
Change = 0.5

"Insufficient Funds" How?

Netrunner21
@Netrunner21
Jun 11 2017 06:39
may be a floating point error
that's usually the culprit. I remember getting the error you're getting on that exact one, not sure what my solution was
qreven
@qreven
Jun 11 2017 06:45
var sum = 1;
function factorialize(num) {
  for (var i = 0; i < num; i++){
      sum = sum*(1+i);
    }
  return sum;
}
factorialize(5);
Mario A. Carlos
@MarioC3
Jun 11 2017 06:45
Guys!
qreven
@qreven
Jun 11 2017 06:46
im getting the right answer but still no complete :(
factorialize(5) should return a number.
factorialize(5) should return 120.
factorialize(10) should return 3628800.
factorialize(20) should return 2432902008176640000.
factorialize(0) should return 1.
Mario A. Carlos
@MarioC3
Jun 11 2017 06:46
I'm doing the quote generator project.
qreven
@qreven
Jun 11 2017 06:46
got all of them right
Mario A. Carlos
@MarioC3
Jun 11 2017 06:46
But My console is throwing a Unexpected token .
Markus Ivancsics
@ivancsicsmarkus
Jun 11 2017 06:46
@MarioC3 Could you give me your link?
Mario A. Carlos
@MarioC3
Jun 11 2017 06:47
This is my code, can someone help me?
$(document).ready(function() {
  $(".circle").on("click", function(){
    $.getJSON('https://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en', function(data) { 
      $(.quote).html(JSON.stringify(data));  
    });
});
});
Markus Ivancsics
@ivancsicsmarkus
Jun 11 2017 06:47

@MarioC3
instead of this:

$(.quote).html(JSON.stringify(data));

write this:

$(".quote").html(JSON.stringify(data));
Mario A. Carlos
@MarioC3
Jun 11 2017 06:47
This is the codepen I'm using: https://codepen.io/MarioC322/pen/WOwGJL
Oh ok!
Markus Ivancsics
@ivancsicsmarkus
Jun 11 2017 06:49
@MarioC3 You also have mixed content issue.
Mario A. Carlos
@MarioC3
Jun 11 2017 06:49
Sounds good Thanks! I'm still receiving an error
let me do some research by myself
if I can't figure it out I'll come back
Pramesha
@pramesha
Jun 11 2017 06:52
@swong194 ya i did resetting and it worked out. thnkz
K L Bhanu
@klbm9999
Jun 11 2017 06:53
@MarioC3 your ajax request is not happening (a cross origin request error), try to use $.ajax with datatype as jsonp (at least that is what i did, i dont exactly know how to solve this error, but i have an idea.) check my project to refer how to make an api call : https://codepen.io/klbm9999/pen/YVbrmg . hope this helps
qreven
@qreven
Jun 11 2017 06:58
var sum = 1;
function factorialize(num) {
  for (var i = 1; i < num; i++){
      sum = sum*(1+i);
    }
  return sum;
}
factorialize(5);
im getting the right answers to all the requirements
but its not accepting my code
factorrial program
can anyone help?
Johnny
@jtan3
Jun 11 2017 07:01
@qreven put the var sum=1 inside your function
Wisnu Wardha
@WardhaCS
Jun 11 2017 07:02
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber=16;       // Change this Line
var player = testObj[16];   // Change this Line
Ok)playerNumber should be a number
X)You should be using the variable playerNumber in your bracket notation
Manish Giri
@Manish-Giri
Jun 11 2017 07:03
@WardhaCS var player = testObj[16];
you're not using playerNumber
as that error message says
Mario A. Carlos
@MarioC3
Jun 11 2017 07:05
Ok. So here I am again.
It looks like I have a JQuery problem
$(document).ready(function() {
  $(".circle").on("click", function(){
    $.getJSON('http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1', function(data) { 
      $('.quote').html(JSON.stringify(data));  
    });
});
});
This is what the console error shows: Uncaught ReferenceError: $ is not defined
Any suggestions?
Manish Giri
@Manish-Giri
Jun 11 2017 07:06
codepen is now on https
resources served over http won't work anymore
@MarioC3
Mario A. Carlos
@MarioC3
Jun 11 2017 07:07
So calling APIs on http is a no no?
Manish Giri
@Manish-Giri
Jun 11 2017 07:07
looks like
Mario A. Carlos
@MarioC3
Jun 11 2017 07:08
So it's not even loading the jQuery script?
njordomir
@njordomir
Jun 11 2017 07:08
On challenge "Sum all Primes," can someone expain to me why my first for loop (i not j) stops iterating at 743 when that doesn't yet violate i<num? It doesn't even seem to do the same amount of runs each time, and I read through my code multiple times. I put console logs in there that will show you what I'm talking about. Check the array length on NewRun 997 and run it one or more times.
function sumPrimes(num) {
  console.log("NewRun$$$$$$$$$$$$$$$$$$$ " + num);
  var isPrimeBool = true;
  var output = [];
  for (i=2;i<=num;i++) {
    isPrimeBool = true;
    for (j=2;j<i;j++) {
      if (i%j === 0) {
        isPrimeBool = false;
      }
    }
    if (isPrimeBool === true) {
      output.push(i);
    }
  }
  console.log(output);
  output = output.reduce(function(acc,val) {
    return acc + val;
  });
  console.log("Output: " + output);
  return output;
}

sumPrimes(10);
Manish Giri
@Manish-Giri
Jun 11 2017 07:09
@MarioC3 look in your console
Mario A. Carlos
@MarioC3
Jun 11 2017 07:09
image.png
It looks like it's not even loading jquery since it's not even definiing $
Manish Giri
@Manish-Giri
Jun 11 2017 07:11
what does your jquery import look like
Mario A. Carlos
@MarioC3
Jun 11 2017 07:11
It's on codepen
I turn it on via settings
Manish Giri
@Manish-Giri
Jun 11 2017 07:11
try out an https api
its probably coz of that
Long Nguyen
@longnt80
Jun 11 2017 07:12
@MarioC3 paste your codepen link here
Long Nguyen
@longnt80
Jun 11 2017 07:14
@MarioC3 no I didn't see anything like the error you showed
@MarioC3 your jQuery works fine
Manish Giri
@Manish-Giri
Jun 11 2017 07:15
Mixed Content: The page at 'https://codepen.io/...' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1'. This request has been blocked; the content must be served over HTTPS.
Long Nguyen
@longnt80
Jun 11 2017 07:15
here's the error in my browser's console:
Mixed Content: The page at 'https://codepen.io/MarioC322/full/WOwGJL/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1'. This request has been blocked; the content must be served over HTTPS.
Mario A. Carlos
@MarioC3
Jun 11 2017 07:16
I use the debug mode... to debug my code
Long Nguyen
@longnt80
Jun 11 2017 07:17
you're jquery is working fine
find another api that serves https
CamperBot
@camperbot
Jun 11 2017 07:17
find another api that serves https
nothing found
Mario A. Carlos
@MarioC3
Jun 11 2017 07:18
ok
Aditya Soni
@adist98
Jun 11 2017 07:29
i am on to build "random quote machine", i have finished everything before that, i need help on the random quote machine, i need some sources that can help me with it.
Kaustubh Mishal
@kaustubhmishal
Jun 11 2017 07:30
getting this error "TypeError: Cannot assign to read only property '0' of string 'Hello World'"

tried this
var myStr = "Jello World";

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

can any 1 help
cant find where I am going wrong
WAINGOR
@WAINGOR
Jun 11 2017 07:47
@kaustubhmishal please send us your code between backticks ---> ```
and tell what assignment you are working on
Manish Giri
@Manish-Giri
Jun 11 2017 07:47
@kaustubhmishal myStr[0] = "H"; // Fix Me
the comment was meant for you to change that specific line.
Since you made a new line, delete this one..
Kaustubh Mishal
@kaustubhmishal
Jun 11 2017 07:50
thanks @Manish-Giri @WAINGOR ... issue solved..thanks for replying 😊
CamperBot
@camperbot
Jun 11 2017 07:50
kaustubhmishal sends brownie points to @manish-giri and @waingor :sparkles: :thumbsup: :sparkles:
:cookie: 226 | @waingor |http://www.freecodecamp.com/waingor
:star2: 5947 | @manish-giri |http://www.freecodecamp.com/manish-giri
Hemakshi Sachdev
@hemakshis
Jun 11 2017 07:54
Can please someone please explain the syntax of map method ??
i find in quite weird..
Mr.007
@hokien07
Jun 11 2017 07:55

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

and my code:
var myStr = '\FirstLine\ \nSecondLine \\r ThirdLine'; // Change this line

this not alow, please help me

Abid Bilabar
@bilabar
Jun 11 2017 07:55
hi, i do factorialize challenge
var result = 1;
function factorialize(n) {

  for (i=1;i<=n;i++){
   result *=i;
  }
  return result;
}

factorialize(0);
Manish Giri
@Manish-Giri
Jun 11 2017 07:56
.map(function(element) {
 // do something with element
}
@hemakshis As .map() iterates over the array, element becomes the array items, one by one.
Then you do further processing with it.
Abid Bilabar
@bilabar
Jun 11 2017 07:56
it give me true result, but the browser say false
Manish Giri
@Manish-Giri
Jun 11 2017 07:57
@bilabar var result = 1;
make this local variable
Muhammad Faheem Akhtar
@mfaheemakhtar
Jun 11 2017 07:57
@longnt80 Thanks, got it now.
CamperBot
@camperbot
Jun 11 2017 07:57
mfaheemakhtar sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 362 | @longnt80 |http://www.freecodecamp.com/longnt80
Hemakshi Sachdev
@hemakshis
Jun 11 2017 07:57
Why do we put function(element) inside the map.. ?
Manish Giri
@Manish-Giri
Jun 11 2017 07:57
it's a callback function
Abid Bilabar
@bilabar
Jun 11 2017 07:58
@Manish-Giri thanks, it works. why it should local?
CamperBot
@camperbot
Jun 11 2017 07:58
bilabar sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5948 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jun 11 2017 07:58
@bilabar FCC tests are run consecutively, and global variables aren't reset.
Abid Bilabar
@bilabar
Jun 11 2017 07:59
@Manish-Giri ok, i got it
Greg Duncan
@GregatGit
Jun 11 2017 08:03
@hemakshis map goes through and applies the function to every element in the array
Kaustubh Mishal
@kaustubhmishal
Jun 11 2017 08:05
@hokien07 remove "\ " before "FirstLine" also there should be no space between characters. Statement should be without spaces
Hemakshi Sachdev
@hemakshis
Jun 11 2017 08:09
@Manish-Giri how does the compiler/interpreter know which callback function to be called??
Mohak Chaturvedi
@lucky73
Jun 11 2017 08:09
i am at escape literal string function module i really facing problem understanding this
plesae help !
Manish Giri
@Manish-Giri
Jun 11 2017 08:09
@hemakshis it executes whatever you pass in to .map().
function square(element) {
  return element * element;
}
[1,2,3].map(square);
@lucky73 what's the problem?
Hemakshi Sachdev
@hemakshis
Jun 11 2017 08:10
okay.. i got it.. thanks a lot @Manish-Giri :+1:
CamperBot
@camperbot
Jun 11 2017 08:10
hemakshis sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5950 | @manish-giri |http://www.freecodecamp.com/manish-giri
ramarcinek
@ramarcinek
Jun 11 2017 08:14

Hello!

Can you advise what is wrong?

function mutation(arr) {

var matchLetters = arr[1].split("");
console.log(matchLetters);

var stringCompareWord = arr[0];
console.log(stringCompareWord);

for (var i=0; i<matchLetters.length; i++){
if (stringCompareWord.indexOf("matchLetters[i]") !== -1) {

      return true;
      console.log("Found");
  } else {
      return false;
      console.log("Not found");
  }

}

return arr;
}

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

I cannot get the value true of false from the loop
Hemakshi Sachdev
@hemakshis
Jun 11 2017 08:18
what IDE is best for JS?
Greg Duncan
@GregatGit
Jun 11 2017 08:19
@hemakshis vscode
ramarcinek
@ramarcinek
Jun 11 2017 08:21

Guys, do you have any idea what is wrong?
function mutation(arr) {

var matchLetters = arr[1].split("");
console.log(matchLetters);

var stringCompareWord = arr[0];
console.log(stringCompareWord);

for (var i=0; i<matchLetters.length; i++){
if (stringCompareWord.indexOf("matchLetters[i]") !== -1) {

      return true;
      console.log("Found");
  } else {
      return false;
      console.log("Not found");
  }

}

return arr;
}

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

Manish Giri
@Manish-Giri
Jun 11 2017 08:23
@ramarcinek your for loop has returns
it'll exit in the first iteration itself.
Dylan Demnard
@kulpio
Jun 11 2017 08:23
Hi guys, I am at the "Truncate String" bone fire and I am stuck. I can make the result work when num is > 3 or when str is < 3, but not both together.... what is wrong with my code?

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

return str;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);

ramarcinek
@ramarcinek
Jun 11 2017 08:25
@Manish-Giri Hmm, yes, you're right. Thanks! I didn't think about it
CamperBot
@camperbot
Jun 11 2017 08:25
ramarcinek sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5951 | @manish-giri |http://www.freecodecamp.com/manish-giri
ramarcinek
@ramarcinek
Jun 11 2017 08:26
@Manish-Giri Could you please also have a look at the condition in the if caluse? Is it correct?
ramamrajdev
@ramamrajdev
Jun 11 2017 08:26
#208 how to make the json object inside the object.
Manish Giri
@Manish-Giri
Jun 11 2017 08:27
@ramarcinek "matchLetters[i]"
remove the quotes
Dylan Demnard
@kulpio
Jun 11 2017 08:28
Would anyone know what is wrong with my code above?
Sandip Shrestha
@saninmersion
Jun 11 2017 08:30
@kulpio let me have a look and see if I can help
ramarcinek
@ramarcinek
Jun 11 2017 08:30
@Manish-Giri Thank you
CamperBot
@camperbot
Jun 11 2017 08:30
ramarcinek sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: ramarcinek already gave manish-giri points
Dylan Demnard
@kulpio
Jun 11 2017 08:31
@saninmersion thank you
CamperBot
@camperbot
Jun 11 2017 08:31
kulpio sends brownie points to @saninmersion :sparkles: :thumbsup: :sparkles:
:cookie: 515 | @saninmersion |http://www.freecodecamp.com/saninmersion
Sandip Shrestha
@saninmersion
Jun 11 2017 08:36
@kulpio for the elseif (str.length <= 3) you don't need to slice the string
ramamrajdev
@ramamrajdev
Jun 11 2017 08:36
#208 how to make the json object inside the object.
Dylan Demnard
@kulpio
Jun 11 2017 08:38
@saninmersion oh! let me try.
Sandip Shrestha
@saninmersion
Jun 11 2017 08:42
@kulpio also I checked the challenge if the given maximum string length num states that it should be (num<=3)and not (str.length <= 3)
Dan Couper
@DanCouper
Jun 11 2017 08:44
@ramamrajdev the challenges do not have numbers
Sandip Shrestha
@saninmersion
Jun 11 2017 08:46
@kulpio also you might want to check (num<=3) before (str.length > num)
Dylan Demnard
@kulpio
Jun 11 2017 08:47

@saninmersion ok that's what I have.... still not working: function truncateString(str, num) {
// Clear out that junk in your trunk
var slicedStr = "";
if (str.length > num) {
slicedStr = str.slice(0, num-3);
var completedStr = slicedStr + "...";
return completedStr;
} else if (num <= 3) {
slicedStr = str(0, num);
var smallCompletedStr = slicedStr + "...";
return smallCompletedStr;
}

return str;
}

truncateString("A-", 1);

Sandip Shrestha
@saninmersion
Jun 11 2017 08:48
@kulpio :up:
Dylan Demnard
@kulpio
Jun 11 2017 08:48
hmm I am not getting it...
Sandip Shrestha
@saninmersion
Jun 11 2017 08:49
@kulpio you might want to check (num<=3) before (str.length > num) also you got to return str I think but if any other variable works for you that's good
@kulpio
if (num <= 3) {
} else if (str.length > num) { 
}
Dylan Demnard
@kulpio
Jun 11 2017 08:49
@saninmersion you mean check before the if?
with another else if statement?
so I erase the else if afteward then
sorry, the else if statement I already have
@saninmersion
sorry, brb....
Sandip Shrestha
@saninmersion
Jun 11 2017 08:53
@kulpio no no I dont mean erase just check (num <= 3) before (str.length > num) like I have done above. The reason your truncateString("A-", 1); does not pass is because when you check (str.length > num) before (num <= 3) , it will never enter the second condition when it should.
Dan Couper
@DanCouper
Jun 11 2017 08:57
@hemakshis any of vscode, atom, sublime, notepad++, whatever, it's much of a muchness, Atom and VSCode generally get support for new things first nowadays, and have the most people working on improving them (there's Facebook's Nuclide IDE built on top of Atom for example). Or there's Vim and Emacs, which or respectively much faster/more reliable a than anything else (Vim) and more powerful than anything else (Emacs), but they involve a serious amount more learning.
Note they're all text editors with IDE features, you don't need an actual idea like VS to write JS at all
Praveen Saraogi
@raviloop
Jun 11 2017 09:00

challenge name : Where do i belong
category : Basic Algorithms in JS

solution i created :


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

var sortedArray;

  //get that array sorted into sortedArray

sortedArray = arr.sort(function(a,b){
    return a-b;
  });

// console.log("sortted Array "+sortedArray);

//diff array to store the difference of num with every element of array
  var diff=[];


//find difference of num with every element in sortedArray and store difference in an array diff
for(i=0;i<sortedArray.length;i++){

 diff[i] = Math.abs(sortedArray[i] - num) ;  

}

  //set the lowest difference value and location to the last element in diff array 
var lowest = diff[diff.length-1];
var loc = diff.length-1;

  //find the lowest difference and its location in the diff array 
for(i=0;i<diff.length;i++){

  if(diff[i] < lowest){
    lowest = diff[i];
    loc = i;
  }
}

  //variable to check for same difference value location
var sameloc=0;

// console.log("diff array" +diff);
// console.log("location of lowest difference " +loc);
// console.log("lowest diff value " +lowest);

// check for location of lowest difference value in diff array , avoiding the current location
for(j=0;j<diff.length;j++){

  if(j!==loc){
  if(lowest == diff[j]){

    sameloc = j;

  }
  }

}

  //finally finalloc is a variable to store the final location 
var finalloc=0;

//  console.log(sameloc+ " == " +loc);


//find the appropriate location by comparing the locations we got  
if(sameloc > loc){
  finalloc = sameloc;
}

else if(sameloc == loc){
  finalloc = loc;
}

else{
  finalloc = loc;
}


 // and if the finalloc is the location of the last element in the array then compare the num with the last value in sortedArray 

if(finalloc == sortedArray.length-1){
  if(num > sortedArray[finalloc])
  {finalloc++;}
}


  return finalloc;
}

getIndexToIns([40,60], 50);

i know these solution is pretty long and confusing and i also know there might be very short alternative to this. but i did the way i understand .
so should i get satisfied with such solutions of mine or should i try to make it shorter by trying hard .
My query is does it really matter how one should achieved the solution ??

Dylan Demnard
@kulpio
Jun 11 2017 09:01
@saninmersion ok, I "get it", but when I do it, now the ones > than 3 don't pass LOL
that is what I wrote:

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

return str;
}

truncateString("A-", 1);

Dan Couper
@DanCouper
Jun 11 2017 09:03
@raviloop it's very long, very complex, and you won't understand it in a week or so. Its fine to have that code to get something working, but it's bad past that because it's very difficult to impossible for someone reading the code (including future you) to understand it.
Sandip Shrestha
@saninmersion
Jun 11 2017 09:03
@kulpio you actually dont need extra variables.
if (num <= 3) {
str = str.slice(0, num);
str = str + "...";
} else if (str.length > num) {
str = str(0, num-3);
str = str + "...";
}
Praveen Saraogi
@raviloop
Jun 11 2017 09:04
@DanCouper so what should i do in that case ?? should i feel okay with it or should i try for an alternative which might take my more time in it
Chloe Chen
@waterwaltz
Jun 11 2017 09:05

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

arr = JSON.stringify(arr);
console.log("this arr = " + arr);

arr = arr.push(item);

return item; // Change this line
}

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

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

shows arr.push is not a function
anyone can help? Thanks!!
Dan Couper
@DanCouper
Jun 11 2017 09:07
@raviloop you just need to count how many items in the array are have a value less than the number, that would be the index, you can make it a single line of easily-understandable code.
If you want to refactor
Adam Faraj
@adamfaraj
Jun 11 2017 09:08
@adamfaraj
userInput !== null || userInput !== ""
this basically checks if the text field is not empty, right?
userInput is an input
i'm trying to build a form authenticator, and if the username field is filled out, i want it display that the Username is not taken.
https://codepen.io/adamfaraj/pen/XgdpVx
Dylan Demnard
@kulpio
Jun 11 2017 09:08
@saninmersion awesome! thank you for your help!. I like to create variable as it helps me keep track of the process, but there it made it harder... LOL.
CamperBot
@camperbot
Jun 11 2017 09:08
kulpio sends brownie points to @saninmersion :sparkles: :thumbsup: :sparkles:
:warning: kulpio already gave saninmersion points
Adam Faraj
@adamfaraj
Jun 11 2017 09:08
but it's doing it while i have the input field empty
Sumit Rajput
@smtrjpt
Jun 11 2017 09:09
@adamfaraj you're using it !==
Sandip Shrestha
@saninmersion
Jun 11 2017 09:10
@kulpio well the trick is to find that line where we overdo it
Dan Couper
@DanCouper
Jun 11 2017 09:10
@raviloop I mean what you've got is fine, it's just much more complicated than it needs to be
Sumit Rajput
@smtrjpt
Jun 11 2017 09:10
it checks when the field in NOT equals to null execute
means whenever you type it exexutes
you should use ==
Ogundele Olumide
@Lumexralph
Jun 11 2017 09:11
@waterwaltz you're to push item into arr which will be holding an array when the function is called, and the you remove the first element in arr and return it
Adam Faraj
@adamfaraj
Jun 11 2017 09:11
@smtrjpt i tried using == and it didn't work
Anshul Adlakha
@anshuladlakha
Jun 11 2017 09:12
https://www.freecodecamp.com/challenges/smallest-common-multiple
Can anyone help me understand the calculation of LCM part of this problem?
any easy way of doing it perhaps?
Chloe Chen
@waterwaltz
Jun 11 2017 09:13
@Lumexralph yes,should be like that. I don't know why it shows "arr.push is not a function" in console.log
Sumit Rajput
@smtrjpt
Jun 11 2017 09:14
@adamfaraj what you tryin' to do ?
Adam Faraj
@adamfaraj
Jun 11 2017 09:15
@smtrjpt if there's text in the input field, a message will be displayed, saying the Username is not taken.
Sumit Rajput
@smtrjpt
Jun 11 2017 09:15
== worked
Ogundele Olumide
@Lumexralph
Jun 11 2017 09:16
@waterwaltz show your code
Adam Faraj
@adamfaraj
Jun 11 2017 09:17
@smtrjpt are you changing both the !== to == ?
Sumit Rajput
@smtrjpt
Jun 11 2017 09:17
yeas
Chloe Chen
@waterwaltz
Jun 11 2017 09:18
@Lumexralph

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


  arr = JSON.stringify(arr);
  console.log("this arr = " + arr);

  arr = arr.push(item);


  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Adam Faraj
@adamfaraj
Jun 11 2017 09:18
@smtrjpt the message "Username not taken" went away. no matter if i have text in the field or not. what did i do wrong
Ogundele Olumide
@Lumexralph
Jun 11 2017 09:19

@waterwaltz why doing this

arr = JSON.stringify(arr);
  console.log("this arr = " + arr);

?

@waterwaltz remove that
Chloe Chen
@waterwaltz
Jun 11 2017 09:20
@Lumexralph okay
Rayy Benhin
@bnhn
Jun 11 2017 09:21
function diffArray(arr1, arr2) {
  var newArr = [];
  var newArr2 = [];
  // Same, same; but different.
  newArr = arr1.filter(function(elem) {
    return arr2.indexOf(elem) === -1;
  });
  newArr2 = arr2.filter(function(elem) {
    return arr1.indexOf(elem) === -1;
  });
  return newArr.concat(newArr2);
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
I'll appreciate a review of the above snippet.
Ogundele Olumide
@Lumexralph
Jun 11 2017 09:21
@waterwaltz when you're done, show your updated code
Chloe Chen
@waterwaltz
Jun 11 2017 09:22
sure, I am trying now, thanks!!
@Lumexralph
Sumit Rajput
@smtrjpt
Jun 11 2017 09:23
@adamfaraj add a id to your input field
store it in a variable like
var user_input = document.getElementById("username");
Mr.007
@hokien07
Jun 11 2017 09:24
Inside function fun1, assign 5 to oopsGlobal without using the var keyword.
??
help me. please!!
Dylan Demnard
@kulpio
Jun 11 2017 09:25
@hokien07 what number in your the map?
Ogundele Olumide
@Lumexralph
Jun 11 2017 09:26
@hokien07 show what you've tried
Chloe Chen
@waterwaltz
Jun 11 2017 09:26
@Lumexralph I think my problem is I can not remove the first one in the array if not doing this
arr = JSON.stringify(arr);
  console.log("this arr = " + arr);
Ogundele Olumide
@Lumexralph
Jun 11 2017 09:27
@hokien07 it's trying to illustrate scope to you
Chloe Chen
@waterwaltz
Jun 11 2017 09:27

@Lumexralph

not working if this way


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


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


  return item;  // Change this line
}
Dylan Demnard
@kulpio
Jun 11 2017 09:27
@hokien07 do you still need help?
Mr.007
@hokien07
Jun 11 2017 09:27

// Declare your variable here

myGlobal = 10;
function fun1() {
// Assign 5 to oopsGlobal Here

}
// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}

Sumit Rajput
@smtrjpt
Jun 11 2017 09:28
execute the conditional on submit in a function.. maybe
@adamfaraj
Ogundele Olumide
@Lumexralph
Jun 11 2017 09:28
@waterwaltz do you know what the push method of an array returns?
Sumit Rajput
@smtrjpt
Jun 11 2017 09:28
@adamfaraj you could even try losing focus i.e. blue event
or onmouseout
Chloe Chen
@waterwaltz
Jun 11 2017 09:29
@Lumexralph add one more to the last one in an array
Sumit Rajput
@smtrjpt
Jun 11 2017 09:29
right now your conditional just works once when loading and then never executes @adamfaraj
Ogundele Olumide
@Lumexralph
Jun 11 2017 09:30
@waterwaltz that's the side-effect, it also returns the length of the array it pushed the value tp
Mr.007
@hokien07
Jun 11 2017 09:30
declare a variable don't use var?
Adam Faraj
@adamfaraj
Jun 11 2017 09:30
@smtrjpt so right an else statement?
Mr.007
@hokien07
Jun 11 2017 09:30
i don't understand
Ogundele Olumide
@Lumexralph
Jun 11 2017 09:30
@waterwaltz that's why arr.push(item); is done cos we only need the side-effect and not the returned value
Adam Faraj
@adamfaraj
Jun 11 2017 09:30
@hokien07 let or const
Sumit Rajput
@smtrjpt
Jun 11 2017 09:30
@adamfaraj
<form onsubmit="x()">
@adamfaraj use the conditional in this statement
Mr.007
@hokien07
Jun 11 2017 09:31
<code> const oopsGlbal = 5; ??</code>
Dylan Demnard
@kulpio
Jun 11 2017 09:32
@hokien07 this is what I got:

var myGlobal = 10;

function fun1() {
// Assign 5 to oopsGlobal Here
oopsGlobal = 5;
}

// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}

Mr.007
@hokien07
Jun 11 2017 09:34
kidding :(
thanks @kulpio
CamperBot
@camperbot
Jun 11 2017 09:34
hokien07 sends brownie points to @kulpio :sparkles: :thumbsup: :sparkles:
:cookie: 249 | @kulpio |http://www.freecodecamp.com/kulpio
Ashan Mohammed
@AshanMohammed
Jun 11 2017 09:35
Hello,
Any one have experience in working with skycon icons? I
Mr.007
@hokien07
Jun 11 2017 09:37
(shift+enter for line break) var code = "formatted";
Dylan Demnard
@kulpio
Jun 11 2017 09:38
@hokien07 do you understand why? The var is outside the function, which is global. The one inside the function is also global by using it without the var keyword.
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 11 2017 09:38

Hi All,
I'm working on Random Quote page.. I've used Math.random to get the id and I'm displaying the quotes based on Id.. If I'm using 5 quotes as total.. the random function getting no where after 5 attempts...
https://codepen.io/reddy-bharathkumar/pen/awNBbJ

Can someone please check it?
sorry for the bad UI, I'm working on the JS part first

Mr.007
@hokien07
Jun 11 2017 09:39
yes!! thanks so much @kulpio
CamperBot
@camperbot
Jun 11 2017 09:39
hokien07 sends brownie points to @kulpio :sparkles: :thumbsup: :sparkles:
:warning: hokien07 already gave kulpio points
Markus Ivancsics
@ivancsicsmarkus
Jun 11 2017 09:41
@reddy-bharathkumar Hello!
@reddy-bharathkumar Is your question still relevant?
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 11 2017 09:41
yes
Markus Ivancsics
@ivancsicsmarkus
Jun 11 2017 09:42
@reddy-bharathkumar It is because you are using splice. Splice removes that random element from the array. So after 5 attempts your quotes array is empty.
Chloe Chen
@waterwaltz
Jun 11 2017 09:42

@Lumexralph
Yes, I can see the length form

console.log(arr);

but can I turn length into an array??

Mark R. Baker
@mrbaker1917
Jun 11 2017 09:43
Working on the smallest common multiple challenge. I can code the smallest between the largest and smallest number, but getting the smallest for all the in between numbers is tough. Here is my code:
function smallestCommons(arr) {
  var minNum = Math.min.apply(null, arr);
  var maxNum = Math.max.apply(null, arr);
  var fullArray = [];
  var lcm = maxNum * maxNum;
  for (var k = minNum; k < maxNum; k++) {
    fullArray.push(k);
  }
 for (var m = 0; m < fullArray.length; m++) {
  for (var i = 1; i <= maxNum; i++) {
    for (var j = 1; j <= maxNum; j++) {
    var minMult = fullArray[m] * i;
    var maxMult = maxNum * j;
    if (minMult === maxMult) {
      if (minMult < lcm) {
      lcm = minMult;
      }
    } else {
      lcm = lcm;
    }
    }
  }
  }
   return lcm;
}
smallestCommons([4, 5]);
I made an array of all numbers except the max, and tried to iterate through it.
Ogundele Olumide
@Lumexralph
Jun 11 2017 09:44
@waterwaltz why would you want to do that? you just need to do 2 things only
Praveen Saraogi
@raviloop
Jun 11 2017 09:44
@DanCouper thanks
CamperBot
@camperbot
Jun 11 2017 09:44
raviloop sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 759 | @dancouper |http://www.freecodecamp.com/dancouper
Ogundele Olumide
@Lumexralph
Jun 11 2017 09:44
@waterwaltz 1. push item to arr 2. use shift to remove the first element in arr and return it
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 11 2017 09:45
@ivancsicsmarkus thanks, I will check and let you know
CamperBot
@camperbot
Jun 11 2017 09:45
reddy-bharathkumar sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:cookie: 604 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
Markus Ivancsics
@ivancsicsmarkus
Jun 11 2017 09:46
@reddy-bharathkumar You should use slice, instead.
var random = Math.floor(Math.random()*quotes.length);
var displayquote = quotes.slice(random,random+1)[0];
Raghu Raj Rai
@Raidestro
Jun 11 2017 09:49
Hey guys. Did anyone of you complete the Local Weather App project ?
Wisnu Wardha
@WardhaCS
Jun 11 2017 09:50
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for(var i=0;i<arr.langth;i++){
    for(var j=0;j<arr[i].langth;j++){
      product*=arr[i][j];
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
X)multiplyAll([[1],[2],[3]]); should return 6
X)multiplyAll([[1,2],[3,4],[5,6,7]]) should return 5040
X)multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]);) should return 54
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 11 2017 09:50
@ivancsicsmarkus thanks a lot man, I was about to ask you the same..
thanks again for the code... ;) :)
CamperBot
@camperbot
Jun 11 2017 09:50
reddy-bharathkumar sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:warning: reddy-bharathkumar already gave ivancsicsmarkus points
Ogundele Olumide
@Lumexralph
Jun 11 2017 09:51
@WardhaCS typo length not langth
@WardhaCS for(var i=0;i<arr.langth;i++){ for(var j=0;j<arr[i].langth;j++){
Wisnu Wardha
@WardhaCS
Jun 11 2017 09:53
Thank you
Sorry i can not read english
Ogundele Olumide
@Lumexralph
Jun 11 2017 09:53
@WardhaCS okay, it's all good
Markus Ivancsics
@ivancsicsmarkus
Jun 11 2017 09:54
@Raidestro Of course.
@Raidestro What do you need?
Raghu Raj Rai
@Raidestro
Jun 11 2017 09:56
@ivancsicsmarkus I'm totally confused man. I did the JS course on FCC properly and it just feels like I don't know a thing about js. I was able to make the Random Quote Generator somehow as it didn't require APIS but now I'm stuck .
mihaiIamandi
@mihaiIamandi
Jun 11 2017 09:56
Hi i cant figure it out how to acces number 16 tried with index and with number could you please help me ?

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

// Only change code below this line;

var playerNumber = testObj[1]; // Change this Line
var player = testObj; // Change this Line

Ogundele Olumide
@Lumexralph
Jun 11 2017 09:57
@mihaiIamandi what property/key in the testObj has the value "Montana" ?
mihaiIamandi
@mihaiIamandi
Jun 11 2017 09:57
16
Ogundele Olumide
@Lumexralph
Jun 11 2017 09:57
@mihaiIamandi assign that to playerNumber variable
Markus Ivancsics
@ivancsicsmarkus
Jun 11 2017 09:59
@Raidestro Retake the course about APIs!
@Raidestro Search for weather api in google! There will be documentations with examples.
Ogundele Olumide
@Lumexralph
Jun 11 2017 09:59
@mihaiIamandi you know how to use a variable to access the value in an object, right?
Chloe Chen
@waterwaltz
Jun 11 2017 10:00

@Lumexralph
it finally works in this way

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

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

  return item;  // Change this line
}

but it doesn't work if I write like this

arr = arr.push(item);
Ogundele Olumide
@Lumexralph
Jun 11 2017 10:03
@waterwaltz yeah, i already explained to you that push returns the new length of the array it's pushing to so in this case
let arr = [1, 3, 5];
arr = arr.push(6);
the length is returned and that's assigned to arr
 but what the side-effect of push does is to put the value to the end of the array
arr = 4;//  length of the array
Chloe Chen
@waterwaltz
Jun 11 2017 10:04
I get it!!!!!! thank you so much @Lumexralph
CamperBot
@camperbot
Jun 11 2017 10:04
waterwaltz sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1913 | @lumexralph |http://www.freecodecamp.com/lumexralph
Raghu Raj Rai
@Raidestro
Jun 11 2017 10:05
@ivancsicsmarkus That's what I'm doing.
Ogundele Olumide
@Lumexralph
Jun 11 2017 10:08
@waterwaltz you're welcome
Kelechi Chinaka
@ke1echi
Jun 11 2017 10:09
hola @Lumexralph
awfa wit d home study @Lumexralph
Ogundele Olumide
@Lumexralph
Jun 11 2017 10:14
@kelechichinaka Bro :wave:
@kelechichinaka done the test, submitted since Friday
how're you?
mithun
@dmithun
Jun 11 2017 10:15
var myStr = "<a href='http://www.example.com' target=\"_blank\">Link</a>";
what did i do wrong???????
Adam Faraj
@adamfaraj
Jun 11 2017 10:17
target="_blank" @dmithun
mihaiIamandi
@mihaiIamandi
Jun 11 2017 10:18
I don't get it how should i asign playerNumber a number , please help me .
p1xelord
@p1xelord
Jun 11 2017 10:18
How to pass arguments to nested filter function?
Adam Faraj
@adamfaraj
Jun 11 2017 10:18
ugh
p1xelord
@p1xelord
Jun 11 2017 10:18
i mean the arguments object
Adam Faraj
@adamfaraj
Jun 11 2017 10:18
i feel like i'm so close
mihaiIamandi
@mihaiIamandi
Jun 11 2017 10:18

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

// Only change code below this line;

var playerNumber = testObj["Montana"]; // Change this Line
var player = testObj[16]; // Change this Line

Adam Faraj
@adamfaraj
Jun 11 2017 10:18
can someone help me
mithun
@dmithun
Jun 11 2017 10:18
var myStr = "<a href='http://www.example.com' target="_blank">Link</a>";
like this @adamfaraj
Adam Faraj
@adamfaraj
Jun 11 2017 10:18
@dmithun i think so
mithun
@dmithun
Jun 11 2017 10:19
i tried, it also didn't work
Adam Faraj
@adamfaraj
Jun 11 2017 10:19
@dmithun what are you trying to do
mihaiIamandi
@mihaiIamandi
Jun 11 2017 10:20
Please help I dont know how to acces the number please help me!

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

// Only change code below this line;

var playerNumber = testObj["Montana"]; // Change this Line
var player = testObj[16]; // Change

David Shin
@datadaveshin
Jun 11 2017 10:21
var myStr = "<a href='http://www.example.com' target="\_blank\">Link</a>";
Kelechi Chinaka
@ke1echi
Jun 11 2017 10:21
am ok man @Lumexralph
David Shin
@datadaveshin
Jun 11 2017 10:21
yeah, need to know what you are trying to do @dmithun
Kelechi Chinaka
@ke1echi
Jun 11 2017 10:21
was the test difficult @Lumexralph
Ogundele Olumide
@Lumexralph
Jun 11 2017 10:22
@mihaiIamandi i told you earlier to assign 16 to playerNumber
Adam Faraj
@adamfaraj
Jun 11 2017 10:22
oh dang. yeah. you need to escape the the quotes
David Shin
@datadaveshin
Jun 11 2017 10:23
var myStr = "<a href='http://www.example.com' target="\"_blank\"">Link</a>";
should escape quotes
Adam Faraj
@adamfaraj