These are chat archives for FreeCodeCamp/HelpJavaScript

8th
Jan 2017
Gavriloski
@Gavriloski
Jan 08 2017 00:01 UTC
What is best way to do this? You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols)
Youssef Karami
@netchester
Jan 08 2017 00:01 UTC
Can someone tell me what's wrong with this code plz

var count = "";

function cc(card) {
  // Only change code below this line
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      card = "5 Bet";
      break;
    case 7:
    case 8:
    case 9:
      card = "0 Hold";
      break;
    case 10:
    case "j":
    case "q":
    case "k":
    case "a":
      card = "-5 Hold";
      break;
    case 3:
    case 7:
    case "q":
    case 8:
    case "a":
      card = "-1 Hold";
      break;
    case 2:
    case "j":
    case 9:
    case 2:
    case 7:
      card = "1 Bet";
      break;
    case 2:
    case 2:
    case 10:
      card = "1 Bet";
      break;
    case 3:
    case 2:
    case "a":
    case 10:
    case "k":
      card = "-1 Hold";
      break;
  }

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7);
Matteo "Betz" Bersan
@beers01
Jan 08 2017 00:02 UTC

@Chrono79 ah! Ok, tnx! So

 processed = processArg(7);

(7) is the argument

John Paul Penaloza
@johnpyp
Jan 08 2017 00:02 UTC
@cjljohnson Ok. I could also push all the params into an array and print that, correct?
Diego Mayer
@Chrono79
Jan 08 2017 00:02 UTC
yes, exactly @beers01
Jamie Lipschitz
@Jlipschitz
Jan 08 2017 00:02 UTC
@johnpyp you can use console.log(json) to see structure of the object as @cjljohnson mentioned by hitting f12 in your browser. You'll the have to traverse down like json.coordinate.latitude and etc
cjljohnson
@cjljohnson
Jan 08 2017 00:02 UTC
@cesarecaravaggio you use switch cases when you have a lot of options to choose from. It's more compact than writing a million if else statements
Matteo "Betz" Bersan
@beers01
Jan 08 2017 00:03 UTC
@Chrono79 damn english :D i'm learning to languages at same time :O
Diego Mayer
@Chrono79
Jan 08 2017 00:03 UTC
@netchester you need to change count value in your switch, not card value and you have a lot of values more than needed in the cases
Also note that "a" isn't the same as "A", capitalization matters
Gavriloski
@Gavriloski
Jan 08 2017 00:04 UTC
@netchester I think you need to check for single char 'k' 'a' ... etc not for String "a" , etc ...
babajide odusola
@cesarecaravaggio
Jan 08 2017 00:04 UTC
@cjljohnson but wouldnt you still have to write a million case statements if you still wanted to have a lot of options to choose from?
cjljohnson
@cjljohnson
Jan 08 2017 00:05 UTC
@cesarecaravaggio yes but writing cases is more compact
Gavriloski
@Gavriloski
Jan 08 2017 00:05 UTC
What is best way to do this: You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) ?
Diego Mayer
@Chrono79
Jan 08 2017 00:05 UTC
@Gavriloski what's the difference between 'a' and "a"?, they're both strings with length = 1
Gavriloski
@Gavriloski
Jan 08 2017 00:05 UTC
@Chrono79 No "A" is threated like string 'A' like single char
babajide odusola
@cesarecaravaggio
Jan 08 2017 00:06 UTC
@cjljohnson got you. ty for clearing that up
CamperBot
@camperbot
Jan 08 2017 00:06 UTC
cesarecaravaggio sends brownie points to @cjljohnson :sparkles: :thumbsup: :sparkles:
:cookie: 269 | @cjljohnson |http://www.freecodecamp.com/cjljohnson
Diego Mayer
@Chrono79
Jan 08 2017 00:07 UTC
@Gavriloski so "AB" and 'AB' are different?
Jamie Lipschitz
@Jlipschitz
Jan 08 2017 00:08 UTC
@Gavriloski they are both treated as strings despite single or double
Gavriloski
@Gavriloski
Jan 08 2017 00:08 UTC
@Chrono79 Because it's javascript. I was thinking in java or c++ or something more "strict"
Diego Mayer
@Chrono79
Jan 08 2017 00:08 UTC
@Jlipschitz That's what I think, there is no char type in javascript
@Gavriloski Ok, now it makes sense :+1:
Gavriloski
@Gavriloski
Jan 08 2017 00:10 UTC
@Chrono79 My fault , not intending to confuse
Diego Mayer
@Chrono79
Jan 08 2017 00:10 UTC
no problem, it was cleared at the end :+1: And it's always good to know a little about another language too
Gavriloski
@Gavriloski
Jan 08 2017 00:14 UTC
That is way to differentiate char from string in those langs that have Char type
Just single quote
Mike
@MikeJSchorah
Jan 08 2017 00:15 UTC
I just have ONE QUESTION today. Someone please answer it.
Please
Please
Please
Jamie Lipschitz
@Jlipschitz
Jan 08 2017 00:16 UTC
shoot
Mike
@MikeJSchorah
Jan 08 2017 00:17 UTC
@Jlipschitz Actually, I need an answer from someone that knows a lot about this stuff. How far are you in the program? (That's not my question)
FlawlessXD
@FlawlessXD
Jan 08 2017 00:19 UTC
I have two questions about the Front-End certificate. On average, how many hours does it take to attain the certificate? and are you able to change the name, that appears on the certificate?
Tyler Collins
@tjscollins
Jan 08 2017 00:19 UTC
@MikeJSchorah Don't be coy. Just ask the question.
Benjamin-Coleman
@Benjamin-Coleman
Jan 08 2017 00:19 UTC
Hey I'm looking for basically just a little hint to get me unstuck on the 'Title Case a Sentence' problem. I figure the general process is going to be
  • Convert string to array of 1 word each
  • Change the first letter in each array items
  • Join the array into a string again
Mike
@MikeJSchorah
Jan 08 2017 00:20 UTC
@tjscollins Sure. Here is the question...
Benjamin-Coleman
@Benjamin-Coleman
Jan 08 2017 00:20 UTC
but I can't figure out how to do the change first letter in each array item. I've been trying with array.map and array.forEach but I don't understand them enough to know if that's the best way to go about it
Tyler Collins
@tjscollins
Jan 08 2017 00:20 UTC
@Benjamin-Coleman Yes, but you need a special case for words like a and the
Or skim it or understand what it is implying
emr53f
@emr53f
Jan 08 2017 00:22 UTC

Hi! I'm having issues with the palindrome challenge. My code works for every example except "palindrome("almostomla")"

function palindrome(str) {
  var reverseArray = [];
  var straightArray = [];
  str = str.toLowerCase().replace(/[^a-zA-Z ]/g, "");
  straightArray = str.split("");
  reverseArray = str.split("").reverse();
  for (var i = 0; i < reverseArray.length; i++){
    if(straightArray[i] != reverseArray[i]){
      return false;
    }
   else{
     return true;
   } 
  }

}

I don't understand where it doesn't work ... straightArray[5] != reverseArray[5] (one's an s, one's a t), but the code still fails. any hints? thank you!

Tyler Collins
@tjscollins
Jan 08 2017 00:22 UTC

@Benjamin-Coleman try something like

var letters = word.split('');

and then uppercase letters[0]. Then rejoin each word (word = letters.join()) and then rejoin the whole sentence

@Benjamin-Coleman Just don't forget the special cases for words === 'a' or word === 'the', etc.
Gavriloski
@Gavriloski
Jan 08 2017 00:23 UTC

@emr53f Maybe you could try something like this : function palindrome(str) {
var test = true;
var n = str.length;

return str;

for(var i = 0; i <= Math.floor(n/2); i++){
if(str[i].toLowerCase() != str[n - 1 -i].toLowerCase()){
test = false;
break;
}
}

return test;
}

Mike
@MikeJSchorah
Jan 08 2017 00:23 UTC
Has anyone looked at that article?
Tyler Collins
@tjscollins
Jan 08 2017 00:23 UTC
@MikeJSchorah ...and the question is...?
Mike
@MikeJSchorah
Jan 08 2017 00:24 UTC
@tjscollins Is it true?
emr53f
@emr53f
Jan 08 2017 00:26 UTC
@Gavriloski thank you! is the -1 in there because arrays start at 0? (called zero notation i think?)
CamperBot
@camperbot
Jan 08 2017 00:26 UTC
emr53f sends brownie points to @gavriloski :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for gavriloski
Tyler Collins
@tjscollins
Jan 08 2017 00:27 UTC

@MikeJSchorah Is what true? There's no single 'it' statement in that 'article'. It's not even an article. It's a thread of different responses.

Do developers copy code? In some contexts--there's only one way to write

i++;

And if you had to look it up because you didn't know it off the top of your head, you'd have to 'copy' the answer. Because there is only one answer for simple stuff like that. Do they copy their own code? If they're smart they're always trying to reuse code.

Mike
@MikeJSchorah
Jan 08 2017 00:28 UTC
@tjscollins So developers, even ones that have been working for a long time, still reuse code? They don't code from scratch!
Gavriloski
@Gavriloski
Jan 08 2017 00:28 UTC
@emr53f -1 there is because: You want to have last one and last one, had index of array.length - 1
Tyler Collins
@tjscollins
Jan 08 2017 00:28 UTC
@MikeJSchorah Yes. No one reinvents the wheel just because they can. There's no point to doing so.
Gavriloski
@Gavriloski
Jan 08 2017 00:29 UTC
@emr53f Can you send me full working code for palindrome I am stuck at replace it doesn't work :/
Tyler Collins
@tjscollins
Jan 08 2017 00:29 UTC
@MikeJSchorah If you've already done it once, reuse it. Doing it over just because you can is a waste of time (unless you can substantially improve it, but that's another issue)
emr53f
@emr53f
Jan 08 2017 00:30 UTC
@Gavriloski the code I pasted above works for every instance but "almostomla"
Gavriloski
@Gavriloski
Jan 08 2017 00:30 UTC
@emr53f it refuses to do replace for me idk why console in chrome is doing it fine, gonna try to refresh whole thing
John Paul Penaloza
@johnpyp
Jan 08 2017 00:31 UTC
@cjljohnson @Jlipschitz thanks for the help
CamperBot
@camperbot
Jan 08 2017 00:31 UTC
johnpyp sends brownie points to @cjljohnson and @jlipschitz :sparkles: :thumbsup: :sparkles:
:cookie: 270 | @cjljohnson |http://www.freecodecamp.com/cjljohnson
:cookie: 215 | @jlipschitz |http://www.freecodecamp.com/jlipschitz
JMNofziger
@JMNofziger
Jan 08 2017 00:31 UTC
Could you guys tell me how to make my solution more concise? This works but I want it to be cleaner/simpler.
// Return true if the string in the first element 
// of the array contains all of the letters of the string 
// in the second element of the array.

function mutation(arr) {

  // first make it all lowercase
  arr = arr.map(function(x){
    return x.toLowerCase();
  });

  // continue looping until # of loops matches length of the second string
  // each loop will inspect another one of the second strings characters
  for(var i = 0; i < arr[1].length; i++){
    if (arr[0].indexOf(arr[1][i]) !== -1){
      continue;
    }
    else{
      return false;
    }
  }
  return true;
}

mutation(["Hello", "hEy"]);
simonekj
@simonekj
Jan 08 2017 00:31 UTC
I'm working on profile lookup. All of my hasOwnProperty things keep returning false and idk why

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

function lookUpProfile(firstName, prop){
// Only change code below this line
if (contacts.hasOwnProperty[firstName] === true)
return contacts[firstName];
else return "No such contact";
if (contacts.hasOwnProperty(prop) === true)
return contacts[prop];
else return "No such property";
// Only change code above this line
}

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

Mike
@MikeJSchorah
Jan 08 2017 00:31 UTC
@tjscollins Ok. So, you've never used someone else's code and modified it? This means that you're basically writing from scratch (and I'm assuming that you're far in the program). So, that article or thread or whatever you want to call it is a complete fabrication?
JMNofziger
@JMNofziger
Jan 08 2017 00:34 UTC
@simonekj I think you might be referencing the parameters wrong. The values that are being passed in your test input are "Akira" and "likes"
cjljohnson
@cjljohnson
Jan 08 2017 00:34 UTC
@MikeJSchorah the FCC stuff is the simplest shit imaginable. yes, some people can complete it without looking stuff up
Gavriloski
@Gavriloski
Jan 08 2017 00:34 UTC

@emr53f function palindrome(str) {
var test = true;
var n = str.length;

for(var i = 0; i <= Math.floor(n/2); i++){
if(str[i].toLowerCase() != str[n - 1 -i].toLowerCase()){
test = false;
break;
}
}

return test;
}

