These are chat archives for FreeCodeCamp/HelpJavaScript

19th
Jun 2017
Jorge Luis Vazquez
@zentech
Jun 19 2017 00:00
@revisualize I'm not trying to mutate... just removing special char and white spaces. then I recerse and assigned to "paly" var, then finally compre result
@revisualize ohh got it..
so I need to assigned to a tempStr... the mutated string.
Frank McCroy
@fmccroy
Jun 19 2017 00:01
@GregatGit I tried moving the quotation marks as recommended, but just got an error stating that URL was undefined. I used TidyJS to make things look better. The JQuery code came out of a video, only my URL’s were different, it should have worked. https://codepen.io/fmccroy/pen/MojYQz
Greg Duncan
@GregatGit
Jun 19 2017 00:03
@fmccroy did they have any css set up to target? you don't have any
Jorge Luis Vazquez
@zentech
Jun 19 2017 00:04
this regex is not removing white spaces.. why?
var tempStr = str.replace(/[\W_]\s+/g, '').toLowerCase();
Frank McCroy
@fmccroy
Jun 19 2017 00:04
@GregatGit I wasn’t sure if that was an issue, it’s not shown in the video. I’ve tried putting in a <body> statement in the HTML section
mrgrizzlie33
@mrgrizzlie33
Jun 19 2017 00:05

Hey guys, I'm having trouble understanding the Golf Code challenge. Any help?

Code:

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

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

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

Anthony Cortez
@Morralito
Jun 19 2017 00:05
@zentech if is only to remove the whitespaces try the trim method
Jorge Luis Vazquez
@zentech
Jun 19 2017 00:06
@Morralito no I need to remove especial char and white spaces
Greg Duncan
@GregatGit
Jun 19 2017 00:08
@fmccroy it is not allowing you to access imgur files
@fmccroy I tried this url https://s3-us-west-2.amazonaws.com/s.cdpn.io/385441/balance-110850.jpg and it worked
Manrique
@Manriqu3
Jun 19 2017 00:08
I really dont understand this mad libs part or where to start. Does anyone know what im talking about
mrgrizzlie33
@mrgrizzlie33
Jun 19 2017 00:09
Yea I think so @Manriqu3
Greg Duncan
@GregatGit
Jun 19 2017 00:09
@fmccroy FreeCodeCamp/FreeCodeCamp#5677
Anthony Cortez
@Morralito
Jun 19 2017 00:09
@zentech is that for a challenge? maybe i've solved it but i don't recall correctly
mrgrizzlie33
@mrgrizzlie33
Jun 19 2017 00:09
@Manriqu3 what lesson no?
Greg Duncan
@GregatGit
Jun 19 2017 00:09
@fmccroy imgur links don't work on code pen
SalimBen
@SalimKen
Jun 19 2017 00:09
@mrgrizzlie33 try like this .... if(strokes == 1){
return "Hole-in-one!";
}
else if( strokes <= (par-2)){
return "Eagle";}
....
Manrique
@Manriqu3
Jun 19 2017 00:09
@mrgrizzlie33 do i make a string and call the variables within it?
mrgrizzlie33
@mrgrizzlie33
Jun 19 2017 00:10
@SalimKen Ok thanks I will
CamperBot
@camperbot
Jun 19 2017 00:10
mrgrizzlie33 sends brownie points to @salimken :sparkles: :thumbsup: :sparkles:
:cookie: 208 | @salimken |http://www.freecodecamp.com/salimken
Manrique
@Manriqu3
Jun 19 2017 00:10
@mrgrizzlie33 i think its 156 or 155
mrgrizzlie33
@mrgrizzlie33
Jun 19 2017 00:10
@Manriqu3 One second
Manrique
@Manriqu3
Jun 19 2017 00:10
@mrgrizzlie33 take your time thank you so much
CamperBot
@camperbot
Jun 19 2017 00:10
manriqu3 sends brownie points to @mrgrizzlie33 :sparkles: :thumbsup: :sparkles:
:warning: @mrgrizzlie33's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Frank McCroy
@fmccroy
Jun 19 2017 00:11
@GregatGit Wow… after all this time the hosting site I picked is messing me up! Guess I pick somewhere else and try again. Is there a hosting site known to be FCC friendly? Thanks for you help @GregatGit
CamperBot
@camperbot
Jun 19 2017 00:11
fmccroy sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 865 | @gregatgit |http://www.freecodecamp.com/gregatgit
mrgrizzlie33
@mrgrizzlie33
Jun 19 2017 00:11
@Manriqu3 Do you happen to know the title of the lesson? It should be the heading of the text field (where they explain it)
Manrique
@Manriqu3
Jun 19 2017 00:12
word blanks
Greg Duncan
@GregatGit
Jun 19 2017 00:12
@fmccroy try photobucket or if you have an account amazon web services
mrgrizzlie33
@mrgrizzlie33
Jun 19 2017 00:13
@Manriqu3 could I see your code?
Manrique
@Manriqu3
Jun 19 2017 00:13
@mrgrizzlie33 I am a "double quoted" string inside "double quotes".
@mrgrizzlie33 one sec
Greg Duncan
@GregatGit
Jun 19 2017 00:14
Manrique
@Manriqu3
Jun 19 2017 00:14

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

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

mrgrizzlie33
@mrgrizzlie33
Jun 19 2017 00:14
@Manriqu3 Ok so you havent done anything yet
Manrique
@Manriqu3
Jun 19 2017 00:14
ive tried a few things but reset it
I tried making a var inside and using the + to add the other variables to the strings but nothing
its something else
idk where to start
the function thing confuses me
SalimBen
@SalimKen
Jun 19 2017 00:16
@Manriqu3 your result must be equal to a sentence you need to make with your argumant and don't forget the space between
mrgrizzlie33
@mrgrizzlie33
Jun 19 2017 00:17
Ok so the idea is that you want to string together the elements of the array wordBlanks. But you need to make sure that a) there is spacing between each side of each plus sign, b) there is some word or character of your own between each element (which is acutally important), and that's about it.
@Manriqu3
If you wanna see the code I can show it to you, but it'd be nice for you to be able to write it yourself.
Manrique
@Manriqu3
Jun 19 2017 00:17
okay let me take a crack at it for a while
ill be back
thank you
mrgrizzlie33
@mrgrizzlie33
Jun 19 2017 00:18

also, don't make a var in the function. just go

result = ...

@Manriqu3
Hope it works!
btw sorry if i am not explaining things the best, I am still a noob and havent really ever helped anyone b4
shelton louis
@louiss0
Jun 19 2017 00:19

@SalimKen 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");

SalimBen
@SalimKen
Jun 19 2017 00:19
@mrgrizzlie33 np it was also first time for me today ^^
mrgrizzlie33
@mrgrizzlie33
Jun 19 2017 00:21
@SalimKen well thank you, you did a great job for your first time xD!
CamperBot
@camperbot
Jun 19 2017 00:21
mrgrizzlie33 sends brownie points to @salimken :sparkles: :thumbsup: :sparkles:
:warning: mrgrizzlie33 already gave salimken points
SalimBen
@SalimKen
Jun 19 2017 00:21
@louiss0 you don't need to write this "case 7:
case 8:
case 9:
count= 0;
break; "
Manish Giri
@Manish-Giri
Jun 19 2017 00:21
@louiss0 need a space in the return
before Bet and Hold
mrgrizzlie33
@mrgrizzlie33
Jun 19 2017 00:23
@SalimKen Btw it worked I just wasn't using ==, I was only using = which was the problem
Manrique
@Manriqu3
Jun 19 2017 00:23
@mrgrizzlie33 hey i got it
SalimBen
@SalimKen
Jun 19 2017 00:23
@mrgrizzlie33
ty
mrgrizzlie33
@mrgrizzlie33
Jun 19 2017 00:23
@Manriqu3 Great! Hope I was of some help!
Manrique
@Manriqu3
Jun 19 2017 00:23
@mrgrizzlie33 when i did it first I put var infront of it all and it wasnt going through thank you
CamperBot
@camperbot
Jun 19 2017 00:23
manriqu3 sends brownie points to @mrgrizzlie33 :sparkles: :thumbsup: :sparkles:
:cookie: 192 | @mrgrizzlie33 |http://www.freecodecamp.com/mrgrizzlie33
mrgrizzlie33
@mrgrizzlie33
Jun 19 2017 00:24
@Manriqu3 Your welcome!
Man, it feels great to be able to help someone!
shelton louis
@louiss0
Jun 19 2017 00:26

why did i get two hold

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

@Manish-Giri 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 ");

SalimBen
@SalimKen
Jun 19 2017 00:27
@louiss0 in 7,8,9 it's
count += 0;
Manish Giri
@Manish-Giri
Jun 19 2017 00:27
@louiss0 why are you setting count to 0 here
case 7:
case 8:
case 9:
count = 0;
break;
Julianna
@jnelli
Jun 19 2017 00:27
Hi there! I'm stumped on the Local Scope and Functions JS exercise, although I've done this before...I'm not quite sure what I'm doing wrong this time around!
Manish Giri
@Manish-Giri
Jun 19 2017 00:27
you don't need to write these cases
count is not affected
shelton louis
@louiss0
Jun 19 2017 00:28
thanks got it
SalimBen
@SalimKen
Jun 19 2017 00:28
@louiss0 nice :)
Taku10
@Taku10
Jun 19 2017 00:28

function myLocalScope() {
'use strict';

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

plz help
Jorge Luis Vazquez
@zentech
Jun 19 2017 00:29
this was my implementation of palindrome, I know there's a shorter way to do it...
function palindrome(str) {
  // Good luck!
  //the string without especial char and lowercase
  var tempStr = str.replace(/[\W_]/g, '').toLowerCase();
  var paly = "";
  for(var i = tempStr.length-1; i >= 0; i--) {
    paly += tempStr.charAt(i);
  }
  return paly === tempStr;
}

palindrome("race car");
Julianna
@jnelli
Jun 19 2017 00:29
I'm stuck on the same one, @Taku10
working on it now...
Taku10
@Taku10
Jun 19 2017 00:29
ok... @jnelli ...
what do u have already
@jnelli
Mario A. Carlos
@MarioC3
Jun 19 2017 00:30
I'm stuck in this...
GAH
Julianna
@jnelli
Jun 19 2017 00:30

function myLocalScope() {
var myVar = 'use strict';
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

Manish Giri
@Manish-Giri
Jun 19 2017 00:31
@jnelli shouldn't you comment the last console log
Julianna
@jnelli
Jun 19 2017 00:31
wtf...ok, it worked when i ran it that time
Mario A. Carlos
@MarioC3
Jun 19 2017 00:31
When I try to end the transition and remove the class....
Julianna
@jnelli
Jun 19 2017 00:31
sans the console log line for myVar
Mario A. Carlos
@MarioC3
Jun 19 2017 00:31
it's not passing my element....
can someone help?
Julianna
@jnelli
Jun 19 2017 00:32
@Taku10 did you get it?
Taku10
@Taku10
Jun 19 2017 00:32
yeah but its not working @jnelli
shelton louis
@louiss0
Jun 19 2017 00:32
@Manish-Giri this is for the reverse a string challenge reverseString("hello");
var reverseString = str.split.reverse.join('hello');
Mario A. Carlos
@MarioC3
Jun 19 2017 00:33
someone?
Taku10
@Taku10
Jun 19 2017 00:33
ok...its wiorking now thanx @jnelli
CamperBot
@camperbot
Jun 19 2017 00:33
taku10 sends brownie points to @jnelli :sparkles: :thumbsup: :sparkles:
:cookie: 174 | @jnelli |http://www.freecodecamp.com/jnelli
william
@theironcock
Jun 19 2017 00:33
stand in line i can't get it
Julianna
@jnelli
Jun 19 2017 00:33
woo!!
Manish Giri
@Manish-Giri
Jun 19 2017 00:33
@louiss0 you should read how split and join works
on mdn
Taku10
@Taku10
Jun 19 2017 00:33
are u at level 169 @jnelli
william
@theironcock
Jun 19 2017 00:33

function nextInLine(arr, item) {
// Your code here
return (testArr, item); // Change this line
}

// Test Setup
var testArr = [4];

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

Mario A. Carlos
@MarioC3
Jun 19 2017 00:35
(?)
ChrisAB74
@ChrisAB74
Jun 19 2017 00:38
Having trouble with the escape sequence. This is what I have var myStr = "FirstLine\n\SecondLine\\rThirdLine";
Jorge Luis Vazquez
@zentech
Jun 19 2017 00:38
what is wrong with this
function findLongestWord(str) {
  var arr = str.split(" ");

  return arr.sort(function(a, b) {
    return b.length - a.length;
  })[0];
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Frank McCroy
@fmccroy
Jun 19 2017 00:38
@theironcock You need to add the “item” to the end of the array (arr), then remove the element from the front of the array, while returning whatever was removed. Look into the commands push, pop, shift if you need more help
Or just ask for more help here :)
Mario A. Carlos
@MarioC3
Jun 19 2017 00:47
I have a question. Some one here?
@MarioC3 you can ask i will try to answer if i can ^^
Mario A. Carlos
@MarioC3
Jun 19 2017 00:56
I got it figured it out...
Thanks! :)
SalimBen
@SalimKen
Jun 19 2017 00:56
@MarioC3 Ok Nice :)
Moisés Man
@moigithub
Jun 19 2017 01:01
@zentech ur function need to return the LENGTH of the largest word
ur code looks OK, refresh the page.. or reset code do again @ChrisAB74
Keon Samuel
@keonsam
Jun 19 2017 01:05
I see like 3 ads per video on youtube
Jorge Luis Vazquez
@zentech
Jun 19 2017 01:12
this is giving me the right output; however, it is not passing
function titleCase(str) {
  var arr = str.toLowerCase().split(" ");
  var output = "";
  for(var i = 0; i < arr.length; i++) {
    output += arr[i].charAt(0).toUpperCase() + arr[i].substring(1,arr[i].length);
    output += " ";
  }
  return output;
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
Manish Giri
@Manish-Giri
Jun 19 2017 01:15
are you adding a space at the end?
I think so.
@zentech
Remy Dale
@TheRemyD
Jun 19 2017 01:21
@ChrisAB74 Did you ever figure out your problem? If not make sure you are outputting the same data that the exercise is requesting. The last part of that string is missing an escape key
Ariel
@ArielLeslie
Jun 19 2017 01:22
@zentech You are adding a space on to the end of every output.
ChrisAB74
@ChrisAB74
Jun 19 2017 01:26
@zentech @TheRemyD I did get it. Not sure what the issue was. Thanks
CamperBot
@camperbot
Jun 19 2017 01:26
chrisab74 sends brownie points to @zentech and @theremyd :sparkles: :thumbsup: :sparkles:
:cookie: 217 | @theremyd |http://www.freecodecamp.com/theremyd
:cookie: 255 | @zentech |http://www.freecodecamp.com/zentech
Moisés Man
@moigithub
Jun 19 2017 01:28
@zentech u could use trim() method to remove the extra space
mdn.io/trim
Jorge Luis Vazquez
@zentech
Jun 19 2017 01:41
@moigithub thanks got it...
CamperBot
@camperbot
Jun 19 2017 01:41
zentech sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3377 | @moigithub |http://www.freecodecamp.com/moigithub
Jorge Luis Vazquez
@zentech
Jun 19 2017 01:42
here's my implementation of confirm the ending
function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  str = str.trim();
  return str.substring((str.length - target.length), str.length) === target;
}

confirmEnding("Bastian", "n");
shelton louis
@louiss0
Jun 19 2017 01:44
where did i go wrong @Manish-Giri var total = 1;
for (var i = 1; i <= num; i++) {
total *= i;
}
@louiss0 that was for the factorialize challenge
Frank McCroy
@fmccroy
Jun 19 2017 01:46
@louiss0 Where is your return statement?
Mario A. Carlos
@MarioC3
Jun 19 2017 01:48
Guys another question
Frank McCroy
@fmccroy
Jun 19 2017 01:48
@louiss0 You added up total, but you never returned it in the end.
Mario A. Carlos
@MarioC3
Jun 19 2017 01:49
<!DOCTYPE html>
<html >
<head>
  <meta charset="UTF-8">
  <title>Javascript Drumkit</title>



      <link rel="stylesheet" href="css/style.css">


</head>

<body>
  <link href="https://fonts.googleapis.com/css?family=Raleway:200,900" rel="stylesheet">

