These are chat archives for FreeCodeCamp/HelpJavaScript

30th
Jan 2017
afennell95
@afennell95
Jan 30 2017 00:03
I got it! thanks for the help guys
Louis Girifalco
@flyblackbox
Jan 30 2017 00:03
I am getting an error TypeError: str.prototype is undefined.. lil help?
function findLongestWord(str) {
  str.split(" ");
  str.prototype.sort(function(a, b) {return a.length-b.length;});
  return str.length[0];
}
findLongestWord("The quick brown fox jumped over the lazy dog");
xemexpress
@xemexpress
Jan 30 2017 00:04
@flyblackbox you don't need to put ".prototype" there~
Louis Girifalco
@flyblackbox
Jan 30 2017 00:04
@xemexpress without prototype, I get: TypeError: str.sort is not a function
Pieter Stokkink
@forkerino
Jan 30 2017 00:07
@flyblackbox .split doesn't alter str, it just splits it and returns a new array, you have to store it somewhere or call sort on it immediately.
xemexpress
@xemexpress
Jan 30 2017 00:07
@flyblackbox I wouldn't use sort(). After you split the string, compare the lengths of each word one by one and then take the longest
Pieter Stokkink
@forkerino
Jan 30 2017 00:07
@flyblackbox basically you try to sort a string.
0319
@0319
Jan 30 2017 00:07
I don't understand what it is asking for:
Pieter Stokkink
@forkerino
Jan 30 2017 00:07
which is the wrong type, so you get a typeerror
0319
@0319
Jan 30 2017 00:07

Using var, declare a global variable myGlobal outside of any function. Initialize it with a value of 10.

Inside function fun1, assign 5 to oopsGlobal without using the var keyword.

Please help
Pieter Stokkink
@forkerino
Jan 30 2017 00:09
@0319 have you written any code?
Louis Girifalco
@flyblackbox
Jan 30 2017 00:09
@xemexpress Wouldn’t it be good to just sort them by character length and then return the first value in the array?
0319
@0319
Jan 30 2017 00:10
Yeah but it says it is wrong @forkerino
Pieter Stokkink
@forkerino
Jan 30 2017 00:10
@flyblackbox sorting is one way to do it.
@0319 show your code, it will be easier to see where your thinking goes wrong.
@flyblackbox it takes a few more steps than just looking at the lengths of all the elements, but it works.
xemexpress
@xemexpress
Jan 30 2017 00:12
@flyblackbox know that the split() won't change the string you are working on to an array
Edgar Pan
@edgaryp
Jan 30 2017 00:13
Any hints for Wherefore art thou?
function whatIsInAName(collection, source) {

  var arr = [];
  var temp = {};

  for (var i = 0; i < collection.length; i++) {
    var j = 0;
    while (j < source.length) {
      if (collection[i].hasOwnProperty(Object.keys(source)[j]) && collection[i][Object.keys(source)[j]] === source[j]) {
      temp = collection[i];
      arr.push(temp);
      }
      j++;
    }
  }

  return arr;
}
whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
thierrybgentile
@thierrybgentile
Jan 30 2017 00:13
I've done it! As i'm getting back into it, does that look like a good/efficient way to this https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0A%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20contacts.length%3B%20i%2B%2B)%20%7B%0A%20%20%20%20if%20(contacts%5Bi%5D.firstName%20%3D%3D%3D%20firstName)%20%7B%0A%20%20%20%20%20%20if%20(contacts%5Bi%5D.hasOwnProperty(prop))%20return%20contacts%5Bi%5D%5Bprop%5D%3B%0A%20%20%20%20%20%20else%20return%20%22No%20such%20property%22%3B%0A%20%20%20%20%7D%0A%20%20%7D%20%20%20%20%0A%20%20%0A%20%20return%20%22No%20such%20contact%22%3B%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Akira%22%2C%20%22likes%22)%3B%0A
Pieter Stokkink
@forkerino
Jan 30 2017 00:14
@thierrybgentile please just copy/paste your code here. If I click this link, my elegant solution will be replaced by whatever you wrote. :P
taltmann42
@taltmann42
Jan 30 2017 00:14
@thierrybgentile looks fine to me :thumbsup:
xemexpress
@xemexpress
Jan 30 2017 00:14

Try this

function findLongestWord(str) {
  var array = str.split(" ");
  array.sort(function(a, b) {return b.length-a.length;});
  return array[0].length;
}

@flyblackbox

Louis Girifalco
@flyblackbox
Jan 30 2017 00:15
@xemexpress OK so this code solved the problem by sorting. But how would you look at the length of all the elements and return the highest?
function findLongestWord(str) {
  str = str.split(" ").sort(function(a, b) {return b.length-a.length;});
  return str[0].length;}
findLongestWord("The quick brown fox jumped over the lazy dog");
Sean Kelly
@spkellydev
Jan 30 2017 00:16
var listItems = document.getElementById("#intPortList").getElementsByTagName('li');
is there a reason this would line of JS would return "Uncaught TypeError: Cannot read property 'getElementsByTagName' of null" in the devl tools console?
Pieter Stokkink
@forkerino
Jan 30 2017 00:17
@flyblackbox you can create a variable to store the longest word up until then, go over the array in a loop and compare, reassigning if needed. OR (imo preferably) you can use .reduce to just keep the longest one.
thierrybgentile
@thierrybgentile
Jan 30 2017 00:17
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName === firstName) {
      if (contacts[i].hasOwnProperty(prop)) return contacts[i][prop];
      else return "No such property";
    }
  }    

  return "No such contact";
// Only change code above this line
}
@forkerino
xemexpress
@xemexpress
Jan 30 2017 00:17
@flyblackbox
  1. split the string to get an array
  2. loop through each element in the array and keep track with their length
  3. return the longest
thierrybgentile
@thierrybgentile
Jan 30 2017 00:17
thanks @taltmann42
CamperBot
@camperbot
Jan 30 2017 00:17
thierrybgentile sends brownie points to @taltmann42 :sparkles: :thumbsup: :sparkles:
:cookie: 412 | @taltmann42 |http://www.freecodecamp.com/taltmann42
Pieter Stokkink
@forkerino
Jan 30 2017 00:17
@thierrybgentile Looks good!
Edgar Pan
@edgaryp
Jan 30 2017 00:20

Anybody?

Any hints for Wherefore art thou?

function whatIsInAName(collection, source) {

  var arr = [];
  var temp = {};

  for (var i = 0; i < collection.length; i++) {
    var j = 0;
    while (j < source.length) {
      if (collection[i].hasOwnProperty(Object.keys(source)[j]) && collection[i][Object.keys(source)[j]] === source[j]) {
      temp = collection[i];
      arr.push(temp);
      }
      j++;
    }
  }

  return arr;
}
whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
Pieter Stokkink
@forkerino
Jan 30 2017 00:20
@spkellydev only reason I can think of is that there are no li tags with the id intPortList.
Sean Kelly
@spkellydev
Jan 30 2017 00:21

@forkerino I'm really challenged by this, I can't seem to figure out whats causing the error

    <ul id="intPortList">
      <li>This is a test Item</li>
    </ul>

var listItems = document.getElementById("#intPortList").getElementsByTagName('li');

for (var i = 0; i<listItems.lenght; i++) {
  listItems[i].addEventListener('click',activateList);
}
function activateList() {
  alert("Click detected!");
}
thierrybgentile
@thierrybgentile
Jan 30 2017 00:21
@forkerino ok great! thank you
CamperBot
@camperbot
Jan 30 2017 00:21
thierrybgentile sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:cookie: 756 | @forkerino |http://www.freecodecamp.com/forkerino
xemexpress
@xemexpress
Jan 30 2017 00:21
@flyblackbox
function findLongestWord(str) {
  var longest = 0;
  var array = str.split(' ');
  for (var i = 0; i < array.length; i++) {
    var len = array[i].length;
    if (len > longest) {
      longest = len;
    }
  }
  return longest;
}
Pieter Stokkink
@forkerino
Jan 30 2017 00:24
@spkellydev li is a childNode of the element with that id, so you need to use this
@xemexpress @flyblackbox or
return str.split(" ").reduce((a,b) => a.length > b.length ? a : b).length;
Sean Kelly
@spkellydev
Jan 30 2017 00:25
Wait, is this separte from nodejs? I don't know anything about nodejs
Pieter Stokkink
@forkerino
Jan 30 2017 00:25
@spkellydev nonono, you misunderstood.
Sean Kelly
@spkellydev
Jan 30 2017 00:25
Oh okay
Pieter Stokkink
@forkerino
Jan 30 2017 00:25
a collection of html elements is called a nodelist.
Sean Kelly
@spkellydev
Jan 30 2017 00:26
Right, I'm with you now
var listItems = document.getElementById("#intPortList").childNodes('li');
would that work?
Pieter Stokkink
@forkerino
Jan 30 2017 00:27
.childNodes doesn't take an argument, it just creates a list of all elements inside the parent node.
Mehmet Aktaş
@aktas023
Jan 30 2017 00:27
TÜRK VARMI
Pieter Stokkink
@forkerino
Jan 30 2017 00:27
@spkellydev actually, you can just use .children as well.
Sean Kelly
@spkellydev
Jan 30 2017 00:27
Huh. Would it be wise to declare my variable locally and then use nth-child
Pieter Stokkink
@forkerino
Jan 30 2017 00:29
Not sure what you are trying to do there.
Sean Kelly
@spkellydev
Jan 30 2017 00:29
What I want to do have it so when a list item is clicked, an alert appears - for now at least.
xemexpress
@xemexpress
Jan 30 2017 00:30
@forkerino so concise! thanks!
CamperBot
@camperbot
Jan 30 2017 00:30
xemexpress sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:cookie: 757 | @forkerino |http://www.freecodecamp.com/forkerino
Sean Kelly
@spkellydev
Jan 30 2017 00:30
I'm really not sure how to use the .children
Pieter Stokkink
@forkerino
Jan 30 2017 00:30

@spkellydev

var listItems = document.getElementById("#intPortList").children;

for (var i = 0; i<listItems.lenght; i++) {
  listItems[i].addEventListener('click',activateList);
}
function activateList() {
  alert("Click detected!");
}

I think that would work.

Sean Kelly
@spkellydev
Jan 30 2017 00:31
@forkerino the getElementsByTagName is supposed to return an array. I wonder if .children does too. I'm going to check it out. Thanks for taking a look
CamperBot
@camperbot
Jan 30 2017 00:31
spkellydev sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:cookie: 758 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jan 30 2017 00:31
@spkellydev :+1:
@xemexpress you could also do return Math.max(...str.split(" ").map(a => a.length));
not sure which performs better.
Kait
@k-vosswinkel
Jan 30 2017 00:38
Hey all - I'm working on my random quote generator, and I have the Twitter share pop-up working, but I can't figure out how to tweet the quote dynamically. Here's my Codepen. I'm honestly just stumped. http://codepen.io/kvosswinkel/full/wojdpV/
ShadowKnight
@ShadowKnight00
Jan 30 2017 00:38
Hello. I'm having problems with a freeCodeCamp problem called "Arguments Optional" where I'm supposed to write a function that should take two argumnets, but reacts differently if you only supply one argument. I understand that, but one of the tests it wants to run is" addTogether(2)(3);" with an expected result of a number, but the console says "TypeError: addTogether(...) is not a function." The function is working mostly except for that test, but I'm not sure how to even search for a solution here. Anyone have any pointers?
Pieter Stokkink
@forkerino
Jan 30 2017 00:40
@ShadowKnight00 if you only have one argument passed into the addTogether function, you should return a function which has closure over that original single argument.
Sean Kelly
@spkellydev
Jan 30 2017 00:40
@k-vosswinkel you need to pull to twitter more specifically after your quote is generated - this is from mine
    $("#tweet").on("click", function(){
      console.log(randoQuote);
window.open("https://twitter.com/intent/tweet?text=" + randoQuote + "-"+author);
  });
