These are chat archives for FreeCodeCamp/HelpJavaScript

14th
Jan 2017
Nick Kuhle
@nickkuhle
Jan 14 2017 00:01 UTC
the error is "unknown error acquiring position" @moigithub
Error (2)
KayTueso
@KayTueso
Jan 14 2017 00:01 UTC
Can someone help explain why this function doesn't work correctly?
'''
function compareNumbers(a, b) {
return a - b;
}
arr.sort(compareNumbers());
return arr;
'''
As I understand, this should sort the numbers in ascending order. However, passing the array [5, 3, 20, 3] to this function returns it as [20, 3, 3, 5]
CamperBot
@camperbot
Jan 14 2017 00:01 UTC
:bulb: to format code use backticks! ``` more info
Moisés Man
@moigithub
Jan 14 2017 00:02 UTC
maybe this helps ?? domoritz/leaflet-locatecontrol#154 @nickkuhle
carlos
@carlitron5000
Jan 14 2017 00:03 UTC
Good afternoon everybody!
Nick Kuhle
@nickkuhle
Jan 14 2017 00:04 UTC
Thank you @moigithub
CamperBot
@camperbot
Jan 14 2017 00:04 UTC
nickkuhle sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2482 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Jan 14 2017 00:04 UTC
@KayTueso sort requires a function
if u add a set of () to ur funciton u CALLING/executing it making it return a result..
u need to pass a function itself
remove the () on ur sort callback function
KayTueso
@KayTueso
Jan 14 2017 00:05 UTC
Thanks! @moigithub
CamperBot
@camperbot
Jan 14 2017 00:05 UTC
kaytueso sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2483 | @moigithub |http://www.freecodecamp.com/moigithub
Eric
@eherod
Jan 14 2017 00:10 UTC
Hello everyone
Nick Kuhle
@nickkuhle
Jan 14 2017 00:10 UTC
@moigithub Thank you!!!
CamperBot
@camperbot
Jan 14 2017 00:10 UTC
nickkuhle sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: nickkuhle already gave moigithub points
Nick Kuhle
@nickkuhle
Jan 14 2017 00:10 UTC
it worked
Pieter Stokkink
@forkerino
Jan 14 2017 00:10 UTC
hi Eric!
Nick Kuhle
@nickkuhle
Jan 14 2017 00:10 UTC
I had to change my geo.wifi.uri
in my browser settings
Eric
@eherod
Jan 14 2017 00:11 UTC
I'm working through the javascript section and I am kind of stumped on one of the exercises. Anyone interested in fielding a question?
Pieter Stokkink
@forkerino
Jan 14 2017 00:11 UTC
shoot
Not sure what they are asking me to do
Moisés Man
@moigithub
Jan 14 2017 00:12 UTC
@nickkuhle probably ur browser updated and messed up the settings :)
Praveen Kaushik
@kaushikpraveen
Jan 14 2017 00:12 UTC
hey, can anyone look in this code & tell exactly whats wrong
Although i've already solved in other 2 ways but i'm really want it to work with this-
function lookUpProfile(firstName, prop){
// Only change code below this line

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

      }
      else 
        return "No such property";
    }
    else{  
    return"No such contact";
    }
  }
Pieter Stokkink
@forkerino
Jan 14 2017 00:12 UTC
They are asking you something very similar to the previous exercise. You have to use -- to decrement your variable myVar.
@eherod
@kaushikpraveen there is no property "prop". You have to use bracket notation
Moisés Man
@moigithub
Jan 14 2017 00:13 UTC
prop is variable.. NO dot notation @kaushikpraveen
Joseph
@revisualize
Jan 14 2017 00:13 UTC
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];
@kaushikpraveen That loop will only loop ONCE.
You're returning no contact too early.
E-Tank
@E-Tank
Jan 14 2017 00:14 UTC
@a-dabrowski Sorry, I got distracted at the wrong time.

function rot13(str) { // LBH QVQ VG!
  var translatedArray = [];
  var checkingArray = str.split('');
  var checkingChar;
  var actualChar;
  for(var i = 0; i < checkingArray.length; i++){
    checkingChar = checkingArray[i].charCodeAt();
    actualChar = checkingChar + 13;
    translatedArray = actualChar.push();
  }
  return checkingArray;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
did i do gd guys ?
Joseph
@revisualize
Jan 14 2017 00:14 UTC

@eherod The opposite of this:

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

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

oshane-willy99
@oshane-willy99
Jan 14 2017 00:17 UTC
Anyone care to help me with the Counting Cards problem
Praveen Kaushik
@kaushikpraveen
Jan 14 2017 00:17 UTC
Finally got that right..Ty Everyone
mark-almakhalas
@mark-almakhalas
Jan 14 2017 00:18 UTC
?
help
Jason Luboff
@JLuboff
Jan 14 2017 00:18 UTC
Post your code and your question.
oshane-willy99
@oshane-willy99
Jan 14 2017 00:18 UTC
Anyone care to help me with the Counting Cards problem
Johnny
@JohnnyBizzel
Jan 14 2017 00:19 UTC

@E-Tank

@a-dabrowski Sorry, I got distracted at the wrong time.

function rot13(str) { // LBH QVQ VG!
  var translatedArray = [];
  var checkingArray = str.split('');
  var checkingChar;
  var actualChar;
  for(var i = 0; i < checkingArray.length; i++){
    checkingChar = checkingArray[i].charCodeAt();
    actualChar = checkingChar + 13;
    translatedArray = actualChar.push();
  }
  return checkingArray;
}
rot13("SERR PBQR PNZC");

I can see an error in this code

Pieter Stokkink
@forkerino
Jan 14 2017 00:20 UTC
@E-Tank you need to check if the character is actually a letter, now you also add 13 to the charcode of spaces, or punctuation. Other than that, what do you think will happen if you add 13 to, for example 'Z'? How will that turn out? In the instructions they explain what you need to do with those.
Eric
@eherod
Jan 14 2017 00:20 UTC
hmm...
Johnny
@JohnnyBizzel
Jan 14 2017 00:20 UTC
@oshane-willy99 Yes sir, use a Switch case statement with fall through (I think it's called)
Eric
@eherod
Jan 14 2017 00:20 UTC
so this is what I wrote: var myvar = 87;
myvar++;
where did I go wrong?
Jason Luboff
@JLuboff
Jan 14 2017 00:20 UTC
@eherod ++ is to increment -- is to decrement
Johnny
@JohnnyBizzel
Jan 14 2017 00:21 UTC
@eherod Well if you want myvar to = 88
Eric
@eherod
Jan 14 2017 00:21 UTC
@JLuboff thanks, I want to increment
CamperBot
@camperbot
Jan 14 2017 00:21 UTC
eherod sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:cookie: 632 | @jluboff |http://www.freecodecamp.com/jluboff
Pieter Stokkink
@forkerino
Jan 14 2017 00:21 UTC
@eherod I think in the exercise it is spelled myVar
Eric
@eherod
Jan 14 2017 00:21 UTC
I want myvar to =88
Johnny
@JohnnyBizzel
Jan 14 2017 00:21 UTC
@eherod myvar or myVar?
Jason Luboff
@JLuboff
Jan 14 2017 00:21 UTC
@eherod If that is not passing, it is due to your variable name. It is case sensitive in all challenges
Johnny
@JohnnyBizzel
Jan 14 2017 00:21 UTC
@forkerino SNAP!
oshane-willy99
@oshane-willy99
Jan 14 2017 00:22 UTC
@JohnnyBizzel @JohnnyBizzel i did try a switch statement but i dont know where i went wrong
Pieter Stokkink
@forkerino
Jan 14 2017 00:22 UTC
@JohnnyBizzel I've got the power!
Eric
@eherod
Jan 14 2017 00:22 UTC
lol @forkerino thanks
CamperBot
@camperbot
Jan 14 2017 00:22 UTC
eherod sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:cookie: 640 | @forkerino |http://www.freecodecamp.com/forkerino
E-Tank
@E-Tank
Jan 14 2017 00:22 UTC
@JohnnyBizzel Yeah, I know there's an error. I'm just trying to figure out if this is even the right way to go. @forkerino So I need to go into regular expressions to ensure that it's just those?
Johnny
@JohnnyBizzel
Jan 14 2017 00:22 UTC
@forkerino I know :D :rage1:
Pieter Stokkink
@forkerino
Jan 14 2017 00:22 UTC
@E-Tank No, you can do it based on charcode.
Jason Luboff
@JLuboff
Jan 14 2017 00:22 UTC
@oshane-willy99 Post your code..its hard to help when we can't see whats wrong
Owolabi
@owolabiezekiel
Jan 14 2017 00:23 UTC
can someone here help
oshane-willy99
@oshane-willy99
Jan 14 2017 00:23 UTC

var count = 0;

function cc(card) {
// Only change code below this line
count = 0;
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;
// 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');

Johnny
@JohnnyBizzel
Jan 14 2017 00:24 UTC
@E-Tank First issue is fix the push statement to : translatedArray.push(actualChar);
@oshane-willy99 Not working? Why?
E-Tank
@E-Tank
Jan 14 2017 00:25 UTC
Returns a bunch of digits. . .So I need to take those digits and turn them back into characters.
And also get the spaces back. =\
Owolabi
@owolabiezekiel
Jan 14 2017 00:25 UTC

i am having problem with 251
You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.
here is my latest version of the solution but it still isnt working
function destroyer(arr) {
// Remove all the values
var oldArray = arr[0];
var removeArr = [];
for(var i = 1; i < arr.length; i++) {
removeArr.push(arr[i]);
}

return oldArray;
}

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

Help please

Johnny
@JohnnyBizzel
Jan 14 2017 00:25 UTC
@E-Tank Yes sir
Pieter Stokkink
@forkerino
Jan 14 2017 00:25 UTC

And also get the spaces back. =\

Better to not change them at all, @E-Tank

oshane-willy99
@oshane-willy99
Jan 14 2017 00:25 UTC
@JohnnyBizzel the output not meeting the criteria ig
Jason Luboff
@JLuboff
Jan 14 2017 00:26 UTC
@oshane-willy99 Don't return count. You don't need the case for 7,8,9 and in fact, thats skewing your count becuase you're telling it to reset to 0
John Paul Penaloza
@johnpyp
Jan 14 2017 00:27 UTC

Hey guys, trying to call an API, but it seems the geolocation API isn't working. Here is my code for this part of the project:

navigator.geolocation.getCurrentPosition(function(pos) {
      crd = pos.coords;
    });
    $.getJSON("https://api.darksky.net/forecast/41f76a34eacc9e318e52e607d8d1bffe/" + crd.latitude + "," + crd.longitude + "?callback=?",

The top should make crd.latitude return current latitude. But in the console it says crd.latitude is undefined.

Pieter Stokkink
@forkerino
Jan 14 2017 00:27 UTC
Ok, have a fun weekend, y'all.
Jason Luboff
@JLuboff
Jan 14 2017 00:27 UTC
@oshane-willy99 After your switch statement, you need to test and return wether you bet or hold
Pieter Stokkink
@forkerino
Jan 14 2017 00:27 UTC
Night night.
Johnny
@JohnnyBizzel
Jan 14 2017 00:27 UTC
@forkerino Good night ;)
Jason Luboff
@JLuboff
Jan 14 2017 00:28 UTC
@forkerino See ya have a good weekend
Pieter Stokkink
@forkerino
Jan 14 2017 00:28 UTC
@JohnnyBizzel Thanks, you too!
CamperBot
@camperbot
Jan 14 2017 00:28 UTC
forkerino sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1123 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Jan 14 2017 00:28 UTC
@oshane-willy99 What @JLuboff said!
Owolabi
@owolabiezekiel
Jan 14 2017 00:28 UTC
hi here
oshane-willy99
@oshane-willy99
Jan 14 2017 00:28 UTC
@JLuboff with an if statement right i tried that as well
Jason Luboff
@JLuboff
Jan 14 2017 00:28 UTC
@johnpyp If you're using codepen, make sure codepen is running over https meaning https://codepen.io/.... should be in your browser url field
@oshane-willy99 Yes, an if statement would work
oshane-willy99
@oshane-willy99
Jan 14 2017 00:29 UTC
thats what i used
i deleted the if statement
Jason Luboff
@JLuboff
Jan 14 2017 00:29 UTC
@oshane-willy99 Well redo it :)
John Paul Penaloza
@johnpyp
Jan 14 2017 00:29 UTC
@JLuboff Ya I know. Geolocation was working when I was using a button. Right now, I am doing it under ready document
Jason Luboff
@JLuboff
Jan 14 2017 00:29 UTC
@oshane-willy99 Also, move your var count = 0; inside of your function instead of outside
@johnpyp It should pop up when you run the page then? Or post a link and I can see
John Paul Penaloza
@johnpyp
Jan 14 2017 00:30 UTC
@JLuboff Alright. It is a little crude and messy right now as I am testing things to make it work.
pops716
@pops716
Jan 14 2017 00:31 UTC
I am on the sum all odd fibonacci numbers and I have created an infinite loop
I tried refreshing the site, but it still is stuck
I also tried closing the browser and opening the algorithm but to no avail
Someone please help me
Jason Luboff
@JLuboff
Jan 14 2017 00:32 UTC
@johnpyp It did prompt me for Geolocation (in firefox). Just wondering, why 4 API calls?
grantknaver
@grantknaver
Jan 14 2017 00:33 UTC
why is this than infinite loop I do not understand
for(var i = 1; i < toArray.length; i++){
  if (toArray[i].match(vowels)){
  var upToVowel = str.slice(1, i);
  var afterVowel = str.slice(i);
    alert(afterVowel);
  }    
}
Jason Luboff
@JLuboff
Jan 14 2017 00:33 UTC
@pops716 An inifinite loop should stop running after you close the browser...but if its not...try clearing your browsers cache/history
John Paul Penaloza
@johnpyp
Jan 14 2017 00:33 UTC
@JLuboff Those in other functions, but they aren't being called. Just wanted to keep them around if I needed to copy/paste. I had them all in seperate functions, but I've been trying everything so I put everything in the "gettingLocation()" function
Jason Luboff
@JLuboff
Jan 14 2017 00:34 UTC
Ah
pops716
@pops716
Jan 14 2017 00:34 UTC
Ok thanks @JLuboff
CamperBot
@camperbot
Jan 14 2017 00:34 UTC
pops716 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:cookie: 633 | @jluboff |http://www.freecodecamp.com/jluboff
John Paul Penaloza
@johnpyp
Jan 14 2017 00:34 UTC
@JLuboff and ya, I got a prompt too. I don't know why it won't work though
Jason Luboff
@JLuboff
Jan 14 2017 00:35 UTC
@johnpyp I see in the console its complaining about "crd is not defined"
oshane-willy99
@oshane-willy99
Jan 14 2017 00:35 UTC
@JLuboff i did the if statements ....
John Paul Penaloza
@johnpyp
Jan 14 2017 00:35 UTC
@JLuboff Yup. That is the problem I identified, but I don't know why
grantknaver
@grantknaver
Jan 14 2017 00:35 UTC
any ideas
Jason Luboff
@JLuboff
Jan 14 2017 00:37 UTC
@johnpyp The first time I see crd, its on line 25, with no var. I next see it in the JSON call on line 27, but I don't believe the call as access to that variable since its a local variable to the geolocation call. Try encapsulating the JSON call in the geolocation call?
@oshane-willy99 Ok...show what you have now..
Krzysztof Borowy
@Krizzu
Jan 14 2017 00:37 UTC
Hey, just got front end cert, woop woop :D
Jason Luboff
@JLuboff
Jan 14 2017 00:38 UTC
@Krizzu Awesome, congratulations!
Alex
@Joshua-A-Smith
Jan 14 2017 00:38 UTC
@Krizzu Grats
Krzysztof Borowy
@Krizzu
Jan 14 2017 00:38 UTC
Thank You :)
John Paul Penaloza
@johnpyp
Jan 14 2017 00:38 UTC
@JLuboff with no var doesn't that make it a global
Krzysztof Borowy
@Krizzu
Jan 14 2017 00:39 UTC
@johnpyp that's true
Alex
@Joshua-A-Smith
Jan 14 2017 00:40 UTC

So this is my code


function chainToSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch(val) {
    case "bob":
      answer = "Marley";
      break;
    case 42:
      answer = "The Answer";
      break;
    case 1:
      answer = "There is no #1";
      break;
    case 99:
      answer = "Missed me by this much!";
      break;
    case 7:
      answer = "Ate Nine";
  break; 
    case "John":
      answer = "";
      break;
    case 156:
      answer = "";
      break;


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

// Change this value to test
chainToSwitch(7);

Yet to the left its says "You should not use any else statements anywhere in the editor
You should not use any if statements anywhere in the editor" How am I wrong here?

Tyler Moeller
@TylerMoeller
Jan 14 2017 00:40 UTC

@johnpyp One issue is that you're trying to do something like this:

<button onclick="b()">click me!</button>

And JS like this:

function a() {
  function b() {
    console.log('hello')
  }
}

Which will result in the error b is not defined

John Paul Penaloza
@johnpyp
Jan 14 2017 00:41 UTC
Is that what I'm doing? I'm calling gettingLocation which is the top function other than document.ready
Tyler Moeller
@TylerMoeller
Jan 14 2017 00:42 UTC
Right, it's inside another function - document.ready(function()
John Paul Penaloza
@johnpyp
Jan 14 2017 00:42 UTC
Also, my goal right now is to have it run the function on start
so it should work, no?
The button isn't my goal right now. As I said, messy
Tyler Moeller
@TylerMoeller
Jan 14 2017 00:42 UTC
You don't need all your code inside document.ready - just the code that needs to run when the document is ready.
In your case, it's click handlers and gettingLocation();
Jason Luboff
@JLuboff
Jan 14 2017 00:43 UTC
@Joshua-A-Smith Have your return outside of your switch statement
Alex
@Joshua-A-Smith
Jan 14 2017 00:45 UTC
@JLuboff
Thanks a million!
CamperBot
@camperbot
Jan 14 2017 00:45 UTC
joshua-a-smith sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:cookie: 634 | @jluboff |http://www.freecodecamp.com/jluboff
Zaluth
@Zaluth
Jan 14 2017 00:47 UTC
convert html elements challenge, how do i find all elements that are not alphanumeric or spaces with regex? my code returns ["< ] (with a space on the right)
function convertHTML(str) {
  var regex = /\W\s/g;
  var search = regex.exec(str);

  return search;
}

convertHTML("Hamburgers < Pizza < Tacos");
["< "] *
oshane-willy99
@oshane-willy99
Jan 14 2017 00:48 UTC

@JLuboff function cc(card) {
// Only change code below this line
count = 0;
switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
count ++;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count --;
break;
}
if (count > 0) {
return count + " Bet";

}
if (count <= 0) {
return count + " Hold";
}

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(3); cc(7); cc("Q"); cc(8); cc("A");

Jason Luboff
@JLuboff
Jan 14 2017 00:49 UTC
@oshane-willy99 You need var in front of count = 0
Jonathan Pérez
@jopcode
Jan 14 2017 00:49 UTC
Hello, any can helpme with phaser?
Jason Luboff
@JLuboff
Jan 14 2017 00:49 UTC
@oshane-willy99 And you don't need the return card at the end
John Paul Penaloza
@johnpyp
Jan 14 2017 00:49 UTC
@TylerMoeller alright I'll try that
oshane-willy99
@oshane-willy99
Jan 14 2017 00:49 UTC
@JLuboff so what tshould i output?
Tyler Moeller
@TylerMoeller
Jan 14 2017 00:50 UTC
@johnpyp The next issue you'll see is that crd isn't defined. navigator.geolocation takes some time to get the location, so by the time your other functions run, crd hasn't been set yet.
You'll need to pass that variable to the functions that require it
Jason Luboff
@JLuboff
Jan 14 2017 00:50 UTC
@oshane-willy99 Your output is in your if statements
oshane-willy99
@oshane-willy99
Jan 14 2017 00:50 UTC
ok ill try to run it
John Paul Penaloza
@johnpyp
Jan 14 2017 00:50 UTC
@TylerMoeller How would I do that?
Tyler Moeller
@TylerMoeller
Jan 14 2017 00:52 UTC
@johnpyp Kind of like this (for example):
  function gettingLocation() {
    navigator.geolocation.getCurrentPosition(function(pos) {
      getWeather(pos);
    });
  }
  function getWeather(pos) {
    //make all your getJSON calls to APIs that need your location
  }
oshane-willy99
@oshane-willy99
Jan 14 2017 00:52 UTC
@JLuboff didnt work
Zaluth
@Zaluth
Jan 14 2017 00:54 UTC
convert html elements challenge, how do i find all elements that are not alphanumeric or spaces with regex? returns ["< "] (with a space on the right)
function convertHTML(str) {
  var regex = /\W\s/g;
  var search = regex.exec(str);

  return search;
}

convertHTML("Hamburgers < Pizza < Tacos");
Joseph
@revisualize
Jan 14 2017 00:54 UTC
@oshane-willy99 You need to REMOVE count = 0; from your function. count is supposed to be a GLOBAL variable.
@JLuboff --^
With the FCC editor Global variables persist between function runs.
John Paul Penaloza
@johnpyp
Jan 14 2017 00:55 UTC
@TylerMoeller I don't understand what that does. Why put getWeather in the gettingLocation function
Jason Luboff
@JLuboff
Jan 14 2017 00:55 UTC
@revisualize Thats what happens when you don't look at the instructions :laughing: That and its 5 minutes to the weekend
@revisualize Thanks for catching that
CamperBot
@camperbot
Jan 14 2017 00:55 UTC
jluboff sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2962 | @revisualize |http://www.freecodecamp.com/revisualize
Tyler Moeller
@TylerMoeller
Jan 14 2017 00:55 UTC
@johnpyp It transfers all the data from navigator.geolocation to your getWeather function so you can use the latitude and longitude to get the weather
Joseph
@revisualize
Jan 14 2017 00:55 UTC
I was at work from 8am to 5pm then 1045pm to 230am and back at 9am this morning.
My world was slowly crashing.
It sucked.
Jason Luboff
@JLuboff
Jan 14 2017 00:56 UTC
Ouch. Server/network maintenence?
John Paul Penaloza
@johnpyp
Jan 14 2017 00:56 UTC
@TylerMoeller oh cool
Joseph
@revisualize
Jan 14 2017 00:56 UTC
@JLuboff Unscheduled Urgent "maintenance"
oshane-willy99
@oshane-willy99
Jan 14 2017 00:56 UTC
@revisualize thanks
CamperBot
@camperbot
Jan 14 2017 00:56 UTC
oshane-willy99 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2963 | @revisualize |http://www.freecodecamp.com/revisualize
oshane-willy99
@oshane-willy99
Jan 14 2017 00:57 UTC
@JLuboff thanks as well
CamperBot
@camperbot
Jan 14 2017 00:57 UTC
oshane-willy99 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:cookie: 635 | @jluboff |http://www.freecodecamp.com/jluboff
Tyler Moeller
@TylerMoeller
Jan 14 2017 00:57 UTC
@johnpyp Maybe this is clearer:
function a() {
  var myVar = "hello world";
  sayHello(myVar);
}

function sayHello(string) {
  console.log(string) // this outputs "hello world"
}
a();
Jason Luboff
@JLuboff
Jan 14 2017 00:57 UTC
@revisualize Ah. Luckily I don't get called in for those...just for the day time ones. We had a I think it was 40 hour power outage at the office that I was going to get thrown into rotation, but by the time I would have to come in (2? am) power was back
Nathan Classen
@NathanHayez
Jan 14 2017 00:58 UTC
This is working almost perfectly but I want it to return "" if the given num value is negative, but it doesnt. Any suggestions? The task seems pretty straightforward.

function repeatStringNumTimes(str, num) {
var strR = str.repeat(num);
  if (num < 0 ){
    return "";
  }

  return strR;
}

repeatStringNumTimes("abc", 3);
Joseph
@revisualize
Jan 14 2017 00:58 UTC
@JLuboff The "maintenance" got scheduled the instance the VM Host that stores the VM for our backup services went .. Offline.
Jason Luboff
@JLuboff
Jan 14 2017 00:58 UTC
@revisualize We've had that happen too lol
Jonathan Pérez
@jopcode
Jan 14 2017 00:58 UTC
any with experience in phaserJS(game framework) can help me pls?
Jason Luboff
@JLuboff
Jan 14 2017 00:59 UTC
Alright...time to go home. Everyone have a nice weekend
John Paul Penaloza
@johnpyp
Jan 14 2017 00:59 UTC
@TylerMoeller ah
Ya I understand
Thanks
Joseph
@revisualize
Jan 14 2017 00:59 UTC
TIME TO GO HOME! YAY!
revisualize @revisualize :runner: :dash: :dash: :dash: :dash: :dash: :boom:
Will
@wwhite2011
Jan 14 2017 01:00 UTC

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

// Your code above this line
return result;
}

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

what is this question asking for?
John Paul Penaloza
@johnpyp
Jan 14 2017 01:02 UTC
@TylerMoeller lemme see if it works.
Tyler Moeller
@TylerMoeller
Jan 14 2017 01:03 UTC
@johnpyp You have a few getJSON calls, all of which take some time to go out to a server and return data. You'll likely have to do some code restructuring to get variables passed along correctly.
grantknaver
@grantknaver
Jan 14 2017 01:03 UTC
how is this an infinite loop

function translatePigLatin(str) {
  var toArray = Array.from(str);
  var vowels= /[aeiou]/g;
  var conversion = toArray.join('');

if(str[0].match(vowels)){
  var vowelEnding = str += "way";
  return vowelEnding;
}
for(var i = 1; i < str.length; i++){
  if(str[i].search(vowels)){
    var upTo = str.substr(0, i);
    var after = str.slice(i);
    var answer = after + upTo + "ay";
    alert(answer);
  }
}

}

translatePigLatin("consonant");
John Paul Penaloza
@johnpyp
Jan 14 2017 01:03 UTC
@TylerMoeller alright
Chris Burros
@cburros
Jan 14 2017 01:05 UTC

Okay, so I am on Chunky Monkey Algorithm Challenge. This code works in my machine but does not work on Free Code Camp's challenge for any of the tests. Perhaps I am missing something: ``` function chunk(arr, size) {
// Break it up.
var newArr = [];

var chunkArr = [];
var count = size;

for (var i = 0; i < arr.length; i) {
    chunkArr.push(arr.slice(i, count));
   i += size;
    count += size; 
    if (count > arr.length) {
        count = arr.length;
    }

} return chunkArr;

} ```

sorry
screwed up my code post but the body of the function is in the post
function chunk(arr, size) {
  // Break it up.
  var newArr = [];

    var chunkArr = [];
    var count = size;

    for (var i = 0; i < arr.length; i) {
        chunkArr.push(arr.slice(i, count));
       i += size;
        count += size; 
        if (count > arr.length) {
            count = arr.length;
        }

    } return chunkArr;
}
Nevermind. I had screwed up the function name and call.
John Paul Penaloza
@johnpyp
Jan 14 2017 01:10 UTC
@TylerMoeller It works perfect! Thanks so much :D
CamperBot
@camperbot
Jan 14 2017 01:10 UTC
johnpyp sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1316 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
Tyler Moeller
@TylerMoeller
Jan 14 2017 01:10 UTC
Glad that helped :+1:
Adel
@AdelMahjoub
Jan 14 2017 01:15 UTC
trying to mime flies or bees movements using Lissajous Curves but this is what I get https://codepen.io/SultanCodeCamper/full/rjLrvY/
CherryPlaysRoblox
@CherryPlaysRoblox1
Jan 14 2017 01:16 UTC
Could someone help me? I don't get Reverse a String
Could someone help me? I don't get Reverse a String
Alessandro
@Riverino
Jan 14 2017 01:31 UTC
Hi guys, I'm having troubles with the challenge "Manipulate Arrays With Pop". my code is: "var removedFromMyArray = myArray.pop();". Apparently .pop() only takes out the last element. But the challenge does not explain how to take to elements out of the array. Any help? thanks.
Ken Haduch
@khaduch
Jan 14 2017 01:33 UTC
@CherryPlaysRoblox1 - what don't you get about it? What have you tried so far?
@AdelMahjoub - that looks pretty cool! I get some "stuttering" on my computer - stopping briefly every once in a while, but it's a neat effect...
CherryPlaysRoblox
@CherryPlaysRoblox1
Jan 14 2017 01:34 UTC
@khaduch I may have forgotten to use the join thing
Ken Haduch
@khaduch
Jan 14 2017 01:35 UTC
@CherryPlaysRoblox1 - you need that, for sure!
@Riverino - .pop should do it, just as you showed. It removes the element from the array, and returns the removed element to the variable. Are you failing any tests?
Adel
@AdelMahjoub
Jan 14 2017 01:36 UTC
@khaduch I'm searching for a way to make each object movement not synchronized with the others, the for loop made the movements synchronized
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 01:38 UTC
does anyone know how to check to see if a number is negative using an if statement?
i have this code..
CherryPlaysRoblox
@CherryPlaysRoblox1
Jan 14 2017 01:38 UTC
@khaduch But the instructions for Factorialize a Number aren't clear to me. Could
you help?
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 01:38 UTC
function sumDigits(num) {
  // your code here
  var digits = (num).toString();
  var total = 0;
  for(var i = 0; i < digits.length; i++){
      if(Number(digits[0]) === -Number(digits[0])){
          total-=Number(digits[0]);
      }
      else{
      total+= Number(digits[i]);
     }
  }
  return total;
}

sumDigits(-316);
Joseph
@revisualize
Jan 14 2017 01:39 UTC

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

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

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

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

Randy Goldsmith
@Dueldrawer8
Jan 14 2017 01:39 UTC
i need to check to see if the first digit in a string number is negative, and if it is, i need to convert it from a string to a negative number and subtract it from total;
Zaluth
@Zaluth
Jan 14 2017 01:41 UTC
convert html elements challenge, how do i find all elements that are not alphanumeric or spaces with regex? returns ["< "] (with a space on the right)
function convertHTML(str) {
  var regex = /\W\s/g;
  var search = regex.exec(str);

  return search;
}

convertHTML("Hamburgers < Pizza < Tacos");
Joseph
@revisualize
Jan 14 2017 01:41 UTC
@Zaluth You can't use a simple regex.
Zaluth
@Zaluth
Jan 14 2017 01:41 UTC
@revisualize what do you mean with simple?
Joseph
@revisualize
Jan 14 2017 01:42 UTC
\W doesn't work.
Zaluth
@Zaluth
Jan 14 2017 01:42 UTC
@revisualize why?
Joseph
@revisualize
Jan 14 2017 01:42 UTC
Because you need to replace the < with something.
oshane-willy99
@oshane-willy99
Jan 14 2017 01:42 UTC

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

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

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

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

Joseph
@revisualize
Jan 14 2017 01:43 UTC
Each <, > and whatever else is unique
Zaluth
@Zaluth
Jan 14 2017 01:43 UTC
@revisualize shoul i use replace?
Joseph
@revisualize
Jan 14 2017 01:43 UTC
d @oshane-willy99 It tells you in the instructions. your object should be named lookup
@Zaluth Yes.
@Zaluth I did.
Zaluth
@Zaluth
Jan 14 2017 01:44 UTC
@revisualize but then how do i select the characters i want?
Joseph
@revisualize
Jan 14 2017 01:44 UTC
I used .replace() and passed it a function.
oshane-willy99
@oshane-willy99
Jan 14 2017 01:44 UTC
@revisualize yeah i named it lookup
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 01:44 UTC
anyone?
Joseph
@revisualize
Jan 14 2017 01:44 UTC
@oshane-willy99 You did?
oshane-willy99
@oshane-willy99
Jan 14 2017 01:44 UTC
@revisualize yeah
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 01:44 UTC
var digits = (num).toString();
  var total = 0;
  for(var i = 0; i < digits.length; i++){
      if(digits[0] === '-'){
          total-=Number(digits[0]);
      }
      else{
      total+= Number(digits[i]);
why wont the if statement work?
Joseph
@revisualize
Jan 14 2017 01:44 UTC
@oshane-willy99 Now finish the lesson.
What's your function?
Your function has declared and initialized the variable result to "". You are not modifying result and your function is returning result. Ergo, you're returning "". You need to modify result to be the value of the property from the object that you created.
Ken Haduch
@khaduch
Jan 14 2017 01:46 UTC
@CherryPlaysRoblox1 - factorialize shouldn't be too bad - what have you got with it, or what don't you understand about it?
CherryPlaysRoblox
@CherryPlaysRoblox1
Jan 14 2017 01:47 UTC
@khaduch I don't get what to do
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 01:47 UTC
hmmm
oshane-willy99
@oshane-willy99
Jan 14 2017 01:48 UTC

@revisualize // Setup
function phoneticLookup(val) {
var result = lookup;

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

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

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

Ken Haduch
@khaduch
Jan 14 2017 01:49 UTC

@CherryPlaysRoblox1 - these are the instructions:

Factorialize a Number 
Return the factorial of the provided integer.

If the integer is represented with the letter n, a factorial is the product of all positive integers less than or equal to n.

Factorials are often represented with the shorthand notation n!

For example: 5! = 1 * 2 * 3 * 4 * 5 = 120

As you can see from the example, 5! is just the product of the values between 1 and 5, inclusive, multiplied times each other. If you can generate a for loop that will generate the numbers, it is a simple matter of multiplying them together. The special cases are 0! and 1! both equal 1.

Stephen James
@sjames1958gm
Jan 14 2017 01:50 UTC
@oshane-willy99 Now use lookup and val to set result.
Joseph
@revisualize
Jan 14 2017 01:50 UTC
@oshane-willy99 Your function has declared and initialized the variable result to "". You are not modifying result and your function is returning result. Ergo, you're returning "". You need to modify result to be the value of the property from the object that you created.
Ken Haduch
@khaduch
Jan 14 2017 01:50 UTC
@Dueldrawer8 - hello.
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 01:51 UTC
@khaduch hey whats up
Joseph
@revisualize
Jan 14 2017 01:51 UTC
@oshane-willy99 This is incorrect.. var result = lookup; it should be var result = "";
Ken Haduch
@khaduch
Jan 14 2017 01:51 UTC
@Dueldrawer8 - is that a freecodecamp challenge? It doesn't look familiar to me?
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 01:51 UTC
function sumDigits(num) {
  // your code here
  var digits = (num).toString();
  var total = 0;
  for(var i = 0; i < digits.length; i++){
      if(digits[0] === '-'){
          total+= -Number(digits[1]);
      }
      else{
      total+= Number(digits[i]);
     }
  }
  return total;
}
anyone know why my if statement will not subtract the first number?
and no its not.. im doing a study guide with a bunch of wierd algorithms
oshane-willy99
@oshane-willy99
Jan 14 2017 01:52 UTC
@revisualize yeah i changed it back
Stephen James
@sjames1958gm
Jan 14 2017 01:52 UTC
@Dueldrawer8 What is the requirement for this function?
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 01:53 UTC
sumDigits will return the sum of all digits in a number
if it is a negative number, i need to only count the first digit as negative
Stephen James
@sjames1958gm
Jan 14 2017 01:53 UTC
@Dueldrawer8 Isn't your function just going to use digits[1] every time if digits[0] is '-'
that will always be true
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 01:53 UTC
so sumDigits(1148) works and equals 14
Ken Haduch
@khaduch
Jan 14 2017 01:54 UTC
@Dueldrawer8 - you have to figure out how to skip the first number if you deal with it as a negative value, wouldn't you?
not that that is the only problem that might be there?
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 01:55 UTC
@khaduch @sjames1958gm true
Stephen James
@sjames1958gm
Jan 14 2017 01:56 UTC
@Dueldrawer8 I would look at the first character before the loop and start the loop at 1 if digits[0] is '-'
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 01:56 UTC
so could i use if(digits[i]) instead?
hm doesnt work
@sjames1958gm ill try that
Ken Haduch
@khaduch
Jan 14 2017 01:58 UTC
@Dueldrawer8 - and you are always using digits[0] in your test, so you will always be subtracting digits[1] - seems like you have to get that out of the loop, or check that you are looking at the first digits and handle that as a special case?
Stephen James
@sjames1958gm
Jan 14 2017 01:59 UTC
@Dueldrawer8 you could do something like
var j = digits[0] === '-' ? 1 : 0;
Adel
@AdelMahjoub
Jan 14 2017 01:59 UTC
now it looks more like real flies movements around something https://codepen.io/SultanCodeCamper/pen/rjLrvY?editors=0010
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:00 UTC
@sjames1958gm not familar with the ternary operator
if digit[0] equals a hyphen.. then its 1 else 0?
Ken Haduch
@khaduch
Jan 14 2017 02:01 UTC
@AdelMahjoub - nice!
Stephen James
@sjames1958gm
Jan 14 2017 02:01 UTC
@Dueldrawer8 that sets j based on digits[0] === '-'
@AdelMahjoub cool
Adel
@AdelMahjoub
Jan 14 2017 02:02 UTC
@khaduch thanks, the problem was the starting angle, should be different for eeach object
CamperBot
@camperbot
Jan 14 2017 02:02 UTC
adelmahjoub sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2271 | @khaduch |http://www.freecodecamp.com/khaduch
Adel
@AdelMahjoub
Jan 14 2017 02:02 UTC
@sjames1958gm thanks
CamperBot
@camperbot
Jan 14 2017 02:02 UTC
adelmahjoub sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5322 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Joseph
@revisualize
Jan 14 2017 02:03 UTC
ACK!
oshane-willy99
@oshane-willy99
Jan 14 2017 02:03 UTC
'result' = 'lookup.val;'
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:03 UTC
@sjames1958gm
if(digits[0] === '-'){
      total-= Number(digits[1])
  }
  else{
  for(var i = 2; i < digits.length; i++){
      total+= Number(digits[i]);
     }
Stephen James
@sjames1958gm
Jan 14 2017 02:03 UTC
@Dueldrawer8
var mult = 1;
var i = 0;
if (digits[0] === '-') {
   mult = -1;
   i = 1;
}
for (; i < digits.length; i++) {
   total += Number(digits[i]);
}
total *= mult;
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:03 UTC
started before loop to check if its negative and then subtract that from total and then i looped through starting at 2
index 2
oshane-willy99
@oshane-willy99
Jan 14 2017 02:07 UTC

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

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

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

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

WHATS WRONG.PLEASE HELP
Stephen James
@sjames1958gm
Jan 14 2017 02:07 UTC
@oshane-willy99 .val does not work because val is a variable
Jenell Pizarro
@nellarro
Jan 14 2017 02:08 UTC
@oshane-willy99 What are the directions?
oshane-willy99
@oshane-willy99
Jan 14 2017 02:08 UTC
@sjames1958gm yh i realised a little ago...thx
Stephen James
@sjames1958gm
Jan 14 2017 02:08 UTC
@oshane-willy99 :+1:
oshane-willy99
@oshane-willy99
Jan 14 2017 02:09 UTC
but still dont knw what to do....lol
Jenell Pizarro
@nellarro
Jan 14 2017 02:09 UTC
@oshane-willy99 Are you trying to test to see if phoneticLookup("charlie") matches anything inside the lookup variable?
oshane-willy99
@oshane-willy99
Jan 14 2017 02:10 UTC
@nellarro yes
@nellarro lookup object
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:11 UTC
@sjames1958gm your setting mult to -1.. and i to 1.. i dont get how that subtracts the first digit from the rest of the digits
Stephen James
@sjames1958gm
Jan 14 2017 02:12 UTC
@Dueldrawer8 Maybe I misunderstood - so if it is minus then you subtract the first digit?
John Paul Penaloza
@johnpyp
Jan 14 2017 02:12 UTC
Hey guys, if I have a full-sized image with icons (for example these: http://d3stroy.deviantart.com/art/Weezle-Weather-Icons-187306753), how would I make it so that based on a variable, I would take certain icons from the full size image?
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:13 UTC
@sjames1958gm correct, if the number is for example -316, only the first digit 3 is negative so it would be -3 + 1 + 6
Jenell Pizarro
@nellarro
Jan 14 2017 02:13 UTC
Alrighty :). So have you thought about finding the particular index instead of using a variable @oshane-willy99 ?
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:13 UTC
if the number is negative, the negative is attatched to the first digit
Ryan L
@codelinde
Jan 14 2017 02:13 UTC
Is there anyone who would be willing to take a crack at a very specific problem I have in my algorithm for the Roman Numeral Converter challenge? If I console.log everything I can see it actually generates the right answer, but after that it throws an error before it can return it because I can't figure out how to get out of the recursion. I essentially want to know if it's worth it to try to fix this problem and thereby 'salvage' my code, or if I should start from scratch with a new approach. https://jsfiddle.net/codelinde/sk77p2h7/1/ If there are any takers I'd greatly appreciate the help
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:13 UTC
and then i need to subtract that negative number from the rest of them
grantknaver
@grantknaver
Jan 14 2017 02:14 UTC
anyone free
Stephen James
@sjames1958gm
Jan 14 2017 02:14 UTC
@Dueldrawer8 Ah, the problem with your solution is that your loop is in the else, but you need the loop for both cases.
in the if you need to init total and change i to 2
@grantknaver What up?
Ken Haduch
@khaduch
Jan 14 2017 02:15 UTC
@johnpyp - I haven't tried this, but maybe this will be helpful? https://css-tricks.com/css-sprites/
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:15 UTC
@khaduch thank you
CamperBot
@camperbot
Jan 14 2017 02:15 UTC
dueldrawer8 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2272 | @khaduch |http://www.freecodecamp.com/khaduch
Stephen James
@sjames1958gm
Jan 14 2017 02:15 UTC
@codelinde Do you want to reverse the order of your array so you start with M ?
oshane-willy99
@oshane-willy99
Jan 14 2017 02:16 UTC
@nellarro yeah....still dont work....lol
Stephen James
@sjames1958gm
Jan 14 2017 02:16 UTC
@codelinde maybe stop when num == 0
@oshane-willy99 did you change to brackets?
Jenell Pizarro
@nellarro
Jan 14 2017 02:17 UTC
If the property of the object you are trying to access has a space in it, you will need to use bracket notation.
@oshane-willy99
Ryan L
@codelinde
Jan 14 2017 02:17 UTC
@sjames1958gm Yeah for some reason it keeps going when I try to set num == 0 as a condition for stopping, but maybe I'm not putting the condition in the right part of the loop
grantknaver
@grantknaver
Jan 14 2017 02:18 UTC
Im trying to figure out why Im returning everything correctly
Stephen James
@sjames1958gm
Jan 14 2017 02:18 UTC
@codelinde generally when you use recursion you return the values back up the recursion chain
grantknaver
@grantknaver
Jan 14 2017 02:18 UTC
it should
here is my code link
oshane-willy99
@oshane-willy99
Jan 14 2017 02:18 UTC
@nellarro no space is in the properties....want to see the code?
Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:19 UTC
@sjames1958gm i dont know if that works..
Stephen James
@sjames1958gm
Jan 14 2017 02:20 UTC
@grantknaver you have a return inside the loop?
oshane-willy99
@oshane-willy99
Jan 14 2017 02:21 UTC
@sjames1958gm brackets???
Stephen James
@sjames1958gm
Jan 14 2017 02:22 UTC
@oshane-willy99 [val]
Ryan L
@codelinde
Jan 14 2017 02:22 UTC
@sjames1958gm Thanks, I'll take another crack at it
CamperBot
@camperbot
Jan 14 2017 02:22 UTC
codelinde sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5323 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
grantknaver
@grantknaver
Jan 14 2017 02:22 UTC
just caught that dealing with it now. one second maythat will fix stuff
Stephen James
@sjames1958gm
Jan 14 2017 02:22 UTC
@codelinde :+1:
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:23 UTC
@sjames1958gm this is what i have..
function sumDigits(num) {
  // your code here
  var digits = (num).toString();
  for(var i = 0; i < digits.length; i++){
    if(digits[0] === '-'){
      var total =  -Number(digits[1]);
     }
  }
    for(var i = 0; i < digits.length; i++){
      total+= Number(digits[i]);
  }
  return total;
}

sumDigits(-316);
oshane-willy99
@oshane-willy99
Jan 14 2017 02:23 UTC
@sjames1958gm yh it worked......lol... thanks
CamperBot
@camperbot
Jan 14 2017 02:23 UTC
oshane-willy99 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5324 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
oshane-willy99
@oshane-willy99
Jan 14 2017 02:23 UTC
@nellarro thanks
CamperBot
@camperbot
Jan 14 2017 02:23 UTC
oshane-willy99 sends brownie points to @nellarro :sparkles: :thumbsup: :sparkles:
:cookie: 244 | @nellarro |http://www.freecodecamp.com/nellarro
oshane-willy99
@oshane-willy99
Jan 14 2017 02:24 UTC
@oshane-willy99 thanks
CamperBot
@camperbot
Jan 14 2017 02:24 UTC
sorry oshane-willy99, you can't send brownie points to yourself! :sparkles: :sparkles:
oshane-willy99
@oshane-willy99
Jan 14 2017 02:24 UTC
lol
grantknaver
@grantknaver
Jan 14 2017 02:24 UTC
now it is deleting certain letters.....
sooo weird
Stephen James
@sjames1958gm
Jan 14 2017 02:26 UTC
@Dueldrawer8 your first loop is not needed because you only do one thing.
Then your second loop should start at 2 if you did find the -
You can set the initial value of i outside the loop
@Dueldrawer8 you still need the if inside the first loop just no loop
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:27 UTC
whats the init value of i? its just 0.. i dont see whats the diff between setting it in and out of the loo
*loop
grantknaver
@grantknaver
Jan 14 2017 02:28 UTC
ya now it is deleting the letter "l" for some reason @sjames1958gm
here is the code
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:28 UTC
now im confused
Stephen James
@sjames1958gm
Jan 14 2017 02:28 UTC
@Dueldrawer8 if the first digit is - you want to start the loop at 2 (because you have already used 0,1 to set total
grantknaver
@grantknaver
Jan 14 2017 02:28 UTC
function translatePigLatin(str) {
  var toArray = Array.from(str);
  var vowels= /[aeiou]/g;


if(str[0].match(vowels)){
  var vowelEnding = str += "way";
  return vowelEnding;  
} 
for(var i = 0; i < toArray.length; i++){
  var final;
  if(str[i].match(vowels) === null){
   toArray.push(toArray[i]);
   toArray.shift(toArray[i]);

  }

}
  return toArray;

}

translatePigLatin("california");
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:28 UTC
@sjames1958gm so no for loop just the if first
Stephen James
@sjames1958gm
Jan 14 2017 02:28 UTC
@Dueldrawer8 The code inthe first loop doesn't use i so no need for a loop
Ken Haduch
@khaduch
Jan 14 2017 02:29 UTC
@grantknaver - think that one thing to change in your if is this: toArray.push(str[i]); because you are checking str for the values, and manipulating toArray. Then I just put an "else" after your if block, and it works? Oh, and make the toArray.shift(); - take out the argument value.
Stephen James
@sjames1958gm
Jan 14 2017 02:29 UTC
@grantknaver Don't you need to stop the loop if you find a vowel?
Jenell Pizarro
@nellarro
Jan 14 2017 02:30 UTC
function largestOfFour(arr) {
  // You can do this!
  var numArr = [];
  for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr.length; j++) {
      if (arr[i][j] // holy oh my goodness I'm stuck)
    }
  }

  return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Stephen James
@sjames1958gm
Jan 14 2017 02:30 UTC
@grantknaver Also, realize your i is going up but you are shifting the array down so you will skip
Jenell Pizarro
@nellarro
Jan 14 2017 02:31 UTC
Need help finding the largest number in each array filled with arrays.
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:31 UTC
@sjames1958gm so it works for negative numbers..but not positive numbers now
Stephen James
@sjames1958gm
Jan 14 2017 02:31 UTC
@nellarro think about how you would find the largest in a single array - that is what youe inner loop is going to do.
Just the result of the inner loop will be put into an array
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:31 UTC
@Dueldrawer8 for example
function sumDigits(num) {
  // your code here
  var digits = (num).toString();
    if(digits[0] === '-'){
      var total =  -Number(digits[1]);
     }

    for(var i = 2; i < digits.length; i++){
      total+= Number(digits[i]);
  }
  return total;
}

sumDigits(316);
Ken Haduch
@khaduch
Jan 14 2017 02:32 UTC
@grantknaver - in other words, I made your loop look like this:
for(var i = 0; i < str.length; i++){
  var final;
  if(str[i].match(vowels) === null){
   toArray.push(str[i]);
   toArray.shift();
   final = toArray.join('');
  } else 
 return final + "ay";
}
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:32 UTC
returning total gives me NaN
Stephen James
@sjames1958gm
Jan 14 2017 02:32 UTC
@Dueldrawer8 Your starting i has to depend on the first if
Jenell Pizarro
@nellarro
Jan 14 2017 02:32 UTC
Cool. Let me hack at it a bit and see if I can crack it @sjames1958gm !
Stephen James
@sjames1958gm
Jan 14 2017 02:33 UTC
@Dueldrawer8 Also var total = 0 should be before the first if as well
@nellarro :+1: good luck !
grantknaver
@grantknaver
Jan 14 2017 02:33 UTC
it was because I manipulating str and also dealing with the array beautiful thank you guys
Stephen James
@sjames1958gm
Jan 14 2017 02:33 UTC
@grantknaver :+1:
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:34 UTC
@sjames1958gm so i need two for loops?
or just an if else
in another words, where does my for loop go? before the if statment?
Ken Haduch
@khaduch
Jan 14 2017 02:35 UTC
@Dueldrawer8 - you could just do something like this:
var i = 1, total = 0;
if( digits[0] === '-') {
    total -= digits[1];
    i = 2;
}
for ( ; i < str.length; i++ ) {
Stephen James
@sjames1958gm
Jan 14 2017 02:35 UTC

@Dueldrawer8 No.

var istart = 0;
if (first digit is '-') then istart = 2;
for (var i = istart

This is what I mean by starting your loop dependent on the first char

grantknaver
@grantknaver
Jan 14 2017 02:35 UTC
nvm
Stephen James
@sjames1958gm
Jan 14 2017 02:36 UTC
@grantknaver Here is different way where string .match where you match not vowels
function translate(str) {
  var prefix = str.match(/^[^aeiou]*/);

  if (prefix[0].length === 0) {
    return str + "way";
  } else {
    return str.slice(prefix[0].length) + prefix[0] + "ay";
  }
}
andry91959
@andry91959
Jan 14 2017 02:38 UTC
guys Im not sure what to do with this one
please help

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

Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:38 UTC
@khaduch it still wont sum the digits if they are all positive
Stephen James
@sjames1958gm
Jan 14 2017 02:39 UTC
@andry91959 YOu need to define myVar inside of myLocalScope()
Ken Haduch
@khaduch
Jan 14 2017 02:39 UTC
@Dueldrawer8 - oh, yeah, how about var i = 0; then set it to 2 if you have the negative thing? I didn't try the whole solution... sorry!
grantknaver
@grantknaver
Jan 14 2017 02:39 UTC
@sjames1958gm your really good man
andry91959
@andry91959
Jan 14 2017 02:39 UTC
@sjames1958gm how to devine it?
define
Stephen James
@sjames1958gm
Jan 14 2017 02:40 UTC
@andry91959
var myVar;
Hasan
@MHAhmed
Jan 14 2017 02:40 UTC
hey guys this is the code i came up with for 'truncate a string' but is there a better way to do it?
function truncateString(str, num) {
  // Clear out that junk in your trunk

  if (num < 3) {
    return str.slice(0, num) + '...';
  } else if (str.length <= num) {
    return str;
  } else if (str.length > num) {
    return str.slice(0,num-3) + "...";
  }
}

truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2);
andry91959
@andry91959
Jan 14 2017 02:40 UTC
@sjames1958gm but they said no global myVar
Stephen James
@sjames1958gm
Jan 14 2017 02:41 UTC
@andry91959 yes that is why it needs to be inside the function
Randy Goldsmith
@Dueldrawer8
Jan 14 2017 02:41 UTC
@sjames1958gm thank you that worked
CamperBot
@camperbot
Jan 14 2017 02:41 UTC
:star2: 5325 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
dueldrawer8 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
Jan 14 2017 02:41 UTC
@MHAhmed That looks fine. .
andry91959
@andry91959
Jan 14 2017 02:42 UTC

@sjames1958gm function myLocalScope() {
'use strict';

var 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

this is wht I did
Stephen James
@sjames1958gm
Jan 14 2017 02:42 UTC
@andry91959 now remove the console.log near the bottom
@andry91959 You may have to refresh the page
andry91959
@andry91959
Jan 14 2017 02:43 UTC

function myLocalScope() {
'use strict';

var myVar;
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope myVar;

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

like that?
Hasan
@MHAhmed
Jan 14 2017 02:43 UTC
@sjames1958gm cool
John Gu
@loop1
Jan 14 2017 02:44 UTC
@sjames1958gm

function mutation(arr) {

for (i=0;i<arr[0].length;i++)
{

 if( arr[1].toLowerCase().indexOf(arr[0].toLowerCase().charAt(i)) == -1 ) {
 return false; 

 }

return true;

}

}

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

andry91959
@andry91959
Jan 14 2017 02:44 UTC
@sjames1958gm so I remove the console log and my var and get it correct
@sjames1958gm but I got "console log never been called"
@sjames1958gm I dont get tit
Stephen James
@sjames1958gm
Jan 14 2017 02:45 UTC
@loop1 you have your check backward - you want to check each character of arr[1] in arr[0]
also you need lowercase the two strings
@andry91959 Show me the code?`
@loop1 nvm about the toLowerCase (I just saw you had that)
Gabriel Amazonas Mesquita
@GabrielAmazonas
Jan 14 2017 02:47 UTC
Hey guys, can anybody help with the rot13 challenge? the alert returns everything correct