@emr53f This one is fully working you just need to add replace to avoid non-alpha
Mike
@MikeJSchorah
Jan 08 2017 00:34 UTC
@cjljohnson I haven't seen most of the algorithm challenges anywhere else. You must have had a great deal of experience before you came here
I went through the beginning of FCC, Codecademy, W3Schools, and 4 JavaScript books. The first time that I saw any of the algorithm challenges were when I first did the algorithm challenges
Diego Mayer
@Chrono79
Jan 08 2017 00:36 UTC
@simonekj contacts is an array, you need to use a loop to access a single contact
emr53f
@emr53f
Jan 08 2017 00:36 UTC
hmm @Gavriloski I originally had a few extra filler variables/arrays but condensed it into one line
function palindrome(str) {
  var reverseArray = [];
  var straightArray = [];
  var fillerArray = [];
  str = str.toLowerCase();
  str = str.replace(/[^a-zA-Z ]/g, "");
  straightArray = str.split("");
  fillerArray = str.split("");
  reverseArray = fillerArray.reverse();
  for (var i = 0; i < reverseArray.length; i++){
    if(straightArray[i] != reverseArray[i]){
      return false;
    }
   else{
     return true;
   } 
  }

}
@MikeJSchorah regardless of whether programmers with experience reuse code, what are you getting at? why does it matter to you? genuinely curious.
simonekj
@simonekj
Jan 08 2017 00:37 UTC
ty @Chrono79
CamperBot
@camperbot
Jan 08 2017 00:37 UTC
simonekj sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3079 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jan 08 2017 00:37 UTC
@emr53f you need to also keep numbers
emr53f
@emr53f
Jan 08 2017 00:38 UTC
@Chrono79 this seemingly works with the examples that have numbers
Diego Mayer
@Chrono79
Jan 08 2017 00:39 UTC
@emr53f are you sure? str = str.replace(/[^a-zA-Z ]/g, "");that regex deletes them and you're keeping space like that
Gavriloski
@Gavriloski
Jan 08 2017 00:40 UTC
@Chrono79 How to avoid lowercase for numbers ?
Jamie Lipschitz
@Jlipschitz
Jan 08 2017 00:40 UTC
It's quite common for developers to copy code, there's nothing wrong with that. That's a double edged sword though because you want to be fast and efficient and copying will help that but not if you don't understand what you are copying. Especially when you have to troubleshoot something you've run into @MikeJSchorah
Diego Mayer
@Chrono79
Jan 08 2017 00:41 UTC
@Gavriloski didn't understand, could you elaborate that question a little more?
emr53f
@emr53f
Jan 08 2017 00:41 UTC
@Chrono79 it's passing the challenge, but you're right, it "shouldn't" work. hmmmmmmmmmmmmmm
cjljohnson
@cjljohnson
Jan 08 2017 00:41 UTC
@Gavriloski numbers don't have a lower case?
Mike
@MikeJSchorah
Jan 08 2017 00:41 UTC
@emr53f For the last 6 months, I thought that, in order to code, you needed to code from scratch. No one told me this. I don't understand why it has been a big secret. Sure, if you've either been a developer for years or have frequented this chatroom daily for quite some time, every problem will come easy to you. But, like I have read elsewhere, you can't pass FCC using just material learned only on FCC. You need to use other resources. Not sure why people like to keep it hidden, but if I would have known this fact, I would have completed this course months ago and not decided to apply for a boot camp, which was a waste of time
Gavriloski
@Gavriloski
Jan 08 2017 00:42 UTC
@Chrono79 Nevermind I fucked something else
Diego Mayer
@Chrono79
Jan 08 2017 00:42 UTC
ok then :P
Gavriloski
@Gavriloski
Jan 08 2017 00:42 UTC
@Chrono79 thanks anyway
CamperBot
@camperbot
Jan 08 2017 00:42 UTC
gavriloski sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3080 | @chrono79 |http://www.freecodecamp.com/chrono79
Mike
@MikeJSchorah
Jan 08 2017 00:42 UTC
EXACTLY. I wish I had known that crucial piece of information last summer. I wouldn't have gotten so discouraged. Thank you @Jlipschitz
CamperBot
@camperbot
Jan 08 2017 00:42 UTC
mikejschorah sends brownie points to @jlipschitz :sparkles: :thumbsup: :sparkles:
:cookie: 216 | @jlipschitz |http://www.freecodecamp.com/jlipschitz
emr53f
@emr53f
Jan 08 2017 00:43 UTC
@MikeJSchorah ahh, i see, sorry about the waste of time :/ i think this goes back to what @Jlipschitz says, when you're learning, it's probably best not to c/p code so that you truly do understand the basics
Gavriloski
@Gavriloski
Jan 08 2017 00:43 UTC
Btw when I copy paste code here how to format it in that nice window ?
Diego Mayer
@Chrono79
Jan 08 2017 00:43 UTC
Click on more info below
CamperBot
@camperbot
Jan 08 2017 00:43 UTC
:bulb: to format code use backticks! ``` more info
emr53f
@emr53f
Jan 08 2017 00:44 UTC
@Gavriloski backticks are above the tab button (next to 1) on the QWERTY keyboard. or maybe just American keyboards.
Gavriloski
@Gavriloski
Jan 08 2017 00:44 UTC
@emr53f yea I know thanks
CamperBot
@camperbot
Jan 08 2017 00:44 UTC
gavriloski sends brownie points to @emr53f :sparkles: :thumbsup: :sparkles:
:cookie: 242 | @emr53f |http://www.freecodecamp.com/emr53f
Diego Mayer
@Chrono79
Jan 08 2017 00:45 UTC
@emr53f yes, different keyboard layouts have it in different places, in spanish keyboards it's next to the p
emr53f
@emr53f
Jan 08 2017 00:46 UTC
@Chrono79 any idea why palindrome("almostomla") doesn't work in my example? and noted on the keyboards!
Jamie Lipschitz
@Jlipschitz
Jan 08 2017 00:47 UTC
@MikeJSchorah I would definitely not advise in favor of copying code to complete a challenge on FCC so I think it's fine that you went that route. You certainly could of just seen the result and studied that but copying to just complete a challenge wouldn't of helped you as much. What bootcamp did you go to?
Diego Mayer
@Chrono79
Jan 08 2017 00:47 UTC
@emr53f is your code exactly the same as before?
emr53f
@emr53f
Jan 08 2017 00:47 UTC
function palindrome(str) {
  var reverseArray = [];
  var straightArray = [];
  var fillerArray = [];
  str = str.toLowerCase();
  str = str.replace(/[&\/\\#,+()$~%.'"_:*?<>{}]/g,"");
  straightArray = str.split("");
  fillerArray = str.split("");
  reverseArray = fillerArray.reverse();
  for (var i = 0; i < reverseArray.length; i++){
    if(straightArray[i] != reverseArray[i]){
      return false;
    }
   else{
     return true;
   } 
  }

}
@Chrono79 changed the regex to not include numbers!
Diego Mayer
@Chrono79
Jan 08 2017 00:48 UTC
@emr53f your loop only runs once, comparing only the first letter
andercodder
@andercodder
Jan 08 2017 00:48 UTC
guys
emr53f
@emr53f
Jan 08 2017 00:49 UTC
@Chrono79 wait it doesn't loop until straightarray[i] doesnt match reversearray[i]?
Mike
@MikeJSchorah
Jan 08 2017 00:49 UTC
@emr53f Yes. Even if I do copy the code, I try to understand it as best as possible. I don't just "copy, paste, and then on to the next challenge." I just didn't have a clue that is how development worked. This field is so convoluted that it takes some in depth research or a mentor/contact to really understand things. If I had known 2 years ago what I know now, I probably would have been employed a year ago, doing this and actually learning more efficiently and not trying to memorize. For the last 2 years, I thought it was all about memorization... and to a degree, a lot does seem to need to be memorized. But, as that article pointed out... "THE MOST IMPORTANT SKILL THAT ANY DEVELOPER HAS IS THE ABILITY TO RESEARCH AND QUICKLY AND FIND ANSWERS TO QUESTIONS ON THE INTERNET." Thanks for the input @emr53f . It is all clear now... :]
CamperBot
@camperbot
Jan 08 2017 00:49 UTC
mikejschorah sends brownie points to @emr53f :sparkles: :thumbsup: :sparkles:
:cookie: 243 | @emr53f |http://www.freecodecamp.com/emr53f
Diego Mayer
@Chrono79
Jan 08 2017 00:49 UTC
@emr53f no, you have an if/else inside the loop and both return
Return exits the loop and the function
Jamie Lipschitz
@Jlipschitz
Jan 08 2017 00:51 UTC
@MikeJSchorah that's a good outlook to have :+1:
andercodder
@andercodder
Jan 08 2017 00:51 UTC

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

return item; // Change this line
}

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

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

please someone just explain me

Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

Run tests (ctrl + enter)

emr53f
@emr53f
Jan 08 2017 00:52 UTC
@Chrono79 thank you!! really appreciate it.
CamperBot
@camperbot
Jan 08 2017 00:52 UTC
:star2: 3081 | @chrono79 |http://www.freecodecamp.com/chrono79
emr53f sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Mike
@MikeJSchorah
Jan 08 2017 00:52 UTC
@Jlipschitz I didn't go to one. I made it to the final rounds and decided against it because I didn't know (once again, not knowing crucial information seems to be my downfall) that the 6 month apprenticeship was not guaranteed like they promised in the beginning. I can't afford to spend $10K when I don't need to. I don't need someone to motivate me to code. I've had that motivation for a long time now
Diego Mayer
@Chrono79
Jan 08 2017 00:54 UTC
@emr53f instead of all those non alphanumeric chars, you could have added the numbers to your previous regex, like this: /[^a-z0-9]/gi a lot shorter and safer than listing like you did (the non alphanum. chars are a lot to list)
andercodder
@andercodder
Jan 08 2017 00:54 UTC
ok mike
Mike
@MikeJSchorah
Jan 08 2017 00:55 UTC
@andercodder Did you get a chance to look at the article?
It's ok if you didn't. It's all clear to me now... Thank you everyone
Manish Giri
@Manish-Giri
Jan 08 2017 00:56 UTC
@andercodder what's your question?
andercodder
@andercodder
Jan 08 2017 00:57 UTC
@Manish-Giri Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
i just need an explanation so i can fix
Manish Giri
@Manish-Giri
Jan 08 2017 00:58 UTC
@andercodder okay, your function gets two arguments - arr and item, yes?
arr is an array, itemis a number.
andercodder
@andercodder
Jan 08 2017 00:58 UTC
yes tis this
Manish Giri
@Manish-Giri
Jan 08 2017 00:59 UTC
the first step is to add the number itemto the end of the array arr, use .push() for this.
Sunray
@hisunray
Jan 08 2017 00:59 UTC
hey guys, i need help with Check for Palindromes challenge
Manish Giri
@Manish-Giri
Jan 08 2017 01:00 UTC
the second and final step is to remove and return the first element from the array arr, use .shift()for this.
andercodder
@andercodder
Jan 08 2017 01:00 UTC
it will be like arr[].push(1);
review the syntax
Sunray
@hisunray
Jan 08 2017 01:02 UTC
anyone Check for Palindromes challenge
help! please.
i can't pass the challenge
Yintii
@Yintii
Jan 08 2017 01:03 UTC
I'm trying to do the "Using objects for lookups" thing and it's just all around confusing, I don't know why I'd have to use it like it wants me to, which is only making it harder to understand how to solve it

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

// Only change code below this line
switch(val) {
case "alpha":
result = "Adams";
break;
case "bravo":
result = "Boston";
break;
case "charlie":
result = "Chicago";
break;
case "delta":
result = "Denver";
break;
case "echo":
result = "Easy";
break;
case "foxtrot":
result = "Frank";
}

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

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

It wants me to replace this switch with an object and I don't understand how to implement "result" into the rest of it
Diego Mayer
@Chrono79
Jan 08 2017 01:04 UTC
@Yintii use your object and the function parameter to set result value before returning it
Gavriloski
@Gavriloski
Jan 08 2017 01:04 UTC

@hisunray This is my code fully working for palindrome:
function palindrome(str) {
var test = true;

str = str.replace(/[^A-Za-z0-9]/g, '');
var n = str.length;
for(var i = 0; i <= Math.floor(n/2); i++){
if(str[i].toLowerCase() != str[n - 1 -i].toLowerCase()){
test = false;
break;
}
}

return test;
}

Awcsome
@Awcsome
Jan 08 2017 01:05 UTC
Hi I'm studying basic JS on the page "Return EAlry pattern for functions and I don't know what I'm doing wrong
Diego Mayer
@Chrono79
Jan 08 2017 01:05 UTC
@Gavriloski a few improvements/suggestions
you can apply toLowerCase before the replace, and you don't need A-Z in the regex that way
Awcsome
@Awcsome
Jan 08 2017 01:06 UTC

// Setup
function abTest(a, b) {
// Only change code below this line
if (a | b < 0){
return undefined;
}
// Only change code above this line

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

// Change values below to test your code
abTest(2,2);
the math code line isn't running when I test it

Sunray
@hisunray
Jan 08 2017 01:07 UTC
@Gavriloski could you explain your
str = str.replace(/[^A-Za-z0-9]/g, ''); line. how did you go about the stuff inside the replace function
Jamie Lipschitz
@Jlipschitz
Jan 08 2017 01:07 UTC
@Gavriloski could you provide feedback instead of the answer? that's not really helping him
Awcsome
@Awcsome
Jan 08 2017 01:07 UTC
@Chrono79 thanks I'll have a look now
CamperBot
@camperbot
Jan 08 2017 01:07 UTC
awcsome sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3082 | @chrono79 |http://www.freecodecamp.com/chrono79
Gavriloski
@Gavriloski
Jan 08 2017 01:07 UTC
@hisunray That is called RegEx
Sunray
@hisunray
Jan 08 2017 01:07 UTC

i don't understand that @Gavriloski
here's my code thus far:
function palindrome(str) {
// Good luck!
var normalStr=str.replace().toLowerCase();
var reverseStr=normalStr.split().reverse().join();
return normalStr===reverseStr;
}

palindrome("eye");

Gavriloski
@Gavriloski
Jan 08 2017 01:07 UTC
@hisunray Google it not master of it
Jin Choi
@JiniHendrix
Jan 08 2017 01:08 UTC
hello, i have an input text box that i'm binding an enter event to console.log something. however the page just refreshes and nothing logs.. i tried using preventDefault() to stop the page refresh but it's not doing anything. please help!
Yintii
@Yintii
Jan 08 2017 01:08 UTC

@Chrono79

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

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

result = obj.val;
// Only change code above this line
return result;
}
// Change this value to test
phoneticLookup("charlie");

Gavriloski
@Gavriloski
Jan 08 2017 01:08 UTC
@Chrono79 So you are saying I can just apply tolowercase on whole string?
Diego Mayer
@Chrono79
Jan 08 2017 01:08 UTC
@Gavriloski yes
Yintii
@Yintii
Jan 08 2017 01:08 UTC
I'm not quite getting itt
Awcsome
@Awcsome
Jan 08 2017 01:09 UTC
@Chrono79 The problem is that it's not running the code that I'm not supposed to change
Diego Mayer
@Chrono79
Jan 08 2017 01:10 UTC
@Awcsome if (a | b < 0){ <- that's not right, see how you write 2 conditions joined with logical or operator in the challenge I told you
Sunray
@hisunray
Jan 08 2017 01:10 UTC
@Gavriloski i got it. thanks mate
CamperBot
@camperbot
Jan 08 2017 01:10 UTC
hisunray sends brownie points to @gavriloski :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for gavriloski
Awcsome
@Awcsome
Jan 08 2017 01:10 UTC
@Chrono79 I've changed it
@Chrono79 but it still doesn't work
Diego Mayer
@Chrono79
Jan 08 2017 01:10 UTC
@Awcsome show me your code now
Awcsome
@Awcsome
Jan 08 2017 01:11 UTC
if (a || b < 0){
return undefined;
}
Diego Mayer
@Chrono79
Jan 08 2017 01:11 UTC
@Awcsome still wrong, the left part evaluates a, given that a is a number, that evaluates as true for any number different than 0
andercodder
@andercodder
Jan 08 2017 01:11 UTC
@Manish-Giri just one more question how shoud be return
Stephen James
@sjames1958gm
Jan 08 2017 01:11 UTC
@Awcsome That is a OR (b < 0) you need < 0 for both variables
Yintii
@Yintii
Jan 08 2017 01:11 UTC
@Chrono79 Got it - Spanks :)
Manish Giri
@Manish-Giri
Jan 08 2017 01:12 UTC
@andercodder you can prefix return to the place where you're using .shift(), that will do remove and return both..
Awcsome
@Awcsome
Jan 08 2017 01:12 UTC
@sjames1958gm do i use a comma?
(a < 0, b<0)?
Yintii
@Yintii
Jan 08 2017 01:12 UTC
@chrono thanks
CamperBot
@camperbot
Jan 08 2017 01:12 UTC
yintii sends brownie points to @chrono :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for chrono
Yintii
@Yintii
Jan 08 2017 01:13 UTC
@Chrono79 thanks I mean damn
CamperBot
@camperbot
Jan 08 2017 01:13 UTC
yintii sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3083 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jan 08 2017 01:13 UTC
:+1:
Jamie Lipschitz
@Jlipschitz
Jan 08 2017 01:13 UTC
function palindrome(str) {
 //use the regex expression to remove spaces, non-aplhanumeric and null to change the original string, as well as use toLowerCase to ignore casing
  str = str.replace(/[\W_]/g, "").toLowerCase(); // /[\W_]/ this the part of the regex that does the search and /g just ensures it's globally replaced

  //compare string when it's revered
  return str === str.split('').reverse().join('');
}
palindrome("eye");
@hisunray
andercodder
@andercodder
Jan 08 2017 01:13 UTC

@Manish-Giri my code now is like that function nextInLine(arr, item) {
// Your code here
arr = [];
item = 1;

return arr.push(item); // Change this line
}

Sunray
@hisunray
Jan 08 2017 01:13 UTC
thanks much @Jlipschitz
CamperBot
@camperbot
Jan 08 2017 01:13 UTC
hisunray sends brownie points to @jlipschitz :sparkles: :thumbsup: :sparkles:
:cookie: 217 | @jlipschitz |http://www.freecodecamp.com/jlipschitz
Manish Giri
@Manish-Giri
Jan 08 2017 01:14 UTC
@andercodder what is the purpose of this?
arr = [];
item = 1;
andercodder
@andercodder
Jan 08 2017 01:15 UTC
is not this the first line it ask me to do ?
Manish Giri
@Manish-Giri
Jan 08 2017 01:15 UTC
no
Oranjoose
@Oranjoose
Jan 08 2017 01:15 UTC
Can others see my progress if they have the link to my profile?
andercodder
@andercodder
Jan 08 2017 01:16 UTC
ok
then i should first do that arr.push(item);
Oranjoose
@Oranjoose
Jan 08 2017 01:17 UTC
It seems like all my public profile shows is when I was working, not what I've accomplished
Manish Giri
@Manish-Giri
Jan 08 2017 01:17 UTC
yes
simonekj
@simonekj
Jan 08 2017 01:18 UTC
Can someone help me with profile lookup. When I run hasOwnProperty, they always come back first and when I tried to run a for loop, it won't return the "firstName" value

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

function lookUpProfile(firstName, prop){
// Only change code below this line
for (contacts[0]; contacts.length; contacts[0]) {
return contacts.firstName;
}
if (contacts.hasOwnProperty[firstName] === true)
return contacts.firstName;
else return "No such contact";
if (contacts.hasOwnProperty(prop) === true)
return contacts[prop];
else return "No such property";
// Only change code above this line

}

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

andercodder
@andercodder
Jan 08 2017 01:19 UTC

@Manish-Giri
function nextInLine(arr, item) {
// Your code here
arr.push(item);
arr.shift(item);

return item; // Change this line
}

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

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

Stephen James
@sjames1958gm
Jan 08 2017 01:20 UTC
@simonekj You need to fix your for loop.
@andercodder Return the value from arr.shift() - shift doesnt take a paramter
Manish Giri
@Manish-Giri
Jan 08 2017 01:20 UTC
@andercodder .shift() doesn't take any parameters, it should just be .shift()
and you need to return what you get back from using .shift(), you're still returning item.
Stephen James
@sjames1958gm
Jan 08 2017 01:21 UTC
@simonekj Review challenges on how to loop over an array with a for loop
@JiniHendrix What are you trying to do with the call to the trigger function?
andercodder
@andercodder
Jan 08 2017 01:23 UTC
@Manish-Giri @sjames1958gm very great thank you i saw my error but thank to you i could understand...thanks not just for explain me but for your patient i know it can be borried teach someone like me but very thank you
CamperBot
@camperbot
Jan 08 2017 01:23 UTC
:star2: 5214 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 3613 | @manish-giri |http://www.freecodecamp.com/manish-giri
andercodder sends brownie points to @manish-giri and @sjames1958gm :sparkles: :thumbsup: :sparkles:
Manish Giri
@Manish-Giri
Jan 08 2017 01:24 UTC
@andercodder welcome, happy coding :tada:
Stephen James
@sjames1958gm
Jan 08 2017 01:24 UTC
@andercodder :+1:
Jin Choi
@JiniHendrix
Jan 08 2017 01:24 UTC
@sjames1958gm hi stephen, i'm ultimately trying to display the input as a comment above the input box. but i'm just trying to debug using console.log for now
Anthony Hayes
@EgoDominusVos
Jan 08 2017 01:25 UTC
Assignment with a Returned Value
```js
Stephen James
@sjames1958gm
Jan 08 2017 01:25 UTC
@JiniHendrix I have to think that the trigger call is causing the refresh
andercodder
@andercodder
Jan 08 2017 01:25 UTC
know i go to sleep
Jin Choi
@JiniHendrix
Jan 08 2017 01:26 UTC
@sjames1958gm yes, I read online that preventDefault() is supposed to stop the refresh, but it's not working unfortunately
Anthony Hayes
@EgoDominusVos
Jan 08 2017 01:27 UTC