<div class='general-wrapper'>

  <h1> JavaScript <br> Drum kit</h1>
  <p>Use your keyboard to play the drums!</p>

  <div class='key-wrapper'>
    <div class='keys'>
      <div data-key="65" class="key">
        <kbd>A</kbd>
      </div>
      <div data-key="83" class="key">
        <kbd>S</kbd>
      </div>
      <div data-key="68" class="key">
        <kbd>D</kbd>
      </div>
      <div data-key="70" class="key">
        <kbd>F</kbd>
      </div>
      <div data-key="71" class="key">
        <kbd>G</kbd>
      </div>
      <div data-key="72" class="key">
        <kbd>H</kbd>
      </div>
      <div data-key="74" class="key">
        <kbd>J</kbd>
      </div>
      <div data-key="75" class="key">
        <kbd>K</kbd>
      </div>
      <div data-key="76" class="key">
        <kbd>L</kbd>
      </div>
    </div>
  </div>

  <div class='reference'>
    <h2 class='sound-text'>Placeholder</h2>
  </div>
  <footer>
    <h3>Made by Mario A. Carlos</h3>
    <a href='https://github.com/MarioC3/Nifty-Quotes'><img class='logos' src='https://gallery.mailchimp.com/8235f94dbdd8c42511c1f5e43/images/188bfb70-e600-4415-bc26-fa5a4dc30a50.png'></a>
  </footer>

</div>


<audio data-key="65" src="sounds/clap.wav"></audio>
<audio data-key="83" src="sounds/hihat.wav"></audio>
<audio data-key="68" src="sounds/kick.wav"></audio>
<audio data-key="70" src="sounds/openhat.wav"></audio>
<audio data-key="71" src="sounds/boom.wav"></audio>
<audio data-key="72" src="sounds/ride.wav"></audio>
<audio data-key="74" src="sounds/snare.wav"></audio>
<audio data-key="75" src="sounds/tom.wav"></audio>
<audio data-key="76" src="sounds/tink.wav"></audio>

<script>
  var text = window.getElementById('sound-text');
  console.log(text.innerHTML);


... and so on and so on...
Sorry it's actually this code
<!DOCTYPE html>
<html >
<head>
  <meta charset="UTF-8">
  <title>Javascript Drumkit</title>



      <link rel="stylesheet" href="css/style.css">


</head>

<body>
  <link href="https://fonts.googleapis.com/css?family=Raleway:200,900" rel="stylesheet">

<div class='general-wrapper'>

  <h1> JavaScript <br> Drum kit</h1>
  <p>Use your keyboard to play the drums!</p>

  <div class='key-wrapper'>
    <div class='keys'>
      <div data-key="65" class="key">
        <kbd>A</kbd>
      </div>
      <div data-key="83" class="key">
        <kbd>S</kbd>
      </div>
      <div data-key="68" class="key">
        <kbd>D</kbd>
      </div>
      <div data-key="70" class="key">
        <kbd>F</kbd>
      </div>
      <div data-key="71" class="key">
        <kbd>G</kbd>
      </div>
      <div data-key="72" class="key">
        <kbd>H</kbd>
      </div>
      <div data-key="74" class="key">
        <kbd>J</kbd>
      </div>
      <div data-key="75" class="key">
        <kbd>K</kbd>
      </div>
      <div data-key="76" class="key">
        <kbd>L</kbd>
      </div>
    </div>
  </div>

  <div class='reference'>
    <h2 class='sound-text'>Placeholder</h2>
  </div>
  <footer>
    <h3>Made by Mario A. Carlos</h3>
    <a href='https://github.com/MarioC3/Nifty-Quotes'><img class='logos' src='https://gallery.mailchimp.com/8235f94dbdd8c42511c1f5e43/images/188bfb70-e600-4415-bc26-fa5a4dc30a50.png'></a>
  </footer>

</div>


<audio data-key="65" src="sounds/clap.wav"></audio>
<audio data-key="83" src="sounds/hihat.wav"></audio>
<audio data-key="68" src="sounds/kick.wav"></audio>
<audio data-key="70" src="sounds/openhat.wav"></audio>
<audio data-key="71" src="sounds/boom.wav"></audio>
<audio data-key="72" src="sounds/ride.wav"></audio>
<audio data-key="74" src="sounds/snare.wav"></audio>
<audio data-key="75" src="sounds/tom.wav"></audio>
<audio data-key="76" src="sounds/tink.wav"></audio>

<script>
  var text = document.getElementsByTagName('h2');
  console.log(text.innerHTML);
when I go to the console. It logs undefined...
shouldn't it be supposed to log Placeholder?
Bryan Reese
@breese8009
Jun 19 2017 01:51
@zentech
function confirmEnding(str, target) {

  return str.substring(-target.length) === target;
}

confirmEnding("Bastian", "n");
@MarioC3 please learn to use gist or code pen, code walls are extremely hard to look at
@zentech btw u actually dont need trim()
;)
Mario A. Carlos
@MarioC3
Jun 19 2017 01:56
ok
How do you select the text in a H2 tag
Bryan Reese
@breese8009
Jun 19 2017 01:56
well, u can do by id,class or element
Mario A. Carlos
@MarioC3
Jun 19 2017 01:57
document.getElementsByTagName('h2')
right?
But that's selecting the actual tag... I want to select the text inside of it
as far as I'm concerned this is how you would do it:
document.getElementsByTagName('h2').innerHTML
correct?
Bryan Reese
@breese8009
Jun 19 2017 01:58
far as i can see, looks right
innerHTML=?
Manish Giri
@Manish-Giri
Jun 19 2017 01:59
@MarioC3 document.getElementsByTagName('h2')
won't this return an array?
unless you want the text for all h2s
you need to select an item off of the array
Bryan Reese
@breese8009
Jun 19 2017 01:59
^
Mario A. Carlos
@MarioC3
Jun 19 2017 02:00
How would I do that?
document.getElementsByTagName('h2[0]')
llike this: document.getElementsByTagName('h2')
?
sorry, like this: document.getElementsByTagName('h2[0]')
Manish Giri
@Manish-Giri
Jun 19 2017 02:01
document.getElementsByTagName('h2')[0]
that
Mario A. Carlos
@MarioC3
Jun 19 2017 02:01
ohhhhhhh
thanks @Manish-Giri !
CamperBot
@camperbot
Jun 19 2017 02:02
marioc3 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6028 | @manish-giri |http://www.freecodecamp.com/manish-giri
Mario A. Carlos
@MarioC3
Jun 19 2017 02:02
That worked!
Manish Giri
@Manish-Giri
Jun 19 2017 02:02
@MarioC3 :+1:
Abhilash Kumar
@apravink
Jun 19 2017 02:02
Hi
has anyone here done the Twitch API challenge?
Thiago De Oliveira
@tdeoliveira05
Jun 19 2017 02:05

Guys I need help at the moment:

The goal is for abTest(-2, 2) to return undefined. I have the following code which does return undefined but the challenge says I havent passed it:

// Setup
function abTest(a, b) {
// Only change code below this line

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

}
// Only change code above this line

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

// Change values below to test your code
abTest(-2, 2);

Mario A. Carlos
@MarioC3
Jun 19 2017 02:08
Ok. quick question again. Once you have it selected, how do you replace it's contents?
do you do it with replae function?
replace*
Andrae M
@andraemarcus
Jun 19 2017 02:10

Can someone help with solving this one? Unsure if the syntax is written correctly.

Assignment: Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.

My answer:
11%3 = 2

Abhilash Kumar
@apravink
Jun 19 2017 02:11
Is the FCC Twitch API down?
Frank McCroy
@fmccroy
Jun 19 2017 02:13
@andraemarcus You need to assign that to a variable.. ie. remainder = 11 % 3 or using variable names in place of 11 and 3, whatever the assignment called for.
"Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator"
Andrae M
@andraemarcus
Jun 19 2017 02:19
@fmccroy thanks bro! I forgot to include the variable name as you suggested above.
CamperBot
@camperbot
Jun 19 2017 02:19
andraemarcus sends brownie points to @fmccroy :sparkles: :thumbsup: :sparkles:
:cookie: 360 | @fmccroy |http://www.freecodecamp.com/fmccroy
lakshmi pallavi
@pallavilakhi9
Jun 19 2017 02:19

Hi Guys
Im at Profile Lookup step and i cannot get the console working , the output is blank.
Here is my code

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

console.log(firstName);

// Only change code above this line
}

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

Frank McCroy
@fmccroy
Jun 19 2017 02:21
@pallavilakhi9 How are you looking at the console? It should be showing whatever is in firstName.
For me, using FireFox I have to bring up the “Browser Console” which is accessed from the Dev Tools menu. Or command-shift-j on my Mac.
Jeff Bothe
@jmbothe
Jun 19 2017 02:26
hey gang. I have finished all the beta basic algorithm challenges except for the falsy bouncer. I feel like I am so close! I posted my code and thoughts on an existing FCC forum post. take a look if you have a minute. Thanks! https://forum.freecodecamp.com/t/falsy-bouncer-challenge/101663/7
lakshmi pallavi
@pallavilakhi9
Jun 19 2017 02:26
@fmccroy : yeah the output should be Akira
but i have nothing but blank
as you said i opened browser console in chrome where i could see Akira
but not in the space below "RUN" where we normally see our output.
DistinctWolf
@DistinctWolf
Jun 19 2017 02:26
Why does this return false