function rot13(str) { // LBH QVQ VG!
var returnArray = [];
var lastArray = [];
for(var i = 0; i < str.split("").length; i++){
if(str.split("")[i] !== " "){
returnArray.push(str.charCodeAt(i));
} else {
returnArray.push(" ");
}

}
var stringResult = "";
for(var j = 0; j < returnArray.length; j++){
if(returnArray[j] === "" || returnArray[j] === " "){
stringResult += " ";
}

if(returnArray[j] < 65 || returnArray[j] > 90){
  stringResult += (String.fromCharCode(returnArray[j]));
}
else if(returnArray[j] - 13 >= 65){
  stringResult += (String.fromCharCode(returnArray[j] - 13));
} else if(returnArray[j] + 13 <= 90) {
   stringResult += (String.fromCharCode(returnArray[j] + 13));
} else {
  stringResult += (String.fromCharCode(returnArray[j]));
}

}
alert(stringResult);

return stringResult;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

John Gu
@loop1
Jan 14 2017 02:47 UTC
arr1.toLowerCase().indexOf(arr[0].toLowerCase().charAt(i)) == -1
andry91959
@andry91959
Jan 14 2017 02:47 UTC

@sjames1958gm function myLocalScope() {
'use strict';

var myVar;
}
myLocalScope();

Stephen James
@sjames1958gm
Jan 14 2017 02:47 UTC
@andry91959 only the second console.log was to be removed -
andry91959
@andry91959
Jan 14 2017 02:48 UTC
@sjames1958gm the last one? do I keep myVar like that?
Stephen James
@sjames1958gm
Jan 14 2017 02:49 UTC
@andry91959 yes
andry91959
@andry91959
Jan 14 2017 02:50 UTC

@sjames1958gm function myLocalScope() {
'use strict';

var myVar;
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
myVar;

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

Ken Haduch
@khaduch
Jan 14 2017 02:50 UTC
@GabrielAmazonas - if you are getting everything correct, check for an extra space at the end of your result.
andry91959
@andry91959
Jan 14 2017 02:50 UTC
@sjames1958gm what do I need to put on last myVar
Stephen James
@sjames1958gm
Jan 14 2017 02:50 UTC
@andry91959 reset the challenge
add var myVar; inside the function
and remove the last console.log
andry91959
@andry91959
Jan 14 2017 02:51 UTC
@sjames1958gm so leave me with this

function myLocalScope() {
'use strict';

var myVar;
}
myLocalScope();

John Gu
@loop1
Jan 14 2017 02:51 UTC
@sjames1958gm why the code does not work?
andry91959
@andry91959
Jan 14 2017 02:51 UTC
but I got console log never been called
Adel
@AdelMahjoub
Jan 14 2017 02:52 UTC
@johnpyp by changing srcX and srcY of the iconWeather depending on the weather, you can do what you have have in mind, you can use the spriteTileSheet from the link, made from the icon pack you linked https://codepen.io/SultanCodeCamper/pen/vgKzGE?editors=1010
Stephen James
@sjames1958gm
Jan 14 2017 02:52 UTC
@loop1 you should have arr[0].indexOf not arr[1].indexOf
andry91959
@andry91959
Jan 14 2017 02:52 UTC
Capture.PNG
@sjames1958gm
Stephen James
@sjames1958gm
Jan 14 2017 02:53 UTC
@andry91959 you removed both console.log

@andry91959

function myFunction() {
  'use strict';

  var myVar;

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

this passes

James Shore
@Jimbobmahooley
Jan 14 2017 02:55 UTC
Hello, I am currently doing the Factorialize a number challenge and I don't want to just search it because I don't just want the answer I want to know why I'm wrong anyway this is what I've got please can someone help thanks
function factorialize(num) {
  for (var i=1; i < num; i++) {
    num *= num(i);
  }


  return num;
}
Stephen James
@sjames1958gm
Jan 14 2017 02:56 UTC
@Jimbobmahooley you are using num for your factorial and for you loop termination
i will never catch num
James Shore
@Jimbobmahooley
Jan 14 2017 02:57 UTC
@sjames1958gm are you saying each time it goes through a loop num is a multiple bigger so it creates an infinite loop?
Elliott Alexander
@escottalexander
Jan 14 2017 02:57 UTC
I dont understand why my function returns "undefined". Can someone look at my code and make sure I'm not missing something? https://codepen.io/escottalexander/pen/JEKKpa?editors=0010
Stephen James
@sjames1958gm
Jan 14 2017 02:58 UTC
@Jimbobmahooley yes.
@Jimbobmahooley use a new variable for the sum calc.
andry91959
@andry91959
Jan 14 2017 02:58 UTC
Capture.PNG
@sjames1958gm im not sure it gets me this
it pass but still Im not sure if im right
Jenell Pizarro
@nellarro
Jan 14 2017 02:59 UTC
@sjames1958gm Went with a different approach. Looked on MDN and found Math.max() it ended up being a lot simpler
Stephen James
@sjames1958gm
Jan 14 2017 02:59 UTC
@andry91959 yes that is right - the idea is that if you put
var myVar;
inside the function the console.log(myVar) outside the function does not work
Jenell Pizarro
@nellarro
Jan 14 2017 03:00 UTC
Thanks @sjames1958gm
CamperBot
@camperbot
Jan 14 2017 03:00 UTC
nellarro sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5326 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jan 14 2017 03:00 UTC
@nellarro Great! doing the reasearch and finding an easier solution is great programming
andry91959
@andry91959
Jan 14 2017 03:00 UTC
@sjames1958gm I think I got it. thank you james
CamperBot
@camperbot
Jan 14 2017 03:00 UTC
andry91959 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5327 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
John Gu
@loop1
Jan 14 2017 03:00 UTC
@sjames1958gm Thanks !
CamperBot
@camperbot
Jan 14 2017 03:00 UTC
loop1 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5328 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
John Gu
@loop1
Jan 14 2017 03:00 UTC

function mutation(arr) {

for (i=0;i<arr1.length;i++)
{

 if( arr[0].toLowerCase().indexOf(arr[1].toLowerCase().charAt(i)) == -1 )

 {
 return false; 

 }

return true;

}

}

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

DRJcoder
@DRJcoder
Jan 14 2017 03:00 UTC
some one please help me
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.'
Stephen James
@sjames1958gm
Jan 14 2017 03:01 UTC
@andry91959 :)
DRJcoder
@DRJcoder
Jan 14 2017 03:01 UTC
what is the code
?
Stephen James
@sjames1958gm
Jan 14 2017 03:01 UTC
@DRJcoder have you tried anything
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:01 UTC
@DRJcoder do you know what % does?
James Shore
@Jimbobmahooley
Jan 14 2017 03:01 UTC
var factorial = 1;
function factorialize(num) {
  for (var i=1; i <= num; i++) {
    factorial *= num(i);
  }
  num = factorial;

  return num;
}
@sjames1958gm like this?
DRJcoder
@DRJcoder
Jan 14 2017 03:02 UTC
help guys help
CamperBot
@camperbot
Jan 14 2017 03:02 UTC
no wiki entry for: guys help
DRJcoder
@DRJcoder
Jan 14 2017 03:02 UTC
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
what is the code, or the answer
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:02 UTC
@DRJcoder remember long division?
Stephen James
@sjames1958gm
Jan 14 2017 03:02 UTC
@Jimbobmahooley move that variable inside the function
DRJcoder
@DRJcoder
Jan 14 2017 03:02 UTC
9/8
sothing like that ?
John Gu
@loop1
Jan 14 2017 03:02 UTC
@sjames1958gm but the mutation(["hello", "hey"]) also return the wrong answer ,please help
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:03 UTC
@Jimbobmahooley why don't you return factorial? instead of assigning it to num again?
@DRJcoder
Stephen James
@sjames1958gm
Jan 14 2017 03:03 UTC
@Jimbobmahooley num(i) is wrong - that should just be i
DRJcoder
@DRJcoder
Jan 14 2017 03:03 UTC
yes I did tried but I just cant get it right
James Shore
@Jimbobmahooley
Jan 14 2017 03:04 UTC
@Lumexralph good point I'm still thinking as if its a challenge and I can't change the code
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:05 UTC
% returns the remainder of dividing two operandS e. g 3 % 2.....will return 1 because 3 / 2 is 1 reminder 1,that remaining 1 is what % returns
DRJcoder
@DRJcoder
Jan 14 2017 03:05 UTC
got it
Robin
@rlake1515
Jan 14 2017 03:05 UTC
my function will return "not found" but not any desired object properties. Any suggestions?
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp)){
  return myObj.checkProp;
  } else {
  return "Not Found";

}
}
// Test your code by modifying these values
checkObj("gift");
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:05 UTC
@Jimbobmahooley okay :smile:
@rlake1515 do you know checkProp is a variable?
James Shore
@Jimbobmahooley
Jan 14 2017 03:06 UTC
@Lumexralph But doesn't it create a problem with scope?
Stephen James
@sjames1958gm
Jan 14 2017 03:06 UTC
@rlake1515 dot notation does not work for variables
James Shore
@Jimbobmahooley
Jan 14 2017 03:06 UTC
@sjames1958gm just returns 1 now
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:06 UTC
@Jimbobmahooley make sure its in your function
Stephen James
@sjames1958gm
Jan 14 2017 03:07 UTC
@Jimbobmahooley hmm, what does it look like?
Robin
@rlake1515
Jan 14 2017 03:07 UTC
@sjames1958gm Thank you! that solved it
CamperBot
@camperbot
Jan 14 2017 03:07 UTC
rlake1515 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5329 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jan 14 2017 03:07 UTC
@rlake1515 :+1:
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:07 UTC
@rlake1515 using dot notation won't work so you have to try the other method
Robin
@rlake1515
Jan 14 2017 03:07 UTC
@Lumexralph thank you as well!
CamperBot
@camperbot
Jan 14 2017 03:07 UTC
rlake1515 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 724 | @lumexralph |http://www.freecodecamp.com/lumexralph
James Shore
@Jimbobmahooley
Jan 14 2017 03:08 UTC
function factorialize(num) {
  for (var i=1; i <= num; i++) {
    var factorial = 1;
    factorial *= i;
    num = factorial;
  }


  return num;
}
@sjames1958gm
Stephen James
@sjames1958gm
Jan 14 2017 03:08 UTC
@Jimbobmahooley init the variable before the loop but still inside the function
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:08 UTC
@Jimbobmahooley declare factorial variable out of the for loop, before the for loop
John Gu
@loop1
Jan 14 2017 03:09 UTC

