These are chat archives for FreeCodeCamp/HelpJavaScript

2nd
May 2016
Randy Goldsmith
@Dueldrawer8
May 02 2016 00:01
@Zorba68 yes it seems to thank you
CamperBot
@camperbot
May 02 2016 00:01
dueldrawer8 sends brownie points to @zorba68 :sparkles: :thumbsup: :sparkles:
:star: 304 | @zorba68 | http://www.freecodecamp.com/zorba68
Randy Goldsmith
@Dueldrawer8
May 02 2016 00:01
@sjames1958gm thanks
CamperBot
@camperbot
May 02 2016 00:01
dueldrawer8 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: dueldrawer8 already gave sjames1958gm points
Justin Woodward
@jwoo92
May 02 2016 00:02
@Zorba68 @sjames1958gm i guess what i am having trouble with is how to perform what is asked. i am not sure how i should go about checking all objects for the name. sorry for the late reply i stepped away from my laptop.
Robert-Jan
@Zorba68
May 02 2016 00:03
@Dueldrawer8 Thing is, when the two character mismatch, you're done and it's not a palindrome. But when the characters match, you still need to check the rest.
@jwoo92 what you want is some kind of loop, and then you can do if (contacts[i].firstName === firstName)
llamatarianism
@llamatarianism
May 02 2016 00:11
@Dueldrawer8 really simple way to do it:
function palindrome(str) {
  return str === str.split("").reverse().join("");
}
literally checks if the string is equal to itself reversed.
you have to split and join though, since reverse only works on arrays not strings
Robert-Jan
@Zorba68
May 02 2016 00:14

@Dueldrawer8

function palindrome (string){ //abcba
    for(var i = 0; i < string.length/2; i++){
        if(string[i] != string[string.length - i - 1]){
            return false;
        }
    }
    return true;
}

there was still an error in the previous one.... need to use the i on both sides of the equation, as above

Randy Goldsmith
@Dueldrawer8
May 02 2016 00:16
@llamatarianism never thought of it that way.. thanks
CamperBot
@camperbot
May 02 2016 00:16
dueldrawer8 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star: 522 | @llamatarianism | http://www.freecodecamp.com/llamatarianism
Robert-Jan
@Zorba68
May 02 2016 00:18
yes that's the easy way :)
dontchaknow
@dontchaknow
May 02 2016 00:22
function mutation(arr) {
    var firstWord = arr[0].toLowerCase();
    var secondWord = arr[1].toLowerCase().split("");
    function compare(someChar) {
        return firstWord.indexOf(someChar) !== -1;
    }
    return secondWord.every(compare);
}
for readability, should I have used variables or is it better to do it like the wiki and not use variables and save memory?
Robert-Jan
@Zorba68
May 02 2016 00:33
@dontchaknow I think it's best to write it such, that you're comfortable reading it
Robert-Jan
@Zorba68
May 02 2016 00:36
@Alhaji24 at first sight it looks correct... what goes wrong?
Ronique Ricketts
@RoniqueRicketts
May 02 2016 00:37
To close a set of if else if functions shouldn't else be the last statement in a function?
Diego Mayer
@Chrono79
May 02 2016 00:37
@llamatarianism I think the part with the regex is missing there
llamatarianism
@llamatarianism
May 02 2016 00:37
@Chrono79 oh yeah, thanks. I forget you need to filter out non-alphanumerics.
CamperBot
@camperbot
May 02 2016 00:37
llamatarianism sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 581 | @chrono79 | http://www.freecodecamp.com/chrono79
dontchaknow
@dontchaknow
May 02 2016 00:37
@Zorba68 thanks that's my feeling as well.
llamatarianism
@llamatarianism
May 02 2016 00:38
@RoniqueRicketts you don't necessarily need an else for every if.
Yan Kozlovskiy
@YanKozlovskiy
May 02 2016 00:38
@RoniqueRicketts if is called a condition not a function
Ronique Ricketts
@RoniqueRicketts
May 02 2016 00:39
@llamatarianism i am doing multiple if statements
Yan Kozlovskiy
@YanKozlovskiy
May 02 2016 00:39
a function is something that executes a series of statements
Diego Mayer
@Chrono79
May 02 2016 00:39
@Dueldrawer8 you need to filter out non-alphanumerics before the comparison
Yan Kozlovskiy
@YanKozlovskiy
May 02 2016 00:39
a condition checks whether or not something is true
Ronique Ricketts
@RoniqueRicketts
May 02 2016 00:39
@YanKozlovskiy thanks for the correction.
CamperBot
@camperbot
May 02 2016 00:39
roniquericketts sends brownie points to @yankozlovskiy :sparkles: :thumbsup: :sparkles:
:star: 212 | @yankozlovskiy | http://www.freecodecamp.com/yankozlovskiy
Yan Kozlovskiy
@YanKozlovskiy
May 02 2016 00:39
if will run the block inside the code when that condition is true
if the condition is not true it will never run the block of code inside the condition
Aparna
@Aparna-S
May 02 2016 00:41
hi all, im doing "Counting Cards" challenge
not about to figure out what is expected, i tried ussing if statements and { count = count + 1;
return count + "Beta";
}
but doesnot work , throws error

this is the given code - var count = 0;

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

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

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

Diego Mayer
@Chrono79
May 02 2016 00:42
@Aparna-S I don't understand your code
Taneisha S. Mitchell-Gayle
@taneipoo
May 02 2016 00:42
wiki format
CamperBot
@camperbot
May 02 2016 00:42
no wiki entry for: format
Ronique Ricketts
@RoniqueRicketts
May 02 2016 00:43
@YanKozlovskiy i have 6 results I want the program to search through so when I pass my arguments through the function and 5 are incorrect it should take the default value, should the default condition be closing with an else?
Diego Mayer
@Chrono79
May 02 2016 00:43
help format
CamperBot
@camperbot
May 02 2016 00:43

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Robert-Jan
@Zorba68
May 02 2016 00:43
here's the code from @Alhaji24 ... I can't see anything wrong with it?
function testGreaterThan(val) {
  if (val > 100) {  // Change this line
    return "Over 100";
  }

  if (val > 10) {  // Change this line
    return "Over 10";
  }

  return "10 or Under";
}

// Change this value to test
testGreaterThan(10);
Diego Mayer
@Chrono79
May 02 2016 00:44
@Zorba68 challenge name?
Aparna
@Aparna-S
May 02 2016 00:44

@Chrono79 thisis what asked - Having more high cards remaining in the deck favors the player. Each card is assigned a value according to the table below. When the count is positive, the player should bet high. When the count is zero or negative, the player should bet low.

Count Change Cards
+1 2, 3, 4, 5, 6
0 7, 8, 9
-1 10, 'J', 'Q', 'K','A'
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.

Example Output
"-3 Hold"
"5 Bet"

Hint
Do NOT reset count to 0 when value is 7, 8, or 9.

Robert-Jan
@Zorba68
May 02 2016 00:45
@Chrono79 I dunno.. @Alhaji24 still here?
Diego Mayer
@Chrono79
May 02 2016 00:45
@Aparna-S Yes, I know that's the challenge description, I didn't understand what you posted
Aparna
@Aparna-S
May 02 2016 00:46

@Chrono79 this is the code they have provided - var count = 0;

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

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

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

Diego Mayer
@Chrono79
May 02 2016 00:46
@Aparna-S Ok, have you made some code yourself?
@Zorba68 Me neither, maybe he has to refresh the browser
@Aparna-S you have to test the card value and modify count value based on the info they provided
Aparna
@Aparna-S
May 02 2016 00:49
@Chrono79 i tried something like this- " if (card == 2) { count = count + 1;
return count + "Beta";
}
Diego Mayer
@Chrono79
May 02 2016 00:50
@Aparna-S no, you only have to return after you've evaluated all possible card values, and based on count value
Beta isn't one of the values you must return, they are Bet or Hold
First, make an if/else block or switch to evaluate card value, and modify count
Aparna
@Aparna-S
May 02 2016 00:53
if (card == 2 && card == 3 && card == 4 && card == 5 && card == 6)
{ count = count + 1;
this one also not correct right?
Diego Mayer
@Chrono79
May 02 2016 00:53
After that make another if/else to return count + Bet or Hold
@Aparna-S No, look, card can't be 2, 3, 4, 5 and 6 at the same time
Aparna
@Aparna-S
May 02 2016 00:54
@Chrono79 we have check for all 6 cards and then return?
Diego Mayer
@Chrono79
May 02 2016 00:55
Wait, first let's have one thing done right
Let's fix your if condition
how do you fix it?
Use another logical operator or you can change it using comparison operators
Norvin Burrus
@ndburrus
May 02 2016 00:57
@Aparna-S you might want to consider using a case statement...
Ronique Ricketts
@RoniqueRicketts
May 02 2016 00:57
help Gulf code
CamperBot
@camperbot
May 02 2016 00:57
no wiki entry for: gulf code
Norvin Burrus
@ndburrus
May 02 2016 00:58
help golf code
CamperBot
@camperbot
May 02 2016 00:58

:point_right: challenge golf code [wiki]

Details

We will now use our knowledge about else if statements and comparison with equality, less and greater operators.

In the game of golf each hole has a par for the average number of strokes needed to sink the ball. Depending on how far above or below par your strokes are, there is a different nickname.

Your function will be passed a par and strokes. Return strings according to this table (based on order of priority - top (highest) to bottom (lowest)):

Strokes Return
1 "Hole-in-one!"
<= par - 2 "Eagle"
par - 1 "Birdie"
par "Par"
par + 1 "Bogey"
par + 2 "Double Bogey"
>= par + 3 "Go Home!"

par and strokes will always be numeric and positive.

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.
:pencil: read more about challenge golf code on the FCC Wiki

Aparna
@Aparna-S
May 02 2016 00:58
@Chrono79 if (card >= 2 && card <=6)
{ count = count + 1;
}
this way?
Diego Mayer
@Chrono79
May 02 2016 00:59
@Aparna-S yes
Complete the else with the other cards that modify count
You can't use && in that case, use the other logical operator
Norvin Burrus
@ndburrus
May 02 2016 01:00
@RoniqueRicketts are you working on this one?
Ronique Ricketts
@RoniqueRicketts
May 02 2016 01:01
@ndburrus Yes I am and I am stuck on it for about 24hrs now. :(
Norvin Burrus
@ndburrus
May 02 2016 01:01
@RoniqueRicketts can you post what you have? :)
Ronique Ricketts
@RoniqueRicketts
May 02 2016 01:02

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

else
return "Go Home";
// Only change code above this line
}

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

Norvin Burrus
@ndburrus
May 02 2016 01:03
@RoniqueRicketts how many tests pass?
Ronique Ricketts
@RoniqueRicketts
May 02 2016 01:03
everything except the last part else return "Go Home";
Norvin Burrus
@ndburrus
May 02 2016 01:04
hmmm... take a closer look at this code...
return "Go Home";
Jack
@jackdois
May 02 2016 01:04
hey, having problems passing step 197 - Local Scope and Functions. Anyone tell me what i am doing wrong.