ShadowKnight
@ShadowKnight00
Jan 30 2017 00:41
I'm reading up on closures and I THOUGHT I implemented one properly, but the double parenthesis has me stumped... Should hte closure work with double parenthesis like that?
(I can't find any examples online of a function call with double parenthesis like that)
Sean Kelly
@spkellydev
Jan 30 2017 00:41
@k-vosswinkel your twitter button isn't a button so it's acting weird as an anchor tag
put the link from the Twitter dev panel into your JS and it should work
Check out the documentation https://dev.twitter.com/overview/api/tweets
Pieter Stokkink
@forkerino
Jan 30 2017 00:42
@k-vosswinkel you can also just change the href attribute inside your getJSON callback.
@ShadowKnight00 the double parens work because and only because addTogether returns a function if only one argument is passed in. The addTogether(2) part in the double parens call will in that case be replaced by the function returned from the addTogether function.
so it will end up being like a normal function call.
ShadowKnight
@ShadowKnight00
Jan 30 2017 00:47
@forkerino That makes sense. Thank you!! I just need to figure out why my closure isn't working properly, then. I'll get it.
CamperBot
@camperbot
Jan 30 2017 00:47
shadowknight00 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:cookie: 759 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Jan 30 2017 00:48
@ShadowKnight00 :+1:
Sean Kelly
@spkellydev
Jan 30 2017 00:48
@forkerino I'm still getting the null reference but now I've found out why. It's running my script before the DOM is generated which is why my getElementsByTagName and .children wouldn't work - any tips how to work around this in codepen? Obviously I could fix it in my index.html by putting the script after the body, but I wanna figure this out too
Pieter Stokkink
@forkerino
Jan 30 2017 00:51
@spkellydev ah, ok. You probably need to wrap it inside something that fires when the DOM is loaded. In jQuery it is $(document).ready(), but in regular ol' js you can use
document.addEventListener("DOMContentLoaded", function(event) { 
  //do everything
});
Sean Kelly
@spkellydev
Jan 30 2017 00:51
@k-vosswinkel if you're interested http://codepen.io/spkellydev/pen/xgLErZ
Kait
@k-vosswinkel
Jan 30 2017 00:51
Woah - ok thank you so much @spkellydev! Couldn't see the forest through the trees.
CamperBot
@camperbot
Jan 30 2017 00:51
k-vosswinkel sends brownie points to @spkellydev :sparkles: :thumbsup: :sparkles:
:cookie: 267 | @spkellydev |http://www.freecodecamp.com/spkellydev
Sean Kelly
@spkellydev
Jan 30 2017 00:51
@forkerino THATS IT! thanks again - I'm trying to use pure JS here
CamperBot
@camperbot
Jan 30 2017 00:51
spkellydev sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:warning: spkellydev already gave forkerino points
Sean Kelly
@spkellydev
Jan 30 2017 00:52
no problem
Pieter Stokkink
@forkerino
Jan 30 2017 00:53
@spkellydev :+1:
Louis Girifalco
@flyblackbox
Jan 30 2017 00:54
@xemexpress @forkerino Thanks guys
CamperBot
@camperbot
Jan 30 2017 00:54
flyblackbox sends brownie points to @xemexpress and @forkerino :sparkles: :thumbsup: :sparkles:
:cookie: 255 | @xemexpress |http://www.freecodecamp.com/xemexpress
:cookie: 760 | @forkerino |http://www.freecodecamp.com/forkerino
Louis Girifalco
@flyblackbox
Jan 30 2017 00:54
@forkerino Would you mind talking me through that reduce function? I’ve watched two videos on YouTube but I can’t wrap my head around it..
Pieter Stokkink
@forkerino
Jan 30 2017 00:55
@edgaryp sorry wanted to reply earlier, but some other people also needed help. The main problem is that Object.keys returns an array, which will be problematic when you try to put it in .hasOwnProperty and an array-index in your if statement.
Pieter Stokkink
@forkerino
Jan 30 2017 00:57
@flyblackbox Have you watched this one?
https://www.youtube.com/watch?v=Wl98eZpkp-c
This guy is the best.
I'm about to turn in, need to get some shuteye. If you still don't get it, pm me and I'll get back to you tomorrow.
Louis Girifalco
@flyblackbox
Jan 30 2017 00:57
OK Thank you
Matt Richards
@mattjrichards
Jan 30 2017 00:59
In the Golf Code Lesson I used the Equality Operator. When I viewed somone else's solution they used the Strict Equality Operator. Why does it work both ways, and whats the difference?
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 if (strokes >= par + 3) { 
   return "Go Home!";
 }


  // Only change code above this line
}