function mutation(arr) {

for (i=0;i<arr1.length;i++)
{

 if( arr[0].toLowerCase().indexOf(arr[1].toLowerCase().charAt(i)) == -1 )

 {
 return false; 

 }

return true;

}

}

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

Ogundele Olumide
@Lumexralph
Jan 14 2017 03:09 UTC
@rlake1515 :smile:
Stephen James
@sjames1958gm
Jan 14 2017 03:09 UTC
@loop1 you cannot return true untill all the letters are chekced
James Shore
@Jimbobmahooley
Jan 14 2017 03:10 UTC
@sjames1958gm @Lumexralph still returning 1
Stephen James
@sjames1958gm
Jan 14 2017 03:11 UTC
@Jimbobmahooley hmm it shouldn't
show one more time :)
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:11 UTC
@Jimbobmahooley show your updated code, are you sure you declared the factorial variable before the for loop?
John Gu
@loop1
Jan 14 2017 03:11 UTC
@sjames1958gm where could i use return true?
Stephen James
@sjames1958gm
Jan 14 2017 03:12 UTC
@loop1 maybe after the loop?
James Shore
@Jimbobmahooley
Jan 14 2017 03:12 UTC
function factorialize(num) {
  var factorial = 1;
  for (var i=1; i <= num; i++) {
    factorial *= i;
    num = factorial;
  }


  return num;
}
@sjames1958gm @Lumexralph
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:12 UTC
@loop1 you have to return true when the loop is done
@Jimbobmahooley remove num = factorial in your loop
@Jimbobmahooley return factorial when your loop is done
James Shore
@Jimbobmahooley
Jan 14 2017 03:14 UTC
@Lumexralph Good point it was just resetting it to 1 wasn't it
thanks @Lumexralph @sjames1958gm it works now
CamperBot
@camperbot
Jan 14 2017 03:14 UTC
jimbobmahooley sends brownie points to @lumexralph and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5330 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:cookie: 725 | @lumexralph |http://www.freecodecamp.com/lumexralph
Stephen James
@sjames1958gm
Jan 14 2017 03:15 UTC
@Jimbobmahooley :+1:
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:15 UTC
@Jimbobmahooley yes that's what happened
John Gu
@loop1
Jan 14 2017 03:15 UTC
@Lumexralph @sjames1958gm done!thanks!
Stephen James
@sjames1958gm
Jan 14 2017 03:15 UTC
@loop1 :+1:
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:15 UTC
@loop1 cool
Stephen James
@sjames1958gm
Jan 14 2017 03:16 UTC
@Jimbobmahooley The variable has to be inside the function because FCC will not reset globals between tests
James Shore
@Jimbobmahooley
Jan 14 2017 03:17 UTC
@sjames1958gm As in global scope?
Amarillia
@Amarillia
Jan 14 2017 03:17 UTC
I am not sure which task is it but why not just simply return num * factorialize(num-1)?
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:17 UTC
@Amarillia that's recursion it's another to do it but his way is cool too
Amarillia
@Amarillia
Jan 14 2017 03:18 UTC
Oh, okay
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:19 UTC
@Amarillia recursion would've have been frowned on but cool that there's now Tail Call Optimization
James Shore
@Jimbobmahooley
Jan 14 2017 03:21 UTC
@Lumexralph Can you explain why the factorial variable had to be defined inside the function please?
kez
@keztheminer
Jan 14 2017 03:21 UTC
can someone please help with word blanks
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:22 UTC
@kezdarkriser do you know how to concatenate strings?
Elliott Alexander
@escottalexander
Jan 14 2017 03:22 UTC
Someone please look at this project. My function returns "undefined" and I don't know why. I've been debugging it for hours. https://codepen.io/escottalexander/pen/JEKKpa?editors=0010
Amarillia
@Amarillia
Jan 14 2017 03:23 UTC
@Lumexralph To be fair I don't know exactly what does it mean Tail Call Optimization but I will have a look at
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:23 UTC
@Jimbobmahooley if it's not a FCC challenge and you declare a variable outside the function it's cool but FCC don't want variables in the global space except the one they declared
kez
@keztheminer
Jan 14 2017 03:25 UTC

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
myNoun="dog" ;
myAdjective="big";
myVerb="ran";
myAdverb="quickly";
result= myAdjective + "," + myNoun + "," + myVerb + ","+ myAdverb;
// Your code above this line
return result;
}

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