function myLocalScope() {
'use strict';
var myVar = "hello";

console.log(myVar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);

// Now remove the console log line to pass the test

Ronique Ricketts
@RoniqueRicketts
May 02 2016 01:05
should that be in curly braces like else { return "Go Home";
ZctrapCoding
@ZctrapCoding
May 02 2016 01:05

@RoniqueRicketts I just came but it think its
```
echo {

}

yeah
Diego Mayer
@Chrono79
May 02 2016 01:05
@jackdois // Now remove the console log line to pass the test <- delete the line above this one
Norvin Burrus
@ndburrus
May 02 2016 01:05
Here is what the requirement is.... see any discrepancy?
Strokes    Return
>= par + 3    "Go Home!"
ZctrapCoding
@ZctrapCoding
May 02 2016 01:05
@RoniqueRicketts it should be
Aparna
@Aparna-S
May 02 2016 01:05

@Chrono79 if (card >= 2 && card <=6)
{ count = count + 1;
return count + " Bet";
}

else if (card >= 7 && card <=9)
{count = count + 0;
return count + " Hold";
}

else if (card== 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A')
{
count = count - 1;
return count + " Hold";
}
else {

return "Change Me";
}

Jack
@jackdois
May 02 2016 01:06
@Chrono79 I have deleted the last line console.log(myVar); and it doesn't pass me...
Diego Mayer
@Chrono79
May 02 2016 01:06
@Aparna-S don't return in the first if/else block
Aparna
@Aparna-S
May 02 2016 01:06
i am still yet to get Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"
Cards Sequence 2, 2, 10 should return "1 Bet" right @Chrono79
Ronique Ricketts
@RoniqueRicketts
May 02 2016 01:06
@ndburrus I tried that earlier and it didn't accept.
idk what i did wrong there
Aparna
@Aparna-S
May 02 2016 01:07
@ndburrus i used if/else statement ..
Norvin Burrus
@ndburrus
May 02 2016 01:07
@RoniqueRicketts let's zoom in...."Go Home!" vs. "Go Home"
Ronique Ricketts
@RoniqueRicketts
May 02 2016 01:07
exclamation.. :)
Norvin Burrus
@ndburrus
May 02 2016 01:07
@RoniqueRicketts You're cooking now! :+1:
Diego Mayer
@Chrono79
May 02 2016 01:07
@jackdois refresh the browser and try again
@Aparna-S look
Norvin Burrus
@ndburrus
May 02 2016 01:08
@RoniqueRicketts does it pass the tests now?
Ronique Ricketts
@RoniqueRicketts
May 02 2016 01:08
lmao!!! i am deading right now with laughter. I could smack myself. auugh. lmao.
yes it did
:D
Norvin Burrus
@ndburrus
May 02 2016 01:09
@RoniqueRicketts awesomesauce! :sparkles:
Tim
@codemymind
May 02 2016 01:09
Thank you @bitgrower for your help on Counting Cards challenge !
CamperBot
@camperbot
May 02 2016 01:09
:star: 1026 | @bitgrower | http://www.freecodecamp.com/bitgrower
codemymind sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
Diego Mayer
@Chrono79
May 02 2016 01:09
 if (card >= 2 && card <=6)
{ count = count + 1;
} else if (card >= 7 && card <=9) // not needed because count + 0 is still count
{count = count + 0;
}
else if (card== 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A')
{
count = count - 1;
}

//here make another if to evaluate count value and return count + Bet or Hold
Jack
@jackdois
May 02 2016 01:09
Thanks @Chrono79 sure i had tried that a few times..have been doing that again and again and couldn't work out why it wasn't passing me...
CamperBot
@camperbot
May 02 2016 01:09
jackdois sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 582 | @chrono79 | http://www.freecodecamp.com/chrono79
FromMotherOwl
@FromMotherOwl
May 02 2016 01:09
Can anyone else with "Increment a Number with JavaScript"
Either I'm really really slow (entirely possible) or I have no idea what its asking
Tim
@codemymind
May 02 2016 01:10
@FromMotherOwl type that into google followed by FCC and you can usually find a solution. or paste your code here so we can see where youre at
FromMotherOwl
@FromMotherOwl
May 02 2016 01:10

var myVar = 87;

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

myVar should equal 88
myVar = myVar should be changed
Use the ++ operator
Do not change code above the line
Norvin Burrus
@ndburrus
May 02 2016 01:11
@FromMotherOwl ok, the ++ operator increments a value/variable by 1....
Diego Mayer
@Chrono79
May 02 2016 01:11
@FromMotherOwl there you go, use myVar++; instead of myVar = myVar +1;
FromMotherOwl
@FromMotherOwl
May 02 2016 01:11
Oooooooooooooooooooooooooooo @Chrono79
Moisés Man
@moigithub
May 02 2016 01:12
many ways to increment::
myVar = myVar + 1;
myVar += 1;
myVar++;
all do the same
@FromMotherOwl
FromMotherOwl
@FromMotherOwl
May 02 2016 01:12
@Chrono79 Thanks...I don't know why I couldn't get to that
CamperBot
@camperbot
May 02 2016 01:12
frommotherowl sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 583 | @chrono79 | http://www.freecodecamp.com/chrono79
FromMotherOwl
@FromMotherOwl
May 02 2016 01:12
Also thanks @ndburrus and @moigithub
CamperBot
@camperbot
May 02 2016 01:12
frommotherowl sends brownie points to @ndburrus and @moigithub :sparkles: :thumbsup: :sparkles:
:star: 304 | @ndburrus | http://www.freecodecamp.com/ndburrus
:star: 1040 | @moigithub | http://www.freecodecamp.com/moigithub
Aparna
@Aparna-S
May 02 2016 01:12

@Chrono79 if (card >= 2 && card <=6)
{ count = count + 1;

}

else if (card >= 7 && card <=9)
{count = count + 0;

  }

else if (card== 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A')
{
count = count - 1;

}
else {

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

is this right?
Tim
@codemymind
May 02 2016 01:12
myVar++; wiould be what theyre trying to teach ya
FromMotherOwl
@FromMotherOwl
May 02 2016 01:13
I've yet to not been able to find help here, I appreciate you!!!
Tim
@codemymind
May 02 2016 01:13
:) I'm learning too and have found wonderful help here and in the main chat
Diego Mayer
@Chrono79
May 02 2016 01:13
@Aparna-S not quite there yet
delete the else return change me
Norvin Burrus
@ndburrus
May 02 2016 01:13
@FromMotherOwl ...the instruction text offers a clue: (1st sentence): You can easily increment or add one to a variable with the ++ operator.
@FromMotherOwl Kudos to you! :)
Tim
@codemymind
May 02 2016 01:14
i've found googling the challenge name and follow it with FCC - the github URLs up top usually have the solution if nobody answers ya here
FromMotherOwl
@FromMotherOwl
May 02 2016 01:14
@ndburrus I think I was stuck with there actually being an 'i' somewhere
Diego Mayer
@Chrono79
May 02 2016 01:14
@Aparna-S read again the conditions about count value, you got them wrong
and no need to put a condition in that else, because if it's not positive is 0 or negative
FromMotherOwl
@FromMotherOwl
May 02 2016 01:15
Yeah normally I take to google, since it knows everything, but I knew it had to be some basic thing I was over looking lol
Norvin Burrus
@ndburrus
May 02 2016 01:15
@FromMotherOwl the i is just a representation of any variable.... :) in this case - myVar
Tim
@codemymind
May 02 2016 01:16
@FromMotherOwl if the "i" was the confusing part - keep in mind the examples mostly dont show you the actual challenge - just an example ! so most likely its gonna be the same but with the variable etc in the challenge that needs to be modified
hope that makes sense lol
Diego Mayer
@Chrono79
May 02 2016 01:16
Sometimes I think it should be FacePalmCamp after you see how easily it's done ;)
FromMotherOwl
@FromMotherOwl
May 02 2016 01:16
@codemymind Yeah, I'm just getting into the whole jquery thing...it's kind of intimidating....at least for me
Norvin Burrus
@ndburrus
May 02 2016 01:17
@FromMotherOwl No Fear! :sparkles:
Tim
@codemymind
May 02 2016 01:17
You got this! :)
FromMotherOwl
@FromMotherOwl
May 02 2016 01:17
Thanks You're the best!
Tim
@codemymind
May 02 2016 01:17
var count = 0;

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

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Aparna
@Aparna-S
May 02 2016 01:17
@Chrono79 i changed it to else , still cant get what condition i went wrong :(
Tim
@codemymind
May 02 2016 01:18
ive found this solution on github for Counting Cards but not sure about the ? -
can anyone please explain a better way to return that FCC has covered
Diego Mayer
@Chrono79
May 02 2016 01:18
@codemymind it's called ternary operator, it's a shorthand for an if/else block that has a return value implicit
Tim
@codemymind
May 02 2016 01:19
the switch/case makes sense, but the concentation in the return has me confused a bit
Diego Mayer
@Chrono79
May 02 2016 01:19
@codemymind it's like this if:
if (count>0) return count+ " Bet";
  else return count+ " Hold";
Tim
@codemymind
May 02 2016 01:19
@Chrono79 what would be the best way to return the switch statement without using the ternary operator - is my question I think? lol
ok thank you, that answers it!
@Chrono79 thank you
CamperBot
@camperbot
May 02 2016 01:20
codemymind sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 584 | @chrono79 | http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
May 02 2016 01:20
no problem
Tim
@codemymind
May 02 2016 01:20
ternary operator it is, lol -
Norvin Burrus
@ndburrus
May 02 2016 01:20
@codemymind you can use the count variable, along with variable for the bet/hold parameters to put a string together...
Diego Mayer
@Chrono79
May 02 2016 01:21
@Aparna-S paste your code again
Norvin Burrus
@ndburrus
May 02 2016 01:21
if (count > 0) {
        myStr = "Bet";
  } else {
        myStr = "Hold";
  }

  return count + " " + myStr;
Tim
@codemymind
May 02 2016 01:21
@ndburrus would you humor me and elaborate a little, please?
@ndburrus thank you
CamperBot
@camperbot
May 02 2016 01:21
codemymind sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star: 305 | @ndburrus | http://www.freecodecamp.com/ndburrus
Tim
@codemymind
May 02 2016 01:22
got it
Aparna
@Aparna-S
May 02 2016 01:22

@Chrono79 var count = 0;

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

}

else if (card >= 7 && card <=9)
{count = count + 0;

  }

else if (card== 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A')
{
count = count - 1;

}

if (count>= 1)
{
return count + " Bet";
}
else
{
return count + " 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');

Norvin Burrus
@ndburrus
May 02 2016 01:22
@codemymind Great! :fire:
Diego Mayer
@Chrono79
May 02 2016 01:22
This message was deleted
Tim
@codemymind
May 02 2016 01:23
ironic were on the same challenge, doing it two different ways? lol
Dan Gallegos
@gallegos20
May 02 2016 01:24
I'm on the card counting challenge...
it's not accepting my code
But... in console it works?

var count = 0;

function cc(card) {
// Only change code below this line
if(card < 7){
count++;

} if(count >= 1){
return count + " Bet";
}
else if(card < 10){
count = count + 0;
if(count < 1){
return count + " Hold";
}
} else if(card == 10 || "J" || "Q" || "K" || "A"){
count--;
if(count < 1){
return count + " Hold";
}
}
}
// Only change code above this line

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

''js var count = 0;

function cc(card) {
// Only change code below this line
if(card < 7){
count++;

} if(count >= 1){
return count + " Bet";
}
else if(card < 10){
count = count + 0;
if(count < 1){
return count + " Hold";
}
} else if(card == 10 || "J" || "Q" || "K" || "A"){
count--;
if(count < 1){
return count + " Hold";
}
}
}
// Only change code above this line

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

Diego Mayer
@Chrono79
May 02 2016 01:24
@Aparna-S I think it should work
Aparna
@Aparna-S
May 02 2016 01:25
@Chrono79 ya it works , thank you !! :)
CamperBot
@camperbot
May 02 2016 01:25
aparna-s sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 585 | @chrono79 | http://www.freecodecamp.com/chrono79
Dan Gallegos
@gallegos20
May 02 2016 01:25
Can smeone help me figure out why my code isn't working for the challenge? Web browser console seems to accept it and reflect the answers they want
but.. I don't know why it wont take it.
Diego Mayer
@Chrono79
May 02 2016 01:25
@Aparna-S in this case, it works with the condition count >=1, but in general positive numbers means > 0
Coryphaeus
@cvdeby
May 02 2016 01:25
I didn't know, eval function is so useful)
Dan Gallegos
@gallegos20
May 02 2016 01:26

```javascript var count = 0;

function cc(card) {
// Only change code below this line
if(card < 7){
count++;

} if(count >= 1){
return count + " Bet";
}
else if(card < 10){
count = count + 0;
if(count < 1){
return count + " Hold";
}
} else if(card == 10 || "J" || "Q" || "K" || "A"){
count--;
if(count < 1){
return count + " Hold";
}
}
}
// Only change code above this line

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

Coryphaeus
@cvdeby
May 02 2016 01:26
Hi @Chrono79 )
Dan Gallegos
@gallegos20
May 02 2016 01:26
ugh
Diego Mayer
@Chrono79
May 02 2016 01:26
@cvdeby Yo
Aparna
@Aparna-S
May 02 2016 01:26
@Chrono79 ohh ok.. got it !!
Dan Gallegos
@gallegos20
May 02 2016 01:26

``` var count = 0;

function cc(card) {
// Only change code below this line
if(card < 7){
count++;

} if(count >= 1){
return count + " Bet";
}
else if(card < 10){
count = count + 0;
if(count < 1){
return count + " Hold";
}
} else if(card == 10 || "J" || "Q" || "K" || "A"){
count--;
if(count < 1){
return count + " Hold";
}
}
}
// Only change code above this line

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

UGH WHY is markdown not working
sorry guys
Diego Mayer
@Chrono79
May 02 2016 01:26
@gallegos20 if card is 1 it's <7 isn't it?
Dan Gallegos
@gallegos20
May 02 2016 01:27
Ah
so it's my order?
Diego Mayer
@Chrono79
May 02 2016 01:27
@gallegos20 separate card value evaluation of count value evaluation in 2 blocks, either 2 ifs, or 1 switch and 1 if
you have to return only in the block where you evaluate count value
Dan Gallegos
@gallegos20
May 02 2016 01:28
wait.
So.. if card is 1 yes it's < 7.. but that's not a card so why does it matter
my question is, why does it return correctly in console?
llamatarianism
@llamatarianism
May 02 2016 01:29
@gallegos20 you need new lines before and after your ```
Coryphaeus
@cvdeby
May 02 2016 01:29
@gallegos20 hit shift+enter after backquotes.
llamatarianism
@llamatarianism
May 02 2016 01:29
(card == 10 || "J" || "Q" ...) is wrong.
everything inside an if statement is evaluated as a boolean
so if you write (card == 10 || "J" || "Q" ...) then that evaluates to this:
if card equals 10 or "J" is truthy (non-empty) or "Q" is truthy (non-empty)...
Dan Gallegos
@gallegos20
May 02 2016 01:31
Ah.
Is it safe to say an if statement isn't the way to approach this
llamatarianism
@llamatarianism
May 02 2016 01:31
nah
you can use an if statement
just don't chain ors in a silly way
you could write out a long chain of equals but I'd just write this
Diego Mayer
@Chrono79
May 02 2016 01:31
@gallegos20 and separate card and count evaluation
llamatarianism
@llamatarianism
May 02 2016 01:31
if (card === 10 || /J|Q|K|A/.test(card))
use a regex to test if it's J or Q or K or A.
Diego Mayer
@Chrono79
May 02 2016 01:32
@llamatarianism you can, but I think it's complicated (at least at this point)
llamatarianism
@llamatarianism
May 02 2016 01:32
ehhh
it's definitely a little more complicated
Dan Gallegos
@gallegos20
May 02 2016 01:33
Ok. Fair enough, thanks for the input.
llamatarianism
@llamatarianism
May 02 2016 01:33
but I prefer it to writing out if (card === 10 || card === "J" || card === "Q" ...)
Dan Gallegos
@gallegos20
May 02 2016 01:33
Let me revisit this and hammer away, thanks guys!
llamatarianism
@llamatarianism
May 02 2016 01:33
or the really long case statements
speaking of this
scala's pattern matching is really nice.
Robert-Jan
@Zorba68
May 02 2016 01:33
@gallegos20 you may want to look at switch, very easy to read
llamatarianism
@llamatarianism
May 02 2016 01:33
card match {
  case 10 | "J" | "Q" | "K" | "A" => " Bet"
}
does exactly what you'd expect.
Diego Mayer
@Chrono79
May 02 2016 01:34
@llamatarianism nice and clean, I like that
Landon
@landonwaldner
May 02 2016 01:34

function cc(card) {
// Card evaluation
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 7:
case 8:
case 9:
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count--;

//Count Evaluation
if (count<=0){return count + " Hold";}
else return count +" Bet";

}

Anyone know the problem with this?
Or can give a pointer
Diego Mayer
@Chrono79
May 02 2016 01:35
@landonwaldner missing } (closing switch)
llamatarianism
@llamatarianism
May 02 2016 01:35
@Chrono79 scala is generally a very nice language. I'd recommend learning it. it's somewhere inbetween java and ruby and is focused on functional programming, but with some objects in there.
I'm more partial to clojure but scala has some great features
the nice thing about pattern matching and if/elses in scala is that they're expressions, too
Landon
@landonwaldner
May 02 2016 01:36
holy am i ever a retard lol
thanks
how did you pick that up so fast
it was solving 4 of the 7 inputs
while missing the close bracket
Diego Mayer
@Chrono79
May 02 2016 01:37
a lot of find the 7 differences when I was a kid, lol
Landon
@landonwaldner
May 02 2016 01:39
lol
llamatarianism
@llamatarianism
May 02 2016 01:39
val bar = 22
val foo = "baz"
val spam = foo + (bar match {
  case 22 | 21 => " eggs"
  case 23 | 20 => " ham"
})
println(spam) // => "baz eggs"
same goes for if/else
Dan Gallegos
@gallegos20
May 02 2016 01:39
@Zorba68 thanks
CamperBot
@camperbot
May 02 2016 01:39
gallegos20 sends brownie points to @zorba68 :sparkles: :thumbsup: :sparkles:
:star: 305 | @zorba68 | http://www.freecodecamp.com/zorba68
Dan Gallegos
@gallegos20
May 02 2016 01:39
@Chrono79 Thanks
@llamatarianism Thanks
llamatarianism
@llamatarianism
May 02 2016 01:39
val spam = foo + (if (bar == 22) " eggs" else " ham")
println(spam) // => "baz eggs"
CamperBot
@camperbot
May 02 2016 01:39
gallegos20 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star: 525 | @llamatarianism | http://www.freecodecamp.com/llamatarianism
llamatarianism
@llamatarianism
May 02 2016 01:40
way simpler and nicer than the ternary operator
Dan Gallegos
@gallegos20
May 02 2016 01:40
@Chrono79 Thank you
CamperBot
@camperbot
May 02 2016 01:40
gallegos20 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 586 | @chrono79 | http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
May 02 2016 01:40
@llamatarianism and easier to understand
Robert-Jan
@Zorba68
May 02 2016 01:40
@llamatarianism that's a nice shortcut indeed
llamatarianism
@llamatarianism
May 02 2016 01:41
I think it works in clojure ( <3 ) too
Coryphaeus
@cvdeby
May 02 2016 01:41
This message was deleted
Diego Mayer
@Chrono79
May 02 2016 01:42
I recommend hackerrank regex challenges, very instructive
llamatarianism
@llamatarianism
May 02 2016 01:43
(def foo "bar")
(def bar 22)
(def baz
  (str foo (if (= 22 bar)
    " eggs"
    " ham")))