Assignment with a Returned Value

// Only change code below this line
var processed = 0;

function processArg(num){
  return (num + 1) /4 ;
}
processed = processArg(7);

with this, we assigned a value of "0" to processed, then changed the var using maths to a new variable? where is this going and how is it useful? (eg. please)

Stephen James
@sjames1958gm
Jan 08 2017 01:27 UTC
@JiniHendrix Prevent default only stops the propagation of the event for the handler being run - you are triggering another event which I think causes the issue.
I am not too familiar with trigger and enterEvent
@EgoDominusVos You are not supposed to redeclared the variable or functoin
Jin Choi
@JiniHendrix
Jan 08 2017 01:29 UTC
@sjames1958gm hmm I see. ill try some different versions
@sjames1958gm thank you
CamperBot
@camperbot
Jan 08 2017 01:30 UTC
jinihendrix sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5215 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Anthony Hayes
@EgoDominusVos
Jan 08 2017 01:30 UTC
@sjames1958gm the challenge REFUSED to let me pass w/o , like an angry troll.
CamperBot
@camperbot
Jan 08 2017 01:30 UTC
:trollface: troll problems? notify admins here
Stephen James
@sjames1958gm
Jan 08 2017 01:30 UTC
@JiniHendrix :+1:
Anthony Hayes
@EgoDominusVos
Jan 08 2017 01:30 UTC
@camperbot LOL ... funny bot
Stephen James
@sjames1958gm
Jan 08 2017 01:31 UTC
@EgoDominusVos YOu should have only had to add one line - processed = processArg(7);
@JiniHendrix Good luck
Anthony Hayes
@EgoDominusVos
Jan 08 2017 01:31 UTC
@sjames1958gm let me try ... just a sec
Having a little trouble
Tariq
@beyallluv
Jan 08 2017 01:34 UTC
Hi. Having problems with Escape Sequences in Strings. Stuck on this for two days. Any suggestions?
var myStr = "FirstLine\n\SecondLine\rThirdLine";
Johnny
@JohnnyBizzel
Jan 08 2017 01:34 UTC
@jerryslone TitleCaseOver ....titleCaseOver
Manish Giri
@Manish-Giri
Jan 08 2017 01:34 UTC
@jerryslone follow the camel case notation, as used in the examples on the left
var someVariable;
var anotherVariableName;
var thisVariableNameIsTooLong;
Anthony Hayes
@EgoDominusVos
Jan 08 2017 01:34 UTC
@sjames1958gm well, that was easy. guess they changed things up. In the past we had to write out everything.
uriznik
@uriznik
Jan 08 2017 01:34 UTC
@beyallluv paste what you have between two back quotes `var mystr...`
Johnny
@JohnnyBizzel
Jan 08 2017 01:34 UTC
@jerryslone StUdLyCapVaR = studley Cap Var ???
Diego Mayer
@Chrono79
Jan 08 2017 01:36 UTC
@beyallluv you missed a backslash, the backslashes around SecondLine should be escaped (both of them), you only escaped the one before it
Joseph
@revisualize
Jan 08 2017 01:38 UTC
@Manish-Giri .shift() doesn't take any arguments. Parameters are in the function declaration. cc: @andercodder
@simonekj Have you fixed Profile Lookup?
Tariq
@beyallluv
Jan 08 2017 01:39 UTC
var myStr = "FirstLine\n\SecondLine\rThirdLine";
Manish Giri
@Manish-Giri
Jan 08 2017 01:39 UTC
whatever.
Joseph
@revisualize
Jan 08 2017 01:39 UTC
@beyallluv You're not escaping the second backslash.
Diego Mayer
@Chrono79
Jan 08 2017 01:39 UTC
var myStr = "FirstLine \n \\ SecondLine \ \r ThirdLine"; <- see? @beyallluv (I've added spaces to make it more evident, don't add the spaces)
Joseph
@revisualize
Jan 08 2017 01:40 UTC
@beyallluv You're missing a \ to escape the second \
Tariq
@beyallluv
Jan 08 2017 01:40 UTC
Thats what I have not passing though.
Diego Mayer
@Chrono79
Jan 08 2017 01:41 UTC
@beyallluv we know, and we're telling you how to fix it
Manish Giri
@Manish-Giri
Jan 08 2017 01:41 UTC
@beyallluv the \ needs to be escaped too..
alican karalar
@alicankaralar
Jan 08 2017 01:43 UTC
HELLOOO
I NEED HELP AGAIN

function lookUpProfile(firstName, prop){
// Only change code below this line
if (contacts.hasOwnProperty(firstName)) {

if (contacts.hasOwnProperty(prop)) {

 return prop;

}
return "No such property";
}
return "No such contact";
// Only change code above this line
}

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

Diego Mayer
@Chrono79
Jan 08 2017 01:44 UTC
@alicankaralar contacts is an array, you need a loop to access a single contact (at least in this challenge)
alican karalar
@alicankaralar
Jan 08 2017 01:44 UTC
ohh
okay
wait
now i get it
i hope
simonekj
@simonekj
Jan 08 2017 01:46 UTC
@revisualize no. I'm still messing with it.
Joseph
@revisualize
Jan 08 2017 01:49 UTC
@alicankaralar You're not looping through the array elements?
@alicankaralar We have an array of objects representing different people in our contacts lists.
Example: var contacts = [ { ... } , { ... } , { ... } , { ... } ];
@simonekj --^ as well.
aaldea
@aaldea
Jan 08 2017 01:51 UTC
Good eening. I was hopping I could get some help with the weather app. I cannot seem to get the background image to change. I even followed some videos and still now working. Could anyone please help?
alican karalar
@alicankaralar
Jan 08 2017 01:52 UTC

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

for (var a = 0 ; a < contacts.length ; a++ ) {

if (contacts[a].hasOwnProperty(firstName)) {

  if (contacts[a].hasOwnProperty(prop)) {

    return prop;
  }

  return "No such property";
}

return "No such Contact";

}
// Only change code above this line
}

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

i tried looping but no good
:(
Diego Mayer
@Chrono79
Jan 08 2017 01:53 UTC
@alicankaralar no contact has a property named with the string contained in firstName
For instance, in that call, firstName contains "Akira", and there is no property named "Akira"
aaldea
@aaldea
Jan 08 2017 01:53 UTC
Or at least it is taking a really long time.
alican karalar
@alicankaralar
Jan 08 2017 01:54 UTC
hm
Diego Mayer
@Chrono79
Jan 08 2017 01:56 UTC
@alicankaralar you should match the property firstName of the current contact against the funcion param firstName instead
alican karalar
@alicankaralar
Jan 08 2017 01:56 UTC
AAAARRRRG
my brain hurts
i don't see how can i check if "akira" is true
Diego Mayer
@Chrono79
Jan 08 2017 02:01 UTC
@alicankaralar it's not if "Akira" is true, access the property firstName of the contact and compare it to firstName
In plain english, is "Akira" the current contact first name?
Lyddip
@lydiayhuang
Jan 08 2017 02:02 UTC
hi guys I have a question
alican karalar
@alicankaralar
Jan 08 2017 02:03 UTC
i did that but improperly i guess
Lyddip
@lydiayhuang
Jan 08 2017 02:03 UTC
for this function I have to multiply without using the operator

function multiply(num1, num2) {

var n = num1;

for(var i = 1; i < num2; i++){
num1 += n; // increments itself
}
return num1;
}

var output = multiply(4, 7);
console.log(output); // --> 28

alican karalar
@alicankaralar
Jan 08 2017 02:03 UTC

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

for (var a = 0 ; a < contacts.length ; a++ ) {

if (firstName==contacts[a]["firstName"]) {

  if (contacts[a].firstName.hasOwnProperty(prop)) {

    return prop;
  }

  return "No such property";
}

return "No such contact";

}
// Only change code above this line
}

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

Lyddip
@lydiayhuang
Jan 08 2017 02:04 UTC
and I get back the right answer but
I have an issue with one of the numbers being 0 or a negative
can someone help me with this?
Yoofee
@y00fee
Jan 08 2017 02:04 UTC
hey there, i'm stuck on lesson 132 - finding a remainder in javascript.
my code is wrong somewhere:
var remainder;
11 % 3 = 2;
key answers: value of remainder should be 2 and use the % operator.. i'm not getting a green light for anything >__<;
Manuel Almeida
@netstudenton
Jan 08 2017 02:05 UTC
guys i'm getting trouble to make my variable global. I can't get de content of latitude and longitude inside the jQuery block
  //longitude and latitude
 var latitude = 0;
 var longitude = 0;

  var myLocation = function () {
    navigator.geolocation.getCurrentPosition(function (position) {
        latitude = position.coords.latitude;
        longitude = position.coords.longitude;
 //    console.log(latitude+","+longitude);
    });
};

jQuery(document).ready(function (){


  myLocation();

  //console.log(latitude+","+longitude);

       $.ajax({
    url: "https://api.wunderground.com/api/7a20b8427beda7c6/geolookup/q/37.776289,-122.395234.json"
,
    dataType: "jsonp", 
    success: function (parsed_json) {
        var location = parsed_json['location']['city'];
        //var temp_f = parsed_json['current_observation']['temp_f'];
      console.log("is working....");
        console.log("Current temperature in " + location + " is: ");
        //$("div").append(longitude + "," + latitude);
    }
});
});
Stephen James
@sjames1958gm
Jan 08 2017 02:05 UTC
@lydiayhuang You may need to test for those cases.
Diego Mayer
@Chrono79
Jan 08 2017 02:05 UTC
@alicankaralar you have to return something different than prop, read that part of the instructions again
Stephen James
@sjames1958gm
Jan 08 2017 02:06 UTC
@y00fee YOu need to assign to remainder variable the operation of taking the remainder then remainder will have value of 2
Lyddip
@lydiayhuang
Jan 08 2017 02:06 UTC
@sjames1958gm I feel like I just need to write 2 if statements
Stephen James
@sjames1958gm
Jan 08 2017 02:06 UTC
@lydiayhuang two if and then else. Maybe depends how you calculate
@netstudenton getCurrentPosition is asyncronous, so when the $.ajax runs the callback fro getCurrentPosition hasn't run
Manuel Almeida
@netstudenton
Jan 08 2017 02:07 UTC
@y00fee
var remainder ;
remainder = 11 % 3;
@sjames1958gm how do I resolve that please ?
Stephen James
@sjames1958gm
Jan 08 2017 02:08 UTC
@netstudenton I think you have to make it one line for the test to pass
Lyddip
@lydiayhuang
Jan 08 2017 02:08 UTC
@sjames1958gm ok this is what I have

function multiply(num1, num2) {
if(num2 === 0) {
return 0;
}
if(num2 < 0) {
num2 = num2;
}
var n = num1;

for(var i = 1; i < num2; i++){
num1 += n; // increments itself
}
return num1;
}

var output = multiply(4, 7);
console.log(output); // --> 28

@sjames1958gm but the second if statement with num2<0 is not working..
@sjames1958gm how do I change the if(num2 <0) into a positive number?
Yoofee
@y00fee
Jan 08 2017 02:09 UTC
ahh lol, newb mistake thanks @netstudenton @sjames1958gm
CamperBot
@camperbot
Jan 08 2017 02:09 UTC
y00fee sends brownie points to @netstudenton and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 133 | @netstudenton |http://www.freecodecamp.com/netstudenton
:star2: 5216 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jan 08 2017 02:09 UTC
@netstudenton You will need to run your $.ajax inside the getCurrentPosition callback (or put it in a function an call it from there)
@lydiayhuang THat looks like it works, does it?
Lyddip
@lydiayhuang
Jan 08 2017 02:10 UTC
@sjames1958gm nope...not working for the negative number
@sjames1958gm if one of the numbers is a negative number it will not multiply
still
Stephen James
@sjames1958gm
Jan 08 2017 02:11 UTC
@lydiayhuang Do you need to do num2 = 0 - num2?
Lyddip
@lydiayhuang
Jan 08 2017 02:11 UTC
@sjames1958gm i have no idea why
@sjames1958gm oooooh ok let me see
Stephen James
@sjames1958gm
Jan 08 2017 02:12 UTC
@lydiayhuang IF you do that you need to reverse the sign on num1 as well
Lyddip
@lydiayhuang
Jan 08 2017 02:12 UTC
@sjames1958gm still railing
failing
Stephen James
@sjames1958gm
Jan 08 2017 02:13 UTC
@lydiayhuang
if(num2 < 0) {
num2 = 0 - num2;
num1 = 0 - num1;
}
alican karalar
@alicankaralar
Jan 08 2017 02:13 UTC
@Chrono79 it has to work now... but doesnt :(

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

for (var a = 0 ; a < contacts.length ; a++ ) {

if (firstName==contacts[a].firstName) {

  if (contacts[a].hasOwnProperty(prop)) {

    return contacts[a][prop];
  }

  return "No such property";
}

return "No such contact";

}
// Only change code above this line
}

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

Stephen James
@sjames1958gm
Jan 08 2017 02:13 UTC
@alicankaralar How can you return no such contact before you check all the contacts?
Manuel Almeida
@netstudenton
Jan 08 2017 02:14 UTC
@lydiayhuang what the is Challenge ?
alican karalar
@alicankaralar
Jan 08 2017 02:14 UTC
ah i see
Diego Mayer
@Chrono79
Jan 08 2017 02:14 UTC
@alicankaralar your loop only runs once that way
Lyddip
@lydiayhuang
Jan 08 2017 02:14 UTC
@sjames1958gm still railing
@netstudenton I'm trying to make a function that multiplies without the multiply operand
Stephen James
@sjames1958gm
Jan 08 2017 02:15 UTC
@lydiayhuang Hmm, I tried and it seemed to work -can you post again?
Lyddip
@lydiayhuang
Jan 08 2017 02:16 UTC

@sjames1958gm @netstudenton function multiply(num1, num2) {
if(num2 === 0) {
return 0;
}
if( num2 < 0) {
num2 = 0- num2;
num2 = 0- num1;
}
var n = num1;

for(var i = 1; i < num2; i++){
num1 += n; // increments itself
}
return num1;
}