i dont know ho to add the second wordblanks cat littlehit and slowly
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:27 UTC
@Amarillia anytime you do recursion the function has to be called many times and each function calls has a stack a kind of memory to keep track of the function calls but when you have numerous data and recursion is called many times, it keeps taking up memory to place the function in call stacks on each individual call and might lead to running out of memory and that's bad... TCO makes it possible that just one call stack is used for the Operation
@kezdarkriser don't assign any variable to the parameters in your function
Amarillia
@Amarillia
Jan 14 2017 03:29 UTC
Got it now. I knew that just didn't know that is called Tail Call Optimization. Thanks @Lumexralph
CamperBot
@camperbot
Jan 14 2017 03:29 UTC
amarillia sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 726 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:30 UTC
@kezdarkriser myNoun is already holding the value "dog" from your function call ditto for other parameters
kez
@keztheminer
Jan 14 2017 03:30 UTC
so myNoun= ;
James Shore
@Jimbobmahooley
Jan 14 2017 03:30 UTC
@Lumexralph oh okay cheers
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:30 UTC
@Amarillia Okay, i get scared of recursion until i met TCO
@kezdarkriser i don't understand
kez
@keztheminer
Jan 14 2017 03:32 UTC
nope nor do i :) i am completly lost on just this one
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:32 UTC
@escottalexander can you paste your js file here?
@kezdarkriser you know how parameters work, right?
Elliott Alexander
@escottalexander
Jan 14 2017 03:35 UTC
@Lumexralph Its on codePen. do you want the js copied off that?
kez
@keztheminer
Jan 14 2017 03:36 UTC
right i got it now thanks guys
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:38 UTC
@escottalexander undefined should be status, right?
@kezdarkriser :+1:
Elliott Alexander
@escottalexander
Jan 14 2017 03:39 UTC
@Lumexralph I dont understand your question.
Amarillia
@Amarillia
Jan 14 2017 03:41 UTC
When we want to repeat a string why we can't do simply str * num? Can we only do this with loops?
Elliott Alexander
@escottalexander
Jan 14 2017 03:42 UTC
@Amarillia No, you can't multiply with a number. You need a loop.
Amarillia
@Amarillia
Jan 14 2017 03:43 UTC
Okay
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:43 UTC
@escottalexander in the strings appended to the body there's a place you have <p> status </p>, right?
@Amarillia you can use string. repeat()
Joe Escobedo
@joeEscob1023
Jan 14 2017 03:44 UTC
so with the inequality operator, everything that is false would be written as true in the console?
Elliott Alexander
@escottalexander
Jan 14 2017 03:44 UTC
@Lumexralph yes.
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:45 UTC
@TacoJoe if both operands are not equal
Joe Escobedo
@joeEscob1023
Jan 14 2017 03:46 UTC
can you give an example please? @Lumexralph
Evan Kalvis
@evan17gr
Jan 14 2017 03:46 UTC
http://codepen.io/evan17gr/pen/qRENOO does anyone know why when the author is uknown it wont show uknown?
Elliott Alexander
@escottalexander
Jan 14 2017 03:46 UTC
@Lumexralph I don't understand why that matters. its the function above this one that is throwing the Undefined at me.
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:47 UTC
@TacoJoe the opertor will return true if both operands are not same e. g false !== 1 will return true
Elliott Alexander
@escottalexander
Jan 14 2017 03:48 UTC
@Lumexralph And to answer your first question, No, Status does not correspond to the undefined.
Joe Escobedo
@joeEscob1023
Jan 14 2017 03:48 UTC
and the operands in this case would be false and 1 right? @Lumexralph
so would true !== 1 return false?
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:49 UTC
@escottalexander i think it's in the json data returned , can you log the json returned in the JQuery section to the consol to inspect it? checking if it has status property?
@TacoJoe yes those are the operands
uriznik
@uriznik
Jan 14 2017 03:50 UTC
@evan17gr move the quoteAuthor check inside your callback
Elliott Alexander
@escottalexander
Jan 14 2017 03:50 UTC
@Lumexralph I will do that.
Joe Escobedo
@joeEscob1023
Jan 14 2017 03:50 UTC
ok! thanks @Lumexralph i get it now
CamperBot
@camperbot
Jan 14 2017 03:50 UTC
tacojoe sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 727 | @lumexralph |http://www.freecodecamp.com/lumexralph
Evan Kalvis
@evan17gr
Jan 14 2017 03:51 UTC
Ok I ll try ty
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:52 UTC
@TacoJoe No, that would return false
Evan Kalvis
@evan17gr
Jan 14 2017 03:52 UTC
Oh thanks a lot it works now!
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:53 UTC
@TacoJoe yes rather
mitron6
@mitron6
Jan 14 2017 03:53 UTC
@evan17gr Hi Evan, make sure you direct your thank at a person. Like @person Thanks.
CamperBot
@camperbot
Jan 14 2017 03:53 UTC
mitron6 sends brownie points to @evan17gr and @person :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for person
:cookie: 398 | @evan17gr |http://www.freecodecamp.com/evan17gr
Evan Kalvis
@evan17gr
Jan 14 2017 03:53 UTC
I'm on my phone sorry
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:54 UTC
@evan17gr you can still do it on your phone
Evan Kalvis
@evan17gr
Jan 14 2017 03:54 UTC
How?
Elliott Alexander
@escottalexander
Jan 14 2017 03:54 UTC
@Lumexralph The first getJSON request doesn't have a status category but it doesn't need one to work with the code. The second getJSON request has a status category and the code uses it perfectly.
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:55 UTC
click on the @ on your keypad it'll bring lists of people you click on the one you want to reference
Evan Kalvis
@evan17gr
Jan 14 2017 03:55 UTC
Yes but idk their name
That's what I mean
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:56 UTC
look at the person that responded to you the name should be there
Evan Kalvis
@evan17gr
Jan 14 2017 03:56 UTC
It doesn't have their nickname though
uriznik
@uriznik
Jan 14 2017 03:58 UTC
he thanked me in the main room so it's all good :clap:
Ogundele Olumide
@Lumexralph
Jan 14 2017 03:59 UTC
@escottalexander tried logging data in the jsonPull function to the console?
James Shore
@Jimbobmahooley
Jan 14 2017 03:59 UTC
Hello I am currently looking at .replace() and using it like so str.replace(/_/gi, ""); however I was wondering if there is a way of using it so that it will also take out spaces but still replace with "" any ideas?
Elliott Alexander
@escottalexander
Jan 14 2017 04:00 UTC
@Lumexralph Yes, I think so...
Ogundele Olumide
@Lumexralph
Jan 14 2017 04:00 UTC
@Jimbobmahooley sure use RegExp
Lampago
@Lampago
Jan 14 2017 04:00 UTC
PLZ help meeee
Plz help me
Wont let me click anything whith that code
Ogundele Olumide
@Lumexralph
Jan 14 2017 04:03 UTC
@escottalexander what did you get? am not with my pc now so there's not much debugging i can do on your code
Lampago
@Lampago
Jan 14 2017 04:03 UTC
After I wrote the code
The scree froze
screen*
Please someone knows why?
Ogundele Olumide
@Lumexralph
Jan 14 2017 04:04 UTC
@Lampago do you have a loop?
James Shore
@Jimbobmahooley
Jan 14 2017 04:04 UTC
@Lumexralph ah okay thanks i'll have a look
CamperBot
@camperbot
Jan 14 2017 04:04 UTC
jimbobmahooley sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:warning: jimbobmahooley already gave lumexralph points
Elliott Alexander
@escottalexander
Jan 14 2017 04:04 UTC
@Lumexralph Oh I see. What did you want to know specifically? I have to getJson requests in my code. only one of them is the problem and i am 99% its not the request but something else in the function.
bluehabit
@bluehabit
Jan 14 2017 04:04 UTC
var animal = 'dog'
var sounds = {
    pig: 'oink',
    cow: 'moo',
    dog: 'woof-wof',
}

