These are chat archives for FreeCodeCamp/HelpJavaScript

4th
Mar 2017
Stephen James
@sjames1958gm
Mar 04 2017 00:00
@yassbetch The object should have properties matching the cases and values that match the assignment strings.
Jason Luboff
@JLuboff
Mar 04 2017 00:00
@forkerino Night!
@HeebieGeeBee Started to. I'm just starting my Simon game but decided yesterday to start on backend. Only got through the first npm lesson
HeebieGeeBee
@HeebieGeeBee
Mar 04 2017 00:01
cool npm is pretty easy
learnyounode is a bit harder
Jameel Matin
@cutiepatootiebear
Mar 04 2017 00:02
@sjames1958gm
var lookup = {
"alpha" = "Adams";
}
HeebieGeeBee
@HeebieGeeBee
Mar 04 2017 00:02
but havent been able to sit down and do them
Yevhenii Kushvid
@Yevhenii-Kushvid
Mar 04 2017 00:02
@sjames1958gm ty)
CamperBot
@camperbot
Mar 04 2017 00:02
yevhenii-kushvid sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6133 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Jason Luboff
@JLuboff
Mar 04 2017 00:02
@HeebieGeeBee I got stuck a litle bit but made it through. Some of the instructions in the tutorial were a little unclear at times
Stephen James
@sjames1958gm
Mar 04 2017 00:02
@yassbetch no ';' but comma
Jameel Matin
@cutiepatootiebear
Mar 04 2017 00:02
oh got it:) thanks @sjames1958gm
CamperBot
@camperbot
Mar 04 2017 00:02
yassbetch sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6134 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Adam
@GoingAllTheWayUp
Mar 04 2017 00:02
@sjames1958gm for sure imo also.. but in the case of .reduce() would we use prev and next parameters and just do some comparisons?
HeebieGeeBee
@HeebieGeeBee
Mar 04 2017 00:02
@JLuboff yeah get even more confusing with the node ones
Adam
@GoingAllTheWayUp
Mar 04 2017 00:03
Anyone useing the linux bash in windows 10?
Stephen James
@sjames1958gm
Mar 04 2017 00:03
@GoingAllTheWayUp I guess prev and curr could be the arrays passed in.
Adam
@GoingAllTheWayUp
Mar 04 2017 00:04
@sjames1958gm is it passing arrays or values?
Jason Luboff
@JLuboff
Mar 04 2017 00:04
@HeebieGeeBee Fun... heh I should be able to get through it though.. its just linux/unix command line which I've dealt with before
Adam
@GoingAllTheWayUp
Mar 04 2017 00:04
im lost with reduce() sorry
Stephen James
@sjames1958gm
Mar 04 2017 00:04
If you convert arguments into an array of arrays, then reduce the outer array
AJ
@DracIdea
Mar 04 2017 00:04
Hey guys
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var x = 0; x < contacts.length; x++){
    // contacts[i] can be turned into a variable for easier access
    var profile = contacts[x];
        // Check to see if the profile is correct based on the firstName value
    if (profile.firstName === firstName) {
      // Check to see if prop exists within the profile
        if (profile.hasOwnProperty(prop)) {
        return profile[prop];
            } else {
                return "No such property";                           
            }  

    }
  return "No such contact"; 
}




  // Only change code above this line
}
HeebieGeeBee
@HeebieGeeBee
Mar 04 2017 00:04
@JLuboff the commands isnt the issue its trying to figure out what functions theyre actually asking you to create
AJ
@DracIdea
Mar 04 2017 00:05
Would anyone be able to tell me why this isn't passing
Jason Luboff
@JLuboff
Mar 04 2017 00:05
@HeebieGeeBee Ah. Ya..that will be tricky I'm sure
HeebieGeeBee
@HeebieGeeBee
Mar 04 2017 00:05
@DracIdea return no such contact outside the loop
Jameel Matin
@cutiepatootiebear
Mar 04 2017 00:06
@sjames1958gm Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.
// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
  var lookup = {
    "alpha": "Adams",
    "bravo": "Boston",
    "charlie": "Chicago",
    "delta": "Denver",
    "echo": "Easy",
    "foxtrot": "Frank"    
  };
AJ
@DracIdea
Mar 04 2017 00:06
@HeebieGeeBee OK, let me give that a try
Stephen James
@sjames1958gm
Mar 04 2017 00:07
@yassbetch Now use that object and the property in val to set result
gitstuffedm8
@gitstuffedm8
Mar 04 2017 00:07
hi guys here is a question - regarding "Sort Arrays with sort" ... it says "If no compare (callback) function is passed in, it will convert the values to strings and sort alphabetically." does this mean if i want to compare items in the array, i would nee to implement an if statement of some kind in the function? (this is not a question about how to pass the challenge btw, just a query regarding this sorting method)
AJ
@DracIdea
Mar 04 2017 00:07
@HeebieGeeBee That was all it was. Thanks!
CamperBot
@camperbot
Mar 04 2017 00:07
dracidea sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 943 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Mar 04 2017 00:07
yw
icodeyouso
@icodeyouso
Mar 04 2017 00:08
currently participating in a sony experia hackathon (a new sony projector app that runs off android)android we all know is written in java. i have yet to learn java so when it comes to trying to write the code in a js framework or library ,would anyone recommend react native js or is there any others that are more
HeebieGeeBee
@HeebieGeeBee
Mar 04 2017 00:08
@gitstuffedm8 an if statement isnt neccessary in the callback
if thats what youre asking
icodeyouso
@icodeyouso
Mar 04 2017 00:08
that are less complicated
gitstuffedm8
@gitstuffedm8
Mar 04 2017 00:09
@HeebieGeeBee so what would be the use of a compare function in there? just curious is all
Stephen James
@sjames1958gm
Mar 04 2017 00:09
@gitstuffedm8 If you can return <0, 0, >0 without and if then no. So likely if you are doing numeric sort then no if but any other would require an if
Jameel Matin
@cutiepatootiebear
Mar 04 2017 00:09
@sjames1958gm kinda confused on what you meant by "property in val to set result"
Stephen James
@sjames1958gm
Mar 04 2017 00:10
@yassbetch https://www.freecodecamp.com/challenges/accessing-objects-properties-with-variables
The parameter/variable val has a property name that you use to find the correct property value in lookup
gitstuffedm8
@gitstuffedm8
Mar 04 2017 00:10
@HeebieGeeBee ahh i see, ok i will play around with it. Thanks!
CamperBot
@camperbot
Mar 04 2017 00:10
gitstuffedm8 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 944 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Mar 04 2017 00:11
@gitstuffedm8 that was @sjames1958gm but youre welcome
Stephen James
@sjames1958gm
Mar 04 2017 00:11
@gitstuffedm8 If you wanted sort an array of objects by the last name property you would need a function that accesses the property
gitstuffedm8
@gitstuffedm8
Mar 04 2017 00:12
woops sorry my mistake! but thanks for the explanationg @sjames1958gm much appreciated (y)
CamperBot
@camperbot
Mar 04 2017 00:12
gitstuffedm8 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6135 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Alejandro López Almeida
@raky291
Mar 04 2017 00:12
someone can explain me the gridland metro algorithm ?
HeebieGeeBee
@HeebieGeeBee
Mar 04 2017 00:14
@JLuboff someone is actually live on the FCC youtube doing backend speed runs at the moment
Jason Luboff
@JLuboff
Mar 04 2017 00:15
@HeebieGeeBee Speed runs eh?
HeebieGeeBee
@HeebieGeeBee
Mar 04 2017 00:15
apperently so
Jason Luboff
@JLuboff
Mar 04 2017 00:17
@HeebieGeeBee Well thats pretty cool
HeebieGeeBee
@HeebieGeeBee
Mar 04 2017 00:18
yeah cant be watching it now, might watch it some other time though
Jason Luboff
@JLuboff
Mar 04 2017 00:19
Ya it'll porobably be more worthwhile to watch when I get to those project as well
Adam
@GoingAllTheWayUp
Mar 04 2017 00:19
https://www.freecodecamp.com/challenges/sorted-union takes one parameter in this case, and it passes an array with a variable number of arrays within it. How do we obtain multiple arguments from this parameter?
HeebieGeeBee
@HeebieGeeBee
Mar 04 2017 00:20
@JLuboff yeah
@GoingAllTheWayUp using arguments?
Moisés Man
@moigithub
Mar 04 2017 00:22
@GoingAllTheWayUp read the "helpful links" on the instructions
Adam
@GoingAllTheWayUp
Mar 04 2017 00:23
yeah its passing ([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8]) and the likes of ([1, 2, 3], [5, 2, 1]) as one parameter but i need multiple arguments one for each internal array
Adam
@GoingAllTheWayUp
Mar 04 2017 00:26
yeah, I did not want to have to set each argument, I want to break down the arr as it enters the function, but I see now
Jameel Matin
@cutiepatootiebear
Mar 04 2017 00:34
@sjames1958gm man, i am just not getting it

// 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"    
  };
  val = lookup.result.charlie;
Lucas Scalzo
@Lu314
Mar 04 2017 00:39
Hey I need help
#134 I only have var remainder= 2;
idk where 11%3 fits in the syntax
Jason Luboff
@JLuboff
Mar 04 2017 00:41
@Lu314 You should have var remainder = 11%3 javascript will do the math
Lucas Scalzo
@Lu314
Mar 04 2017 00:42
@JLuboff thats all??
Jason Luboff
@JLuboff
Mar 04 2017 00:42
Yes
Lucas Scalzo
@Lu314
Mar 04 2017 00:42
aw ok
Stephen James
@sjames1958gm
Mar 04 2017 00:43
@yassbetch val is input so don't assign to it.
result = lookup[val]
Lucas Scalzo
@Lu314
Mar 04 2017 00:44
thanks
Stephen James
@sjames1958gm
Mar 04 2017 00:44
@GoingAllTheWayUp Use Array.from to convert arguments to an Array (of arrays) and then do reduce on that array.
Jameel Matin
@cutiepatootiebear
Mar 04 2017 00:45
@sjames1958gm Thanks, what mental image was I not grapsing you think?
CamperBot
@camperbot
Mar 04 2017 00:45
yassbetch sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: yassbetch already gave sjames1958gm points
Jameel Matin
@cutiepatootiebear
Mar 04 2017 00:45
or concept was I not grasping to better have a mental image?
Joseph
@revisualize
Mar 04 2017 00:45
Hi.
Jason Luboff
@JLuboff
Mar 04 2017 00:47
@revisualize Hey
Joseph
@revisualize
Mar 04 2017 00:48
I'm tired.
Jason Luboff
@JLuboff
Mar 04 2017 00:48
Quitting time in 12 minutes
Joseph
@revisualize
Mar 04 2017 00:48
I'm leaving in about 2
Jason Luboff
@JLuboff
Mar 04 2017 00:48
I have to get these stupid database rebuilds going
And my server is running like shit.
Simon
@smnshulgan
Mar 04 2017 00:49
hey guys is it possible to use str.toUpperCase() to just capitalize the first letter
Anon
@MikeyZee
Mar 04 2017 00:50
Hey everyone, I'm working on a school assignment to create such an easy and simple game and I'm stuck. I'm attempting to create a global variable to use in multiple functions within JavaScript. When I call the variable in the first function it recognises it, but when I do the same in my second function it states the variable is undefined, why can it not receive the same value as the first function?
Thank you all :smiley:
Joseph
@revisualize
Mar 04 2017 00:50
@smnshulgan Yes.
@MikeyZee Got code?
Simon
@smnshulgan
Mar 04 2017 00:50
@revisualize would it be .toUpperCase(0); ?
Joseph
@revisualize
Mar 04 2017 00:50
@smnshulgan No.
Simon
@smnshulgan
Mar 04 2017 00:50
@revisualize Any links to where i can read about it?
Jason Luboff
@JLuboff
Mar 04 2017 00:51
@smnshulgan Yes and no. strings are immutable, you can't use it in place...you need to actually replace it
Joseph
@revisualize
Mar 04 2017 00:51

@smnshulgan Look..

var str = "hello";

How do you access the first letter of the string?

str[0]
Simon
@smnshulgan
Mar 04 2017 00:51
dang i forgot by now how to do it
ok
Anon
@MikeyZee
Mar 04 2017 00:51
The code is in my repo, if you could have a look ? I'm on an iPad so I don't believe I can display the code
Joseph
@revisualize
Mar 04 2017 00:52
You then can use .toUpperCase() on str[0] and then assign that value to whatever you need to assign it to.
Adam
@GoingAllTheWayUp
Mar 04 2017 00:52
@sjames1958gm thanks, im looking
CamperBot
@camperbot
Mar 04 2017 00:52
goingallthewayup sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6136 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Jason Luboff
@JLuboff
Mar 04 2017 00:52
@MikeyZee Without seeing the code...its hard to determine..
Joseph
@revisualize
Mar 04 2017 00:52
@smnshulgan But, as @JLuboff stated... Strings are immutable. So, you can't just use that method call to make the first character uppercase
You can make the first char uppercase and append the rest of the characters.
Anon
@MikeyZee
Mar 04 2017 00:53
Yea that is fair enough, ok I'll grab my laptop later on and hopefully someone can have a look, thankyou anyway :)
Joseph
@revisualize
Mar 04 2017 00:54
@MikeyZee The scope process should look up the chain to find the variable.
Jason Luboff
@JLuboff
Mar 04 2017 00:55
Adios
Joseph
@revisualize
Mar 04 2017 00:55
:v:
I think I'm going to go see what I can see at Comicon.
(I don't really have a ticket. So, I'll just be walking around in the public area.)
:eyes:
:woman:
:eyes:
Simon
@smnshulgan
Mar 04 2017 01:03
ok so i have an array and its split into strings that are all in caps
how can i only toLowerCase() all but the first characters
Manish Giri
@Manish-Giri
Mar 04 2017 01:05
@smnshulgan fetch the first character
use .toLowerCase() on it
Simon
@smnshulgan
Mar 04 2017 01:05
fetch?
like str[0]?
MartinaMF
@MartinaMF
Mar 04 2017 01:05

var count = 0;

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

if(card >= 2 && card<= 6){
count ++;
return '"' + count +"\u00A0"+ "Bet" + '"';

}
else if(card>=7&&card<=9){
return '"' + count +"\u00A0"+ "Bet" + '"';
}
else if (card==10 || card=='J' || card=='Q' || card=='K' || card=='A'){
count--;
return '"' + count +"\u00A0"+ 'Hold' + '"';

}
return "Change Me";

}

// Only change code above this line

// Add/remove calls to test your function.
// Note: Only the last will display
cc(10);