function type() {
 var number=arguments[0];
   console.log(typeof number===Number);
}
type(1);
Frank McCroy
@fmccroy
Jun 19 2017 02:28
@pallavilakhi9 A console.log will not show output where we normally see things on FCC, you have to go looking for it specifically in the browser.
@FlashHero number is not the same as Number ?
Khein Gutierrez
@kheinrg
Jun 19 2017 02:29
Man... JS is kinda way to hard to leaaarn. Haha
*too
Anthony Cortez
@Morralito
Jun 19 2017 02:30
@FlashHero numbers is not the same s Number and typeof number !== number
Frank McCroy
@fmccroy
Jun 19 2017 02:30
Although I would think trying to do typeof to a comparison statement should return boolean..
DistinctWolf
@DistinctWolf
Jun 19 2017 02:31
wait what but if i console.log typeof number variable i get Number so i'm confused please explain
Jeff Bothe
@jmbothe
Jun 19 2017 02:32
try '''function type() {
var number=arguments[0];
console.log(number===number);
}
type(1);'''
CamperBot
@camperbot
Jun 19 2017 02:32
:bulb: to format code use backticks! ``` more info
Jeff Bothe
@jmbothe
Jun 19 2017 02:33
i mean function type() { var number=arguments[0]; console.log(number===number); } type(1);
Anthony Cortez
@Morralito
Jun 19 2017 02:33
typeof number returns" number" as an string
comparing that string to a number whos value is a integer returns false
var n  =  1;
console.log(typeof n === n);

// returns false
DistinctWolf
@DistinctWolf
Jun 19 2017 02:35
oh ok thanks @Morralito @jmbothe
CamperBot
@camperbot
Jun 19 2017 02:35
:cookie: 65 | @jmbothe |http://www.freecodecamp.com/jmbothe
:cookie: 265 | @morralito |http://www.freecodecamp.com/morralito
flashhero sends brownie points to @morralito and @jmbothe :sparkles: :thumbsup: :sparkles:
RyanHuang06
@RyanHuang06
Jun 19 2017 02:35
@SalimKen sry for late reply, but thanks!
CamperBot
@camperbot
Jun 19 2017 02:35
ryanhuang06 sends brownie points to @salimken :sparkles: :thumbsup: :sparkles:
:cookie: 211 | @salimken |http://www.freecodecamp.com/salimken
DistinctWolf
@DistinctWolf
Jun 19 2017 02:36
@jmbothe you should use the Boolean object that will return all the true value
McDuckerton
@McDuckerton
Jun 19 2017 02:40

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

fahrenheit = 0 9/5 + 32;
fahrenheit = 20
9/5 + 32;
// Only change code above this line
return fahrenheit;
}

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

I am trying to get all temperatures to return but just can't seem to figure it out
Manish Giri
@Manish-Giri
Jun 19 2017 02:42
@McDuckerton use the celsius variable
instead of numbers 0 or 20
Ogundele Olumide
@Lumexralph
Jun 19 2017 02:44
@McDuckerton use celsius * 9 / 5 + 32;
McDuckerton
@McDuckerton
Jun 19 2017 02:44
@Manish-Giri, thank you! I don't know why I didn't think of that before.
CamperBot
@camperbot
Jun 19 2017 02:44
mcduckerton sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 6029 | @manish-giri |http://www.freecodecamp.com/manish-giri
Ogundele Olumide
@Lumexralph
Jun 19 2017 02:44
@Manish-Giri Bro! but still gggggggggm :smiling_imp:
Guderian Raborg
@hypercuber
Jun 19 2017 02:51
How do you put different tags in html in same line without line break?
Ogundele Olumide
@Lumexralph
Jun 19 2017 02:52
@hypercuber nest them I think and taking into consideration their box type (inline or block)
Guderian Raborg
@hypercuber
Jun 19 2017 02:53

I dont follow. Like those tags:

<h1>Hi</h1> <p>yall</p>

shows : "HI yall"

not:
HI
yall
Ogundele Olumide
@Lumexralph
Jun 19 2017 02:54
@hypercuber what did you do to your CSS ?
Guderian Raborg
@hypercuber
Jun 19 2017 02:54
@Lumexralph Nothing. I think there is a way in html
I am not using table or anything...
DistinctWolf
@DistinctWolf
Jun 19 2017 02:55
@hypercuber you'll have to set display to block for that
Wyut-Yi
@Wyut-Yi
Jun 19 2017 02:55
please help me ! The first elements in each of your sub-arrays must all be strings
The second elements in each of your sub-arrays must all be numbers
You must have at least 5 items in your list
Guderian Raborg
@hypercuber
Jun 19 2017 02:56
@FlashHero Can you give me more info or link about it ?
Ogundele Olumide
@Lumexralph
Jun 19 2017 02:56
@hypercuber for me it came out as
Hi

yall
Guderian Raborg
@hypercuber
Jun 19 2017 02:56
I want it in one line
Ogundele Olumide
@Lumexralph
Jun 19 2017 02:57
@hypercuber then you do some lil CSS h1 and p are block elements, uses css and make their display {inline}
DistinctWolf
@DistinctWolf
Jun 19 2017 02:58
h1{
  display:inline;
}
p{
  display:inline;
}
Ogundele Olumide
@Lumexralph
Jun 19 2017 02:58
@Wyut-Yi [[string, number], [string, number], .........]
SAURABH SHEORAIN
@SSheorain
Jun 19 2017 02:59
@roxroy thanks
CamperBot
@camperbot
Jun 19 2017 02:59
ssheorain sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:cookie: 986 | @roxroy |http://www.freecodecamp.com/roxroy
Guderian Raborg
@hypercuber
Jun 19 2017 02:59
@Lumexralph @FlashHero thanks
CamperBot
@camperbot
Jun 19 2017 02:59
hypercuber sends brownie points to @lumexralph and @flashhero :sparkles: :thumbsup: :sparkles:
:cookie: 201 | @flashhero |http://www.freecodecamp.com/flashhero
:star2: 1956 | @lumexralph |http://www.freecodecamp.com/lumexralph
Guderian Raborg
@hypercuber
Jun 19 2017 02:59
is there a way in html?
Kelechi Chinaka
@ke1echi
Jun 19 2017 03:00
:wave: @Lumexralph
Adrian Turika
@therealcode
Jun 19 2017 03:00
Does anyone know what I'm doing wrong here? It all shows as one line of text... var myStr = "FirstLine\n\SecondLine\\nThirdLine"; // Change this line
Ogundele Olumide
@Lumexralph
Jun 19 2017 03:00
@hypercuber yes, using the style attribute of each tags I think
@kelechichinaka bro
@therealcode carriage-return \r before ThirdLine not \n
Adrian Turika
@therealcode
Jun 19 2017 03:02
OOOOO thanks @Lumexralph !
CamperBot
@camperbot
Jun 19 2017 03:02
therealcode sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1957 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jun 19 2017 03:02
@therealcode :+1:
Roxroy
@roxroy
Jun 19 2017 03:02
@therealcode , you will need to escape the \Secon... and \Third.. section. Add an extra \, so that here are 2 . Secondly, you are missing the \ before \ThirdLine
Guderian Raborg
@hypercuber
Jun 19 2017 03:03

One way that works is

    </tr>
      <td>HI</td>
      <td>yall</td>
    <tr>

without <table> but if I am going to make a bunch I might want to use table

Adrian Turika
@therealcode
Jun 19 2017 03:03
@roxroy Thank you!
CamperBot
@camperbot
Jun 19 2017 03:03
therealcode sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:cookie: 987 | @roxroy |http://www.freecodecamp.com/roxroy
fdemaa
@fdemaa
Jun 19 2017 03:04
@Lumexralph hi ! I have a string, an i use split, to convert it in an array of substring , can i use a loop to calculate the length of each substring ? or there is other way ? im stuck with this one
Ogundele Olumide
@Lumexralph
Jun 19 2017 03:05
@fdemaa sure you can loop through to get the length of each element
fdemaa
@fdemaa
Jun 19 2017 03:06
@Lumexralph okey i will keep trying then
Wyut-Yi
@Wyut-Yi
Jun 19 2017 03:06
@Lumexralph thank you! i got it xD
Ogundele Olumide
@Lumexralph
Jun 19 2017 03:06
@fdemaa it won't be an array of substring, just an array of the string characters
@fdemaa you can also use map too
@Wyut-Yi :+1:
fdemaa
@fdemaa
Jun 19 2017 03:07
thanks man @Lumexralph
CamperBot
@camperbot
Jun 19 2017 03:07
fdemaa sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1958 | @lumexralph |http://www.freecodecamp.com/lumexralph
Roxroy
@roxroy
Jun 19 2017 03:07
@fdemaa , you can use a for loop to iterate the list. Create a variable to store the longest string and update it if the subsequent one is larger. Then return the variable storing the longest one.
BernardMaling
@BernardMaling
Jun 19 2017 03:08
How do you complete " using objects for lookups" without messing with the return?
Roxroy
@roxroy
Jun 19 2017 03:10
@BernardMaling , assign the new value to the result variable.
result = ..answer goes here...;
fdemaa
@fdemaa
Jun 19 2017 03:11
@roxroy thanks !
CamperBot
@camperbot
Jun 19 2017 03:11
fdemaa sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:cookie: 988 | @roxroy |http://www.freecodecamp.com/roxroy
Zach Hall
@el4z
Jun 19 2017 03:11
doing the mutations algorithim challenge. have passed all but one test
Paul Christian L. Catoera
@poncatoera
Jun 19 2017 03:11
the first?
Zach Hall
@el4z
Jun 19 2017 03:11
seems its an issue that its not running the loop for the last array
Paul Christian L. Catoera
@poncatoera
Jun 19 2017 03:11
@el4z
Zach Hall
@el4z
Jun 19 2017 03:11
yeah

function mutation(arr) {
var lower = arr[0].toLowerCase();
var lower2 = arr[1].toLowerCase();
var indexval = lower.indexOf(lower2);
if (indexval != -1){
return true;
}
else{
lower2=lower2.toLowerCase().split("")
for (var i=0;i<lower2.length;i++){
var test = lower.indexOf(lower2[i]);
if (test!==-1){
i++;
}
else {
return false;
}
return true;
}
}
}

mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]);

Ogundele Olumide
@Lumexralph
Jun 19 2017 03:12
@el4z you should return true out of the loop
Paul Christian L. Catoera
@poncatoera
Jun 19 2017 03:12
im having trouble too. mine wasnt looping and it is only checking the first character of the string
Zach Hall
@el4z
Jun 19 2017 03:13
ive got true at the very bottom. idea is that if it tests every character and none are -1 it is true
but its bypassing to true without testing the last character of 'hey'
Ogundele Olumide
@Lumexralph
Jun 19 2017 03:14
@el4z but you're returning in your loop? that won't make the loop complete checking if it's true
Zach Hall
@el4z
Jun 19 2017 03:14
i thought return ended the function. ok
so after return false do I set i to a number that stops the loop or something?
Ogundele Olumide
@Lumexralph
Jun 19 2017 03:15
@el4z what's this doing at the top
if (indexval != -1){
return true;
}
Zach Hall
@el4z
Jun 19 2017 03:15
to test if the whole word is indexed. if it is there is no need to break it up and test each individual word
letter*
Ogundele Olumide
@Lumexralph
Jun 19 2017 03:15
@el4z the moment you return a value from a function, it gives the value stops execution of the function and exits the function
Zach Hall
@el4z
Jun 19 2017 03:16
yeah i thought so.
Ogundele Olumide
@Lumexralph
Jun 19 2017 03:16

@el4z what's this doing at the top

if (indexval != -1){
return true;
}

you don't need that in your code @el4z

BernardMaling
@BernardMaling
Jun 19 2017 03:17
thanks @roxroy
CamperBot
@camperbot
Jun 19 2017 03:17
bernardmaling sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:cookie: 989 | @roxroy |http://www.freecodecamp.com/roxroy
Zach Hall
@el4z
Jun 19 2017 03:17

function mutation(arr) {

var lower = arr[0].toLowerCase();
var lower2 = arr[1].toLowerCase().split("");
var i = 0;
while (i<lower2.length){
var test = lower.indexOf(lower2[i]);
if (test !== -1){
i++;
test=0;
}
else {
return false;
}
return true;
}

this was my original code
same issue
doesn't have that at the top
Paul Christian L. Catoera
@poncatoera
Jun 19 2017 03:21

function mutation(arr) {
  var a = arr[0].toLowerCase();
  var b = arr[1].toLowerCase();
 for (var i = 0; i < arr[1].length; i++) {
  if (a.indexOf(b[i]) < 0) { 
    return false;
 } return true;
}
}
mutation(["hello", "hell "]);
this was mine too same problem.
Zach Hall
@el4z
Jun 19 2017 03:22
weird man!
Ogundele Olumide
@Lumexralph
Jun 19 2017 03:22
@el4z when the loop is done checking through the characters and sees all characters in the other array, then it should return a true for mutation, so return true out of the loop, after it
Zach Hall
@el4z
Jun 19 2017 03:22
palindrome?
im not doing the palindrome one haha
Ogundele Olumide
@Lumexralph
Jun 19 2017 03:22
@poncatoera you have same issue too, return true after the for loop
Paul Christian L. Catoera
@poncatoera
Jun 19 2017 03:23
thanks @Lumexralph that worked
CamperBot
@camperbot
Jun 19 2017 03:23
poncatoera sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1959 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jun 19 2017 03:24
@el4z sorry for the typo, meant mutation
Paul Christian L. Catoera
@poncatoera
Jun 19 2017 03:24
can you explain further? why if the true is inside the loop it is correct except for the first trial? @Lumexralph
Ogundele Olumide
@Lumexralph
Jun 19 2017 03:24
@poncatoera :+1:
Paul Christian L. Catoera
@poncatoera
Jun 19 2017 03:25
does it stop at the last character so it returns true?
Zach Hall
@el4z
Jun 19 2017 03:25
@Lumexralph thanks for the help man, i'll try work it out
CamperBot
@camperbot
Jun 19 2017 03:25
el4z sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1960 | @lumexralph |http://www.freecodecamp.com/lumexralph
Lostboy561
@Lostboy561
Jun 19 2017 03:26
hey need some help here, I am suppose to return the last letter in a string and that last letter if it matches a target letter should return true....... however confirmEnding("He has to give me a new name", "name") returns false ?????????

function confirmEnding(str, target)
{
// "Never give up and good luck will find you."
// -- Falcor
if (str.slice(-1) == target)
{
return true;

}

else{
return false;
}

}

confirmEnding("He has to give me a new name", "name");

Ogundele Olumide
@Lumexralph
Jun 19 2017 03:26
@poncatoera because when the loop is not done checking but don't run the condition you gave, it goes to the return true; statement, and what return does is to give the expression/value on the right and exit the function at that point, that causes the loop to stop early too
Lostboy561
@Lostboy561
Jun 19 2017 03:27
it would be nice if i new how to just share the screen shoot thing
Ogundele Olumide
@Lumexralph
Jun 19 2017 03:27
@Lostboy561 you'll need to use the length property of target to make it easier for you
Paul Christian L. Catoera
@poncatoera
Jun 19 2017 03:27
@Lumexralph okay got it. thanks again
Ogundele Olumide
@Lumexralph
Jun 19 2017 03:27
@Lostboy561 or format your code ?
Lostboy561
@Lostboy561
Jun 19 2017 03:28
so whats wrong with it...... should it be str.slice(str, length -1)
@Lumexralph
i tried that didn't work on that phrase
Lostboy561
@Lostboy561
Jun 19 2017 03:34
,,,,,,

function confirmEnding(str, target)
{
// "Never give up and good luck will find you."
// -- Falcor
if (str.slice(str, length -1) == target)
{
return true;

}

else{

return false;

}
}

confirmEnding("He has to give me a new name", "name");
,,,,,

i don't know how you input this into this chat
Ogundele Olumide
@Lumexralph
Jun 19 2017 03:34
@Lostboy561 target.length should take you closer
Jonathon Lopez
@JonathonLLopez
Jun 19 2017 03:35
@Lostboy561 add 3 backticks () and then shift+enter, paste code, and then 3 more backticks ()
Lostboy561
@Lostboy561
Jun 19 2017 03:36

\\
function confirmEnding(str, target)
{
// "Never give up and good luck will find you."
// -- Falcor
if (str.slice(str, length -1) == target)
{
return true;

}

else{

return false;

}
}

confirmEnding("He has to give me a new name", "name");
\\

Jonathon Lopez
@JonathonLLopez
Jun 19 2017 03:36
@Lostboy561 sorry, this is a backtick (`)
Lostboy561
@Lostboy561
Jun 19 2017 03:36
function confirmEnding(str, target)
{
  // "Never give up and good luck will find you."
  // -- Falcor
  if (str.slice(str, length -1) == target)
    {
      return true;

    }
  else{

    return false;
  }  
}

confirmEnding("He has to give me a new name", "name");
thanks
Zach Hall
@el4z
Jun 19 2017 03:36
@Lumexralph I got it! you were right, just positioning of return true. tyvm
Lostboy561
@Lostboy561
Jun 19 2017 03:37
@JonathonLLopez thanks
CamperBot
@camperbot
Jun 19 2017 03:37
lostboy561 sends brownie points to @jonathonllopez :sparkles: :thumbsup: :sparkles:
:cookie: 314 | @jonathonllopez |http://www.freecodecamp.com/jonathonllopez
Lostboy561
@Lostboy561
Jun 19 2017 03:38
that phrase just won't return true
NotTheBest
@NotTheBest
Jun 19 2017 03:44
I need help on the "profile lookup" level
Lostboy561
@Lostboy561
Jun 19 2017 03:44
anyone there lol
NotTheBest
@NotTheBest
Jun 19 2017 03:44
I can't seem to get it working

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

function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName == firstName) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i].prop;
}
else
return "No such property";
}
}
return "No such contact";
// Only change code above this line
}
// Change these values to test your function
lookUpProfile("Akira", "likes");

this is my code right now, I'm not sure if its the best way to do it
The code isn't printing out the value if both the first name and property exists
Ogundele Olumide
@Lumexralph
Jun 19 2017 03:46
@NotTheBest prop is a parameter, just like a variable use bracket notation to access the object contacts[i]
Jonathon Lopez
@JonathonLLopez
Jun 19 2017 03:47
@Lostboy561 I'd offer to help, but I'm working on that challenge myself
NotTheBest
@NotTheBest
Jun 19 2017 03:47
wow
thanks @Lumexralph
CamperBot
@camperbot
Jun 19 2017 03:47
notthebest sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1961 | @lumexralph |http://www.freecodecamp.com/lumexralph
NotTheBest
@NotTheBest
Jun 19 2017 03:47
I didn't know you couldn't use dot notation on parameters
was stuck on that for a while
Ogundele Olumide
@Lumexralph
Jun 19 2017 03:48
@NotTheBest :+1:
cool
Lostboy561
@Lostboy561
Jun 19 2017 03:50
i just looked upi the code @JonathonLLopez
there is an easy solution but i don't know how it works now lol i got how splice worked up now lol great can finish but never a good thing to move on and not know how something happens
return str.substring(str.length - target.length) === target;
Jonathon Lopez
@JonathonLLopez
Jun 19 2017 03:51
@Lostboy561 yeah I agree. I'm still trying to work this one out
Andrea Mammoliti
@AndreusSH
Jun 19 2017 03:52
Hi the challenge asks to look for palindromes, including special characters and punctuation

Check for Palindromes

Return true if the given string is a palindrome. Otherwise, return false.

A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.

Note
You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything lower case in order to check for palindromes.

We'll pass strings with varying formats, such as "racecar", "RaceCar", and "race CAR" among others.

We'll also pass strings with special symbols, such as "2A33a2", "2A3 3a2", and "2_A33#A2".

Remember to use Read-Search-Ask if you get stuck. Write your own code.

any hint about how to get ride of punctuation, spaces and special characters all together?
Lostboy561
@Lostboy561
Jun 19 2017 03:53
ya your doing to have to use Reg words to finish that challenge
I had to look up how and what expression would get rid of the special characters
Andrea Mammoliti
@AndreusSH
Jun 19 2017 03:55

@Lostboy561 function palindrome(str) {
// Good luck!
if (str === str.split('').reverse().join('')) {
return true;

}

else if (str === str.split('').reverse().join('').replace(/[\W]\s/gi,'_')) {
return true;
}

else {
return false;
}

}

palindrome("eye");

Lostboy561
@Lostboy561
Jun 19 2017 03:56
one minute
@JonathonLLopez good website
return str.substring(str.length - target.length) === target;
@AndreusSH
do you just want the website it explains all of it better then I could
Andrea Mammoliti
@AndreusSH
Jun 19 2017 03:59
@Lostboy561 thanks a lot then
CamperBot
@camperbot
Jun 19 2017 03:59
andreussh sends brownie points to @lostboy561 :sparkles: :thumbsup: :sparkles:
:warning: @lostboy561's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Lostboy561
@Lostboy561
Jun 19 2017 04:01
@JonathonLLopez hey i am wondering about this substring thing man
str.length == 21 but target.length == 4, lol how does that return the last character
M-C-Haker
@M-C-Haker
Jun 19 2017 04:02
can someone tell me how to to return just the first number of an array? (stand in line) i have the other part, but the notation for finding the first letter in a string isn't helping
Lostboy561
@Lostboy561
Jun 19 2017 04:02
str.split(' ') will split the string then return str[0]; first character of it
that should work
M-C-Haker
@M-C-Haker
Jun 19 2017 04:03
seems a little more advanced than where i'm at in the cirriculum I'm thinking it should be more vanilla than that..?
Lostboy561
@Lostboy561
Jun 19 2017 04:04
str[0]
array[0] // means the first position in the array
you said the number is the first character
Jonathon Lopez
@JonathonLLopez
Jun 19 2017 04:05
@Lostboy561 So I think what's happening is it's returning a new string, and not necessarily the length of the string. So it's take the string, and removing the target from the string, and then comparing the substr() to target
M-C-Haker
@M-C-Haker
Jun 19 2017 04:06
sure, i don't doubt that, i'm just saying i haven't seen anything that advanced so far and i think there's a different solution they're looking for. for example here's the code:

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

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

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

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

instructions: Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed
Roxroy
@roxroy
Jun 19 2017 04:07
@M-C-Haker , did the solution pass all the test?
M-C-Haker
@M-C-Haker
Jun 19 2017 04:07
So i have the part that adds the number to the end of the array and removes the first number to the end of the array, but i'm not sure how to return the element that was removed
@roxroy no it didn't
Roxroy
@roxroy
Jun 19 2017 04:08
@M-C-Haker , don't think you need the first testArr.shift();, Keep the second one.
Lostboy561
@Lostboy561
Jun 19 2017 04:08
just return test array
return testArray
you already shfited it
@JonathonLLopez i am gonig to look over this websit
M-C-Haker
@M-C-Haker
Jun 19 2017 04:09
got TypeError: testArr is not a function
Lostboy561
@Lostboy561
Jun 19 2017 04:11
arent you suppose to drop the first item and add an item to the last
Roxroy
@roxroy
Jun 19 2017 04:11
@M-C-Haker , remove the second line should not give that error. Can you post you code
Lostboy561
@Lostboy561
Jun 19 2017 04:12
@JonathonLLopez hey man i see what your saying
just the numbers don't add up 21-4
M-C-Haker
@M-C-Haker
Jun 19 2017 04:12

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

return item; // Change this line
}

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

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

that's what i have currently
Lostboy561
@Lostboy561
Jun 19 2017 04:13
i think it is just testArr.push; testArr.shift(), return testArr;
doesn't that not work lol
i am a newbie too
Roxroy
@roxroy
Jun 19 2017 04:14
@M-C-Haker , go back to the original code, that you first posted, ( prior to my response) then make the changes I had suggested.
Ogundele Olumide
@Lumexralph
Jun 19 2017 04:15
@M-C-Haker testArr should be the arr parameter
@M-C-Haker you don't need to pass argument to the shift array method
M-C-Haker
@M-C-Haker
Jun 19 2017 04:16