(println baz) ; baz eggs
Coryphaeus
@cvdeby
May 02 2016 01:43
@llamatarianism Does that work?)
val bar = 22
val foo = "baz"
val spam = foo + (bar match {
  case 22 | 21 => " eggs"
  case 23 | 20 => " ham"
})
println(spam) // => "baz eggs"
llamatarianism
@llamatarianism
May 02 2016 01:43
@cvdeby yeah
Coryphaeus
@cvdeby
May 02 2016 01:43
@llamatarianism Cool)
Like switch with return)
@llamatarianism Does it es6 feature.
llamatarianism
@llamatarianism
May 02 2016 01:46
oh I think you've misunderstood.
that's not javascript
it's scala
This message was deleted
Coryphaeus
@cvdeby
May 02 2016 01:46
@llamatarianism Aa)
Diego Mayer
@Chrono79
May 02 2016 01:46
@llamatarianism do you know Ruby?
llamatarianism
@llamatarianism
May 02 2016 01:47
@Chrono79 some. it's been a while.
I still have a soft spot for it because it was my gateway drug that led me into functional programming
Diego Mayer
@Chrono79
May 02 2016 01:47
Have you seen how trivial is Caesar Cipher in Ruby?
Coryphaeus
@cvdeby
May 02 2016 01:47
@llamatarianism Which platforms are using scala?
llamatarianism
@llamatarianism
May 02 2016 01:48
@cvdeby the most famous 2 are twitter and tumblr
oops
it's a hosted language that runs in the JVM
so you can do anything java can do and more with scala
including making android apps
Coryphaeus
@cvdeby
May 02 2016 01:48
@llamatarianism Android?
llamatarianism
@llamatarianism
May 02 2016 01:49
@cvdeby yeah. like, phones.
Coryphaeus
@cvdeby
May 02 2016 01:49
@llamatarianism Ou, cool) I wanna learn scala)
Coryphaeus
@cvdeby
May 02 2016 01:50
@llamatarianism On free time I learn android development) ( and English :smile:)
@llamatarianism Ahah, Derek, I love him lessons)
@llamatarianism Thanks)
CamperBot
@camperbot
May 02 2016 01:50
cvdeby sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star: 526 | @llamatarianism | http://www.freecodecamp.com/llamatarianism
llamatarianism
@llamatarianism
May 02 2016 01:51
@Chrono79 wow, that's very small.
Diego Mayer
@Chrono79
May 02 2016 01:51
I hated it when I saw it, in javascript you have to think a lot more
Dan Gallegos
@gallegos20
May 02 2016 01:55
ok guys
went with this
llamatarianism
@llamatarianism
May 02 2016 01:56
@Chrono79 ooh y'know what's neat about clojure
and I think also java by extension
you can just convert a char to an int or an int to a char
Dan Gallegos
@gallegos20
May 02 2016 01:56
var count = 0;
var choice = "";