// Change these values to test
golfScore(1, 1);
Johnny
@JohnnyBizzel
Jan 30 2017 01:02
@mattjrichards } else if (strokes <= par -2) { :x:
Sean Kelly
@spkellydev
Jan 30 2017 01:02
@mattjrichards you could probably use a switch statement to make it a bit easier to read
Aj Broman
@Bromana
Jan 30 2017 01:03

Quick little Q:

When dealing with objects if an object property is encased in " " example: "hat" : "ballcap"

Johnny
@JohnnyBizzel
Jan 30 2017 01:03
@mattjrichards } else if (strokes <= par) { :+1:
Aj Broman
@Bromana
Jan 30 2017 01:03
you can call "hat" without the quotes?
.hat in my case
Johnny
@JohnnyBizzel
Jan 30 2017 01:04
@Bromana Try it. See what happens
Sean Kelly
@spkellydev
Jan 30 2017 01:04
at @Bromana someone could probably give you a better answer, but I don't think you actually need to have the "s when you're making the object
for hat at least
because its not a string
Matt Richards
@mattjrichards
Jan 30 2017 01:04
@JohnnyBizzel Not following. What did I do wrong?
Aj Broman
@Bromana
Jan 30 2017 01:04

well in the codecamp example :

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

the object is "hat" but I can't call "hat" I have to remove the ''
Johnny
@JohnnyBizzel
Jan 30 2017 01:05
@spkellydev Depends if it's JSON http://www.w3schools.com/js/js_json_syntax.asp
objectTest.png
@bromana the result
Aj Broman
@Bromana
Jan 30 2017 01:07
got it! ty :P So ya cant use it as a string
o/
Johnny
@JohnnyBizzel
Jan 30 2017 01:07
Also valid:
var testObj = {
hat: "ballcap",
shirt: "jersey",
shoes: "cleats"
};
// Only change code below this line
var hatValue = testObj.hat; 
var shirtValue = testObj.shirt;
Sean Kelly
@spkellydev
Jan 30 2017 01:08
Ah, okay.
Aj Broman
@Bromana
Jan 30 2017 01:08
ty all for the help <3
Sean Kelly
@spkellydev
Jan 30 2017 01:08
So JS is smart enough to work around the JSON requirements, very cool
Johnny
@JohnnyBizzel
Jan 30 2017 01:08
@Bromana Mention when thanking please
Matt Richards
@mattjrichards
Jan 30 2017 01:08
@JohnnyBizzel Why } else if (strokes <= par) {
Aj Broman
@Bromana
Jan 30 2017 01:09
lol Ty @JohnnyBizzel , @spkellydev for the help
CamperBot
@camperbot
Jan 30 2017 01:09
bromana sends brownie points to @johnnybizzel and @spkellydev :sparkles: :thumbsup: :sparkles:
:star2: 1206 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
:cookie: 268 | @spkellydev |http://www.freecodecamp.com/spkellydev
Johnny
@JohnnyBizzel
Jan 30 2017 01:09
@mattjrichards par will always be the same
Aj Broman
@Bromana
Jan 30 2017 01:09
Didn't know it gave points! :)
Johnny
@JohnnyBizzel
Jan 30 2017 01:09
@Bromana Cheers :beers:
@Bromana I think it's an incentive for people to help others :star:
Sean Kelly
@spkellydev
Jan 30 2017 01:10
@mattjrichards } else if (stroke <= par) { because you can structure it better by putting all the requirement for less than par in the same tree... at least that seems to be the case that @JohnnyBizzel is making
Johnny
@JohnnyBizzel
Jan 30 2017 01:10

@mattjrichards

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

Knowing how Golf is scored helps. :golf:

Matt Richards
@mattjrichards
Jan 30 2017 01:13
@JohnnyBizzel @spkellydev Yeah, I guess that would help. I know nothing about golf. I'm trying to fit in my brain what you're putting down.
Johnny
@JohnnyBizzel
Jan 30 2017 01:15
@mattjrichards Each golf hole is ranked a value (par) which is basically the average strokes to complete.
If you shoot less than par number of shots, this is "below par"... better. The fewer the shots to complete the course is the winner.
Sean Kelly
@spkellydev
Jan 30 2017 01:15
@mattjrichards you really don't need to! I find it helps to write out my logic before I start coding that way I can figure out the steps
Johnny
@JohnnyBizzel
Jan 30 2017 01:16
@mattjrichards This code is for a single hole. A golf round consists of 18 holes.
Sean Kelly
@spkellydev
Jan 30 2017 01:16
Matt Richards
@mattjrichards
Jan 30 2017 01:16
I get it, but I don't, if that makes sense. I'm trying to make sense of the formula.
Johnny
@JohnnyBizzel
Jan 30 2017 01:17
@mattjrichards I take 2 shots to complete a par 4 hole. What is my score?
Matt Richards
@mattjrichards
Jan 30 2017 01:17
@spkellydev ahh, yes. It's the algebra I'm having trouble with.
The way I think about Math is funny.
Johnny
@JohnnyBizzel
Jan 30 2017 01:18
@mattjrichards (strokes - par <= -2) { // 2 -4 = -2
Sean Kelly
@spkellydev
Jan 30 2017 01:18
Yea but you don't actually have to do the math, the program does that. its point and shoot, just figure out how to read the instructions so that you know where to point
Matt Richards
@mattjrichards
Jan 30 2017 01:20
I know. I don't know how to explain the point I'm trying to make. I'm trying to fit the way the code is structured in my head so that I can make sense of it.
Sean Kelly
@spkellydev
Jan 30 2017 01:20
which is why you should write it out before you begin to code. Thats my whole point lol
Matt Richards
@mattjrichards
Jan 30 2017 01:21
@JohnnyBizzel 2?
Johnny
@JohnnyBizzel
Jan 30 2017 01:22
@mattjrichards Your code works. What's the problem?
Matt Richards
@mattjrichards
Jan 30 2017 01:23
I have trouble getting past something if I can't understand how it works.
Johnny
@JohnnyBizzel
Jan 30 2017 01:24
@mattjrichards Stick it here: http://pythontutor.com/javascript.html
You can step through it.
Matt Richards
@mattjrichards
Jan 30 2017 01:27
So, your score is dependent upon the par not just by how many strokes you take to get it?
Sean Kelly
@spkellydev
Jan 30 2017 01:27
no, the label thats put on the score - the score is the same
Johnny
@JohnnyBizzel
Jan 30 2017 01:28
@mattjrichards Correct. Look at the test cases.
Matt Richards
@mattjrichards
Jan 30 2017 01:29
I see them, I'm just trying to make sense of them.
Johnny
@JohnnyBizzel
Jan 30 2017 01:29
@mattjrichards Hole in one - best possible. Eagle and Birdie are good. Bogeys are bad.
Stephen Kilgore
@devninja89
Jan 30 2017 01:29
I'm going back and refactoring some of my old algorithm challenges. This is the most efficient way I could think of to do the problem. Create an array using the from method and populate it with n numbers based on the passed in argument, then reduce the array. Is there a way to do this even more efficiently that I am missing?
function factorialize(num) {
  var nums = Array.from(new Array(num), function(item, index) 
                        { 
    return index + 1;
  });
    return nums.reduce(function (a,b) {
      return a*b;
  }, 1);
}

factorialize(5);
Matt Richards
@mattjrichards
Jan 30 2017 01:30
I understand that. It's the math I'm trying to make sense of.
Johnny
@JohnnyBizzel
Jan 30 2017 01:31
@devninja89 I didn't bother with arrays:
function factorialize(num) {
  var factorial = 1;

  for (i = 1; i <= num ; i++) {
    factorial *= i;
  }

  return factorial;
}

factorialize(5);
Jean Marco Romero
@volkranium
Jan 30 2017 01:31
what makes JS different from backend languages is basically DOM manipulation right?
Johnny
@JohnnyBizzel
Jan 30 2017 01:32
@mattjrichards 2 minus 4 = minus 2.
Sean Kelly
@spkellydev
Jan 30 2017 01:32
@devninja89 you can also decrement the iterations
function factorialize(num) {
  var result = 1;
  while (num >= 1) {
    result = result * num;
    num--;

  }
  num = result;
  return num;
}

factorialize(20);
Louis Girifalco
@flyblackbox
Jan 30 2017 01:33
I’m geting an error: Illegal return statement. Is it because I am not allowed to run another line of code after a return?
var currentGen = 1;
var totalGen = 19;
var totalMW = 0;


while (currentGen <= 1){
    totalMW += 62;
    return "Generator #" + currentGen + " is on, adding 62 MW, for a total of " + totalMW + " MW!";
    currentGen++;

}
while (currentGen > 4 && <= 19){
    totalMW += 124;
    return "Generator #" + currentGen + " is on, adding 124 MW, for a total of " + totalMW + " MW!";
    currentGen++;
}
Sean Kelly
@spkellydev
Jan 30 2017 01:33
yea @flyblackbox return exits the loop
wait
no
Ugur Ozcelik
@ugurozcelik
Jan 30 2017 01:34
str.toLowerCase().split( ) === str.reverse().toLowerCase().split( );
what is wrong with this code ? can anyone help?
Louis Girifalco
@flyblackbox
Jan 30 2017 01:34
@spkellydev ??
Sean Kelly
@spkellydev
Jan 30 2017 01:34
@flyblackbox I don't understand your conditional
you're going to get an infinite loop, no?
Louis Girifalco
@flyblackbox
Jan 30 2017 01:35
Oops. that 1 should be a 4
Johnny
@JohnnyBizzel
Jan 30 2017 01:35
@devninja89 This is the most efficient I have seen:
function factorialize(num) {
  if (num === 0) { return 1; }
  return num * factorialize(num-1);
}

factorialize(5);
Stephen Kilgore
@devninja89
Jan 30 2017 01:35
damn
i kept trying to think of recursive ways to do it
and there it is.
Johnny
@JohnnyBizzel
Jan 30 2017 01:35
@flyblackbox That's the whole point of return
Louis Girifalco
@flyblackbox
Jan 30 2017 01:36
I want to print that variable’s value, but I want to increment it by one after printing it
Matt Richards
@mattjrichards
Jan 30 2017 01:36
par - stroke = - score ???
Sean Kelly
@spkellydev
Jan 30 2017 01:36
yea, you have to do that with while loops, you could've use a for loop to eliminate that step
@mattjrichards look up a video on the game of gold already. There are set defined rules like any game. Eagle has its own specifications, bogey, and so on. It's just how the game operates
golf*
Matt Richards
@mattjrichards
Jan 30 2017 01:38
I was trying to make sense of your 2 minus 4 = minus 2
Sean Kelly
@spkellydev
Jan 30 2017 01:38
yea, but its only in the scope of a conditional statement
you're stroke count isn't going on the score card as a negative
you*
your*
you're testing for a negative value that way you can determine which type of hole they scored with their stroke count
Johnny
@JohnnyBizzel
Jan 30 2017 01:41
@mattjrichards Look at the final round and the winner is on a score of minus 14:
https://en.wikipedia.org/wiki/2016_PGA_Championship
And won $1.8 million
Sean Kelly
@spkellydev
Jan 30 2017 01:41
its a score of -14 relative to par
Johnny
@JohnnyBizzel
Jan 30 2017 01:43
@flyblackbox Your requirements are vague. What do you want to do?
Louis Girifalco
@flyblackbox
Jan 30 2017 01:43

The Hoover Dam has 19 generators of multiple types. For simplicity, let’s say that the first 4 of these generators output 62 megawatts, and the other 15 output 124 megawatts. In hooverDam.js, the Dam Rangers have asked you to design a system of two loops that turns each generator on in progression, and prints the new total of megawatts generated.

They’d like the first loop to be a while loop handling the first 4 generators. Then, they’d like the second loop to be a for loop that handles the other 15 generators. Each output line should resemble the following lines, with adjusted values for the currentGen and totalMW:

Generator #1 is on, adding 62 MW, for a total of 62 MW!
Generator #2 is on, adding 62 MW, for a total of 124 MW!

Sean Kelly
@spkellydev
Jan 30 2017 01:43
his score is 266 but par was 280 which makes the -14 score
Louis Girifalco
@flyblackbox
Jan 30 2017 01:43
var currentGen = 1;
var totalGen = 19;
var totalMW = 0;


while (currentGen <= 4){
    totalMW += 62;
    console.log("Generator #" + currentGen + " is on, adding 62 MW, for a total of " + totalMW + " MW!");
    currentGen++;

}
while (currentGen > 4 && <= 19){
    totalMW += 124;
    console.log("Generator #" + currentGen + " is on, adding 124 MW, for a total of " + totalMW + " MW!");
    currentGen++;
}
I feell ike this should work
but I’m getting an error:
Line 10: Unexpected token <=
Make sure you use a while loop
Johnny
@JohnnyBizzel
Jan 30 2017 01:44
@flyblackbox It says the 2nd loop should be a for loop.
Anas Butt
@anas2ab
Jan 30 2017 01:45
can someone help me with escape sequences in javascript
var myStr = 'FirstLine \n \SecondLine\ \rThirdLine';
Louis Girifalco
@flyblackbox
Jan 30 2017 01:45
lol
Anas Butt
@anas2ab
Jan 30 2017 01:45
idk why thats not working
Louis Girifalco
@flyblackbox
Jan 30 2017 01:45
oh..
Johnny
@JohnnyBizzel
Jan 30 2017 01:45
@anas2ab var myStr = 'FirstLine \\n \\SecondLine\\ \\rThirdLine'; no need for spaces
Anas Butt
@anas2ab
Jan 30 2017 01:45
okay thats exactyl what i have
its still not working
Johnny
@JohnnyBizzel
Jan 30 2017 01:47
@flyblackbox First loop works
Louis Girifalco
@flyblackbox
Jan 30 2017 01:47
Yes it does
I didn’t read the requirements...
I’m a dumb dumb
Johnny
@JohnnyBizzel
Jan 30 2017 01:47
@anas2ab I formatted your code. Copy and paste here it doesn't always show code unless you format it
'''
CamperBot
@camperbot
Jan 30 2017 01:47
:bulb: to format code use backticks! ``` more info
Sean Kelly
@spkellydev
Jan 30 2017 01:48
sometimes you have to refresh your browser if you've been working on the solution for a while too. It kinda times out sometimes. Took me a while to figure that out!
Hello911
@Hello911
Jan 30 2017 01:49
For Confirm Ending Challenge, what is exactly should the function return? a string? true or false?
Natalia Ramos
@NataliaRamos
Jan 30 2017 01:49
My Logical order in If Else Statements does not pass the less than 5.
function orderMyLogic(val) { if (val < 10) { return "Less than 10"; } else if (val < 5) { return "Less than 5"; } else { return "Greater than or equal to 10"; } }
Johnny
@JohnnyBizzel
Jan 30 2017 01:50
@flyblackbox 2nd loop:
for (var i=5; i<19;i++) {
   totalMW += 62;
    console.log("Generator #" + i + " is on, adding 62 MW, for a total of " + totalMW + " MW!");
  }
Sean Kelly
@spkellydev
Jan 30 2017 01:50
@CyuSunill you need to use camelCasing and rewrite the variables
They're kinda funky like that and you need to use the correct casing because the language is case sensitive
CyuSunill
@CyuSunill
Jan 30 2017 01:50
i am totally new .. dont know spkelllydev
Louis Girifalco
@flyblackbox
Jan 30 2017 01:50
@JohnnyBizzel I was going to try it this way but I’m getting an error...
for (; currentGen > 4 && < 19; currentGen++) {
    totalMW += 124;
    console.log("Generator #" + currentGen + " is on, adding 124 MW, for a total of " + totalMW + " MW!");
    currentGen++;
}
Johnny
@JohnnyBizzel
Jan 30 2017 01:51
@flyblackbox My way works :D
Matt Richards
@mattjrichards
Jan 30 2017 01:51
@spkellydev ok, I got it. I think. If you got a hole in one on every par (which I know is next to impossible) you'd have a positive score. The par is a number that is average attempts before you're expected to score?
Paulo Tokimatu
@paulotokimatu
Jan 30 2017 01:51
@flyblackbox try currentGen > 4 && currentGen < 19
Sean Kelly
@spkellydev
Jan 30 2017 01:51
@CyuSunill look at the examples they provide. You need to change the casing of the letters to reflex the requiremnets of the syntaax
haha @mattjrichards
Johnny
@JohnnyBizzel
Jan 30 2017 01:52
@flyblackbox Why totalMW += 124;?
Matt Richards
@mattjrichards
Jan 30 2017 01:52
@spkellydev can you smell the smoke over here?
Louis Girifalco
@flyblackbox
Jan 30 2017 01:53
Because the second set of generators add 124MW, the first set add 64
Sean Kelly
@spkellydev
Jan 30 2017 01:53
@flyblackbox get rid of the last line of the loop
you iterated when you called the for loop
Anas Butt
@anas2ab
Jan 30 2017 01:53
var myStr = "FirstLine\\n \\SecondLine\\ \\rThirdLine"; so someone please tell me why this isn't working
Sean Kelly
@spkellydev
Jan 30 2017 01:53
now youre iterating twice
Louis Girifalco
@flyblackbox
Jan 30 2017 01:54
Ah true
Joseph
@revisualize
Jan 30 2017 01:54
@anas2ab You're not escaping the newline correctly.
Anas Butt
@anas2ab
Jan 30 2017 01:54
oh
how do I do it
Louis Girifalco
@flyblackbox
Jan 30 2017 01:54
That line was left over from when I was using a while loop
Joseph
@revisualize
Jan 30 2017 01:54
@anas2ab You're escaping a backslash before the n
Sean Kelly
@spkellydev
Jan 30 2017 01:54
Joseph
@revisualize
Jan 30 2017 01:54
@anas2ab You also need to remove ALL spaces.
Louis Girifalco
@flyblackbox
Jan 30 2017 01:55
I’m still getting this error.. Line 12: Unexpected token <
Make sure you use a while loop.
Anas Butt
@anas2ab
Jan 30 2017 01:55
oh wow
thanks
that was annoying
Johnny
@JohnnyBizzel
Jan 30 2017 01:55
@revisualize I said that.
It's like an echo...
Joseph
@revisualize
Jan 30 2017 01:55
@JohnnyBizzel I know.
Natalia Ramos
@NataliaRamos
Jan 30 2017 01:56
function orderMyLogic(val) {
  if (val < 10) {
    return "Less than 10";
  } else if (val < 5) {
    return "Less than 5";
  } else {
    return "Greater than or equal to 10";
  }
}
Johnny
@JohnnyBizzel
Jan 30 2017 01:56
@spkellydev Thanks for that :joy:
CamperBot
@camperbot
Jan 30 2017 01:56
johnnybizzel sends brownie points to @spkellydev :sparkles: :thumbsup: :sparkles:
:cookie: 269 | @spkellydev |http://www.freecodecamp.com/spkellydev
Joseph
@revisualize
Jan 30 2017 01:56
@JohnnyBizzel Someday. I hop people will learn to read.
@NataliaRamos More restrictive first.
Louis Girifalco
@flyblackbox
Jan 30 2017 01:56
I passed
Johnny
@JohnnyBizzel
Jan 30 2017 01:56
@revisualize Remember English is not everyone's 1st language
Louis Girifalco
@flyblackbox
Jan 30 2017 01:56
not sure what I changed to fix it.. but thanks everyone for the help
Johnny
@JohnnyBizzel
Jan 30 2017 01:57
@flyblackbox Well done ;)
Joseph
@revisualize
Jan 30 2017 01:57
@NataliaRamos 4 is less than 10 so.. You need to put the more restrictive condition first.
@JohnnyBizzel I know.
Louis Girifalco
@flyblackbox
Jan 30 2017 01:57
@JohnnyBizzel thank you ;D
CamperBot
@camperbot
Jan 30 2017 01:57
flyblackbox sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1207 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Anas Butt
@anas2ab
Jan 30 2017 01:57
you guys are hella passive aggressive
Johnny
@JohnnyBizzel
Jan 30 2017 01:57
@flyblackbox My pleasure
Natalia Ramos
@NataliaRamos
Jan 30 2017 01:58
@revisualize Thanks
CamperBot
@camperbot
Jan 30 2017 01:58
nataliaramos sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3142 | @revisualize |http://www.freecodecamp.com/revisualize
Sean Kelly
@spkellydev
Jan 30 2017 01:58
@anas2ab thanks!
CamperBot
@camperbot
Jan 30 2017 01:58
spkellydev sends brownie points to @anas2ab :sparkles: :thumbsup: :sparkles:
:cookie: 146 | @anas2ab |http://www.freecodecamp.com/anas2ab
Matt Richards
@mattjrichards
Jan 30 2017 02:00
@spkellydev lol...I feel his frustrastion.
Sean Kelly
@spkellydev
Jan 30 2017 02:00
its so weird to hear Robin Williams be that vulgar to me!
Matt Richards
@mattjrichards
Jan 30 2017 02:01
I know, right? Shame on you Peter Pan.
Sean Kelly
@spkellydev
Jan 30 2017 02:01
I should be writing my weather app but I'm here watching golf videos instead haha
armynational
@armynational
Jan 30 2017 02:02
ok im having trouble incrementing a number with js?
any help?
Sean Kelly
@spkellydev
Jan 30 2017 02:02
@armynational thank you for your service. what's the example
CamperBot
@camperbot
Jan 30 2017 02:02
spkellydev sends brownie points to @armynational :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for armynational
armynational
@armynational
Jan 30 2017 02:03

var myVar = 87;

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

Thank you @spkellydev
CamperBot
@camperbot
Jan 30 2017 02:03
armynational sends brownie points to @spkellydev :sparkles: :thumbsup: :sparkles:
:cookie: 270 | @spkellydev |http://www.freecodecamp.com/spkellydev
Matt Richards
@mattjrichards
Jan 30 2017 02:03
I know. I give up. I'm moving on to the next lesson.
Sean Kelly
@spkellydev
Jan 30 2017 02:04
Okay so that is going to make myVar = 88
Matt Richards
@mattjrichards
Jan 30 2017 02:04
@spkellydev @JohnnyBizzel thank you
CamperBot
@camperbot
Jan 30 2017 02:04
mattjrichards sends brownie points to @spkellydev and @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 271 | @spkellydev |http://www.freecodecamp.com/spkellydev
:star2: 1208 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Sean Kelly
@spkellydev
Jan 30 2017 02:04
what're you trying to do there @armynational
no doubt @mattjrichards maybe its for the best!
Mahmoud Ahmed
@Lartwel
Jan 30 2017 02:04
Hi! I've a question here about indexOf in javascript
Margaret
@Margaret2
Jan 30 2017 02:04
@armynational you're not supposed to use = with ++
armynational
@armynational
Jan 30 2017 02:04
right but its not saying that it does and it myVar should not be changed
Sean Kelly
@spkellydev
Jan 30 2017 02:04
oh true, good call @Margaret2
Mahmoud Ahmed
@Lartwel
Jan 30 2017 02:05

var array = [2, 9, 9];

array.indexOf(2, -1); // -1
array.indexOf(2, -3); // 0

armynational
@armynational
Jan 30 2017 02:05
myVar should equal 88
myVar = myVar should be changed
Mahmoud Ahmed
@Lartwel
Jan 30 2017 02:05
why are the outputs different here?
Sean Kelly
@spkellydev
Jan 30 2017 02:05
myVar +=1;
or myVar++;
Margaret
@Margaret2
Jan 30 2017 02:05
@armynational right, so if you have a variable i, then to increment it you just use i++;
Matt Richards
@mattjrichards
Jan 30 2017 02:05
It'll come together for me. Was never good at Math and Algebra. I'm just gonna keep truckin' on.
Mahmoud Ahmed
@Lartwel
Jan 30 2017 02:06
Any one can help?
Sean Kelly
@spkellydev
Jan 30 2017 02:06
Thats the best way to learn. All this webdev stuff is new to me. I got pretty good with Java and now Javascript makes me feel like I'm being laughed at!
Vizij
@Vizij
Jan 30 2017 02:07
@Lartwel You're starting at two different points in the array. The first example is -1, which is starting from the back of the array, so the last 9. It doesn't find 2, so you get a result of -1. Second is starting from -3, 3 indexes from back of array -- which is actually array 0. That's the result you get
armynational
@armynational
Jan 30 2017 02:07

this is my code:
var myVar = 87;

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

and it is not working @spkellydev

Sean Kelly
@spkellydev
Jan 30 2017 02:07
well, now it's going to have an error cause you still have the myVar =
and you'll get 89
myVar++;
or
myVar+=1;
Vizij
@Vizij
Jan 30 2017 02:08
@Lartwel Essentially the second number in your .indexOf call is the index from where you start searching, and it goes left to right. But if that number is negative, it's counting from the back of the array.
(but still going left to right)
armynational
@armynational
Jan 30 2017 02:08

var myVar = 87;

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

this is the new code and its still not working @spkellydev

Sean Kelly
@spkellydev
Jan 30 2017 02:09
you don't need myVar =
Matt Richards
@mattjrichards
Jan 30 2017 02:09
@spkellydev I hear ya. I guess the main thing is not to give up, which at times I want to, but where would that get me?
Sean Kelly
@spkellydev
Jan 30 2017 02:09
because ++ is an incrementer
so its naturally going to make the variable, myVar, increment
armynational
@armynational
Jan 30 2017 02:10

this?

var myVar = 87;

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

because this isnt working either @spkellydev

Mahmoud Ahmed
@Lartwel
Jan 30 2017 02:10
@Vizij in the 2 examples it starts searching from a negative index
Sean Kelly
@spkellydev
Jan 30 2017 02:10
lemme see the link to the example @armynational
you dont need the myVar = myVar; its understood
armynational
@armynational
Jan 30 2017 02:11
i got it now thanks @spkellydev
CamperBot
@camperbot
Jan 30 2017 02:11
armynational sends brownie points to @spkellydev :sparkles: :thumbsup: :sparkles:
:warning: armynational already gave spkellydev points
Sean Kelly
@spkellydev
Jan 30 2017 02:11
No doubt!
Mahmoud Ahmed
@Lartwel
Jan 30 2017 02:11
@Vizij and they should go from right to left. so in the 2 examples: the "2" element should not be found right??
Sean Kelly
@spkellydev
Jan 30 2017 02:14
@mattjrichards I like to take breaks when I get frustrated. Sometimes I'll watch SimpleProgrammer on YouTube that way I still feel like I'm being productive but I'm not looking at code that makes me angry!
Ugur Ozcelik
@ugurozcelik
Jan 30 2017 02:15

function findLongestWord(str) {
var word = str.split(' ');

var longestword = 0;

for(var i = 0; i < word.length; i++){
if (word(i).length > longestword){
longestword = word(i).length;
}
}
return longestword;
}

findLongestWord("The quick brown fox jumped over the lazy dog");

says word is not a function ? what should i do?

Sean Kelly
@spkellydev
Jan 30 2017 02:16
capitalize the W in the return @ugurozcelik
eeflores
@eeflores
Jan 30 2017 02:16
word[i]
Matt Richards
@mattjrichards
Jan 30 2017 02:16
@spkellydev lol...yes, I've learned to do that. I wouldn't take breaks before and I would just burn myself out. Now I take breaks.
Sean Kelly
@spkellydev
Jan 30 2017 02:16
and the var actually
everywhere danh
dang*
Moisés Man
@moigithub
Jan 30 2017 02:17
@ugurozcelik words is an array.. u should use brackets not parenthesis
Margaret
@Margaret2
Jan 30 2017 02:17
@ugurozcelik () are used for functions, [] are used for accessing items in an array
Sean Kelly
@spkellydev
Jan 30 2017 02:17
Look into pomodoro timers, you'll be making one soon enough anyway @mattjrichards you can be productive for 25 min, take a 5 min break
its motivating
armynational
@armynational
Jan 30 2017 02:17
finding a remainder in javascript? what is this suppose to look like
eeflores
@eeflores
Jan 30 2017 02:18
var x = 25 % 16;
Matt Richards
@mattjrichards
Jan 30 2017 02:18
@spkellydev I'll do that.
Margaret
@Margaret2
Jan 30 2017 02:18
@armynational % is an operator just like any other, so you can do 10 + 5, 10 * 5, 10 % 5 etc.
Sean Kelly
@spkellydev
Jan 30 2017 02:19
25 % 5 = 0 10%3 = 1
Ugur Ozcelik
@ugurozcelik
Jan 30 2017 02:19
@Margaret2 @moigithub @eeflores thanks
CamperBot
@camperbot
Jan 30 2017 02:19
ugurozcelik sends brownie points to @margaret2 and @moigithub and @eeflores :sparkles: :thumbsup: :sparkles:
:star2: 1409 | @margaret2 |http://www.freecodecamp.com/margaret2
:star2: 2635 | @moigithub |http://www.freecodecamp.com/moigithub
:cookie: 924 | @eeflores |http://www.freecodecamp.com/eeflores
armynational
@armynational
Jan 30 2017 02:20

// Only change code below this line

var remainder;
11%3=2;

eeflores
@eeflores
Jan 30 2017 02:20
assign 11 % 3 to remainder
Sean Kelly
@spkellydev
Jan 30 2017 02:21
remainder would be the 2, so take out the =2 and make remainder = 11%3
David Amanze
@GodKingShogun
Jan 30 2017 02:21
hello everyone :smile:
Sean Kelly
@spkellydev
Jan 30 2017 02:21
sup @GodKingShogun whats new
David Amanze
@GodKingShogun
Jan 30 2017 02:22
can someone take a look at my weather app code on codepen. it should at least give me back the temp in Celsius but no luck
Christopher McCormack
@cmccormack
Jan 30 2017 02:23
@GodKingShogun GET https://ip-api.com/json net::ERR_CONNECTION_REFUSED
should be http
David Amanze
@GodKingShogun
Jan 30 2017 02:24
@cmccormack lol someone said i had to add the s yesterday
Christopher McCormack
@cmccormack
Jan 30 2017 02:25
nah. You can test it in the browser, https doesn't work
That project is kind of tough because you have to find both APIs for location and for weather that are both either http or https, but not both.
David Amanze
@GodKingShogun
Jan 30 2017 02:26
ok i made two adjustment. the http and i quickly realized that i had access to the wrong part of the object for lon and lat
Sean Kelly
@spkellydev
Jan 30 2017 02:28
@GodKingShogun does it work
David Amanze
@GodKingShogun
Jan 30 2017 02:28
@spkellydev no
Sean Kelly
@spkellydev
Jan 30 2017 02:28
should you be using .appendTo and insteads use .html
Christopher McCormack
@cmccormack
Jan 30 2017 02:29
    var lat=data.lat;
    var lon=data.lon;
Sean Kelly
@spkellydev
Jan 30 2017 02:29
I'm working on mine too, so don't take this as a real suggestion cause I'm very new to it
armynational
@armynational
Jan 30 2017 02:30
how do i convert Celsius into fahrenheit?
Jarek
@DesolateMonkey
Jan 30 2017 02:30
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName == firstName) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
}
return "No such property";
}
return "No such contact";
}
// Only change code above this line
}
Christopher McCormack
@cmccormack
Jan 30 2017 02:30
coord was part of the navigation api but not part of the json response. If you do console.log(data) after you open your function you can see the whole object in the console in codepen
Jarek
@DesolateMonkey
Jan 30 2017 02:30
whats wrong? help!
Margaret
@Margaret2
Jan 30 2017 02:32
@DesolateMonkey try moving return "No such contact"; out of your for loop, so it won't return until all the contacts have been searched
taltmann42
@taltmann42
Jan 30 2017 02:32
@DesolateMonkey If you search for e.g. "Harry", the for loop will start with i=0, which is the contact with firstName Akira. So the inner if isn't being entered. Instead, you return "No such contact". So you can't know if any further contacts may have the firstName "Harry". return stops the function from further executing
Rico042002
@rico042002
Jan 30 2017 02:33
Hello guys
anybody with experience working with objects
Bryan Reese
@breese8009
Jan 30 2017 02:34
yes
David Amanze
@GodKingShogun
Jan 30 2017 02:34
@cmccormack i tried the console.log(data) but it said undefined
@rico042002 what's your question
Rico042002
@rico042002
Jan 30 2017 02:35
How do I make a function return if I have no property that matches in the object?
Christopher McCormack
@cmccormack
Jan 30 2017 02:35
@GodKingShogun Worked for me in your codepen:
  $.getJSON("http://ip-api.com/json",function(data){
    var lat=data.lat;
    var lon=data.lon;
    console.log(data);
Margaret
@Margaret2
Jan 30 2017 02:36
@rico042002 just write a return statement inside the if statement
Jarek
@DesolateMonkey
Jan 30 2017 02:36
@Margaret2 @taltmann42 Thanks a ton!
CamperBot
@camperbot
Jan 30 2017 02:36
:star2: 1410 | @margaret2 |http://www.freecodecamp.com/margaret2
desolatemonkey sends brownie points to @margaret2 and @taltmann42 :sparkles: :thumbsup: :sparkles:
:cookie: 413 | @taltmann42 |http://www.freecodecamp.com/taltmann42
Rico042002
@rico042002
Jan 30 2017 02:36
I have an object with names as object properties and visits as a property value they want me to return the function if the name is not in the object!
I tried but it didnt pass if obj === null return. I tried
David Amanze
@GodKingShogun
Jan 30 2017 02:37
@cmccormack so did you get back the temp in celsius
Margaret
@Margaret2
Jan 30 2017 02:37
@rico042002 scroll up and look at @DesolateMonkey 's code, it might help you understand what they want you to do
Christopher McCormack
@cmccormack
Jan 30 2017 02:37
@GodKingShogun I believe you would also want your api call to the weather api to be part of your previous call, as the previous call is asynchronous
Bryan Reese
@breese8009
Jan 30 2017 02:37
@rico042002 post ur code
David Amanze
@GodKingShogun
Jan 30 2017 02:38
@cmccormack how would i do that
Rico042002
@rico042002
Jan 30 2017 02:38
var customerData = {
  'Joe': {
    visits: 1
  },
  'Carol': {
    visits: 2
  },
  'Howard': {
    visits: 3,
  },
  'Carrie': {
    visits: 4
  }
};

function greetCustomer(firstName) {
  greeting = '';
  if (customerData === null) {
    console.log('Is this your first time');
  }



  return greeting;
}

greetCustomer(customerData);
Christopher McCormack
@cmccormack
Jan 30 2017 02:38
@GodKingShogun I wasn't trying to, just wanted you to be aware you can see the object by using the console log statement and use that understanding to select the right key from the json response
Tejas Tank
@majordwarf
Jan 30 2017 02:39

function run() {
    if(!run.didrun){
    run.didrun=true;
    localStorage.setItem('run.didrun');
    }
    else{
    document.getElementById("fr").style.visibility = "hidden";
    }
}
This code should hide an element from HTML if its not the first run. But it is still displaying it. Please Help!
Margaret
@Margaret2
Jan 30 2017 02:39
@rico042002 customerData is obviously not null, why don't you try using hasOwnProperty to check if the name in the object
syntax is like this: myObject.hasOwnProperty(myProperty)
David Amanze
@GodKingShogun
Jan 30 2017 02:40
@cmccormack i entered the console.log(data) in my code but my page still remains blank except for the header
Christopher McCormack
@cmccormack
Jan 30 2017 02:40

@GodKingShogun

@cmccormack how would i do that
sorry I was thinking pythonically, you do have it in the correct scope

@GodKingShogun you have to click the console button at the bottom to see the output of the console.log statement
David Amanze
@GodKingShogun
Jan 30 2017 02:41
@cmccormack i also have a css written in my code but it doesn't change when i run it
Rico042002
@rico042002
Jan 30 2017 02:41
the properties are names but they have no distinction. Its very confusing
Tejas Tank
@majordwarf
Jan 30 2017 02:41

```

function run() {
if(!run.didrun){
run.didrun=true;
localStorage.setItem('run.didrun');
}
else{
document.getElementById("fr").style.visibility = "hidden";
}
}

```
This code should hide an element from HTML if its not the first run. But it is still displaying it. Please Help!

Margaret
@Margaret2
Jan 30 2017 02:41
@cmccormack pythonically :+1: :D and what would js be... javascriptically? :joy:
Tejas Tank
@majordwarf
Jan 30 2017 02:42
function run() {
if(!run.didrun){
run.didrun=true;
localStorage.setItem('run.didrun');
}
else{
document.getElementById("fr").style.visibility = "hidden";
}
}
Bryan Reese
@breese8009
Jan 30 2017 02:42
@rico042002 whats the name of this challenge? im not sure what ur supposed to do
Christopher McCormack
@cmccormack
Jan 30 2017 02:42
@Margaret2 I believe that's correct :D
taltmann42
@taltmann42
Jan 30 2017 02:42
@majordwarf to save to the localStorage, you have to use the setItem function with 2 parameters: key and value. In your case "run" and "didrun" may be suitable, or even "run" and true
Rico042002
@rico042002
Jan 30 2017 02:42
@breese8009 Its not an FCC challenge
Tejas Tank
@majordwarf
Jan 30 2017 02:42
This code should hide an element from HTML if its not the first run. But it is still displaying it. Please Help!
Bryan Reese
@breese8009
Jan 30 2017 02:42
@rico042002 I donno what ur function is supposed to do
taltmann42
@taltmann42
Jan 30 2017 02:42
@majordwarf then again, you don't get the value from the localstorage before looking if it actually exists
Leo Vroegindewey
@system1ord
Jan 30 2017 02:42

// Example
function ourReusableFunction() {
console.log("Heyya, World");
}

ourReusableFunction();

// Only change code below this line

function resuableFunction() {
console.log ("Hi World");
}
resuableFunction();

Christopher McCormack
@cmccormack
Jan 30 2017 02:42
@GodKingShogun check your opening h1 tag for the css issue
Leo Vroegindewey
@system1ord
Jan 30 2017 02:42
how do i call this function?
Bryan Reese
@breese8009
Jan 30 2017 02:42
@rico042002 what do u want ur function to do?
Tejas Tank
@majordwarf
Jan 30 2017 02:43
@taltmann42 Thanks!
CamperBot
@camperbot
Jan 30 2017 02:43
majordwarf sends brownie points to @taltmann42 :sparkles: :thumbsup: :sparkles:
:cookie: 415 | @taltmann42 |http://www.freecodecamp.com/taltmann42
Rico042002
@rico042002
Jan 30 2017 02:43
its a greeting function
Margaret
@Margaret2
Jan 30 2017 02:43
@system1ord looks like you are doing it right, but check the name of your function, it probably should not be resuableFunction
Rico042002
@rico042002
Jan 30 2017 02:43
Im in over my head
Joseph
@revisualize
Jan 30 2017 02:43
@system1ord resuableFunction();
David Amanze
@GodKingShogun
Jan 30 2017 02:44
@cmccormack fail on my part. i tried inputting it in the console part and it still says undefined
Leo Vroegindewey
@system1ord
Jan 30 2017 02:44
wow i feel stupid.. its a spelling error
@Margaret2 @revisualize thanks
CamperBot
@camperbot
Jan 30 2017 02:44
system1ord sends brownie points to @margaret2 and @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3143 | @revisualize |http://www.freecodecamp.com/revisualize
:star2: 1411 | @margaret2 |http://www.freecodecamp.com/margaret2
Christopher McCormack
@cmccormack
Jan 30 2017 02:45
@GodKingShogun the console.log logs the object to the console. to view it in the console, you just click the console button at the bottom. It's working fine to me when I reload your page and run it
armynational
@armynational
Jan 30 2017 02:45
i need help converting celsius into fahrenheit
Joseph
@revisualize
Jan 30 2017 02:45
@armynational What is your function?
Christopher McCormack
@cmccormack
Jan 30 2017 02:45
@GodKingShogun console.log is a troubleshooting tool. If you don't know the state of a variable or object, you can log it to console at that point and see. I like to put tons of log statements in my code while I'm building it so I can track what the state is and what function I'm entering/exiting, but it's up to the programmer how they use their tools
Bryan Reese
@breese8009
Jan 30 2017 02:46
@rico042002 I think I did this one at codeacademy
armynational
@armynational
Jan 30 2017 02:46

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

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

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

@revisualize

Bryan Reese
@breese8009
Jan 30 2017 02:46
I just dont remember what the instructions want u to do
Joseph
@revisualize
Jan 30 2017 02:46
@armynational So, you haven't done anything. Okay.
armynational
@armynational
Jan 30 2017 02:46
idk where to start or put anything @revisualize
Joseph
@revisualize
Jan 30 2017 02:46
@armynational What is the mathematical function to turn Celsius to Fahrenheit?
David Amanze
@GodKingShogun
Jan 30 2017 02:47
@cmccormack i have it written in my code and i am clicking the console button but no luckhttps://codepen.io/GodKingShogun/pen/LxOLQg?editors=1111
armynational
@armynational
Jan 30 2017 02:47
Celsius times 9/5, plus 32 @revisualize
LynnPLong
@LynnPLong
Jan 30 2017 02:47

var Bike = function() {

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

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

return getGear();

};
};

Christopher McCormack
@cmccormack
Jan 30 2017 02:47
@revisualize
// *** Conversion function 
// Celsius = (Farenheit - 32) * 5/9
// Celsius = Kelvin − 273.15
// Farenheit = (Celsius * 9/5) + 32
// Farenheit = Kelvin ×  9⁄5 − 459.67
// Kelvin = Celsius + 273.15
// Kelvin = (Farenheit + 459.67) × 5/9
Joseph
@revisualize
Jan 30 2017 02:47
@cmccormack I didn't ask you. But, thanks?
CamperBot
@camperbot
Jan 30 2017 02:48
revisualize sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 296 | @cmccormack |http://www.freecodecamp.com/cmccormack
Bryan Reese
@breese8009
Jan 30 2017 02:48
@rico042002 doesnt it want a specific return if someone has never been, if someone is returning and if someone is back for a second time or something like that
Christopher McCormack
@cmccormack
Jan 30 2017 02:48
@revisualize wasn't just for you, but nice response...
Rico042002
@rico042002
Jan 30 2017 02:48
@breese8009 yes
Bryan Reese
@breese8009
Jan 30 2017 02:48
@revisualize lol
Joseph
@revisualize
Jan 30 2017 02:49
@armynational Okay. So, if we know that celsius is a variable that we can convert celsius to fahrenheit and assign that to the fahrenheit variable?
Bryan Reese
@breese8009
Jan 30 2017 02:49
@rico042002 yea ive solve that one before, its been a while but if u can get me the directions id love to crack at it again, i remember it not being too hard
David Amanze
@GodKingShogun
Jan 30 2017 02:49
@cmccormack also you said something earlier about making my weather api callback a part of my first api. i didn't really understand how to do that
Joseph
@revisualize
Jan 30 2017 02:49
@cmccormack Sorry, I saw my name tagged in the post so, I assumed it was for me. Otherwise. I figure I shouldn't have been tagged. But, I guess I'm clearly mistaken.
Bryan Reese
@breese8009
Jan 30 2017 02:50
@rico042002 maybe send me the link of the site ur doing the challenge on, which i believe is codeacademy
Christopher McCormack
@cmccormack
Jan 30 2017 02:50
@GodKingShogun that was a mistake on my part, but you may want to tab it to the right one tab so you can tell it's within the scope of your previous API call for location
Bryan Reese
@breese8009
Jan 30 2017 02:51
@breese8009 PM me the link
armynational
@armynational
Jan 30 2017 02:51

fahrenheit=(09/5)+32;
fahrenheit=(-30
9/5)+32;
fahrenheit=(-109/5)+32;
fahrenheit=(20
9/5)+32;
fahrenheit=(30*9/5)+32;

this is what i did and it says its wrong..... whats wrong with it? @revisualize

David Amanze
@GodKingShogun
Jan 30 2017 02:52
@cmccormack do you mean tab my weather api once
Joseph
@revisualize
Jan 30 2017 02:52
@armynational Why aren't you using the celsius variable?
armynational
@armynational
Jan 30 2017 02:53
because im converting celsius into fahrenheit @revisualize
Christopher McCormack
@cmccormack
Jan 30 2017 02:53
@GodKingShogun yup that's all I meant
Joseph
@revisualize
Jan 30 2017 02:53
@armynational You need to use the celsius variable to make that happen.
armynational
@armynational
Jan 30 2017 02:54
could you give me an example? @revisualize
David Amanze
@GodKingShogun
Jan 30 2017 02:54
@cmccormack i did all that but my page is still just showing the header :worried:
Joseph
@revisualize
Jan 30 2017 02:54

@armynational Let me ask you a side question.

var x = val + 3;

What does x represent if val is 7?
What does x represent if val is 39?

armynational
@armynational
Jan 30 2017 02:55
4 and 36 . @revisualize
Joseph
@revisualize
Jan 30 2017 02:55
@armynational I said + not -
armynational
@armynational
Jan 30 2017 02:55
sorry 10 and 42 @revisualize
Joseph
@revisualize
Jan 30 2017 02:56
@armynational Do you see how val is a variable that you can use to do math against?
@armynational Same principle with this challenge.
Christopher McCormack
@cmccormack
Jan 30 2017 02:56
@GodKingShogun take a look at your api call - you haven't added your newly acquired lat/lon information, you just sent a string with {lat} and {lon} in it. Gotta break that up and insert the variables
Joseph
@revisualize
Jan 30 2017 02:56
@armynational celsius is a variable that we can use in our math expression
armynational
@armynational
Jan 30 2017 02:56
but how would represent that with celsius? @revisualize
Joseph
@revisualize
Jan 30 2017 02:57
@armynational re-read the instructions. celsius is a variable.
You are given a variable celsius representing a temperature in Celsius.
Use the variable fahrenheit already defined and apply the algorithm to assign it the corresponding temperature in Fahrenheit.

Parameters are like variables that represent the values that get passed into your function from the function call.
https://cs.wellesley.edu/~cs110/lectures/L16/images/function-anatomy.png
Notice how the variables level and score in the function definition addScore are called parameters.
However, when we invoke the function like in:
addScore(3, 10) or addScore(6, 20)
the values are called arguments. Here is an important lesson:
You define a function with parameters, you call a function with arguments.

Another 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.

Yet another example code:

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

You can see how the parameter is used like a variable inside of the function.
And you can do mathematical operations to the parameter and assign the value to the variable result.

Other important things to remember:
* A function can have zero parameters. You still have to use the parentheses to define it.
* A function might have no return statements. In this case we say that the function returns undefined.

From knowing that please note that technically, calling parameters variables isn't correct. Parameters are part of the function declaration and when the function is called, an execution context is formed and there parameters are variables that hold the passed arguments.

David Amanze
@GodKingShogun
Jan 30 2017 02:59
@cmccormack lat on lon in the weather api were originally params
Leo Vroegindewey
@system1ord
Jan 30 2017 03:00
function fun1() {
// Assign 5 to oopsGlobal Here
oopsGlobal(5);
}
Inside function fun1, assign 5 to oopsGlobal without using the var keyword. How do i this excatly if I cant use a a VAR?
David Amanze
@GodKingShogun
Jan 30 2017 03:01
@cmccormack how would i insert then as variables
Christopher McCormack
@cmccormack
Jan 30 2017 03:01
@GodKingShogun you have to break up the string, you can't just insert the text into the string or it will also be treated as text. Remember the string concatenation operator. https://www.freecodecamp.com/challenges/concatenating-strings-with-plus-operator
taltmann42
@taltmann42
Jan 30 2017 03:01
@system1ord there is a var oopsGlobal above the function isn't it?
Leo Vroegindewey
@system1ord
Jan 30 2017 03:01
no there is not
Manish Giri
@Manish-Giri
Jan 30 2017 03:02
@system1ord you need to assign the value to oopsGlobal
taltmann42
@taltmann42
Jan 30 2017 03:02
@system1ord ah okay.. well.. just don't use var
Manish Giri
@Manish-Giri
Jan 30 2017 03:02
oopsGlobal = ....
Vizij
@Vizij
Jan 30 2017 03:02
@system1ord Literally the same way you would do it with var, just omit var
Leo Vroegindewey
@system1ord
Jan 30 2017 03:02
oh ok
wow -
Joseph
@revisualize
Jan 30 2017 03:02
@armynational are things making sense or am I just confusing you?
Leo Vroegindewey
@system1ord
Jan 30 2017 03:02
@Manish-Giri @taltmann42 thanks
CamperBot
@camperbot
Jan 30 2017 03:02
system1ord sends brownie points to @manish-giri and @taltmann42 :sparkles: :thumbsup: :sparkles:
:cookie: 416 | @taltmann42 |http://www.freecodecamp.com/taltmann42
:star2: 3985 | @manish-giri |http://www.freecodecamp.com/manish-giri
David Amanze
@GodKingShogun
Jan 30 2017 03:02
@Manish-Giri Hello Senpai :smile:
Manish Giri
@Manish-Giri
Jan 30 2017 03:03
@GodKingShogun konichiwa!
armynational
@armynational
Jan 30 2017 03:03

@revisualize

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

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

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

i honestly dont get it

Joseph
@revisualize
Jan 30 2017 03:04
@armynational You're doing it backwards.
armynational
@armynational
Jan 30 2017 03:04
what exactly am i doing backwards? @revisualize
Joseph
@revisualize
Jan 30 2017 03:04
@armynational fahrenheit should be on the left of the assignment operator (=)
David Amanze
@GodKingShogun
Jan 30 2017 03:04
@cmccormack i dont really get it. can you do an example for lon and then i will do lat
armynational
@armynational
Jan 30 2017 03:05
i got it thank you i havent been on here in about a week so im trying to get back into it @revisualize
CamperBot
@camperbot
Jan 30 2017 03:05
:star2: 3144 | @revisualize |http://www.freecodecamp.com/revisualize
armynational sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
Christopher McCormack
@cmccormack
Jan 30 2017 03:06
@GodKingShogun something like this:
var url = "http://api.openweathermap.org/data/2.5/weather?" + lon + ...
Joseph
@revisualize
Jan 30 2017 03:06
@armynational Take the time to look at the solution. And re-read the instructions.
@armynational Make sure that you understand everything because using parameters as variables is critical to programming.
@armynational Learning to program isn't about getting the correct answer on some website. It is about learning the concepts and making sure than you can understand them to apply them to different problems.
David Amanze
@GodKingShogun
Jan 30 2017 03:08
@cmccormack so i won't need the & until after lat like so +lon+lat&units=metric
Christopher McCormack
@cmccormack
Jan 30 2017 03:12
@GodKingShogun the lat and lon, when provided as part of the url, are called parameters. each parameter is usually in the form of &lat=33.123 or something similar.
just read the & as an and it it makes sense. The URL+Path is http://api.openweathermap.org/data/2.5/weather, the ? means a query will follow the URL + Path, and parameters will follow the ?
c0d0er
@c0d0er
Jan 30 2017 03:15
@walidashri thanks
CamperBot
@camperbot
Jan 30 2017 03:15
c0d0er sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 863 | @walidashri |http://www.freecodecamp.com/walidashri
David Amanze
@GodKingShogun
Jan 30 2017 03:15
@cmccormack take a look at how i have it and tell me if it's right
Noe Santiago
@Santiago7011
Jan 30 2017 03:16
help on 150 please!
CamperBot
@camperbot
Jan 30 2017 03:16
no wiki entry for: on 150 please
David Amanze
@GodKingShogun
Jan 30 2017 03:16
had to switch it to appendTo
Christopher McCormack
@cmccormack
Jan 30 2017 03:18
@GodKingShogun you still have your variables inserted directly into the string. You have to end the first part of the string by adding the quotes, then add the +, then use quotes to start the next part again.
var google = "www.google.com";
var url  = "http://" + google;
David Amanze
@GodKingShogun
Jan 30 2017 03:19
@cmccormack oh
armynational
@armynational
Jan 30 2017 03:20
whats wrong with this
var myStr "FirstLinen\n\SecondLine\rThirdline"
Vizij
@Vizij
Jan 30 2017 03:22
@armynational You're missing the = for assignment, you have a "n" at the end of FirstLine, your first backslash isn't escaped, your second backslash isn't there at all, and you're missing a semicolon.
Manish Giri
@Manish-Giri
Jan 30 2017 03:23
@Santiago7011 what's the challenge name? post your code.
Ogundele Olumide
@Lumexralph
Jan 30 2017 03:23
@Santiago7011 What's your question?
@Manish-Giri :wave:
armynational
@armynational
Jan 30 2017 03:24
FirstLinenewline backslashSecondLinebackslash carriage-returnThirdLine
this is what it told me @Vizij
Manish Giri
@Manish-Giri
Jan 30 2017 03:24
@Lumexralph :wave:
Ogundele Olumide
@Lumexralph
Jan 30 2017 03:24
it's morning here
Vizij
@Vizij
Jan 30 2017 03:25
@armynational Yep. I pointed out the things you need to get to that.
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 30 2017 03:25

Hey guys, I'm on the "Make Object Properties Private" challenge, without just telling me the answer, could someone explain to me why my code is not working, thanks.

var Bike = function() {
// Only change code below this line.
var gear = 0;
this.setGear = function(switchGear) {
gear += switchGear;
};
this.getGear = function() {
return gear;
};
};

var myBike = new Bike();

David Amanze
@GodKingShogun
Jan 30 2017 03:25
@Lumexralph my brother. how you dey
Manish Giri
@Manish-Giri
Jan 30 2017 03:26
@TheRealChrisEdwards gear += switchGear; should probably be = instead of +=
CyuSunill
@CyuSunill
Jan 30 2017 03:26
stuck in case sensitivity in variables. please need help!!!
armynational
@armynational
Jan 30 2017 03:26

but i dont understand what you mean i corrected the semi colon and = but i dont understand the rest because a ccording to the table thats correct

@Vizij

David Amanze
@GodKingShogun
Jan 30 2017 03:26
@Manish-Giri good night senpai :smile:
Ogundele Olumide
@Lumexralph
Jan 30 2017 03:27
@TheRealChrisEdwards your setGear method should assign the parameter to gear
David Amanze
@GodKingShogun
Jan 30 2017 03:27
:wa
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 30 2017 03:27
@Manish-Giri
but why tho, isn't the purpose of this.setGear to be able to change the gear with the user input
David Amanze
@GodKingShogun
Jan 30 2017 03:27
:wave:
Ogundele Olumide
@Lumexralph
Jan 30 2017 03:27
@GodKingShogun hey bro
@TheRealChrisEdwards that's why you need =
David Amanze
@GodKingShogun
Jan 30 2017 03:28
@Lumexralph you have been Americanized :smile: kilodey
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 30 2017 03:28
@Lumexralph @Manish-Giri Thanks, ill take your word
CamperBot
@camperbot
Jan 30 2017 03:28
:star2: 3987 | @manish-giri |http://www.freecodecamp.com/manish-giri
therealchrisedwards sends brownie points to @lumexralph and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 892 | @lumexralph |http://www.freecodecamp.com/lumexralph
Vizij
@Vizij
Jan 30 2017 03:28
@armynational Each character has to be escaped. Like, for example, this part: "FirstLinen\n\SecondLine" . You have an extra "n" right after FirstLine here, that's just counted as the character "n". Then, you have a newline, that's properly escaped. Then, you have a backslash -- but that backslash is not escaped. Double check the chart to the left.
Jona Reyes
@rookie-cookie
Jan 30 2017 03:28

hey guys, im a bit stuck in Testing Objects for Properties, can i get a little help. here's my code, i cant figure out what's wrong with it. // Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");

Manish Giri
@Manish-Giri
Jan 30 2017 03:29
@TheRealChrisEdwards yes, you set the gear to what the user passes in, you were instead incrementing gear with what the user passed.
Ogundele Olumide
@Lumexralph
Jan 30 2017 03:29
@rookie-cookie checkProp is not a string it's a parameter
Manish Giri
@Manish-Giri
Jan 30 2017 03:29
@rookie-cookie first, here
if (myObj.hasOwnProperty("checkProp"))
checkProp is a variable, not the sring
Christopher McCormack
@cmccormack
Jan 30 2017 03:29
@rookie-cookie take quotes off the checkProp
Manish Giri
@Manish-Giri
Jan 30 2017 03:29
then here - return myObj.checkProp;
use bracket notation
@rookie-cookie
Ogundele Olumide
@Lumexralph
Jan 30 2017 03:30
@GodKingShogun you're Japanese, right?
Manish Giri
@Manish-Giri
Jan 30 2017 03:30
@GodKingShogun good night!! cya tomorrow :wave:
David Amanze
@GodKingShogun
Jan 30 2017 03:30
@Lumexralph kedu
Jona Reyes
@rookie-cookie
Jan 30 2017 03:31
@Manish-Giri that worked, thanks :)
CamperBot
@camperbot
Jan 30 2017 03:31
rookie-cookie sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3988 | @manish-giri |http://www.freecodecamp.com/manish-giri
David Amanze
@GodKingShogun
Jan 30 2017 03:31
@Lumexralph what do you mean eh. i have African blood flowing in me
Ogundele Olumide
@Lumexralph
Jan 30 2017 03:31
@rookie-cookie dot method won't work , you're using a parameter.... so bracket as @Manish-Giri said
armynational
@armynational
Jan 30 2017 03:31
var myStr ="FirstLine\n\SecondLine\\rThirdline";
what about this? @Vizij
Manish Giri
@Manish-Giri
Jan 30 2017 03:31
@rookie-cookie :+1:
David Amanze
@GodKingShogun
Jan 30 2017 03:32
@Lumexralph i eat pounded yam and ogbono for breakfast lunch and dinner
Manish Giri
@Manish-Giri
Jan 30 2017 03:32
lol
Ogundele Olumide
@Lumexralph
Jan 30 2017 03:32
@GodKingShogun wait ooo, the last time we spoke you said you're Japanese abi?
Jona Reyes
@rookie-cookie
Jan 30 2017 03:32
thanks guys!
Vizij
@Vizij
Jan 30 2017 03:32
@armynational Close, but your backslashes around SecondLine still aren't escaped. Remember, to escape a backslash, you have to actually "backslash the backslash". \\
Michael Bomholt
@bomholtm
Jan 30 2017 03:33
is there a way to calculate 100vh - height of a div which is changing height?
Ogundele Olumide
@Lumexralph
Jan 30 2017 03:33
@GodKingShogun pounded yam.... yeah!
armynational
@armynational
Jan 30 2017 03:33
are they not already double backslashed? @Vizij
David Amanze
@GodKingShogun
Jan 30 2017 03:33
@Lumexralph where did you get that information from :smile:
armynational
@armynational
Jan 30 2017 03:34
var myStr ="FirstLine\n\SecondLine\\rThirdline"; @Vizij this is the one it was suppose to copy but it didnt
Ogundele Olumide
@Lumexralph
Jan 30 2017 03:34
@GodKingShogun and how'll you eat that all day, ehn?
David Amanze
@GodKingShogun
Jan 30 2017 03:34
lol im dying here. i have to go now. peace everyone :wave:
Vizij
@Vizij
Jan 30 2017 03:34
@armynational They aren't, no. You have "FirstLine (newline) \SecondLine\ (carriage-return) Thirdline", but the backslashes need to be escaped \\ in order to show up.
Ogundele Olumide
@Lumexralph
Jan 30 2017 03:35
i saw Shogun in your name and that was the from Shogunate... Warrior leader or king in Japan history and I asked you if you're from there and you said yes... so? @GodKingShogun
Vizij
@Vizij
Jan 30 2017 03:36
I think it should be "ThirdLine" also, that might throw an error. Can't remember if that was capitalized or not.
armynational
@armynational
Jan 30 2017 03:36
it still did it
var myStr="FirstLine\n\SecondLine\\rThirdLine";
@Vizij
Joseph
@revisualize
Jan 30 2017 03:36
@armynational Thirdline is not the same as ThirdLine .. Note the cap L
armynational
@armynational
Jan 30 2017 03:36
it wont put it in this chat room like i want
Ogundele Olumide
@Lumexralph
Jan 30 2017 03:36
@GodKingShogun don't go ooo.... you must clear yourself
Joseph
@revisualize
Jan 30 2017 03:36
@armynational You need to learn how to post code.
Diego Mayer
@Chrono79
Jan 30 2017 03:37
@armynational that last code is ok
Vizij
@Vizij
Jan 30 2017 03:37
@armynational Use backticks. code . Start and end with `
Joseph
@revisualize
Jan 30 2017 03:37

If you are posting code that is large, Please use Gist - https://gist.github.com/ then please paste the link here.
...
How to do code block format: ..... PLEASE try with a small block of code before you try to make a bigger one.
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code
```js [SHIFT+ENTER]
// your code here
``` [CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

...
You can also do inline code formatting:
A string of text with a `variable` or `other bit of code`.
Output:
A string of text with a variable or other bit of code.

Mohammad
@Mo76
Jan 30 2017 03:37

hey guys,

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  arr = arr.filter(function(val){
    return val !== false && val !== null && val !==0 && val !=="" && val !==undefined || val!== NaN;
  });
  return arr;
}

how do I check if there is NaN in the array?
Thanks in advance

Diego Mayer
@Chrono79
Jan 30 2017 03:37
@Mo76 in your case val === val
Ogundele Olumide
@Lumexralph
Jan 30 2017 03:37
@Mo76 val! == val
armynational
@armynational
Jan 30 2017 03:38
i fixed it thank you @Vizij @revisualize
CamperBot
@camperbot
Jan 30 2017 03:38
armynational sends brownie points to @vizij and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 345 | @vizij |http://www.freecodecamp.com/vizij
:warning: armynational already gave revisualize points
Mohammad
@Mo76
Jan 30 2017 03:38
cool thanks
Ogundele Olumide
@Lumexralph
Jan 30 2017 03:38
rather val === val....
Manish Giri
@Manish-Giri
Jan 30 2017 03:38
@Mo76 try Number.isNaN()
Diego Mayer
@Chrono79
Jan 30 2017 03:38
@Mo76 now try using Boolean
Ogundele Olumide
@Lumexralph
Jan 30 2017 03:38
NaN is not equal to itself
Manish Giri
@Manish-Giri
Jan 30 2017 03:38
or maybe try searching for truthy values instead
of falsy
Ogundele Olumide
@Lumexralph
Jan 30 2017 03:39
@Manish-Giri will that handle NaN?
Margaret
@Margaret2
Jan 30 2017 03:39
@Mo76 just return val, it will work
Manish Giri
@Manish-Giri
Jan 30 2017 03:40
@Lumexralph I remember seeing a person's code a few weeks earlier, where it worked with that..
Ogundele Olumide
@Lumexralph
Jan 30 2017 03:40
:zap:
Margaret
@Margaret2
Jan 30 2017 03:40
FAIL
Manish Giri
@Manish-Giri
Jan 30 2017 03:40
:zap: is back
Mohammad
@Mo76
Jan 30 2017 03:40
@Margaret2 it worked, nice
Margaret
@Margaret2
Jan 30 2017 03:41
:+1:
:zap: in, :zap: out... nite guys :wave:
Ogundele Olumide
@Lumexralph
Jan 30 2017 03:42
@Manish-Giri ok
@Margaret2 yeah just like a :zap:... :smirk
Joe Narvaez
@wordyallen
Jan 30 2017 03:46
anyone here do redux?
Coy Sanders
@coymeetsworld
Jan 30 2017 03:50
@wordyallen :wave: learning it yeah, got it to work on Recipe Box app last night
Joe Narvaez
@wordyallen
Jan 30 2017 04:07
const StartButtons = inject('store')(observer(({store})=>(
  <div>
    <button style={{...button, color: '#4bd761'}} onClick={() => store.startTimer()}>
      start
    </button>
    <button style={button} onClick={() => store.resetTimer()}>
      reset
    </button>
  </div>
)))



export default observer( ({store})=>{

  const {mainDisplay, isRunning} = store
  return (
    <Provider store={store}>
    <div >
      <div style={main}>
        {mainDisplay}
      </div>
      <div>
        <div style={bContainer}>
          {isRunning ? <RunningButtons />:<StartButtons />}
        </div>
      </div>
    </div>
  </Provider>
  )
})
@coymeetsworld feast your eyes on this state management glory. no mapstatetoprops, combineReducer, actions container components... after a a year of doing redux, mobx is making me love state management again
Coy Sanders
@coymeetsworld
Jan 30 2017 04:08
ya I was following that in the main chat, looks nice @wordyallen yeah I agree there seems to be alot of boilerplate w/ redux
will look into that most likely after i get some more work in with redux, only started using it in an actual project a week ago
c0d0er
@c0d0er
Jan 30 2017 04:09
does anybody know how to make event.target.value in redux?
Joe Narvaez
@wordyallen
Jan 30 2017 04:09
um.. context scoping and redux are not related
Gurbaksh Singh
@Gurbakshs
Jan 30 2017 04:09
hi - can anyone recommend additional resources (books, etc) in order to get better with solving the algorithms challenges
Joe Narvaez
@wordyallen
Jan 30 2017 04:10
you use an arrow to go up one level or function for the callsite
Kenny
@kennyallen
Jan 30 2017 04:10
I 2nd @Gurbakshs ’s request
Joe Narvaez
@wordyallen
Jan 30 2017 04:10
I can
best book ever
destroyed a few interviews
Kenny
@kennyallen
Jan 30 2017 04:11
Really? And they ask these kinds of things in interviews?
Joe Narvaez
@wordyallen
Jan 30 2017 04:11
its in python, but rewriting it in js is good
yeah... they asked me implement a linked list
and the other was just to explain how mergesort time complexity is better
not common
but it happens
Kenny
@kennyallen
Jan 30 2017 04:14
hmm
Awesome. Thanks for the suggestion!
Joe Narvaez
@wordyallen
Jan 30 2017 04:15
yer
Tom Lee
@user512
Jan 30 2017 04:16

Hey all, when working with NodeJS/ExpressJS, is there any debugger tool you can recommend?

I came from Ruby/ Rails and I used to use something call pry. Thank you.

Joe Narvaez
@wordyallen
Jan 30 2017 04:16
nodemon
Tom Lee
@user512
Jan 30 2017 04:17
Exactly what I am looking for, thanks @wordyallen!
CamperBot
@camperbot
Jan 30 2017 04:17
user512 sends brownie points to @wordyallen :sparkles: :thumbsup: :sparkles:
:cookie: 268 | @wordyallen |http://www.freecodecamp.com/wordyallen
Joe Narvaez
@wordyallen
Jan 30 2017 04:18
you the bawz
Tejas Tank
@majordwarf
Jan 30 2017 04:22
var firstTime = localStorage.getItem("first_time");
if(!firstTime) {
    function apiRecived() {
    document.getElementById("fr").style.visibility = "hidden";
    };
    localStorage.setItem("first_time","1");
}
Can Some one tell me why the variable is not being saved in local storage?
Joe Narvaez
@wordyallen
Jan 30 2017 04:24
firstTime exists
I think it might be bound to undefined
also rap music
Tejas Tank
@majordwarf
Jan 30 2017 04:24
Please elaborate I'm just a beginner
Alex
@Joshua-A-Smith
Jan 30 2017 04:25

Does anyone know how to hide a div onload then use button onclick to show the div later no jquery vanilla javascript???
Here's my code...

<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
/*body {
  background-color:#CD5C5C;
} */

body {
  background-image: url("http://onehdwallpaper.com/wp-content/uploads/2015/07/Full-HD-Nature-HD-Wallpapers.jpg"); 
   min-height:100%;
   min-width:1024x;
   width:100%;
   height:auto;
   top:0;
   left:0;
   position:fixed;
   background-repeat:no-repeat;
   background-size:cover;
 }
  header {
  /*background-color:#00ff7F;  -Right here we're gonna try a backgorund-image */
  background-image: url("http://www.lanlinglaurel.com/data/out/181/5577762-clouds-wallpaper.png");
  font-family:"Papyrus";
  font-size:45px;
  width:500px;
  height:50px;
  opacity:0.6;
  clear:left;
  border:10px solid black;
  border-radius:25px;
  letter-spacing:5px;
  color:#4B0082;
  padding:15px;
  margin:auto;
  text-align:center;
}
/*  ul {
  list-style-type:none;
  background-color:lightgrey;
  height:30%;
  width:15%;
  border-radius:15%;
  opacity:0.6;
}
li {
  padding:30px;
  font-size:30px;
  font-family:copperplate gothic light;
  font-weight:bold;
}
li:hover {
  background-color:black;
  color:white;
} */
</style>
</head>
<body>

<header id="swang">color</header>
<!-- <ul>
  <li onclick="f()">News</li>
  <li onclick="vr()">Home</li>
</ul> -->
<button id ="one" onclick="africa"></button>
<button id="two" onclick="japan"></button>
<button id="three" onclick="china"></button>
<button id="four" onclick="usa"></button>
<button id="five" onclick="uk"></button>
<button id="six" onclick="austarlia"></button>
<button id="seven" onclick="russia"></button>



<script>
/* button onclick target new window open new window */

/*  button onclick prompt   */

/* write objects call them in functions document.get elementbyid settimout call buttons or a div tag slowmo when user clicks onclick */

/*  button onclick alert  */

/*  make arrays access and or call them with "0" "1" add the arrays with math push use shift unshift push and pop */

/*  create a skinny css menu click target open new tab in window or menu */


/*  function document.getElementById setTimeout get div & or element slow opaque rise up when user clicks button  onclick   */

var x = 10;
for (i = 0; i != x; i++) {
  if (i == 2) {
   /* alert(); */
  }
  else if (i == 4) {
    break;
  }
}

var f = function() {
  alert("No News!"); 
}

var vr = function() {
  alert("No Home");
}
/*  onclick document.getElementById setTimeout call slow timer getElementByTagName call div & or object mclaren as you hit the button use document.getElementByTagName to call divs with photos slowmo using set out timer to slowly pop up the properties using buttions */
var whip = {
  engine: 1,
  interior: "clean",
  interiorcolor: "red",
  rimsize: 14,
  horsepower: 7000,
  topspeed: "207mph",
  price: "180,851.05 dollars and cents"
}
document.getElementById("swang").innerHTML = "McLaren";
var one = whip.engine;
document.getElementById("one").innerHTML = one;
var two = whip.interior;
document.getElementById("two").innerHTML = two;
var three = whip.interiorcolor;
document.getElementById("three").innerHTML = three;
var four = whip.rimsize;
document.getElementById("four").innerHTML = four;
var five = whip.horsepower;
document.getElementById("five").innerHTML = five;
var six = whip.topspeed;
document.getElementById("six").innerHTML = six;
var seven = whip.price;
document.getElementById("seven").innerHTML = seven;
/* ?----------------------------------------------- ?
?------------ l i n e b r e a k -----------------  ?  */

var africa = function() {

}

var japan = function() {

}

var china = function() {

}

var usa = function() {

}

var uk = function() {

}

var australia = function() {

}

var russia = function() {

}

</script>
</body>
</html>

Pls help thanks.

Joseph
@revisualize
Jan 30 2017 04:28
@Joshua-A-Smith SERIOUSLY?

Get help on our basic JavaScript and Algorithms Challenges.

If you are posting code that is large use Gist - https://gist.github.com/ paste the link here.

(our referencing FreeCodeCamp)
Tejas Tank
@majordwarf
Jan 30 2017 04:35

```
var firstTime = localStorage.getItem("first_time");
if(!firstTime) {
function apiRecived() {
document.getElementById("fr").style.visibility = "hidden";
};
localStorage.setItem("first_time","1");
}

```
Can Some one tell me why the variable is not being saved in local storage?

Rico042002
@rico042002
Jan 30 2017 04:40
anybody can help changing multiple arrays to an object
Joe Escobedo
@joeEscob1023
Jan 30 2017 04:44
I dont really understand the 'new' concept with objects
Enrique Machado
@juniorkino7
Jan 30 2017 04:46
I need help with the second challenge of java
Tom Lee
@user512
Jan 30 2017 04:53
@Joshua-A-Smith maybe set display none on that div and use javascript to listen for onclick to set display block?
Darleck8
@Darleck8
Jan 30 2017 05:00

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

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

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

help
how do
??
Jacky Lui
@Recelis
Jan 30 2017 05:02
hey, I'm having a bit of trouble with the Profile Loopup question 250. Is the general idea to loop through the contacts array and then do something like this? check1 = contacts[i]["firstName"].firstName.hasOwnProperty;
?
Ogundele Olumide
@Lumexralph
Jan 30 2017 05:02
@Darleck8 typo var farenheit should be fahrenheitand don't declare another variable it's already declared above
@Recelis contacts[i].firstName === firstName seems better
Pablo Arcia
@freakaziod210
Jan 30 2017 05:06
Hey, can someone help me out with some code challenges?
Ogundele Olumide
@Lumexralph
Jan 30 2017 05:07
@freakaziod210 ask your question
Lawanu Borthakur
@Lawanu
Jan 30 2017 05:11

function titleCase(str) {
var str_array=[];
var i;
str_array=str.split('');
for(i=0;i<str_array.length;i++)
{
if(i===0)
{
str_array[0].toUpperCase();

   }

else if(str_array[i]===' ')
{
str_array[i+1].toUpperCase();
}
}

return str_array.join(" ");
}

titleCase("i'm a little tea pot");

Pablo Arcia
@freakaziod210
Jan 30 2017 05:12
I need to create an html document that has an input box. The input box will accept text. As the text is input, I need to use
javascript to dynamically display the text on the screen in the shapeof a greater-than symbol.
@Lumexralph
Jacky Lui
@Recelis
Jan 30 2017 05:13
thanks @Darleck8! that helped!
CamperBot
@camperbot
Jan 30 2017 05:13
recelis sends brownie points to @darleck8 :sparkles: :thumbsup: :sparkles:
:cookie: 106 | @darleck8 |http://www.freecodecamp.com/darleck8
Lawanu Borthakur
@Lawanu
Jan 30 2017 05:13

can anyone plis tell me what is the problem with this code?.I am not getting the proper output for title case a sentence:function titleCase(str) {
var str_array=[];
var i;
str_array=str.split('');
for(i=0;i<str_array.length;i++)
{
if(i===0)
{
str_array[0].toUpperCase();

   }

else if(str_array[i]===' ')
{
str_array[i+1].toUpperCase();
}
}

return str_array.join(" ");
}

titleCase("i'm a little tea pot");

@camperbot plis help
jamesjd54
@jamesjd54
Jan 30 2017 05:16
when you log out is it supposed to clear all your code?
ive been doing the algorithm challenges and the ones i completed still have check marks but everything is gone
Lawanu Borthakur
@Lawanu
Jan 30 2017 05:17
no
Bryan Reese
@breese8009
Jan 30 2017 05:18
var str_array=[];
var i;
str_array=str.split('');
for(i=0;i<str_array.length;i++)
{
if(i===0)
{
str_array[0].toUpperCase();
   }
else if(str_array[i]===' ')
{
str_array[i+1].toUpperCase();
}
}
return str_array.join(" ");
}
titleCase("i'm a little tea pot");
now easier to read
Christopher McCormack
@cmccormack
Jan 30 2017 05:18
@jamesjd54 Click the number by your name, not the map.
@jamesjd54 Sorry, by your profile picture
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:18
@Lawanu what do you think your loop is doing?
jamesjd54
@jamesjd54
Jan 30 2017 05:19
oh sweet!
thank you, ive been referring back to other challenges to give myself ideas for when im getting stuck on my current one
plus it kinda bummed me out htinking all that work was gone
Lawanu Borthakur
@Lawanu
Jan 30 2017 05:19
@HeebieGeeBee it is incrementing the value of i.
@HeebieGeeBee isnt it??
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:20
yes but i mean what do you thnk your doing each time it increments?
as in your if(i===0)....
Lawanu Borthakur
@Lawanu
Jan 30 2017 05:20
@HeebieGeeBee it is checking the spaces
jamesjd54
@jamesjd54
Jan 30 2017 05:21
can someone explain why this only sorts and then pushes the first array?
function largestOfFour(arr) {
for(var i=0;i<4;i++){
arr[i].sort(function(a,b){
return a-b;});
var newArr=[];
newArr.push(arr[i][3]);
return newArr;
Lawanu Borthakur
@Lawanu
Jan 30 2017 05:21
@HeebieGeeBee for the first i put i===0
@HeebieGeeBee so,that 1st term become capital
Bryan Reese
@breese8009
Jan 30 2017 05:22

function largestOfFour(arr) {
for(var i=0;i<4;i++){
  arr[i].sort(function(a,b){
    return a-b;});
  var newArr=[];
  newArr.push(arr[i][3]);
  return newArr;
use back ticks
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:23
tr maybe doing str[i +1] = str[i +1].toUpperCase()
@Lawanu
but like with your own variable names
Michael Davis
@mdavis93
Jan 30 2017 05:24

In doing the 'Check for Palindromes' challenge I completed it, however it took two replace functions using RegEx. The first function used the /\W/gi expression, and the second used /_/g. Surely there's something I'm missing where I can do it all in one line right?

  var clean = str.replace(/\W/gi, '').toLowerCase();
  clean = clean.replace(/_/g, "");

-Pardon my double post here and in 'Help'

Ken Haduch
@khaduch
Jan 30 2017 05:24
@jamesjd54 - are you returning inside or outside of the for loop? Hard to tell...
jamesjd54
@jamesjd54
Jan 30 2017 05:24
specifically why doesnt that sort every array in the array
Khang Duy
@KD158
Jan 30 2017 05:24
can any1 help me please? i cant get through the "Escape Sequences in Strings" challenge
Bryan Reese
@breese8009
Jan 30 2017 05:25
@KD158 i hate that one too
Ken Haduch
@khaduch
Jan 30 2017 05:26
@mdavis93 - /[W_]/ try that
jamesjd54
@jamesjd54
Jan 30 2017 05:26
@khaduch thats the only way to use that sort function right? dont you have to do return a-b if you want to sort it smallest to largest?
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:26
str_array[i+1] = str_array[i+1].toUpperCase(); instead of just str_array[i+1].toUpperCase(); @Lawanu and the same for the other lines too
Ken Haduch
@khaduch
Jan 30 2017 05:26
Missed a backslash in that regexp
Posting from the phone
Lawanu Borthakur
@Lawanu
Jan 30 2017 05:27
@HeebieGeeBee but it is showing reference error
Ken Haduch
@khaduch
Jan 30 2017 05:27
/[W_]/
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:27
~what reference error? @Lawanu
Lawanu Borthakur
@Lawanu
Jan 30 2017 05:28
@HeebieGeeBee array is not defined

function titleCase(str) {
var str_array=[];
var i;
str_array=str.split('');
for(i=0;i<str_array.length;i++)
{
if(i===0)
{
str_array[0]=array[0].toUpperCase();

   }

else if(str_array[i]===' ')
{
str_array[i+1]=str_array[i+1].toUpperCase();
}
}

return str_array.join(" ");
}

titleCase("i'm a little tea pot");

Khang Duy
@KD158
Jan 30 2017 05:28
var myStr= "FirstLine \\ \n SecondLine \\r ThirdLine" ; // Change this line
here my code
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:29
need to put str_array @Lawanu
Michael Davis
@mdavis93
Jan 30 2017 05:29
str.replace(/[\W_]/, ''); doesn't seem to do anything. In fact, it makes 'clean' the exact same as the passed string.
Ken Haduch
@khaduch
Jan 30 2017 05:29
@mdavis93 - posting from my phone wasn't working - you can combine those two regexps into one expression /[\W_]/ or /\W|_/
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:29
str_array[0]=array[0].toUpperCase(); in this line @Lawanu
Ken Haduch
@khaduch
Jan 30 2017 05:30
@mdavis93 - this works for me: var lcString = str.toLowerCase().replace(/[\W_]/ig, '');
Lawanu Borthakur
@Lawanu
Jan 30 2017 05:30
@HeebieGeeBee Thanks a lot,Now it is working fine.
CamperBot
@camperbot
Jan 30 2017 05:30
lawanu sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 573 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:30
cool well done
Michael Davis
@mdavis93
Jan 30 2017 05:31
Hmm... trying again.. perhaps typo is at fault (wouldn't be the first time)
Ken Haduch
@khaduch
Jan 30 2017 05:32
@breese8009 - your return newArr; looks like it might be inside the for loop? And you probably need to declare your var newArr = [] before the for loop
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:32
dont really need the i do you if youre converting to lowercase first do you @khaduch
Bryan Reese
@breese8009
Jan 30 2017 05:32
@khaduch oh that wasnt my code, I was reposting other dudes code in proper format so it was easier to read
lol
thnaks th
thanks tho*
Ken Haduch
@khaduch
Jan 30 2017 05:33
@HeebieGeeBee - probably not, but it doesn't hurt, and you probably don't need it at all because I don't think that \W is case sensitive...
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:33
yeah fair enough
Ken Haduch
@khaduch
Jan 30 2017 05:33
@jamesjd54 - what I said in :point_up: January 30, 2017 12:32 AM that post...
Michael Davis
@mdavis93
Jan 30 2017 05:33
Yep, I forgot to put the 'i' and 'g' back. So, just so I understand, if I want multiple checks, I need to brace them in [ .. ]?
Ken Haduch
@khaduch
Jan 30 2017 05:34
@breese8009 - sorry, I got confused between the time I looked at it on my phone and got back to the computer.
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:34
pretty much @mdavis93
Ken Haduch
@khaduch
Jan 30 2017 05:34
@mdavis93 - you'd definitely want the /g, don't think you need the /i and yes, the brackets make groups of characters (or expressions, in this case)
Chase
@Athabasco
Jan 30 2017 05:35
Can I please get some help with the Caesar's Cipher? Here's what I got, but it's off a little bit.

function rot13(str) { // LBH QVQ VG!
  var string = "";
  var newLetter = "";
  var letterNumber = 0;
  for (var i = 0; i < str.length; i++){
if (str.charCodeAt(i) !== 32 && str.charCodeAt(i) < 77){
 letterNumber = str.charCodeAt(i) + 13;
  newLetter = String.fromCharCode(letterNumber);
  string += newLetter;
    } else if (str.charCodeAt(i) > 77){
      var numSub = 90;
      var numAdd = 65;
      var theNum = 0;

      theNum = 90 - str.charCodeAt(i);
      numAdd += theNum;
      newLetter = String.fromCharCode(numAdd);

      string += newLetter;

    } else {
      string += " ";
    }



  }


  return string;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Ken Haduch
@khaduch
Jan 30 2017 05:35
@Athabasco - I'm going to make a wild guess that you have an extra space at the end of your returned string...
Michael Davis
@mdavis93
Jan 30 2017 05:36
Yeah, just caught the /i wasn't needed if I convert to lower first. Thank you for the help. I've never worked with RegEx before... I've seen the phrase, but always thought it was something to do with the computer's Registry or something, lol!
Chase
@Athabasco
Jan 30 2017 05:36
@khaduch Nope. This is my return HRII KOJI KMAP
Ken Haduch
@khaduch
Jan 30 2017 05:37
@mdavis93 - check out some of the regex sites, if you are new to them, like regex101 - freecodecamp recommends a couple in some of the lessons?
@Athabasco = well, that's close... ;)
Chase
@Athabasco
Jan 30 2017 05:37
@khaduch Not as close as I would like... It's two off.
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:39
@Athabasco why dont you just plus 13 if its higher than 77 and minus 13 if its less
Chase
@Athabasco
Jan 30 2017 05:39
@HeebieGeeBee Because I'm not a logical thinker.
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:40
fair enough
think its actually the other way round too plus 13 if its less than 77 and minus 13 if its higher than 77
Chase
@Athabasco
Jan 30 2017 05:41
@HeebieGeeBee Oh. What do you know... It worked. Thanks.
CamperBot
@camperbot
Jan 30 2017 05:41
athabasco sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 574 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:42
sweet
well done
Chase
@Athabasco
Jan 30 2017 05:42
@HeebieGeeBee Well, it almost worked. Only the first of four tests is working.
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:43
whats not working?
and what does your code look like now
Chase
@Athabasco
Jan 30 2017 05:43
@HeebieGeeBee Z and !

function rot13(str) { // LBH QVQ VG!
  var string = "";
  var newLetter = "";
  var letterNumber = 0;
  for (var i = 0; i < str.length; i++){
if (str.charCodeAt(i) !== 32 && str.charCodeAt(i) < 77){
 letterNumber = str.charCodeAt(i) + 13;
  newLetter = String.fromCharCode(letterNumber);
  string += newLetter;
    } else if (str.charCodeAt(i) > 77 && str.charCodeAt(i) !== 32){
      letterNumber = str.charCodeAt(i) - 13;
      newLetter = String.fromCharCode(letterNumber);

      string += newLetter;

    } else {
      string += " ";
    }



  }


  return string;
}
jamesjd54
@jamesjd54
Jan 30 2017 05:43

got it, thanks @khaduch

function largestOfFour(arr) {
var newArr=[];
for (var i=0;i<arr.length;i++){
arr[i].sort(function(a,b){return a-b;});
newArr.push(arr[i][3]);
}

return newArr;
}

CamperBot
@camperbot
Jan 30 2017 05:43
jamesjd54 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2384 | @khaduch |http://www.freecodecamp.com/khaduch
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:43
youre missing out what happens if its exactly 77 i think @Athabasco
Ken Haduch
@khaduch
Jan 30 2017 05:43
@jamesjd54 :+1: - great! You're welcome...
Chase
@Athabasco
Jan 30 2017 05:44
@HeebieGeeBee But ! isn't working.
@HeebieGeeBee Or ?
Matt Richards
@mattjrichards
Jan 30 2017 05:44
This code works, but should there be a break for the last case?
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";
  }

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

// Change this value to test
chainToSwitch(7);
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:45
you need to do like >=77 or <=77 for whichever statement is right @Athabasco
firgure out which one needs it
@mattjrichards you could if you want but if it gets to the end its gonna break anyways
Chase
@Athabasco
Jan 30 2017 05:46
@HeebieGeeBee I got that working, but ? and ! aren't working.
Jor
@joreyesl
Jan 30 2017 05:46
@mattjrichards yes and no, if there isnt a break then it'll go on to the next case, but there is no more cases so
Matt Richards
@mattjrichards
Jan 30 2017 05:46
@HeebieGeeBee thank you
CamperBot
@camperbot
Jan 30 2017 05:46
mattjrichards sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 575 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:46
make sure it gets a limit on numbers higher than the alphabet character codes too @Athabasco
Chase
@Athabasco
Jan 30 2017 05:46
@HeebieGeeBee Oh, thanks!
CamperBot
@camperbot
Jan 30 2017 05:46
athabasco sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:warning: athabasco already gave heebiegeebee points
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:46
charcode 90 or whatver it is
Matt Richards
@mattjrichards
Jan 30 2017 05:47
@joreyesl Thank you. Got it.
CamperBot
@camperbot
Jan 30 2017 05:47
mattjrichards sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 396 | @joreyesl |http://www.freecodecamp.com/joreyesl
Michael Davis
@mdavis93
Jan 30 2017 05:48
hmm.. how does one give 'brownie points' to someone for giving help?
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:48
say thank you with them tagged @mdavis93
CamperBot
@camperbot
Jan 30 2017 05:48
heebiegeebee sends brownie points to @mdavis93 :sparkles: :thumbsup: :sparkles:
:cookie: 240 | @mdavis93 |http://www.freecodecamp.com/mdavis93
Jor
@joreyesl
Jan 30 2017 05:48
@Athabasco You need to check that you only +/- when code is <91 and >64. Otherwise you are also changing the ! and ?
Chase
@Athabasco
Jan 30 2017 05:48
You say 'thanks' or 'ty' or anything like that.
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:48
like tha
Michael Davis
@mdavis93
Jan 30 2017 05:48
ahh!
Thank you @khaduch for the help, I really appreciate it!
CamperBot
@camperbot
Jan 30 2017 05:49
:star2: 2385 | @khaduch |http://www.freecodecamp.com/khaduch
mdavis93 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:49
@Athabasco yeah like @joreyesl said make your changes work with the ranges
if you do that it will ignore the spaces too
Michael Davis
@mdavis93
Jan 30 2017 05:51
Out of curiosity, how do I turn off Notifications? The 'Notification' link in the menu doesn't do anything in the app nor the site..
Chase
@Athabasco
Jan 30 2017 05:51
@joreyesl @HeebieGeeBee Thanks a lot! Just got it working.
CamperBot
@camperbot
Jan 30 2017 05:51
athabasco sends brownie points to @joreyesl and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:warning: athabasco already gave heebiegeebee points
:cookie: 397 | @joreyesl |http://www.freecodecamp.com/joreyesl
c0d0er
@c0d0er
Jan 30 2017 05:51
@walidashri thanks!
CamperBot
@camperbot
Jan 30 2017 05:51
c0d0er sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 864 | @walidashri |http://www.freecodecamp.com/walidashri
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:52
it will @mdavis93 put it on mute:notify me only when mentioned
Jor
@joreyesl
Jan 30 2017 05:52
@mdavis93 click on room settings, then notifications
Michael Davis
@mdavis93
Jan 30 2017 05:53
I did.. nothing happens when I go to "Room Settings" and "Notification". "Share Chatroom", "Archives", etc work.. but "Notifications" doesn't
Jor
@joreyesl
Jan 30 2017 05:53
@mdavis93 yea i just tried it, must be bug on their end. Not opening the notifications options
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:54
working for me
Michael Davis
@mdavis93
Jan 30 2017 05:54
O.o
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:55
what browser are you two using?
Michael Davis
@mdavis93
Jan 30 2017 05:55
FF
FireFox
Jor
@joreyesl
Jan 30 2017 05:55
same FF
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:55
well thats your first mistake
Jor
@joreyesl
Jan 30 2017 05:55
lol
Michael Davis
@mdavis93
Jan 30 2017 05:55
It also wasn't working for me in the Desktop App though, so I can't say it's a browser issue
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:56
yeah dunno
Jor
@joreyesl
Jan 30 2017 05:56
Its worked before, Ive got my settings changed when I first joined
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:57
can you not change settings in the actual browser settings
Michael Davis
@mdavis93
Jan 30 2017 05:57
Same here. I changed the settings for the main room to notify me only when I'm mentioned
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:57
in permissions or anything
until the get the bug sorted
Michael Davis
@mdavis93
Jan 30 2017 05:58
The only problem I see with that is being notified if you're mentioned.. if you mute it via system, then it's muted completely
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:58
yeah
Michael Davis
@mdavis93
Jan 30 2017 05:59
It's okay. I'll just jump in-and-out of the help room until it gets sorted out. I'm patient.
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 05:59
its just if the constant popups were really bothering you
ive been kinda making my brain hurt learning about making game engines in javascript
and im starting to wonder if i should just use these game makers instead and make life easy for myself
it just seems bad to take the easy way out
Jor
@joreyesl
Jan 30 2017 06:04
@HeebieGeeBee i guess it depends, if want to focus on making games, then using an engine would be better. But making your own engine would be a good learning experince I would think
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 06:04
yeah
i know it is and i will, just venting a little lol
Jor
@joreyesl
Jan 30 2017 06:05
hehe alright
HeebieGeeBee
@HeebieGeeBee
Jan 30 2017 06:05