@roxroy that only gets me 3 out of the 4 `
function nextInLine(arr, item) {
testArr.push(item);

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

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

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

Ogundele Olumide
@Lumexralph
Jun 19 2017 04:17
@M-C-Haker remember shift removes the first element in an array? you need to return the removed element in your function
Roxroy
@roxroy
Jun 19 2017 04:17
@M-C-Haker, change testArr to arr in function nextInLine
Ogundele Olumide
@Lumexralph
Jun 19 2017 04:18
@M-C-Haker arr.push(item); same for the next line using shift
M-C-Haker
@M-C-Haker
Jun 19 2017 04:18
@Lumexralph that's what i had originally,
Ogundele Olumide
@Lumexralph
Jun 19 2017 04:19
@M-C-Haker what @roxroy was saying is correct
Roxroy
@roxroy
Jun 19 2017 04:19
@M-C-Haker , since you are passing in testArr as arr, you use arr within the function. arr will then be local to the function.
Run the test and let me know the results.
Ogundele Olumide
@Lumexralph
Jun 19 2017 04:19
@M-C-Haker apply his suggestions
caliph
@mirzamohid
Jun 19 2017 04:19
@M-C-Haker you should not change this line:console.log(nextInLine([2], 1)); // Modify this line to test
M-C-Haker
@M-C-Haker
Jun 19 2017 04:20
@mirzamohid you can if you want, that's how to see different results it'll pass for any of the arguments if you have the right code, that's why it says modify
Ogundele Olumide
@Lumexralph
Jun 19 2017 04:20
@M-C-Haker your last code is okay, just change where testArr exists to arr and you're done
Lostboy561
@Lostboy561
Jun 19 2017 04:20
@JonathonLLopez hey man figured it out
Roxroy
@roxroy
Jun 19 2017 04:20
@M-C-Haker , post the code if you still have problem or have question on it
Lostboy561
@Lostboy561
Jun 19 2017 04:22
@JonathonLLopez so the length of the string is 21, but buy turning the (target.length) to negative it goes to the last character backwards so in the word "name" it will count down 21,20,19,18 and check that name === name
M-C-Haker
@M-C-Haker
Jun 19 2017 04:25
@roxroy changing test arr to arr did let me accomplish thanks @Lumexralph . Looks like i was using the shift twice, which was unnecessary? Thanks for the help again
CamperBot
@camperbot
Jun 19 2017 04:25
m-c-haker sends brownie points to @roxroy and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 994 | @roxroy |http://www.freecodecamp.com/roxroy
:star2: 1962 | @lumexralph |http://www.freecodecamp.com/lumexralph
Sumit Kumar
@numa251
Jun 19 2017 04:26

var count = 0;

function cc(card) {
// Only change code below this line
if(card == 2 || card == 3 || card == 4 || card == 5 || card == 6) {
count+=1;
return count +" Bet";
}

else if(card == 7 || card == 8 || card == 9) {
        count+=0;
return count + " Hold";
}

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

}

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

Please help
caliph
@mirzamohid
Jun 19 2017 04:30
@numa251 please be noted that the player's decision : "Bet" or "Hold" refers to updated count
which means if the count is positive : "Bet" , if the count is 0 or less : "Hold"
i think you should do another one if/else statement for updated count
sorry, you should do another one for "Bet" and "Hold"
Adam Ayd
@adamayd
Jun 19 2017 04:34
Hey everyone, I'm working on the Weather App challenge and I am racking my brains on how to hide the Dark Sky API key. Does anyone have any ideas on this?
caliph
@mirzamohid
Jun 19 2017 04:35
@numa251 figured out?
Roxroy
@roxroy
Jun 19 2017 04:35
@decaren , are you using codePen? If so then it is not possible. But don't sweat about it.
Adam Ayd
@adamayd
Jun 19 2017 04:36
Yes I am using codepen. Is this a major concern going forward?
Ogundele Olumide
@Lumexralph
Jun 19 2017 04:37
@numa251 firstly for case 7,8,9 you can eliminate that cos it's not doing anything, secondly use your conditional statement checking card to only decrement or increment count. then use a condition statement to later check if count is positive i.e > 0 or not to return count + string(Bet or Hold)
@decaren how to hide the key?
@decaren the key in the url?
Adam Ayd
@adamayd
Jun 19 2017 04:39
Yes, I'm trying to figure it out. Yes the Dark Sky API Docs said not to put the key in the url but I don't know how to hide it.
Roxroy
@roxroy
Jun 19 2017 04:42
@decaren , it won't work if you hide it. You would have to deploy to a server and pass it as an environment variable so that it is hidden. But don't sweat about it and move on to the other challenges.
Adam Ayd
@adamayd
Jun 19 2017 04:43
Ok, Thanks @roxroy
CamperBot
@camperbot
Jun 19 2017 04:43
decaren sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:cookie: 997 | @roxroy |http://www.freecodecamp.com/roxroy
Lostboy561
@Lostboy561
Jun 19 2017 04:43
hey is there some thing that you can down load to write java script in to mess around
Roxroy
@roxroy
Jun 19 2017 04:47
@Lostboy561 , there is a chrome plug, https://github.com/richgilbank/Scratch-JS that can help with that. Also, Firefox has a scratch pad that does the same thing.
Jonathon Lopez
@JonathonLLopez
Jun 19 2017 04:53
@Lostboy561 Gotcha. That makes a lot of sense. We were on the right track
Joseph
@revisualize
Jun 19 2017 04:58

Can I get some feedback on this text????

..

Accessing values in Objects.
Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings.
If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];

There are a few other limitations when accessing an object property. If the object key has a space or number in it, you cannot use dot notation.

var myObj = {
      "key one": "Value for 'key one'",
      "key": "Value for 'key'",
      "method property": "Method Property would be a function",
      "1": "Value for 'key 1'",
      "2": "Value for 'key 2'"
   };

For ease of explination, I'm just returning strings for my object property values. The object property keys have a few different aspects to them, a couple with spaces and a couple as numbers.

When you use dot notation to access:
myObj.key one; The object value returned will be a string: "Value for 'key'"
Whereas, when you use bracket notation and access an object property key:
myObj["key one"]; The object value returned will be a string "Value for 'key one'".
If you try to use dot notation to access an object property with a space in it that doesn't have an additional corrosponding shorter object property key. (Like I did with "key one" and "key")
You'll get the error: Uncaught SyntaxError: Unexpected identifier or SyntaxError: Unexpected token, expected ;
If you attempt to just do myObj.method; you will get back the value undefined
Additionally, if you were to access a number with dot notation:
myObj.1; .. You will get an error: Uncaught SyntaxError: Unexpected number or you may get SyntaxError: Unexpected token, expected ;
If you want to access an object property with a number as the object key you will be required to use Bracket Notation:
myObj["1"]; and you will get the object property value of "Value for 'key 1'".

CallMeOrange
@EgnaroDev
Jun 19 2017 04:58
@revisualize :wave:
So you are still keeping up with good notes
Lostboy561
@Lostboy561
Jun 19 2017 05:00
anyone done this string turnicate problem yet
Mario Ley Tello
@23marioley
Jun 19 2017 05:16

function palindrome(str) {
  // Good luck!
  str = str.toLowerCase();
  str = str.replace(/\s+/g, '');
  var array2 = str.split(''); //[str.split('')]
  var array3 = array2.reverse().join('');

  return str == array3;

}



palindrome("eye");
How can I check for non/alphanumerical characters to replace them ?
jimingeorge
@jimingeorge
Jun 19 2017 05:18
can somebody help me out with this exercise"https://www.freecodecamp.com/challenges/word-blanks" . I am not able to understand how to begin or how to do it. Even an example would do.
abraham anak agung
@padunk
Jun 19 2017 05:20
@jimingeorge just return a sentence with all the words text + myNoun + text + ....etc
Roxroy
@roxroy
Jun 19 2017 05:20
@jimingeorge , you will need to add a blank word between each of the words that is passed in.
Note that the word must have a space before and after it, eg ' blue ' but not 'blue' the first one has the spaces.
Sunny Wong
@swong194
Jun 19 2017 05:21
@jimingeorge hey i think you need to make a sentence eg. the big dog ran quickly with the given strings
jimingeorge
@jimingeorge
Jun 19 2017 05:23
thanks @swong194 @roxroy @padunk will try it
CamperBot
@camperbot
Jun 19 2017 05:23
jimingeorge sends brownie points to @swong194 and @roxroy and @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 280 | @swong194 |http://www.freecodecamp.com/swong194
:cookie: 345 | @padunk |http://www.freecodecamp.com/padunk
:star2: 1002 | @roxroy |http://www.freecodecamp.com/roxroy
CallMeOrange
@EgnaroDev
Jun 19 2017 05:23
@roxroy congrats reaching 1k
Mario Ley Tello
@23marioley
Jun 19 2017 05:26
what are the cookies and stars for?
WAINGOR
@WAINGOR
Jun 19 2017 05:27
Hi all, I am @ intermediate algo challenges... Somehow FCC says my code returns a 3dimensional array, but my browser devtools says it does not! (it logs a 2d array!) My code:
function pairElement(str) {


  var savePairs = [["A","T"],["C","G"]];

  var splitString = str.split('');
console.log(splitString);
  var containLetter = [];
  var X = 0;
  var X1 = 0;
  var Y = function(element, index) {
          if (element != splitString[j]) {console.log(element+ ' komt erdoorheen');}
      return element != splitString[j];
  };
  var Z = [];
  var A = [];

  for (var i=0; i<savePairs.length; i++) {
      for (var j=0; j<splitString.length; j++) {
          X=i;
          X1=j;
          if(savePairs[i].indexOf(splitString[j])>-1) {
              containLetter = savePairs[i].filter(Y);

//               console.log(containLetter);
//               stop de andere letter binnen de array waar letter in voorkomt in containLetter
              containLetter = containLetter.join('');
//               console.log(containLetter);
              Z.push(splitString[j]);
              Z.push(containLetter);
              A.push([Z]);
            Z=[];
            console.log('dit is '+A);

          }
      }
  }

console.log(A);
return A;
}
pairElement("ATCGA")
Aniculaesei
@Aniculaesei
Jun 19 2017 05:27
@roxroy thank you man
CamperBot
@camperbot
Jun 19 2017 05:27
aniculaesei sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:star2: 1003 | @roxroy |http://www.freecodecamp.com/roxroy
Aniculaesei
@Aniculaesei
Jun 19 2017 05:28
Hello Guys!Can someone tell me how I can take the wether app icons from here?Thank you:http://darkskyapp.github.io/skycons/
abraham anak agung
@padunk
Jun 19 2017 05:29
@WAINGOR you know you could solve the problem with just simple switch method?
Maks Ushakov
@maks-ushakov
Jun 19 2017 05:32
@Aniculaesei Hello. It is not "real" icons, they will be rendered from script
Mario Ley Tello
@23marioley
Jun 19 2017 05:34
function palindrome(str) {
  // Good luck!
  str = str.toLowerCase();
  str = str.replace(/\s+/g, '');
  var array2 = str.split(''); //[str.split('')]
  var array3 = array2.reverse().join('');

  return str == array3;

}



palindrome("eye");
How can I check for non-alphanumerical characters to replace them ?
Aniculaesei
@Aniculaesei
Jun 19 2017 05:37
@maks-ushakov thank you..but how I can use them?
CamperBot
@camperbot
Jun 19 2017 05:37
aniculaesei sends brownie points to @maks-ushakov :sparkles: :thumbsup: :sparkles:
:cookie: 357 | @maks-ushakov |http://www.freecodecamp.com/maks-ushakov
Maks Ushakov
@maks-ushakov
Jun 19 2017 05:39
@Aniculaesei Do you see script under "icons"?
<canvas id="icon1" width="128" height="128"></canvas>
<canvas id="icon2" width="128" height="128"></canvas>

<script>
  var skycons = new Skycons({"color": "pink"});
  // on Android, a nasty hack is needed: {"resizeClear": true}

  // you can add a canvas by it's ID...
  skycons.add("icon1", Skycons.PARTLY_CLOUDY_DAY);
* * *
Adam Ayd
@adamayd
Jun 19 2017 05:40
Alright guys I'm back. Now I'm struggling with the Dark Sky API quietly failing. Anyone else experience that??
WAINGOR
@WAINGOR
Jun 19 2017 05:43
@padunk nope.... could you send it to me ? :)
abraham anak agung
@padunk
Jun 19 2017 05:44
@WAINGOR no :smile: it is a simple solution, you know switch method right? so you just need to figure out if A you need to do.... and if T ..... etc
CallMeOrange
@EgnaroDev
Jun 19 2017 05:46
@padunk hey can you help me? this has nothing to do with JS
abraham anak agung
@padunk
Jun 19 2017 05:46
@MCTwoDigitZero perhaps
CallMeOrange
@EgnaroDev
Jun 19 2017 05:48
@padunk take a look at my pen first
Just stay in full page mode
Tell me what happen to oval shape image when you hit home
The title portfolio with home, about etc is a navbar
abraham anak agung
@padunk
Jun 19 2017 05:50
nothing happen with oval shape image, it just roll up a little bit when i hit home
CallMeOrange
@EgnaroDev
Jun 19 2017 05:51
yeah that
it roll up right?
So Here is a question
How do I get image to stay below navbar when I hit home?
Like when it roll up it go past navbar
are you able to help with that?
abraham anak agung
@padunk
Jun 19 2017 05:53
put your home id on the div. not on the image
CallMeOrange
@EgnaroDev
Jun 19 2017 05:53
I have tried that before
Nothing happen if I hit home
hold on... I need to kill a bug
abraham anak agung
@padunk
Jun 19 2017 05:54
yes because you already home. what u expect?
CallMeOrange
@EgnaroDev
Jun 19 2017 05:55
What do you mean? you hit home and image move up right?
But image went past navbar how do I avoid that?
Nitin
@thenm
Jun 19 2017 05:55
var say = function() { console.log(hello); }
Ctrl-Altz
@Ctrl-Altz
Jun 19 2017 05:56
everytime i add a button it just is basic not the one i choose
i.e i used <button type="button" class="btn btn-success">Success</button>
Nitin
@thenm
Jun 19 2017 05:56
What is difference between
var say = function() { console.log(hello); } AND
function say() {console.log(hello); }
Ctrl-Altz
@Ctrl-Altz
Jun 19 2017 05:56
but on the html page its just baic
CallMeOrange
@EgnaroDev
Jun 19 2017 05:57
@thenm variable just store these value and that is an function
abraham anak agung
@padunk
Jun 19 2017 05:57
@MCTwoDigitZero as i told you before put your id='home' in your div not in your <img ..../>
CallMeOrange
@EgnaroDev
Jun 19 2017 05:57
@padunk I already told you that I have tried it
And didnt work for me
abraham anak agung
@padunk
Jun 19 2017 05:58
it work here
CallMeOrange
@EgnaroDev
Jun 19 2017 05:58
Wow it actually work
Sorry..
I think I might have stored both id in different elements
thanks @padunk
CamperBot
@camperbot
Jun 19 2017 05:58
mctwodigitzero sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 346 | @padunk |http://www.freecodecamp.com/padunk
Nitin
@thenm
Jun 19 2017 05:58
@MCTwoDigitZero but what is the use of it?
abraham anak agung
@padunk
Jun 19 2017 05:59
u welcome
CallMeOrange
@EgnaroDev
Jun 19 2017 05:59
@thenm well without variable you can do whatever in that function block but I dont know much about variable
You would have to use variable to use function
Mario Ley Tello
@23marioley
Jun 19 2017 05:59
function palindrome(str) {
  // Good luck!
  str = str.toLowerCase();
  str = str.replace(/\s+/g, '');
  str = str.replace(/\W+/g, '');
  str = str.replace(/[_]/g, '');
  var array2 = str.split(''); //[str.split('')]
  var array3 = array2.reverse().join('');

  return str == array3;

}



palindrome("0_0 (: /-\ :) 0-0");
CallMeOrange
@EgnaroDev
Jun 19 2017 06:00
I think you should ask someone who is good at JS but I dont think no one store function in a variable
Mario Ley Tello
@23marioley
Jun 19 2017 06:00
Hey pals, is there anyway to make more efficient my code?
CallMeOrange
@EgnaroDev
Jun 19 2017 06:00
@padunk you know 2-3 persons before you tried to help me
Nitin
@thenm
Jun 19 2017 06:00
@MCTwoDigitZero not clear anyway thanks
CamperBot
@camperbot
Jun 19 2017 06:00
thenm sends brownie points to @mctwodigitzero :sparkles: :thumbsup: :sparkles:
:cookie: 171 | @mctwodigitzero |http://www.freecodecamp.com/mctwodigitzero
CallMeOrange
@EgnaroDev
Jun 19 2017 06:00
It was pretty hard to explain but Im glad you understood
Nitin
@thenm
Jun 19 2017 06:01
No i still have doubt please somone explain:
What is difference between
var say = function() { console.log(hello); } AND
function say() {console.log(hello); }??
Why we use such ways to declare a function?
CallMeOrange
@EgnaroDev
Jun 19 2017 06:02
@thenm I was not talking to you xD
Why do you need function stored in variable?
Nitin
@thenm
Jun 19 2017 06:03
@MCTwoDigitZero Oops but my question is still around
Yes
CallMeOrange
@EgnaroDev
Jun 19 2017 06:03
I see
Look like there isn't anyone around to answer that question
Roxroy
@roxroy
Jun 19 2017 06:04
@MCTwoDigitZero and @thenm , one is a Function Declarations and the other a Function Expressions . A function declaration and is defined as soon as its surrounding function or script is executed. See the full explanation , https://javascriptweblog.wordpress.com/2010/07/06/function-declarations-vs-function-expressions/ here.
CallMeOrange
@EgnaroDev
Jun 19 2017 06:04
@thenm ask alexanderkopke in help room
Never mind
Markus Ivancsics
@ivancsicsmarkus
Jun 19 2017 06:05
@23marioley You could use less regex statements
@23marioley
function palindrome(str) {
  str = str.replace(/[\W_]/g,'').toLowerCase();
  var array = str.split('').reverse().join('');
  if (str === array) return true;
  else return false;
}

palindrome("eye");
Maa Poe Ei Phyu
@mapoeeiphyu20
Jun 19 2017 06:05
can anyone explain me?
convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86
Nitin
@thenm
Jun 19 2017 06:06
@roxroy Ok reading
Markus Ivancsics
@ivancsicsmarkus
Jun 19 2017 06:06
@mapoeeiphyu20 Your function should return the input celsius value times 9/5 plus 32.
Andrew Millar
@Sl4rtyb4rtf4st
Jun 19 2017 06:09
@23marioley you can combine all those regexes with a pipe "|", In regex that is a sort of "or"
this:
str = str.replace(/\s+/g, '');
str = str.replace(/\W+/g, '');
str = str.replace(/[]/g, '');
can become this:
str = str.replace(/\s+|W+|[
]/g, "")
Maa Poe Ei Phyu
@mapoeeiphyu20
Jun 19 2017 06:11
@ivancsicsmarkus i got it.Thank u
CamperBot
@camperbot
Jun 19 2017 06:11
mapoeeiphyu20 sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:cookie: 626 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
Andrew Millar
@Sl4rtyb4rtf4st
Jun 19 2017 06:13
Fprgot the "`"'s
str = str.replace(/\s+/g, '');
str = str.replace(/\W+/g, '');
str = str.replace(/[]/g, '');
can become this:
str = str.replace(/\s+|W+|[]/g, "")
Manrique
@Manriqu3
Jun 19 2017 06:13
could someone explain the Assignment called Stand in Line to me in a different way im not sure if its asking me to add the var queue or to use .shift or what
Andrew Millar
@Sl4rtyb4rtf4st
Jun 19 2017 06:14
Hi people, first time back on gitter again after day 1. I'm stuck with an challenge number 251, one of the algorithm challenges. It's the challenge where you have to check for falsy items in an array. I loop though the array and check every item if it is !item. If it is I splice that item. But the loop, for some reason is skipping over the explicitly "false" item, I don't get it.
for (var i=0; i<arr.length; i++) {
    if(!arr[i]){
      console.log(arr[i]);
      arr.splice(i,1);
    }
  }