var sound = sounds[animal]
//undefined

Why does sound in the above code return undefined?

I can write sounds.dog and it will return its value woof-woof just fine

Lampago
@Lampago
Jan 14 2017 04:05 UTC
@Lumexralph Well the exercice is nesting for loops so I guess I do
mitron6
@mitron6
Jan 14 2017 04:05 UTC
@Lampago Maybe your console.log always returns undefined so that the inner look never terminates.
Ogundele Olumide
@Lumexralph
Jan 14 2017 04:05 UTC
@Lampago it's an infinite loop probably
Lampago
@Lampago
Jan 14 2017 04:06 UTC
@mitron6 okay, but how do I fix it
Jenell Pizarro
@nellarro
Jan 14 2017 04:06 UTC
@bluehabit your key values aren't strings
Lampago
@Lampago
Jan 14 2017 04:06 UTC
@Lumexralph How do I fix that :(
Jenell Pizarro
@nellarro
Jan 14 2017 04:06 UTC
dog != 'dog' @bluehabit
bluehabit
@bluehabit
Jan 14 2017 04:06 UTC
@nellarro Ah ok that makes sense thanks
CamperBot
@camperbot
Jan 14 2017 04:06 UTC
bluehabit sends brownie points to @nellarro :sparkles: :thumbsup: :sparkles:
:cookie: 247 | @nellarro |http://www.freecodecamp.com/nellarro
bluehabit
@bluehabit
Jan 14 2017 04:07 UTC
@nellarro I suppose there is no way to do that in dot notation then?
mitron6
@mitron6
Jan 14 2017 04:07 UTC
@Lampago Replace the console.log with something to increment the variable of the loop.
Ogundele Olumide
@Lumexralph
Jan 14 2017 04:08 UTC
@bluehabit animal variable has to hold the name of. the property in the sounds object, it's like a reference and looking at the object sounds there's no property "dog", try animal = dog
James Shore
@Jimbobmahooley
Jan 14 2017 04:08 UTC
@Lumexralph \W essentially does what I want however I don't want underscores is there a way of taking those out as well without making another .reduce()?
mitron6
@mitron6
Jan 14 2017 04:09 UTC
@Lampago Your inner loop for (j) never changes the value of j so the loop never ends.
Lampago
@Lampago
Jan 14 2017 04:09 UTC
@mitron6 The thing is as soon as I load the web page the screen just freeze
Jenell Pizarro
@nellarro
Jan 14 2017 04:10 UTC
@bluehabit Yep. As soon as you fix the strings.
Ogundele Olumide
@Lumexralph
Jan 14 2017 04:10 UTC
@Jimbobmahooley reduce foe? add underscores to the pattern
reduce() for what?
@Lampago can you show the code?
mitron6
@mitron6
Jan 14 2017 04:11 UTC
@Lampago Can you use chrome?

@Lampago I created an infinite loop like you did and chrome gives this message:

Error: Potential infinite loop at line ...

Lampago
@Lampago
Jan 14 2017 04:13 UTC
@mitron6 I Loaded the page and as fast as I could I smashed my keyboard, I am safe now but the code is messed, Thxs tho Jajaja
James Shore
@Jimbobmahooley
Jan 14 2017 04:13 UTC
@Lumexralph Essentially It is a function [with parameter (str)] that needs to take out everything except letters and numbers in the string so I was doing str.reduce(/\W/gi, "" ) but i also want to remove underscores and I don't know what reduce foe is?
bluehabit
@bluehabit
Jan 14 2017 04:14 UTC

@nellarro Not sure what you mean by fixing the key value strings.

I tried something like this

var animal = 'dog'
var sounds = {
    'pig': 'oink',
    'cow': 'moo',
    'dog': 'woof-wof',
}

var sound = sounds.animal
Ogundele Olumide
@Lumexralph
Jan 14 2017 04:16 UTC
@escottalexander it's from the isActive function
@bluehabit you can't use dot method for variables
@bluehabit try the bracket [ ] method
@bluehabit because animal is not a valid identifier or property name of the object, it's a variable and more of like a reference to that property name assigned to it
Elliott Alexander
@escottalexander
Jan 14 2017 04:19 UTC
@Lumexralph Thats right. The isActive function returns undefined instead of any other thing I have put in it. BUT the code runs all the way to the return line where it is told what to return.
Jenell Pizarro
@nellarro
Jan 14 2017 04:20 UTC
@bluehabit you had it awesome the first time around but you didn't have the key value pairs as strings. now you can try what @Lumexralph said with bracket notation like you had earlier :)
Ogundele Olumide
@Lumexralph
Jan 14 2017 04:22 UTC
@escottalexander in your pullJson function what's logged to the console when you logged labelActivity?
Edgar Pan
@edgaryp
Jan 14 2017 04:23 UTC
Need help with my code please. Trying to generate a random quote by using Forismatic API. http://codepen.io/edgaryp/pen/wgWxbW?editors=1010
Moisés Man
@moigithub
Jan 14 2017 04:26 UTC
@edgaryp remove the last slash on ur api url
Ogundele Olumide
@Lumexralph
Jan 14 2017 04:27 UTC
@escottalexander then probably it's the way the strings are concatenated, return a string literal let's say "ball" in the isActiveTest function then log labelActivity in pullJson function and see where that takes you
Edgar Pan
@edgaryp
Jan 14 2017 04:28 UTC
@moigithub thank you
CamperBot
@camperbot
Jan 14 2017 04:28 UTC
edgaryp sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2484 | @moigithub |http://www.freecodecamp.com/moigithub
Elliott Alexander
@escottalexander
Jan 14 2017 04:29 UTC
@Lumexralph Ive done what you're talking about. I tried simple strings, I tried numbers. everything returns undefined. i really appreciate the help.
Adam Hamm
@adamhamm
Jan 14 2017 04:29 UTC
Hi all, I'm trying to make an algorithm that checks for palindromes. This passes all tests but a couple and I can't seem to see why it's not catching a couple of capital letters.

function palindrome(str) {
// Good luck!
var newStr = str.replace(/[^A-Za-z0-9]/g, "");
var revStr = newStr.split("").reverse().join("");

console.log(newStr);
return newStr === revStr ? true : false;
}

palindrome("A man, a plan, a canal. Panama");

uriznik
@uriznik
Jan 14 2017 04:31 UTC
@adamhamm use the toLowerCase() function
Moisés Man
@moigithub
Jan 14 2017 04:31 UTC
@escottalexander do u know how function works ?
return ... return the execution flow to whatever called it
soo on the getJSON callback function.. who "calls" that is getJSON itself.. so
returning inside the callback wont give values to ur labelActivity
Adam Hamm
@adamhamm
Jan 14 2017 04:35 UTC
Ah, right. Lost when I was making some edits...
Elliott Alexander
@escottalexander
Jan 14 2017 04:35 UTC
@moigithub Wow. OK that makes sense. So when it says "return" its returning that str as a callback? How would you adjust that? any ideas?
Moisés Man
@moigithub
Jan 14 2017 04:36 UTC
@escottalexander one way could be.. nest those 2 getJSON.. and inside the inner callback append data to ur html
$.getJSON( '...', function(data1){
    $.getJSON( '...', function(data2){   

                 add data to ur html mixing data1 + data2 values
      })
})
or using promises
Adam Hamm
@adamhamm
Jan 14 2017 04:38 UTC
@uriznik Ah, thanks! I must have lost it when I was editing.
CamperBot
@camperbot
Jan 14 2017 04:38 UTC
adamhamm sends brownie points to @uriznik :sparkles: :thumbsup: :sparkles:
:cookie: 489 | @uriznik |http://www.freecodecamp.com/uriznik
Elliott Alexander
@escottalexander
Jan 14 2017 04:38 UTC
Thanks, I will look into that. Thanks @moigithub and @Lumexralph !
CamperBot
@camperbot
Jan 14 2017 04:38 UTC
escottalexander sends brownie points to @moigithub and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 728 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 2485 | @moigithub |http://www.freecodecamp.com/moigithub
Wolf Howard
@WolfHoward
Jan 14 2017 04:43 UTC
I've just completed the Profile Lookup lesson in the Javascript module. It took me a while to get a proper answer. I'm wondering if there's more than one way to accomplish the goal here?
John Paul Penaloza
@johnpyp
Jan 14 2017 04:43 UTC
Hey guys! I finally finished my Weather project after a while, any thoughts/optimizations? https://codepen.io/johnpyp/full/QdbGeO/
Ogundele Olumide
@Lumexralph
Jan 14 2017 04:48 UTC
@WolfHoward there's always more than one way when it comes to programming
:point_up: January 14, 2017 5:31 AM eureka!
Wolf Howard
@WolfHoward
Jan 14 2017 04:55 UTC
@Lumexralph touche

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

for (var i = 0; i < 4; i++) {
if (contacts[i]['firstName'] == firstName) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
}
return "No such property";
}
ans = "No such contact";
}