var output = multiply(4, 7);
console.log(output); // --> 28

still failing with the negative numbers part
Stephen James
@sjames1958gm
Jan 08 2017 02:16 UTC
@lydiayhuang num1 = 0 - num1 (you have num2 = 0 - num1)
Lyddip
@lydiayhuang
Jan 08 2017 02:16 UTC
@sjames1958gm ohh shoot
@sjames1958gm thank you!!
CamperBot
@camperbot
Jan 08 2017 02:17 UTC
lydiayhuang sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5217 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Jamie Lipschitz
@Jlipschitz
Jan 08 2017 02:18 UTC
@netstudenton make sure you nest your ajax call inside that get current position method, also sometimes codepen will complain about you not being connected via https:// so just add that the top of the url once you nest to rule that out as well
Manuel Almeida
@netstudenton
Jan 08 2017 02:24 UTC
@sjames1958gm @Jlipschitz thank you
CamperBot
@camperbot
Jan 08 2017 02:24 UTC
netstudenton sends brownie points to @sjames1958gm and @jlipschitz :sparkles: :thumbsup: :sparkles:
:cookie: 218 | @jlipschitz |http://www.freecodecamp.com/jlipschitz
:star2: 5218 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Manuel Almeida
@netstudenton
Jan 08 2017 02:28 UTC
@Jlipschitz my api is getting bad information about speficific location it just give the correct country and state, but wrong city and neighborhood
@Jlipschitz what api did you use ?
Jamie Lipschitz
@Jlipschitz
Jan 08 2017 02:29 UTC
@netstudenton let me check
Jamie Lipschitz
@Jlipschitz
Jan 08 2017 02:33 UTC
I use openweather @netstudenton
Manuel Almeida
@netstudenton
Jan 08 2017 02:34 UTC
i'm from RIo de Janeiro !
It is saying my city is 'Crajau' seems to my neighborhood that is Grajau with G !! ahah
oooh wrong link
Yintii
@Yintii
Jan 08 2017 02:38 UTC
'''
CamperBot
@camperbot
Jan 08 2017 02:38 UTC
:bulb: to format code use backticks! ``` more info
rjoyce411
@rjoyce411
Jan 08 2017 02:41 UTC

Someone please help. I can't get past this "After nextInLine(testArr, 10), testArr[4] should be 10............... function nextInLine(arr, item) {
// Your code here
arr.push(1);

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

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

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

F. Payton Guthrie
@paytguth
Jan 08 2017 02:47 UTC
Hey guys I've been working on this challenge for like 4 hours and I'd love it someone could help.

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

function lookUpProfile(firstName, prop){
// Only change code below this line
var contactLocation;
var fnBool = false;
var propBool = false;

for (i = 0; i <= 3; i++){
if (firstName == contacts[i].firstName) {
contactLocation = i;
fnBool = true;
break;
} }

if (fnBool === false) {return "No such contact";}

if (fnBool === true || contacts[i].hasOwnProperty(prop) === true) {
propBool = true;
return contacts[i][prop];
}
// Only change code above this line
}

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

Everything works but no matter what I do I can't get it to display No such property when the name is correct but the property does not exist
Jerry Purvis
@MessiaHack
Jan 08 2017 02:51 UTC
@netstudenton it's working correctly for me. In the browser, it will not be as accurate as doing it on a mobile device
Vizij
@Vizij
Jan 08 2017 02:53 UTC
@rjoyce411 You're always pushing the number 1 to the end, but it's asking you to push the second argument it gives you. function(arr, item)
alican karalar
@alicankaralar
Jan 08 2017 02:57 UTC
ughhh
i don't know how to stop the loop once it has found the values and the answers

function lookUpProfile(firstName, prop){
// Only change code below this line
var answer = "";

var a = 0;

while (a < contacts.length) {

if (firstName==contacts[a].firstName) {

  if (contacts[a].hasOwnProperty(prop)) {

    return contacts[a][prop];
  }

  else { return "No such property"; } 
}

   else { answer = "No such contact";}
a++;

}

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

i somehow got the greenlight but i don't know if i did it right
Manuel Almeida
@netstudenton
Jan 08 2017 03:02 UTC
@paytguth your var i in if (fnBool === true || contacts[i].hasOwnProperty(prop) === true)I isn't defined
Diego Mayer
@Chrono79
Jan 08 2017 03:02 UTC
@alicankaralar return exits the loop and the function
you could simply return No such contact after the loop
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 03:02 UTC
https://codepen.io/Geeheeb/pen/RKPvVm?editors=1111 can someone tell if they have proplems with twitch loading when they click on one of the logos?
Vizij
@Vizij
Jan 08 2017 03:02 UTC
@alicankaralar When you hit a return, the function exits, so the loop (and everything else) inside the function stops automatically
Brian
@BrianCodes33
Jan 08 2017 03:02 UTC
how do i enter a hyphen after every word w/ regex?
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 03:03 UTC
for some reason the new page opens up with the correct url, but the page just wont load for me
but if i go and just type the url in the page loads
dont quite understand what is happening
alican karalar
@alicankaralar
Jan 08 2017 03:04 UTC
@Chrono79 @Vizij thats my point. i want it to return once it has found the name AND the property, so it doesn't keep going. but then i don't know how to handle no such property and no such contact. i wan't it to stop searching after an answer is defined. btw . i passed with this code. but i don't think this is the right way
Creg Antony
@cregantony
Jan 08 2017 03:05 UTC
How come this doesnt work
```
var myStr= "FirstLine\n \SecondLine\\r Thirdline" ; // Change this line
var myStr= "FirstLine\n \\SecondLine\\\r Thirdline" ; // Change this line
Diego Mayer
@Chrono79
Jan 08 2017 03:05 UTC
@cregantony remove spaces, check your words (it's ThirdLine)

@alicankaralar

if (firstName==contacts[a].firstName) {

  if (contacts[a].hasOwnProperty(prop)) {

    return contacts[a][prop];
  }

  else { return "No such property"; } 
}

That code does that

Nathan Classen
@NathanHayez
Jan 08 2017 03:07 UTC
can someone help me approach the Reverse String bonfire? I figure that I will split the string into an array, then reverse it, then join. But I feel like the lessons thus far have taught me these concepts with very little practical instruction on how to work them in a code.
CamperBot
@camperbot
Jan 08 2017 03:07 UTC
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Vizij
@Vizij
Jan 08 2017 03:08 UTC
@alicankaralar It is. Basically, you're in the loop.
It finds the name it's looking for - OK. It finds the property on the object that has that name - OK. First return, it returns the value of that property.
It finds the name it's looking for - OK. It doesn't find the property. It returns the second return, No property.
It doesn't find the name. Loop ends, you hit third return. No contact
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 03:09 UTC
Failed to load '' as a plugin, because the frame into which the plugin is loading is sandboxed. what does this mean?
Brian
@BrianCodes33
Jan 08 2017 03:10 UTC
@NathanHayez i can help
alican karalar
@alicankaralar
Jan 08 2017 03:10 UTC
@Vizij @Chrono79 yes i see. right. i didn't have to initialize an answer variable in the beginning then
Brian
@BrianCodes33
Jan 08 2017 03:10 UTC
@NathanHayez you are exactly right in your approach
try to replicate that in code
alican karalar
@alicankaralar
Jan 08 2017 03:11 UTC
thanks @Vizij @Chrono79 @revisualize
CamperBot
@camperbot
Jan 08 2017 03:11 UTC
alicankaralar sends brownie points to @vizij and @chrono79 and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 264 | @vizij |http://www.freecodecamp.com/vizij
:star2: 3084 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 2869 | @revisualize |http://www.freecodecamp.com/revisualize
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 03:11 UTC
is it becuase its coming from codepen?
Nathan Classen
@NathanHayez
Jan 08 2017 03:11 UTC
@BrianCodes33 Thanks, yeah I will try!
CamperBot
@camperbot
Jan 08 2017 03:11 UTC
nathanhayez sends brownie points to @briancodes33 :sparkles: :thumbsup: :sparkles:
:cookie: 26 | @briancodes33 |http://www.freecodecamp.com/briancodes33
Brian
@BrianCodes33
Jan 08 2017 03:11 UTC
:beers: @NathanHayez
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 03:12 UTC
well im going to say it as say its out of my control
Joseph
@revisualize
Jan 08 2017 03:17 UTC
WOOT! I got 1 brownie today!
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 03:18 UTC
dont act all snoo ty about it @revisualize
CamperBot
@camperbot
Jan 08 2017 03:18 UTC
heebiegeebee sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2870 | @revisualize |http://www.freecodecamp.com/revisualize
Ghost
@ghost~56a80c91e610378809be5d28
Jan 08 2017 03:18 UTC
@revisualize that's no brownie
Nathan Classen
@NathanHayez
Jan 08 2017 03:18 UTC
@BrianCodes33 This is what I came up with, and it is returning "hello" as "olleh" but it has not passed me yet?

function reverseString(str) {
  return str;
}

reverseString("hello").split("").reverse().join("");
Ghost
@ghost~56a80c91e610378809be5d28
Jan 08 2017 03:19 UTC
I have a question about Webpack. What does resolve alias do / why use it?
Diego Mayer
@Chrono79
Jan 08 2017 03:19 UTC
@NathanHayez yur code should be inside the function
Brian
@BrianCodes33
Jan 08 2017 03:19 UTC
@NathanHayez you have the right idea
diego lemme help him i got this
Diego Mayer
@Chrono79
Jan 08 2017 03:20 UTC
ok then
alican karalar
@alicankaralar
Jan 08 2017 03:20 UTC
thanks @MaeStat @forkerino
CamperBot
@camperbot
Jan 08 2017 03:20 UTC
alicankaralar sends brownie points to @maestat and @forkerino :sparkles: :thumbsup: :sparkles:
:cookie: 274 | @maestat |http://www.freecodecamp.com/maestat
:cookie: 559 | @forkerino |http://www.freecodecamp.com/forkerino
Brian
@BrianCodes33
Jan 08 2017 03:21 UTC
@NathanHayez think of basic algebra
you have a function expression
f(x) = 3x + 5
and then you call it
f(5)
which gives you 20
i hope that doesn’t confuse you, but it made me help understand functions at first
so put the split reverse join thing you got going on in your function body - in between the curlies
Nathan Classen
@NathanHayez
Jan 08 2017 03:23 UTC
@BrianCodes33 OOOOOOOH!! So everything inside the functions curly brakets is the "3x + 5" and so then the call is "reverseString("whatever string")?
Brian
@BrianCodes33
Jan 08 2017 03:24 UTC
yes!
exactumondo
we first need to define our function, and then call it (hey function, we need to use you now)...
so take that knowledge and go write your function :)
Nathan Classen
@NathanHayez
Jan 08 2017 03:26 UTC
Didn't work. -_-
Diego Mayer
@Chrono79
Jan 08 2017 03:26 UTC
I would add, why do you write a function that returns the value you pass without doing anything to it? It doesn't sound that useful, doesn't it?
Nathan Classen
@NathanHayez
Jan 08 2017 03:26 UTC

function reverseString(str) {
  str.split("").reverse().join("");

  return str;

}

reverseString("hello");
Brian
@BrianCodes33
Jan 08 2017 03:27 UTC
you got it
although
no need to return it on seperate line
just return on same line
gupgdown
@r1nc3w1nd
Jan 08 2017 03:29 UTC
wall of code incoming

'''var count = 0;

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

}

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

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

CamperBot
@camperbot
Jan 08 2017 03:29 UTC
:bulb: to format code use backticks! ``` more info
gupgdown
@r1nc3w1nd
Jan 08 2017 03:29 UTC
sorry

```var count = 0;

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

}

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

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

Diego Mayer
@Chrono79
Jan 08 2017 03:30 UTC
@r1nc3w1nd don't return when evaluating card, do it after it, evaluating count
Nathan Classen
@NathanHayez
Jan 08 2017 03:30 UTC
@BrianCodes33 It is not working though. In my mind, "I've got a function and it will be defined by a string, then the function will take that string and split.reverse.join, then return the str. Its still not working though?
And that return element was prewritten into the bonfire..
cjljohnson
@cjljohnson
Jan 08 2017 03:31 UTC
@NathanHayez when you do the reverse you aren't saving it to a variable or anything. then you return the original string that you put in the function
Brian
@BrianCodes33
Jan 08 2017 03:31 UTC
i think you got it the other way around- your function defines your string input, and you get an output
@NathanHayez you got the function right just try returning it all on the same line
Nathan Classen
@NathanHayez
Jan 08 2017 03:33 UTC
@BrianCodes33 That worked!
function reverseString(str) {
  return str.split("").reverse().join("");
  }
reverseString("hello");
Brian
@BrianCodes33
Jan 08 2017 03:33 UTC
nice job! :thumbsup:
now try doing it w/ a for loop take your head for a spin ;)
gupgdown
@r1nc3w1nd
Jan 08 2017 03:34 UTC
@Chrono79 that did it. much thanks.
CamperBot
@camperbot
Jan 08 2017 03:34 UTC
r1nc3w1nd sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3085 | @chrono79 |http://www.freecodecamp.com/chrono79
Brian
@BrianCodes33
Jan 08 2017 03:34 UTC
finding different solutions in programming === good stuff @NathanHayez
Sidharth Anand
@fuuraa
Jan 08 2017 03:34 UTC
good morning guys
Nathan Classen
@NathanHayez
Jan 08 2017 03:34 UTC
Thanks for your help! @BrianCodes33
I'm on basic algorithm scripting so ill probably have more questions.
CamperBot
@camperbot
Jan 08 2017 03:34 UTC
nathanhayez sends brownie points to @briancodes33 :sparkles: :thumbsup: :sparkles:
:warning: nathanhayez already gave briancodes33 points
Brian
@BrianCodes33
Jan 08 2017 03:35 UTC
@NathanHayez anytime
Nathan Classen
@NathanHayez
Jan 08 2017 03:35 UTC

@BrianCodes33 How would I do that with a for loop??!

....man, I feel like I've forgotten so much of what I just went through!

Brian
@BrianCodes33
Jan 08 2017 03:37 UTC
that is a great question, it is somewhat advanced i guess- you need decrement the loop at the last index and push each character into a new result
@NathanHayez google is a great resource for your questions, start googling everything everytime you hit a roadblock
kamonAKL
@kamonAKL
Jan 08 2017 03:39 UTC
I stuck in "Stand in line" question
Manish Giri
@Manish-Giri
Jan 08 2017 03:43 UTC
@kamonAKL what's the problem
Phillip
@psnider22
Jan 08 2017 03:45 UTC

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

// Only change code below this line

var myTotal = 0;

for (var i = 0; i < myArr.length; i++){
myTotal += myArr[i];
}

myTotal needs to be 20 and I cant seem to get that
solves as undefined
Manish Giri
@Manish-Giri
Jan 08 2017 03:47 UTC
@psnider22 can you post the challenge URL here? click "run tests" first.
Diego Mayer
@Chrono79
Jan 08 2017 03:48 UTC
@psnider22 Declare and initialize a variable total
Manish Giri
@Manish-Giri
Jan 08 2017 03:48 UTC

@psnider22

Declare and initialize a variable total to 0. Use a for loop to add the value of each element of the myArr array to total.

read the instruction, they want you to use a specific variable name.
Phillip
@psnider22
Jan 08 2017 03:48 UTC
lol thanks @Manish-Giri
CamperBot
@camperbot
Jan 08 2017 03:48 UTC
psnider22 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3622 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Jan 08 2017 03:48 UTC
:+1:
John Paul Penaloza
@johnpyp
Jan 08 2017 03:52 UTC

Hey guys, I'm working on the Weather Report Project, and I'm having a problem.

Currently, I only have functions for getting current location and making an API call to the openweathermap API.

My problem is that the API call isn't working, although it was earlier. I didn't change anything. Could someone tell me problem? Here is my codepen: https://codepen.io/johnpyp/pen/QdbGeO?editors=1010

If you don't want to open up a codepen, here is the Javascript and HTML for this specific function:

function gettingWeather() {
  $.getJSON("http://api.openweathermap.org/data/2.5/weather?q=London,uk&APPID=5c825746cd5c94165fbd2a80ef0eceb2", function(json) {
    alert("test");
  });
<button class="btn btn-primary"id="getWeather" onclick="gettingWeather()">Weather Data</button>
gupgdown
@r1nc3w1nd
Jan 08 2017 03:52 UTC
var testObj = {
    "an entree": "hamburger",
    "the drink": "water"
};

var entreeValue = [];
etc.
im not sure what im being asked to here.
or, how to go about what im being asked to, actually
Johnny
@JohnnyBizzel
Jan 08 2017 03:53 UTC
@r1nc3w1nd :hamburger: :beer: can't find water
John Paul Penaloza
@johnpyp
Jan 08 2017 03:54 UTC
@r1nc3w1nd What are you being asked to do? You haven't given any insight into the assignment.
Johnny
@JohnnyBizzel
Jan 08 2017 03:54 UTC
@johnpyp Having lunch I think
gupgdown
@r1nc3w1nd
Jan 08 2017 03:54 UTC
Read the values of the properties "an entree" and "the drink" of testObj using bracket notation and assign them to entreeValue and drinkValue respectively.
John Paul Penaloza
@johnpyp
Jan 08 2017 03:54 UTC
@JohnnyBizzel lol
@r1nc3w1nd ah.
gupgdown
@r1nc3w1nd
Jan 08 2017 03:55 UTC
i tried
Johnny
@JohnnyBizzel
Jan 08 2017 03:55 UTC
@r1nc3w1nd Object notation...!
gupgdown
@r1nc3w1nd
Jan 08 2017 03:55 UTC
yes
John Paul Penaloza
@johnpyp
Jan 08 2017 03:56 UTC
@r1nc3w1nd Alright, so what you should do is something like this: testObj[] and assign that to a variable
Good luck!
John Paul Penaloza
@johnpyp
Jan 08 2017 03:56 UTC
@r1nc3w1nd figure out what to put in the brackets
gupgdown
@r1nc3w1nd
Jan 08 2017 03:57 UTC
that worked, but i swear to Allah i had already tried that
John Paul Penaloza
@johnpyp
Jan 08 2017 03:57 UTC
@JohnnyBizzel any ideas what to do for my question if you have looked at it/know what to do.
gupgdown
@r1nc3w1nd
Jan 08 2017 03:57 UTC
@johnpyp thanks
CamperBot
@camperbot
Jan 08 2017 03:57 UTC
r1nc3w1nd sends brownie points to @johnpyp :sparkles: :thumbsup: :sparkles:
:cookie: 269 | @johnpyp |http://www.freecodecamp.com/johnpyp
John Paul Penaloza
@johnpyp
Jan 08 2017 03:58 UTC
@r1nc3w1nd probably a syntax error, but if you mess up the correct answer with a syntax error, everything is hard because you'll never get anywhere haha. Always good to revisit what you think is the logical conclusion even if it didn't work the first time. Glad you got it :)
kamonAKL
@kamonAKL
Jan 08 2017 04:13 UTC
@Manish-Giri thank you for responding me I don't know what to do with the arr and item variables
CamperBot
@camperbot
Jan 08 2017 04:13 UTC
kamonakl sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3623 | @manish-giri |http://www.freecodecamp.com/manish-giri
kamonAKL
@kamonAKL
Jan 08 2017 04:14 UTC

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

return item; // Change this line
}

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

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

Manish Giri
@Manish-Giri
Jan 08 2017 04:16 UTC
@kamonAKL read these posts
Zaurbek Zhakupov
@zzhakupov
Jan 08 2017 04:17 UTC
Hello guys, I'll highly appreaciate if you can afford me some feedback on my roguelike project. I spended whole winter break to do this. Hope you enjoy it. http://codepen.io/Zooll/pen/RoXGmG
kamonAKL
@kamonAKL
Jan 08 2017 04:17 UTC
ok thanks @Manish-Giri
CamperBot
@camperbot
Jan 08 2017 04:17 UTC
kamonakl sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: kamonakl already gave manish-giri points
kamonAKL
@kamonAKL
Jan 08 2017 04:18 UTC
thnaks
Steven2493
@Steven2493
Jan 08 2017 04:22 UTC
function findLongestWord(str) {

  newStr = str.split(" ");
  lgth = newStr[0].length;

  for(var i = 0; i < newStr.length; i++){
    if(newStr[i].length > lgth){
      lgth = newStr[i].length;
      return lgth;
    }
  }

}

findLongestWord("The quick brown fox jumped over the lazy dog");
I Need some help on the longest word in teh string one?
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 04:26 UTC
dont have the return in the loop
@Steven2493
Margaret
@Margaret2
Jan 08 2017 04:28 UTC
@Zooll8 cool! good job! must have been a lot of work
Manish Giri
@Manish-Giri
Jan 08 2017 04:31 UTC
@kamonAKL welcome
jump020305
@jump020305
Jan 08 2017 04:37 UTC
gupgdown
@r1nc3w1nd
Jan 08 2017 04:43 UTC
on the "using objects for lookup" lesson. looks like:
function phoneticLookup(val){
  var result = '';
  var lookup={
  "alpha":"adams";
etc
};
result = //not sure what goes here
return result;
}
phoneticLookup("alpha");
Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.
babajide odusola
@cesarecaravaggio
Jan 08 2017 04:47 UTC
can someone pls help me with this lesson?

function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  case val1:
  answer==="alpha";


  case val2:
  answer==="beta";


  case val3:
  answer==="gamma";
  break;

  case val4:
  answer==="delta";
  break;
  // Only change code above this line  
  return answer;  
}

// Change this value to test
caseInSwitch(1);
i have it all wrong
Bunny Vishal
@bunnyvishal6
Jan 08 2017 04:48 UTC
@cesarecaravaggio return answer should be done outside switch statement
@cesarecaravaggio what is the actual task?
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 04:49 UTC
you also shouldnt have val1 etc as the case
and @r1nc3w1nd how would you target "alpha"?
Bunny Vishal
@bunnyvishal6
Jan 08 2017 04:50 UTC
@cesarecaravaggio yep you should use val as the case
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 04:50 UTC
no he shoudl use 1 etc
case 1....
gupgdown
@r1nc3w1nd
Jan 08 2017 04:51 UTC
tahts the question im sitting here trying to answer haha
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 04:51 UTC
how do you target an object?
@r1nc3w1nd
gupgdown
@r1nc3w1nd
Jan 08 2017 04:53 UTC
lookup[alpha]?
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 04:53 UTC
if i wanted you to return the lookup object how would you return it? @r1nc3w1nd
yes almost
except alpha is not the parameter
whats the parameter of the function?
gupgdown
@r1nc3w1nd
Jan 08 2017 04:54 UTC
val?
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 04:54 UTC
yes
gupgdown
@r1nc3w1nd
Jan 08 2017 04:54 UTC
lookup[val]?
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 04:54 UTC
could be
gupgdown
@r1nc3w1nd
Jan 08 2017 04:55 UTC
slap me and call me Georgie
@HeebieGeeBee thanks
CamperBot
@camperbot
Jan 08 2017 04:55 UTC
r1nc3w1nd sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 475 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 04:55 UTC
yw
Joseph
@revisualize
Jan 08 2017 04:56 UTC
Hi.
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 04:57 UTC
hello
its quiet huh
Joseph
@revisualize
Jan 08 2017 04:58 UTC
A little. I'm chilling at home. I got a little to drunk last night.
Slept until noon.
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 04:59 UTC
nice
ashifmvp
@ashifmvp
Jan 08 2017 05:00 UTC
@HeebieGeeBee
var myfirstName = "Moh";
var mylastName = "Ash";
whats wrong in this
i am unable to proceed
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:00 UTC
nothing from what i can see
ashifmvp
@ashifmvp
Jan 08 2017 05:00 UTC
myFirstName should be a string with at least one character in it.
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:00 UTC
maybe use myLastName and myFirstName
ashifmvp
@ashifmvp
Jan 08 2017 05:01 UTC
this is the not
Erik Von Ploennies
@erikvp
Jan 08 2017 05:01 UTC

I'm working on Find the Longest Word In A String. function findlongestWord(str) {
str = str.split(' ');
str.sort(function (a, b){return b.length - a.length;});
return str[0].length;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
This give the correct answer when I run it outside of FCC. Why won't FCC take this?

ashifmvp
@ashifmvp
Jan 08 2017 05:01 UTC
note
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:01 UTC
make sure you use the capital letters
@erikvp i dont see how that will work finding the longest
ashifmvp
@ashifmvp
Jan 08 2017 05:02 UTC
caps in what
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:02 UTC
your variable names @ashifmvp
myFirstName not myfirstName
camelcase
Erik Von Ploennies
@erikvp
Jan 08 2017 05:04 UTC
it sorts the strings longest to shortest. then I get length of string in [0].
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:04 UTC
str.sort(function (a, b){return b.length - a.length;});
return str[0].length;
} @erikvp what do you think this is doing?
sorting your array longest to shortest?
Erik Von Ploennies
@erikvp
Jan 08 2017 05:05 UTC
yes
it seems to work when I run it outside FCC.
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:07 UTC
@erikvp your function name is slightly different to whats being called
might wanna check that
then i guess it will work
Erik Von Ploennies
@erikvp
Jan 08 2017 05:09 UTC
That worked! Thanks!
Emily Sperry
@sperrye
Jan 08 2017 05:09 UTC
function ajax() {
    $.ajax ({ //call
      url: "https://wind-bow.gomix.me/twitch-api/streams/" + users[i] + "?callback=?", //api URL
      type: 'GET',
      dataType: 'jsonp',
      data:
      {format: "json"},
      success: //if successful ex function
         function (data) {
      fetchData(data);
    },
      error: function () {
      console.log("No");
      }
    })
  }
I'm getting 'jQuery.Deferred 'GET' is not defined. What am I doing wrong?
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:09 UTC
cool well done
@sperrye you got your codepen?
It's kind of all over the place right now just ignore CSS/ids I'm just trying to get the api working
Erik Von Ploennies
@erikvp
Jan 08 2017 05:14 UTC
@HeebieGeeBee Thanks again for the help. Just checked, and I had it correct in my code outside FCC but completely missed it when I re-wrote it.
CamperBot
@camperbot
Jan 08 2017 05:14 UTC
:cookie: 476 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
erikvp sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:15 UTC
@sperrye looks like its working to me what exactly is the problem? where you getting that error messge?
Emily Sperry
@sperrye
Jan 08 2017 05:15 UTC
error message is in the codepen console
"jQuery.Deferred exception: GET is not defined" "ReferenceError: GET is not defined at ajax (pen.js:33:19) at HTMLDocument.<anonymous> (pen.js:27:9) at j (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js:2:29568) at k (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js:2:29882)" undefined
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:17 UTC
i dont get that message
its all working fine for me and i havent done anything
maybe try a refresh?
Emily Sperry
@sperrye
Jan 08 2017 05:18 UTC
it's working now. so strange. thanks @HeebieGeeBee
CamperBot
@camperbot
Jan 08 2017 05:18 UTC
sperrye sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 477 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:19 UTC
np
james clark
@james0212
Jan 08 2017 05:21 UTC
who's done with the challenge"stand in line"?
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:21 UTC
i have
heroiczero
@heroiczero
Jan 08 2017 05:21 UTC
@james0212 review your push, pop, shift and unshift methods for arrays in fcc.
Greg Duncan
@GregatGit
Jan 08 2017 05:25 UTC
@sperrye you probably shouldn't call a function ajax but give it a unique name like myAjax or something like that
Varun Kanwat
@VarunKanwat
Jan 08 2017 05:25 UTC

// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

for (var i = 0; i < ourArr.length; i++) {
ourTotal += ourArr[i];
}

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

// Only change code below this line
var total = 0;
for (var i = 0; i < myArr.lengh; i++) {
total = total + myArr[i];
}

my total is 0. I don' t understand where is the problem
Challange name = Iterate Through an Array with a For Loop
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:27 UTC
what does it want you to do ? @VarunKanwat
Varun Kanwat
@VarunKanwat
Jan 08 2017 05:27 UTC
total should be equal to 20
@HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:28 UTC
length*
Varun Kanwat
@VarunKanwat
Jan 08 2017 05:28 UTC
oh..
thanks a lot man...so silly mistake
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:28 UTC
np
Alfian Akmal Hanantio
@amalhanaja
Jan 08 2017 05:39 UTC
Hey
I' m stucked
with Understanding Uninitialized Variables
heroiczero
@heroiczero
Jan 08 2017 05:41 UTC
@amalhanaja just set the var equal to 5, 10, and "I am a"
gupgdown
@r1nc3w1nd
Jan 08 2017 05:44 UTC
function multiplyAll(arr){
var product = 1;
for (var i=0; i < arr.length; i++){
for var j=0; j < arr[i].length;j++){
product *= arr[i];
}
}return product;
}
Ramone
@RamoneQR
Jan 08 2017 05:44 UTC
@dylang400 nope I figured it out with some help! Thanks though
CamperBot
@camperbot
Jan 08 2017 05:44 UTC
:cookie: 73 | @dylang400 |http://www.freecodecamp.com/dylang400
Holden Hartsoe
@hartsoeha
Jan 08 2017 05:44 UTC
hey folks, quick question...when you're using regular expressions to find the number of occurrences of a given character or word and store that in a variable...is it creating an array with each occurrence placed at an index location? I'm only asking because when you use .length to obtain the number of occurrences it seems able to count each occurrence individually
CamperBot
@camperbot
Jan 08 2017 05:44 UTC
ramoneqr sends brownie points to @dylang400 :sparkles: :thumbsup: :sparkles:
Alfian Akmal Hanantio
@amalhanaja
Jan 08 2017 05:44 UTC
thanks
@heroiczero thank
CamperBot
@camperbot
Jan 08 2017 05:44 UTC
:cookie: 635 | @heroiczero |http://www.freecodecamp.com/heroiczero
amalhanaja sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
gupgdown
@r1nc3w1nd
Jan 08 2017 05:45 UTC
assumeing no typos in my code above, it is working on this: ([[1], [2], [3]])
but not on this: ([[1,2],[3,4],[5,6,7]])
goal is to multiply product variable by each number in the sub arrays
first exmple returns 6, second one returns null
devpaaji
@devpaaji
Jan 08 2017 05:58 UTC
Why is window.onload event used? What happens if DOM manipulation code is not written inside onload method?
kamonAKL
@kamonAKL
Jan 08 2017 05:59 UTC
I already changed it to lookup table why is it not correct

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

// Only change code below this line

var lookup={
"alpha":"Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank"
};

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

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