Dima Doulov
@dimadoulov
Jun 19 2017 06:15
Whats the difference between getting and setting gear in the 'Make Object Properties Private' lesson?
Joseph
@revisualize
Jun 19 2017 06:19
@dimadoulov Getting the gear ... returns the gear variable.
abraham anak agung
@padunk
Jun 19 2017 06:19
@Sl4rtyb4rtf4st splice will change your array, that is why it skip
Andrew Millar
@Sl4rtyb4rtf4st
Jun 19 2017 06:19
Fuck I get it how stupid, if I remove an item from the array then the for loop, looping of the array items, doesn't work anymore. Man what a noob error...
Joseph
@revisualize
Jun 19 2017 06:19
@dimadoulov Setting the gear ... changes the gear variable.
Andrew Millar
@Sl4rtyb4rtf4st
Jun 19 2017 06:20
@padunk yeah thanks, while looking at the code again it clicked again and I saw my mistake...
CamperBot
@camperbot
Jun 19 2017 06:20
sl4rtyb4rtf4st sends brownie points to @padunk :sparkles: :thumbsup: :sparkles:
:cookie: 347 | @padunk |http://www.freecodecamp.com/padunk
mitron6
@mitron6
Jun 19 2017 06:20
@Sl4rtyb4rtf4st if you modify the array in the middle of the loop your index will be wrong. Consider using array.filter
Maa Poe Ei Phyu
@mapoeeiphyu20
Jun 19 2017 06:23
can anyone explain this?
You should have two single quotes ' and four double quotes "
Only remove the backslashes \ used to escape quotes.
jimingeorge
@jimingeorge
Jun 19 2017 06:26
Guys , i need your help in this "https://www.freecodecamp.com/challenges/word-blanks"

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
var wordBlanks = "The "+ myNoun +"which is"+ myAdjective +"kinda"+ myVerb +"u know"+ myAdverb + "got that";

// Your code above this line
return result;
}

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