Simon
@smnshulgan
Mar 04 2017 01:06
for(var i = 0; i < array.length; i++)
{
array[i] = array[i].toUpperCase().toLowerCase(array[i][0]);
}
return array;
is that how?
JohnWoodman
@JohnWoodman
Mar 04 2017 01:07
im having an issue when testing my record collection challenge. Whenever i return the entire collection. it returns the entire collection like i think its supposed to, but there is still no check mark for the one i was testing, even though I met the requirement
Gulsvi
@gulsvi
Mar 04 2017 01:08
@smnshulgan word[0] + word.substr(1).toLowerCase();
If it's all caps, leave the first letter alone and make the rest of it all lower case
Simon
@smnshulgan
Mar 04 2017 01:10
@SkyCoder01 could you explain to me what that code would do
KSV
@vicmania2007
Mar 04 2017 01:11
function booWho(bool) {
  // What is the new fad diet for ghost developers? The Boolean.

  if(bool) {
    return false;
  } else return Boolean(bool);
}
booWho(null);
Gulsvi
@gulsvi
Mar 04 2017 01:11
@smnshulgan Let's say your word is "HELLO"
word[0] is "H"
substr(1) is "ELLO"
substr(1).toLowerCase(); is "ello"
KSV
@vicmania2007
Mar 04 2017 01:12
I didnt understand Boolean objects concept at all
How will booWho([1, 2, 3]) return false?
Btw Question: Check if a value is classified as a boolean primitive. Return true or false.
Joseph
@revisualize
Mar 04 2017 01:13
@MartinaMF Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.
Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
Gulsvi
@gulsvi
Mar 04 2017 01:13
@vicmania2007 As a hint, it helps to check the type of the parameter passed to the booWho function.
Joseph
@revisualize
Mar 04 2017 01:14
@MartinaMF You're returning too early. You're also returning based on the value of the card. Not on the value of count
KSV
@vicmania2007
Mar 04 2017 01:15
@SkyCoder01 ok i can find whether it is primitive or not..
Gulsvi
@gulsvi
Mar 04 2017 01:16
Yes, by checking it's type. Giving much more of a hint than that almost gives the answer away unfortunately. :)
@vicmania2007
KSV
@vicmania2007
Mar 04 2017 01:17
i think i got it..
Gulsvi
@gulsvi
Mar 04 2017 01:17
It's more about knowledge than going through steps to solve a problem, not one of my favorites so far
Simon
@smnshulgan
Mar 04 2017 01:18
@SkyCoder01 ok i got it to lower case everything but the first character, how can i still keep the first character though
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 01:18

hi @SkyCoder01 and @revisualize Im working on Smallest common multiple challenge. Here is my code. Can you guys guide me if Im in the right direction? ```

function smallestCommons(arr) {
var firstArg = arr[0];
var secondArg= arr[1];

var lowestCommonMultiple = (1/firstArg + 1/secondArg) (firstArg secondArg);
if((lowestCommonMultiple % firstArg === 0) && (lowestCommonMultiple %secondArg ===0)){
return lowestCommonMultiple;
}
else
{
return (lowestCommonMultiple %2) * lowestCommonMultiple;
}

}

smallestCommons([1,5]);
```

Alejandro López Almeida
@raky291
Mar 04 2017 01:18
someone can help me with gridland metro algorithm ?
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 01:18

function smallestCommons(arr) {
  var firstArg = arr[0];
  var secondArg= arr[1];

  var lowestCommonMultiple = (1/firstArg + 1/secondArg) * (firstArg * secondArg);
  if((lowestCommonMultiple % firstArg === 0) && (lowestCommonMultiple %secondArg ===0)){
    return lowestCommonMultiple;
  }
  else
    {
      return (lowestCommonMultiple %2) * lowestCommonMultiple;
    }


}


smallestCommons([1,5]);
Gulsvi
@gulsvi
Mar 04 2017 01:19
@smnshulgan Add the first letter of the word (word[0]) to the rest of the letters (substr(1))
@pshiwakoti1 I haven't finished that one yet. It looks like you'll need to use the Euclidean Algorithm to get the Greatest Common Divisor first - that's what I'm working on at the moment.
Probably lots of other ways to do it (as always)
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 01:23
oh really, ok
Joseph
@revisualize
Mar 04 2017 01:23
@pshiwakoti1 I haven't solved that lesson. I don't know the algorithm.
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 01:23
i thought i would have to find out LCM
like I did in grade 5
Simon
@smnshulgan
Mar 04 2017 01:24
@SkyCoder01 got it to work thanks
CamperBot
@camperbot
Mar 04 2017 01:24
smnshulgan sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 425 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 01:24
1/1 + 1/5 = (5 + 1)* 5
Joseph
@revisualize
Mar 04 2017 01:24
What?
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 01:24
so the LCM would be 6/5 but why its 60?
Joseph
@revisualize
Mar 04 2017 01:24
No it wouldn't.
Gulsvi
@gulsvi
Mar 04 2017 01:24
Nice @smnshulgan :)
Joseph
@revisualize
Mar 04 2017 01:25
@pshiwakoti1 1/1 + 1/5 is 1.2 ... (5 + 1) * 5 is 30
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 01:26
oh ya you are right
I missed 1/5
so how does it become smallestCommons([1,5]) to 60 then?
Gulsvi
@gulsvi
Mar 04 2017 01:27
I need another math lesson....I thought 1,5 would be 5
[1,2,3,4,5,6,7,8,9....]
[5,10,15,20,25...]
omar esmail
@o-esmail
Mar 04 2017 01:28

why this code does not work

//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

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

// Only change code above this line
}

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

Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 01:29
so [1,2,3,4,5,6,7,8,9....]
[5,10,15,20,25...] what do these arrays represent to? Im unclear about it
Joseph
@revisualize
Mar 04 2017 01:29

@o-esmail

for ( ..... ) {
    if (evaluation) {
        return "truth";
    } else {
        return "lies";
    }
 }

This exact loop.. Does not loop. Because as we know:
The return statement ends function execution and specifies a value to be returned to the function caller.
Syntax
return [[expression]];
expression
The expression to return. If omitted, undefined is returned instead.

@o-esmail Your for loop isn't looping either.
@o-esmail re-read the instructions .... Gist by revisualize / FreeCodeCamp - Profile Lookup.js
omar esmail
@o-esmail
Mar 04 2017 01:31
i figure out the right ans.
but why i can't combined the 2 for if's in one like i did
Joseph
@revisualize
Mar 04 2017 01:31
@o-esmail Because that messes up your logic.
Gulsvi
@gulsvi
Mar 04 2017 01:32
@pshiwakoti1 Those are the multiples of the numbers 1 and 5
omar esmail
@o-esmail
Mar 04 2017 01:32
could you explain more please
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 01:32
oh i see
Joseph
@revisualize
Mar 04 2017 01:32
@o-esmail run your code through www.pythontutor.com/javascript.html
revisualize @revisualize leaves.
Gulsvi
@gulsvi
Mar 04 2017 01:34
LCM(a,b) = (a*b)/GCD(a,b)
Simon
@smnshulgan
Mar 04 2017 01:34
hey guys can you help me with this

function largestOfFour(arr)
{
var great = [0,0,0,0];
for(var i = 0; i < arr.length-1; i++)
{
for(var j = 0; i < arr[i].length-1; i++)
{
if(arr[i][j]>=arr[i+1][j+1])
{
if(arr[i][j] > great)
{
great[i] = arr[i][j];
}
else{}
}
}
}
return great;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

it keeps returning [0,0,0,0]
omar esmail
@o-esmail
Mar 04 2017 01:35
@revisualize so after the first return i stops iterate ? right ?
Gulsvi
@gulsvi
Mar 04 2017 01:35
```js
Your code goes here
```
Joseph
@revisualize
Mar 04 2017 01:35
@smnshulgan run your code through www.pythontutor.com/javascript.html
Simon
@smnshulgan
Mar 04 2017 01:35
@revisualize ok i ran it now what
Joseph
@revisualize
Mar 04 2017 01:35
@smnshulgan Did you visualize each step of the process?
Simon
@smnshulgan
Mar 04 2017 01:36
do i click the forward>
nvm i got it
thanks @revisualize
CamperBot
@camperbot
Mar 04 2017 01:36
smnshulgan sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3418 | @revisualize |http://www.freecodecamp.com/revisualize
omar esmail
@o-esmail
Mar 04 2017 01:37
@revisualize anyway thanks for this site it will help me alot
CamperBot
@camperbot
Mar 04 2017 01:37
o-esmail sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3419 | @revisualize |http://www.freecodecamp.com/revisualize
omar esmail
@o-esmail
Mar 04 2017 01:37
@revisualize thanks to you
CamperBot
@camperbot
Mar 04 2017 01:37
o-esmail sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: o-esmail already gave revisualize points
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 01:44
@revisualize I found one solution on Stackoverflow. Can you please look at it?
function LCM(arr) {
  var newArr = [];

  for (var j = arr[0]; j <= arr[1]; j++) {
    newArr.push(j);
  }

  var a = Math.abs(newArr[0]);
  for (var i = 1; i < newArr.length; i++) {
    var b = Math.abs(newArr[i]),
      c = a;

    while (a && b) {
      a > b ? a %= b : b %= a;
    }
    a = Math.abs(c * newArr[i] / (a + b))
  }
  return console.log(a);
}

LCM([1, 13]);
Krishna Diamesso
@DiamessoGroup
Mar 04 2017 01:46
Hello, can i get some help
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 01:46
if I reverse the order of numbers in the array like LCM([5,1]) it gives NAN
Krishna Diamesso
@DiamessoGroup
Mar 04 2017 01:47

I am working on the profile lookup exercise for Javascript.
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i=0; i<contacts.length; i++) {
if (contacts[i].firstName == firstName) {
return contacts[i][prop];
}

if (typeof contacts[i].firstName === undefined) {
return "No such contact";
} else if (!contacts[i].hasOwnProperty) {
return "No such property";
}
}
// Only change code above this line
}

Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 01:53
hi @DiamessoGroup please surround your code with backcodes so that you get a nice code box like I did above. You have to put ticks before and after your code
Krishna Diamesso
@DiamessoGroup
Mar 04 2017 01:56
@pshiwakoti1 Thanks. i did not know that
ok let me do it now
CamperBot
@camperbot
Mar 04 2017 01:56
diamessogroup sends brownie points to @pshiwakoti1 :sparkles: :thumbsup: :sparkles:
:cookie: 283 | @pshiwakoti1 |http://www.freecodecamp.com/pshiwakoti1
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 01:57
open up your note pad copy paste the code and put code
\
backcode I men
Krishna Diamesso
@DiamessoGroup
Mar 04 2017 01:58
'''
var i;
'''
CamperBot
@camperbot
Mar 04 2017 01:58
:bulb: to format code use backticks! ``` more info
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 01:58
no not that quote
backcode which is next to 1 key
are you on a mac or pc?
Krishna Diamesso
@DiamessoGroup
Mar 04 2017 01:59
\\
var i;
\\
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 01:59
no not backslash
``
Krishna Diamesso
@DiamessoGroup
Mar 04 2017 01:59
@pshiwakoti1 what character do you use for the backcodes?
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 01:59
``
``
A010
@A010
Mar 04 2017 02:00

Hey guys I'm doing a challenge called Mutations. Can someone help me with writing the IF statement. Here is the question:
Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.

I'm trying to make the for loop continue if it's true at each letter and if it's done return true else return false. any hints???


function mutation(arr) {
 var lowerCaseOne = arr[0].toLowerCase();
 var lowerCaseTwo = arr[1].toLowerCase();
  var slitTwo = lowerCaseTwo.split('');

  for(var i = 0; i < lowerCaseTwo.length; i++){
  var ans = lowerCaseOne.indexOf(slitTwo[i]);
    if(ans != -1){

      return true;
    } else {
      return false;
    }
  }

}

mutation(["hello", "hey"]);
Krishna Diamesso
@DiamessoGroup
Mar 04 2017 02:00
var i;
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:00
yes you got it
Krishna Diamesso
@DiamessoGroup
Mar 04 2017 02:01

//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

  /*if (typeof firstName === undefined) {
    return "No such contact";
  } 

  if (!contacts[i].hasOwnProperty) {
    return "No such property";
  }*/
}

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("bob", "likes");
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:01
hi @revisualize are you there?
Krishna Diamesso
@DiamessoGroup
Mar 04 2017 02:02
It is first asking for a function that check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:03
looks like experts are busy right now
David Kang
@d-kang
Mar 04 2017 02:04
@simon in your j loop yo have i++\
fahdi-dev
@fahdi-dev
Mar 04 2017 02:04
question: so contact is an object or an array?
im a new developer coming from java
so im a bit new to javascript
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:05
@fahdi-dev im a java developer too
how far did you do the exercises, what rank number are you in
David Kang
@d-kang
Mar 04 2017 02:05
@simon ooops i just opened the chatroom and your question showed up. i guess it took a min to update the new messages
fahdi-dev
@fahdi-dev
Mar 04 2017 02:06
im on exercise 214.. profile lookup
Robert Richey
@0x0936
Mar 04 2017 02:06
@DiamessoGroup after verifying the current contact's first name, you must then check if it has the property prop. if not, return no such property. only after the loop ends can you know for sure if there is no such contact
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:06
oh ok you have done great @fahdi-dev
fahdi-dev
@fahdi-dev
Mar 04 2017 02:06
im still a bit confused on how javascript handles objects
i did the exercises up until this point but i just need some clarification
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:06
same heere
Manish Giri
@Manish-Giri
Mar 04 2017 02:06
@fahdi-dev question?
fahdi-dev
@fahdi-dev
Mar 04 2017 02:07
so in this exercise,, is the contacts variable referring to an object or to an array?
Manish Giri
@Manish-Giri
Mar 04 2017 02:07
array
David Kang
@d-kang
Mar 04 2017 02:07
@fahdi-dev the contacts is an object
Robert Richey
@0x0936
Mar 04 2017 02:07
contacts is an array
Manish Giri
@Manish-Giri
Mar 04 2017 02:07
@d-kang how so?
fahdi-dev
@fahdi-dev
Mar 04 2017 02:07
i was thinking its an array as well, but the code i wrote is apparently wrong
David Kang
@d-kang
Mar 04 2017 02:08
@Manish-Giri because everything is an object
Manish Giri
@Manish-Giri
Mar 04 2017 02:08
he didn't ask that.
he's trying to get the basics right
fahdi-dev
@fahdi-dev
Mar 04 2017 02:08
@Manish-Giri yes, im trying to understand the basics
Manish Giri
@Manish-Giri
Mar 04 2017 02:08
@fahdi-dev show what you have
fahdi-dev
@fahdi-dev
Mar 04 2017 02:09
how do i do that?
Julia
@juliasjoberg
Mar 04 2017 02:09

Trying to solve the counting cards challenge..

var count = 0;

function cc(card) {
// Only change code below this line
if (card >= 2 && card <= 6) {
count += 1 + " Bet";
} else if (card >= 7 && card <= 9) {
count += " Hold";
} else {
count -= 1 + " Hold";
}

return "count";
// Only change code above this line
}

Manish Giri
@Manish-Giri
Mar 04 2017 02:09
@juliasjoberg you're merging a few things
inside the if statements, you should just increment or decrement count
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:09
@juliasjoberg you may want to surround your code with `` before and after the codes so that you get nice box with code visualization
Manish Giri
@Manish-Giri
Mar 04 2017 02:10
then, depending on what the value of count is, you should return count along with the string bet or hold
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:10
backcodes
Manish Giri
@Manish-Giri
Mar 04 2017 02:10
@juliasjoberg
Julia
@juliasjoberg
Mar 04 2017 02:11
@Manish-Giri hmm ok.. not quite sure how I'm meant to do it still. But will give it another go.
@pshiwakoti1 ok thanks, will do that next time!
CamperBot
@camperbot
Mar 04 2017 02:11
juliasjoberg sends brownie points to @pshiwakoti1 :sparkles: :thumbsup: :sparkles:
:cookie: 284 | @pshiwakoti1 |http://www.freecodecamp.com/pshiwakoti1
Gulsvi
@gulsvi
Mar 04 2017 02:12
Why does the Smallest Common Multiples challenge expect smallestCommons([1, 5]) = 60? Shouldn't it be 5? I can't figure this one out for some reason...
Wolfram Alpha agrees
fahdi-dev
@fahdi-dev
Mar 04 2017 02:13
@Manish-Giri here is my code
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0; i< contacts.length; i++){
if(contacts[i][0] == firstName){
for(var j =0; j < contacts[i].length; j++){
if(contacts[i][j] == prop){
return contacts[i][j];
}else{
return "No such property";
}
}
}
return "No such contact";
}
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:13
@SkyCoder01 im on the same challenge
Manish Giri
@Manish-Giri
Mar 04 2017 02:13
@juliasjoberg here's some pseudocode to help you -
function cc(card) {
// Only change code below this line
if (card >= 2 && card <= 6) {
 //increment count by 1
} else if (card >= 7 && card <= 9) {

} else {
 //decrement count by 1
}

// if count is greater than  0 - return count and "Bet"
// else - return count and "Hold"
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:13
@SkyCoder01 Im not sure what this algorithm is
i thought LCM(1,5) would be 6/5
how its 60 i have no idea
Manish Giri
@Manish-Giri
Mar 04 2017 02:14

@fahdi-dev see here

var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];

this is the contacts array, each element in the array is an object.

it's not a nested array, so you shouldn't try to do contacts[i][j]
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:14
I found a solution on Stackoverflow and posted above @SkyCoder01
Gulsvi
@gulsvi
Mar 04 2017 02:14
It should be LCM(a,b) = (a*b)/GCD(a,b)
fahdi-dev
@fahdi-dev
Mar 04 2017 02:15
@Manish-Giri ahhhh i got it!.. thanks, i was assuming it was a nested array!
CamperBot
@camperbot
Mar 04 2017 02:15
fahdi-dev sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4572 | @manish-giri |http://www.freecodecamp.com/manish-giri
fahdi-dev
@fahdi-dev
Mar 04 2017 02:15
thanks
Manish Giri
@Manish-Giri
Mar 04 2017 02:15
@fahdi-dev welcome
Gulsvi
@gulsvi
Mar 04 2017 02:15
GCD(1,5) = 1, so LCM(1,5) = 5/1 = 5
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:16
i thought LCM(1,5) would be 1/1 + 1/5 = 6/5
Pedro La Rosa D. (Luigi Doganieri)
@luigi055
Mar 04 2017 02:16
Hello! i'm looking for a react user that could help me with something plz. private
Gulsvi
@gulsvi
Mar 04 2017 02:17
A multiple of a whole number can't be a fraction
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:17
well thats what I studied in grade 5
Manish Giri
@Manish-Giri
Mar 04 2017 02:17
@luigi055 you can post here..
Pedro La Rosa D. (Luigi Doganieri)
@luigi055
Mar 04 2017 02:17
ok
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:18
lcm is the reciprocal of the number isn't it?
Pedro La Rosa D. (Luigi Doganieri)
@luigi055
Mar 04 2017 02:18
```
Gulsvi
@gulsvi
Mar 04 2017 02:18
They give us this help page: https://www.mathsisfun.com/least-common-multiple.html
And explain that the LCM of 3,5 is 15. LCM(3,5) = (3*5)/GCD(3,5) = 15/1 = 15
Adel
@AdelMahjoub
Mar 04 2017 02:18
can I have somme feedbacks please ? https://zombies-flood.surge.sh/
Pedro La Rosa D. (Luigi Doganieri)
@luigi055
Mar 04 2017 02:19
import React, { Component } from 'react';