function cc(card) {
switch(card){
  case 1:
  case 2:
  case 3:
  case 4:
  case 5:
  case 6:
    count++;
    break;
  case 7:
  case 8:
  case 9:
    break;
  case 10:
  case "J":
  case "Q":
  case "K":
  case "A":
    count--;
    break;
}
if(count > 0){
  choice = " Bet";
}
  else if(count <= 0){
  choice = " Hold";
  }

  // Only change code below this line


  return count + choice;
  // Only change code above this line
}
llamatarianism
@llamatarianism
May 02 2016 01:56
no need for the String.charCodeAt and String.fromCharCode
Diego Mayer
@Chrono79
May 02 2016 01:57
@llamatarianism That's nice
@gallegos20 no need for var choice, and no need for if (count <= 0) in that else
It should work though
Dan Gallegos
@gallegos20
May 02 2016 01:58
ok cool, thank you @Chrono79
CamperBot
@camperbot
May 02 2016 01:58
gallegos20 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: gallegos20 already gave chrono79 points
llamatarianism
@llamatarianism
May 02 2016 02:05
; tried to make a rot13 in clojure.
(require '[clojure.string :as s])

(defn rot13-char [ch]
  "Rotates each character."
  (if (re-matches #"\W|_" (str ch))
    ch
  (do
    (let [chcode (int ch)]
    (if (>= chcode 78)
      (char (- chcode 13))
      (char (+ chcode 13)))))))

(defn rot13-string [str]
  "Rotates an entire string."
  (s/join "" (map rot13 (s/upper-case str))))
actually wait, that doesn't ignore non-alphabet chars
Coryphaeus
@cvdeby
May 02 2016 02:07
@llamatarianism Does scala a little bit similar with python?
llamatarianism
@llamatarianism
May 02 2016 02:07
@cvdeby a little bit. I'd compare it more to ruby.
llamatarianism
@llamatarianism
May 02 2016 02:15
thing about clojure
I have precisely no idea when to indent anything :P
shawnlunny
@shawnlunny
May 02 2016 02:17

Hey guys I am working on the roman numeral JS problem and am extremely close although frustratingly "far". I am unsure where my logic is wrong. In my example I am trying to run the rules so any given number can be converted. I know I could do the special cases in my object but really want to do this with the logic I have.

How do you share your page in chat?

Tyler
@tylergross
May 02 2016 02:17
@shawnlunny
help format
CamperBot
@camperbot
May 02 2016 02:17

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Norvin Burrus
@ndburrus
May 02 2016 02:18
@shawnlunny roman numeral?
shawnlunny
@shawnlunny
May 02 2016 02:21
function convertToRoman(num) {
  //create key:value pairs
  var romanLookup = {M:1000, D:500, C:100, L:50, X:10, V:5, I:1};
  var roman = [];
  var romanKeys = Object.keys(romanLookup);
  var curValue;
  var index;
  var count = 1;
  var origNum = num;

  for(var i in romanLookup){
    curValue = romanLookup[i];
    index = romanKeys.indexOf(i);

    while(num >= curValue){
      //push up to three of the same roman numeral
      if(count < 4){
        roman.push(i);
      } else {
        //if we were going to push more than 3 we need to rework the numerals
        //first pop off the roman numerals we just added
        while(count > 1){
          roman.pop();
          count--;
        }

        //check which value to swap with either 1 previous or 2 previous
        //this can either be something like the number 40 (XL) 4 (IV)
        if(origNum <= (romanLookup[romanKeys[index - 1]] + curValue)){
          roman.push(romanKeys[index]);
          roman.push(romanKeys[index - 1]);
        } else {
          //this would be something like 900 (CM) or 9 (IX)
          roman.push(romanKeys[index]);
          roman.push(romanKeys[index - 2]);
        }
      }
      num -= curValue;
      count++;
    }
    count = 1;
  }
 return roman.join("");
}
convertToRoman(44); //XLIV //I get: XLIX
//convertToRoman(36);
//convertToRoman(9);
//convertToRoman(4);
//convertToRoman(649); //DCXLIX //I get: DCXCVIX
The numbers with issues are listed below the code there.
as examples
Juan L
@rustyflakes
May 02 2016 02:24
I need help with my random quote generator
I don't know how to append the Quote and the Author data to my html elements.
``` function getQuote() {
$.ajax({
headers: {
"X-Mashape-Key": "OivH71yd3tmshl9YKzFH7BTzBVRQp1RaKLajsnafgL2aPsfP9V",
Accept: "application/json",
"Content-Type": "application/x-www-form-urlencoded"
},
url: 'https://andruxnet-random-famous-quotes.p.mashape.com/cat=',
success:
}
})}
```
function getQuote() {
  $.ajax({
    headers: {
      "X-Mashape-Key": "OivH71yd3tmshl9YKzFH7BTzBVRQp1RaKLajsnafgL2aPsfP9V",
      Accept: "application/json",
      "Content-Type": "application/x-www-form-urlencoded"
    },
    url: 'https://andruxnet-random-famous-quotes.p.mashape.com/cat=',
    success: 
    }
shawnlunny
@shawnlunny
May 02 2016 02:28
@rustyflakes you should be able to take the success response object (im assuming json object) and take the author and Quote from it and append some html around it. Is this what you mean? It's unclear where you are having an issue.
@tylergross thanks for the chat help for how to format code.
CamperBot
@camperbot
May 02 2016 02:30
shawnlunny sends brownie points to @tylergross :sparkles: :thumbsup: :sparkles:
:star: 363 | @tylergross | http://www.freecodecamp.com/tylergross
Tyler
@tylergross
May 02 2016 02:33
@shawnlunny np sorry i couldn't help i looked at your code but you took a completely different approach to this challenge that i took originally
than
Chris Humphreys
@ChrisCHumphreys
May 02 2016 02:34
anyone have time to play a little tic tac toe. just want to make sure it is unbeatable. if you have time here it is. thanks! http://codepen.io/geochris35/pen/oxarpZ/?editors=0010
shawnlunny
@shawnlunny
May 02 2016 02:36
@tylergross Yes I can make this easier by doing something like CM and IX etc right in the roman lookup object but I really don't want to "cheat". I also think I know where the logic bug is; its in that logic where i decide to look back 1 or 2 numerals and swap.... specifically: if(origNum <= (romanLookup[romanKeys[index - 1]] + curValue)){
I'm just not sure what I would need to make that to work for all cases
Chris Humphreys
@ChrisCHumphreys
May 02 2016 02:36
might be best to look at it in full screen, it is pretty cramped in the little window
Sekhar Kolli
@SekharKolli
May 02 2016 02:36
@geochris35 , for some reason, I’m unable to place an x in the centre of the board. Your doesn’t seem to allow that
Samuel Cupidon
@Zerazera
May 02 2016 02:37
@geochris35 After I play one game the Xs and Os disappear and if I click around I get "you lost" or "tied" messages
Coryphaeus
@cvdeby
May 02 2016 02:37
@geochris35 If I'll click on field before I choose piece - program begins to crash.
Tyler
@tylergross
May 02 2016 02:37
@geochris35 might have a bug or two... what happens when you click the "Choose x or o" twice or multiple after?
Chris Humphreys
@ChrisCHumphreys
May 02 2016 02:38
@tylergross @cvdeby @Zerazera Haha. thanks you guys! I never thought of people doing that. I guess I have some debugging to do!
Samuel Cupidon
@Zerazera
May 02 2016 02:38
@geochris35 Also, I don't know if you care about this for your project, but it is not at all responsive
CamperBot
@camperbot
May 02 2016 02:38
geochris35 sends brownie points to @tylergross and @cvdeby and @zerazera :sparkles: :thumbsup: :sparkles:
:star: 395 | @cvdeby | http://www.freecodecamp.com/cvdeby
:star: 413 | @zerazera | http://www.freecodecamp.com/zerazera
:star: 364 | @tylergross | http://www.freecodecamp.com/tylergross
Robert-Jan
@Zorba68
May 02 2016 02:38
@shawnlunny you could probably get more grip on it using console.log() at good places, to see how the number grows and shrinks, etc.
Chris Humphreys
@ChrisCHumphreys
May 02 2016 02:39
@Zerazera yeah, i am going to make it more responsive, once i know it is working
shawnlunny
@shawnlunny
May 02 2016 02:39
@geochris35 in firefox 46.0 i click X and then try for center but nothing happens. then the computer wins since i cant go there
Coryphaeus
@cvdeby
May 02 2016 02:39
@geochris35 The perfect program - it is when a monkey can use it :smile:
Chris Humphreys
@ChrisCHumphreys
May 02 2016 02:40
haha, thanks you guys!
I will be back shortly with this stuff hopefully working.
Samuel Cupidon
@Zerazera
May 02 2016 02:40
@geochris35 In general responsiveness is something you should develop for from the start -- it's difficult to add it in later on.
Chris Humphreys
@ChrisCHumphreys
May 02 2016 02:40
@Zerazera Yeah, that makes sense. I will remember that for my next project.
@shawnlunny thanks man
CamperBot
@camperbot
May 02 2016 02:41
geochris35 sends brownie points to @shawnlunny :sparkles: :thumbsup: :sparkles:
:star: 288 | @shawnlunny | http://www.freecodecamp.com/shawnlunny
vceli
@vceli
May 02 2016 02:41
speak spanish?
eduwin7
@eduwin7
May 02 2016 02:44
Hi all
need help with the stand in line problem
i dont know how to code it
marcsnts
@marcsnts
May 02 2016 02:45
can anyone help with the "Seek and Destroy" challenge
eduwin7
@eduwin7
May 02 2016 02:45
?
marcsnts
@marcsnts
May 02 2016 02:45
@eduwin7 you can help me?
Sekhar Kolli
@SekharKolli
May 02 2016 02:46
@marcsnts , what is troubling you?
shawnlunny
@shawnlunny
May 02 2016 02:46
@eduwin7 @marcsnts What have you tried? Please Paste your code using help format
eduwin7
@eduwin7
May 02 2016 02:46
i havent gotten that far yet @marcsnts
Bobby McDonald
@BobbyMcWho
May 02 2016 02:46
@SekharKolli what project are you on now
eduwin7
@eduwin7
May 02 2016 02:47
return item = [0],1, [2],1 ;
marcsnts
@marcsnts
May 02 2016 02:47
This message was deleted
how do u send the code in that nice editor format
eduwin7
@eduwin7
May 02 2016 02:47

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

return item = [0],1, [2],1 ;

}

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

Sekhar Kolli
@SekharKolli
May 02 2016 02:47
@BobbyMcWho , finished working on my Random quote generator, why?
Robert-Jan
@Zorba68
May 02 2016 02:48
help format
CamperBot
@camperbot
May 02 2016 02:48

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Coryphaeus
@cvdeby
May 02 2016 02:48
@Chrono79 Thanks for Hackerrank :smile:
CamperBot
@camperbot
May 02 2016 02:48
cvdeby sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 587 | @chrono79 | http://www.freecodecamp.com/chrono79
shawnlunny
@shawnlunny
May 02 2016 02:48
help format
CamperBot
@camperbot
May 02 2016 02:48

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Diego Mayer
@Chrono79
May 02 2016 02:48
@cvdeby no problem
Bobby McDonald
@BobbyMcWho
May 02 2016 02:48
@SekharKolli just curious, finally said I'm done with mine after a lot of rewriting
marcsnts
@marcsnts
May 02 2016 02:48
This message was deleted
eduwin7
@eduwin7
May 02 2016 02:48

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

return item = [0],1, 2,1 ;

}

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

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

marcsnts
@marcsnts
May 02 2016 02:49
function destroyer(arr) {
  return arr.filter(function (val) {
    for (var i = 1; i < arguments.length; i++) {
      if (arguments[i] == val) {
        return false;
      }
    }
    return true;
  });
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
is what i have
eduwin7
@eduwin7
May 02 2016 02:49
anyone ?
shawnlunny
@shawnlunny
May 02 2016 02:49
I figured out where my issue is. Now what to do about it lmao. Going into a deep think.
marcsnts
@marcsnts
May 02 2016 02:51
@eduwin7 what do you need help with
eduwin7
@eduwin7
May 02 2016 02:51
i cant get all to return
nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
marcsnts
@marcsnts
May 02 2016 02:51
paste ur code
eduwin7
@eduwin7
May 02 2016 02:52

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

return item = ([0],1), ([2],1) ;

}

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

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

marcsnts
@marcsnts
May 02 2016 02:53
uh
item is a number not an array
eduwin7
@eduwin7
May 02 2016 02:53
can you give me an example please
marcsnts
@marcsnts
May 02 2016 02:56
//function nextInLine which takes in an array (arr) and an integer (item) and adds it to the end of the array, while at the same time removing the first (0th) element of the array. returns the element removed
function nextInLine(arr, item) {
      //put item in the end of arr
      //remove 0th element and remove it
}
@eduwin7
Chris Humphreys
@ChrisCHumphreys
May 02 2016 02:58
ok. Im back. I think I fixed all the issues. as far as responsiveness, it looks bad in the little window, but on my phone in debug mode it looks great. not sure what is going on with the preview window. Anyway if you guys could break it again I would appreciate it. :smile:
marcsnts
@marcsnts
May 02 2016 02:58

@eduwin7 example would be...

given array [1,2,3] and item 1738.
put item at the end of the array -> [1,2,3,1738]
remove 0th element -> [2,3,1738]
return 0th element -> return 1

Sekhar Kolli
@SekharKolli
May 02 2016 02:59
@geochris35 , smoother now. Working well
Chris Humphreys
@ChrisCHumphreys
May 02 2016 03:00
anyone know why it looks so horrible in the preview?
@SekharKolli thanks
CamperBot
@camperbot
May 02 2016 03:00
geochris35 sends brownie points to @sekharkolli :sparkles: :thumbsup: :sparkles:
:star: 303 | @sekharkolli | http://www.freecodecamp.com/sekharkolli
Robert-Jan
@Zorba68
May 02 2016 03:00
@shawnlunny it only seems to work for the first 4 in the number it comes across, it gets that one right, the rest become 9s.
@shawnlunny perhaps a problem with origNum
eduwin7
@eduwin7
May 02 2016 03:04

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

return item [5,6,7,8,9],5;

}

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

still can't get it all
marcsnts
@marcsnts
May 02 2016 03:04
@eduwin7 look at the example i gave u
@eduwin7 with that setup your array should be [2,3,4,5,item] and return 1
Robert-Jan
@Zorba68
May 02 2016 03:07
@shawnlunny I think I got it working
well, not quite, now it gets the 9 wrong
Christina
@cgraham74
May 02 2016 03:10
help sorted union
CamperBot
@camperbot
May 02 2016 03:10

:point_right: algorithm sorted union [wiki]

Problem Explanation:

  • The program has to return a new array of unique values from two original arrays in the order they show up. So there is not sorting required, and no duplicates.
:pencil: read more about algorithm sorted union on the FCC Wiki
eduwin7
@eduwin7
May 02 2016 03:11

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

return item [2,3,4,5,125];

}\

still dont get it
marcsnts
@marcsnts
May 02 2016 03:11
youre not returning an array
you return the value that is being removed from the array
@eduwin7 refer back to the challenge "Manipulate Arrays With shift"
Sekhar Kolli
@SekharKolli
May 02 2016 03:14
@eduwin7 , may i know which challenge are you on please?
eduwin7
@eduwin7
May 02 2016 03:14
Stand in line
Rudolf Carl Pablico
@rudolfpablico
May 02 2016 03:15
hi guys, question on charCodeAt, can i use it on array elements?
zackluckyf
@zackluckyf
May 02 2016 03:15
function addTogether(x, y) {
    if(y !== undefined && typeof x === 'number'){
      return x + y;
    }
    else if(typeof x === 'number'){
      return function(y){    
        if(typeof y === 'number'){
           return x + y;
        }
        else
          return undefined;
      };
    } 
}
for arguments optional my code doesn't work for the 4th test. I'm not sure how y is a number?
Rudolf Carl Pablico
@rudolfpablico
May 02 2016 03:15
array elements are string but returning null
I'm on Caesars Cipher challenge
Sekhar Kolli
@SekharKolli
May 02 2016 03:17
@rudolfpablico, yes you’ll be able to use it on array elements
Rudolf Carl Pablico
@rudolfpablico
May 02 2016 03:18
@SekharKolli can you show me an example code? thanks
CamperBot
@camperbot
May 02 2016 03:18
rudolfpablico sends brownie points to @sekharkolli :sparkles: :thumbsup: :sparkles:
:star: 304 | @sekharkolli | http://www.freecodecamp.com/sekharkolli
Frank XC
@tenkdayz
May 02 2016 03:19
@zackluckyf check for arguments.length
Diego Mayer
@Chrono79
May 02 2016 03:19
@zackluckyf also, y could be a string, that's not undefined and it will enter your first if condition
Sekhar Kolli
@SekharKolli
May 02 2016 03:19
here is some sample code…
function someFunction(str) {
var returnStr = "";  
  for(var i=0; i<str.length; i++) {
    //console.log(str.charCodeAt(i));

  if((str.charCodeAt(i) > 64) && (str.charCodeAt(i) < 78)) {
      returnStr += String.fromCharCode(str.charCodeAt(i) + 13);  
  } 
}
}
Frank XC
@tenkdayz
May 02 2016 03:20
@Chrono79 does the challenge test for strings?
Diego Mayer
@Chrono79
May 02 2016 03:20
@tenkdayz addTogether(2, "3") should return undefined.
cannelflow
@cannelflow
May 02 2016 03:21
@eduwin7 problem solved?
Frank XC
@tenkdayz
May 02 2016 03:21
@Chrono79 I see.
Diego Mayer
@Chrono79
May 02 2016 03:22
@tenkdayz as it is right now it will return "23"
cannelflow
@cannelflow
May 02 2016 03:23
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. 
function nextInLine(arr, item) {
Add the number to the end of the array<====push
 then remove the first element of array.<====shift
then return what was removed
}
@eduwin7
Diego Mayer
@Chrono79
May 02 2016 03:25
@cannelflow @eduwin7 this 2 steps can be made at the same time:
then remove the first element of array.<====shift
then return what was removed
because shift returns the value removed
zackluckyf
@zackluckyf
May 02 2016 03:26
@Chrono79 you're right that was the issue i simply added another if statement to make sure y was number. thank you
Robert Richey
@0x0936
May 02 2016 03:27
@rudolfpablico a very simple example ['a', 'b'][0].charCodeAt(0); // 97 index into the array to get a string, then pass an index to charCodeAt - zero if just a single letter
cannelflow
@cannelflow
May 02 2016 03:27
@Chrono79 thats what i also said
jsut tried to explain it to noob
Diego Mayer
@Chrono79
May 02 2016 03:28
@cannelflow no problem, just then then sounded to me like 2 steps
Sekhar Kolli
@SekharKolli
May 02 2016 03:30
@rudolfpablico , not sure if the other example made sense… here is a different example
console.log("charCodeFor A: " + "A".charCodeAt(0)); // will print 65. The code for ‘A'
console.log("charCodeFor B: " + "AB".charCodeAt(1)); // will print 66. The code for ‘B'
console.log("charCodeFor C: " + "ABC".charCodeAt(2)); // will print 67. The code for ‘C'
cannelflow
@cannelflow
May 02 2016 03:30
@Chrono79 :smile:
wintersunI
@wintersunI
May 02 2016 03:44
@eduwin7 are you still trying to do nextInLine(arr,item)?
Jevaughn Vance
@jvans7
May 02 2016 03:53
hi there. would like some help in the Nesting For Loop Lesson please.
hope someone has completed that lesson
Sekhar Kolli
@SekharKolli
May 02 2016 03:54
sure @jvans7 , what is your question?
Jevaughn Vance
@jvans7
May 02 2016 03:54

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++) {
}