what am i doing wrong?
abraham anak agung
@padunk
Jun 19 2017 06:27
@jimingeorge you don't need to assign new variable wordBlanks. just assign it to result. and you will need to add space between word
Roxroy
@roxroy
Jun 19 2017 06:28
@jimingeorge , you will need to add a space before each of the words you added, eg "which is" would be " which is ", note the spaces that I added
Nitin
@thenm
Jun 19 2017 06:33
@roxroy Thanks now I get the difference between function expression and function declaration
CamperBot
@camperbot
Jun 19 2017 06:33
thenm sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:star2: 1008 | @roxroy |http://www.freecodecamp.com/roxroy
jimingeorge
@jimingeorge
Jun 19 2017 06:33
@padunk @roxroy thnx guys . Finally got it right.
CamperBot
@camperbot
Jun 19 2017 06:33
jimingeorge sends brownie points to @padunk and @roxroy :sparkles: :thumbsup: :sparkles:
:star2: 1009 | @roxroy |http://www.freecodecamp.com/roxroy
:cookie: 348 | @padunk |http://www.freecodecamp.com/padunk
Roxroy
@roxroy
Jun 19 2017 06:34
@jimingeorge , @thenm , glad to have helped. Take care. I will catch you next time.
rugano
@rugano
Jun 19 2017 06:35
Hello campers,can someone tell me why my tic tac toe game isn't working ?here: https://codepen.io/Njue/full/NgbxBa
lazzlo
@lazzlo
Jun 19 2017 06:38
@rugano Try removing hide in line 38: TICAPP.display.hide.hideGameChoice();
Roxroy
@roxroy
Jun 19 2017 06:38
@rugano , there is an error, that is prevent it from runnng. Uncaught TypeError: Cannot read property 'hideGameChoice' of undefined.
Sairam jalakam Devarajulu
@jalakamsairam
Jun 19 2017 06:39
hello
can any one help me with golf code
i am finding difficulty in solving few test cases
:(
lazzlo
@lazzlo
Jun 19 2017 06:41
@jalakamsairam Type your code and what exactly you need help with, otherwise we can't help you
Valdovas1
@Valdovas1
Jun 19 2017 06:41

Hello guys !

Could any of you assist me on this assignment ?

function mutation(arr) {
var loop = arr;
if (loop.indexOf('h') < 1)
{ return false;
}
else if (loop.indexOf('h') > 1)
{
return true;
}

}

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

I always get false
Sairam jalakam Devarajulu
@jalakamsairam
Jun 19 2017 06:41

function golfScore(par, strokes) {
// Only change code below this line
if(strokes >= par+3){
return ("Go Home!");
}else if (strokes == par+2){
return ("Double bogey");

}else if(strokes == par+1){
return ("Bogey");
}else if(strokes == par){
return ("par");
}else if(strokes == par-1){
return("Birdie");
}else if(strokes <= par-2){
return("Eagle");
}else if(strokes == 1 && par === ""){
return("Hole-in-one!");
}else{

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

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

i am unable to solve these test cases
lazzlo
@lazzlo
Jun 19 2017 06:42
@jalakamsairam @Valdovas1 Guys remember to surround your code with ``` so we can see it better
Valdovas1
@Valdovas1
Jun 19 2017 06:42

''function mutation(arr) {
var loop = arr;
if (loop.indexOf('h') < 1)
{ return false;
}
else if (loop.indexOf('h') > 1)
{
return true;
}

}

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

`function mutation(arr) {
var loop = arr;
if (loop.indexOf('h') < 1)
{ return false;
}
else if (loop.indexOf('h') > 1)
{
return true;
}

}

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

```function mutation(arr) {
var loop = arr;
if (loop.indexOf('h') < 1)
{ return false;
}
else if (loop.indexOf('h') > 1)
{
return true;
}

}

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

lazzlo
@lazzlo
Jun 19 2017 06:42
Like this:
function mutation(arr) {
var loop = arr;
if (loop.indexOf('h') < 1)
{ return false;
}
else if (loop.indexOf('h') > 1)
{
return true;
}
}
mutation(["hello", "hey"]);
Valdovas1
@Valdovas1
Jun 19 2017 06:42
how did you did it ?
@Lazzlo
lazzlo
@lazzlo
Jun 19 2017 06:43
Type three ```, then enter, then type your code, then enter, then three more ````
Valdovas1
@Valdovas1
Jun 19 2017 06:44
function mutation(arr) {
var loop = arr;
if (loop.indexOf('h') < 1)
 { return false;
 }
  else if (loop.indexOf('h') > 1)
    {
      return true;
    }


}

mutation(["hello", "hey"]);
```
Noice!
Sairam jalakam Devarajulu
@jalakamsairam
Jun 19 2017 06:45

'''
function golfScore(par, strokes) {
// Only change code below this line
if(strokes >= par+3){
return ("Go Home!");
}else if (strokes == par+2){
return ("Double bogey");

}else if(strokes == par+1){
return ("Bogey");
}else if(strokes == par){
return ("par");
}else if(strokes == par-1){
return("Birdie");
}else if(strokes <= par-2){
return("Eagle");
}else if(strokes == 1 && par === ""){
return("Hole-in-one!");
}else{

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

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

CamperBot
@camperbot
Jun 19 2017 06:45
:bulb: to format code use backticks! ``` more info
Sairam jalakam Devarajulu
@jalakamsairam
Jun 19 2017 06:46

function golfScore(par, strokes) {
  // Only change code below this line
  if(strokes >= par+3){
    return ("Go Home!");
  }else if (strokes == par+2){
    return ("Double bogey");

  }else if(strokes == par+1){
    return ("Bogey");
  }else if(strokes == par){
    return ("par");
  }else if(strokes == par-1){
    return("Birdie");
  }else if(strokes <= par-2){
     return("Eagle");
  }else if(strokes == 1 && par === ""){
    return("Hole-in-one!");
  }else{

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

// Change these values to test
golfScore(5, 4);
Valdovas1
@Valdovas1
Jun 19 2017 06:46

Anyone could assist me on this of why it might not work ?

```

function mutation(arr) {
var loop = arr;
if (loop.indexOf('h') < 1)
{ return false;
}
else if (loop.indexOf('h') > 1)
{
return true;
}

}

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


function mutation(arr) {
var loop = arr;
if (loop.indexOf('h') < 1)
 { return false;
 }
  else if (loop.indexOf('h') > 1)
    {
      return true;
    }


}

mutation(["hello", "hey"]);
```
Sairam jalakam Devarajulu
@jalakamsairam
Jun 19 2017 06:47
use ` instead '''
CamperBot
@camperbot
Jun 19 2017 06:47
:bulb: to format code use backticks! ``` more info
Sairam jalakam Devarajulu
@jalakamsairam
Jun 19 2017 06:47
you can press cmd + cntrl + enter for help
markdown help
lazzlo
@lazzlo
Jun 19 2017 06:47
@Valdovas1 You're comparing the words hello and hey to the letter h. That's why you get false, because they're not equal
Valdovas1
@Valdovas1
Jun 19 2017 06:48
@Lazzlo then why it is not solving the whole assignment correct ?
@Valdovas1
lazzlo
@lazzlo
Jun 19 2017 06:49
@Valdovas1 Because you're only comparing one letter. You need to check if all the letters in the first word is in the second word
daisyzhang0225
@daisyzhang0225
Jun 19 2017 06:50

function nextInLine(arr, item) {
// Your code here
testArr.push(item);
return testArr.shift(); // Change this line
}

// Test Setup
var testArr = [5,6,7,8,9];

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

nextInLine([5,6,7,8,9], 1) should return 5
Valdovas1
@Valdovas1
Jun 19 2017 06:51
so instead of checking one letter I should put 1 word in indexOf('Hey')
@Lazzlo
?
Sairam jalakam Devarajulu
@jalakamsairam
Jun 19 2017 06:51
those are test cases
Valdovas1
@Valdovas1
Jun 19 2017 06:51
@jalakamsairam Thank you
CamperBot
@camperbot
Jun 19 2017 06:51
valdovas1 sends brownie points to @jalakamsairam :sparkles: :thumbsup: :sparkles:
:cookie: 78 | @jalakamsairam |http://www.freecodecamp.com/jalakamsairam
daisyzhang0225
@daisyzhang0225
Jun 19 2017 06:52
HEY,guys, I am wondering why I can't pass this step, all the codes seems right5 has been returned

@daisyzhang0225
function nextInLine(arr, item) {
// Your code here
testArr.push(item);
return testArr.shift(); // Change this line
}

// Test Setup
var testArr = [5,6,7,8,9];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
nextInLine([5,6,7,8,9], 1) should return 5

lazzlo
@lazzlo
Jun 19 2017 06:52
@Valdovas1 Nope, you are not searching for words. you should search for all the letters in the first word
Valdovas1
@Valdovas1
Jun 19 2017 06:52
Okey okey @Lazzlo how that is done ? Because the indexOf() stops when he reaches first letter ?
lazzlo
@lazzlo
Jun 19 2017 06:54
@Valdovas1 Save all the letters of the first word in an array and check every single one of them against the second word
Lhats0
@stahloliver
Jun 19 2017 06:54
Hi, can anyone help with accessing JS variables?
Sairam jalakam Devarajulu
@jalakamsairam
Jun 19 2017 06:54
@daisyzhang0225 can you please markdown so that i can help you?
lazzlo
@lazzlo
Jun 19 2017 06:54
@stahloliver What do you need help with?
Lhats0
@stahloliver
Jun 19 2017 06:55
@Lazzlo Hi, I am trying to access a global variable created within a function outside the function, but I am still getting "undefined" when I try to console.log it
I think I misunderstood the concept of global variables
Sairam jalakam Devarajulu
@jalakamsairam
Jun 19 2017 06:55
@daisyzhang0225 change testArr to arr. the arr should match with the parameter name you are passing .. it will work then.
@stahloliver variable created within a function is always local to that particular function.
Lhats0
@stahloliver
Jun 19 2017 06:57
@jalakamsairam how do I access it from outside?
lazzlo
@lazzlo
Jun 19 2017 06:57
@stahloliver Declare it from the outside of every function. That's when it's global
Sairam jalakam Devarajulu
@jalakamsairam
Jun 19 2017 06:58
@stahloliver declare it outside the function
Kevin
@kevinwr
Jun 19 2017 06:58

Hey, all.

Question:

when constructing a constructor function/object do you have to do it like this:

var Car = function() {
  this.wheels = 4;
  this.engines = 1;
  this.seats = 5;
};

Or can you just leave out function()?

Also, I have seem some name the function inside, and some just use function() to declare an anonymous function. What is the difference in terms of functionality?

Lhats0
@stahloliver
Jun 19 2017 06:59

yeah. Here's what I do.

var foo = {};

function bar(response) {
     foo.something = response;    
};

bar();
console.log(foo.something);

The response is an empty object

actually, it's "undefined"
when I console log foo I get an empty object
If that is the natural way JS works, how do you use data from API response?
Thomas
@sjurs1
Jun 19 2017 07:01
@forkerino Hehe, the symmetric difference challenge... https://www.freecodecamp.com/challenges/symmetric-difference
lazzlo
@lazzlo
Jun 19 2017 07:03
@stahloliver You are calling bar without an argument
rugano
@rugano
Jun 19 2017 07:03
@Lazzlo thanks,i removed hide but the game only goes to the next step and stops,what should i do?
CamperBot
@camperbot
Jun 19 2017 07:03
rugano sends brownie points to @lazzlo :sparkles: :thumbsup: :sparkles:
:cookie: 4 | @lazzlo |http://www.freecodecamp.com/lazzlo
Lhats0
@stahloliver
Jun 19 2017 07:03
@Lazzlo yeah, sorry, that is just a bad example, I just didn't want to paste my 40 lines to show my problem
lazzlo
@lazzlo
Jun 19 2017 07:04
@stahloliver In your code, bar has an argument?
WAINGOR
@WAINGOR
Jun 19 2017 07:04
Hi all, I still havent found out why FCC says my code returns a 3d array... When I run this code in chrome/firefox I get a 2d array!
code:

function pairElement(str) {


  var savePairs = [["A","T"],["C","G"]];

  var splitString = str.split('');
console.log(splitString);
  var containLetter = [];
  var X = 0;
  var X1 = 0;
  var Y = function(element, index) {
          if (element != splitString[j]) {console.log(element+ ' komt erdoorheen');}
      return element != splitString[j];
  };
  var Z = [];
  var A = [];

  for (var i=0; i<savePairs.length; i++) {
      for (var j=0; j<splitString.length; j++) {
          X=i;
          X1=j;
          if(savePairs[i].indexOf(splitString[j])>-1) {
              containLetter = savePairs[i].filter(Y);

//               console.log(containLetter);
//               stop de andere letter binnen de array waar letter in voorkomt in containLetter
              containLetter = containLetter.join('');
//               console.log(containLetter);
              Z.push(splitString[j]);
              Z.push(containLetter);
              A.push([Z]);
            Z=[];
            console.log('dit is '+A);

          }
      }
  }

console.log(A);
return A;
}
pairElement("ATCGA")
Lhats0
@stahloliver
Jun 19 2017 07:06
@Lazzlo here I simplified my code
var myLocation = {};

function getLocation(){
  $.getJSON("http://ip-api.com/json/", function(data) {
    myLocation.lat = data.lat;
    myLocation.lon = data.lon;
  });
};

console.log(myLocation);
when I console log data.lat from within the function it works
lazzlo
@lazzlo
Jun 19 2017 07:07
try logging myLocation.lat. Does that work?
Lhats0
@stahloliver
Jun 19 2017 07:07
nope, just tried it 5 second ago
Tarun Garhwal
@eoo
Jun 19 2017 07:09
im on the random quote machine project. how would i go about pre-populating the tweet content for the twitter share button
im using an <a> tag for the twiiter button
like this :
<a href="https://twitter.com/intent/tweet" target="_blank">
Calvin
@oakypokey
Jun 19 2017 07:10
@eoo you’d have ot update the href using JS
*Jquery
Tarun Garhwal
@eoo
Jun 19 2017 07:10
yeah but the formatting is really weird
Dan Couper
@DanCouper
Jun 19 2017 07:10
Yeah, the tweet text just goes in as a parameter
lazzlo
@lazzlo
Jun 19 2017 07:10
@WAINGOR I recommend that you sit down with a pen and paper and make an algorithm for this problem before you start typing code. Your code is way more long and convoluted than it needs to be.
Tarun Garhwal
@eoo
Jun 19 2017 07:10
lots of %20 etc
Dan Couper
@DanCouper
Jun 19 2017 07:11
@eeo encodeURIComponent(myText)
Calvin
@oakypokey
Jun 19 2017 07:11
^wish i’d know that
lazzlo
@lazzlo
Jun 19 2017 07:11
@stahloliver Have you called getLocation yet? Stupid question maybe
Lhats0
@stahloliver
Jun 19 2017 07:12
@eoo just dealt with the same thing. This works perfectly
twitterShare.onclick = function() {
    var twitterWindow =      
window.open('https://twitter.com/share?text=' + whateverYourTweetIs, 'twitter-popup', 'height=350,width=600');
rugano
@rugano
Jun 19 2017 07:12
@Lazzlo still stuck,the game only goes to second step and stops,what could be the cause?
Tarun Garhwal
@eoo
Jun 19 2017 07:12
@DanCouper whoa that makes thins easier hanks
@stahloliver do i need to add some API for that to work?
Dan Couper
@DanCouper
Jun 19 2017 07:12
@oakypokey @eoo I think Twitter should automatically do it backend anyway - what @stahloliver posted should just work
lazzlo
@lazzlo
Jun 19 2017 07:12
@stahloliver It's hard for me to say more precisely without seeing more code. You can DM me your codepen if you want me to look at it
rugano
@rugano
Jun 19 2017 07:12
@DanCouper hi,
Calvin
@oakypokey
Jun 19 2017 07:13
@DanCouper I think the %20 is for the spaces though
lazzlo
@lazzlo
Jun 19 2017 07:13
@rugano I have no idea dude. Try console logging different stuff and see why you can't move on. Part of coding is to figure out why stuff is not working
Lhats0
@stahloliver
Jun 19 2017 07:14
@eoo Yeah this goes before your script in html
    <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
Valdovas1
@Valdovas1
Jun 19 2017 07:15
@Lazzlo How do you maketwo different words compare to each other with one arr ? should i create second argument ?
lazzlo
@lazzlo
Jun 19 2017 07:16
@Valdovas1 Split all the letters in one word into an array and loop through them with a for loop
Tarun Garhwal
@eoo
Jun 19 2017 07:16
@stahloliver okay thanks mate lemme play around with it
CamperBot
@camperbot
Jun 19 2017 07:16
eoo sends brownie points to @stahloliver :sparkles: :thumbsup: :sparkles:
:cookie: 264 | @stahloliver |http://www.freecodecamp.com/stahloliver
Lhats0
@stahloliver
Jun 19 2017 07:16
@eoo np. Took me a week of fiddling to get it right
Tarun Garhwal
@eoo
Jun 19 2017 07:19
@stahloliver haha same, things seem hard when just starting out. i guess it would be a matter of seconds for a seasoned programmer
Dan Couper
@DanCouper
Jun 19 2017 07:19
@oakypokey yup, it is, but Twitter should deal with that. encodeURIComponent will do it for you though: it's designed to sanitise strings that need to go into URIs. If you want to go the other way, you use decodeURIComponent - like if you use it on the url of one of your FCC challenges, you can see all of the code you've written for the challenge
Lhats0
@stahloliver
Jun 19 2017 07:22
@eoo Yeah dude, carry on, I made that work, and it felt great. Fingers crossed
Tarun Garhwal
@eoo
Jun 19 2017 07:23
yup it feels great when things fall into place, like "aha!"
@DanCouper encodeURIComponent seems like a better choice since i do not need to import any APis
Dan Couper
@DanCouper
Jun 19 2017 07:24
@kevinwr you can't leave out the function keyword because what that is (a constructor) is literally just a function that makes an object. However to make things simpler and more consistent, the class keyword was added to the language
Valdovas1
@Valdovas1
Jun 19 2017 07:25
@Lazzlo So i should make it in one word and try to find letters that doubles ?
Kevin
@kevinwr
Jun 19 2017 07:28
@DanCouper oh interesting. Haven't read about that anywhere. I'll have to try and look that up. Definitely one of the problems I've found when doing additional research is lack of consistency in explanations. Really makes things super complicated
Dan Couper
@DanCouper
Jun 19 2017 07:29
@kevinwr you won't be able to get past the FCC challenge using it I think, because it expects the function form, but, for future reference:
class Car {
  constructor() {
    this.wheels = 4;
    this.engines = 1;
    this.seats = 5;
  }

  takeOutSeat() {
    if (this.seats === 0) console.log('No more seats to remove!');
    this.seats = this.seats - 1;
    console.log('You removed a seat! There are now ' + this.seats + ' seats!');
  }
}
> var myCar = new Car();
> myCar.takeOutSeat()
You removed a seat! There are now 4 seats!
You put the stuff you would put in the function in the constructor, and any methods after it
It's exactly the same, but a bit easier to read
Kevin
@kevinwr
Jun 19 2017 07:31
@DanCouper Definitely interesting. thanks for the example. Still feeling iffy on the whole "this" keyword.
CamperBot
@camperbot
Jun 19 2017 07:31
kevinwr sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 790 | @dancouper |http://www.freecodecamp.com/dancouper
Chris Juchtmans
@kjuchtmans
Jun 19 2017 07:31
@Lazzlo that nailed it, thanks!
CamperBot
@camperbot
Jun 19 2017 07:31
kjuchtmans sends brownie points to @lazzlo :sparkles: :thumbsup: :sparkles:
:cookie: 5 | @lazzlo |http://www.freecodecamp.com/lazzlo
Dan Couper
@DanCouper
Jun 19 2017 07:34

@kevinwr :) yes, it behaves a bit wierdly. Best explanation I've seen is probably (note the following is generally correct, there are a few wierd edge cases tho):

  1. The keyword "this" refers to whatever is to the left of the dot at call-time.
  2. If there's nothing to the left of the dot, then "this" is the root scope (e.g. Window).
  3. A few functions change the behavior of "this"—bind, call and apply
  4. The keyword "new" binds this to the object just created

By "to the left of the dot" it means like

For foo.bar(), this would refer to foo; for foo.bar.baz(), this would refer to foo.bar, and so on

rugano
@rugano
Jun 19 2017 07:34
Which other code editors apart from codepen highlights the bugs you make as you type your code?
Dan Couper
@DanCouper
Jun 19 2017 07:35
It is using a thing called ESLint
Which you can install on any text editor
there is JSHint as well, which ESLint is the successor to. And StandardJS as well
All editors have linting plugins which will do this for you
rugano
@rugano
Jun 19 2017 07:36
@DanCouper can i have your help on tic tac toe game ?Can't figure out why the code isn't working completely as expected
Dan Couper
@DanCouper
Jun 19 2017 07:37
Is it on codepen? Can I have a look
Chris Juchtmans
@kjuchtmans
Jun 19 2017 07:37
g'day to you all, coders :wave:
Lhats0
@stahloliver
Jun 19 2017 07:38
Thanks for your help @Lazzlo
CamperBot
@camperbot
Jun 19 2017 07:38
stahloliver sends brownie points to @lazzlo :sparkles: :thumbsup: :sparkles:
:cookie: 6 | @lazzlo |http://www.freecodecamp.com/lazzlo
Dan Couper
@DanCouper
Jun 19 2017 07:42

@kevinwr when you create an object using the var Car = function() .... or class Car { ...., then doing new Car, what the function is doing when you do this:

var Car = function() {
  this.wheels = 4;
  this.engines = 1;
  this.seats = 5;
};

var myCar = new Car();

is creating an object like

{ wheels: 4, engines: 1, seats: 5 }

And it's done that way, using the this... and the new keyword so that it creates an instance of Car (myCar); so that it binds those variables as properties of that object you created, just that object, and you can create loads of them, and they are all discrete:

var myCar1 = new Car();
var myCar2 = new Car();
var myCar3 = new Car();
var myCar4 = new Car();

Thos will all have their own personal versions of the object, and you can alter them all seperately

rugano
@rugano
Jun 19 2017 07:42
Tarun Garhwal
@eoo
Jun 19 2017 07:46
can i have two call back fucntions for the on() method?
Ken Haduch
@khaduch
Jun 19 2017 07:46
@kjuchtmans - good day to you, too
Tarun Garhwal
@eoo
Jun 19 2017 07:46
like $('selector').on("click", fun1, fun2);
lazzlo
@lazzlo
Jun 19 2017 07:47
@eoo Create a new function that calls both of those functions and have that as a callback instead
Kevin
@kevinwr
Jun 19 2017 07:47
@DanCouper Thanks for the explanations. I'm slowly getting it. The one thing I'm curious about is how, if you are sending an argument to a method,
CamperBot
@camperbot
Jun 19 2017 07:47
kevinwr sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:warning: kevinwr already gave dancouper points
Kevin
@kevinwr
Jun 19 2017 07:47
oh crap, let me finish my thought hahaha
Tarun Garhwal
@eoo
Jun 19 2017 07:48
@Lazzlo ooh that sounds lame
huehue
Alexander Domikov
@AlexanderDom
Jun 19 2017 07:48
no actually, it's good idea :), anyway you can add only one function for callback so
Kevin
@kevinwr
Jun 19 2017 07:49
var Bike = function() {

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

  this.getGear = function() {
    return gear;
  };

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

var myBike = new Bike();

So in the above code, if you want to change gear, you can do myBike.setGear(4)

Ok...so how does your argument get passed to the inner fuction parameter "newGear"?

lazzlo
@lazzlo
Jun 19 2017 07:49
@eoo Dunno if this works but try it out:
$("#btn").on("click",function(event){
    event.preventDefault();
    pay();
    cls();
});
Tarun Garhwal
@eoo
Jun 19 2017 07:50
okay lemme try
Kevin
@kevinwr
Jun 19 2017 07:51
Goodness, I really need to find some new resources that REALLY break JS down instead of just giving me abstract ideas or brief overviews (which most of them do). the best resource I've found thus far is "Javascript Absolute Beginners Guide".
Dan Couper
@DanCouper
Jun 19 2017 07:52
@kevinwr aaalso (final post on this), re anonymous functions and named functions, it's the difference between function expressions and function declarations - respectively var foo = function() {} and function foo() {}. The first one is a variable called foo that has a function as a value, the second is a function called foo. In practise they generally behave exactly the same, except as regards hoisting (function declarations - function foo() {} - get pulled to the top of the scope by JS, function expressions - var foo = function - can only get used when the JS interpreter hits that line of code). This is a fairly concise explanation, first answer here: https://teamtreehouse.com/community/what-are-the-pros-and-cons-of-using-function-statement-vs-function-expression
Kevin
@kevinwr
Jun 19 2017 07:52
though it still doesn't quite go into depth the way I'd like
lazzlo
@lazzlo
Jun 19 2017 07:53
@kevinwr The same way when you call any function. setGear is a function (or method because it's part of an object) that gets its parameters when you call it. You are calling it when you write myBike.setGear(4) and sending the argument 4 with it.
Chris Juchtmans
@kjuchtmans
Jun 19 2017 07:54

"Twitch.TV API"

After Leisure Suit Larry (lounge of lizards) and Diablo I, I have given up on gaming, living with the distant fear of relapse ever since. Does that mean I can't be a coder now? :worried:

Kevin
@kevinwr
Jun 19 2017 07:55
@Lazzlo I understand, but in order to pass the argument, I would expect to see something like this.setGear(newGear) = function(newGear)...
quinn3111993
@quinn3111993
Jun 19 2017 07:55
Hi, I cannot find the mistake in this coding, please help
var studlyCapVar;
var properCamelCase;
var titleCaseOver;
studlyCapVar = 10;
properCamelCase = "A String";
titleCaseOver = 9000;
Claudio Restifo
@Marmiz
Jun 19 2017 07:55
@kevinwr if you like reading I advise give the "You don't know JavaScript" (YDKJS for short) series of books.
They really makes a great job at explaining JS....
You can read them on-line for free on their github repo
https://github.com/getify/You-Dont-Know-JS
Kevin
@kevinwr
Jun 19 2017 07:56
@Marmiz Yeah, I know about that resource. Glanced at it, but didn't get the feeling it was what I needed. I'll check it out again.
Ayush Mahajan
@ay2306
Jun 19 2017 07:57
@quinn3111993 I am not sure but this can be a problem. In JS there is no declaration of variable type so I am always worried regarding it. try:
var studlyCapVar=0;
var properCamelCase="";
var titleCaseOver=0;
studlyCapVar = 10;
properCamelCase = "A String";
titleCaseOver = 9000;
@quinn3111993 else share rest of your code, problem has to be in there...
lazzlo
@lazzlo
Jun 19 2017 07:59

@kevinwr I think you're mixing up two concepts. The way to call a function and the way to declare it. When you write 'this.setGear = function(newGear)... ' you are saying that you want setGear to be a function that will take the argument newGear.

If you write 'this.setGear(newGear) = function(newGear)', you are essentially calling the function before declaring it

Kevin
@kevinwr
Jun 19 2017 08:01
@Lazzlo I know....it's hard to explain the way I'm thinking about it. In some ways it makes sense, in other's it doesn't.
lazzlo
@lazzlo
Jun 19 2017 08:01
@ay2306 You don't need to initialize variables to a value when you declare them. So the problem is probably in the rest of the code
@kevinwr Try to write down for yourself what you are thinking. I find it helps me sometimes when I am stuck with my brainloops
Ayush Mahajan
@ay2306
Jun 19 2017 08:03
@Lazzlo being a C/C++ coder, it always worry me and its a relief to know that we dont have to initialise them there. But I find it strange, how will memory allocation take place?
Dan Couper
@DanCouper
Jun 19 2017 08:05
@kevinwr I'd second the You Don't Know JS series; I'd also recommend a little book called The Principles of Object Oriented JavaScript, which explains how objects work really well, I think I've got a spare copy that came in a bundle I bought a while ago somewhere on my computer, I'll dm it across to you if you want it
quinn3111993
@quinn3111993
Jun 19 2017 08:06
Thanks all, I see my mistake that I doubled the first 3 lines (that they had given above my coding)
Will White
@willnwhite
Jun 19 2017 08:06
@kevinwr The way to think about it is that this.setGear is (=) a function that takes newGear (function (newGear)...).
Ayush Mahajan
@ay2306
Jun 19 2017 08:06
@quinn3111993 :+1:
Will White
@willnwhite
Jun 19 2017 08:07
@kevinwr this.setGear(newGear) = function(newGear)... has a redundant (newGear).
rugano
@rugano
Jun 19 2017 08:08
@DanCouper did you see it?
Dan Couper
@DanCouper
Jun 19 2017 08:09
will have look in a sec @rugano , just got scrum meeting to go to
Tarun Garhwal
@eoo
Jun 19 2017 08:09
so theres a link around a button, and an enent handler for the button 'click'.
what will happen first when the button is clicked? open the link or the jquery fucntion?
lazzlo
@lazzlo
Jun 19 2017 08:09
@ay2306 I don't know the details of memory allocation, so can't discuss that unfortunately.
rugano
@rugano
Jun 19 2017 08:10
@DanCouper ok,
Tarun Garhwal
@eoo
Jun 19 2017 08:13
ismail
@ismail2009
Jun 19 2017 08:14
please anyone can help me in challenge 168
Tarun Garhwal
@eoo
Jun 19 2017 08:14
in the JS, the setTweetText() is called after printquote(), but it doesnt set the text to the new quote, rather, the old one
how do i overcome this?
i guess this is happening cause of jQuery being asynchronous?
Will White
@willnwhite
Jun 19 2017 08:15
@ismail2009 Where are the challenge numbers?
Blauelf
@Blauelf
Jun 19 2017 08:15
@ismail2009 168 is the number of your brownie points, has nothing to do with the challenge you're in.
ismail
@ismail2009
Jun 19 2017 08:18
i mean challenge stand in line in basic of java script
Tarun Garhwal
@eoo
Jun 19 2017 08:18
can someone look at my code?
CallMeOrange
@EgnaroDev
Jun 19 2017 08:20
@Blauelf are you good with html/css?
Claudio Restifo
@Marmiz
Jun 19 2017 08:21
@eoo what's appening is that the setTweetText function is called right after getJSON is called, what you want is call it when getJSON receive a response
Tarun Garhwal
@eoo
Jun 19 2017 08:22
yes how do i accomplish that?>
Blauelf
@Blauelf
Jun 19 2017 08:22
@MCTwoDigitZero More JS, I don't exactly like that HTML/CSS is subject to interpretation (and layouts looking the same on all major browsers contain lots of vendor-prefixes and browser switches)
CallMeOrange
@EgnaroDev
Jun 19 2017 08:22
@Blauelf do you know about floating and stuff?
Just trying to get two things in one line
ismail
@ismail2009
Jun 19 2017 08:23
@Blauelf i mean challenge stand in line in basic of java script
Anamika Gupta
@anamikasheetal1993
Jun 19 2017 08:23

function testElse(val) {
var result = "";
// Only change code below this line

if (val > 5) {
result = "Bigger than 5";
}
else{
result="5 or smaller";
}

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

// Change this value to test
testElse(4);
please tell me the error

Claudio Restifo
@Marmiz
Jun 19 2017 08:23
@eoo then or await shpuld do the trick
CallMeOrange
@EgnaroDev
Jun 19 2017 08:23
@ismail2009 that is not challenge number they are how many cookies you have
about @ismail2009
CamperBot
@camperbot
Jun 19 2017 08:24
:cookie: 168 | @ismail2009 |http://www.freecodecamp.com/ismail2009
CallMeOrange
@EgnaroDev
Jun 19 2017 08:24
There is no way to know challenge's number unless you counts
Blauelf
@Blauelf
Jun 19 2017 08:24
@anamikasheetal1993 What are you meant to do?
Claudio Restifo
@Marmiz
Jun 19 2017 08:25
Being JQuery I'd go for then since I'm not sure if you can use the await method. Need to check the getJSON docs and see if it's an async method
Will White
@willnwhite
Jun 19 2017 08:25
@ismail2009 Do you know push and shift?
Anamika Gupta
@anamikasheetal1993
Jun 19 2017 08:25
my code is not running
Blauelf
@Blauelf
Jun 19 2017 08:25
@ismail2009 You need to write code for the function. First, append the number to the array. Then, remove and return the first element of the array. Make sure to use arr and item within the function.
rugano
@rugano
Jun 19 2017 08:25
@eoo seems to be ok,the api doing it's work
Blauelf
@Blauelf
Jun 19 2017 08:26
@anamikasheetal1993 What do you mean with "not running"?
Ogundele Olumide
@Lumexralph
Jun 19 2017 08:27
@DanCouper I won't mind a copy if it's available
Anamika Gupta
@anamikasheetal1993
Jun 19 2017 08:28
can you please tell me how to solve this problem
Blauelf
@Blauelf
Jun 19 2017 08:28
@anamikasheetal1993 You might need to write the else as } else { for the test to accept it. Also, it's Smaller with uppercase S
Does not have to be } else {, but some whitespace around else seems to be required.
Anamika Gupta
@anamikasheetal1993
Jun 19 2017 08:31
@Blauelf ok I got it thanks.
CamperBot
@camperbot
Jun 19 2017 08:31
anamikasheetal1993 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4410 | @blauelf |http://www.freecodecamp.com/blauelf
Tarun Garhwal
@eoo
Jun 19 2017 08:32
@Marmiz okay lemme try
@rugano i want the setTweetText() to execute only after getJSON is finished
Claudio Restifo
@Marmiz
Jun 19 2017 08:34
@eoo I'd simply call all my methods when the getJSON is done:
  $.getJSON("https://api.myjson.com/bins/mmaxj").then(function(data){
     // all the stuff I want it to do including setting the text
  });
ez pz
ismail
@ismail2009
Jun 19 2017 08:36
@Blauelf thanks it work
CamperBot
@camperbot
Jun 19 2017 08:36
ismail2009 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4411 | @blauelf |http://www.freecodecamp.com/blauelf
Jillo Abdullahi
@jillo-abdullahi
Jun 19 2017 08:36
Hi guys, Wann make this return true. How can I apply indexOf() here?
function mutation(arr) {

 var str = arr[0].toLowerCase().split("").sort().join("");
  var testStr = arr[1].toLowerCase().split("").sort().join("");
  return str.includes(testStr);
}

mutation(["floor", "for"]);
Tarun Garhwal
@eoo
Jun 19 2017 08:37
@Marmiz holy shit are you a god?
thanks!
Blauelf
@Blauelf
Jun 19 2017 08:37
@jillo-abdullahi No sorting required. You have to test whether all individual characters of the second string can be found in the first string. This requires some kind of loop.
Claudio Restifo
@Marmiz
Jun 19 2017 08:38
@eoo no I'm a noob.
But remember this lessons when you'll find yourself stuck in the infamous "callback hell"
:)
glad it worked :sparkles:
Jillo Abdullahi
@jillo-abdullahi
Jun 19 2017 08:38
@Blauelf I see...
Tarun Garhwal
@eoo
Jun 19 2017 08:39
haha it wouldve taken me another half hour if was going to read the documentation
im not used to it @Marmiz
random quote machine complete with this
i could add more design elements but i think im gonno skip to next now hehe
Dan Couper
@DanCouper
Jun 19 2017 08:50

@rugano basically the reason it's not doing anything is that the event is not firing, at all. Generally, this is because the element the click event needs to attach to is not present at the point the script is trying to attach it. When I add two breakpoints, one on the first click event to pick the player, one on the second, and run the script, I get to the first event, then if I jump through, it takes me back to $(document).ready(function() {TICAPP.initializeGame();});, at which point I can't get any further. At some point the script gets stuck in a loop: it cannot attach that first event, and it goes round in a circle then stops.

The issue I have is that the code is so complex and intertwined that I can't effectively debug it: because you have one single God object, which builds objects and behaviours inside it, it is near-impossible to tell what the state of the system is at any one point. The main TICAPP object does everything, and it keeps constructing new things inside it all the time. You need to split all the code out: you don't need it to do everything: you can seperate out the player logic, and the display logic , and the state (the current move, the score etc). Put stuff in small functions that do one thing, use them instead of dynamically creating objects and methods, flatten the code out so there isn't any nesting: like for example TICAPP.game.resetGame() - you can just have a function called resetGame() that does one thing, resets the game, you gain nothing by having this incredibly complex object that controls everything. Also don't next event handlers in event handlers. For example, just have a function to let a player pick the starting x or o. The second player can call the same function, just check what the other player has picked and prevent that option.

Jillo Abdullahi
@jillo-abdullahi
Jun 19 2017 08:53
@Blauelf, Finally figured it out. Thanks!
CamperBot
@camperbot
Jun 19 2017 08:53
jillo-abdullahi sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4412 | @blauelf |http://www.freecodecamp.com/blauelf
Dan Couper
@DanCouper
Jun 19 2017 09:04
@rugamo: for example, very very roughly, you can seperate out the stateful bits of logic into something like this, then just have a list of functions that accept the relevant state and do their stuff:
// this is always the same, regardless of game:
var  winCombos = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9],
    [1, 4, 7],
    [2, 5, 8],
    [3, 6, 9],
    [1, 5, 9],
    [7, 5, 3]
  ];

// These are common to the current game
// NOTE currentBoard could just be ["", "", "", "", "", "", "", "", ""], and numFilledIn
// can just check how many are not empty strings:
var currentGame = {
    numFilledIn: 0,
    currentBoard: {
      1: "",
      2: "",
      3: "",
      4: "",
      5: "",
      6: "",
      7: "",
      8: "",
      9: ""
    }
};

var games = {
  timeOuts: []
};

var players = {
  playerOne: {
    score: 0,
    currentPiece: "" // "X" or "O"
  },
  playerTwo: {
    score: 0,
    cuurrentPiece: "" // "X" or "O"
  }
};
CallMeOrange
@EgnaroDev
Jun 19 2017 09:09
@jillo-abdullahi hey can you help me?
Jillo Abdullahi
@jillo-abdullahi
Jun 19 2017 09:09
@MCTwoDigitZero Sure. What's up?
CallMeOrange
@EgnaroDev
Jun 19 2017 09:10
@jillo-abdullahi I saw your portfolio
I wanna know how you did it with projects section
Just with image and anchor element
Jillo Abdullahi
@jillo-abdullahi
Jun 19 2017 09:14

@MCTwoDigitZero I used Bootstrap thumbnail class for the images. Here is a snippet

<div class="thumbnail">
            <a href="#" target="_blank">
              <img class="img-rounded" src="./images/project-moyaleraha.JPG" alt="Bus Reservation System">
              <div class="caption">
                <p>From Moyale with love! A bus reservation system.</p>
              </div>
            </a>
          </div>

The images are rounded off at the corners with the img-rounded class.

CallMeOrange
@EgnaroDev
Jun 19 2017 09:15
@jillo-abdullahi I see but how am I able to get an image of my pen?
Do i have to create my own image then upload it?
I guess thats the answer
Jillo Abdullahi
@jillo-abdullahi
Jun 19 2017 09:18
@MCTwoDigitZero I actually didn't do this project off Codepen, just locally on my PC. I snipped the image and added it to my local project folder.
CallMeOrange
@EgnaroDev
Jun 19 2017 09:18
I see
If I wanted my own image to upload I can use postimg
Jillo Abdullahi
@jillo-abdullahi
Jun 19 2017 09:20
@MCTwoDigitZero You can also upload your image on say, Dropbox and then just add the image link.
CallMeOrange
@EgnaroDev
Jun 19 2017 09:20
Well yeah just like postimg
Jillo Abdullahi
@jillo-abdullahi
Jun 19 2017 09:20
Yap
CallMeOrange
@EgnaroDev
Jun 19 2017 09:20
anyway thanks @jillo-abdullahi
CamperBot
@camperbot
Jun 19 2017 09:20
mctwodigitzero sends brownie points to @jillo-abdullahi :sparkles: :thumbsup: :sparkles:
:cookie: 251 | @jillo-abdullahi |http://www.freecodecamp.com/jillo-abdullahi
Jillo Abdullahi
@jillo-abdullahi
Jun 19 2017 09:21
@MCTwoDigitZero Glad to be of help!
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 19 2017 09:21
hey all, I've added Jquery and Bootstrap to my JS part, but it's still giving the below error
Uncaught Error: Bootstrap's JavaScript requires jQuery
can some one please check it
Blauelf
@Blauelf
Jun 19 2017 09:24
@reddy-bharathkumar Maybe you put them in the wrong order?
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 19 2017 09:24
I added the Jquery first then bootstrap
Blauelf
@Blauelf
Jun 19 2017 09:25
You put bootstrap in twice, once in the HTML section, once in JS.
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 19 2017 09:26
@Blauelf you are awesome.. thanks man..
CamperBot
@camperbot
Jun 19 2017 09:26
reddy-bharathkumar sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4413 | @blauelf |http://www.freecodecamp.com/blauelf
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 19 2017 09:26
quick help, does my page working in your system.. I mean is it showing the result
CallMeOrange
@EgnaroDev
Jun 19 2017 09:27
@reddy-bharathkumar it does
Nice project
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 19 2017 09:27
@MCTwoDigitZero thank you.. :)
CamperBot
@camperbot
Jun 19 2017 09:27
reddy-bharathkumar sends brownie points to @mctwodigitzero :sparkles: :thumbsup: :sparkles:
:cookie: 173 | @mctwodigitzero |http://www.freecodecamp.com/mctwodigitzero
Blauelf
@Blauelf
Jun 19 2017 09:34
@reddy-bharathkumar Does not work for me, though that jQuery/Bootstrap error seems to be removed. If the network (transparent proxy sometimes replacing websites) were the problem, I should see some error messages, but maybe I just don't, so not necessarily meaning it does not work.
CallMeOrange
@EgnaroDev
Jun 19 2017 09:35
@Blauelf did you do refresh? it does work for me
Omair Shahid
@Omair133
Jun 19 2017 09:36
After putting a lot of effort, I've managed to solve the Chunky Monkey challenge, but the code which I've written is a very complex one. If anyone has solved it in an easier way then please do share your code . Here is my code :
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var x = Math.floor(arr.length/size);
  var c=0;
  var array=[];
  var finalArray=[];
  for(var j=0;j<x;j++)
    {
      for(var i=0;i<size;i++)
        {
          array.push(arr[c]);
          c++;
        }
      finalArray.push(array);
      array=[];
    }
  if(arr.length>(size*x))
    {
      for(var k=c;k<arr.length;k++)
        {
          array.push(arr[c]);
          c++;
        }
      finalArray.push(array);
    }
  return finalArray;
}
chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3);
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 19 2017 09:39
@Blauelf can you refresh it once and try again please
also, can you check my Skycon code part once.. not sure why it's not working
Pieter Stokkink
@forkerino
Jun 19 2017 09:44

@Omair133 One of the easiest ways is to use a single loop:

function chunkArrayInGroups(arr, size) {
  var result = [];
  for (var i=0; i<arr.length; i+=size){
    result.push(arr.slice(i, i+size));
  }
  return result;
}

choosing the right things for the head of the for loop is important... :)

Bharath Kumar Reddy
@reddy-bharathkumar
Jun 19 2017 09:44
got it, never mind
Blauelf
@Blauelf
Jun 19 2017 09:44

@reddy-bharathkumar The getJSON does not seem to do anything, but it also does not fail, I have no idea. I also have no idea what the geoip stuff is meant to do, when called manually it returns stupid stuff only (my proxy's internal IP address?)

May be a problem on my network only.

Partly works on Chrome. Tells me
partly-cloudy-day
27.19 C
Will Waymel
@willwaymel
Jun 19 2017 09:46
I'm going crazy... why does this return an empty array?
var moves = [];
var makeArray = function() {
    for (i = 0; i<9; i++) {
        moves.push(i);
    }
};
console.log(moves);
Omair Shahid
@Omair133
Jun 19 2017 09:46
@forkerino This was way to easy.. :smile: Thanks
CamperBot
@camperbot
Jun 19 2017 09:46
omair133 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2665 | @forkerino |http://www.freecodecamp.com/forkerino
Saif Ur Rahman
@saifsmailbox98
Jun 19 2017 09:47
@willwaymel you have to call the function
CallMeOrange
@EgnaroDev
Jun 19 2017 09:47
lol because moves have empty array
Never mind
It was used in function block didnt see it
Yeah you call the function by returning make______
Will Waymel
@willwaymel
Jun 19 2017 09:48
@saifsmailbox98 huh... i thought when you did it like this var makearray = function vs function makearray() it was automatically called?

@MCTwoDigitZero lol yes... thank you

lol because moves have empty array

CamperBot
@camperbot
Jun 19 2017 09:49
willwaymel sends brownie points to @mctwodigitzero :sparkles: :thumbsup: :sparkles:
:cookie: 174 | @mctwodigitzero |http://www.freecodecamp.com/mctwodigitzero
Saif Ur Rahman
@saifsmailbox98
Jun 19 2017 09:49
@willwaymel you have to explicitly call it, put this makeArray(); before console.log
CallMeOrange
@EgnaroDev
Jun 19 2017 09:49
@willwaymel well moves was used in function block I didnt see it
Not say if its used correctly or not
Will Waymel
@willwaymel
Jun 19 2017 09:50
@MCTwoDigitZero what do you mean?
CallMeOrange
@EgnaroDev
Jun 19 2017 09:50
var makeArray = function() {
    for (i = 0; i<9; i++) {
        moves.push(i);
    }
True moves have empty array but its already used in function
Will Waymel
@willwaymel
Jun 19 2017 09:50
I've had var x = function in a loop before and it was called without me explicitly calling it,
CallMeOrange
@EgnaroDev
Jun 19 2017 09:51
Well I dont know much about variable storing function
Saif Ur Rahman
@saifsmailbox98
Jun 19 2017 09:51

@willwaymel because you would have used something like this

function() { statements }

Blauelf
@Blauelf
Jun 19 2017 09:51
@reddy-bharathkumar Now also loads on Firefox, not sure what it was.
CallMeOrange
@EgnaroDev
Jun 19 2017 09:51
@saifsmailbox98 hey can you test something for me?
Will Waymel
@willwaymel
Jun 19 2017 09:51
@MCTwoDigitZero @saifsmailbox98 got it. thanks for the help!
CamperBot
@camperbot
Jun 19 2017 09:51
willwaymel sends brownie points to @mctwodigitzero and @saifsmailbox98 :sparkles: :thumbsup: :sparkles:
:warning: willwaymel already gave mctwodigitzero points
:cookie: 513 | @saifsmailbox98 |http://www.freecodecamp.com/saifsmailbox98
Saif Ur Rahman
@saifsmailbox98
Jun 19 2017 09:51
@MCTwoDigitZero sure
@willwaymel yw
Click first image below project and MCTwoDigitZero
They have link uploaded but doesnt take me to its link for some reason
water-melon91
@water-melon91
Jun 19 2017 09:53
i don't understand this chapter
dd.png
please help
Zack Novosad
@zacknovosad
Jun 19 2017 09:53
function titleCase(str) {
  str = str.toLowerCase();
  console.log('string: ' + str);
  stringArray = str.split(' ');
  console.log('string array: ' + stringArray);
  processedArray = [];

  for(var i = 0; i < stringArray.length; i++) {
    console.log('iteration: ' + i);
    processedArray[i] += stringArray[i].substring(0, 1).toUpperCase();
    processedArray[i] += stringArray[i].substring(1, stringArray[i].length);
    console.log('processed array: ' + processedArray);

  }
  str = processedArray.join(' ');
  console.log('processedString: ' + str);
}

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

https://www.freecodecamp.com/challenges/title-case-a-sentence

Anyone know why I'm getting 'undefined' added to my processedArray before every string?

CallMeOrange
@EgnaroDev
Jun 19 2017 09:54
no not that image lol
Saif Ur Rahman
@saifsmailbox98
Jun 19 2017 09:54
this image?
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 19 2017 09:54
@Blauelf geoip is to get the locations details, I used it to fill the data on left-side
CallMeOrange
@EgnaroDev
Jun 19 2017 09:54
I said that image below projects
Blauelf
@Blauelf
Jun 19 2017 09:54
@reddy-bharathkumar That one won't work for me it seems.
Saif Ur Rahman
@saifsmailbox98
Jun 19 2017 09:54
@MCTwoDigitZero the one with the text "coming soon"?
CallMeOrange
@EgnaroDev
Jun 19 2017 09:55
@saifsmailbox98 not coming soon
Next to it
Click on it
Blauelf
@Blauelf
Jun 19 2017 09:56
hunterxhunter?
CallMeOrange
@EgnaroDev
Jun 19 2017 09:56
yeah
Saif Ur Rahman
@saifsmailbox98
Jun 19 2017 09:56
hunter?
Zack Novosad
@zacknovosad
Jun 19 2017 09:56
this is my output:
processedString: undefinedI'm undefinedA undefinedLittle undefinedTea undefinedPot
CallMeOrange
@EgnaroDev
Jun 19 2017 09:56
click on that Hunter x Hunter image
Saif Ur Rahman
@saifsmailbox98
Jun 19 2017 09:56
add target="_blank" as an attribute to it.
CallMeOrange
@EgnaroDev
Jun 19 2017 09:56
I already did
I added it to anchor element
Even both of it
Dont work for some reason...
Blauelf
@Blauelf
Jun 19 2017 09:58
@MCTwoDigitZero What's that event handler on the anchor element?
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 19 2017 09:58
@MCTwoDigitZero need one more help, does my weather project showing location to you on left side of the page..?
CallMeOrange
@EgnaroDev
Jun 19 2017 09:58
event handler?
@reddy-bharathkumar yeah all of it
location, temperature etc..
Toggle buttons also works
Blauelf
@Blauelf
Jun 19 2017 09:59
@MCTwoDigitZero
$(document).on('click', 'a', function(event){
    event.preventDefault();

    $('html, body').animate({
        scrollTop: $( $.attr(this, 'href') ).offset().top
    }, 1000);
});
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 19 2017 09:59
@MCTwoDigitZero ohh cool, @Blauelf it's working for others.. not sure why it's not working on your system?
CallMeOrange
@EgnaroDev
Jun 19 2017 09:59
Oh thats for smooth scrolling
Blauelf
@Blauelf
Jun 19 2017 09:59
@reddy-bharathkumar Odd proxy
CallMeOrange
@EgnaroDev
Jun 19 2017 09:59
oh... that event handler..
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 19 2017 10:00
@Blauelf oh okay..
@MCTwoDigitZero @Blauelf thanks again :)
CamperBot
@camperbot
Jun 19 2017 10:00
reddy-bharathkumar sends brownie points to @mctwodigitzero and @blauelf :sparkles: :thumbsup: :sparkles:
:warning: reddy-bharathkumar already gave mctwodigitzero points
:warning: reddy-bharathkumar already gave blauelf points
CallMeOrange
@EgnaroDev
Jun 19 2017 10:00
So I just have to delete event.preventDefault();
Saif Ur Rahman
@saifsmailbox98
Jun 19 2017 10:00
@MCTwoDigitZero yes
CallMeOrange
@EgnaroDev
Jun 19 2017 10:01
That solved the problem thanks guys
anyway I have one more problem :/
@MCTwoDigitZero what is it?
Just scroll to bottom then hit home and about in navbar
See the differences
Saif Ur Rahman
@saifsmailbox98
Jun 19 2017 10:07
@MCTwoDigitZero home works fine. about is also doing its job as you can see the text about just touching the browser window behind the navbar
CallMeOrange
@EgnaroDev
Jun 19 2017 10:08
well... thats fine but I just want about just to be below navbar
bro I just added a trick...
Saif Ur Rahman
@saifsmailbox98
Jun 19 2017 10:10
@MCTwoDigitZero you can move the a
CallMeOrange
@EgnaroDev
Jun 19 2017 10:10
I simply moved id = "about" to MCTwoDigitZero so no one will be able to figure out without looking at code
@saifsmailbox98 but it will affect below
This "trick" is fine for now :/
Rajesh
@raj347
Jun 19 2017 10:11
hi all i am new to java script...can somebody help me to finish this task, The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.
TWoerner94
@TWoerner94
Jun 19 2017 10:11
Hey guys, I'm working on the Exact Change challenge right now. All the tests come back fine except for this one here. It returns "Insufficient Funds" but I cant figure out why.

function checkCashRegister(price, cash, cid) {
  var change = [
    ["HUNDRED", 0.00],
    ["TWENTY", 0.00],
    ["TEN", 0.00],
    ["FIVE", 0.00],
    ["ONE", 0.00],
    ["QUARTER", 0.00],
    ["NICKEL", 0.00],
    ["DIME", 0.00],
    ["PENNY", 0.00]
  ];
  var changeAmount = cash - price;
  var cidAmount = 0;

  for (i=0; i<cid.length; i++) {
    cidAmount += cid[i][1];
  }
  if (changeAmount === cidAmount) {
    return "Closed";
  }

  while (changeAmount > 0) {
    if (changeAmount >= 100 && cid[8][1] >= 100) {
      change[0][1] += 100.00;
      changeAmount -= 100.00;
      cid[8][1] -= 100.00;
      continue;
    } else if (changeAmount >= 20 && cid[7][1] >= 20) {
      change[1][1] += 20.00;
      changeAmount -= 20.00;
      cid[7][1] -= 20.00;
      continue;
    } else if (changeAmount >= 10 && cid[6][1] >= 10) {
      change[2][1] += 10.00;
      changeAmount -= 10.00;
      cid[6][1] -= 10.00;
      continue;
    } else if (changeAmount >= 5 && cid[5][1] >= 5) {
      change[3][1] += 5.00;
      changeAmount -= 5.00;
      cid[5][1] -= 5.00;
      continue;
    } else if (changeAmount >= 1 && cid[4][1] >= 1) {
      change[4][1] += 1.00;
      changeAmount -= 1.00;
      cid[5][1] -= 1.00;
      continue;
    } else if (changeAmount >= 0.25 && cid[3][1] >= 0.25) {
      change[5][1] += 0.25;
      changeAmount -= 0.25;
      cid[3][1] -= 0.25;
      continue;
    } else if (changeAmount >= 0.1 && cid[2][1] >= 0.1) {
      change[6][1] += 0.10;
      changeAmount -= 0.10;
      cid[2][1] -= 0.10;
      continue;
    } else if (changeAmount >= 0.05 && cid[1][1] >= 0.05) {
      change[7][1] += 0.05;
      changeAmount -= 0.05;
      cid[1][1] -= 0.05;
      continue;
    } else if (changeAmount >= 0.01 && cid[0][1] >= 0.01) {
      change[8][1] += 0.01;
      changeAmount -= 0.01;
      cid[0][1] -= 0.01;
      continue;
    } else {
      return "Insufficient Funds";
    }
  }

  change = change.filter(function(val) {
    if (val[1] !== 0) {
      return val;
    }
  });

  return change;
}


checkCashRegister(3.26, 100.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
CallMeOrange
@EgnaroDev
Jun 19 2017 10:11
oh jeez
That is a lot of code
Ok bye guys will be done with portfolio tomorrow
TWoerner94
@TWoerner94
Jun 19 2017 10:12
Haha yea sorry, probably also not the most elegant way to solve this
Rajesh
@raj347
Jun 19 2017 10:12

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

fahrenheit = (9/5) + (-30);

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

// Change the inputs below to test your code
convertToF(0);
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86

can somebody help me?
Pieter Stokkink
@forkerino
Jun 19 2017 10:13
@TWoerner94 maybe a floating point inaccuracy? type 0.1 + 0.2 into the console and you'll see what happens.
@TWoerner94 one way to solve is to do all calculations in pennies.
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 19 2017 10:13
@raj347 I don't think that's the correct formula
TWoerner94
@TWoerner94
Jun 19 2017 10:14
returns 0.300000000004
How do I fix this?
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 19 2017 10:14
@TWoerner94 var = +var.toFixed(2)
Dmitry
@Wasterlord
Jun 19 2017 10:14

hi all
pls help - why this code drop all strings?

function bouncer(arr) {

function filt(falsyVal){
for (var i = 0;i<arr.length;i++){
if (falsyVal === false || falsyVal === undefined || falsyVal === 0 || falsyVal === null || falsyVal === "" || isNaN(falsyVal)){
return false;
} else {
return true;
}

 }

}

var a = arr.filter(filt);

return a;
}

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

Rajesh
@raj347
Jun 19 2017 10:15
@reddy-bharathkumar can u plz tell me the correct formula n how shud i write in java
TWoerner94
@TWoerner94
Jun 19 2017 10:15
Where do I put in this code @reddy-bharathkumar ?
abhishek4kahol
@abhishek4kahol
Jun 19 2017 10:15
hi guys! i am doing this palindrome problem, im getting problem in one particular set for almostomla
function palindrome(str) {
str = str.toLowerCase().replace(/[^A-Za-z0-9]/g, '');
for(var i=0;i<str.length;i++){
if(str[i] === str[str.length-1-i]){
return true;
}
else{
return false;
}
}
palindrome("almostomla");
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 19 2017 10:15
right after the line where you got the long decimal number
TWoerner94
@TWoerner94
Jun 19 2017 10:16
That was just a test, Im not actually using that code
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 19 2017 10:17
@raj347 fahrenheit = celsius*(9/5)+32;
TWoerner94
@TWoerner94
Jun 19 2017 10:17
Also this here
``
checkCashRegister(19.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
Is working fine
Returns ["QUARTER", 0.5] like its supposed to
All the other tests also come back just fine
Saif Ur Rahman
@saifsmailbox98
Jun 19 2017 10:20
@abhishek4kahol if you are going to test it like that it will return true even if only the first character and the last character are equal. like in the case of (bathtub)
also you need to split it first
Dmitry
@Wasterlord
Jun 19 2017 10:21

guys pls help - when i use IsNaN in filter - i drop all strings

function bouncer(arr) {

function filt(falsyVal){
for (var i = 0;i<arr.length;i++){
if (falsyVal === false || falsyVal === undefined || falsyVal === 0 || falsyVal === null || falsyVal === "" || isNaN(falsyVal)){
return false;
} else {
return true;
} }}

var a = arr.filter(filt);
return a;
}

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

can someone say why its going on?
Pieter Stokkink
@forkerino
Jun 19 2017 10:22
@TWoerner94 some decimal values can be represented in binary, some can't. Do all the calculations in pennies and convert back at the end. (i.e. do everything times 100 before the calculations and / 100 after)
TWoerner94
@TWoerner94
Jun 19 2017 10:23
Alright I'll try that, thanks @forkerino
CamperBot
@camperbot
Jun 19 2017 10:23
twoerner94 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2666 | @forkerino |http://www.freecodecamp.com/forkerino
Saif Ur Rahman
@saifsmailbox98
Jun 19 2017 10:23
@Wasterlord you have to remove all falsy values from the array.
Rajesh
@raj347
Jun 19 2017 10:24
thanks alot @reddy-bharathkumar
CamperBot
@camperbot
Jun 19 2017 10:24
raj347 sends brownie points to @reddy-bharathkumar :sparkles: :thumbsup: :sparkles:
:cookie: 334 | @reddy-bharathkumar |http://www.freecodecamp.com/reddy-bharathkumar
Dmitry
@Wasterlord
Jun 19 2017 10:24
@saifsmailbox98 ye end it remove it - but remove also strings(
abhishek4kahol
@abhishek4kahol
Jun 19 2017 10:24
@saifsmailbox98 why do i need to split it when im checking alphabets for each index
Ugo
@uvieugo
Jun 19 2017 10:25
hey y'all
Rajesh
@raj347
Jun 19 2017 10:25

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

fahrenheit = 0 (9/5) + 32;
fahrenheit = (-30)
(9/5) + 32;
fahrenheit = (-10) (9/5) + 32;
fahrenheit = (0)
(9/5) + 32;
fahrenheit = (20) (9/5) + 32;
fahrenheit = (30)
(9/5) + 32;

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

// Change the inputs below to test your code
convertToF(0);
/convertToF(-30);
convertToF(-10);
convertToF(0);
convertToF(20);
convertToF(30);
/
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86
still unable to submit...any suggestions?

Pieter Stokkink
@forkerino
Jun 19 2017 10:25
@Wasterlord You can use Number.isNaN() instead of isNaN()
Ugo
@uvieugo
Jun 19 2017 10:25
a quick question about json
Saif Ur Rahman
@saifsmailbox98
Jun 19 2017 10:25
@abhishek4kahol incase to want to reverse it,
Ugo
@uvieugo
Jun 19 2017 10:26
whats the best way to add bulk data to a json file
Bharath Kumar Reddy
@reddy-bharathkumar
Jun 19 2017 10:26
@raj347 you just have to pass the celsius variable
just keep that formula that I've given and return fahrenheit
Dmitry
@Wasterlord
Jun 19 2017 10:26
@forkerino thx - it help
CamperBot
@camperbot
Jun 19 2017 10:26
wasterlord sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2667 | @forkerino |http://www.freecodecamp.com/forkerino
heroiczero
@heroiczero
Jun 19 2017 10:26
@raj347 use the parameter celsius and the formula to the left of your excercise
Saif Ur Rahman
@saifsmailbox98
Jun 19 2017 10:26
@Wasterlord why are you using a for loop inside of the functon filt?
abhishek4kahol
@abhishek4kahol
Jun 19 2017 10:26
@saifsmailbox98 str = str.toLowerCase().replace(/[^A-Za-z0-9]/g, '');
return str === str.split('').reverse().join('');
i have solved it with this way
Saif Ur Rahman
@saifsmailbox98
Jun 19 2017 10:27
@abhishek4kahol great :+1:
Pieter Stokkink
@forkerino
Jun 19 2017 10:27
@Wasterlord what @saifsmailbox98 said is a good question. Furthermore, because you return inside your loop, it won't cycle more than once. :)
abhishek4kahol
@abhishek4kahol
Jun 19 2017 10:27
@saifsmailbox98 but want to know what is the problem with previous solution
TWoerner94
@TWoerner94
Jun 19 2017 10:28
I think I found the problem. I converted everything into pennies now, but even so I'm left with a changeAmount of 0.999999999999982
Dmitry
@Wasterlord
Jun 19 2017 10:28
@forkerino now i rly dont understand how this filter work)
Saif Ur Rahman
@saifsmailbox98
Jun 19 2017 10:28
@abhishek4kahol your previous solution would not wait for the next character if the first and last charcters are equal it will return true, OR if first and last characters are not same it will return false
Pieter Stokkink
@forkerino
Jun 19 2017 10:28
@TWoerner94 sounds like you still did some calculations before multiplying by 100.
TWoerner94
@TWoerner94
Jun 19 2017 10:29
Wait I send you my new code
Pieter Stokkink
@forkerino
Jun 19 2017 10:29
@Wasterlord :) .filter does the looping for you
Rajesh
@raj347
Jun 19 2017 10:29
thanks again @reddy-bharathkumar
CamperBot
@camperbot
Jun 19 2017 10:29
raj347 sends brownie points to @reddy-bharathkumar :sparkles: :thumbsup: :sparkles:
:warning: raj347 already gave reddy-bharathkumar points