oh i got it
sorry guys , I for got this line result = lookup.val;
Alex
@MaeStat
Jan 08 2017 06:02 UTC
@kamonAKL what you have to do in your challange? What it's name?
Kartikeya Gupta
@kartikeya100
Jan 08 2017 06:02 UTC
plz help me http://futurewatercity.com/ how is this background made and how do i add pointers(numbers) there
heroiczero
@heroiczero
Jan 08 2017 06:02 UTC
@kamonAKL remember that you have to use bracket object notation for variables
Alex
@MaeStat
Jan 08 2017 06:03 UTC
@kamonAKL and separate objects with comma
Julia
@medusabeast
Jan 08 2017 06:04 UTC
@hartsoeha well, .length simply finds the number of variables within a string, whereas bracket notation is able to specify the index of string and array indexing specifies the entry within the array. I noted it as similar to "Inception" dream within a dream within a dream lol. It just depends on what kind of array/strings you are working with and what you are looking for. Hope this helps!
gupgdown
@r1nc3w1nd
Jan 08 2017 06:05 UTC
i got it. in case anyone wanted to know...should have been: product *= arr[i][j]
Michael J Kusdya
@michael-kusdya
Jan 08 2017 06:06 UTC
hello, can i ask non freecodecamp related question here ? i'm doing a challenge on codewars and i'm kinda stuck right now
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:11 UTC
@kartikeya100 what do you want to know?
Michael J Kusdya
@michael-kusdya
Jan 08 2017 06:11 UTC
sorry nvm, already solved it
Holden Hartsoe
@hartsoeha
Jan 08 2017 06:12 UTC
Thanks @medusabeast !
CamperBot
@camperbot
Jan 08 2017 06:12 UTC
hartsoeha sends brownie points to @medusabeast :sparkles: :thumbsup: :sparkles:
:cookie: 196 | @medusabeast |http://www.freecodecamp.com/medusabeast
grantknaver
@grantknaver
Jan 08 2017 06:13 UTC
im curious why do I have to check if something is array in this assignment
all of the answers return arrays
Iqbal
@mibaldobaghi
Jan 08 2017 06:14 UTC
hi guys
Kartikeya Gupta
@kartikeya100
Jan 08 2017 06:14 UTC
@HeebieGeeBee how is that background a draggaable image and how are those pointers added?
Iqbal
@mibaldobaghi
Jan 08 2017 06:15 UTC
id like to ask a question for better understanding
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:15 UTC
@grantknaver becuase some arent arrays?
h1tag
@h1tag
Jan 08 2017 06:15 UTC
Hey, I'm on the Random Quote Generator project, for the random quote generating functionality, is it OK if I search google for it (because I think google will give me the code for it)? Is this the right way to do the project?
grantknaver
@grantknaver
Jan 08 2017 06:16 UTC
all of them are set between [ ]
Iqbal
@mibaldobaghi
Jan 08 2017 06:16 UTC
in this file there is an object called AIAction. Underneath it there is two public functions called AIAction.ASCENDING and DESCENDING. what is the difference of typing it outside and inside the object like this.DESCENDING?
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:16 UTC
steamrollArray([1, {}, [3, [[4]]]]) should return [1, {}, 3, 4]. this one isnt @grantknaver
Iqbal
@mibaldobaghi
Jan 08 2017 06:16 UTC
@fortMaximus you can search google for an API to use in the project
grantknaver
@grantknaver
Jan 08 2017 06:16 UTC
I have tested and the first test case doesnt return the first index, but I dont under why
true I guess I am thinking about the eariler test cases
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:17 UTC
@kartikeya100 probably due to some fancy javascripting
h1tag
@h1tag
Jan 08 2017 06:17 UTC
@mibaldobaghi thanks
CamperBot
@camperbot
Jan 08 2017 06:17 UTC
fortmaximus sends brownie points to @mibaldobaghi :sparkles: :thumbsup: :sparkles:
:cookie: 369 | @mibaldobaghi |http://www.freecodecamp.com/mibaldobaghi
Kartikeya Gupta
@kartikeya100
Jan 08 2017 06:18 UTC
@HeebieGeeBee could you tell me any fancy js librarries?
grantknaver
@grantknaver
Jan 08 2017 06:20 UTC
what would be the if statement to test for an empty array if (arr[i].length === 0)?
or maybe if(arr[i] === undefined / null ) ?
Richard
@richafig
Jan 08 2017 06:21 UTC
Hi everyone! I need help with Stand in Line in the js branch. Do I use .push, .shift, etc.?
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:22 UTC
@kartikeya100 i cant, ive only used jquery, maybe someone else can though
if array = [] @grantknaver
with proper syntax of course
but [] is an empty array
grantknaver
@grantknaver
Jan 08 2017 06:24 UTC
so basically if ( arr[i] === []) {
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:24 UTC
yeah
i dunno if this is considered cheating or not, but when i did that challenge, i did google how to flatten nested arrays @grantknaver
grantknaver
@grantknaver
Jan 08 2017 06:27 UTC
that is just figuring out
ashifmvp
@ashifmvp
Jan 08 2017 06:27 UTC
@HeebieGeeBee
var myStr = "FirstLine\nSecondLine\rThirdline";
grantknaver
@grantknaver
Jan 08 2017 06:27 UTC
but I have been kinda shooting from the hip
ashifmvp
@ashifmvp
Jan 08 2017 06:27 UTC
whats wrong in above
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:27 UTC
put your code inbetween backticks @ashifmvp
ashifmvp
@ashifmvp
Jan 08 2017 06:28 UTC
may be i mstook the instruction
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:28 UTC
cant tell which backslashes have been taken out by chat
but im guessing you havent escaped the backslashes around \SecondLine\ properly
Alison Yoon
@AlisonYoon
Jan 08 2017 06:28 UTC
Could anyone help , I don't see what makes an error here
ashifmvp
@ashifmvp
Jan 08 2017 06:28 UTC
can you correct me in code
Alison Yoon
@AlisonYoon
Jan 08 2017 06:28 UTC
JQuery
if( $("#site_title:nth-child(1)").css('transform') == 'translate3d(0,0%,0)'){
$("#nav_page a:nth-child(3)").click(function(){
    $("#site_title_wrap div:contains('UNEP')").css('transform','translate3d(0px,-150%,0px)');
    $("#site_title_wrap div:contains('Flower')").css('transform','translate3d(0px,0%,0px)');
    $("#site_type p:contains('Desktop Website') ").css('transform','translate3d(0px,-100%,0px)');
    $("#site_type p:contains('Mobile Website') ").css('transform','translate3d(0px,0%,0px)');
    $("#site_tool p:nth-child(1)").css('transform','translate3d(0px,-100%,0px)');
    $("#site_tool p:nth-child(2)").css('transform','translate3d(0px,0%,0px)');
    $("#site_url a:nth-child(1)").css('transform','translate3d(0px,-150%,0px)');
    $("#site_url a:nth-child(2)").css('transform','translate3d(0px,0%,0px)');
  });
};
Dhavalkumar Prajapati
@adhavalboy
Jan 08 2017 06:29 UTC
myVar = myVar should be changed
what it means?
Alison Yoon
@AlisonYoon
Jan 08 2017 06:29 UTC
inside the if (){"do somthing"} works just fine but with if() added there, it doesn't work
ashifmvp
@ashifmvp
Jan 08 2017 06:30 UTC
@HeebieGeeBee can you correct me in code
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:30 UTC
FirstLine\n\\SecondLine\\\rThirdLine i think its somethign like that but cant remember totally off the top of my head
Dhavalkumar Prajapati
@adhavalboy
Jan 08 2017 06:30 UTC
@AlisonYoon this () for condition
Alison Yoon
@AlisonYoon
Jan 08 2017 06:30 UTC
is there anything wrong with my condition ?
h1tag
@h1tag
Jan 08 2017 06:31 UTC
@richafig read carefully what the challenge asks and read about what each method of those does, then use the methods that match the functionality of what the challenge is asking you to do
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:31 UTC
thats some fancy jquerying @AlisonYoon
Alison Yoon
@AlisonYoon
Jan 08 2017 06:31 UTC
Thanks :)
for some reason, with if() it doesn't wokr
Richard
@richafig
Jan 08 2017 06:31 UTC
@fortMaximus Ok, thanks
CamperBot
@camperbot
Jan 08 2017 06:31 UTC
richafig sends brownie points to @fortmaximus :sparkles: :thumbsup: :sparkles:
:cookie: 263 | @fortmaximus |http://www.freecodecamp.com/fortmaximus
David
@DavidGcastro
Jan 08 2017 06:32 UTC
hey guys
im stuck on the the mad libs part
how do i do it
Alison Yoon
@AlisonYoon
Jan 08 2017 06:32 UTC
what's wrong with if()
Kartikeya Gupta
@kartikeya100
Jan 08 2017 06:33 UTC
@HeebieGeeBee ok
Alison Yoon
@AlisonYoon
Jan 08 2017 06:33 UTC
@adhavalboy is condition wrong?
Kartikeya Gupta
@kartikeya100
Jan 08 2017 06:33 UTC
@AlisonYoon
if(condition){
statement 1;
statement 2;
}
Alison Yoon
@AlisonYoon
Jan 08 2017 06:33 UTC
@kartikeya100 exactly!
why doesn't it work ?
statement itself works just fine without if(condition)
David
@DavidGcastro
Jan 08 2017 06:34 UTC
halpp
Kartikeya Gupta
@kartikeya100
Jan 08 2017 06:34 UTC
@AlisonYoon share your code
Alison Yoon
@AlisonYoon
Jan 08 2017 06:34 UTC
@kartikeya100 so this is my condition ehre
$("#site_title:nth-child(1)").css('transform') == 'translate3d(0,0%,0)'
$("#nav_page a:nth-child(3)").click(function(){
$("#site_title_wrap div:contains('UNEP')").css('transform','translate3d(0px,-150%,0px)');
$("#site_title_wrap div:contains('Flower')").css('transform','translate3d(0px,0%,0px)');
$("#site_type p:contains('Desktop Website') ").css('transform','translate3d(0px,-100%,0px)');
$("#site_type p:contains('Mobile Website') ").css('transform','translate3d(0px,0%,0px)');
$("#site_tool p:nth-child(1)").css('transform','translate3d(0px,-100%,0px)');
$("#site_tool p:nth-child(2)").css('transform','translate3d(0px,0%,0px)');
$("#site_url a:nth-child(1)").css('transform','translate3d(0px,-150%,0px)');
$("#site_url a:nth-child(2)").css('transform','translate3d(0px,0%,0px)');
});
this is the statement part

if( $("#site_title:nth-child(1)").css('transform') == 'translate3d(0,0%,0)'){

$("#nav_page a:nth-child(3)").click(function(){
    $("#site_title_wrap div:contains('UNEP')").css('transform','translate3d(0px,-150%,0px)');
    $("#site_title_wrap div:contains('Flower')").css('transform','translate3d(0px,0%,0px)');
    $("#site_type p:contains('Desktop Website') ").css('transform','translate3d(0px,-100%,0px)');
    $("#site_type p:contains('Mobile Website') ").css('transform','translate3d(0px,0%,0px)');
    $("#site_tool p:nth-child(1)").css('transform','translate3d(0px,-100%,0px)');
    $("#site_tool p:nth-child(2)").css('transform','translate3d(0px,0%,0px)');
    $("#site_url a:nth-child(1)").css('transform','translate3d(0px,-150%,0px)');
    $("#site_url a:nth-child(2)").css('transform','translate3d(0px,0%,0px)');
  });

};

and this is including the if(condition)
Kartikeya Gupta
@kartikeya100
Jan 08 2017 06:35 UTC
try using ===
Alison Yoon
@AlisonYoon
Jan 08 2017 06:35 UTC
ok
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:36 UTC
can you have an onclick function inside an if statement?
Alison Yoon
@AlisonYoon
Jan 08 2017 06:36 UTC
ahhh no :/ it doesn't work @kartikeya100
@HeebieGeeBee can't I ?
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:36 UTC
how would it work exactly
not saying you cant im just wondering
Alison Yoon
@AlisonYoon
Jan 08 2017 06:37 UTC
So, if #site_title:nth-child(1)'s css property "transform" is 'translate3d(0,0%,0)', as I click "next"button which is #nav_page a:nth-child(3) ,
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:37 UTC
is this for a website menu?
Alison Yoon
@AlisonYoon
Jan 08 2017 06:37 UTC
all those selector's transform:translate3d()value supposed to change
but only if if( $("#site_title:nth-child(1)").css('transform') == 'translate3d(0,0%,0)')
@HeebieGeeBee it's not for menu, it is for individual pages
ah I wish I could share my screen
anyways, there's no mistake found on the code I guess
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 08 2017 06:42 UTC
can some plz help me with JavaScript section: Stand in Line?
*the queue section
Alison Yoon
@AlisonYoon
Jan 08 2017 06:42 UTC
if there was any error, developer's window's console would have told me that
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 08 2017 06:42 UTC
I'm about to rip the hair outta my head
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:42 UTC
yeah i guess so @AlisonYoon
Ghulam Shabir
@ghulamshabir
Jan 08 2017 06:42 UTC
@TheRealChrisEdwards what you have so far ?
Alison Yoon
@AlisonYoon
Jan 08 2017 06:42 UTC
it's weird
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 08 2017 06:43 UTC

arr = [0,1,2,3,4];
var nextInLine = arr + item.push;
var result = arr.shift(0);

return result;

i know this isn't correct, but that's what I've started with
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:44 UTC
read up about how push() method works @TheRealChrisEdwards
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 08 2017 06:44 UTC
so far i know that i need to shift my array somehow, and push my item arg somehow, but putting my function together is giving me some trouble
Joseph Livengood
@JosephLivengood
Jan 08 2017 06:44 UTC
@TheRealChrisEdwards So its asking you to push the array, then shift the array basically
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:45 UTC
push item into the array
Ghulam Shabir
@ghulamshabir
Jan 08 2017 06:45 UTC
@TheRealChrisEdwards you need two array methods, a push() to add item to the end of arr then remove and return first element using .shift() you can review these two methods in your previous lessons Manipulating Arrays with...
Joseph Livengood
@JosephLivengood
Jan 08 2017 06:45 UTC
@TheRealChrisEdwards Push works like shift how its written:
array.push(item_to_push);
Richard
@richafig
Jan 08 2017 06:46 UTC
@ghulamshabir thanks
CamperBot
@camperbot
Jan 08 2017 06:46 UTC
richafig sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1660 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Richard
@richafig
Jan 08 2017 06:46 UTC
@JosephLivengood thanks
CamperBot
@camperbot
Jan 08 2017 06:46 UTC
:cookie: 378 | @josephlivengood |http://www.freecodecamp.com/josephlivengood
richafig sends brownie points to @josephlivengood :sparkles: :thumbsup: :sparkles:
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 08 2017 06:46 UTC
so, arr.push(item)?
Emily Sperry
@sperrye
Jan 08 2017 06:46 UTC
I used the for loop that iterated over the array of twitch users to get their data to generate a ul of their usernames. Now I'm trying to add their streaming status to those generated list items, but it's only working on the first name on the list... my question is, is it possible to give a unique ID to each of these list items (in this case the username)(did that) and then call it later to update the online status?
Joseph Livengood
@JosephLivengood
Jan 08 2017 06:48 UTC
@TheRealChrisEdwards Correct, you can push the item to add it to the array, then shift it to pull the first item off
Emily Sperry
@sperrye
Jan 08 2017 06:48 UTC
It's currently outputting the online status only for the first user. Is it because the function that shows the status is placed outside the for loop?
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 08 2017 06:48 UTC
do i even need to use arithmetic operators for nextInLine? And I'm pretty sure that I'm trying to return arr.shift(0)?
Joseph Livengood
@JosephLivengood
Jan 08 2017 06:48 UTC
No arg for shift @TheRealChrisEdwards
But yes you can just return arr.shift();
Richard
@richafig
Jan 08 2017 06:49 UTC
testArr.shift();??
Ghulam Shabir
@ghulamshabir
Jan 08 2017 06:49 UTC
@richafig no ,arr
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 08 2017 06:49 UTC
yeah, but in the function, testArr hasn't been defined yet, wouldn't that be out of order?
Richard
@richafig
Jan 08 2017 06:49 UTC
Maybe that's my issue. Ha, thanks @ghulamshabir
CamperBot
@camperbot
Jan 08 2017 06:49 UTC
:warning: richafig already gave ghulamshabir points
richafig sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
Ghulam Shabir
@ghulamshabir
Jan 08 2017 06:50 UTC
@richafig :smile:
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 08 2017 06:51 UTC
br
*brb
gupgdown
@r1nc3w1nd
Jan 08 2017 06:52 UTC
function lookUpProfile(firstName,prop){
//code here
}
my code:
if (contacts.firstname.hasOwnProperty() && contacts.prop.hasOwnProperty(prop){
return contacts[prop];
}else{
return "No such contact"'
}
for the "profile lookup" problem
Ghulam Shabir
@ghulamshabir
Jan 08 2017 06:55 UTC
@r1nc3w1nd contacts is an array use for loop to iterate over it
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 08 2017 06:55 UTC
k, so now i have:
arr.push(item);
return arr.shift();
}
//and this is what console says:
TypeError: nativeLog is not a function. (In 'nativeLog(nativeMsg)', 'nativeLog' is 1)
//and that really doesn't help much
grantknaver
@grantknaver
Jan 08 2017 06:55 UTC
[].concat.apply([], arr); does this mean
can someone explain this code to me
Emily Sperry
@sperrye
Jan 08 2017 06:58 UTC
@r1nc3w1nd you have a typo after No such contact... extra '
gupgdown
@r1nc3w1nd
Jan 08 2017 06:59 UTC
@sperrye thanks for info. always assume no typos in my code here ahah.
CamperBot
@camperbot
Jan 08 2017 06:59 UTC
:cookie: 285 | @sperrye |http://www.freecodecamp.com/sperrye
r1nc3w1nd sends brownie points to @sperrye :sparkles: :thumbsup: :sparkles:
gupgdown
@r1nc3w1nd
Jan 08 2017 06:59 UTC
jk
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 08 2017 07:01 UTC