export default function (enhacedComponent) {
  class Authenticate extends Component {
    constructor(props) {
      super(props);
    }

    render() {
      return <enhacedComponent {...this.props} />;
    }
  }

  return Authenticate;
}
Gulsvi
@gulsvi
Mar 04 2017 02:19
@pshiwakoti1 Maybe you're thinking of denominators and numerals?
Pedro La Rosa D. (Luigi Doganieri)
@luigi055
Mar 04 2017 02:19
a need help with that code using react. is a higher order component
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:19
maybe @SkyCoder01
Pedro La Rosa D. (Luigi Doganieri)
@luigi055
Mar 04 2017 02:19
when i try to wrap any other component it always return <enhacedComponent></enhacedComponent> in the html inspector in console
idk what i am doing wrong
Gulsvi
@gulsvi
Mar 04 2017 02:20
I'll skip this one for now
Pedro La Rosa D. (Luigi Doganieri)
@luigi055
Mar 04 2017 02:20
can anyone help me?
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:20
@SkyCoder01 do you think I should use the solution that was found on Stackoverflow?
Julia
@juliasjoberg
Mar 04 2017 02:21

@Manish-Giri

`var count = 0;

function cc(card) {
// Only change code below this line
if (card >= 2 && card <= 6) {
count += 1;
} else if (card >= 7 && card <= 9) {

} else {
count -= 1;
}

if (card > 0) {
return count + "Bet";
} else {
return count + "Hold";
}
// Only change code above this line
}`

Not sure what I'm doing wrong... any more tips?

Gulsvi
@gulsvi
Mar 04 2017 02:21
@pshiwakoti1 no lol
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:21
lol
Manish Giri
@Manish-Giri
Mar 04 2017 02:21
@juliasjoberg add spaces
Gulsvi
@gulsvi
Mar 04 2017 02:21
Better to learn by coming up with it on your own I think
Manish Giri
@Manish-Giri
Mar 04 2017 02:21
return count + "Hold"; and return count + "Bet";
here
@juliasjoberg
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:22
@SkyCoder01 the algorithm doesn't make sense to me what it is asking for
Lets say multiple of 1 are 1,2,3,4....
and multiple of 5 are 5,10,15,20,25,30,35,40,45,50,55,60
where does it say which multiple i common to both?
how it is 60?
Manish Giri
@Manish-Giri
Mar 04 2017 02:24
lowest
Julia
@juliasjoberg
Mar 04 2017 02:24
@Manish-Giri Ofc, thanks! It still fails the test on
"Cards Sequence 7, 8, 9 should return "0 Hold" though.. any ideas?
CamperBot
@camperbot
Mar 04 2017 02:24
juliasjoberg sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4574 | @manish-giri |http://www.freecodecamp.com/manish-giri
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:25
@Manish-Giri will you plz explain
Manish Giri
@Manish-Giri
Mar 04 2017 02:26
@pshiwakoti1 which is the lowest multiple of 5 that is also a multiple of 1?
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:26
5
Manish Giri
@Manish-Giri
Mar 04 2017 02:26
@juliasjoberg post your challenge url here, click "run tests" first
@pshiwakoti1 so that's your answer
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:27
@Manish-Giri the answer is 60
how did that become 60?
fahdi-dev
@fahdi-dev
Mar 04 2017 02:27
@pshiwakoti1 you said you were a java dev? how do you like javascript compared to java?
Manish Giri
@Manish-Giri
Mar 04 2017 02:27
@pshiwakoti1 I was talking about 1 and 5
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:27
@fahdi-dev im liking it. I still don't know many things
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:28
yes @Manish-Giri the smallestCommons([1, 5]) should return 60.
Manish Giri
@Manish-Giri
Mar 04 2017 02:29
@juliasjoberg this is wrong
if (card > 0) {
    return count + " Bet";
  }
you want to check the count variable, not card
fahdi-dev
@fahdi-dev
Mar 04 2017 02:30
@pshiwakoti1 i actually prefer java
Julia
@juliasjoberg
Mar 04 2017 02:30
@Manish-Giri Ah, of course! Passed now, thanks a lot!
CamperBot
@camperbot
Mar 04 2017 02:30
juliasjoberg sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: juliasjoberg already gave manish-giri points
Manish Giri
@Manish-Giri
Mar 04 2017 02:30
@juliasjoberg :+1:
Christopher aka Pencho
@penchochris
Mar 04 2017 02:30
good evening guys!
Seth
@sethdcd
Mar 04 2017 02:31
hello, how can i reactivate a page to share geolocation if i accidently selected never share location? i deleted cookies but it's still not coming up :(
Manish Giri
@Manish-Giri
Mar 04 2017 02:31

@pshiwakoti1 the problem is not to find the LCM