return ans;
// Only change code above this line
}
'''

CamperBot
@camperbot
Jan 14 2017 04:59 UTC
:bulb: to format code use backticks! ``` more info
Wolf Howard
@WolfHoward
Jan 14 2017 05:00 UTC
function lookUpProfile(firstName, prop) {
// Only change code below this line

  for (var i = 0; i < 4; i++) {
    if (contacts[i]['firstName'] == firstName) {
      if (contacts[i].hasOwnProperty(prop)) {
        return contacts[i][prop];
      }
      return "No such property";
    }
    ans = "No such contact";
  }

  return ans;
// Only change code above this line
}
Sorry for that first send. This was my solution. I kept running into an issue with dot notation and eventually realized that firstName was both a variable and an object key. Is there a dot notation style solution, or a more elegant method of achieving this result?
Ogundele Olumide
@Lumexralph
Jan 14 2017 05:02 UTC
@WolfHoward make i < contatcs.length in your for loop
Manish Giri
@Manish-Giri
Jan 14 2017 05:02 UTC
@WolfHoward your code will break if contacts has more than 5 elements
for (var i = 0; i < 4; i++)
Ammy3165
@Ammy3165
Jan 14 2017 05:02 UTC

help me to solve this problem, it's a reverse a string challenge
function reverseString(Str) {
Str = [];
return Str.reverse();

}

reverseString("hello");

CamperBot
@camperbot
Jan 14 2017 05:02 UTC
no wiki entry for: me to solve this problem its a reverse a string challenge function reversestringstr str return strreverse reversestringhello
Wolf Howard
@WolfHoward
Jan 14 2017 05:03 UTC
Good call.
@Manish-Giri @Lumexralph Thanks.
CamperBot
@camperbot
Jan 14 2017 05:03 UTC
wolfhoward sends brownie points to @manish-giri and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 729 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 3758 | @manish-giri |http://www.freecodecamp.com/manish-giri
Ogundele Olumide
@Lumexralph
Jan 14 2017 05:04 UTC
@WolfHoward and adding to @Manish-Giri you just return "No such contacts"no need for another variable
@Ammy3165 split the string before you reverse it
Manish Giri
@Manish-Giri
Jan 14 2017 05:04 UTC
:+1:
OGBigByrd
@OGBigByrd
Jan 14 2017 05:05 UTC
this is probably an easy fix but im having a hard time with the var myvar challenge to get a to initialize a any pointers?
Ogundele Olumide
@Lumexralph
Jan 14 2017 05:05 UTC
@Ammy3165 when you split a string, an array is returned, you reverse the array and join the array to make it a string
@OGBigByrd what are your instructions?
OGBigByrd
@OGBigByrd
Jan 14 2017 05:06 UTC
define a variable a with var and initialize it to a value of 9
heroiczero
@heroiczero
Jan 14 2017 05:06 UTC
@OGBigByrd set var a equal to 9
Ogundele Olumide
@Lumexralph
Jan 14 2017 05:07 UTC
@OGBigByrd how will you declare a variable? just a quick question
Wolf Howard
@WolfHoward
Jan 14 2017 05:07 UTC
@Luxemralph Ahhh. The ans assignment was my fix when the For loop wasn't iterating. Makes sense, just need to leave the return for the end.
Alex
@Joshua-A-Smith
Jan 14 2017 05:07 UTC

On Counting Cards Lesson I'm sort of confused how I should go about this


var count = 0;

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

    case 2: 
    case 3: 
    case 4: 
    case 5: 
    case 6:
      "Change Me" = "5 Bet";
      break;      





  }

  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(4); cc(5); cc(6);

I know I want to use a switch satatement

Ogundele Olumide
@Lumexralph
Jan 14 2017 05:07 UTC
@WolfHoward yeah
@Joshua-A-Smith you're to decrement or increment count in each cases of the switch statement
OGBigByrd
@OGBigByrd
Jan 14 2017 05:08 UTC
got it thanks guys
Ogundele Olumide
@Lumexralph
Jan 14 2017 05:09 UTC
@OGBigByrd you mention their names
Ammy3165
@Ammy3165
Jan 14 2017 05:10 UTC

@Lumexralph hey see this one, It's not running,
function reverseString(Str) {
Str = [];
var splitTheString = Str.split();
var reverseTheString = splitTheString.reverse();
var joinTheString= reverseTheString.join();
return joinTheString;

}

reverseString("hello");

Alex
@Joshua-A-Smith
Jan 14 2017 05:10 UTC
@Lumexralph
Like so?

var count = 0;

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

    case 2: 
      "Change Me" = +1;
      break;
    case 3: 
    case 4: 
    case 5: 
    case 6:





  }

  return "Change Me";
  // Only change code above this line
}
heroiczero
@heroiczero
Jan 14 2017 05:11 UTC
@Ammy3165 how do you want to split it gotta have something in the () for split and join
Ogundele Olumide
@Lumexralph
Jan 14 2017 05:11 UTC
@Joshua-A-Smith count += 1 not "changeMe" that'll result in a string
@Ammy3165 what's this for Str = []; ? also you use split with a separator .... string.split("")
Ammy3165
@Ammy3165
Jan 14 2017 05:12 UTC
@Lumexralph declaring Str as an array
Ogundele Olumide
@Lumexralph
Jan 14 2017 05:14 UTC
@Ammy3165 that will affect your operation because you'r only assigning an empty array to Str giving it a new value, you don't need to do that
Ammy3165
@Ammy3165
Jan 14 2017 05:15 UTC
I am just storing the value of the string as variable.
@Lumexralph
Ogundele Olumide
@Lumexralph
Jan 14 2017 05:16 UTC
@Ammy3165 which string?
Ammy3165
@Ammy3165
Jan 14 2017 05:17 UTC
@Lumexralph okk I got it.
Ogundele Olumide
@Lumexralph
Jan 14 2017 05:18 UTC
@Ammy3165 okay
Ammy3165
@Ammy3165
Jan 14 2017 05:19 UTC

@Lumexralph this is what I am running now, but where is the bug for reverse a string challenge,
function reverseString(Str) {
var splitTheString = Str.split();
var reverseTheString = splitTheString.reverse();
var joinTheString= reverseTheString.join();
return joinTheString;

}

reverseString("hello");

Ogundele Olumide
@Lumexralph
Jan 14 2017 05:20 UTC
@Ammy3165 you're not splitting anything , put a separator in the split method as argument like this split("")
heroiczero
@heroiczero
Jan 14 2017 05:21 UTC
@Ammy3165 Str.split(""); and .join("");
Ammy3165
@Ammy3165
Jan 14 2017 05:21 UTC
@heroiczero @Lumexralph why is it necessary?
heroiczero
@heroiczero
Jan 14 2017 05:21 UTC
@Ammy3165 have to know how you want to split the string
@Ammy3165 do you want to split it with a "space" or with a "letter" or just split each character
Ogundele Olumide
@Lumexralph
Jan 14 2017 05:22 UTC
heroiczero
@heroiczero
Jan 14 2017 05:23 UTC
@Ammy3165 it is the same with the .join() how do you want to join it?
Ammy3165
@Ammy3165
Jan 14 2017 05:23 UTC
@heroiczero @Lumexralph thanks buddy
CamperBot
@camperbot
Jan 14 2017 05:23 UTC
ammy3165 sends brownie points to @heroiczero and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 667 | @heroiczero |http://www.freecodecamp.com/heroiczero
:cookie: 730 | @lumexralph |http://www.freecodecamp.com/lumexralph
VictorMirchev
@VictorMirchev
Jan 14 2017 05:23 UTC
I'm supposed to call a constructor but I've never learnt how to do that? Can someone help
Ogundele Olumide
@Lumexralph
Jan 14 2017 05:24 UTC
@VictorMirchev what do you think a constructor is?
jakobmara
@jakobmara
Jan 14 2017 05:24 UTC

function rot13(str) { // LBH QVQ VG!
  var thing = "";
  var arr = [];
  var newStr = "";
  var code = 0;
  for (var i = 0; i < str.length; i++){
    code = str.charCodeAt(i);

    if (code + 13 > 90){
     code += 13;
     var remainder = 90 - code;
     code = 65 + remainder;
     arr.push(code); 
    }
    else{
      code = code + 13;
      arr.push(code);
    }

  }
  thing = String.fromCharCode(arr);  
  return thing;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Whenever I try and run this it returns a red dot doesn anyone know why?
does*
VictorMirchev
@VictorMirchev
Jan 14 2017 05:25 UTC
object in a function
something like that
var Car = function(wheels, seats, engines) {
//Change this constructor
this.wheels = 4;
this.seats = 5;
this.engines = 1;
};
this is my constructor and i have to call it
Ogundele Olumide
@Lumexralph
Jan 14 2017 05:25 UTC
@VictorMirchev a constructor is a function that's used to produce other objects
@VictorMirchev you're to create an instance of that constructor
VictorMirchev
@VictorMirchev
Jan 14 2017 05:26 UTC

Alter the Car constructor to use parameters to assign values to the wheels, seats, and engines properties.

Then call your new constructor with three number arguments and assign it to myCar to see it in action.

var myCar = new Car(3, 1, 2);
didnt work
Charan
@charan1998
Jan 14 2017 05:27 UTC

function destroyer() {
var arr = arguments[0];
var deleteElements = [];
for(var i = 1; i < arguments.length; i++) {
deleteElements.push(arguments[i]);
}
var newArr = arr.filter(function(val) {
return arr.indexOf(val) != -1;
});
return newArr;
}

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

Ogundele Olumide
@Lumexralph
Jan 14 2017 05:27 UTC
@VictorMirchev i think you need to have understanding of how constructor functions works
Charan
@charan1998
Jan 14 2017 05:27 UTC
i have to delete the other 2 arguments from the array
Can anyone tell me why it is not working?!
amarg26
@amarg26
Jan 14 2017 05:29 UTC
anybody worked on jquery datatable ??
Ogundele Olumide
@Lumexralph
Jan 14 2017 05:31 UTC
@VictorMirchev take a lil time with this it will help you solve that challenge, giving you solution won't help your learning https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object_prototypes
@VictorMirchev will you give it a try? and let me see what you come up with?
jakobmara
@jakobmara
Jan 14 2017 05:32 UTC
can someone help me with ceaser ciphers?
VictorMirchev
@VictorMirchev
Jan 14 2017 05:32 UTC
Yeah I'm reading it. thx
Alex
@Joshua-A-Smith
Jan 14 2017 05:33 UTC
On "Accessing Objects Properties with the Dot Operator" Does anyone care to elaborate? I'm confused
heroiczero
@heroiczero
Jan 14 2017 05:34 UTC
@Joshua-A-Smith you can access an object with the Object.Property
Alex
@Joshua-A-Smith
Jan 14 2017 05:35 UTC
@heroiczero
I'll give your link a quick read-through
But as for now I can't seem to get it to work for me...
// Setup
var testObj = {
  "hat": "ballcap",
  "shirt": "jersey",
  "shoes": "cleats"
};

// Only change code below this line

var hatValue = testObj."hat";      // Change this line
var shirtValue = testObj."shirt";    // Change this line
amarg26
@amarg26
Jan 14 2017 05:37 UTC
can anyone help me for jquery datatables ???
Ogundele Olumide
@Lumexralph
Jan 14 2017 05:37 UTC
@Joshua-A-Smith use testObj.hat not testObj.hat or you can just do testObj["hat"]...
Jor
@joreyesl
Jan 14 2017 05:37 UTC
@Joshua-A-Smith looks like you are trying to use dot notation, you don't need to use the quotes.
heroiczero
@heroiczero
Jan 14 2017 05:37 UTC
@Joshua-A-Smith you use "" for bracket notation or variables or parameters
Alex
@Joshua-A-Smith
Jan 14 2017 05:38 UTC
@Lumexralph @joreyesl @heroiczero
Indeed
Thanks a million!
CamperBot
@camperbot
Jan 14 2017 05:38 UTC
joshua-a-smith sends brownie points to @lumexralph and @joreyesl and @heroiczero :sparkles: :thumbsup: :sparkles:
:cookie: 159 | @joreyesl |http://www.freecodecamp.com/joreyesl
:cookie: 731 | @lumexralph |http://www.freecodecamp.com/lumexralph
:cookie: 669 | @heroiczero |http://www.freecodecamp.com/heroiczero
Ogundele Olumide
@Lumexralph
Jan 14 2017 05:38 UTC
@Joshua-A-Smith you need to spend time with the link @heroiczero gave you
Evan Kalvis
@evan17gr
Jan 14 2017 05:38 UTC
http://codepen.io/evan17gr/pen/qRENOO why is it not opening a new windows to tweet the quote?
VictorMirchev
@VictorMirchev
Jan 14 2017 05:41 UTC
@Lumexralph Got it!
Ogundele Olumide
@Lumexralph
Jan 14 2017 05:42 UTC
@VictorMirchev glad you did
@VictorMirchev can you show your code?
Manish Giri
@Manish-Giri
Jan 14 2017 05:44 UTC
@evan17gr there's a problem here
 $("#twitter").click(function(){
    $(this).attr("href", 'https://twitter.com/intent/tweet?text=' + data.quoteText+data.quoteAuthor);

  });
data is undefined inside the function
Evan Kalvis
@evan17gr
Jan 14 2017 05:46 UTC
@Manish-Giri it doesnt even open a new window for some reason
Manish Giri
@Manish-Giri
Jan 14 2017 05:48 UTC
@evan17gr that can be fixed

 $("#twitter").click(function(){
   window.open('http://www.google.com','_blank');
  });
Jor
@joreyesl
Jan 14 2017 05:48 UTC
@evan17gr I belive the .click event overrides the default click that would have happened.
Evan Kalvis
@evan17gr
Jan 14 2017 05:49 UTC
@Manish-Giri ok ty now its working
CamperBot
@camperbot
Jan 14 2017 05:49 UTC
evan17gr sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: evan17gr already gave manish-giri points
Manish Giri
@Manish-Giri
Jan 14 2017 05:50 UTC
@evan17gr :+1:
jakobmara
@jakobmara
Jan 14 2017 05:55 UTC
can someone help me with one of the basic algorithm challenges?
Nathan Parsons
@10milliondollarwebpage
Jan 14 2017 05:56 UTC
@unlawfulspoonisback
a group of developers are making an operating system, requirements are that you have to know a compiled programming language if you want to join in go to https://gitter.im/Atom-io-Atom/Lobby
another requirement is that you have to be younger than 18
Ogundele Olumide
@Lumexralph
Jan 14 2017 05:58 UTC
@unlawfulspoonisback am 27 :worried:
Nathan Parsons
@10milliondollarwebpage
Jan 14 2017 05:59 UTC
you can join though @Lumexralph
if you know a compiled language
Ogundele Olumide
@Lumexralph
Jan 14 2017 05:59 UTC
@unlawfulspoonisback i'll pass
@unlawfulspoonisback :+1:
wlagos1992
@wlagos1992
Jan 14 2017 06:00 UTC
@Lumexralph why is there a 0 at the end of this operation

var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.

var singleVal = array.reduce(function(prevVal, CurrVal) {

  return prevVal+CurrVal; }, 0);
Ogundele Olumide
@Lumexralph
Jan 14 2017 06:01 UTC
@wlagos1992 it's optional but since it's provided it will be used as the prevVal of your callback
Gina Wilson
@photuris5
Jan 14 2017 06:02 UTC

starting to learn js. What am I missing for this challenge?

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
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(-20);

Ogundele Olumide
@Lumexralph
Jan 14 2017 06:02 UTC
@wlagos1992 there're time you can ignore it but it's always good to use it, remove that 0 and see what you get from the reduce method
wlagos1992
@wlagos1992
Jan 14 2017 06:03 UTC
@photuris5 think back to algerbra just give the computer an X value so it is forever solvable
Ogundele Olumide
@Lumexralph
Jan 14 2017 06:03 UTC
@photuris5 use your celsius parameter, it takes different values for your function when called
wlagos1992
@wlagos1992
Jan 14 2017 06:04 UTC
@Lumexralph okay so real quick .reduce goes through my array and as long as i put the function( X, Y ) it will apply whatever i tell it to do for X and Y value by value?
Ogundele Olumide
@Lumexralph
Jan 14 2017 06:05 UTC
@wlagos1992 don't get it mixed up X is accumulator/previous value and Y is nextValue
wlagos1992
@wlagos1992
Jan 14 2017 06:05 UTC

@photuris5 its not telling you to solve those numbers its telling you to give the computer an equation to solve it

var x = celcius then x+5 /987654 or what ever the numbers are

and what exactly is an accumulator?
Ogundele Olumide
@Lumexralph
Jan 14 2017 06:06 UTC
@wlagos1992 accumulator is what holds the value of the result returned from last callback on the array element
wlagos1992
@wlagos1992
Jan 14 2017 06:06 UTC
reduce has an optional second argument which can be used to set the initial value of the accumulator. If no initial value is specified it will be the first array element and currentVal will start with the second array element.
is that the 0 you were talking about?
oops sorry i thought it would put breaks
reduce has an optional second argument which can be used to set the initial value of the accumulator. If no initial value is specified it will be the first array element and currentVal will start with the second array element.
Ogundele Olumide
@Lumexralph
Jan 14 2017 06:06 UTC
@wlagos1992 yes
@wlagos1992 hope you understand now?
wlagos1992
@wlagos1992
Jan 14 2017 06:08 UTC
@Lumexralph yes thank you
CamperBot
@camperbot
Jan 14 2017 06:08 UTC
wlagos1992 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 732 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jan 14 2017 06:08 UTC
@wlagos1992 you're welcome
Gina Wilson
@photuris5
Jan 14 2017 06:12 UTC
@wlagos1992 Thanks for the help! Late night, brain is slowing down.
CamperBot
@camperbot
Jan 14 2017 06:12 UTC
photuris5 sends brownie points to @wlagos1992 :sparkles: :thumbsup: :sparkles:
:cookie: 181 | @wlagos1992 |http://www.freecodecamp.com/wlagos1992
Gina Wilson
@photuris5
Jan 14 2017 06:17 UTC
@wlagos1992 can't believe I was making that so hard.
Addison Dalton
@Addison-Dalton
Jan 14 2017 06:20 UTC

Doing the Caesar's Cipher problem. I have it working fine, but I'm wondering if my code is too complex. Just looking for some tips to see if I could clean it up anywhere. here is my code:

function rot13(str) { // LBH QVQ VG!
  var arrOfChar = str.split("");
  //console.log(arrOfChar);
  for(var i = 0; i < arrOfChar.length; i++){
    if(arrOfChar[i].charCodeAt(0) >= 65 && arrOfChar[i].charCodeAt(0) <=90){
      //console.log("Begin: " +arrOfChar[i]+" code is: "+arrOfChar[i].charCodeAt(0));
      if(arrOfChar[i].charCodeAt(0) +13 > 90){
        arrOfChar[i] = String.fromCharCode(((arrOfChar[i].charCodeAt(0) + 13)%90)+64);
      }else{
        arrOfChar[i] = String.fromCharCode(arrOfChar[i].charCodeAt(0) + 13); 
      }
    }
  }

  return arrOfChar.join("");
}

rot13("SERR PBQR PNZC");

Thanks!

Mike
@mbooth364
Jan 14 2017 06:21 UTC
im trying to write a for loop to print out each letter of a string individually, can someone show me how to do this please?
Jor
@joreyesl
Jan 14 2017 06:21 UTC
@Addison-Dalton Its readable, i see no problem with it
wlagos1992
@wlagos1992
Jan 14 2017 06:22 UTC
@photuris5 happens to us all

function reverseString(str) {
  str.split();
  str.reverse();
  str.join();
  return str;
}

reverseString("hello");
maybe its late but why doesnt this work haha
Ogundele Olumide
@Lumexralph
Jan 14 2017 06:23 UTC
@mbooth364 treat the string as an array of characters
@wlagos1992 split()
wlagos1992
@wlagos1992
Jan 14 2017 06:23 UTC
cause im not telling it where to split
Ogundele Olumide
@Lumexralph
Jan 14 2017 06:24 UTC
@wlagos1992 yes
wlagos1992
@wlagos1992
Jan 14 2017 06:24 UTC
is there a /\c for every character?
Ogundele Olumide
@Lumexralph
Jan 14 2017 06:24 UTC
and you should watch your join() too
Jor
@joreyesl
Jan 14 2017 06:24 UTC
@wlagos1992 you call split() but what do you want to use as the seperator
Ogundele Olumide
@Lumexralph
Jan 14 2017 06:24 UTC
@wlagos1992 i don't understand
wlagos1992
@wlagos1992
Jan 14 2017 06:24 UTC
how do i tell it to split every letter?
Mike
@mbooth364
Jan 14 2017 06:25 UTC
this is what I have but it just prints out the word as a whole var fruits = ['apple'];
for(var i = 0; i < fruits.length; i++){
console.log(fruits[i]);
}
Ogundele Olumide
@Lumexralph
Jan 14 2017 06:25 UTC
@wlagos1992 split("")
@mbooth364 because it's in an array
wlagos1992
@wlagos1992
Jan 14 2017 06:25 UTC
okay i have that, not it says reverse() is not a function so let me go look back at that
Jor
@joreyesl
Jan 14 2017 06:26 UTC
@wlagos1992 also when you use reverse() you are using it on the string not the array
Ogundele Olumide
@Lumexralph
Jan 14 2017 06:26 UTC
@mbooth364 do fruits[0] to hold the strings
Jor
@joreyesl
Jan 14 2017 06:27 UTC
@wlagos1992 when you use split() it returns an array, but you are not assigning it to anything. Then when you use reverse() it has to be on the array that gets created, not on the string that you used split on.
Ogundele Olumide
@Lumexralph
Jan 14 2017 06:27 UTC
@wlagos1992 remember strings are immutable, you can just store a value from their resulting operation, you can't change it
wlagos1992
@wlagos1992
Jan 14 2017 06:28 UTC

function reverseString(str) {
  var here =str.split("");
  here.reverse();
 str= here.join();
  return str;
}

reverseString("hello");
Ogundele Olumide
@Lumexralph
Jan 14 2017 06:28 UTC
@mbooth364 let fruits[0] replace fruits in your loop
Manish Giri
@Manish-Giri
Jan 14 2017 06:28 UTC
@wlagos1992 don't you need to pass in something to .join()
wlagos1992
@wlagos1992
Jan 14 2017 06:28 UTC
forgot the "" in the join but i got it thank you @joreyesl and @Lumexralph
CamperBot
@camperbot
Jan 14 2017 06:28 UTC
wlagos1992 sends brownie points to @joreyesl and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 162 | @joreyesl |http://www.freecodecamp.com/joreyesl
:warning: wlagos1992 already gave lumexralph points
Muhammad Hasham
@MohammadHasham
Jan 14 2017 06:29 UTC
Can anyone help me regarding some jQuery?
Jor
@joreyesl
Jan 14 2017 06:30 UTC
@MohammadHasham feel free to ask the question, plenty of ppl here can take a look at it :)
Muhammad Hasham
@MohammadHasham
Jan 14 2017 06:31 UTC
i want to make the color appear and then dissapear only once (it shall not repeat) what i tried to do is this,
<input type="text" class="liveEvents" />

JS:
function moveClass() {
    $('.liveEvents')
        .addClass('liveEventsActive');

}
function removeClass(){
$('.liveEvents')
         .addClass('liveEvents');
}

setInterval(moveClass, 2000);
setInterval(removeClass,2000);

CSS:
.liveEvents { background-color: Red; }
.liveEventsActive{ background-color: Green; }
@joreyesl @Manish-Giri
it is just making it green but not making it again red!
Jor
@joreyesl
Jan 14 2017 06:32 UTC
@MohammadHasham well you added both classes to it, so it will retain the last class' color
few ways around it, it so make sure that you remove the previous class when you want to add a new class
Muhammad Hasham
@MohammadHasham
Jan 14 2017 06:33 UTC
@joreyesl yeah this is what i think but it retains the first class color i.e;red
green !!! typos!
i want to make that to again become red
Addison Dalton
@Addison-Dalton
Jan 14 2017 06:33 UTC
@joreyesl Ok! Sorry to reply back so late. Thanks!
CamperBot
@camperbot
Jan 14 2017 06:33 UTC
addison-dalton sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 163 | @joreyesl |http://www.freecodecamp.com/joreyesl
Ogundele Olumide
@Lumexralph
Jan 14 2017 06:34 UTC
@MohammadHasham did the TYPOS got you scared ? :laughing:
Muhammad Hasham
@MohammadHasham
Jan 14 2017 06:34 UTC
@Lumexralph :smile:
Rebecca Vest
@idahogurl
Jan 14 2017 06:34 UTC
I'm having issues with the exact change challenge
Jor
@joreyesl
Jan 14 2017 06:34 UTC
@MohammadHasham in the remove class function you should try using .removeClass()
Ogundele Olumide
@Lumexralph
Jan 14 2017 06:34 UTC
@idahogurl i hope it's not NaN issue?
Muhammad Hasham
@MohammadHasham
Jan 14 2017 06:34 UTC
Does it not take any params?
Rebecca Vest
@idahogurl
Jan 14 2017 06:35 UTC
My code is failing this test. 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]])
Jor
@joreyesl
Jan 14 2017 06:35 UTC
@MohammadHasham yes it does take params
Ogundele Olumide
@Lumexralph
Jan 14 2017 06:35 UTC
have a great time and fun coding people, am out
Muhammad Hasham
@MohammadHasham
Jan 14 2017 06:35 UTC
so how can i write that like that removeClass()?
Rebecca Vest
@idahogurl
Jan 14 2017 06:35 UTC
I get 80 for the twenties
Jor
@joreyesl
Jan 14 2017 06:36 UTC
@MohammadHasham well you want to make it red again, so remove the class that is making it green
Muhammad Hasham
@MohammadHasham
Jan 14 2017 06:37 UTC
ok i'll give it a try!
@joreyesl
Rebecca Vest
@idahogurl
Jan 14 2017 06:38 UTC
I've stepped through it with the developer tools and it makes sense to me. What I am missing?
function getCurrencyCounts(amount, currencyValue) {
var count = 0;
while(amount >= currencyValue) {
count++;
amount -= currencyValue;
}
return count;
}
Muhammad Hasham
@MohammadHasham
Jan 14 2017 06:38 UTC
it is not getting back to green ! @joreyesl
Rebecca Vest
@idahogurl
Jan 14 2017 06:39 UTC
@MohammadHasham Do you have the right selector?
Jor
@joreyesl
Jan 14 2017 06:39 UTC
@MohammadHasham it starts red, then green, but not getting back to red?
Muhammad Hasham
@MohammadHasham
Jan 14 2017 06:39 UTC
no it starts from green .addClass() makes that to red and then it doesn't return to green
@joreyesl
@idahogurl am i missing something? i have used '$' by the way
Rebecca Vest
@idahogurl
Jan 14 2017 06:41 UTC
Like if I was trying to select all the buttons off the page with jQuery. I would use $("button")
Jor
@joreyesl
Jan 14 2017 06:41 UTC
@MohammadHasham for me it looks like it starts of red since the input has class="liveEvents" which the CSS says red
Rebecca Vest
@idahogurl
Jan 14 2017 06:41 UTC
What you put in the quotes is called your selector
Muhammad Hasham
@MohammadHasham
Jan 14 2017 06:41 UTC
@joreyesl @idahogurl i'll again check that

@joreyesl Thanks i did that

function moveClass() {
    $('.liveEvents')
        .addClass('liveEventsActive');
}
function removeClass() {
    $('.liveEvents')
        .addClass('liveEvents');
}

setInterval(moveClass, 1000);
setInterval(removeClass,1000);

This is what i did
That's working now.

CamperBot
@camperbot
Jan 14 2017 06:42 UTC
mohammadhasham sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 164 | @joreyesl |http://www.freecodecamp.com/joreyesl
Sarah
@Shoyren
Jan 14 2017 06:43 UTC
Hi, can anyone tell me why sometimes Javascript will create decimals if you add recursively like here? I'm trying to do the "Exact Change" algorithm, but my answers are wrong because when I run it, I get a random decimal subtracted somewhere: https://jsfiddle.net/shoyren/uwkf4d74/
redoz94
@redoz94
Jan 14 2017 06:43 UTC
greetings fellow programmers, could some one please help me out in this exercise? My code doesnt seem to pass...
Rebecca Vest
@idahogurl
Jan 14 2017 06:43 UTC
Why would you select liveEvents and put liveEvents back on?
Rebecca Vest
@idahogurl
Jan 14 2017 06:44 UTC
Use toFixed(2)
@Shoyren
Rebecca Vest
@idahogurl
Jan 14 2017 06:44 UTC
It has something to do with precision
Umm...redoz94 there is a line here
Sarah
@Shoyren
Jan 14 2017 06:45 UTC
@idahogurl Thanks!
CamperBot
@camperbot
Jan 14 2017 06:45 UTC
shoyren sends brownie points to @idahogurl :sparkles: :thumbsup: :sparkles:
:cookie: 292 | @idahogurl |http://www.freecodecamp.com/idahogurl
Markus Kiili
@Masd925
Jan 14 2017 06:45 UTC
@Shoyren The robust way to avoid rounding problems is to use penny amounts that are safe integers.
redoz94
@redoz94
Jan 14 2017 06:45 UTC
@idahogurl sorry! im new to this. Wont happen again
Jor
@joreyesl
Jan 14 2017 06:45 UTC
@redoz94 look at where you are defining myStr, you are concatenating some adjective to it already
Rebecca Vest
@idahogurl
Jan 14 2017 06:46 UTC
@Shoyren let me know if you pass all the tests
I'm stuck with the 100 - 3.26 one
redoz94
@redoz94
Jan 14 2017 06:47 UTC
@joreyesl so it should work, right?
Justin
@tanpaopao
Jan 14 2017 06:47 UTC
function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes = 1) {
    return "Hole-in-one!";
  } else if (strokes <= par - 2) {
    return "Eagle";
  } else if (strokes == par - 1) {
    return "Birdie";
  } else if (strokes == par) {
    return "Par";
  } else if (strokes == par + 1) {
    return "Bogey";
  } else if (strokes == par + 2) {
    return "Double Bogey";
  } else {
    return "Go Home!";
  }

  // Only change code above this line
}

// Change these values to test
golfScore(5, 3);
Could someone tell me what's wrong with my assignment?
Jor
@joreyesl
Jan 14 2017 06:47 UTC
instead of this >>>> var myStr = "Learning to code is " + someAdjective;
they want this >>>> someAdjective += myStr;
Markus Kiili
@Masd925
Jan 14 2017 06:47 UTC
@tanpaopao = is assignment operator.
if (strokes = 1) {
Rebecca Vest
@idahogurl
Jan 14 2017 06:47 UTC
Yup @Masd925
redoz94
@redoz94
Jan 14 2017 06:48 UTC
@joreyesl
var someAdjective;
var myStr = "Learning to code is ";
someAdjective += myStr;
Justin
@tanpaopao
Jan 14 2017 06:48 UTC
@Masd925 haha, I see. Thank you. How stupid I am!
CamperBot
@camperbot
Jan 14 2017 06:48 UTC
tanpaopao sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3159 | @masd925 |http://www.freecodecamp.com/masd925
redoz94
@redoz94
Jan 14 2017 06:48 UTC
@joreyesl not working
Rebecca Vest
@idahogurl
Jan 14 2017 06:49 UTC
It starts at 96.76, you subtract 20, that is one time
redoz94
@redoz94
Jan 14 2017 06:49 UTC
var someAdjective;
var myStr = "Learning to code is ";
someAdjective += myStr; @joreyesl
Joseph
@revisualize
Jan 14 2017 06:49 UTC
@joreyesl Actually they dont.
Jor
@joreyesl
Jan 14 2017 06:49 UTC
@redoz94 almost, but you have someAdjective and myStr reversed
Rebecca Vest
@idahogurl
Jan 14 2017 06:49 UTC
Now it is 76.76, subtract 20, count is 2
Now it is is 56.76, subtract 20, count is 3
Jor
@joreyesl
Jan 14 2017 06:50 UTC
@revisualize yea read it backwards initially, my mistake
Joseph
@revisualize
Jan 14 2017 06:50 UTC
someAdjective should be set to a string at least 3 characters long
Append someAdjective to myStr using the += operator
Rebecca Vest
@idahogurl
Jan 14 2017 06:50 UTC
Now it is 36.76, subtract 20, count is 4
Joseph
@revisualize
Jan 14 2017 06:50 UTC
// Example
var anAdjective = "awesome!";
var ourStr = "Free Code Camp is ";
ourStr += anAdjective;
Rebecca Vest
@idahogurl
Jan 14 2017 06:50 UTC
that is 80 not 60.
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]]) should return [["TWENTY", 60.00], ["TEN", 20.00], ["FIVE", 15.00], ["ONE", 1.00], ["QUARTER", 0.50], ["DIME", 0.20], ["PENNY", 0.04]]
redoz94
@redoz94
Jan 14 2017 06:50 UTC
@joreyesl
var someAdjective="Awesome";
var myStr = "Learning to code is ";
myStr =+ someAdjective ;
Joseph
@revisualize
Jan 14 2017 06:50 UTC
@redoz94 =+ ???? backwards
Jor
@joreyesl
Jan 14 2017 06:50 UTC
@redoz94 yea that looks right
rackey0623
@rackey0623
Jan 14 2017 06:51 UTC

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

redoz94
@redoz94
Jan 14 2017 06:51 UTC
@joreyesl still not working though
rackey0623
@rackey0623
Jan 14 2017 06:51 UTC
how to solve this question?
Rebecca Vest
@idahogurl
Jan 14 2017 06:51 UTC
What am I doing wrong!! Ahhhhhh!!!
rackey0623
@rackey0623
Jan 14 2017 06:51 UTC
how to get the result
Joseph
@revisualize
Jan 14 2017 06:51 UTC
@redoz94 Well, you need to do += correctly.
Jor
@joreyesl
Jan 14 2017 06:51 UTC
@redoz94 woops missed the typo, @revisualize is right should be += not =+\
Joseph
@revisualize
Jan 14 2017 06:52 UTC
@rackey0623 It is just string concatenation with variables parameters.
redoz94
@redoz94
Jan 14 2017 06:52 UTC
@revisualize ahhhhhh so stupid of me! thanks man! and thanks to you too @joreyesl !
CamperBot
@camperbot
Jan 14 2017 06:52 UTC
redoz94 sends brownie points to @revisualize and @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 165 | @joreyesl |http://www.freecodecamp.com/joreyesl
:star2: 2966 | @revisualize |http://www.freecodecamp.com/revisualize
rackey0623
@rackey0623
Jan 14 2017 06:52 UTC
i still don't get the meaning
Markus Kiili
@Masd925
Jan 14 2017 06:52 UTC
@idahogurl You could also get the count by amount/currencyValue>>0. ES5 JS lacks a trunc operator so that is why binary truncation is used.
rackey0623
@rackey0623
Jan 14 2017 06:52 UTC
i don't know what be asked to do
Joseph
@revisualize
Jan 14 2017 06:52 UTC
@rackey0623 Did you click the link that I just supplied?
Rebecca Vest
@idahogurl
Jan 14 2017 06:53 UTC
??
rackey0623
@rackey0623
Jan 14 2017 06:53 UTC
yes i'm reading
Rebecca Vest
@idahogurl
Jan 14 2017 06:53 UTC
What is ">>"
Joseph
@revisualize
Jan 14 2017 06:53 UTC
@idahogurl SORRY!
Markus Kiili
@Masd925
Jan 14 2017 06:53 UTC
@idahogurl It just truncates the float to an integer 20/3>>0; // 6
rackey0623
@rackey0623
Jan 14 2017 06:53 UTC
i'll check out later ,thx
@revisualize
Rebecca Vest
@idahogurl
Jan 14 2017 06:54 UTC
K. so 96.76 / 20 will give me 3?
Joseph
@revisualize
Jan 14 2017 06:54 UTC
@rackey0623 Later?
rackey0623
@rackey0623
Jan 14 2017 06:54 UTC
i'm reading it, i cost me sometime
Markus Kiili
@Masd925
Jan 14 2017 06:54 UTC
@idahogurl 20 fits 4 times into 96.76
Rebecca Vest
@idahogurl
Jan 14 2017 06:54 UTC
Then the challenge has a bug
rackey0623
@rackey0623
Jan 14 2017 06:55 UTC
cause i'm Chinese, i can't read it fluently
Joseph
@revisualize
Jan 14 2017 06:55 UTC
@rackey0623 Oh.
rackey0623
@rackey0623
Jan 14 2017 06:55 UTC
thanks you so much by the way
Joseph
@revisualize
Jan 14 2017 06:55 UTC
@rackey0623 One second.
rackey0623
@rackey0623
Jan 14 2017 06:55 UTC
okay
Rebecca Vest
@idahogurl
Jan 14 2017 06:56 UTC
How do you get 3 twenties from the price of 3.26 with 100.0 cash given
Markus Kiili
@Masd925
Jan 14 2017 06:56 UTC
@idahogurl You need to take into account what bills are in the register.
rackey0623
@rackey0623
Jan 14 2017 06:56 UTC
yes?
Rebecca Vest
@idahogurl
Jan 14 2017 06:57 UTC
Awww....that makes sense!
Joseph
@revisualize
Jan 14 2017 06:57 UTC
@rackey0623 Same lesson but, using multiple variables.
Rebecca Vest
@idahogurl
Jan 14 2017 06:57 UTC
Thank you @Masd925 Markus
CamperBot
@camperbot
Jan 14 2017 06:57 UTC
idahogurl sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3160 | @masd925 |http://www.freecodecamp.com/masd925
rackey0623
@rackey0623
Jan 14 2017 06:57 UTC
i've finished this one
Joseph
@revisualize
Jan 14 2017 06:57 UTC

@rackey0623 Example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.

rackey0623
@rackey0623
Jan 14 2017 06:58 UTC
why there is an "@" in front of revisualize
what does an "@" uses for?
Jor
@joreyesl
Jan 14 2017 06:59 UTC
@rackey0623 he's using it to signify the username, thats just an example he made so you can see how to complete the challenge
rackey0623
@rackey0623
Jan 14 2017 06:59 UTC
thanks !
it takes time to understand, i'm new on javascribe
JuscelinoJunior
@JuscelinoJunior
Jan 14 2017 07:00 UTC
anybody help me please? I don't understand Return Early Pattern for Functions callenge
Joseph
@revisualize
Jan 14 2017 07:01 UTC
@rackey0623 It's just a string
JuscelinoJunior
@JuscelinoJunior
Jan 14 2017 07:02 UTC

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

// 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(-1,-2);```

Markus Kiili
@Masd925
Jan 14 2017 07:02 UTC
@JuscelinoJunior You need to test function parameters with an if and return undefined;.
rackey0623
@rackey0623
Jan 14 2017 07:02 UTC
whould u plz finish this for me so i can understand what i need to do in this case?
the explanation makes me confuse
JuscelinoJunior
@JuscelinoJunior
Jan 14 2017 07:04 UTC
thanks @Masd925 The challenge's explanation wasn't clear
CamperBot
@camperbot
Jan 14 2017 07:04 UTC
juscelinojunior sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3161 | @masd925 |http://www.freecodecamp.com/masd925
Muhammad Hasham
@MohammadHasham
Jan 14 2017 07:06 UTC
can anyone help me with this code snippet
else if (x == 3) {
        //red
         function redAddition(){
        $('#red-btn').addClass('.redClass')
        }
        function redSubtraction(){
          $('#red-btn').addClass('.redNewClass');
        }
        setInterval(redAddition,1000);
        setInterval(redSubtraction,1000);
        //red
        arr[i] = x; //arr[2] = x;
        i++;
      }
redoz94
@redoz94
Jan 14 2017 07:06 UTC
https://www.freecodecamp.com/challenges/word-blanks i dont get this guys. What am i supposed to be doing here?
Joseph
@revisualize
Jan 14 2017 07:06 UTC
The function declaration was set up as... function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) giving the function name as wordBlanks and with four parameter of myNoun, myAdjective, myVerb and myAdverb`. There is more that I could go into (if you want I can) but, I'll sum it up with: Parameters are variable-like objects that represent the values that get passed into your function from the function call (arguments). (You basically treat them like variables.)
Jor
@joreyesl
Jan 14 2017 07:07 UTC
@redoz94 you need to concatenate the noun adjective, verb, and adverb into a sentence
Ivan Ngundela
@ingundela
Jan 14 2017 07:08 UTC
hello everyone,,, please help with the challenge Filter Arrays with filter
my code is
var newArray = oldArray.filter(function(val) {
  return oldArray < 6;
});
redoz94
@redoz94
Jan 14 2017 07:09 UTC
@joreyesl myNoun + myAdjective + myVerb + myAdverb;
like this @joreyesl ?
rackey0623
@rackey0623
Jan 14 2017 07:10 UTC

```function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "wordblanks" + myNoun + myAdjective + myVerb + myAdverb ;
// Your code below this line
myNoun = "dog";
myAdjective = "big";
myVerb = "ran";
myAdverb = "quickly";

// Your code above this line
return result;
}

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

still don't get it..
redoz94
@redoz94
Jan 14 2017 07:11 UTC

@joreyesl function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";