Sorry, this is my first time being stumped by JS section, I'm just not putting this together, think brain is melting.
Here's what I have now:
arr.push(item);
var nextInLine = arr.shift(0);

return nextInLine;

Sorry, complete:

function nextInLine(arr, item) {
// Your code here
arr.push(item);
var nextInLine = arr.shift(0);

return nextInLine; // Change this line
}

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

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

Any input much appreciated... why don't they all say "is offline"?
Joseph Livengood
@JosephLivengood
Jan 08 2017 07:03 UTC
@TheRealChrisEdwards You dont need an argument for shift
@TheRealChrisEdwards just
arr.shift();
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:04 UTC
@grantknaver it unfolds the nested array, for example [[1,2]] becomes [1,2]
Richard
@richafig
Jan 08 2017 07:04 UTC
@JosephLivengood I'm trying that too, I'm just stuck.
Bunny Vishal
@bunnyvishal6
Jan 08 2017 07:05 UTC
@sperrye try console.log(data) and view ,I think data will be an array, so you need to iterate through that array and call featch on elements data
Vijith Nair
@wizelmagnifico
Jan 08 2017 07:05 UTC
myArray should only contain [["John", 23]].
Use pop() on myArray
removedFromMyArray should only contain ["cat", 2].
grantknaver
@grantknaver
Jan 08 2017 07:05 UTC
hmm
Emily Sperry
@sperrye
Jan 08 2017 07:05 UTC
thanks @bunnyvishal6
CamperBot
@camperbot
Jan 08 2017 07:05 UTC
sperrye sends brownie points to @bunnyvishal6 :sparkles: :thumbsup: :sparkles:
:cookie: 473 | @bunnyvishal6 |http://www.freecodecamp.com/bunnyvishal6
Bunny Vishal
@bunnyvishal6
Jan 08 2017 07:06 UTC
@sperrye welcome.
Joseph Livengood
@JosephLivengood
Jan 08 2017 07:07 UTC
If you saw this in code would you understand what it means, or is there an easier way to do this?
if (updates.open) { updates.open = String(updates.open) == "true" }
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:07 UTC
@wizelmagnifico pop removes and returns last element of an array
Vijith Nair
@wizelmagnifico
Jan 08 2017 07:07 UTC
yeah got it
gupgdown
@r1nc3w1nd
Jan 08 2017 07:07 UTC
@ghulamshabir like this?:```
grantknaver
@grantknaver
Jan 08 2017 07:08 UTC
its not completely giving access to nested arrays though
gupgdown
@r1nc3w1nd
Jan 08 2017 07:08 UTC
for (var i=0; i < contacts.length;i++){
if //check stuff
}
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:08 UTC
@grantknaver it only unfolds one level of array
@r1nc3w1nd yes
llamatarianism
@llamatarianism
Jan 08 2017 07:09 UTC
@JosephLivengood that is completely and utterly pointless
it's basically
if (updates.open) {
  updates.open = updates.open;
}
Aleksandar Zdravkovski
@azdravkovski
Jan 08 2017 07:09 UTC
Hey guys. I'm probably going about this the wrong way but I can't get the last Basic Algorithm challenge (Caesar's Cipher) to work for me. Here's what I have:

function rot13(str) { // LBH QVQ VG!
  var arr = [];
  var finArr = [];
  for (var i = 0; i < str.length; i++) {
  var uni = str.charCodeAt(i);
  arr.push(uni);
  }
  for (var n = 0; n < arr.length; n++) {
    arr[n] -= 13;
  }
  for (var j = 0; j < arr.length; j++) {
    var letter = String.fromCharCode(arr[j]);
    finArr.push(letter);
  }
  return finArr.join('');
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Joseph Livengood
@JosephLivengood
Jan 08 2017 07:09 UTC
@llamatarianism No its extremely important, it changes a string to a boolean
Aleksandar Zdravkovski
@azdravkovski
Jan 08 2017 07:10 UTC
I'm getting something like F8EE C5DE CAM6
which is close, but no cigar
XD
Joseph Livengood
@JosephLivengood
Jan 08 2017 07:10 UTC
Potentially I'll leave a comment on that line. lol
grantknaver
@grantknaver
Jan 08 2017 07:10 UTC
how would you unfold multiple levels?
var myNewArray = [].concat.apply([][], arr);
I think that is wrong though
dsillydude
@dsillydude
Jan 08 2017 07:11 UTC
hey guys i need help i cant figure it out

// Setup
function phoneticLookup(val) {

// Only change code below this line

val = {
alpha:"Adams",
bravo: "Boston",
charlie:"chacago",
delta:"Denver",
echo:"Easy",
foxtrot:"Frank",

};

answer = val.alpha;

// Only change code above this line

}

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

Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:11 UTC
@azdravkovski you are supposed to convert A-M into N-Z and vice versa
dsillydude
@dsillydude
Jan 08 2017 07:12 UTC
how do i finish that?
llamatarianism
@llamatarianism
Jan 08 2017 07:12 UTC
@JosephLivengood if updates.open is a string
why do you bother converting it to a string
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 08 2017 07:12 UTC

close??...

function nextInLine(arr, item) {
// Your code here
arr.push(item);
var nextInLine = arr.shift(0);

return nextInLine; // Change this line
}

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

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

llamatarianism
@llamatarianism
Jan 08 2017 07:12 UTC
why do String(updates.open) == "true"? why not just do updates.open == "true"?
Joseph Livengood
@JosephLivengood
Jan 08 2017 07:12 UTC
@llamatarianism Req.query is always a string when you get it
Aleksandar Zdravkovski
@azdravkovski
Jan 08 2017 07:12 UTC
@ghulamshabir Right. So I thought I'd only need to shift the letters by 13 characters
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:12 UTC
@grantknaver no that won't work
llamatarianism
@llamatarianism
Jan 08 2017 07:12 UTC
anyway
the if statement is pointless regardless
gupgdown
@r1nc3w1nd
Jan 08 2017 07:13 UTC
for (var i=0; i < contacts.length;i++){
  if (contacts.firstname === true && contacts.prop.hasOwnPropery()){
    return contacts.prop;
  } else {
  return "No such contact";
  }
// Only change code above this line
}}
Emily Sperry
@sperrye
Jan 08 2017 07:13 UTC
it is iterating over each one.... I changed it to append but now its showing all status updates in one user's list item. example right now it says freecodecamp is offline is offline is offline is online is offline... lol
llamatarianism
@llamatarianism
Jan 08 2017 07:13 UTC
could just be updates.open = updates.open == "true"
gupgdown
@r1nc3w1nd
Jan 08 2017 07:13 UTC
works for "no such contact" but nothing else
grantknaver
@grantknaver
Jan 08 2017 07:13 UTC
ya it is erroring out
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:13 UTC
@azdravkovski no, add 13 as well for a-m letters
Joseph Livengood
@JosephLivengood
Jan 08 2017 07:13 UTC
@llamatarianism Not in context, without it, it would set an empty string to false
llamatarianism
@llamatarianism
Jan 08 2017 07:14 UTC
if the point of the code is to convert a string to a boolean
surely that's what you want
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:15 UTC
@azdravkovski you need add 13 to A-M charcodes and subtract 13 from N-Z charcodes and don't do maths for other characters charcodes
grantknaver
@grantknaver
Jan 08 2017 07:16 UTC
how do you go about unfolding multiple layers @ghulamshabir
Aleksandar Zdravkovski
@azdravkovski
Jan 08 2017 07:16 UTC
@ghulamshabir I see now. I need to work out the code for that. It's not as straightforward as I thought.
@ghulamshabir Thanks.
CamperBot
@camperbot
Jan 08 2017 07:16 UTC
azdravkovski sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1661 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:17 UTC
@grantknaver I think you can use loop over arr, never done like that
grantknaver
@grantknaver
Jan 08 2017 07:17 UTC
tried that ug ya
do you know what the two sets of brackets mean in...
var myNewArray = [].concat.apply([], arr);
Wilfredo-Ho
@Wilfredo-Ho
Jan 08 2017 07:18 UTC
anyone help me with translating decimal numbers to Roman numberals?
Ben Carp
@carpben
Jan 08 2017 07:20 UTC
Hi everryone, the task is to filter all falsy values. For some reason I'm failing to filter the NaN value.
llamatarianism
@llamatarianism
Jan 08 2017 07:21 UTC
@carpben are you trying to do if (something === NaN)?
because that doesn't work
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:21 UTC
@grantknaver first [] is just there to call concat
llamatarianism
@llamatarianism
Jan 08 2017 07:21 UTC
nothing is equal to NaN, not even NaN
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:21 UTC
@grantknaver actuall call is like this Array.prototype.concat
Ben Carp
@carpben
Jan 08 2017 07:22 UTC

Hi everryone, the task is to filter all falsy values. For some reason I'm failing to filter the NaN value. Hi everryone, the task is to filter all falsy values. For some reason I'm failing to filter the NaN value.
function bouncer(arr) {
// Don't show a false ID to this bouncer.
function cond (value){
return (value!==false) && (value!==null) && (value!==0) && (value!=="") && (value!==undefined) && (value !== NaN);
}
return arr.filter(cond);
}

console.log(bouncer([false, null, 0, NaN, undefined, ""]))
console.log(bouncer([1, null, NaN, 2, undefined]));
bouncer([7, "ate", "", false, 9]);

llamatarianism
@llamatarianism
Jan 08 2017 07:22 UTC
@grantknaver the first empty array is necessary because Array.prototype.concat is a method of arrays
the second empty array is kind of hard to explain
it's what becomes this inside the call to Array.prototype.concat
here's a demonstration:
Vijith Nair
@wizelmagnifico
Jan 08 2017 07:22 UTC
Instructions
Declare a local variable myVar inside myLocalScope. Run the tests and then follow the instructions commented out in the editor.
Ben Carp
@carpben
Jan 08 2017 07:23 UTC
Again from the beginning. I'm trying to use the filter function to eliminate all falty values from an array. For some reason I fail to eliminate the NaN value.
grantknaver
@grantknaver
Jan 08 2017 07:23 UTC
@llamatarianism thanks
CamperBot
@camperbot
Jan 08 2017 07:23 UTC
grantknaver sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1458 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Ben Carp
@carpben
Jan 08 2017 07:23 UTC
blob
Here is the screenshot.
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:23 UTC
@grantknaver and second [] is for combining contents other array to []
llamatarianism
@llamatarianism
Jan 08 2017 07:24 UTC
function Foo() {}

Foo.prototype.bar = function(arg1, arg2) {
  console.log("arg1:", arg1);
  console.log("arg2:", arg2);
  console.log("this:", this);
}

Foo.prototype.bar.apply("bingo", [6, 7]);
// arg1: 6
// arg2: 7
// this: bingo
__SharifTarver__
@Sharifdesigns22
Jan 08 2017 07:24 UTC

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

var myStr = "My crazy"+ myAdjective + myNoun + myVerb + "the ground"+ myAdverb ;
// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("cat", "little", "hit", "slowly");
wordBlanks("dog", "big", "ran", "quickly");``` word blanks challenge?

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

var myStr = "My crazy"+ myAdjective + myNoun + myVerb + "the ground"+ myAdverb ;
  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("cat", "little", "hit", "slowly");
wordBlanks("dog", "big", "ran", "quickly");
grantknaver
@grantknaver
Jan 08 2017 07:25 UTC
hmm
llamatarianism
@llamatarianism
Jan 08 2017 07:25 UTC
@Sharifdesigns22 you don't have spaces between the words
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:25 UTC
@carpben try value === value for NaN
llamatarianism
@llamatarianism
Jan 08 2017 07:25 UTC
and you're returning result, not myStr
myStr will be something like this: "My crazylittlecathitthe groundslowly"
and you're not even returning it, you're just returning result, which is an empty string
Wilfredo-Ho
@Wilfredo-Ho
Jan 08 2017 07:26 UTC
@carpben change the "return value = ..." to "return value" in the function
grantknaver
@grantknaver
Jan 08 2017 07:26 UTC
@llamatarianism you talking to me
llamatarianism
@llamatarianism
Jan 08 2017 07:26 UTC
@grantknaver nah, talking to @Sharifdesigns22
__SharifTarver__
@Sharifdesigns22
Jan 08 2017 07:26 UTC
ahhh okay, and for spaces am i ending the string with a semicolon for spaces?
grantknaver
@grantknaver
Jan 08 2017 07:26 UTC
oh ok
Wilfredo-Ho
@Wilfredo-Ho
Jan 08 2017 07:27 UTC
@carpben all metioned above is boolean false
llamatarianism
@llamatarianism
Jan 08 2017 07:27 UTC
@Sharifdesigns22 just put spaces between the words, like this:
var myAdjective = "big";
var myNoun = "dog";

var noSpacesWhichIsWrong = myAdjective + myNoun; // "bigdog"
var hasSpacesWhichIsCorrect = myAdjective + " " + myNoun; // "big dog"
grantknaver
@grantknaver
Jan 08 2017 07:29 UTC
@llamatarianism can I ask you one more question
llamatarianism
@llamatarianism
Jan 08 2017 07:29 UTC
@grantknaver sure
I got nowhere else to be
grantknaver
@grantknaver
Jan 08 2017 07:29 UTC
lol ok
llamatarianism
@llamatarianism
Jan 08 2017 07:29 UTC
it's 7:30 am on a sunday and my dog's dead
grantknaver
@grantknaver
Jan 08 2017 07:29 UTC
fuck sorry man
...
__SharifTarver__
@Sharifdesigns22
Jan 08 2017 07:29 UTC
ahh perfect, I'll pst an update momentarily
llamatarianism
@llamatarianism
Jan 08 2017 07:29 UTC
nah go ahead with the question
grantknaver
@grantknaver
Jan 08 2017 07:30 UTC
well...
llamatarianism
@llamatarianism
Jan 08 2017 07:30 UTC
as long as I surround myself with low-quality memes, I won't cry
__SharifTarver__
@Sharifdesigns22
Jan 08 2017 07:30 UTC
sorry to heat about your dog @llamatarianism
llamatarianism
@llamatarianism
Jan 08 2017 07:30 UTC
thanks @Sharifdesigns22
CamperBot
@camperbot
Jan 08 2017 07:30 UTC
llamatarianism sends brownie points to @sharifdesigns22 :sparkles: :thumbsup: :sparkles:
:cookie: 148 | @sharifdesigns22 |http://www.freecodecamp.com/sharifdesigns22
grantknaver
@grantknaver
Jan 08 2017 07:31 UTC
Im trying to flatten an array
llamatarianism
@llamatarianism
Jan 08 2017 07:31 UTC
alright
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 08 2017 07:31 UTC
sorry to everyone, Stand in Line literally required 2 lines of code, going to bed now, thanks to @ghulamshabir , @JosephLivengood & @HeebieGeeBee
CamperBot
@camperbot
Jan 08 2017 07:31 UTC
therealchrisedwards sends brownie points to @ghulamshabir and @josephlivengood and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 380 | @josephlivengood |http://www.freecodecamp.com/josephlivengood
:cookie: 478 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:star2: 1662 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
grantknaver
@grantknaver
Jan 08 2017 07:31 UTC
and I am trying gain concat into the main array more than one layer down indexs, but after 3 and half hours Im stuck
Idk I have tried everyting
here is what I got
llamatarianism
@llamatarianism
Jan 08 2017 07:32 UTC
@grantknaver just do it repeatedly until the array is flat
grantknaver
@grantknaver
Jan 08 2017 07:33 UTC
unction steamrollArray(arr) {
  // I'm a steamroller, baby
 for(var i =0; i < arr.length; i++){

   var myNewArray = [].concat.apply([], arr);
   console.log(myNewArray);
 }




 //console.log(arr[2][1][0]);

}

steamrollArray([1, [2], [3, [[4]]]]);
I dont know how to do that
llamatarianism
@llamatarianism
Jan 08 2017 07:33 UTC
pseudocode is something like this:
def flatten(array)
    if array is flat
        return array
    else
        return flatten(flatten-one-layer(array))