// Only change code above this line
return product;
}
}
// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

i'm sort of stuck
@SekharKolli I think the next line has to product = something?
be*
Sekhar Kolli
@SekharKolli
May 02 2016 03:56
that is correct. @jvans7. Could you give me the name of the challenge that you are on please?
Jevaughn Vance
@jvans7
May 02 2016 03:57
Nesting for Loops
@SekharKolli
Sekhar Kolli
@SekharKolli
May 02 2016 03:57
@jvans7 lovely. Give me a moment please
Coy Sanders
@coymeetsworld
May 02 2016 03:57
@jvans7 you want to modify the product variable within your 2nd for loop
dont want to return it till you exit both for loops
Sekhar Kolli
@SekharKolli
May 02 2016 03:59
@jvans7 , here is the line that you want in the loops…
  for(var i=0;i<arr.length;i++){
    for(var j=0;j<arr[i].length;j++){
      product *= arr[i][j];  // This will give you the product
    }
  }
Coy Sanders
@coymeetsworld
May 02 2016 03:59
@SekharKolli you shouldn't be giving the code out...
that doesn't help anyone from learning what they need to
Sekhar Kolli
@SekharKolli
May 02 2016 04:02
Thought so… @coymeetsworld
Since @jvans7 is stuck… it will get him him started.
@jvans7 , does the line make sense? The best way to visualize the code is to throw in as many console.log(); lines to output values
Coy Sanders
@coymeetsworld
May 02 2016 04:02
get him started? thats the entire code lol
Jevaughn Vance
@jvans7
May 02 2016 04:02
i just needed one line @coymeetsworld see above
Coy Sanders
@coymeetsworld
May 02 2016 04:03
i understand, but when you just get the answers hard for you to learn
Jevaughn Vance
@jvans7
May 02 2016 04:05
for sure @coymeetsworld . It would be great if you explain it tho. would really appreciate that
Coy Sanders
@coymeetsworld
May 02 2016 04:05
so you're given a 2 dimensional array, and you need to access each variable inside that 2-d array and compute the product (i.e. multiply all the numbers together)
so you have this array called arr which is [[1,2],[3,4],[5,6,7]]
if you checked what arr[0] is it would give you another array, [1,2]
arr1 gives you [3,4] and arr[2] give you [5,6,7]
Sekhar Kolli
@SekharKolli
May 02 2016 04:07
@jvans7 , open Browser’s console window… and paste the following code in…
  for(var i=0;i<arr.length;i++){
    console.log(“Array : ”+arr[i]);
    for(var j=0;j<arr[i].length;j++){
    console.log(“Product : “+ product);
      product *= arr[i][j];  // This will give you the product
    }
  }
Coy Sanders
@coymeetsworld
May 02 2016 04:07
you want to get to those values so you need another for loop to iterate through each of those sub arrays
so arr[0][0] would be 1, arr[0][1] would be 2
theres nothing left in that first array so you go to the next, arr[1][0] would be 3, arr[1][1] would be 4
does that make sense?
Jevaughn Vance
@jvans7
May 02 2016 04:09
yes @coymeetsworld
continue
@SekharKolli thank you
CamperBot
@camperbot
May 02 2016 04:09
jvans7 sends brownie points to @sekharkolli :sparkles: :thumbsup: :sparkles:
:star: 305 | @sekharkolli | http://www.freecodecamp.com/sekharkolli
Coy Sanders
@coymeetsworld
May 02 2016 04:09
thats pretty much it, now that you know how to access those variables you multiply them all together to get the product
which is where the *= comes into play
so shorthand what you're doing is making product = 1*1*2*3*4*5*6*7
Helen Jessica
@near93
May 02 2016 04:11
Hi all, I just stored a 2 dimensional array account number and initial balance user input. accList = [accNum, initialBal]. is it possible to call the values again individually? e.g., list it as a table like -> account number: accNum, initial balance: initialBal. I don't know where to go from there, here is my code: http://codepen.io/near93/pen/qZQrvy
Coy Sanders
@coymeetsworld
May 02 2016 04:12
yes @near93, kind of similar to what we were talking about above, you have a 2-d array
and looks like account number is always at index 0 and balance at 1
Jevaughn Vance
@jvans7
May 02 2016 04:12
@coymeetsworld thank you
CamperBot
@camperbot
May 02 2016 04:12
jvans7 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 684 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Helen Jessica
@near93
May 02 2016 04:13
Yes. I'm kinda confused if I did it right @coymeetsworld
Coy Sanders
@coymeetsworld
May 02 2016 04:13
i think it looks fine
Helen Jessica
@near93
May 02 2016 04:13
I want to display it as a list once the user has added its account. @coymeetsworld
sort of a table of account numbers with its corresponding balance
Coy Sanders
@coymeetsworld
May 02 2016 04:14
best to use some sort of loop like a for loop
Helen Jessica
@near93
May 02 2016 04:14
thanks @coymeetsworld
CamperBot
@camperbot
May 02 2016 04:14
near93 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 685 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 02 2016 04:15
np
also you may want to look into using jQuery's .html() or .append() functions
.innerHTML may not work on all browsers
acgillette
@acgillette
May 02 2016 04:21
I'm working on the chunky monkey algorithm. Something in my code isn't working but I'm not sure what. Anyone willing to take a look?
function chunkArrayInGroups(arr, size) {
  var chunkyMonkey = [];
  for (var i = 0; i < arr.length; i += size) {
    chunkyMonkey.push(arr.slice(i, size));
  }
  return chunkyMonkey;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
GitResumeCoding
@GitResumeCoding
May 02 2016 04:22
Looking for some help on the Stand in Line challenge
This is what I have, it only gets the first two tests right.
function nextInLine(arr, item) {
  // Your code here
  var addToArray = arr.push(item);
  var removedFromArray = arr.unshift(); 

  return removedFromArray;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Coy Sanders
@coymeetsworld
May 02 2016 04:24
think you're slicing too early @acgillette
Hector Garcia
@augmt
May 02 2016 04:24
@acgillette you want to make sure to adjust where you end your slice for each iteration of the for loop
acgillette
@acgillette
May 02 2016 04:26
oh duh. Didn't see the flaw in using size for the end of slice. Got the code to work and passed haha
thx @augmt and @coymeetsworld
CamperBot
@camperbot
May 02 2016 04:27
acgillette sends brownie points to @augmt and @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 398 | @augmt | http://www.freecodecamp.com/augmt
:star: 686 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 02 2016 04:27
np @acgillette
@GitResumeCoding look at what unshift does
unshift adds an item to the beginning of the list
and returns the length of the array after insert.
GitResumeCoding
@GitResumeCoding
May 02 2016 04:31
@coymeetsworld haha, had it mixed up. I guess I need to make a happy UN-birthday into just a birthday
Coy Sanders
@coymeetsworld
May 02 2016 04:31
:thumbsup: yes
also you don't need a variable to store the "birthday" value in
just do return arr.birthday(); :)
GitResumeCoding
@GitResumeCoding
May 02 2016 04:41
:)
Jevaughn Vance
@jvans7
May 02 2016 04:41
@coymeetsworld hey I would like to ask if you can explain the Profile Lookup Lesson. please
Coy Sanders
@coymeetsworld
May 02 2016 04:41
sure which part?
Martialis39
@Martialis39
May 02 2016 04:42
Hey all
Can anyone give me some non-spoilery tips on Roman Numerals?
or intermediate algos in general?
Jevaughn Vance
@jvans7
May 02 2016 04:43
@coymeetsworld you can go from the start
Coy Sanders
@coymeetsworld
May 02 2016 04:44
you're given an array of objects you need to go through and find information
Thomas G.
@CaptainMurphey
May 02 2016 04:44
hey guys im working thru the javascript tuts and im on Instructions
Change the code to use the ++ operator on myVar.

var myVar = 87;

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

Coy Sanders
@coymeetsworld
May 02 2016 04:45
@CaptainMurphey its just myVar++
Thomas G.
@CaptainMurphey
May 02 2016 04:45
and its not working
Coy Sanders
@coymeetsworld
May 02 2016 04:45
myVar++ is really myVar += 1
Thomas G.
@CaptainMurphey
May 02 2016 04:45
no semicolon?
Coy Sanders
@coymeetsworld
May 02 2016 04:45
yes semicolon
@jvans7 so you need to first check if the firstname property of the object is equal to the firstName you're looking for
if it is, see if that object has the property prop (look up the hasOwnProperty function). If it has the property return it, if not return "No such property"
if you go through the entire list of contacts and can't find an object with the firstname you're looking for, you return "No such contact"
going offline in a min, getting late showing of GoT but hope that helps
Jevaughn Vance
@jvans7
May 02 2016 04:48
@coymeetsworld thank you
CamperBot
@camperbot
May 02 2016 04:48
jvans7 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: jvans7 already gave coymeetsworld points
Coy Sanders
@coymeetsworld
May 02 2016 04:48
no problem
Thomas G.
@CaptainMurphey
May 02 2016 04:49
@coymeetsworld ahh so i see the point is not to assign it to myVar, is that correct coding practice, I mean every time i have used a ++ operator it was part of a function or in a for loop...does this automatically set myVar equal to the new value or is it just kind of a counter
Chris Cullen
@123xylem
May 02 2016 04:49
Why is this saying arr is not defined?
function bouncer(arr) {

  function dontHave(value) {

    for(i=0;i<arr.length;i++)
  if (arr[i] !== false || null && 0 && "" && undefined && NaN);

  }
  return arr;
}

bouncer([7, "ate", "", false, 9]).filter(dontHave);
shawnlunny
@shawnlunny
May 02 2016 04:50
@Zorba68 yes its a logic issue with that if statement. i have to handle num differently in the upper else; or reduce origNum accordingly so the logic works correctly after we have already decided the numerals.
I think I have an idea of how to get it to work. working on it now.
@Zorba68 Specifically the first iteration for 44 in that inner if gets // 45 <= 60
and on the second it would be // 45 <= 6 thus instead of IV it gets IX and thats the issue. so i need to update origNum
Chris Cullen
@123xylem
May 02 2016 04:56
help falsy bouncer
CamperBot
@camperbot
May 02 2016 04:56

:point_right: algorithm falsy bouncer [wiki]

Problem Explanation:

Remove all falsy values from an array.

:pencil: read more about algorithm falsy bouncer on the FCC Wiki