Find the smallest common multiple of the provided parameters that can be evenly divided by both, as well as by all sequential numbers in the range between these parameters.

Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:32
@fahdi-dev I have been learning java almost 2 decades but I still don't know many things in Java. But I decided to learn front end stuffs as well like CSS, Javascript, HTML5 and Im liking it a lot
Christopher aka Pencho
@penchochris
Mar 04 2017 02:32
I'm doing "Check for Palindromes" problem with this code:
function palindrome(str) {
  str = str.replace(/[&\/\\#,+()_\s$~%.'":*?<>{}]/g,'');
  str.toLowerCase();
  var strRev = str.split('').reverse().join('');

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

}
palindrome("eye");
any one knows why is not working?
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:33
@Manish-Giri actually you are right, how to find the number that is evenly divisible and by all sequential numbers in the range
fahdi-dev
@fahdi-dev
Mar 04 2017 02:33
@pshiwakoti1 i am in university right now, and most of my base courses have been in java, C++ , Python, and C#...im going to be taking a web development class next semester, i am using free code camp to prepare for that
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:35
@fahdi-dev you did the right thing. U will be certified by university and FCC both
@Manish-Giri will you please suggest the algorithm involved in Small Common Multiple challenge
fahdi-dev
@fahdi-dev
Mar 04 2017 02:39
@pshiwakoti1 thanks!
CamperBot
@camperbot
Mar 04 2017 02:39
fahdi-dev sends brownie points to @pshiwakoti1 :sparkles: :thumbsup: :sparkles:
:cookie: 285 | @pshiwakoti1 |http://www.freecodecamp.com/pshiwakoti1
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:44
@Manish-Giri are you there?
rsenter1993
@rsenter1993
Mar 04 2017 02:44
Hello all!
I'm stuck on this lesson.

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

fahrenheit = 9/5 +32;

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

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

trying to converto -30 and have a value return
fahdi-dev
@fahdi-dev
Mar 04 2017 02:46
farenheit = celcisus (9/5) +32
@rsenter1993
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:46
@rsenter1993 please surround your code with back codes
``
so that you get the code visualization
fahdi-dev
@fahdi-dev
Mar 04 2017 02:47
@pshiwakoti1 how do you surround with back codes? i was wondering the same thing
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 02:47
``
``
fahdi-dev
@fahdi-dev
Mar 04 2017 02:47
@pshiwakoti1 ah
rsenter1993
@rsenter1993
Mar 04 2017 02:47
Okay thank you guys
gmr90
@gmr90
Mar 04 2017 02:51

var str1="";
function repeatStringNumTimes(str, num) {
// repeat after me
if(num >0){
for(var i =0;i <num ;i++){
str1 += str;

     }     
   return str1;
}
else{
    return "";
}
//console.log(str1);

// str1 = '"'+str1+'"';
// return str1;

}

repeatStringNumTimes("*", 3);

i getting output but not taking this code . can you please help me
rsenter1993
@rsenter1993
Mar 04 2017 02:55
Can I get some help with this code?

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

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

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

I keep getting a message saying celsius is not a function
eyesore-
@eyesore-
Mar 04 2017 02:57
@rsenter1993 Look at fahrenheit = celsius (9/5) +32; The way you have it you are calling celsius with argument 9/5
@rsenter1993 You need to rewrite that line.
gmr90
@gmr90
Mar 04 2017 02:58
fahrenheit = celsius *(9/5) +32;
eyesore-
@eyesore-
Mar 04 2017 02:58
Don't just give him the answer /:
gmr90
@gmr90
Mar 04 2017 02:59
mybad
Tolga Dur
@tolgadur
Mar 04 2017 03:00

function whatIsInAName(collection, source) {
// Only change code below this line
var search = Object.keys(source);
function x (obj){
for(var i = 0; i < search.length; i++){
if(!obj.hasOwnProperty(search[i]) || obj[search[i]] !== source[search[i]]){
return false;
}
return true;
}
}

//Only change code above this line
return collection.filter(x);

This doesn't pass all tests
why?
rsenter1993
@rsenter1993
Mar 04 2017 03:00
Thank you for the helps guys. When I do any 9/5 does it need to be in ()?
Tolga Dur
@tolgadur
Mar 04 2017 03:00
for the "Wherefore art thou" challenge
eyesore-
@eyesore-
Mar 04 2017 03:00
@tolgadur is this the one you were working on last night?
Tolga Dur
@tolgadur
Mar 04 2017 03:01
even though the results are the same
gmr90
@gmr90
Mar 04 2017 03:02
@rsenter1993 r1993 . you can do that. but with celcius(9/5). it treat it as function
zhen zeng
@zengyanzi
Mar 04 2017 03:03
HI
eyesore-
@eyesore-
Mar 04 2017 03:03
Sup
zhen zeng
@zengyanzi
Mar 04 2017 03:03
is there anybody read the code of Seek and Destroy,please?
eyesore-
@eyesore-
Mar 04 2017 03:04
@tolgadur what are you failing?
rsenter1993
@rsenter1993
Mar 04 2017 03:04
Oh okay so the () are a way to Indicate it as a function. Thank you for letting me know
zhen zeng
@zengyanzi
Mar 04 2017 03:05
it is to hard for me to figure out
eyesore-
@eyesore-
Mar 04 2017 03:05
@rsenter1993 Not necessarily, but it is the way you invoke a function.
@rsenter1993 when you write say hi() you are telling the compiler to invoke a function named hi
badalsaibo
@heyDante
Mar 04 2017 03:06
Hey guys, do you know how to generate random non-repetitive numbers in JS?
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 03:06
has anybody done Finders and Keepers??
gmr90
@gmr90
Mar 04 2017 03:07
blob
@eyesore- can you please help out on this
eyesore-
@eyesore-
Mar 04 2017 03:07
@heyDante You could have a storage to check which numbers have already been generated.
@gmr90 Yeah, what lesson is it for?
gmr90
@gmr90
Mar 04 2017 03:08
Repeat a string repeat a string Incomplete   
i got the output but it is not taking ,still showing x mark
Tolga Dur
@tolgadur
Mar 04 2017 03:09
I am failing the last two tests
@eyesore- yes it's the one from last night. I couldn't read the responses last night though
eyesore-
@eyesore-
Mar 04 2017 03:10
@gmr90 Which one are you failing.
@tolgadur I'll help you out right now.
Prakash Shiwakoti
@pshiwakoti1
Mar 04 2017 03:10
anyone suggest me with Finders and Keepers?
gmr90
@gmr90
Mar 04 2017 03:10
@eyesore all except last one
Edgar Pan
@edgaryp
Mar 04 2017 03:12
Hi, why 8 is returned?
function foo(){
    function bar() {
        return 3;
    }
    return bar();
    function bar() {
        return 8;
    }
}
alert((foo));
gmr90
@gmr90
Mar 04 2017 03:13
@edgaryp because you called the function bar()
eyesore-
@eyesore-
Mar 04 2017 03:13
@gmr90 You are never declaring str1
gmr90
@gmr90
Mar 04 2017 03:14
@eyesore- var str1 = "" declared globally
Edgar Pan
@edgaryp
Mar 04 2017 03:14
@gmr90 why it doesn't return 3 since return is before second bar function
eyesore-
@eyesore-
Mar 04 2017 03:16
@gmr90 I didn't see that. Sorry. I don't know if that is how FCC has you do it, but best practice would be to put it in the function. You don't need to that do now though. I would suggest to get rid of your else statement by the way. After the if just return str1
@tolgadur I sent you a pm :+1:
gmr90
@gmr90
Mar 04 2017 03:18
@eyesore- thank you for your time
Seth
@sethdcd
Mar 04 2017 03:18
how can i enable geolocation on my firefox browser if i disabled it?
eyesore-
@eyesore-
Mar 04 2017 03:19
@gmr90 No problem! Let me know if you keep having issues with it. I can show you my code once you get it done as well if you'd like.
gmr90
@gmr90
Mar 04 2017 03:19
@edgaryp i'm not sure. i think it is because of stack thing or may be it take last function. ill try to figure out . let you know after sometime
eyesore-
@eyesore-
Mar 04 2017 03:20
@sethdcd You should be able to do it from the info button on the omnibar or from the developer tools. At leas that is how it is in Chrome. I'm guessing it is similar.
gmr90
@gmr90
Mar 04 2017 03:20
@eyesore- sure , i will try for sometime and then ill ask about your code.thank you !
CamperBot
@camperbot
Mar 04 2017 03:20
gmr90 sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 66 | @eyesore- |http://www.freecodecamp.com/eyesore-
eyesore-
@eyesore-
Mar 04 2017 03:20
@gmr90 No problem.
gmr90
@gmr90
Mar 04 2017 03:25
@eyesore- it went through after declaring var str1 in the function
eyesore-
@eyesore-
Mar 04 2017 03:27
@gmr90 In an actual work environment it should work whether it is in or out, but it is better practice to have it inside. You want your functions to be modular and stand on their own.
Jeff
@Garanimal
Mar 04 2017 03:27
sup everybody
gmr90
@gmr90
Mar 04 2017 03:28
@eyesore- thank you for your inputs.
CamperBot
@camperbot
Mar 04 2017 03:28
:warning: gmr90 already gave eyesore- points
gmr90 sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
eyesore-
@eyesore-
Mar 04 2017 03:29
@gmr90 Yeah, no problem!
gmr90
@gmr90
Mar 04 2017 03:36
@edgaryp function foo(){
function bar() {
console.log("hi1");
//return 8;
}
bar();
function bar() {
console.log("hi2");
//return 3;
}
function bar() {
console.log("hi3");
//return 3;
}
foo();
bar() always invoking the last function if the other are having same name. don't know exact reason.
Edgar Pan
@edgaryp
Mar 04 2017 03:38
@gmr90 I think I found the answer https://www.youtube.com/watch?v=sw49K4pxHCU
@gmr90 hoisting was happened in the function scope
acarosell1
@acarosell1
Mar 04 2017 03:40

Hello. I am looking for some advice on the "Confirm the Ending" Basic Algorithm Scripting challenge. My code passes all of the given test cases however it is not registering as so and I am not passing the challenge. Here is my code: function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
if (target === str.substr(str.length-target.length, target.length)){

return "true";}
else return "false";
}
confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain");

Margaret
@Margaret2
Mar 04 2017 03:41
@acarosell1 you're not supposed to return strings
you're supposed to return true or false, not "true" or "false"
eyesore-
@eyesore-
Mar 04 2017 03:42
What she said. It's looking for a boolean.
Ty N.
@mynameislink
Mar 04 2017 03:42
Anyone know how to make a for loop skip over even numbers and only print odd numbers in a loop?
acarosell1
@acarosell1
Mar 04 2017 03:42
@Margaret2 Yep, that could be it :) Thanks
CamperBot
@camperbot
Mar 04 2017 03:42
acarosell1 sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 1863 | @margaret2 |http://www.freecodecamp.com/margaret2
Margaret
@Margaret2
Mar 04 2017 03:42
@acarosell1 and really you could just simplify it to be:
return target === str.substr(str.length-target.length, target.length))
if you remember that from an earlier challenge ^
eyesore-
@eyesore-
Mar 04 2017 03:43
@mynameislink I got you. Do you have anything yet?
Margaret
@Margaret2
Mar 04 2017 03:43
@mynameislink can use the % operator to check if a number is even or odd
acarosell1
@acarosell1
Mar 04 2017 03:43
@eyesore- Thanks
CamperBot
@camperbot
Mar 04 2017 03:43
acarosell1 sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 67 | @eyesore- |http://www.freecodecamp.com/eyesore-
Ty N.
@mynameislink
Mar 04 2017 03:44
Ohh snap I didn't think about that @Margaret2 I'll try that!

@eyesore- So far this is what I've got:

var myArray = [];

for (var x = 0; x < 10; x++) {
myArray.push(x);
}

@eyesore- I know the [x++] part is wrong lol but I just don't know how to make it skip numbers
eyesore-
@eyesore-
Mar 04 2017 03:45
@mynameislink Yeah, just do a conditional with % like @Margaret2 said
Margaret
@Margaret2
Mar 04 2017 03:45
@mynameislink x+=2
fahdi-dev
@fahdi-dev
Mar 04 2017 03:45
@mynameislink use % operator in an if statement
Ty N.
@mynameislink
Mar 04 2017 03:45
Lol yeah the modulus almost created an inf. loop on me :P
fahdi-dev
@fahdi-dev
Mar 04 2017 03:46
@mynameislink how did it create an infinite loop?
Ty N.
@mynameislink
Mar 04 2017 03:46
The x += 2 will only print out evens though
Johnny
@jtan3
Mar 04 2017 03:46
@mynameislink start at 1 instead of 0
Ty N.
@mynameislink
Mar 04 2017 03:46

@fahdi-dev like this:

var myArray = [];

for (var x = 0; x < 10; x % 2) {
myArray.push(x);
}

fahdi-dev
@fahdi-dev
Mar 04 2017 03:46
@mynameislink add a conditional inside the for loop which pushes onto the array only if the modulo condition is met
@mynameislink no that will not work
eyesore-
@eyesore-
Mar 04 2017 03:47
^ what he said.
Ty N.
@mynameislink
Mar 04 2017 03:47
@jtan3 hey that worked!!
Lol well that was silly I didn't figure that out in the first place haha thanks everyone!
eyesore-
@eyesore-
Mar 04 2017 03:47
@mynameislink you should also check out how to check if something is even or odd. Just so you have that knowledge.
Ty N.
@mynameislink
Mar 04 2017 03:48
@eyesore- what do you mean?
eyesore-
@eyesore-
Mar 04 2017 03:49
@mynameislink you had x % 2 which doesn't really check if it's even or odd on it's own. You need a little more than that.
fahdi-dev
@fahdi-dev
Mar 04 2017 03:49
@mynameislink i think what @eyesore- means is that modulo will become more important as you go further along your programming career..for example when you will learn about hashing onto an array, you will need to understand how that works
eyesore-
@eyesore-
Mar 04 2017 03:50
That too. Is there anything in FCC on hashing?
fahdi-dev
@fahdi-dev
Mar 04 2017 03:50
@eyesore- i dont know
@eyesore- im studying CS at university, im just using FCC as a supplement to learn/ refresh on stuff
eyesore-
@eyesore-
Mar 04 2017 03:52
@fahdi-dev I was just curious. I just get on the chat to help out. I'm not very familiar with the whole FCC curriculum.
Ty N.
@mynameislink
Mar 04 2017 03:53
@fahdi-dev @eyesore- I think hashing is only with Ruby right? Bcuz 'objects' in JS work practically the same as hashes in Ruby
fahdi-dev
@fahdi-dev
Mar 04 2017 03:53
@eyesore- yeah, im just starting on this as well, i want to complete the entire curriculum by summer
eyesore-
@eyesore-
Mar 04 2017 03:53
@mynameislink you are talking about hash tables. Hashing is something you do to create a hash table, but yeah objects are technically a hash table
fahdi-dev
@fahdi-dev
Mar 04 2017 03:54
@mynameislink ive done hashing/ creating hash tables/ etc in java / c# and c++
Ty N.
@mynameislink
Mar 04 2017 03:54
@fahdi-dev hey speaking of c# and c++....do you recommend learning them?
fahdi-dev
@fahdi-dev
Mar 04 2017 03:54
@mynameislink definately
Ty N.
@mynameislink
Mar 04 2017 03:54
@fahdi-dev I mean, is it worth the know-how for a career as a web dev?
eyesore-
@eyesore-
Mar 04 2017 03:55
@mynameislink not as a web developer
Ty N.
@mynameislink
Mar 04 2017 03:55
I just know nothing about them to have a basis for judgement about them
@eyesore- That's what I'm aiming for is full stack web dev, and then learning Ruby/Rails/Python programming lang's on the side you know?
fahdi-dev
@fahdi-dev
Mar 04 2017 03:56
@mynameislink as a web developer you want to focus on stuff like HTML/CSS/ JS/ NODE/RUBY/ .NET framwork..etc etc but you should also know the basics of java, java web applet design etc etc..oh and data bases
SQL/mySQL
Mongo
Ty N.
@mynameislink
Mar 04 2017 03:57
I know a few of them in pretty good extent like HTML/CSS/JS/Ruby/Rails/jQuery/Angular/Git and all that stuff
fahdi-dev
@fahdi-dev
Mar 04 2017 03:57
learn about REST
eyesore-
@eyesore-
Mar 04 2017 03:57
@mynameislink Do you have a preference in frontend or backend? You may also want to dabble in functional language like Scala or Haskell
Ty N.
@mynameislink
Mar 04 2017 03:57
@fahdi-dev wtf is REST?? lol never heard of it
eyesore-
@eyesore-
Mar 04 2017 03:58
@mynameislink RESTful is how you call api's. There is also GraphQL
Uros Tadic
@urketadic
Mar 04 2017 03:58
Why do I have to remove my browser history (cookies etc) to be able to see UPDATE on my website?
Jason Luboff
@JLuboff
Mar 04 2017 03:58
@urketadic Becuase it is caching
Ty N.
@mynameislink
Mar 04 2017 03:58
@eyesore- I prefer the HTML5/CSS3 aspect of it all so I'd say a main focus on front-end
Jason Luboff
@JLuboff
Mar 04 2017 03:59
@urketadic Any webpage that is seen inside your network will be cached unless you specify not to..and in my experience..it still caches
Ty N.
@mynameislink
Mar 04 2017 03:59
@eyesore- But I love things like jQuery and Angular
eyesore-
@eyesore-
Mar 04 2017 03:59
@mynameislink Don't look to master any languages. Try to learn the concepts and really understand that. It will help you much more in the long run to be able to transition.
Ty N.
@mynameislink
Mar 04 2017 04:00
@eyesore- if there was one language you'd recommend for someone going full stack (but mainly front) and wanting to master a language, what would you say?
eyesore-
@eyesore-
Mar 04 2017 04:00
@mynameislink if you are working on any newer code base you are hardly ever going to deal with just poor HTML so you should be good there. Another thing to check out is Vue and React. Also for CSS you should really look into preprocessors.
Uros Tadic
@urketadic
Mar 04 2017 04:00
ooooooook
but
how do website update then
why do i see other websites update
eyesore-
@eyesore-
Mar 04 2017 04:01
@mynameislink Javascript
Jason Luboff
@JLuboff
Mar 04 2017 04:01
F5 and if it still caches, ctrl + F5
Ty N.
@mynameislink
Mar 04 2017 04:02
@eyesore- I've heard Reactjs is closely, if not nearly identical, to Angularjs though?
Ryan Santos
@ryasan86
Mar 04 2017 04:03
I have more of a theory crafting question than I do with the challenges. Say you have 3 ways to do something...just for example's sake...1. via Loop and fewer methods 2. via function methods and less loops 3. Can't think of one but you get the point lol....Does anyone else think that sticking to one way of solving a problem for a while would be more effective at first.....then trying all the different ways to approach a problem later after more experience?
Ty N.
@mynameislink
Mar 04 2017 04:03
@eyesore- I love HTML and CSS but I think you're right, I'm gonna give JS more of a chance then I have
eyesore-
@eyesore-
Mar 04 2017 04:04
@mynameislink Not completely. Angular is more involved and a full framework. It also has two way binding as React has 1 way binding. Then Angular 2 is another thing. That is more like React.
Margaret
@Margaret2
Mar 04 2017 04:04
@mynameislink definitely not identical. they are both front end javascript frameworks, but there are differences in syntax and implementation, like @eyesore said
Ryan Santos
@ryasan86
Mar 04 2017 04:04
I look up all these resources while doing challenges and many times i find many ways to do something.
Margaret
@Margaret2
Mar 04 2017 04:05
@emag50 i would say do what makes sense to you. The point is to develop your ability to think logically and solve problems
but you know, the more ways you know how to do something, the more tools in your toolbelt
eyesore-
@eyesore-
Mar 04 2017 04:06
@mynameislink no one is really going to hire you to write vanilla CSS. Look into learning a preprocessor.
Ty N.
@mynameislink
Mar 04 2017 04:06
@eyesore- @Margaret2 I think the only thing I find ridiculous is how many playable sub-libraries there are of JS itself like React, Angular, jQuery, etc
Margaret
@Margaret2
Mar 04 2017 04:06
lol yeah there are tons :D
Ty N.
@mynameislink
Mar 04 2017 04:06
@eyesore- Not to sound like the dummy in the room but, what is a preprocessor?
Ryan Santos
@ryasan86
Mar 04 2017 04:06
develop your own style? I was thinking that too....then I thought too much and went,"well years from now, if I had a more text book approach then I'd be in a better spot." but other times I do feel like it's just feel.
or drawing from experience.
Ty N.
@mynameislink
Mar 04 2017 04:07
@Margaret2 Lol so freakin many dude
Ryan Santos
@ryasan86
Mar 04 2017 04:07
but im trying to be effecient with time...that's all
so for loops 4 life
gotchya hahaha
Margaret
@Margaret2
Mar 04 2017 04:07
@mynameislink read this when you get a chance if you haven't seen it :laughing: https://hackernoon.com/how-it-feels-to-learn-javascript-in-2016-d3a717dd577f#.b130hr1wt
eyesore-
@eyesore-
Mar 04 2017 04:07
@mynameislink no worries. Have you heard of SASS or LESS? You can use variables and such.
fahdi-dev
@fahdi-dev
Mar 04 2017 04:07
@mynameislink are you learning on your own, or are you attending school as well?
for programming/CS
Ty N.
@mynameislink
Mar 04 2017 04:08
@Margaret2 Lol checking it out right meow :P
eyesore-
@eyesore-
Mar 04 2017 04:08
@mynameislink Then you also have to learn about a task runner. I personally prefer webpack, but there is also Grunt and Gulp
Ryan Santos
@ryasan86
Mar 04 2017 04:08
so many ways to do something but all it takes it mistaking a period for a comma and it's rip
Ty N.
@mynameislink
Mar 04 2017 04:09
@eyesore- No I'm a kitchen manager lol I've been "teaching myself" coding for 2 years straight now and my end-goal is to make a career out of being a programmer
Margaret
@Margaret2
Mar 04 2017 04:09
@mynameislink yeah, preprocessors allow you use different syntax and do more with CSS. main ones are Less, SCSS, PostCSS, and Stylus
eyesore-
@eyesore-
Mar 04 2017 04:09
@emag50 When you say efficient in time do you mean in your life or time complexity in your code?
fahdi-dev
@fahdi-dev
Mar 04 2017 04:09
@mynameislink good luck man!
eyesore-
@eyesore-
Mar 04 2017 04:09
@Margaret2 I'm into PostCSS and would highly recommend it.
fahdi-dev
@fahdi-dev
Mar 04 2017 04:09
@mynameislink there is a lot to learn lol
Ryan Santos
@ryasan86
Mar 04 2017 04:09
i mean just like learning anything else...more quality time than quantity
learning
Margaret
@Margaret2
Mar 04 2017 04:10
@eyesore- cool! i haven't tried it yet
Ty N.
@mynameislink
Mar 04 2017 04:10
@Margaret2 I'm also on Codecademy and learning SCSS or "SASS" but I've only just started that recently. I've been wrapping up my classes on Angular and jQuery
eyesore-
@eyesore-
Mar 04 2017 04:10
@emag50 Oh, okay. For the most part you just want to made sure you know why things happen.
Ty N.
@mynameislink
Mar 04 2017 04:10
@fahdi-dev lol beyond belief man
Margaret
@Margaret2
Mar 04 2017 04:10
i will probably start learning angular soon, right now i only know react and vue
eyesore-
@eyesore-
Mar 04 2017 04:11
@Margaret2 It's awesome because you can still use SASS, LESS, or Stylus
Vue is a mash of React and Angular.
Margaret
@Margaret2
Mar 04 2017 04:12
@emag50 re: your comment about mistaking a period for a comma - I posted this the other day :joy: :point_up: February 24, 2017 9:45 PM
Ryan Santos
@ryasan86
Mar 04 2017 04:12
yea...it's very easy to lose muscle memory with JS...i feel like it's better to practice a single punch 1000 times than to do 1000 punches 1 time k
fahdi-dev
@fahdi-dev
Mar 04 2017 04:12
@mynameislink after you learn "everything" i guess you could say... find your niche and specialize in what interests you (like app development, web, etc etc) and get reallllly good at it...theres good money :D
Ty N.
@mynameislink
Mar 04 2017 04:12
Is React worth the read? If you know what I mean that is lol
Ryan Santos
@ryasan86
Mar 04 2017 04:12
lmao its so true!
Margaret
@Margaret2
Mar 04 2017 04:13
@eyesore- yeah I agree, that's why it's awesome :smile:
eyesore-
@eyesore-
Mar 04 2017 04:13
@mynameislink Yes it is. React is going nowhere and it is widely used.
Margaret
@Margaret2
Mar 04 2017 04:14
@mynameislink yeah, React is cool. You should definitely familiarize yourself with it, even if you don't end up liking it as much as Angular
Ryan Santos
@ryasan86
Mar 04 2017 04:14
I have my linter off sometimes cuz I don't like stuff popping up on my screen out of no where and ill find a period that breaks the whole thing after 30 min into a problem
eyesore-
@eyesore-
Mar 04 2017 04:14
@mynameislink I like React much more once you start using Redux or Flux
Ty N.
@mynameislink
Mar 04 2017 04:14
@fahdi-dev lol good money would be a nice thing but, I also just want to do what I'm doing right now for example: Sitting on my balcony, drinking a gin & tonic, and coding until my face falls off lol and make money doing it (:
M Denise
@colemanallme
Mar 04 2017 04:14
Hi everyone, working on JavaScript, it seems to be so complicated.
Ryan Santos
@ryasan86
Mar 04 2017 04:14
You a proponent of Angular 2 @mynameislink
10/10 agreed @colemanallme but satisfying when it works.
Ty N.
@mynameislink
Mar 04 2017 04:15
@eyesore- I'm gonna have to check it out then it seems cool from what you guys are saying lol
@emag50 No way I actually fuckin hate Angular hahah but, gotta know it you kno? Lol
Ryan Santos
@ryasan86
Mar 04 2017 04:16
Angular 2 or 1
Ty N.
@mynameislink
Mar 04 2017 04:16
@emag50 I actually prefer jQuery even though it's stupidly out-dated
eyesore-
@eyesore-
Mar 04 2017 04:16
@mynameislink Angular and Angular 2 are WAY different.
M Denise
@colemanallme
Mar 04 2017 04:16
@emag50 I know what you mean
Ty N.
@mynameislink
Mar 04 2017 04:17
@eyesore- @emag50 I didn't know there even WAS an Angular 2??
Ryan Santos
@ryasan86
Mar 04 2017 04:17
@mynameislink i do....angular 2 and react don't have cool animations like jquery....ahhh bootstrap days
Margaret
@Margaret2
Mar 04 2017 04:17
:yellow_heart: vanilla JS
:heart: Angular
:blue_heart: React
:green_heart: Vue
:purple_heart: ???
eyesore-
@eyesore-
Mar 04 2017 04:17
Mithrol
Margaret
@Margaret2
Mar 04 2017 04:17
anybody know a purple js framework?
eyesore-
@eyesore-
Mar 04 2017 04:17
Aurelia
NaveenRathor
@NaveenRathor
Mar 04 2017 04:17

function isLess(a, b) {
// Fix this code
switch (a === b) {
case a === b:
return true;

}
return false;
}

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

Ty N.
@mynameislink
Mar 04 2017 04:17
The purple is TyEnnJS @Margaret2 lol I'm gonna create my own language on the JS backbone hahah :P
NaveenRathor
@NaveenRathor
Mar 04 2017 04:18
what's wrong in my code
Margaret
@Margaret2
Mar 04 2017 04:18
@mynameislink lol you do that bro!
Ryan Santos
@ryasan86
Mar 04 2017 04:18
@colemanallme Just keep at it!...man when I was going through basic loops I wanted to cry at first but it gets easier....well...it gets harder too but the things you're working on now gets a lot easier!
Margaret
@Margaret2
Mar 04 2017 04:18
@eyesore- oh nice ty :smile:
CamperBot
@camperbot
Mar 04 2017 04:18
margaret2 sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 68 | @eyesore- |http://www.freecodecamp.com/eyesore-
eyesore-
@eyesore-
Mar 04 2017 04:18
No problem.
@mynameislink if you want to be confused as fuck you should definitely use Backbone
fahdi-dev
@fahdi-dev
Mar 04 2017 04:19
@mynameislink hahahaha sounds like a good plan! make money drinking and typing...ahhhh :D
Margaret
@Margaret2
Mar 04 2017 04:19
if anyone is looking for a project, there's a need for chocolate JS and strawberry JS to round out vanilla JS :icecream: :chocolate_bar: :strawberry:
:trollface:
Nikhil KD
@kadyanikhil
Mar 04 2017 04:19
how to display number cause for that i need to use testObj.Montana; but still it doesnt work as challenge says to use bracket noataion. pls help.

// 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 this Line
Ty N.
@mynameislink
Mar 04 2017 04:20
Lmao @eyesore- is that another JS language?
NaveenRathor
@NaveenRathor
Mar 04 2017 04:20
what's wrong in my code

function isLess(a, b) {
// Fix this code
switch (a === b) {
case a === b:
return true;

}
return false;
}

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

eyesore-
@eyesore-
Mar 04 2017 04:20
@mynameislink Yup!
Ty N.
@mynameislink
Mar 04 2017 04:20
@fahdi-dev Lol such is the dream man :P
Margaret
@Margaret2
Mar 04 2017 04:20
@eyesore- do you think there's enough market for Backbone that it would be worthwhile to learn it
M Denise
@colemanallme
Mar 04 2017 04:20
Does anyone know of any JavaScript resources that are good to learn from?
Ty N.
@mynameislink
Mar 04 2017 04:20
@kadyanikhil you want var player to call on var playerNumber
Ryan Santos
@ryasan86
Mar 04 2017 04:20
I like Angular 2...Typescript is pretty straight forward...more object based and you can't really do cool animations like with jQuery no....next best thing is web animations js
eyesore-
@eyesore-
Mar 04 2017 04:21
@Margaret2 Not anymore. It's kind of what started it all though.
Ryan Santos
@ryasan86
Mar 04 2017 04:21
but Angular 2 is still in beta but I think final Release now
Margaret
@Margaret2
Mar 04 2017 04:21
@NaveenRathor you need to check if a is less than b, not if a is equal to b
eyesore-
@eyesore-
Mar 04 2017 04:21
@colemanallme Eloquent Javascript
Margaret
@Margaret2
Mar 04 2017 04:21
they are already working on Angular 4 lol
eyesore-
@eyesore-
Mar 04 2017 04:21
@emag50 Angular 2 was released last July homie
Ryan Santos
@ryasan86
Mar 04 2017 04:21
check their site
M Denise
@colemanallme
Mar 04 2017 04:22
@eyesore- ok thanks
CamperBot
@camperbot
Mar 04 2017 04:22
colemanallme sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 69 | @eyesore- |http://www.freecodecamp.com/eyesore-
Ryan Santos
@ryasan86
Mar 04 2017 04:22
and try an angular cli command
any command
Ty N.
@mynameislink
Mar 04 2017 04:22
@eyesore- @fahdi-dev @Margaret2 Thanks to you guys for enlightening my brain about how asinine JS can be sometimes lol
CamperBot
@camperbot
Mar 04 2017 04:22
mynameislink sends brownie points to @eyesore- and @fahdi-dev and @margaret2 :sparkles: :thumbsup: :sparkles:
:cookie: 70 | @eyesore- |http://www.freecodecamp.com/eyesore-
:cookie: 228 | @fahdi-dev |http://www.freecodecamp.com/fahdi-dev
:star2: 1866 | @margaret2 |http://www.freecodecamp.com/margaret2
Margaret
@Margaret2
Mar 04 2017 04:22
@mynameislink hahaha
Ty N.
@mynameislink
Mar 04 2017 04:22
Lol wtaf are 'brownie points'???
And why did I just share my brownies with you all? Those are mine!
Margaret
@Margaret2
Mar 04 2017 04:23
looks like it says angular/material components are in beta...
Ty N.
@mynameislink
Mar 04 2017 04:23
Hahaha
NaveenRathor
@NaveenRathor
Mar 04 2017 04:23
@Margaret2 thanks It's done
CamperBot
@camperbot
Mar 04 2017 04:23
naveenrathor sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 1867 | @margaret2 |http://www.freecodecamp.com/margaret2
Margaret
@Margaret2
Mar 04 2017 04:23
@mynameislink don't worry, it doesn't take away from you, cbot has infinite brownies
eyesore-
@eyesore-
Mar 04 2017 04:23
@emag50 angular.io is Angular 2 angularjs is Angular 1
Margaret
@Margaret2
Mar 04 2017 04:24
yeah, but angular 2 itself is not in beta
eyesore-
@eyesore-
Mar 04 2017 04:24
Yeah, it was released last July.
Ryan Santos
@ryasan86
Mar 04 2017 04:24
really...ok well then it might just be the angular cli module
Ty N.
@mynameislink
Mar 04 2017 04:25
Lol @Margaret2 I was just being sarcastic I know the brownies aren't real..........unfortunately
Jason Luboff
@JLuboff
Mar 04 2017 04:25
@Margaret2 Ya but sometimes he's greedy and doesnt give you any
Margaret2 @Margaret2 * nom nom nom *
Margaret
@Margaret2
Mar 04 2017 04:25
cbot
CamperBot
@camperbot
Mar 04 2017 04:25
you called?
Margaret
@Margaret2
Mar 04 2017 04:25
you're a dork
:smile:
Ryan Santos
@ryasan86
Mar 04 2017 04:26
blob
Margaret
@Margaret2
Mar 04 2017 04:26
@mynameislink have you done the eightball yet?
eyesore-
@eyesore-
Mar 04 2017 04:26
You gotta update your packages man.
Ryan Santos
@ryasan86
Mar 04 2017 04:26
this morning...twice
i see npm install angular/cli@latest -g every night in my dreams
Margaret
@Margaret2
Mar 04 2017 04:27
lol
Ryan Santos
@ryasan86
Mar 04 2017 04:28
alright back to the algorithm challenges...see ya folks!
Margaret
@Margaret2
Mar 04 2017 04:28
:wave:
Adam
@GoingAllTheWayUp
Mar 04 2017 04:29
anyone used joomla?
Ty N.
@mynameislink
Mar 04 2017 04:29
Dammit. Anyone care to help me out this one?

var myArr = [ 2, 3, 4, 5, 6];

for (total = 0; total < myArr.length; total ++) {
console.log(myArr[total]);
}

The 'total' variable needs to equal 20....
ankitlovey
@ankitlovey
Mar 04 2017 04:30
Can someone tell me why myVar++; in not incrementing myVar by 1 in Increment a Number with JavaScript challenge. Thank you
Joseph
@revisualize
Mar 04 2017 04:30
@mynameislink Don't console.log
Adam
@GoingAllTheWayUp
Mar 04 2017 04:30
you need to add an addition operator like +=
Margaret
@Margaret2
Mar 04 2017 04:30
@mynameislink well myArr.length is only 5, so how will total ever equal 20?
Ty N.
@mynameislink
Mar 04 2017 04:30
@revisualize Should I just 'return'?
Joseph
@revisualize
Mar 04 2017 04:30
@ankitlovey What exactly are you doig?
@mynameislink No you should create another variable.
Adam
@GoingAllTheWayUp
Mar 04 2017 04:31
newArray += array[1] + array[2]
?
Margaret
@Margaret2
Mar 04 2017 04:31
@ankitlovey you need to show your code
Ty N.
@mynameislink
Mar 04 2017 04:31
@Margaret2 @revisualize Here's the 'Instructions'
ankitlovey
@ankitlovey
Mar 04 2017 04:31

var myVar = 87;

// Only change code below this line
myVar = myVar ++;

Ty N.
@mynameislink
Mar 04 2017 04:31
Declare and initialize a variable total to 0. Use a for loop to add the value of each element of the myArr array to total.
Margaret
@Margaret2
Mar 04 2017 04:31
@ankitlovey the whole point of using ++ is that you don't need =
Joseph
@revisualize
Mar 04 2017 04:32

@ankitlovey

var num = 5;
num = num + 1; // 6
num += 1; // 7
num++; // 8

See how the one for getting num from 7 to 8 doesn't use the assignment operator (=)?
The lesson is requesting that you recreate that process so that you know how to increment and decrement a number with short notation.

Margaret
@Margaret2
Mar 04 2017 04:32
just xyz++
Adam
@GoingAllTheWayUp
Mar 04 2017 04:32
@mynameislink you need to have another var one that is adding the values of your array position
Joseph
@revisualize
Mar 04 2017 04:32
@mynameislink I know the instructions. You need to create another variable.
Aaron Dwayne Gebana
@adgebana
Mar 04 2017 04:32
is the Seek and Destroy challenge bugged? I am not appear to be passing the test cases when I hit Run tests, but the console output displays the expected answer so I believe my algorithm is correct, just not being recognized by freeCodeCamp :/
Joseph
@revisualize
Mar 04 2017 04:32
@mynameislink You need a variable to loop through your array indexes.
@mynameislink You need another variable to store the total
ankitlovey
@ankitlovey
Mar 04 2017 04:33
@Margaret2 and @revisualize . Thank you. Got it!
CamperBot
@camperbot
Mar 04 2017 04:33
ankitlovey sends brownie points to @margaret2 and @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1868 | @margaret2 |http://www.freecodecamp.com/margaret2
:star2: 3420 | @revisualize |http://www.freecodecamp.com/revisualize
Ty N.
@mynameislink
Mar 04 2017 04:33
@GoingAllTheWayUp @revisualize The problem is how to add that outside variable 'myArray' WITH the 'total' variable, on top of creating a new variable inside the for loop
Margaret
@Margaret2
Mar 04 2017 04:33
@mynameislink so yeah, like @GoingAllTheWayUp said, you have to use += to add the value to total. Use another variable for the loop
Joseph
@revisualize
Mar 04 2017 04:33
@mynameislink And you have to do addition with all of the array elements to total
Ty N.
@mynameislink
Mar 04 2017 04:33
ohh snap duh!
Joseph
@revisualize
Mar 04 2017 04:33
@mynameislink YOU JUST MAKE ANOTHER VARIABLE
var value;
Adam
@GoingAllTheWayUp
Mar 04 2017 04:33
its not total you wish to add but the index position at your total value
Seth
@sethdcd
Mar 04 2017 04:34
hi all i'm trying to get the weather app to work but i keep getting this error with my .getJSON method
Failed to load resource: net::ERR_CONNECTION_REFUSED
Adam
@GoingAllTheWayUp
Mar 04 2017 04:34
something like ` var newArray += oldArray[i]
Simon
@smnshulgan
Mar 04 2017 04:34
hey guys i dont get why my confirm ending isnt working

function confirmEnding(str, target) {
var x;
x = str.length - 1;
if(str.substr(x) === target)
{
return true;
}
else
{
return false;
}
}

confirmEnding("Bastian", "n");

it doesnt work for Open sesame
Margaret
@Margaret2
Mar 04 2017 04:35
@GoingAllTheWayUp he's not trying to make a new array, so saying var newArray is confusing...
Gulsvi
@gulsvi
Mar 04 2017 04:36
@sethdcd Can you open your weather API url in your browser manually?
Seth
@sethdcd
Mar 04 2017 04:36
@SkyCoder01 yes
Gulsvi
@gulsvi
Mar 04 2017 04:36
What URL?
Margaret
@Margaret2
Mar 04 2017 04:36
@smnshulgan because you only check the last letter, for some of the tests you have to check more than one letter. Like if you do confirmEnding("Bastian", "on") it should return false
Seth
@sethdcd
Mar 04 2017 04:36
i'm just using the default location with my api key for now
Adam
@GoingAllTheWayUp
Mar 04 2017 04:36
@Margaret2 thanks, lol
CamperBot
@camperbot
Mar 04 2017 04:36
goingallthewayup sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:star2: 1869 | @margaret2 |http://www.freecodecamp.com/margaret2
Gulsvi
@gulsvi
Mar 04 2017 04:36
@sethdcd Are you sure you can open that in your browser? I get an error
Open Weather Map makes you pay money to use HTTPS://
Seth
@sethdcd
Mar 04 2017 04:37
@SkyCoder01 oh really?
@sethdcd yeah it doesnt look like it's working, but when i try HTTP i get a security error
eyesore-
@eyesore-
Mar 04 2017 04:37
Just dropping it in here that everyone should check out Postman when working with APIs
Ty N.
@mynameislink
Mar 04 2017 04:38
@Margaret2 @revisualize Lol you guys are awesome thanks!
CamperBot
@camperbot
Mar 04 2017 04:38
mynameislink sends brownie points to @margaret2 and @revisualize :sparkles: :thumbsup: :sparkles:
:warning: mynameislink already gave margaret2 points
:star2: 3421 | @revisualize |http://www.freecodecamp.com/revisualize
Seth
@sethdcd
Mar 04 2017 04:38
@SkyCoder01 Mixed Content: The page at 'https://codepen.io/sethdcd/full/oZxGoO/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=410463b3935acea56c8171825dbb4440'. This request has been blocked; the content must be served over HTTPS.
Ty N.
@mynameislink
Mar 04 2017 04:38
cb those are my brownies
NaveenRathor
@NaveenRathor
Mar 04 2017 04:38
what's wrong in my code

function abTest(a, b) {
// Only change code below this line
switch (b === a){
case a < 0:
return "String!";

}

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

Margaret
@Margaret2
Mar 04 2017 04:38
@sethdcd that's because you have to be on http://codepen.io to load an http resource like that
Tolga Dur
@tolgadur
Mar 04 2017 04:38
I am doing the "Missing Letter" Challenge
what's wrong?

function fearNotLetter(str) {
var alph = "abcdefghijklmnopqrstuvwxyz";
var alphSplit = alph.split("");
var strSplit = str.split("");

for(var key in strSplit){
if(strSplit[key] !== alphSplit[key]){
return strSplit[key];
}
}
}

eyesore-
@eyesore-
Mar 04 2017 04:39
@sethdcd Also do some research on HTTP request and CORS
Gulsvi
@gulsvi
Mar 04 2017 04:39
@sethdcd Lots of people hit that problem. If your Codepen is opened over HTTPS, you have to call APIs over HTTPS. The only problem is that navigator.geolocation only works over HTTPS. You'll have to use a different way to get location or a Weather API that supports HTTPS
Seth
@sethdcd
Mar 04 2017 04:39
@SkyCoder01 @Margaret2 ah! thanks guys :D (duh!)
CamperBot
@camperbot
Mar 04 2017 04:39
sethdcd sends brownie points to @skycoder01 and @margaret2 :sparkles: :thumbsup: :sparkles:
:cookie: 428 | @skycoder01 |http://www.freecodecamp.com/skycoder01
:star2: 1870 | @margaret2 |http://www.freecodecamp.com/margaret2
Margaret
@Margaret2
Mar 04 2017 04:40
@NaveenRathor your code is not doing what it's supposed to do. you need to check if a or b is less than 0
@NaveenRathor hint: use an if statement and an || (or) operator
eyesore-
@eyesore-
Mar 04 2017 04:41
@sethdcd That will tell you why things happen the way they do.
Aaron Dwayne Gebana
@adgebana
Mar 04 2017 04:43

this is annoying, does anyone have a working solution for Seek and Destroy?

this is mine:
function filterOut(currentValue) {
return currentValue !== this;
}

function destroyer(arr) {
// store the arguments into a variable for easier readability
var args = Array.from(arguments);
for (var i = 0; i < args.length; i++) {
arr = arr.filter(filterOut, args[i]);
}
return arr;
}

destroyer([3, 5, 1, 2, 2], 2, 3, 5);

from the console it outputs 1 but does not pass the case test.

if I use " return 1" instead of "return arr" the console outputs 1 AND PASSES the test case....

NaveenRathor
@NaveenRathor
Mar 04 2017 04:43
@Margaret2

function abTest(a, b) {
// Only change code below this line
if (a || b < 0){
return "String!";
}

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

it's not work
any correction in my code
Margaret
@Margaret2
Mar 04 2017 04:44
@NaveenRathor each side of the || operator is evaluated as a separate expression. So you have to have a < 0, not just a
bc right now, the first thing it evaluates is if(a)
NaveenRathor
@NaveenRathor
Mar 04 2017 04:48
@Margaret2 Thanks It's done
CamperBot
@camperbot
Mar 04 2017 04:48
naveenrathor sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:warning: naveenrathor already gave margaret2 points
Ty N.
@mynameislink
Mar 04 2017 04:52
@Margaret2 I just took that 'are you a real programmer' test lol that was silly :P
Had to hahah
Margaret
@Margaret2
Mar 04 2017 04:52
@mynameislink hahaha yeah
Ty N.
@mynameislink
Mar 04 2017 04:53
Lol okay peace out everybody I'm gonna go learn some shiiiiiz
And drink another gin and tonic lol
Carmen Huang
@chuang43
Mar 04 2017 05:04
does anyone know how to replace double quotes with single quotes in this:
"<a href=\'http://www.example.com\' target=\_blank\>Link</a>"
heroiczero
@heroiczero
Mar 04 2017 05:05
@chuang43 maybe its because you are escaping the '
@chuang43 which challenge is it?
eyesore-
@eyesore-
Mar 04 2017 05:06
Best practice outside FCC is to use single quotes for JS and double for HTML
Gulsvi
@gulsvi
Mar 04 2017 05:07
Template literals FTW
eyesore-
@eyesore-
Mar 04 2017 05:09
Are those allowed in FCC? They didn't let me use let or const when I was helping someone /:
Gulsvi
@gulsvi
Mar 04 2017 05:10
I don't think so - but in codepen, they're fine.
@eyesore- Works fine in some of them like Word Blanks: https://www.freecodecamp.com/challenges/word-blanks
Ken Haduch
@khaduch
Mar 04 2017 05:12
@eyesore- the JS lint tool that they use will flag let and const as ES6 features. If you add this: // jshint esversion: 6 at the very top of the editor window, it should remove the warnings.
although it isn't necessarily true that the test code will support it in all cases, I guess.
eyesore-
@eyesore-
Mar 04 2017 05:13
Oh, I didn't know they used jshint. It's cool. I don't really go through the lessons.
Carmen Huang
@chuang43
Mar 04 2017 05:13
i got it! thanks!
john94
@lpy1994
Mar 04 2017 05:17
guys, do you know how to repeat a string without using .repeat() ?
heroiczero
@heroiczero
Mar 04 2017 05:18
@lpy1994 probably use a for loop or something
john94
@lpy1994
Mar 04 2017 05:20
@heroiczero more specifically ?
eyesore-
@eyesore-
Mar 04 2017 05:21
@lpy1994 Where are you getting stuck?
heroiczero
@heroiczero
Mar 04 2017 05:22
@lpy1994 like a
for (i = 0; i < 5; i++) { 
    return "Hello";
}
Richard Belotte
@belotte
Mar 04 2017 05:22
OK so this may be a dumb question but is the java script object the object in "object oriented programming"?
john94
@lpy1994
Mar 04 2017 05:23
@eyesore- "repeat a string repeat a string” challenge in FCC
eyesore-
@eyesore-
Mar 04 2017 05:23
@belotte That was confusing haha but not necessarily. Can you elaborate a little more?
@lpy1994 I know that. I was just wondering what you had so far so we can kind of guide your path.
heroiczero
@heroiczero
Mar 04 2017 05:24
@lpy1994 yeah i would use a for loop or a while loop for that
john94
@lpy1994
Mar 04 2017 05:24
@eyesore- I just solved it by using .repeat() .
Jeff
@Garanimal
Mar 04 2017 05:27
@lpy1994 I solved it using a for
NaveenRathor
@NaveenRathor
Mar 04 2017 05:27
what's wrong in my code

var count = 0;

function cc(card) {
// Only change code below this line
if(card >= 0){
return "-3 Hold";
}
return "5 Bet";
// Only change code above this line
}

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

john94
@lpy1994
Mar 04 2017 05:27
@Garanimal that is why I am tring to figure out
Richard Belotte
@belotte
Mar 04 2017 05:28
@eyesore- yes, my wording was poor. So in the term "object" in the phrase "object oriented programming" or "OOP"... does that refer to the object model used in java script ( { key : value } )?
Jeff
@Garanimal
Mar 04 2017 05:28
@NaveenRathor dont you need to use a switch for that one?
eyesore-
@eyesore-
Mar 04 2017 05:28
@belotte So you could say that since OOP is a programming language that is highly based of inheritance and an object. Arrays are objects and so are Functions. Javascript is actually a multi-paradigm language since it does have some functional aspects to it.
@belotte I wrote that before you last message, but I also gave a high level definition on OOP haha let me know if that helps out.
heroiczero
@heroiczero
Mar 04 2017 05:29
@NaveenRathor What are you trying to do? take it step by step. What is the objective of counting cards. If you are given a card, Are you adding to the count or subtracting?
Richard Belotte
@belotte
Mar 04 2017 05:29
@eyesore- sort of... What is an "multi-paradigm"?
NaveenRathor
@NaveenRathor
Mar 04 2017 05:29
@Garanimal i'm not using switch case
Jeff
@Garanimal
Mar 04 2017 05:30
@NaveenRathor you should be.
eyesore-
@eyesore-
Mar 04 2017 05:30
@belotte that is when you've got both functional and OOP aspects in a language. Or more, it doesn't just have to be that.
heroiczero
@heroiczero
Mar 04 2017 05:30
@lpy1994 review your for loop in freecodecamp the answer can be really simple.
Richard Belotte
@belotte
Mar 04 2017 05:30
OK...
Jeff
@Garanimal
Mar 04 2017 05:31
@NaveenRathor there are 12 options for the cards and only 3 possible outputs. do you really want to create 12 if loops?
Richard Belotte
@belotte
Mar 04 2017 05:31
I guess I don't know the definition of an object .
eyesore-
@eyesore-
Mar 04 2017 05:31
@belotte If you need me to explain anything else I'm game haha :smile:
Richard Belotte
@belotte
Mar 04 2017 05:32
@eyesore- I thought an object was an array that had a series of key : value elements, no?
john94
@lpy1994
Mar 04 2017 05:32
@heroiczero trying...
eyesore-
@eyesore-
Mar 04 2017 05:33
@belotte When you think of an object in Javascript just think of it as a data structure. It holds information for whenever you need it. An Array is actually an object in Javascript (this isn't the same in all languages). In Javascript the indexes are the keys and the values are well the values.
@belotte Just curious because I really don't want to confuse you, how far along are you in learning Javascript?
@belotte or do you have experience in another language?
Richard Belotte
@belotte
Mar 04 2017 05:35
@eyesore- that's starting to make sense. I've been trying off and on for years. I've gone through Lynda.com, Codeschool.com, egghead, etc
eyesore-
@eyesore-
Mar 04 2017 05:35
@belotte Cool. I'm not trying to say you're a noob or anything just wanted to make sure I didn't confuse you away from learning haha
Richard Belotte
@belotte
Mar 04 2017 05:36
Yeah... it's ok. I am kind of a noob
no shame
NaveenRathor
@NaveenRathor
Mar 04 2017 05:37
@Garanimal it's not working
my code is here

var count = 0;

function cc(card) {
// Only change code below this line
switch(card){
case 2, 3, 4, 5, 6:
return "5 Bet";
case 7, 8, 9:
return "0 Hold";
case 10, 'J', 'Q', 'K', 'A':
return "-1 Hold";
case 10, 'J', 'Q', 'K', 'A':
return "-5 Hold";
}
// Only change code above this line
}

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

Richard Belotte
@belotte
Mar 04 2017 05:37
@eyesore- Thank you!
CamperBot
@camperbot
Mar 04 2017 05:37
belotte sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 71 | @eyesore- |http://www.freecodecamp.com/eyesore-
Bryan Reese
@breese8009
Mar 04 2017 05:38
hi, another JS question...it wants me to write a function that gives the sum of all the numbers provided. That part wasnt too hard... but im stuck on how to take into account if there is an input like -435...it wants me to make just that first number a negative number if that makes sense...
function sumDigits(num) {
var sum= num.toString().split('').map(Number).reduce(function(a,b){
  return a+b;
});
 return sum;

}
sumDigits(234);
heroiczero
@heroiczero
Mar 04 2017 05:38
@NaveenRathor gotta do case 2: and so on review switch in free code camp
eyesore-
@eyesore-
Mar 04 2017 05:38
@belotte You're just learning. We all are no matter how advanced it may seem someone is. So yeah in OOP things are based off an object and inheritance. In Javascript we have prototypal inheritance which relates to class inheritance in Java. So the reason we can call .push() on [ 1, 2, 3].push(1) is because .push is a method on the Array object.
@belotte [ 1, 2, 3 ] will look at it's prototype which is the Array constructor and that has the methods.
Jeff
@Garanimal
Mar 04 2017 05:40
@NaveenRathor thats not how switch works. you need to define each case
var count=0
function cc(card){
case 2:
case 3:
case 4:
.
.
.
Bryan Reese
@breese8009
Mar 04 2017 05:40
anyone anyone?
Jeff
@Garanimal
Mar 04 2017 05:40
@breese8009 looking
Bryan Reese
@breese8009
Mar 04 2017 05:40
@Garanimal thank u
CamperBot
@camperbot
Mar 04 2017 05:40
breese8009 sends brownie points to @garanimal :sparkles: :thumbsup: :sparkles:
:cookie: 295 | @garanimal |http://www.freecodecamp.com/garanimal
Bryan Reese
@breese8009
Mar 04 2017 05:41
@Garanimal it aint easy lol
Jeff
@Garanimal
Mar 04 2017 05:41
@breese8009 why .toString()?
郭向阳
@xzgg
Mar 04 2017 05:41

Translate the specified string into pig latin.

Pig Latin moves the first consonant or consonant cluster of an English word to the suffix, followed by the suffix "ay".

If the word starts with a vowel, you only need to add "way" to the suffix.

how to write
Bryan Reese
@breese8009
Mar 04 2017 05:42
@Garanimal what do u mean?
Jeff
@Garanimal
Mar 04 2017 05:43
@breese8009 why are you turning the values into a string?
eyesore-
@eyesore-
Mar 04 2017 05:43
So he can split
Bryan Reese
@breese8009
Mar 04 2017 05:44
@Garanimal so i can split it into an array
john94
@lpy1994
Mar 04 2017 05:45
@heroiczero @eyesore- thx, I google it and got it.
CamperBot
@camperbot
Mar 04 2017 05:45
lpy1994 sends brownie points to @heroiczero and @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 925 | @heroiczero |http://www.freecodecamp.com/heroiczero
:cookie: 72 | @eyesore- |http://www.freecodecamp.com/eyesore-
Bryan Reese
@breese8009
Mar 04 2017 05:45
I turned to string, split into an array, map back to numbers, reduced to add all the numbers in the array and return the sum
eyesore-
@eyesore-
Mar 04 2017 05:45
@lpy1994 no problem
Bryan Reese
@breese8009
Mar 04 2017 05:45
now i want to some how take into account the -
eyesore-
@eyesore-
Mar 04 2017 05:46
@Garanimal If you need another pair of eyes on it let me know.
NaveenRathor
@NaveenRathor
Mar 04 2017 05:47
@Garanimal it's not working
Cards Sequence 2, 3, 4, 5, 6 should return "5 Bet"
Cards Sequence 7, 8, 9 should return "0 Hold"
Cards Sequence 10, J, Q, K, A should return "-5 Hold"
Cards Sequence 3, 7, Q, 8, A should return "-1 Hold"
Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"
Cards Sequence 2, 2, 10 should return "1 Bet"
Cards Sequence 3, 2, A, 10, K should return "-1 Hold"
it's the question
Jeff
@Garanimal
Mar 04 2017 05:47
@NaveenRathor what is your code?
Gulsvi
@gulsvi
Mar 04 2017 05:47
@breese8009 I would do something like:
function sumDigits(num) {
  const numArray = num.toString().split('');
  if (numArray[0] == '-') return -1 * numArray[1] + numArray.slice(2).reduce((a,b) => +a + +b);
  return numArray.reduce((a,b) => +a + +b);
}
NaveenRathor
@NaveenRathor
Mar 04 2017 05:48
@Garanimal

var count = 0;

function cc(card) {
// Only change code below this line
switch(card){
case 2:
return "1 Bet";
case 3:
return "-1 Hold";
case 4:
return "5 Bet";
case 5:
return "5 Bet";
case 7:
return "-1 Hold";
case 10:
return "-1 Hold";

}
// Only change code above this line
}

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

Jeff
@Garanimal
Mar 04 2017 05:49
@NaveenRathor the usefulness of switch is that you can assign multiple arguments to a single output.
var count = 0;


function cc(card) {
  // Only change code below this line
  switch (card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    count=count+1;
    break;
@NaveenRathor this would assign the cards 2-6 to add 1 to the count.
Bryan Reese
@breese8009
Mar 04 2017 05:50
@SkyCoder01 nope, didnt work :(
and i fixed the syntax
Gulsvi
@gulsvi
Mar 04 2017 05:50
What's the expected output for -234, I'm getting 5. Might have misunderstood the requirements
function sumDigits(num) {
  const numArray = num.toString().split('');
  if (numArray[0] == '-') return -1 * numArray[1] + numArray.slice(2).reduce((a,b) => +a + +b);
  return numArray.reduce((a,b) => +a + +b);
}
var output = sumDigits(-234);
console.log(output); //5
-2 + 3 + 4 = 5
NaveenRathor
@NaveenRathor
Mar 04 2017 05:57
@Garanimal Still it's not working
Jeff
@Garanimal
Mar 04 2017 05:57
@NaveenRathor what do you have now?
NaveenRathor
@NaveenRathor
Mar 04 2017 05:57

var count = 0;

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

}
// Only change code above this line
}

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

Ogundele Olumide
@Lumexralph
Mar 04 2017 05:58
@NaveenRathor you can eliminate the case 7, 8, 9 since it's doing nothing
Jeff
@Garanimal
Mar 04 2017 05:59
@NaveenRathor you have nothing telling it what to do once its done. What do you want it to say? You've manipulated the count variable, now use that to determine what to do based on the count.
Ogundele Olumide
@Lumexralph
Mar 04 2017 05:59
@NaveenRathor you need a control flow statement if to check whether count is positive or negative and send the appropriate count + string required
NaveenRathor
@NaveenRathor
Mar 04 2017 06:01
@Garanimal it's not working

var count = 0;

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

  return "5 Bet";


case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
  count = count-1;
  return "-3 Hold";

}
// Only change code above this line
}

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

Jeff
@Garanimal
Mar 04 2017 06:02
@NaveenRathor what are the possible options for the count to be?
and what are the necessary returns based on those results?
NaveenRathor
@NaveenRathor
Mar 04 2017 06:02
question is
Cards Sequence 2, 3, 4, 5, 6 should return "5 Bet"
Cards Sequence 7, 8, 9 should return "0 Hold"
Cards Sequence 10, J, Q, K, A should return "-5 Hold"
Cards Sequence 3, 7, Q, 8, A should return "-1 Hold"
Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"
Cards Sequence 2, 2, 10 should return "1 Bet"
Cards Sequence 3, 2, A, 10, K should return "-1 Hold"
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:03
@NaveenRathor you need an if statement after your initial switch statement..... before you can return count and the string hold or bet
@NaveenRathor the previous code you posted is closer than the recent one
Jeff
@Garanimal
Mar 04 2017 06:04
@NaveenRathor so IF the count is positive you should say "Bet", and IF the count is negative or 0 you should say "Hold"
can you think of a way you could implement that condition into your code?
NaveenRathor
@NaveenRathor
Mar 04 2017 06:07
@Garanimal i'm trying but it's not working
frankho kevinho
@frankhokevinho
Mar 04 2017 06:07
hello
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:07
@frankhokevinho hi
frankho kevinho
@frankhokevinho
Mar 04 2017 06:08
how can i do to use a arguments of an function in another function
Jeff
@Garanimal
Mar 04 2017 06:09
@NaveenRathor ok there are two cases right? Either:
A: The count is positve, in which case you want the code to return"count Bet"
or
B: The count is negative, in which case you want the code to return "count Hold"
You should be able to use an If/Else statment to acheive this.
make sure your if/else statment is outside the switch operator but still inside the function cc
Aditya Gupta
@adityagupta4213
Mar 04 2017 06:09

Hey guys!

I want to highlight some links placed inside a scrollable container when they are inside a specific region of the page.

More specifically-

The links are placed inside a fixed height container with a scrollable overflow. I want to change the color of the links (the <a> tags) when they are within a certain region of the viewport (about within 10% from the top and bottom of the center). Is there any way to achieve this?

Ogundele Olumide
@Lumexralph
Mar 04 2017 06:09
@frankhokevinho just make the other function local to the function with the parameter
Jeff
@Garanimal
Mar 04 2017 06:10
@frankhokevinho heres an example
function reduction(a,b){
  return Math.max(a,b);
}
var tank=[];
function largestOfFour(arr) {
  for (var i=0; i<arr.length; i++) {
    arr[i] = arr[i].reduce(reduction);
    }
  return arr;
  }
NaveenRathor
@NaveenRathor
Mar 04 2017 06:10
@Garanimal and what should define inside the if statement

var count = 0;

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

  return "5 Bet";
 }
  break;

case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
  count = count-1;
  return "-3 Hold";

}
// Only change code above this line
}

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

Gulsvi
@gulsvi
Mar 04 2017 06:10

and i fixed the syntax

Curious what syntax you fixed, @breese8009

@frankhokevinho Assign arguments to a variable and pass it to the other function
Greg Duncan
@GregatGit
Mar 04 2017 06:12
@NaveenRathor if(count = count+1){ is wrong in 2 ways - count will never equal count + 1 and it should be === not =
Jeff
@Garanimal
Mar 04 2017 06:12
@NaveenRathor Heres the breakdown of your code
The Switch operator is only used to build/add up the count and set it at the appropriate value.
You then use an if/else statement AFTER (NOT INSIDE) the switch function telling the original function to either return hold or bet based on the count
Greg Duncan
@GregatGit
Mar 04 2017 06:12
for an if statement
Abhishek
@Abhishek7415
Mar 04 2017 06:13
help me to do 143
Jeff
@Garanimal
Mar 04 2017 06:14
@NaveenRathor your If statement is simply if (count>0){return count+______} else {return count+ ______}
@Abhishek7415 which challenge?
also is anyone here good with .push
I can literally never get it to work.
frankho kevinho
@frankhokevinho
Mar 04 2017 06:15
Capture.PNG
Capture.PNG
@Garanimal it doesn't realy work when i call digitNumber with a simple integer it work but not when i call it with num arguments of the second fonction
Jeff
@Garanimal
Mar 04 2017 06:19
@frankhokevinho that one is honestly a bit beyond me. It doesnt seem right to be referencing each function within the other function though.
Bryan Reese
@breese8009
Mar 04 2017 06:20
@SkyCoder01 u had double +
Gulsvi
@gulsvi
Mar 04 2017 06:20
@breese8009 That's a unary operator, changes a string to a number
Abhishek
@Abhishek7415
Mar 04 2017 06:24
chalange 143 @Garanimal
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:24
@Abhishek7415 how can we know that?
Jeff
@Garanimal
Mar 04 2017 06:25
@Abhishek7415 ya man we needa challenge name.
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:25
@Abhishek7415 you should ask question with the title of the challenge you're working on
Bryan Reese
@breese8009
Mar 04 2017 06:25
@SkyCoder01 it was giving that as the error when i ran it
Gulsvi
@gulsvi
Mar 04 2017 06:26
@breese8009 Weird, it works in codepen
Abhishek
@Abhishek7415
Mar 04 2017 06:26
"myStr should have encoded text with the proper escape sequences and no spacing.
myStr should have one newline character \n
myStr should have one carriage return character \r
myStr should have two correctly escaped backslash characters \
that's d challange
NaveenRathor
@NaveenRathor
Mar 04 2017 06:27
@Garanimal i'm waiting
Jeff
@Garanimal
Mar 04 2017 06:27
@NaveenRathor for?
Bryan Reese
@breese8009
Mar 04 2017 06:27
@SkyCoder01 its a challenge on prep.hackreactor.com
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:27
@Abhishek7415 FirstLinenewline escaped backslash escaped SecondLine backslash escaped carriage return escaped ThirdLine
Gulsvi
@gulsvi
Mar 04 2017 06:27

I suppose you could also do:

function sumDigits(num) {
  const numArray = num.toString().split('');
  if (numArray[0] == '-') return -1 * numArray[1] + numArray.slice(2).reduce((a, b) => Number(a) + Number(b));
  return numArray.reduce((a, b) => Number(a) + Number(b));
}
var output = sumDigits(-234);
console.log(output); //5

with Number() instead of the unary plus

NaveenRathor
@NaveenRathor
Mar 04 2017 06:27
@Garanimal still it's not working
Jeff
@Garanimal
Mar 04 2017 06:27
@NaveenRathor I can give you the answer if you're over trying to figure it out
NaveenRathor
@NaveenRathor
Mar 04 2017 06:27

var count = 0;

function cc(card) {
// Only change code below this line
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:

 }

if(count > 0){

        return count + 1;
     }else {
         return count - 1;


     }
// Only change code above this line

}

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

Bryan Reese
@breese8009
Mar 04 2017 06:27
@SkyCoder01 lemme plug that
Jeff
@Garanimal
Mar 04 2017 06:28
@NaveenRathor dude, have you even read the challenge?????
@NaveenRathor You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). 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.
NaveenRathor
@NaveenRathor
Mar 04 2017 06:29
@Garanimal i read it
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:29
@NaveenRathor
switch(expression) {
}

if statement to check count
if(count is positive) {
   return count + string
}
else {
   return count + string
}
Bryan Reese
@breese8009
Mar 04 2017 06:29
@SkyCoder01 THAT one worked
Jeff
@Garanimal
Mar 04 2017 06:29
@NaveenRathor
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
Where in your code are you meeting this requirement?
Gulsvi
@gulsvi
Mar 04 2017 06:30
Cool, just learned about that + recently, maybe not compatible everywhere. Will read more about it.
NaveenRathor
@NaveenRathor
Mar 04 2017 06:30
@Garanimal i'm not understand
Bryan Reese
@breese8009
Mar 04 2017 06:31
@SkyCoder01 wow but thats a deep solution
never would have thought that route
but its well thought out
@SkyCoder01 thank u
CamperBot
@camperbot
Mar 04 2017 06:31
breese8009 sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 429 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Gulsvi
@gulsvi
Mar 04 2017 06:31
@breese8009 I think there's an algorithm that's probably more efficient. Something with mod 10 and then divide by 10 in a while loop until num = 0
Bryan Reese
@breese8009
Mar 04 2017 06:32
mod 10?
Gulsvi
@gulsvi
Mar 04 2017 06:32
num % 10
Bryan Reese
@breese8009
Mar 04 2017 06:33
oh modulo
lol sorry
Tawah
@Tawah
Mar 04 2017 06:33
Hi! I am new to codecamp if you can see my screen can you tell me where I am going wrong with my response.
Gulsvi
@gulsvi
Mar 04 2017 06:33
@breese8009 Like this, with some logic for the negative number:
var value = 2568,
    sum = 0;

while (value) {
    sum += value % 10;
    value = Math.floor(value / 10);
}

console.log(sum);
Stephan Sharps
@ssharps711
Mar 04 2017 06:34
Hey dudes!
Gulsvi
@gulsvi
Mar 04 2017 06:34
It gets messy with the negative number part though
Stephan Sharps
@ssharps711
Mar 04 2017 06:34
var array = [1,2,3,4,5,6,7];
var newArray = [];

// Only change code below this line.

array.reverse(newArray);
What the f is going on there?
Jeff
@Garanimal
Mar 04 2017 06:34
@ssharps711 there is nothing in newArray to reverse
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:34
@ssharps711 you need to apply reverse on array
@ssharps711 array.reverse()
Jeff
@Garanimal
Mar 04 2017 06:35
@ssharps711 your current code says to apply the reverse of newArray to array
Stephan Sharps
@ssharps711
Mar 04 2017 06:36

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

// Only change code below this line.

newArray.reverse(array);
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:36
@ssharps711 newArray = array.reverse()
Jeff
@Garanimal
Mar 04 2017 06:37
@ssharps711 scratch that im a dummy @Lumexralph is correct.
@NaveenRathor Whered ya go?
Stephan Sharps
@ssharps711
Mar 04 2017 06:37
@Lumexralph thanks @Garanimal not as dumb as me thanks
CamperBot
@camperbot
Mar 04 2017 06:37
ssharps711 sends brownie points to @lumexralph and @garanimal :sparkles: :thumbsup: :sparkles:
:star2: 1254 | @lumexralph |http://www.freecodecamp.com/lumexralph
:cookie: 296 | @garanimal |http://www.freecodecamp.com/garanimal
Jor
@joreyesl
Mar 04 2017 06:37
.reverse() modifies the original array, no need to assign it to a new array. Or make a copy if you dont want the original modified
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:38
@ssharps711 you're both not dumb, maybe you forgot :wink:
Stephan Sharps
@ssharps711
Mar 04 2017 06:39
;) I forgot
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:39
@ssharps711 :smile:
Coded
@Ajayhar
Mar 04 2017 06:42
Can someone explain boolean objects and primitive types in simple terms?
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:42
@Ajayhar in Javascript you need to work with values, right?
Coded
@Ajayhar
Mar 04 2017 06:43
@Lumexralph Yes.
I understand what boolean values are
but the boolean objects vs primitive datatype is what i dont understand
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:44
@Ajayhar there are elementary values you can use in performing an operation or writing a program in JS
Coded
@Ajayhar
Mar 04 2017 06:45
I mean, var x = Boolean(false); vs var x = false;
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:45
@Ajayhar Boolean is also part of the primitive datatype
Coded
@Ajayhar
Mar 04 2017 06:46
But is the difference between these two statements:
var x = Boolean(false); vs var x = false;
@Lumexralph
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:47
@Ajayhar most datatype in JS have Object wrapper, from their constructor Boolean() is a wrapper that converts any value as argument to boolean true or false based on it's truthy or falsynesss
@Ajayhar you don't need to do Boolean(false) because false is already a boolean
Coded
@Ajayhar
Mar 04 2017 06:48
What is the purpose of wrapping a datatype with an object?
@Lumexralph
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:48
@Ajayhar for explicit coercion
@Ajayhar and when you want to access their methods
Coded
@Ajayhar
Mar 04 2017 06:49
so Boolean() decides if its parameters are true or false. is that right?
@Lumexralph
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:49
@Ajayhar Boolean() coerces/ changes the datatype to true or false which is boolean.... are you aware of truthy and falsy values?
Coded
@Ajayhar
Mar 04 2017 06:50
yes. like null and NaN right?
@Lumexralph
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:51
@Ajayhar yes, if you wrap them with the Boolean() it will coerce/ change their datatype to boolean true or false based on that
@Ajayhar truthy values are values when coerced implicitly or explicitly in JS returns boolean true and vice-versa for falsy values
Coded
@Ajayhar
Mar 04 2017 06:53
Can you give a for example?
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:53
@Ajayhar
Boolean(0) // false
Boolean(1) //true, both are coerced to boolean using that boolean wrapper
Coded
@Ajayhar
Mar 04 2017 06:53
@Lumexralph
Stephan Sharps
@ssharps711
Mar 04 2017 06:55
Why did no one tell me to use the Mozilla Developer Network prior to FCC
Coded
@Ajayhar
Mar 04 2017 06:55
So it is like a function that decides whether or not its parameters are true or false. am i at least getting closer? @Lumexralph
Stephan Sharps
@ssharps711
Mar 04 2017 06:55
It's like the textbook to FCC
APURV SINGH
@apurvvv
Mar 04 2017 06:55
quotes=[["a"],["good"],["boy"]];
images=[["1.png"],["2.png"],["3.png"]]
var img= document.getElementById('image').src;
var con = document.getElementById('text');
var but = document.getElementById('button');
but.onclick= function(){
  var randomNumber=Math.floor(Math.random()*(quotes.length));
  con.innerHTML=quotes[randomNumber];
  img.innerHTML=images[randomNumber];
   }
quotes are working fine but image remains the same. Can you find out problem?
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:56
@Ajayhar not really that, do you know what i mean by coercion?
Jor
@joreyesl
Mar 04 2017 06:56
@Ajayhar that is what you are doing, you are using the Boolean function. If you did var x = new Boolean(false) then you would be creating an object wrapper, but simply using var x = Boolean(false) you are using it as a function.
Stephan Sharps
@ssharps711
Mar 04 2017 06:56
Either way, if any of you are stuck on anything and feeling lost search through https://developer.mozilla.org/en-US/docs/Web/JavaScript
Coded
@Ajayhar
Mar 04 2017 06:57
@Lumexralph Yes. to force. right?
Ogundele Olumide
@Lumexralph
Mar 04 2017 06:57
@Ajayhar not force, to change a value from one datatype to another
@Ajayhar like changing from Number to String
Coded
@Ajayhar
Mar 04 2017 07:01
@joreyesl what is the difference in functionality between var x = new Boolean(false) and var x = Boolean(false) ? @Lumexralph
Ogundele Olumide
@Lumexralph
Mar 04 2017 07:02
@Ajayhar
var a = 42;

var b = a + "";         // implicit coercion

var c = String( a );    // explicit coercion
Jor
@joreyesl
Mar 04 2017 07:02
@Ajayhar Boolean(false) will return true/false based on the argument. new Boolean(false) will create an object.
Ogundele Olumide
@Lumexralph
Mar 04 2017 07:03
@Ajayhar using new initiates/create an object instance just like @joreyesl told you
kishore sriramula
@KISHORESSK
Mar 04 2017 07:03
var myStr = 'FirstLine\n"\SecondLine\"\rThirdLine'; // Change this line
whats wrong with this one
Ogundele Olumide
@Lumexralph
Mar 04 2017 07:03
@KISHORESSK don't use quotes around your escaped characters
@KISHORESSK escape backslash like this \\
Coded
@Ajayhar
Mar 04 2017 07:07
@joreyesl @Lumexralph I think I have some studying to do on these topics. Thanks for explaining, guys.
CamperBot
@camperbot
Mar 04 2017 07:07
ajayhar sends brownie points to @joreyesl and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 549 | @joreyesl |http://www.freecodecamp.com/joreyesl
:star2: 1255 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Mar 04 2017 07:08
@Ajayhar :+1:
mkrv01
@mkrv01
Mar 04 2017 07:08
Good morning guys ! Could someone explain the logics behind <<Check for palindromes>> ? I don't even know where to start with this. This one seems odd.
kishore sriramula
@KISHORESSK
Mar 04 2017 07:12
@Lumexralph thanks
CamperBot
@camperbot
Mar 04 2017 07:12
kishoressk sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1256 | @lumexralph |http://www.freecodecamp.com/lumexralph
Jor
@joreyesl
Mar 04 2017 07:12

@mkrv01 well first step is to clean the string, remove any special characters, just keep alphanumeric characters. I would suggest to use a regex and the .replace string method.

Once you have cleaned the string, then you want to reverse a copy of the string and then compare the two strings. If they are the same, then the string is a palindrome.

mkrv01
@mkrv01
Mar 04 2017 07:16
@joreyesl Thank you ! Let me see how I can go on about this
CamperBot
@camperbot
Mar 04 2017 07:16
mkrv01 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 550 | @joreyesl |http://www.freecodecamp.com/joreyesl
Ben Carp
@carpben
Mar 04 2017 07:30
hi everyone. Can't figure out why I'm getting this error. pen: https://codepen.io/bencarp/pen/WpbEoj
blob
Phiggins567
@phiggins567
Mar 04 2017 07:33
Hey, did anyone completed the JavaScript calculator not using eval()?
Christian Laurente
@Daviers01
Mar 04 2017 07:41
Hi guys, I have a small project and i'd like to put some activity calendar like FCC's calendar. Any idea?
Manish Giri
@Manish-Giri
Mar 04 2017 07:43
@phiggins567 I did
Ogundele Olumide
@Lumexralph
Mar 04 2017 07:43
@Manish-Giri but it's not a good idea.... good morning bro
Manish Giri
@Manish-Giri
Mar 04 2017 07:44
@Lumexralph :wave:
Ogundele Olumide
@Lumexralph
Mar 04 2017 07:44
@Manish-Giri how're you?
Manish Giri
@Manish-Giri
Mar 04 2017 07:44
@Lumexralph lol, that's why I didn't use eval()
completed the JavaScript calculator not using eval()
Ogundele Olumide
@Lumexralph
Mar 04 2017 07:45
@Manish-Giri don't mind me
Manish Giri
@Manish-Giri
Mar 04 2017 07:45
haha
i'm all right
how're you @Lumexralph
Ogundele Olumide
@Lumexralph
Mar 04 2017 07:45
:smile:
am just cool, the weather is also very friendly so far
playing around with python
Phiggins567
@phiggins567
Mar 04 2017 07:52
@Manish-Giri any advice on how to approach it? As I can't work out how to store the values and the math function
Manish Giri
@Manish-Giri
Mar 04 2017 07:55
@phiggins567 well you'll get the values by using .html() or .val() or by having IDs on the calculator buttons, like if a user clicks on the button 9, I gave it the ID #nine, and then I check what the ID was for the clicked button, and fetch the value accordingly...
as for the functions, I just had 4-6 basic functions, add, sub, divide etc, which takes two numbers and returns the result
Phiggins567
@phiggins567
Mar 04 2017 08:01
how would you chain them together?
Drew Seifert
@dseif003
Mar 04 2017 08:06
can anyone help me with
Make Object Properties Private challenge I have looked, read and researched everything short of getting the answer. I wanted to figure it out but I don't know what this is really asking
here is what I have so far

var Car = function() {
// this is a private variable
var speed = 10;

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

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

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

var Bike = function() {

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

};
this.getGear = function(){
bike -= 4;
};
this.setGear = function(){
bike -= 3;
};

var myCar = new Car();

var myBike = new Bike();

Ogundele Olumide
@Lumexralph
Mar 04 2017 08:07
@dseif003 setGear method should have a parameter that it assigns to the gear variable and getGear method should return gear
Drew Seifert
@dseif003
Mar 04 2017 08:08
like '3'?
I put that in the parenthesis but I get an error
Ogundele Olumide
@Lumexralph
Mar 04 2017 08:10
@dseif003
setGear(parameter) {
     gear = parameter
}

getGear() {  return gear }
manjulamk
@manjulamk
Mar 04 2017 08:11
var myStr ="Firstline"\n\\SecondLine\\r"ThirdLine" ;d token
i am getting invalid or unxpecte
please help me
Muhammad Hasham
@MohammadHasham
Mar 04 2017 08:17
anyone doing JS30 currently?
Drew Seifert
@dseif003
Mar 04 2017 08:23
this challenge makes no sense I have to go back a few challenges to see if I can make sense on this non sense and terrible instructions. so frustrating.
Dharminder Singh
@click4ds
Mar 04 2017 08:28
@dseif003 Did you figured out the solution?
Drew Seifert
@dseif003
Mar 04 2017 08:31
no
Dharminder Singh
@click4ds
Mar 04 2017 08:42
@dseif003 Try This

var Car = function() {
// this is a private variable
var speed = 10;

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

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

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

var Bike = function() {

// Only change code below this line.

var gear = 4;

this.setGear = function(setGear) {
gear = setGear;

};

this.getGear = function() {

return gear;

};

};

var myCar = new Car();

var myBike = new Bike();

myBike.getGear(1);
myBike.setGear(1);

in this function we are assigning value to setGear and then saving the value into private variable
郭向阳
@xzgg
Mar 04 2017 08:51

function translate(str) {
var letterchar=['a','e','i','o','u'];
var zifu=letterchar.join("");

for(i=0;i<str.length;i++){
var temp=str.charAt(i);
var num=zifu.indexOf(temp);

   if(num>0){
     str=str.substr(i)+str.substr(0,i-1)+"ay";

      return str;}

   else if(num==0){
       str=str+"way";

  return str;}

  }

}
translate("california");