I did this
if (array.every(Array.isArray)) ...
grantknaver
@grantknaver
Jan 08 2017 07:34 UTC
i have read that but it didn't help
that just checks if it is an object
llamatarianism
@llamatarianism
Jan 08 2017 07:35 UTC
no it doesn't, it checks if it's an array
and array.every(f) makes sure that f(x) is true for every x in the array
actually wait
grantknaver
@grantknaver
Jan 08 2017 07:36 UTC
cant an array have only one index?
llamatarianism
@llamatarianism
Jan 08 2017 07:36 UTC
I think I used array.some(Array.isArray) actually
an array can have any number of elements in it. it doesn't effect how every or some work. they still work fine.
array.some(f) makes sure that f(x) is true for at least one x in the array
so if array.some(Array.isArray) is true, that means the array isn't flat
grantknaver
@grantknaver
Jan 08 2017 07:38 UTC
some tests an index against an element
how does it check to see if it isn't flat
llamatarianism
@llamatarianism
Jan 08 2017 07:39 UTC
if the array is flat
then that means that none of the items of the array are arrays.
if array.some(Array.isArray) is true, then one or more of the items in array is an array
so it's not flat
grantknaver
@grantknaver
Jan 08 2017 07:39 UTC
oh
llamatarianism
@llamatarianism
Jan 08 2017 07:39 UTC
if it's false, then there are no arrays inside array, so it is
grantknaver
@grantknaver
Jan 08 2017 07:40 UTC
so it would look something like this
hmm
Ben Carp
@carpben
Jan 08 2017 07:44 UTC
Can anyone help me with the question I posted at 14:23?
llamatarianism
@llamatarianism
Jan 08 2017 07:44 UTC
@carpben 2 people already did
you can't just do value !== NaN
nothing is equal to NaN, not even NaN
Ben Carp
@carpben
Jan 08 2017 07:45 UTC
@llamatarianism strange. I didn't see any notification.
llamatarianism
@llamatarianism
Jan 08 2017 07:45 UTC
this is how you test for NaN
function isNaNButItActuallyWorks(x) {
  return x !== x;
}
isNaNButItActuallyWorks(NaN); // true
isNaNButItActuallyWorks(anythingElse); // false
you could also just do this
bouncer=$=>$.filter(_=>_)
devpaaji
@devpaaji
Jan 08 2017 07:47 UTC
console.log("1 && 2 = "+(1 && 2));
Ben Carp
@carpben
Jan 08 2017 07:47 UTC
@llamatarianism haha. Coolbut a little strange. Anyway good enough.
devpaaji
@devpaaji
Jan 08 2017 07:47 UTC
why it gives 2
@carpben
@grantknaver
llamatarianism
@llamatarianism
Jan 08 2017 07:48 UTC
@devpaaji this is how && works:
function and(x, y) {
  if (x) {
    return y;
  }
  return x;
}
1 is truthy, so it returns y, which is 2
|| works similarly:
function or(x, y) {
  if (x) {
    return x;
  }
  return y;
}
so:
1 && 2 = 2
0 && 2 = 0

1 || 2 = 1
0 || 2 = 2
grantknaver
@grantknaver
Jan 08 2017 07:50 UTC
Ok this is where I ended up still doesn't like it
devpaaji
@devpaaji
Jan 08 2017 07:50 UTC
still not clear
grantknaver
@grantknaver
Jan 08 2017 07:50 UTC
  var myNewArray;
 for(var i =0; i < arr.length; i++){
   if(arr.some(Array.isArray)){
      myNewArray = [].concat.apply([], arr); 
   }else {
     return myNewArray;
   }


 }
devpaaji
@devpaaji
Jan 08 2017 07:50 UTC
trying to understand
llamatarianism
@llamatarianism
Jan 08 2017 07:50 UTC
@grantknaver don't use a for loop
use a while loop:
def flatten(array)
    while array isn't flat
        [].concat.apply([], array)
    return array
(^ pseudocode)
@devpaaji look at the code I posted above
the and and or functions work just like && and || do
devpaaji
@devpaaji
Jan 08 2017 07:51 UTC
1 && 2 = 2
0 && 2 = 0
Ben Carp
@carpben
Jan 08 2017 07:51 UTC
THANKS @llamatarianism
CamperBot
@camperbot
Jan 08 2017 07:51 UTC
carpben sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1459 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
llamatarianism
@llamatarianism
Jan 08 2017 07:52 UTC
@carpben no problem
devpaaji
@devpaaji
Jan 08 2017 07:52 UTC
it checks for bool val
llamatarianism
@llamatarianism
Jan 08 2017 07:52 UTC
no, && and || work on anything
devpaaji
@devpaaji
Jan 08 2017 07:52 UTC
0 is false
llamatarianism
@llamatarianism
Jan 08 2017 07:52 UTC
falsy, but basically, yeah
Mrdaniels3
@Mrdaniels3
Jan 08 2017 07:52 UTC
looking for help with Global Scope and Functions
devpaaji
@devpaaji
Jan 08 2017 07:53 UTC
then how 0 and 2 == 0
you mean 0 is false and 2 is false
llamatarianism
@llamatarianism
Jan 08 2017 07:53 UTC
because 0 is falsy
and falsy thing && truthy thing = falsy thing
devpaaji
@devpaaji
Jan 08 2017 07:53 UTC
so false
llamatarianism
@llamatarianism
Jan 08 2017 07:53 UTC
2 isn't falsy
2 is truthy
any number that isn't equal to 0 is truthy
devpaaji
@devpaaji
Jan 08 2017 07:53 UTC
like 1 is truthy
Mrdaniels3
@Mrdaniels3
Jan 08 2017 07:54 UTC

`var myGlobal = 10;// Declare your variable here
oopsGlobal();

function fun1() {
oopsGlobal=5; // Assign 5 to oopsGlobal Here

}

console.log()` could someone check out my code please

devpaaji
@devpaaji
Jan 08 2017 07:54 UTC
0 || 1 = 1
why is this 1
false or true
so or checks if one is correct
llamatarianism
@llamatarianism
Jan 08 2017 07:55 UTC
this is the truth table for ||:
true  || false = true
false || true  = true
true  || true  = true
false || false = false
just replace true and false with 1 and 0 and it works the same way
devpaaji
@devpaaji
Jan 08 2017 07:55 UTC
1 && 2 = 2
both are true here
why 2
llamatarianism
@llamatarianism
Jan 08 2017 07:55 UTC
because it's the second thing
if it was 2 && 1, it'd return 1
Adel
@AdelMahjoub
Jan 08 2017 07:56 UTC
At line 153, I thought to translate the canvas to the camera x,y position to make the scrolling, but it works when translating it to -camera.x, -camera.y http://codepen.io/SultanCodeCamper/pen/KapYmO?editors=0010
llamatarianism
@llamatarianism
Jan 08 2017 07:56 UTC
it returns the second thing because that way it doesn't have to bother checking whether it's truthy or not
truthy thing && other thing = other thing
whether other thing is truthy or falsy
devpaaji
@devpaaji
Jan 08 2017 07:56 UTC
@devpaaji
what is diff between local storage and cookie
cookies can be used to store and retrieve data from web server
where as local storage cannot
correct
you mean anything apart from 0 is truthy
why other thing
1 and 2 are both truthy?
llamatarianism
@llamatarianism
Jan 08 2017 07:58 UTC
because it doesn't matter whether 2 is truthy or falsy
1 && 2 = 2 and 1 && 0 = 0
if the first thing is truthy, the second thing always gets returned
whether or not that second thing is truthy
devpaaji
@devpaaji
Jan 08 2017 07:58 UTC
ohk
var a={},
    b={key:'b'},
    c={key:'c'};

a[b]=123;
a[c]=456;

console.log(a[b]); // why 456
grantknaver
@grantknaver
Jan 08 2017 07:59 UTC
nope still nothing
function steamrollArray(arr) {
  // I'm a steamroller, baby


 while (arr.some(Array.isArray)){
        [].concat.apply([], arr);
 }
 return arr;

 //console.log(arr[2][1][0]);

}

steamrollArray([1, [2], [3, [[4]]]]);
llamatarianism
@llamatarianism
Jan 08 2017 08:00 UTC
@devpaaji the keys in objects are always strings
so it's not actually doing a[b] = 123 and a[c] = 456
it's doing
a[String(b)] = 123;
a[String(c)] = 456;
which is like doing:
a['[object Object]'] = 123;
a['[object Object]'] = 456;
Rafa Huelin
@rafahuelin
Jan 08 2017 08:01 UTC

good morning!

true && true = true
true && false = false
false && true = false
false && false = false

&& restricts to all the conditions to be true

llamatarianism
@llamatarianism
Jan 08 2017 08:01 UTC
if you want to have b and c as separate entries, use a map
Ghulam Shabir
@ghulamshabir
Jan 08 2017 08:01 UTC
@rafahuelin Morning :wave:
devpaaji
@devpaaji
Jan 08 2017 08:02 UTC
well noted thanks @llamatarianism
CamperBot
@camperbot
Jan 08 2017 08:02 UTC
devpaaji sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
Rafa Huelin
@rafahuelin
Jan 08 2017 08:02 UTC
good morning @ghulamshabir :)
CamperBot
@camperbot
Jan 08 2017 08:02 UTC
:star2: 1460 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
devpaaji
@devpaaji
Jan 08 2017 08:02 UTC
Why is window.onload event used? What happens if DOM manipulation code is not written inside onload method?
Ghulam Shabir
@ghulamshabir
Jan 08 2017 08:02 UTC
@rafahuelin :smile: are you back ?
grantknaver
@grantknaver
Jan 08 2017 08:02 UTC
am I doing the while loop wrong I tried your p. code
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 08:02 UTC
anyone got good understanding of this twich api work around?
llamatarianism
@llamatarianism
Jan 08 2017 08:02 UTC
let a = new Map();
const b = { key: 'b' };
const c = { key: 'c' };

a.set(b, 123);
a.set(c, 456);

console.log(a.get(b)); // 123
console.log(a.get(c)); // 456
Rafa Huelin
@rafahuelin
Jan 08 2017 08:02 UTC
@ghulamshabir back on business :)
devpaaji
@devpaaji
Jan 08 2017 08:03 UTC
we have Map in JS
llamatarianism
@llamatarianism
Jan 08 2017 08:03 UTC
@grantknaver concat doesn't mutate arr
you need to do:
Ghulam Shabir
@ghulamshabir
Jan 08 2017 08:03 UTC
@rafahuelin :laughing: welcome :cake:
llamatarianism
@llamatarianism
Jan 08 2017 08:03 UTC
arr = [].concat.apply([], arr); inside the loop
devpaaji
@devpaaji
Jan 08 2017 08:03 UTC
(function(x) {
    return (function(y) {
        console.log(x);
    })(2)
})(1);
// why it gives 1
llamatarianism
@llamatarianism
Jan 08 2017 08:04 UTC
that's basically the same as doing this:
var x = 1;
var y = 2;

console.log(x); // 1
that's why
devpaaji
@devpaaji
Jan 08 2017 08:04 UTC
why use closures
llamatarianism
@llamatarianism
Jan 08 2017 08:04 UTC
shrug
devpaaji
@devpaaji
Jan 08 2017 08:04 UTC
here
llamatarianism
@llamatarianism
Jan 08 2017 08:04 UTC
there's no real reason in that specific example
grantknaver
@grantknaver
Jan 08 2017 08:04 UTC
ok
llamatarianism
@llamatarianism
Jan 08 2017 08:05 UTC
they're useful in other cases to have local variables that you only use once
grantknaver
@grantknaver
Jan 08 2017 08:05 UTC
Im going to reaccount what I think we did
devpaaji
@devpaaji
Jan 08 2017 08:06 UTC
for (var i = 0; i < 5; i++) {
  setTimeout(function() { console.log(i); }, i * 1000 );
}
giving 5
not -0, 1, 2, 3, 4
grantknaver
@grantknaver
Jan 08 2017 08:08 UTC
so basically we searched arr with some(). With the Array.isArray parameter every time an array was found concat was used to added the arr var to update the arr array. Correct?
Rafa Huelin
@rafahuelin
Jan 08 2017 08:08 UTC
Hi guys I'm working on the wikipedia viewer project and I'm finding a problem after typing a search and pressing enter, the search input area moves up, but if I click on it it moves down again. does anybody know why is this happening?
http://codepen.io/rafahuelin/pen/ygNKzQ?editors=0111
grantknaver
@grantknaver
Jan 08 2017 08:09 UTC
hopefully I understand now. I think I do
I just dont understand arr.concat.apply([], arr); completely
llamatarianism
@llamatarianism
Jan 08 2017 08:11 UTC
obj.method.apply(obj, [arg1, arg2, arg3]) is the same as obj.method(arg1, arg2, arg3)
so [].concat.apply([], [[1, [2]], [3]]) is the same as [].concat([1, [2]], [3])
the reason that you need to pass in obj twice is because apply works with any function, not just methods
function notAMethod() {
  console.log(this);
}

notAMethod.apply(97.1, []); // Number { [[PrimitiveValue]]: 97.1 }
grantknaver
@grantknaver
Jan 08 2017 08:13 UTC
oooooooooooooooooooooooooooooo OK :)
Faik Abbaszadeh
@Faikabbaszadeh
Jan 08 2017 08:14 UTC
Hi , someAdjective , someAdjective should be set to a string at least 3 characters long what is that?
how to be that?
llamatarianism
@llamatarianism
Jan 08 2017 08:14 UTC
@Faikabbaszadeh
"a"    // 1 character long
"ab"   // 2 characters long
"abc"  // 3 characters long
"abcd" // 4 characters long
grantknaver
@grantknaver
Jan 08 2017 08:15 UTC
@llamatarianism thanks
CamperBot
@camperbot
Jan 08 2017 08:15 UTC
grantknaver sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:warning: grantknaver already gave llamatarianism points
electronicdreamplant
@electronicdreamplant
Jan 08 2017 08:15 UTC
Can someone help with what I think may be a bug in the "Return a Value from a Function with Return" challenge?
I followed the example to enter my code;

function timesFive(num) {
return num * 5;
}

var answer = timesFive(2);

But the console displays the result as 25 and marks it as correct
llamatarianism
@llamatarianism
Jan 08 2017 08:17 UTC
that's not a bug
electronicdreamplant
@electronicdreamplant
Jan 08 2017 08:17 UTC
What did I do wrong?
llamatarianism
@llamatarianism
Jan 08 2017 08:17 UTC
it doesn't care about this stuff:
var answer = timesFive(2);
otherwise you could just cheat all the challenges by typing in this:
var answer = 25;
it runs its own tests on your function
your function works fine, so it passed the challenge
electronicdreamplant
@electronicdreamplant
Jan 08 2017 08:18 UTC
OK, was just following the example in the text
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 08:18 UTC
@rafahuelin you have loads of css and js making the search box move about
electronicdreamplant
@electronicdreamplant
Jan 08 2017 08:18 UTC
function plusThree(num) {
return num + 3;
}
var answer = plusThree(5); // 8
Also, it gives the value (25) so I don't see where it took the value from for the calculation
llamatarianism
@llamatarianism
Jan 08 2017 08:19 UTC
it did timesFive(5)
that's one of the tests
grantknaver
@grantknaver
Jan 08 2017 08:20 UTC
@llamatarianism
llamatarianism
@llamatarianism
Jan 08 2017 08:20 UTC
@grantknaver yeah?
electronicdreamplant
@electronicdreamplant
Jan 08 2017 08:20 UTC
OK, so it is supplying the values to test and not me?
grantknaver
@grantknaver
Jan 08 2017 08:20 UTC
I follow your explanation so I went back into the code to try to remove
apply and return arr this way
llamatarianism
@llamatarianism
Jan 08 2017 08:20 UTC
@electronicdreamplant yeah
Rafa Huelin
@rafahuelin
Jan 08 2017 08:21 UTC
@HeebieGeeBee that's the idea :)
But what is causing that problem? I think that the submit or something about the forms that I'm not aware of is causing this problem
grantknaver
@grantknaver
Jan 08 2017 08:21 UTC
arr = arr.concat.( arr);
why doesn't this work
electronicdreamplant
@electronicdreamplant
Jan 08 2017 08:21 UTC
Thanks @llamatarianism appreciate the guidance
CamperBot
@camperbot
Jan 08 2017 08:21 UTC
electronicdreamplant sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1461 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
grantknaver
@grantknaver