buiphuking
@buiphuking
May 02 2016 05:24
is anybody found formula for Map the Debris ?
Chris Buchert
@cbuchert
May 02 2016 05:24
Hey, folks. I'm working on the last algo challenge on front end intermediate algorithm scripting (arguments optional) and am hitting a technical hurtle I can't seem to figure out. How do you pass arguments to a function that is the return value of another function (eg addTogether(2)(3))? You can see my current spaghetti code here: http://bit.ly/1NNNZtn
Thomas G.
@CaptainMurphey
May 02 2016 05:28
anyone else having problems getting the challenges to load..or is it just my crappy internet?
Chris Buchert
@cbuchert
May 02 2016 05:29
I'm not having any issues. Have you tried different browsers or an incognito window?
Or clearing your browser cache and then reloading?
Thomas G.
@CaptainMurphey
May 02 2016 05:29
no ill try that meow
Chris Buchert
@cbuchert
May 02 2016 05:30
(usually ctrl + shift + r will do a forced reload without cache)
or cmd + shift + r if you're on an mac.
Thomas G.
@CaptainMurphey
May 02 2016 05:30
hah mac, hah oh your a silly goose!
Chris Buchert
@cbuchert
May 02 2016 05:33
Gotta cover those bases. :)
Thomas G.
@CaptainMurphey
May 02 2016 05:34
but you left out linux!
not that i use that either
Chris Buchert
@cbuchert
May 02 2016 05:34
Linux doesn't have jacked up keyboards.
By default.
Thomas G.
@CaptainMurphey
May 02 2016 05:35
linux is pretty cool, reminds me of the old days using win 95 where getting anything to work required a tutorial or a VM
Chris Buchert
@cbuchert
May 02 2016 05:35
Sounds like you haven't used Linux in a while. :)
Thomas G.
@CaptainMurphey
May 02 2016 05:35
only alot shinier
its been about 3 years
why is it better now?
Chris Buchert
@cbuchert
May 02 2016 05:36
Well, you definitely don't have to recompile the kernel every time you install now.
That's a really nice feature.
Thomas G.
@CaptainMurphey
May 02 2016 05:37
thats good at least.. I just remember trying to get games running and getting very frustrated
Chris Buchert
@cbuchert
May 02 2016 05:37
Yeah, it's not what most games are built for.
I still keep a Windows partition for Steam and CAD. Apart from that, I've been using Ubuntu exclusively for a few years now.
The learning curve hurts pretty bad, but once you know where to find things and how to restart things it eases up.
Thomas G.
@CaptainMurphey
May 02 2016 05:39
yeah dude its kind of a bummer that its not more popular.. i mean look at google's stuff, its open source more or less and with alot of support it become the bees knees, the hornets nipples and all other assorted bug's genetalia!
Chris Buchert
@cbuchert
May 02 2016 05:39
As long as you're not trying to play games or use Autodesk or Adobe products.
Thomas G.
@CaptainMurphey
May 02 2016 05:40
still better than mac OS, where a calculator app is a $10/month subscription
Chris Buchert
@cbuchert
May 02 2016 05:40
Dude, not to pick fights or anything, but Linux is wildly popular. You use it all the time and probably don't know it.
The vast majority of the internet is hosted on linux machines, not to mention embedded systems (think your microwave, your fridge, parts of your car), etc.
Thomas G.
@CaptainMurphey
May 02 2016 05:41
oh yeah i know,, but its not really mainstream you know
like for regular jackoffs
Chris Buchert
@cbuchert
May 02 2016 05:41
How about your phone?
Android is built on Linux.
Ish.
Kind of.
Thomas G.
@CaptainMurphey
May 02 2016 05:42
is it?
Chris Buchert
@cbuchert
May 02 2016 05:42
Mostly.
yeah.
kirbyedy
@kirbyedy
May 02 2016 05:42
@CaptainMurphey really ?! which one?
Thomas G.
@CaptainMurphey
May 02 2016 05:42
i though it was all developed with Java
Chris Buchert
@cbuchert
May 02 2016 05:43
That's what the apps are written in, but using Java was just a design choice by the original Android team before it was acquired by Google.
Thomas G.
@CaptainMurphey
May 02 2016 05:43
although when i was using umbuntu It did seem alot like a android phone
isint linux based off of the old UNIX? or is that something different
Chris Buchert
@cbuchert
May 02 2016 05:45
Yeah. Check out the Wikipedia page on Android. Just search for 'Linux' on the page and you'll find the references.
Thomas G.
@CaptainMurphey
May 02 2016 05:47
holy crap the first android system was 2008, i could have swore I had a smart phone in high school and that ended 05
what was your guys first smart phone model?
Chris Buchert
@cbuchert
May 02 2016 05:48
I was an early adopter. I had a G1.
Thomas G.
@CaptainMurphey
May 02 2016 05:49
ahh my roomate in college had one of those, he was all proud of it, im guessing he probably tried to make sexy times with it
can you guys play a lil bit with both X and O and report any bugs
Chris Buchert
@cbuchert
May 02 2016 05:50
Sure thing, Eldar.
Eldar Tinjić
@EldarT90
May 02 2016 05:50
also if some1 of you know how to solve 1 bug i noticed, i would be delighted - if you play with O and computer with X, sometimes computer wont play X at all
which is strange
Thomas G.
@CaptainMurphey
May 02 2016 05:50
my first one was a Huawai acend I think, total POS and it still cost an arm and a leg
@EldarT90 well heres what ive seen so far...first it seems computer is super east to beat. its not blocking obvious sets of 3.. also when I choose O to play it resets and asks me to pic x or 0 again then press play this last game also ended x0x x00 0xx left to right top to bottom, and it hasnt ended in a draw or at all, just sitting there with a full board
Chris Buchert
@cbuchert
May 02 2016 05:55
@EldarT90, I think I just ran into your bug (the one where X doesn't play). I was a fair number of moves into the game and X just didn't take a turn. Is that what you're talking about?
Thomas G.
@CaptainMurphey
May 02 2016 05:56
ohh i just hit it too.. it lets you drop another 0 and just says no games won
and if you win while playing 0 it says 0 wins
Eldar Tinjić
@EldarT90
May 02 2016 05:57
@cbuchert yes
Thomas G.
@CaptainMurphey
May 02 2016 05:58
i dont know JS well enough to help you fix dem bugs though...I should get back to work
Eldar Tinjić
@EldarT90
May 02 2016 05:58
@CaptainMurphey well i didnt input any logic in AI yet so thats reasonable; bug wiht picking O - im not sure since im not getting it - but yeah tnx i ll have to look into that
CamperBot
@camperbot
May 02 2016 05:58
eldart90 sends brownie points to @captainmurphey :sparkles: :thumbsup: :sparkles:
:star: 159 | @captainmurphey | http://www.freecodecamp.com/captainmurphey
Thomas G.
@CaptainMurphey
May 02 2016 05:59
@EldarT90 is it just picking its spot at random?
Eldar Tinjić
@EldarT90
May 02 2016 05:59
@CaptainMurphey yes, atm
Thomas G.
@CaptainMurphey
May 02 2016 06:01
ok that makes more sense.. dude that might be part of the problem ive only worked with it when making word games, but the math.random can do some pretty weird ass things and i dont know why
Josue Godoy Lechuga
@josue1080
May 02 2016 06:01
Help Check for Palindromes
CamperBot
@camperbot
May 02 2016 06:01

:point_right: algorithm check for palindromes [wiki]

Explanation:

Our goal for solving this problem is tidying up the string passed in, and checking whether it is in fact a palindrome.

  • If you are unsure of what a palindrome is, it is a word or phrase that when reversed spells the same thing forwards or backwards. A simple example is mom, when you reverse the letters, it spells the same thing! Another example of a palindrome is race car. When we take out anything that is not a character it becomes racecar which is the same spelled forwards or backwards!

Once we have determined whether it is a palindrome or not we want to return either true or false based on our findings.

:pencil: read more about algorithm check for palindromes on the FCC Wiki

Josue Godoy Lechuga
@josue1080
May 02 2016 06:05
Help Find the Longest Word in a String
CamperBot
@camperbot
May 02 2016 06:05

:point_right: algorithm find the longest word in a string [wiki]

Explanation:

You have to go through each word and figure out which one is the longest and return not the word, but how many characters it has.

:pencil: read more about algorithm find the longest word in a string on the FCC Wiki

Josue Godoy Lechuga
@josue1080
May 02 2016 06:07
Help Title Case a Sentence
CamperBot
@camperbot
May 02 2016 06:07

:point_right: algorithm title case a sentence [wiki]

Explanation:

We have to return a sentence with camel case. This means that the first letter will always be in uppercase and the rest lowercase.

:pencil: read more about algorithm title case a sentence on the FCC Wiki

Chris Cullen
@123xylem
May 02 2016 06:08
Can someone tell me how to make this iterate over the whole arr without returning too quickly? I already have a different solution but want to make this one work
function bouncer(arr) {
for(i=0;i<arr.length;i++){
 while (arr[i] != Boolean)

  return arr[i];
}
}

bouncer([7, "ate", "", false, 9]);
Thomas G.
@CaptainMurphey
May 02 2016 06:08
@123xylem is it returning after 3?
Chris Cullen
@123xylem
May 02 2016 06:09
it returns just 7
as it sees a non boolean and returns
I think
Thomas G.
@CaptainMurphey
May 02 2016 06:10
@123xylem i know an empty string like "" will result in false which is boolean
Chris Cullen
@123xylem
May 02 2016 06:11
yea
Scott Gibson
@sc00gle
May 02 2016 06:11
help $switch
CamperBot
@camperbot
May 02 2016 06:11

:point_right: challenge adding a default option in switch statements [wiki]

Challenge: Adding a default option in Switch statements

In a switch statement you may not be able to specify all possible values as case statements. Instead, you can add the default statement which will be executed if no matching case statements are found. Think of it like the final else statement in an if/else chain.

A default statement should be the last case.

switch (num) {
  case value1:
    statement1
    break;
  case value2:
    statement2;
    break;
...
  default:
    defaultStatement;
}

:pencil: read more about challenge adding a default option in switch statements on the FCC Wiki

Thomas G.
@CaptainMurphey
May 02 2016 06:12
@123xylem thats weird it should do at least up to "ate" I think ive seen something like this...something about needing to add an || operator, gimme a bit ill look
@123xylem you are missing a { after your while statement check and see if that fixes it
Jorge
@liberaltech
May 02 2016 06:13
https://codepen.io/liberaltech/pen/QNZeKw
is there a reason why my collapse is lagging?
Chris Cullen
@123xylem
May 02 2016 06:14
f
@CaptainMurphey nope sometimes {} dont seem to be neccesary.. ive been wondering about that mysel
Thomas G.
@CaptainMurphey
May 02 2016 06:16
@123xylem i believe thats javascript's thingy where it trys to fill in missing syntax..and of course screws it up. lemme play with it a bit
Maximilian
@MLK97
May 02 2016 06:16
@liberaltech Have you tried to use $('class').on('click', function(){}) instead of the .click command?
Jorge
@liberaltech
May 02 2016 06:17
@MLK97 nope, ill try it now
Maximilian
@MLK97
May 02 2016 06:17
@liberaltech I hope it helps :)
Scott Gibson
@sc00gle
May 02 2016 06:19
Hi guys, I'm having problems with "Selecting from many options with Switch Statements". Is someone able to check out https://gist.github.com/sc00gle/787ece39de9a6e2a0ef73e939c9fa6af and explain why it wont execute?
Thomas G.
@CaptainMurphey
May 02 2016 06:20
@123xylem hey are you working on codepen
kirbyedy
@kirbyedy
May 02 2016 06:20
@sc00gle missing break after case 4 maybe ?
Maximilian
@MLK97
May 02 2016 06:21
@sc00gle you haven't defined a break after case 4. so javascript just returns answer if case 4 is achieved
Coy Sanders
@coymeetsworld
May 02 2016 06:21
you dont need a break after case 4
problem is return statement is inside switch statement, needs to be outside of it
Scott Gibson
@sc00gle
May 02 2016 06:22
Hi @kirbyedy @MLK97 I've tried with break' after case 4 but no good.
Coy Sanders
@coymeetsworld
May 02 2016 06:22
only case 4 will return
kirbyedy
@kirbyedy
May 02 2016 06:23
@sc00gle oh, also missing a closing bracket after case 4
Scott Gibson
@sc00gle
May 02 2016 06:23
Spot on @coymeetsworld - only case 4 was returning. Moved } and now working. Thank you @coymeetsworld
CamperBot
@camperbot
May 02 2016 06:23
sc00gle sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 687 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 02 2016 06:23
yw @sc00gle
Eldar Tinjić
@EldarT90
May 02 2016 06:26
https://codepen.io/EldarT/full/aNQdJy/ - can some1 help me figure out the bug that is popping out when you are playing O
after 2 or 3 moves you will see how computer wont put X in its turn
but would rather let you put O two times in a row
this problem wont happen when you are playing with X , but only with O
Chris Cullen
@123xylem
May 02 2016 06:28
@CaptainMurphey na just github
@CaptainMurphey how come?
Thomas G.
@CaptainMurphey
May 02 2016 06:28
@123xylem dude i just don't know, i feel like it something to do with .length being used on an array
Chris Cullen
@123xylem
May 02 2016 06:29
@CaptainMurphey :)
no worries
the realcode is so much easier

``` function bouncer(arr) {

return arr.filter(Boolean);
} ```

Thomas G.
@CaptainMurphey
May 02 2016 06:30
@123xylem like i think .length only looks at strings right? and there is a different keyword for checking the different part of an array
Chris Cullen
@123xylem
May 02 2016 06:30
But I was trying to do it without knowing I could use a Boolean value like that
@CaptainMurphey .length works on arrays aswell afaik
toseefahmed
@toseefahmed
May 02 2016 06:30
I need help me in whereAreYou bonefire
unable to satisfy last 2 cond.
Chris Cullen
@123xylem
May 02 2016 06:31
But i think the problem is its returning after the first statement is completed and its not bothering to go through the whole array
toseefahmed
@toseefahmed
May 02 2016 06:31

function whereAreYou(collection, source) {
var arr = [];
var key = Object.keys(source);

for(var name in collection){
if(collection[name][key] === source[key]){
arr.push(collection[name]);
}
}
return arr;
}

whereAreYou([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' }, { last: 'Montague' });

this is my code
Thomas G.
@CaptainMurphey
May 02 2016 06:31
@123xylem yeah that is quite a bit easier... wouldnt .length be looking at the length of the data inside the array and not the array iteself?
Chris Cullen
@123xylem
May 02 2016 06:31
Maybe I could shift the results into new arrray and return that at the end
Jorge
@liberaltech
May 02 2016 06:31
@MLK97 i tried it but it didnt see to help
zhangolve
@zhangolve
May 02 2016 06:32
Hello everyone,I am doing "Introducing JavaScript Object Notation JSON" https://www.freecodecamp.com/challenges/introducing-javascript-object-notation-json
my code is
Thomas G.
@CaptainMurphey
May 02 2016 06:32
@123xylem yeah that would work
zhangolve
@zhangolve
May 02 2016 06:32

var myMusic = [
{
"firstalbum":[{ "artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}],
// Add record here
"secoundalbum":[{ "artist": "Meacial Jackson",
"title": "chain",
"release_year": 1983,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}]

}];

Chris Cullen
@123xylem
May 02 2016 06:32

well now its an infinite loop...```js
function bouncer(arr) {
var newarray=[];
for(i=0;i<arr.length;i++){
while (arr[i] != Boolean){
newarray.shift(arr);}

return newarray;
}
}

bouncer([7, "ate", "", false, 9]);

```

zhangolve
@zhangolve
May 02 2016 06:33
but it never succeed ,can anybody help me ?
Chris Cullen
@123xylem
May 02 2016 06:33
function bouncer(arr) {
var newarray=[];
for(i=0;i<arr.length;i++){
while (arr[i] != Boolean){
newarray.shift(arr);}
return newarray;
}
}
bouncer([7, "ate", "", false, 9]);
Maximilian
@MLK97
May 02 2016 06:33
@liberaltech yea u followed. It may also be that codepen doesn't provide casual users a good networking speed, so i think the problem is not on your site but rather on codepen's site :)
Chris Cullen
@123xylem
May 02 2016 06:33
ANy1 know why above code makes infinite loop?
Jorge
@liberaltech
May 02 2016 06:34
@MLK97 oooooh! i forgot about that lol
Maximilian
@MLK97
May 02 2016 06:34
@liberaltech you could ask some professionals in here but that's my idea
Jorge
@liberaltech
May 02 2016 06:36
@MLK97 thanks
CamperBot
@camperbot
May 02 2016 06:36
liberaltech sends brownie points to @mlk97 :sparkles: :thumbsup: :sparkles:
:star: 292 | @mlk97 | http://www.freecodecamp.com/mlk97
Maximilian
@MLK97
May 02 2016 06:37
@liberaltech your welcome :)
Eldar Tinjić
@EldarT90
May 02 2016 06:46
https://codepen.io/EldarT/pen/aNQdJy - can some1 tell me why there is bug with 2 consecutive O when player picks O
at 2nd or 3rd move usually
it never happens with X
Michael Vu
@iammvu
May 02 2016 06:49

Hi, can someone help me write a 'celsius to farenheit' javascript function? This is what I have but its not right:
function convertToF(celsius) {
// Only change code below this line
var Farenheit;
Farenheit = (celsius *= 9/5) += 32;

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

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

Zach
@Moose1551
May 02 2016 06:51
of course I know this is totally wrong, but in looking at the "helpful" links in the bonfire challenge "Seek and Destroy", how should I use arguments?
return arr.filter(arguments);
CamperBot
@camperbot
May 02 2016 06:51
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Luis Gaytan
@techiedodo
May 02 2016 06:52
@iammvu have you tried just using and not = and + and not +=?
Michael Vu
@iammvu
May 02 2016 06:56
@techiedodo thanks but I think it wants me to use these augmented +=, *=, /=... operations for this excercise
CamperBot
@camperbot
May 02 2016 06:57
iammvu sends brownie points to @techiedodo :sparkles: :thumbsup: :sparkles:
:star: 197 | @techiedodo | http://www.freecodecamp.com/techiedodo
TanYiXun
@TanYiXun
May 02 2016 07:02
Bonfire seek and destroy
CamperBot
@camperbot
May 02 2016 07:02

:fire:Bonfire: Seek and Destroy :link:

function destroyer(arr) {
  // Remove all the values
  return arr;
}

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

You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.

more info:  bf details | bf links | hint

Mariya
@mariyadiminsky
May 02 2016 07:03
Anyone looking to learn JavaScript ES6 consider following this series: https://medium.com/@__Masha__/learn-es6-the-dope-way-i-const-let-var-ae828580472b#.pfurdplqu
TanYiXun
@TanYiXun
May 02 2016 07:06
Guys which is the best websites to learn Java?
Michael Karpinski
@karpimpski
May 02 2016 07:07
@TanYiXun depending on your expertise, Codecademy is a good place to get the basics
for practice, go to Codewars. learn from a site like Codecademy
TanYiXun
@TanYiXun
May 02 2016 07:08
@michael alright thanks :)
Jevaughn Vance
@jvans7
May 02 2016 07:11
wowww just finished basic javaScript but still a bit shaky lol anyone has any reliable youtube channel or links where i can maybe watch n review? thanks
Frank XC
@tenkdayz
May 02 2016 07:12
@jvans7 adam khoury in youtube... he's the man
Michael Karpinski
@karpimpski
May 02 2016 07:12
@jvans7 I like thenewboston
Jevaughn Vance
@jvans7
May 02 2016 07:14
thanks guy
Michael Vu
@iammvu
May 02 2016 07:14
nvm I got it. They just wanted:
var fahrenheit = (celsius * (9/5)) + 32;
Eldar Tinjić
@EldarT90
May 02 2016 07:14
:point_up: May 2, 2016 8:46 AM
Michael Vu
@iammvu
May 02 2016 07:15
Sorry if that is what you meant @techiedodo . Thanks
CamperBot
@camperbot
May 02 2016 07:15
iammvu sends brownie points to @techiedodo :sparkles: :thumbsup: :sparkles:
:warning: iammvu already gave techiedodo points
Luis Gaytan
@techiedodo
May 02 2016 07:15
@iammvu no worries, sometimes there are different ways to do the same thing.
Jorge
@liberaltech
May 02 2016 07:17
is there a way to find and add users using twitch api
Elodie
@Elodie950
May 02 2016 07:20
Hi! I'm new on free code camp! I do the exercice "Comparison with the Inequality Operator" and I'm blocked! All the instructions are good but not the last : "You should use the != operator"
But in my code I have used the != operator
Vivek
@vivek28111992
May 02 2016 07:22
@Mashadim is there any another part for es6?
Elodie
@Elodie950
May 02 2016 07:22
I don't know how put my code on the chat

function testNotEqual(val) {
if( val != "99"){
return "Not Equal";
}
return "Equal";
}

// Change this value to test
testNotEqual(12);

Michael Karpinski
@karpimpski
May 02 2016 07:23
@Elodie950
help format
CamperBot
@camperbot
May 02 2016 07:23

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Hamed Nourhani
@hamednourhani
May 02 2016 07:23
hi how can i change autoplay option for this plugin on the fly :smile:

/**

  • jquery.gallery.js
  • http://www.codrops.com
    *
  • Copyright 2011, Pedro Botelho / Codrops
  • Free to use under the MIT license.
    *
  • Date: Mon Jan 30 2012
    */

(function( $, undefined ) {

/*
 * Gallery object.
 */
$.Gallery                 = function( options, element ) {

    this.$el    = $( element );
    this._init( options );

};

$.Gallery.defaults         = {
    current        : 0,    // index of current item
    autoplay    : false,// slideshow on / off
    interval    : 2000  // time between transitions
};

$.Gallery.prototype     = {
    _init                 : function( options ) {

        this.options         = $.extend( true, {}, $.Gallery.defaults, options );

        // support for 3d / 2d transforms and transitions
        this.support3d        = Modernizr.csstransforms3d;
        this.support2d        = Modernizr.csstransforms;
        this.supportTrans    = Modernizr.csstransitions;

        this.$wrapper        = this.$el.find('.dg-wrapper');

        this.$items            = this.$wrapper.children();
        this.itemsCount        = this.$items.length;

        this.$nav            = this.$el.find('nav');
        this.$navPrev        = this.$nav.find('.dg-prev');
        this.$navNext        = this.$nav.find('.dg-next');

        // minimum of 3 items
        if( this.itemsCount < 3 ) {

            this.$nav.remove();
            return false;

        }    

        this.current        = this.options.current;

        this.isAnim            = false;

        this.$items.css({
            'opacity'    : 0,
            'visibility': 'hidden'
        });

        this._validate();

        this._layout();

        // load the events
        this._loadEvents();

        // slideshow
        if( this.options.autoplay ) {

            this._startSlideshow();

        }

    },
    _validate            : function() {

        if( this.options.current < 0 || this.options.current > this.itemsCount - 1 ) {

            this.current = 0;

        }    

    },
    _layout                : function() {

        // current, left and right items
        this._setItems();

        // current item is not changed
        // left and right one are rotated and translated
        var leftCSS, rightCSS, currentCSS;

        if( this.support3d && this.supportTrans ) {

            leftCSS     = {
                '-webkit-transform'    : 'translateX(-350px) translateZ(-200px) rotateY(45deg)',
                '-moz-transform'    : 'translateX(-350px) translateZ(-200px) rotateY(45deg)',
                '-o-transform'        : 'translateX(-350px) translateZ(-200px) rotateY(45deg)',
                '-ms-transform'        : 'translateX(-350px) translateZ(-200px) rotateY(45deg)',
                'transform'            : 'translateX(-350px) translateZ(-200px) rotateY(45deg)'
            };

            rightCSS    = {
                '-webkit-transform'    : 'translateX(350px) translateZ(-200px) rotateY(-45deg)',
                '-moz-transform'    : 'translateX(350px) translateZ(-200px) rotateY(-45deg)',
                '-o-transform'        : 'translateX(350px) translateZ(-200px) rotateY(-45deg)',
                '-ms-transform'        : 'translateX(350px) translateZ(-200px) rotateY(-45deg)',
                'transform'            : 'translateX(350px) translateZ(-200px) rotateY(-45deg)'
            };

            leftCSS.opacity        = 1;
            leftCSS.visibility    = 'visible';
            rightCSS.opacity    = 1;
            rightCSS.visibility    = 'visible';

        }
        else if( this.support2d && this.supportTrans ) {

            leftCSS     = {
                '-webkit-transform'    : 'translate(-350px) scale(0.8)',
                '-moz-transform'    : 'translate(-350px) scale(0.8)',
                '-o-transform'        : 'translate(-350px) scale(0.8)',
                '-ms-transform'        : 'translate(-350px) scale(0.8)',
                'transform'            : 'translate(-350px) scale(0.8)'
            };

            rightCSS    = {
                '-webkit-transform'    : 'translate(350px) scale(0.8)',
                '-moz-transform'    : 'translate(350px) scale(0.8)',
                '-o-transform'        : 'translate(350px) scale(0.8)',
                '-ms-transform'        : 'translate(350px) scale(0.8)',
                'transform'            : 'translate(350px) scale(0.8)'
            };

            currentCSS    = {
                'z-index'            : 999
            };

            leftCSS.opacity        = 1;
            leftCSS.visibility    = 'visible';
            rightCSS.opacity    = 1;
            rightCSS.visibility    = 'visible';

        }

        this.$leftItm.css( leftCSS || {} );
        this.$rightItm.css( rightCSS || {} );

        this.$currentItm.css( currentCSS || {} ).css({
            'opacity'    : 1,
            'visibility': 'visible'
        }).addClass('dg-center');

    },
    _set
Luis Gaytan
@techiedodo
May 02 2016 07:32
@Elodie950 the code is looking at 99 as an integer and not a string. By putting the "" you turned the integer into a string. Try using the same code without the ""
thomas-duval
@thomas-duval
May 02 2016 08:00

Hey guys,
Can someone explain me this line :

int % 2 ? 0 : i

Int being a number, how can a remainder result be Boolean ?
Thanks

Vivek
@vivek28111992
May 02 2016 08:01
@thomas-duval % gives the remainder
Coy Sanders
@coymeetsworld
May 02 2016 08:01
doesn't have to be boolean, if its 0 its false, if its non-zero its true
need help with game when player is O
just play 1 round and you will see bug when computer lets you input 2xO in a row
which never happens with x
if some1 with deeper understanding of JS could look into this , id be grateful tnx
thomas-duval
@thomas-duval
May 02 2016 08:06
Thanks @coymeetsworld , I didn't know the conditional operator worked that way, no explanation on MDN.
CamperBot
@camperbot
May 02 2016 08:06
thomas-duval sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 690 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
its called the ternary operator just FYI
thomas-duval
@thomas-duval
May 02 2016 08:09
@coymeetsworld What I meant by no explanation on MDN is that it only says :
" condition : An expression that evaluates to true or false. "
Or I missed something ...
Coy Sanders
@coymeetsworld
May 02 2016 08:10
condition is just like what you would put in an if statement
Goun Choe
@lenaChoe
May 02 2016 08:10
I want to use this openweathermap API in Json
o API call: api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}
(ex. api.openweathermap.org/data/2.5/weather?lat=35&lon=139)

o API respond:
{"coord":{"lon":139,"lat":35},
"sys":{"country":"JP","sunrise":1369769524,"sunset":1369821049},
"weather":[{"id":804,"main":"clouds","description":"overcast clouds","icon":"04n"}],
"main":{"temp":289.5,"humidity":89,"pressure":1013,"temp_min":287.04,"temp_max":292.04},
"wind":{"speed":7.31,"deg":187.002},
"rain":{"3h":0},
"clouds":{"all":92},
"dt":1369824698,
"id":1851632,
"name":"Shuzenji",
"cod":200}
Coy Sanders
@coymeetsworld
May 02 2016 08:10

like for example you wouldn't do something like this

if (var x) {
//do something
}

Goun Choe
@lenaChoe
May 02 2016 08:11
How can I call this api in my javascript(jquery)? and use this json?
Coy Sanders
@coymeetsworld
May 02 2016 08:11
@lenaChoe you would use the getJSON function
Goun Choe
@lenaChoe
May 02 2016 08:11
@coymeetsworld $.getJSON("http://api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+lon, function(json) {
$("#location").html(JSON.stringify(json));
}); like this?????
Coy Sanders
@coymeetsworld
May 02 2016 08:12
yes something like that
Goun Choe
@lenaChoe
May 02 2016 08:12
@coymeetsworld okay Thanks alot! I will try in this way
CamperBot
@camperbot
May 02 2016 08:12
lenachoe sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 691 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 02 2016 08:12
no problem
thomas-duval
@thomas-duval
May 02 2016 08:13
@coymeetsworld What I don't understand is how a remainder operation match the requirement for the condition (i.e evaluates to true or false).
Coy Sanders
@coymeetsworld
May 02 2016 08:14
a value can be evaluated as true or false
if its 0 its false, if its not 0 its true
if (0) {
  console.log("0 is a true value"); //wont print
}
if (1) {
  console.log("1 is a true value"); //will print
}
if (-1) {
  console.log("-1 is a true value"); //will print
}
Eldar Tinjić
@EldarT90
May 02 2016 08:15
@coymeetsworld hey mate, do you have time to check out my problem later?
Coy Sanders
@coymeetsworld
May 02 2016 08:16
what problem @EldarT90
thomas-duval
@thomas-duval
May 02 2016 08:16
@coymeetsworld oooooh I guess I missed that, thanks a lot !
CamperBot
@camperbot
May 02 2016 08:16
thomas-duval sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: thomas-duval already gave coymeetsworld points
Eldar Tinjić
@EldarT90
May 02 2016 08:16
:point_up: May 2, 2016 10:04 AM @coymeetsworld
havent gotten that far @EldarT90 just starting that program
sounds like an edge case you have though
Eldar Tinjić
@EldarT90
May 02 2016 08:19
@coymeetsworld the thing is i use same formula for X and O, so i dont understand why it occurs only with O
Javier
@sh1g
May 02 2016 08:20
Probably an easier way to do the problem but I am feeling pretty good about finishing the Fibonacci aproblem
Coy Sanders
@coymeetsworld
May 02 2016 08:22
not sure why that is @EldarT90 , perhaps simplifying the code a bit would help you see what its doing, or writing out debugging lines
alpox
@alpox
May 02 2016 08:29
@EldarT90 It also happens with X as i see. The computer acts totally randomly
@EldarT90 Or maybe i understand you wrong ^^
Eldar Tinjić
@EldarT90
May 02 2016 08:33
@alpox nah randomness isnt problem ^^ btw good morning; it is workign randomly now because i havent coded it yet to take optimal squares; however if you play as an O vs computer-X
you should always be 1 move behind
and after 2-3 moves you will see that computer "will let you" to play 2 times O in a row
which is a bug
alpox
@alpox
May 02 2016 08:34
@EldarT90 what do you mean with let me play 2 times O in a row
@EldarT90 Ah now i've seen it
Eldar Tinjić
@EldarT90
May 02 2016 08:34
@alpox ^^
Justin Woodward
@jwoo92
May 02 2016 08:35
would anyone be able to assist me on the javascript challenge "profile lookup"? i am a little bit lost and could gratefuly use some guidance.

We have an array of objects representing different people in our contacts lists.

A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you.

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

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

if (firstName == "firstName" && prop == "likes") {
   return ;
} else if ( firstName != /*?*/ ) {
   return "No such contact";
} else if ( prop != /*?*/) {
   return "No such property";
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Coryphaeus
@cvdeby
May 02 2016 08:38
Does somebody remember the name of cinema, where engineer destroyed the super computer with tic tac toe game?)
Coy Sanders
@coymeetsworld
May 02 2016 08:38
@jwoo92 you need to first create a loop that goes through all contacts
and check if the objects firstName property matches the firstName you're passing into lookUpProfile
Jevaughn Vance
@jvans7
May 02 2016 08:39
@jwoo92 you have to create a loop
Justin Woodward
@jwoo92
May 02 2016 08:42
@coymeetsworld i am still not sure how to work off of your advice. in my code above, you can see what i have came up so far.
Coy Sanders
@coymeetsworld
May 02 2016 08:42
yeah theres a few problems
first of which is you're not looking at the contacts array at all
which you need to
you're not trying to hardcode firstName or prop in your first if statement
because firstName and prop can change, maybe you're looking for firstName Harry instead
Jevaughn Vance
@jvans7
May 02 2016 08:44
@jwoo92 think of it like a directory and you are checking all the first names in it and the way you do that is by looping through it. @coymeetsworld is a great helper
Coy Sanders
@coymeetsworld
May 02 2016 08:45
@jvans7 :+1: thanks
CamperBot
@camperbot
May 02 2016 08:45
coymeetsworld sends brownie points to @jvans7 :sparkles: :thumbsup: :sparkles:
:star: 238 | @jvans7 | http://www.freecodecamp.com/jvans7
Justin Woodward
@jwoo92
May 02 2016 08:47
@coymeetsworld thanks so far, i am not 100% confident yet when it comes to arrays and i have been having a hard time with javascript lately.
CamperBot
@camperbot
May 02 2016 08:47
jwoo92 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 694 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 02 2016 08:49
start off simple, try not to do everything at once then
z5014823
@z5014823
May 02 2016 08:49
blob
I think there is a mistake with the second last condition on the left panel,
Coy Sanders
@coymeetsworld
May 02 2016 08:50
break off the problem into small pieces, first you know you have to see if there is a contact with the name you're looking for
z5014823
@z5014823
May 02 2016 08:50
1.01 > 20-19.5 ==> Sufficient funds.. has anyone encountered this problem?
Coy Sanders
@coymeetsworld
May 02 2016 08:50
so look first into how to iterate through an array (i.e. you can use a for loop for that)
and just build off of that, then you need to see how to access the firstName property of the objects in the array, etc.
z5014823
@z5014823
May 02 2016 08:52
the question ^
blob
Coy Sanders
@coymeetsworld
May 02 2016 08:53
but can you give EXACT change @z5014823 ?
you can't break anything in the cash drawer, thats all you have
alpox
@alpox
May 02 2016 08:53
@EldarT90 Found the issue
z5014823
@z5014823
May 02 2016 08:54
@coymeetsworld ahah i didn't see that, thanks
CamperBot
@camperbot
May 02 2016 08:54
z5014823 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 695 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 02 2016 08:54
np @z5014823
alpox
@alpox
May 02 2016 08:54

@EldarT90 You forgot to push to newArr in restart:

      if (counter == 1) {
        b = Math.floor(Math.random() * 9) + 1;
        $("#f" + b).html("X");
        newArr.push(b);
      }

And on play-click:

  if (counter == 1) {
    b = Math.floor(Math.random() * 9) + 1;
    $("#f" + b).html("X");
    newArr.push(b);
  }
Eldar Tinjić
@EldarT90
May 02 2016 08:59
@alpox good eye mate, tnx i was looking at the wrong place all along
CamperBot
@camperbot
May 02 2016 08:59
eldart90 sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star: 628 | @alpox | http://www.freecodecamp.com/alpox
prashant kumar
@prashantpatchi
May 02 2016 08:59
hi
i need help
Quoting Strings with Single Quotes
Travis
@dukenukethem
May 02 2016 09:00
Hey everyone! Wrong section probably but is there any reason why I can't view my map?
Justin Woodward
@jwoo92
May 02 2016 09:00
@coymeetsworld this is what i have so far
for(var i=0; i < contacts.length; i++) {
  if (firstName == /*?*/) {

      }
}
looking better?
for (var i=0; i < contacts.length; i++) {
  if (firstName == /*?*/ && prop == /*?*/ ) {

      }
}
Jevaughn Vance
@jvans7
May 02 2016 09:03
@jwoo92 first line is good. well done
Eldar Tinjić
@EldarT90
May 02 2016 09:04
@alpox what do you think about desing btw? :D
Coy Sanders
@coymeetsworld
May 02 2016 09:05
yeah looks good
@dukenukethem think theres been some problems on the website
Travis
@dukenukethem
May 02 2016 09:06
Quick question, The "=" sign assigns values to variable right?
Coy Sanders
@coymeetsworld
May 02 2016 09:06
might have some intermittent issues, this shows on the top of my page "We're back up, but we're still fixing some minor issues. Thanks for your patience."
also yes to the variable assignment operator
Travis
@dukenukethem
May 02 2016 09:06
@coymeetsworld alright thanks I sawa that earlier :). Also thanks again haha
CamperBot
@camperbot
May 02 2016 09:06
dukenukethem sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 696 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 02 2016 09:06
np
the doer
@ewathedoer
May 02 2016 09:09
@dukenukethem right
Justin Woodward
@jwoo92
May 02 2016 09:10
am i headed in the right direction?
for (var i=0; i < contacts.length; i++) {
  if (firstName == contacts[0] && typeof prop == 'string' ) {

      }
}
prashant kumar
@prashantpatchi
May 02 2016 09:10
in need heölp in
help
CamperBot
@camperbot
May 02 2016 09:10

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. ex: find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • Algorithm BONFIRENAME info on a Algorithm

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

prashant kumar
@prashantpatchi
May 02 2016 09:11
Quoting Strings with singlwe Quotes
Raffy Jun Lorenzana
@raffylorenzana
May 02 2016 09:14
hi, need help on where art thou challenge
Coy Sanders
@coymeetsworld
May 02 2016 09:14
closer @jwoo92, except don't want to hardcode contacts[0], you want to check contacts[i], which is how you are checking each object in the contacts array
you also need to check the firstName of the contact, not just contacts
Coryphaeus
@cvdeby
May 02 2016 09:14
@jwoo92 Condition is wrong, but loop works right.
Coy Sanders
@coymeetsworld
May 02 2016 09:14
anyways going to bed soon, also with property look up the hasOwnProperty function, that is what you'll need to use
Coryphaeus
@cvdeby
May 02 2016 09:17
@jwoo92 Try to find Property of Object, which Value is equal to given firstName's value and Name is firstName
Darth Skywalker
@adityaparab
May 02 2016 09:18
@Alhaji24 Should be
function testGreaterOrEqual(val) {
  if (val>='20') {  // Change this line
    return "20 or Over";
  }

  if (val>='10') {  // Change this line
    return "10 or Over";
  }

  return "9 or Under";
}

// Change this value to test
testGreaterOrEqual(19);
Justin Woodward
@jwoo92
May 02 2016 09:18
this is what i currently have
for (var i=0; i < contacts.length; i++) {
  if (firstName == contacts[i] && typeof prop == 'string' ) {
      return prop;
      } else if ( firstName != contacts[i] && typeof prop == 'string') {
        return "No such contact";
      } else if (typeof prop != 'string') {
        return "No such property";
      }
}
Alhaji Turay
@Alhaji24
May 02 2016 09:19
@adityaparab thanks
CamperBot
@camperbot
May 02 2016 09:19
alhaji24 sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:star: 156 | @adityaparab | http://www.freecodecamp.com/adityaparab
Raffy Jun Lorenzana
@raffylorenzana
May 02 2016 09:20

need help on where art thou challenge
```
function whereAreYou(collection, source) {
var arr = [];
var key = Object.keys(source);

collection.forEach(function(item) {
if(item[key] === source[key]) {
arr.push(item);
}
});

return arr;

}

whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });

Coryphaeus
@cvdeby
May 02 2016 09:21
@jwoo92 Now you're trying to find Object which Name is firstName, but you need an Object which Property's Name is firstName and Value is equal to given firstName's value.
Raffy Jun Lorenzana
@raffylorenzana
May 02 2016 09:21
my code does not work when the object is more than one
Blauelf
@Blauelf
May 02 2016 09:22
@jwoo92 contacts[i] is an object that has (among others) a property of name "firstName". Also, you might want to revisit Testing Objects for Properties.
Raffy Jun Lorenzana
@raffylorenzana
May 02 2016 09:23
need help on where art thou challenge
i m not able to solve his can any one help me
Justin Woodward
@jwoo92
May 02 2016 09:25
@Blauelf thankyou, that is a good idea and you are right. i may have forgotten key aspects from that lesson.
@cvdeby thanks as well to you for helping me so far
CamperBot
@camperbot
May 02 2016 09:25
jwoo92 sends brownie points to @cvdeby :sparkles: :thumbsup: :sparkles:
:star: 396 | @cvdeby | http://www.freecodecamp.com/cvdeby
Razvan Bran
@razvan87
May 02 2016 09:25
Hello
I need some help with the strings
Blauelf
@Blauelf
May 02 2016 09:25
@rjlorenz931 You could use filter instead of forEach (and return the return value of filter), as you are rebuilding filter in some way, and as Object.keys gives an array, you have to iterate that (could do that using every)
Sean
@seanmi
May 02 2016 09:28
sir may i ask on how to out put other type of escape quote?. because im only able to output is the single quote only and the rest arent working. tia
Stephen James
@sjames1958gm
May 02 2016 09:31
@razvan87 You need build a sentence from the values passed into the function, including spaces between words. Do you recall how to join strings together, either literal " " or those stored in variables, for example myNoun
Blauelf
@Blauelf
May 02 2016 09:31
@razvan87 Remember how to combine strings and variables. The result string should include all words that were passed, and those should be individual words.
UDAY PRAPHULLA MALANGAVE
@malangaveuday
May 02 2016 09:31
<!DOCTYPE html>
<html>
   <head>
      <link rel="stylesheet" href="CSS/main.css">
  </head>

  <body> 

      <svg id="game-container">
          <g id="snake-container" x="20" y="20">

          </g>
      </svg>


      <!--<script src="JS/app.js"></script>-->
      <script src="new-app.js"></script>
  </body>

</html>
how to change x and y coordinates of g element dynamically ??
thomas-duval
@thomas-duval
May 02 2016 09:31
This message was deleted
prashant kumar
@prashantpatchi
May 02 2016 09:31
@seanmi even i am doing same
Sean
@seanmi
May 02 2016 09:32
ty sir @sjames1958gm
thomas-duval
@thomas-duval
May 02 2016 09:33

Hey there,
My filter function is not working :

function filterArr() {
        list.filter(function (element) {
            console.log(!regex.test(element));
            return !regex.test(element);
        });
    }

The console give the right answer (true or false) but the array (list) is not changed.
What's wrong ?

Stephen James
@sjames1958gm
May 02 2016 09:33
@malangaveuday Are you using jquery