These are chat archives for FreeCodeCamp/HelpJavaScript

8th
Jan 2017
Gavriloski
@Gavriloski
Jan 08 2017 00:01
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
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

@Chrono79 ah! Ok, tnx! So

 processed = processArg(7);

(7) is the argument

John P Penaloza
@johnpyp
Jan 08 2017 00:02
@cjljohnson Ok. I could also push all the params into an array and print that, correct?
Diego Mayer
@Chrono79
Jan 08 2017 00:02
yes, exactly @beers01
Jamie Lipschitz
@Jlipschitz
Jan 08 2017 00:02
@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
@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
@Chrono79 damn english :D i'm learning to languages at same time :O
Diego Mayer
@Chrono79
Jan 08 2017 00:03
@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
@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
@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
@cesarecaravaggio yes but writing cases is more compact
Gavriloski
@Gavriloski
Jan 08 2017 00:05
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
@Gavriloski what's the difference between 'a' and "a"?, they're both strings with length = 1
Gavriloski
@Gavriloski
Jan 08 2017 00:05
@Chrono79 No "A" is threated like string 'A' like single char
babajide odusola
@cesarecaravaggio
Jan 08 2017 00:06
@cjljohnson got you. ty for clearing that up
CamperBot
@camperbot
Jan 08 2017 00:06
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
@Gavriloski so "AB" and 'AB' are different?
Jamie Lipschitz
@Jlipschitz
Jan 08 2017 00:08
@Gavriloski they are both treated as strings despite single or double
Gavriloski
@Gavriloski
Jan 08 2017 00:08
@Chrono79 Because it's javascript. I was thinking in java or c++ or something more "strict"
Diego Mayer
@Chrono79
Jan 08 2017 00:08
@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
@Chrono79 My fault , not intending to confuse
Diego Mayer
@Chrono79
Jan 08 2017 00:10
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
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
I just have ONE QUESTION today. Someone please answer it.
Please
Please
Please
Jamie Lipschitz
@Jlipschitz
Jan 08 2017 00:16
shoot
Mike
@MikeJSchorah
Jan 08 2017 00:17
@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
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
@MikeJSchorah Don't be coy. Just ask the question.
Benjamin-Coleman
@Benjamin-Coleman
Jan 08 2017 00:19
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
@tjscollins Sure. Here is the question...
Benjamin-Coleman
@Benjamin-Coleman
Jan 08 2017 00:20
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
@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

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

@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

@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
Has anyone looked at that article?
Tyler Collins
@tjscollins
Jan 08 2017 00:23
@MikeJSchorah ...and the question is...?
Mike
@MikeJSchorah
Jan 08 2017 00:24
@tjscollins Is it true?
emr53f
@emr53f
Jan 08 2017 00:26
@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
emr53f sends brownie points to @gavriloski :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for gavriloski
Tyler Collins
@tjscollins
Jan 08 2017 00:27

@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
@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
@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
@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
@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
@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
@Gavriloski the code I pasted above works for every instance but "almostomla"
Gavriloski
@Gavriloski
Jan 08 2017 00:30
@emr53f it refuses to do replace for me idk why console in chrome is doing it fine, gonna try to refresh whole thing
John P Penaloza
@johnpyp
Jan 08 2017 00:31
@cjljohnson @Jlipschitz thanks for the help
CamperBot
@camperbot
Jan 08 2017 00:31
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
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
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
@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
@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
@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

@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
@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
@simonekj contacts is an array, you need to use a loop to access a single contact
emr53f
@emr53f
Jan 08 2017 00:36
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
ty @Chrono79
CamperBot
@camperbot
Jan 08 2017 00:37
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
@emr53f you need to also keep numbers
emr53f
@emr53f
Jan 08 2017 00:38
@Chrono79 this seemingly works with the examples that have numbers
Diego Mayer
@Chrono79
Jan 08 2017 00:39
@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
@Chrono79 How to avoid lowercase for numbers ?
Jamie Lipschitz
@Jlipschitz
Jan 08 2017 00:40
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
@Gavriloski didn't understand, could you elaborate that question a little more?
emr53f
@emr53f
Jan 08 2017 00:41
@Chrono79 it's passing the challenge, but you're right, it "shouldn't" work. hmmmmmmmmmmmmmm
cjljohnson
@cjljohnson
Jan 08 2017 00:41
@Gavriloski numbers don't have a lower case?
Mike
@MikeJSchorah
Jan 08 2017 00:41
@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
@Chrono79 Nevermind I fucked something else
Diego Mayer
@Chrono79
Jan 08 2017 00:42
ok then :P
Gavriloski
@Gavriloski
Jan 08 2017 00:42
@Chrono79 thanks anyway
CamperBot
@camperbot
Jan 08 2017 00:42
gavriloski sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3080 | @chrono79 |http://www.freecodecamp.com/chrono79
Mike
@MikeJSchorah
Jan 08 2017 00:42
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
mikejschorah sends brownie points to @jlipschitz :sparkles: :thumbsup: :sparkles:
:cookie: 216 | @jlipschitz |http://www.freecodecamp.com/jlipschitz
emr53f
@emr53f
Jan 08 2017 00:43
@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
Btw when I copy paste code here how to format it in that nice window ?
Diego Mayer
@Chrono79
Jan 08 2017 00:43
Click on more info below
CamperBot
@camperbot
Jan 08 2017 00:43
:bulb: to format code use backticks! ``` more info
emr53f
@emr53f
Jan 08 2017 00:44
@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
@emr53f yea I know thanks
CamperBot
@camperbot
Jan 08 2017 00:44
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
@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
@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
@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
@emr53f is your code exactly the same as before?
emr53f
@emr53f
Jan 08 2017 00:47
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
@emr53f your loop only runs once, comparing only the first letter
andercodder
@andercodder
Jan 08 2017 00:48
guys
emr53f
@emr53f
Jan 08 2017 00:49
@Chrono79 wait it doesn't loop until straightarray[i] doesnt match reversearray[i]?
Mike
@MikeJSchorah
Jan 08 2017 00:49
@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
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
@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
@MikeJSchorah that's a good outlook to have :+1:
andercodder
@andercodder
Jan 08 2017 00:51

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
@Chrono79 thank you!! really appreciate it.
CamperBot
@camperbot
Jan 08 2017 00:52
:star2: 3081 | @chrono79 |http://www.freecodecamp.com/chrono79
emr53f sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Mike
@MikeJSchorah
Jan 08 2017 00:52
@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
@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
ok mike
Mike
@MikeJSchorah
Jan 08 2017 00:55
@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
@andercodder what's your question?
andercodder
@andercodder
Jan 08 2017 00:57
@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
@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
yes tis this
Manish Giri
@Manish-Giri
Jan 08 2017 00:59
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
hey guys, i need help with Check for Palindromes challenge
Manish Giri
@Manish-Giri
Jan 08 2017 01:00
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
it will be like arr[].push(1);
review the syntax
Sunray
@hisunray
Jan 08 2017 01:02
anyone Check for Palindromes challenge
help! please.
i can't pass the challenge
Yintii
@Yintii
Jan 08 2017 01:03
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
@Yintii use your object and the function parameter to set result value before returning it
Gavriloski
@Gavriloski
Jan 08 2017 01:04

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

// 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
@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
@Gavriloski could you provide feedback instead of the answer? that's not really helping him
Awcsome
@Awcsome
Jan 08 2017 01:07
@Chrono79 thanks I'll have a look now
CamperBot
@camperbot
Jan 08 2017 01:07
awcsome sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3082 | @chrono79 |http://www.freecodecamp.com/chrono79
Gavriloski
@Gavriloski
Jan 08 2017 01:07
@hisunray That is called RegEx
Sunray
@hisunray
Jan 08 2017 01:07

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
@hisunray Google it not master of it
Jin Choi
@JiniHendrix
Jan 08 2017 01:08
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

@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
@Chrono79 So you are saying I can just apply tolowercase on whole string?
Diego Mayer
@Chrono79
Jan 08 2017 01:08
@Gavriloski yes
Yintii
@Yintii
Jan 08 2017 01:08
I'm not quite getting itt
Diego Mayer
@Chrono79
Jan 08 2017 01:09
Awcsome
@Awcsome
Jan 08 2017 01:09
@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
@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
@Gavriloski i got it. thanks mate
CamperBot
@camperbot
Jan 08 2017 01:10
hisunray sends brownie points to @gavriloski :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for gavriloski
Awcsome
@Awcsome
Jan 08 2017 01:10
@Chrono79 I've changed it
@Chrono79 but it still doesn't work
Diego Mayer
@Chrono79
Jan 08 2017 01:10
@Awcsome show me your code now
Awcsome
@Awcsome
Jan 08 2017 01:11
if (a || b < 0){
return undefined;
}
Diego Mayer
@Chrono79
Jan 08 2017 01:11
@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
@Manish-Giri just one more question how shoud be return
Stephen James
@sjames1958gm
Jan 08 2017 01:11
@Awcsome That is a OR (b < 0) you need < 0 for both variables
Yintii
@Yintii
Jan 08 2017 01:11
@Chrono79 Got it - Spanks :)
Manish Giri
@Manish-Giri
Jan 08 2017 01:12
@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
@sjames1958gm do i use a comma?
(a < 0, b<0)?
Yintii
@Yintii
Jan 08 2017 01:12
@chrono thanks
CamperBot
@camperbot
Jan 08 2017 01:12
yintii sends brownie points to @chrono :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for chrono
Yintii
@Yintii
Jan 08 2017 01:13
@Chrono79 thanks I mean damn
CamperBot
@camperbot
Jan 08 2017 01:13
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
:+1:
Jamie Lipschitz
@Jlipschitz
Jan 08 2017 01:13
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

@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
thanks much @Jlipschitz
CamperBot
@camperbot
Jan 08 2017 01:13
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
@andercodder what is the purpose of this?
arr = [];
item = 1;
andercodder
@andercodder
Jan 08 2017 01:15
is not this the first line it ask me to do ?
Manish Giri
@Manish-Giri
Jan 08 2017 01:15
no
Oranjoose
@Oranjoose
Jan 08 2017 01:15
Can others see my progress if they have the link to my profile?
andercodder
@andercodder
Jan 08 2017 01:16
ok
then i should first do that arr.push(item);
Oranjoose
@Oranjoose
Jan 08 2017 01:17
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
yes
simonekj
@simonekj
Jan 08 2017 01:18
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

@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
@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
@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
@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
@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
: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
@andercodder welcome, happy coding :tada:
Stephen James
@sjames1958gm
Jan 08 2017 01:24
@andercodder :+1:
Jin Choi
@JiniHendrix
Jan 08 2017 01:24
@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
Assignment with a Returned Value
```js
Stephen James
@sjames1958gm
Jan 08 2017 01:25
@JiniHendrix I have to think that the trigger call is causing the refresh
andercodder
@andercodder
Jan 08 2017 01:25
know i go to sleep
Jin Choi
@JiniHendrix
Jan 08 2017 01:26
@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

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
@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
@sjames1958gm hmm I see. ill try some different versions
@sjames1958gm thank you
CamperBot
@camperbot
Jan 08 2017 01:30
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
@sjames1958gm the challenge REFUSED to let me pass w/o , like an angry troll.
CamperBot
@camperbot
Jan 08 2017 01:30
:trollface: troll problems? notify admins here
Stephen James
@sjames1958gm
Jan 08 2017 01:30
@JiniHendrix :+1:
Anthony Hayes
@EgoDominusVos
Jan 08 2017 01:30
@camperbot LOL ... funny bot
Stephen James
@sjames1958gm
Jan 08 2017 01:31
@EgoDominusVos YOu should have only had to add one line - processed = processArg(7);
@JiniHendrix Good luck
Anthony Hayes
@EgoDominusVos
Jan 08 2017 01:31
@sjames1958gm let me try ... just a sec
Having a little trouble
Tariq
@beyallluv
Jan 08 2017 01:34
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
@jerryslone TitleCaseOver ....titleCaseOver
Manish Giri
@Manish-Giri
Jan 08 2017 01:34
@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
@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
@beyallluv paste what you have between two back quotes `var mystr...`
Johnny
@JohnnyBizzel
Jan 08 2017 01:34
@jerryslone StUdLyCapVaR = studley Cap Var ???
Diego Mayer
@Chrono79
Jan 08 2017 01:36
@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
@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
var myStr = "FirstLine\n\SecondLine\rThirdLine";
Manish Giri
@Manish-Giri
Jan 08 2017 01:39
whatever.
Joseph
@revisualize
Jan 08 2017 01:39
@beyallluv You're not escaping the second backslash.
Diego Mayer
@Chrono79
Jan 08 2017 01:39
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
@beyallluv You're missing a \ to escape the second \
Tariq
@beyallluv
Jan 08 2017 01:40
Thats what I have not passing though.
Diego Mayer
@Chrono79
Jan 08 2017 01:41
@beyallluv we know, and we're telling you how to fix it
Manish Giri
@Manish-Giri
Jan 08 2017 01:41
@beyallluv the \ needs to be escaped too..
alican karalar
@alicankaralar
Jan 08 2017 01:43
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
@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
ohh
okay
wait
now i get it
i hope
simonekj
@simonekj
Jan 08 2017 01:46
@revisualize no. I'm still messing with it.
Joseph
@revisualize
Jan 08 2017 01:49
@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
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

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
@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
Or at least it is taking a really long time.
alican karalar
@alicankaralar
Jan 08 2017 01:54
hm
Diego Mayer
@Chrono79
Jan 08 2017 01:56
@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
AAAARRRRG
my brain hurts
i don't see how can i check if "akira" is true
Diego Mayer
@Chrono79
Jan 08 2017 02:01
@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
hi guys I have a question
alican karalar
@alicankaralar
Jan 08 2017 02:03
i did that but improperly i guess
Lyddip
@lydiayhuang
Jan 08 2017 02:03
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

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
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
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
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
@lydiayhuang You may need to test for those cases.
Diego Mayer
@Chrono79
Jan 08 2017 02:05
@alicankaralar you have to return something different than prop, read that part of the instructions again
Stephen James
@sjames1958gm
Jan 08 2017 02:06
@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
@sjames1958gm I feel like I just need to write 2 if statements
Stephen James
@sjames1958gm
Jan 08 2017 02:06
@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
@y00fee
var remainder ;
remainder = 11 % 3;
@sjames1958gm how do I resolve that please ?
Stephen James
@sjames1958gm
Jan 08 2017 02:08
@netstudenton I think you have to make it one line for the test to pass
Lyddip
@lydiayhuang
Jan 08 2017 02:08
@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
ahh lol, newb mistake thanks @netstudenton @sjames1958gm
CamperBot
@camperbot
Jan 08 2017 02:09
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
@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
@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
@lydiayhuang Do you need to do num2 = 0 - num2?
Lyddip
@lydiayhuang
Jan 08 2017 02:11
@sjames1958gm i have no idea why
@sjames1958gm oooooh ok let me see
Stephen James
@sjames1958gm
Jan 08 2017 02:12
@lydiayhuang IF you do that you need to reverse the sign on num1 as well
Lyddip
@lydiayhuang
Jan 08 2017 02:12
@sjames1958gm still railing
failing
Stephen James
@sjames1958gm
Jan 08 2017 02:13
@lydiayhuang
if(num2 < 0) {
num2 = 0 - num2;
num1 = 0 - num1;
}
alican karalar
@alicankaralar
Jan 08 2017 02:13
@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
@alicankaralar How can you return no such contact before you check all the contacts?
Manuel Almeida
@netstudenton
Jan 08 2017 02:14
@lydiayhuang what the is Challenge ?
alican karalar
@alicankaralar
Jan 08 2017 02:14
ah i see
Diego Mayer
@Chrono79
Jan 08 2017 02:14
@alicankaralar your loop only runs once that way
Lyddip
@lydiayhuang
Jan 08 2017 02:14
@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
@lydiayhuang Hmm, I tried and it seemed to work -can you post again?
Lyddip
@lydiayhuang
Jan 08 2017 02:16

@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
@lydiayhuang num1 = 0 - num1 (you have num2 = 0 - num1)
Lyddip
@lydiayhuang
Jan 08 2017 02:16
@sjames1958gm ohh shoot
@sjames1958gm thank you!!
CamperBot
@camperbot
Jan 08 2017 02:17
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
@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
@sjames1958gm @Jlipschitz thank you
CamperBot
@camperbot
Jan 08 2017 02:24
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
@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
@netstudenton let me check
Jamie Lipschitz
@Jlipschitz
Jan 08 2017 02:33
I use openweather @netstudenton
Manuel Almeida
@netstudenton
Jan 08 2017 02:34
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
'''
CamperBot
@camperbot
Jan 08 2017 02:38
:bulb: to format code use backticks! ``` more info
rjoyce411
@rjoyce411
Jan 08 2017 02:41

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
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
@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
@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
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
@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
@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
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
@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
how do i enter a hyphen after every word w/ regex?
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 03:03
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
@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
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
@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
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
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Vizij
@Vizij
Jan 08 2017 03:08
@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
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
@NathanHayez i can help
alican karalar
@alicankaralar
Jan 08 2017 03:10
@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
@NathanHayez you are exactly right in your approach
try to replicate that in code
alican karalar
@alicankaralar
Jan 08 2017 03:11
thanks @Vizij @Chrono79 @revisualize
CamperBot
@camperbot
Jan 08 2017 03:11
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
is it becuase its coming from codepen?
Nathan Classen
@NathanHayez
Jan 08 2017 03:11
@BrianCodes33 Thanks, yeah I will try!
CamperBot
@camperbot
Jan 08 2017 03:11
nathanhayez sends brownie points to @briancodes33 :sparkles: :thumbsup: :sparkles:
:cookie: 26 | @briancodes33 |http://www.freecodecamp.com/briancodes33
Brian
@BrianCodes33
Jan 08 2017 03:11
:beers: @NathanHayez
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 03:12
well im going to say it as say its out of my control
Joseph
@revisualize
Jan 08 2017 03:17
WOOT! I got 1 brownie today!
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 03:18
dont act all snoo ty about it @revisualize
CamperBot
@camperbot
Jan 08 2017 03:18
heebiegeebee sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2870 | @revisualize |http://www.freecodecamp.com/revisualize
Evan
@CodeDraken
Jan 08 2017 03:18
@revisualize that's no brownie
Nathan Classen
@NathanHayez
Jan 08 2017 03:18
@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("");
Evan
@CodeDraken
Jan 08 2017 03:19
I have a question about Webpack. What does resolve alias do / why use it?
Diego Mayer
@Chrono79
Jan 08 2017 03:19
@NathanHayez yur code should be inside the function
Brian
@BrianCodes33
Jan 08 2017 03:19
@NathanHayez you have the right idea
diego lemme help him i got this
Diego Mayer
@Chrono79
Jan 08 2017 03:20
ok then
alican karalar
@alicankaralar
Jan 08 2017 03:20
thanks @MaeStat @forkerino
CamperBot
@camperbot
Jan 08 2017 03:20
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
@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
@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
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
Didn't work. -_-
Diego Mayer
@Chrono79
Jan 08 2017 03:26
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

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

  return str;

}

reverseString("hello");
Brian
@BrianCodes33
Jan 08 2017 03:27
you got it
although
no need to return it on seperate line
just return on same line
gupgdown
@r1nc3w1nd
Jan 08 2017 03:29
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
:bulb: to format code use backticks! ``` more info
gupgdown
@r1nc3w1nd
Jan 08 2017 03:29
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
@r1nc3w1nd don't return when evaluating card, do it after it, evaluating count
Nathan Classen
@NathanHayez
Jan 08 2017 03:30
@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
@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
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
@BrianCodes33 That worked!
function reverseString(str) {
  return str.split("").reverse().join("");
  }
reverseString("hello");
Brian
@BrianCodes33
Jan 08 2017 03:33
nice job! :thumbsup:
now try doing it w/ a for loop take your head for a spin ;)
gupgdown
@r1nc3w1nd
Jan 08 2017 03:34
@Chrono79 that did it. much thanks.
CamperBot
@camperbot
Jan 08 2017 03:34
r1nc3w1nd sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3085 | @chrono79 |http://www.freecodecamp.com/chrono79
Brian
@BrianCodes33
Jan 08 2017 03:34
finding different solutions in programming === good stuff @NathanHayez
Sidharth Anand
@fuuraa
Jan 08 2017 03:34
good morning guys
Nathan Classen
@NathanHayez
Jan 08 2017 03:34
Thanks for your help! @BrianCodes33
I'm on basic algorithm scripting so ill probably have more questions.
CamperBot
@camperbot
Jan 08 2017 03:34
nathanhayez sends brownie points to @briancodes33 :sparkles: :thumbsup: :sparkles:
:warning: nathanhayez already gave briancodes33 points
Brian
@BrianCodes33
Jan 08 2017 03:35
@NathanHayez anytime
Nathan Classen
@NathanHayez
Jan 08 2017 03:35

@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
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
I stuck in "Stand in line" question
Manish Giri
@Manish-Giri
Jan 08 2017 03:43
@kamonAKL what's the problem
Phillip
@psnider22
Jan 08 2017 03:45

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
@psnider22 can you post the challenge URL here? click "run tests" first.
Diego Mayer
@Chrono79
Jan 08 2017 03:48
@psnider22 Declare and initialize a variable total
Manish Giri
@Manish-Giri
Jan 08 2017 03:48

@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
lol thanks @Manish-Giri
CamperBot
@camperbot
Jan 08 2017 03:48
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
:+1:
John P Penaloza
@johnpyp
Jan 08 2017 03:52

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
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
@r1nc3w1nd :hamburger: :beer: can't find water
John P Penaloza
@johnpyp
Jan 08 2017 03:54
@r1nc3w1nd What are you being asked to do? You haven't given any insight into the assignment.
Johnny
@JohnnyBizzel
Jan 08 2017 03:54
@johnpyp Having lunch I think
gupgdown
@r1nc3w1nd
Jan 08 2017 03:54
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 P Penaloza
@johnpyp
Jan 08 2017 03:54
@JohnnyBizzel lol
@r1nc3w1nd ah.
gupgdown
@r1nc3w1nd
Jan 08 2017 03:55
i tried
Johnny
@JohnnyBizzel
Jan 08 2017 03:55
@r1nc3w1nd Object notation...!
gupgdown
@r1nc3w1nd
Jan 08 2017 03:55
yes
John P Penaloza
@johnpyp
Jan 08 2017 03:56
@r1nc3w1nd Alright, so what you should do is something like this: testObj[] and assign that to a variable
Good luck!
John P Penaloza
@johnpyp
Jan 08 2017 03:56
@r1nc3w1nd figure out what to put in the brackets
gupgdown
@r1nc3w1nd
Jan 08 2017 03:57
that worked, but i swear to Allah i had already tried that
John P Penaloza
@johnpyp
Jan 08 2017 03:57
@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
@johnpyp thanks
CamperBot
@camperbot
Jan 08 2017 03:57
r1nc3w1nd sends brownie points to @johnpyp :sparkles: :thumbsup: :sparkles:
:cookie: 269 | @johnpyp |http://www.freecodecamp.com/johnpyp
John P Penaloza
@johnpyp
Jan 08 2017 03:58
@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
@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
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

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
@kamonAKL read these posts
Zaurbek Zhakupov
@zzhakupov
Jan 08 2017 04:17
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
ok thanks @Manish-Giri
CamperBot
@camperbot
Jan 08 2017 04:17
kamonakl sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:warning: kamonakl already gave manish-giri points
kamonAKL
@kamonAKL
Jan 08 2017 04:18
thnaks
Steven2493
@Steven2493
Jan 08 2017 04:22
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
dont have the return in the loop
@Steven2493
Margaret
@Margaret2
Jan 08 2017 04:28
@Zooll8 cool! good job! must have been a lot of work
Manish Giri
@Manish-Giri
Jan 08 2017 04:31
@kamonAKL welcome
jump020305
@jump020305
Jan 08 2017 04:37
gupgdown
@r1nc3w1nd
Jan 08 2017 04:43
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
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
@cesarecaravaggio return answer should be done outside switch statement
@cesarecaravaggio what is the actual task?
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 04:49
you also shouldnt have val1 etc as the case
and @r1nc3w1nd how would you target "alpha"?
Bunny Vishal
@bunnyvishal6
Jan 08 2017 04:50
@cesarecaravaggio yep you should use val as the case
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 04:50
no he shoudl use 1 etc
case 1....
gupgdown
@r1nc3w1nd
Jan 08 2017 04:51
tahts the question im sitting here trying to answer haha
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 04:51
how do you target an object?
@r1nc3w1nd
gupgdown
@r1nc3w1nd
Jan 08 2017 04:53
lookup[alpha]?
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 04:53
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
val?
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 04:54
yes
gupgdown
@r1nc3w1nd
Jan 08 2017 04:54
lookup[val]?
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 04:54
could be
gupgdown
@r1nc3w1nd
Jan 08 2017 04:55
slap me and call me Georgie
@HeebieGeeBee thanks
CamperBot
@camperbot
Jan 08 2017 04:55
r1nc3w1nd sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 475 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 04:55
yw
Joseph
@revisualize
Jan 08 2017 04:56
Hi.
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 04:57
hello
its quiet huh
Joseph
@revisualize
Jan 08 2017 04:58
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
nice
ashifmvp
@ashifmvp
Jan 08 2017 05:00
@HeebieGeeBee
var myfirstName = "Moh";
var mylastName = "Ash";
whats wrong in this
i am unable to proceed
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:00
nothing from what i can see
ashifmvp
@ashifmvp
Jan 08 2017 05:00
myFirstName should be a string with at least one character in it.
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:00
maybe use myLastName and myFirstName
ashifmvp
@ashifmvp
Jan 08 2017 05:01
this is the not
Erik Von Ploennies
@erikvp
Jan 08 2017 05:01

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
note
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:01
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
caps in what
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:02
your variable names @ashifmvp
myFirstName not myfirstName
camelcase
Erik Von Ploennies
@erikvp
Jan 08 2017 05:04
it sorts the strings longest to shortest. then I get length of string in [0].
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:04
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
yes
it seems to work when I run it outside FCC.
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:07
@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
That worked! Thanks!
Emily Sperry
@sperrye
Jan 08 2017 05:09
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
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
@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
:cookie: 476 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
erikvp sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:15
@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
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
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
it's working now. so strange. thanks @HeebieGeeBee
CamperBot
@camperbot
Jan 08 2017 05:18
sperrye sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 477 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:19
np
james clark
@james0212
Jan 08 2017 05:21
who's done with the challenge"stand in line"?
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:21
i have
heroiczero
@heroiczero
Jan 08 2017 05:21
@james0212 review your push, pop, shift and unshift methods for arrays in fcc.
Greg Duncan
@GregatGit
Jan 08 2017 05:25
@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

// 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
what does it want you to do ? @VarunKanwat
Varun Kanwat
@VarunKanwat
Jan 08 2017 05:27
total should be equal to 20
@HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:28
length*
Varun Kanwat
@VarunKanwat
Jan 08 2017 05:28
oh..
thanks a lot man...so silly mistake
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 05:28
np
Alfian Akmal Hanantio
@amalhanaja
Jan 08 2017 05:39
Hey
I' m stucked
with Understanding Uninitialized Variables
heroiczero
@heroiczero
Jan 08 2017 05:41
@amalhanaja just set the var equal to 5, 10, and "I am a"
gupgdown
@r1nc3w1nd
Jan 08 2017 05:44
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
@dylang400 nope I figured it out with some help! Thanks though
CamperBot
@camperbot
Jan 08 2017 05:44
:cookie: 73 | @dylang400 |http://www.freecodecamp.com/dylang400
Holden Hartsoe
@hartsoeha
Jan 08 2017 05:44
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
ramoneqr sends brownie points to @dylang400 :sparkles: :thumbsup: :sparkles:
Alfian Akmal Hanantio
@amalhanaja
Jan 08 2017 05:44
thanks
@heroiczero thank
CamperBot
@camperbot
Jan 08 2017 05:44
:cookie: 635 | @heroiczero |http://www.freecodecamp.com/heroiczero
amalhanaja sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
gupgdown
@r1nc3w1nd
Jan 08 2017 05:45
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
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
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
@kamonAKL what you have to do in your challange? What it's name?
Kartikeya Gupta
@kartikeya100
Jan 08 2017 06:02
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
@kamonAKL remember that you have to use bracket object notation for variables
Alex
@MaeStat
Jan 08 2017 06:03
@kamonAKL and separate objects with comma
Julia
@medusabeast
Jan 08 2017 06:04
@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
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
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
@kartikeya100 what do you want to know?
Michael J Kusdya
@michael-kusdya
Jan 08 2017 06:11
sorry nvm, already solved it
Holden Hartsoe
@hartsoeha
Jan 08 2017 06:12
Thanks @medusabeast !
CamperBot
@camperbot
Jan 08 2017 06:12
hartsoeha sends brownie points to @medusabeast :sparkles: :thumbsup: :sparkles:
:cookie: 196 | @medusabeast |http://www.freecodecamp.com/medusabeast
grantknaver
@grantknaver
Jan 08 2017 06:13
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
hi guys
Kartikeya Gupta
@kartikeya100
Jan 08 2017 06:14
@HeebieGeeBee how is that background a draggaable image and how are those pointers added?
Iqbal
@mibaldobaghi
Jan 08 2017 06:15
id like to ask a question for better understanding
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:15
@grantknaver becuase some arent arrays?
h1tag
@h1tag
Jan 08 2017 06:15
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
all of them are set between [ ]
Iqbal
@mibaldobaghi
Jan 08 2017 06:16
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
steamrollArray([1, {}, [3, [[4]]]]) should return [1, {}, 3, 4]. this one isnt @grantknaver
Iqbal
@mibaldobaghi
Jan 08 2017 06:16
@fortMaximus you can search google for an API to use in the project
grantknaver
@grantknaver
Jan 08 2017 06:16
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
@kartikeya100 probably due to some fancy javascripting
h1tag
@h1tag
Jan 08 2017 06:17
@mibaldobaghi thanks
CamperBot
@camperbot
Jan 08 2017 06:17
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
@HeebieGeeBee could you tell me any fancy js librarries?
grantknaver
@grantknaver
Jan 08 2017 06:20
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
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
@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
so basically if ( arr[i] === []) {
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:24
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
that is just figuring out
ashifmvp
@ashifmvp
Jan 08 2017 06:27
@HeebieGeeBee
var myStr = "FirstLine\nSecondLine\rThirdline";
grantknaver
@grantknaver
Jan 08 2017 06:27
but I have been kinda shooting from the hip
ashifmvp
@ashifmvp
Jan 08 2017 06:27
whats wrong in above
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:27
put your code inbetween backticks @ashifmvp
ashifmvp
@ashifmvp
Jan 08 2017 06:28
may be i mstook the instruction
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:28
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
Could anyone help , I don't see what makes an error here
ashifmvp
@ashifmvp
Jan 08 2017 06:28
can you correct me in code
Alison Yoon
@AlisonYoon
Jan 08 2017 06:28
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
myVar = myVar should be changed
what it means?
Alison Yoon
@AlisonYoon
Jan 08 2017 06:29
inside the if (){"do somthing"} works just fine but with if() added there, it doesn't work
ashifmvp
@ashifmvp
Jan 08 2017 06:30
@HeebieGeeBee can you correct me in code
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:30
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
@AlisonYoon this () for condition
Alison Yoon
@AlisonYoon
Jan 08 2017 06:30
is there anything wrong with my condition ?
h1tag
@h1tag
Jan 08 2017 06:31
@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
thats some fancy jquerying @AlisonYoon
Alison Yoon
@AlisonYoon
Jan 08 2017 06:31
Thanks :)
for some reason, with if() it doesn't wokr
Richard
@richafig
Jan 08 2017 06:31
@fortMaximus Ok, thanks
CamperBot
@camperbot
Jan 08 2017 06:31
richafig sends brownie points to @fortmaximus :sparkles: :thumbsup: :sparkles:
:cookie: 263 | @fortmaximus |http://www.freecodecamp.com/fortmaximus
David
@DavidGcastro
Jan 08 2017 06:32
hey guys
im stuck on the the mad libs part
how do i do it
Alison Yoon
@AlisonYoon
Jan 08 2017 06:32
what's wrong with if()
Kartikeya Gupta
@kartikeya100
Jan 08 2017 06:33
@HeebieGeeBee ok
Alison Yoon
@AlisonYoon
Jan 08 2017 06:33
@adhavalboy is condition wrong?
Kartikeya Gupta
@kartikeya100
Jan 08 2017 06:33
@AlisonYoon
if(condition){
statement 1;
statement 2;
}
Alison Yoon
@AlisonYoon
Jan 08 2017 06:33
@kartikeya100 exactly!
why doesn't it work ?
statement itself works just fine without if(condition)
David
@DavidGcastro
Jan 08 2017 06:34
halpp
Kartikeya Gupta
@kartikeya100
Jan 08 2017 06:34
@AlisonYoon share your code
Alison Yoon
@AlisonYoon
Jan 08 2017 06:34
@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
try using ===
Alison Yoon
@AlisonYoon
Jan 08 2017 06:35
ok
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:36
can you have an onclick function inside an if statement?
Alison Yoon
@AlisonYoon
Jan 08 2017 06:36
ahhh no :/ it doesn't work @kartikeya100
@HeebieGeeBee can't I ?
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:36
how would it work exactly
not saying you cant im just wondering
Alison Yoon
@AlisonYoon
Jan 08 2017 06:37
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
is this for a website menu?
Alison Yoon
@AlisonYoon
Jan 08 2017 06:37
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
can some plz help me with JavaScript section: Stand in Line?
*the queue section
Alison Yoon
@AlisonYoon
Jan 08 2017 06:42
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
I'm about to rip the hair outta my head
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:42
yeah i guess so @AlisonYoon
Ghulam Shabir
@ghulamshabir
Jan 08 2017 06:42
@TheRealChrisEdwards what you have so far ?
Alison Yoon
@AlisonYoon
Jan 08 2017 06:42
it's weird
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 08 2017 06:43

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
read up about how push() method works @TheRealChrisEdwards
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 08 2017 06:44
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
@TheRealChrisEdwards So its asking you to push the array, then shift the array basically
HeebieGeeBee
@HeebieGeeBee
Jan 08 2017 06:45
push item into the array
Ghulam Shabir
@ghulamshabir
Jan 08 2017 06:45
@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
@TheRealChrisEdwards Push works like shift how its written:
array.push(item_to_push);
Richard
@richafig
Jan 08 2017 06:46
@ghulamshabir thanks
CamperBot
@camperbot
Jan 08 2017 06:46
richafig sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1660 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Richard
@richafig
Jan 08 2017 06:46
@JosephLivengood thanks
CamperBot
@camperbot
Jan 08 2017 06:46
: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
so, arr.push(item)?
Emily Sperry
@sperrye
Jan 08 2017 06:46
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
@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
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
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
No arg for shift @TheRealChrisEdwards
But yes you can just return arr.shift();
Richard
@richafig
Jan 08 2017 06:49
testArr.shift();??
Ghulam Shabir
@ghulamshabir
Jan 08 2017 06:49
@richafig no ,arr
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 08 2017 06:49
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
Maybe that's my issue. Ha, thanks @ghulamshabir
CamperBot
@camperbot
Jan 08 2017 06:49
:warning: richafig already gave ghulamshabir points
richafig sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
Ghulam Shabir
@ghulamshabir
Jan 08 2017 06:50
@richafig :smile:
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 08 2017 06:51
br
*brb
gupgdown
@r1nc3w1nd
Jan 08 2017 06:52
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
@r1nc3w1nd contacts is an array use for loop to iterate over it
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 08 2017 06:55
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
[].concat.apply([], arr); does this mean
can someone explain this code to me
Emily Sperry
@sperrye
Jan 08 2017 06:58
@r1nc3w1nd you have a typo after No such contact... extra '
gupgdown
@r1nc3w1nd
Jan 08 2017 06:59
@sperrye thanks for info. always assume no typos in my code here ahah.
CamperBot
@camperbot
Jan 08 2017 06:59
:cookie: 285 | @sperrye |http://www.freecodecamp.com/sperrye
r1nc3w1nd sends brownie points to @sperrye :sparkles: :thumbsup: :sparkles:
gupgdown
@r1nc3w1nd
Jan 08 2017 06:59
jk
Chris (aka Eazy E)
@TheRealChrisEdwards
Jan 08 2017 07:01

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
@TheRealChrisEdwards You dont need an argument for shift
@TheRealChrisEdwards just
arr.shift();
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:04
@grantknaver it unfolds the nested array, for example [[1,2]] becomes [1,2]
Richard
@richafig
Jan 08 2017 07:04
@JosephLivengood I'm trying that too, I'm just stuck.
Bunny Vishal
@bunnyvishal6
Jan 08 2017 07:05
@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
myArray should only contain [["John", 23]].
Use pop() on myArray
removedFromMyArray should only contain ["cat", 2].
grantknaver
@grantknaver
Jan 08 2017 07:05
hmm
Emily Sperry
@sperrye
Jan 08 2017 07:05
thanks @bunnyvishal6
CamperBot
@camperbot
Jan 08 2017 07:05
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
@sperrye welcome.
Joseph Livengood
@JosephLivengood
Jan 08 2017 07:07
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
@wizelmagnifico pop removes and returns last element of an array
Vijith Nair
@wizelmagnifico
Jan 08 2017 07:07
yeah got it
gupgdown
@r1nc3w1nd
Jan 08 2017 07:07
@ghulamshabir like this?:```
grantknaver
@grantknaver
Jan 08 2017 07:08
its not completely giving access to nested arrays though
gupgdown
@r1nc3w1nd
Jan 08 2017 07:08
for (var i=0; i < contacts.length;i++){
if //check stuff
}
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:08
@grantknaver it only unfolds one level of array
@r1nc3w1nd yes
llamatarianism
@llamatarianism
Jan 08 2017 07:09
@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
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
@llamatarianism No its extremely important, it changes a string to a boolean
Aleksandar Zdravkovski
@azdravkovski
Jan 08 2017 07:10
I'm getting something like F8EE C5DE CAM6
which is close, but no cigar
XD
Joseph Livengood
@JosephLivengood
Jan 08 2017 07:10
Potentially I'll leave a comment on that line. lol
grantknaver
@grantknaver
Jan 08 2017 07:10
how would you unfold multiple levels?
var myNewArray = [].concat.apply([][], arr);
I think that is wrong though
dsillydude
@dsillydude
Jan 08 2017 07:11
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
@azdravkovski you are supposed to convert A-M into N-Z and vice versa
dsillydude
@dsillydude
Jan 08 2017 07:12
how do i finish that?
llamatarianism
@llamatarianism
Jan 08 2017 07:12
@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

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
why do String(updates.open) == "true"? why not just do updates.open == "true"?
Joseph Livengood
@JosephLivengood
Jan 08 2017 07:12
@llamatarianism Req.query is always a string when you get it
Aleksandar Zdravkovski
@azdravkovski
Jan 08 2017 07:12
@ghulamshabir Right. So I thought I'd only need to shift the letters by 13 characters
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:12
@grantknaver no that won't work
llamatarianism
@llamatarianism
Jan 08 2017 07:12
anyway
the if statement is pointless regardless
gupgdown
@r1nc3w1nd
Jan 08 2017 07:13
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
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
could just be updates.open = updates.open == "true"
gupgdown
@r1nc3w1nd
Jan 08 2017 07:13
works for "no such contact" but nothing else
grantknaver
@grantknaver
Jan 08 2017 07:13
ya it is erroring out
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:13
@azdravkovski no, add 13 as well for a-m letters
Joseph Livengood
@JosephLivengood
Jan 08 2017 07:13
@llamatarianism Not in context, without it, it would set an empty string to false
llamatarianism
@llamatarianism
Jan 08 2017 07:14
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
@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
how do you go about unfolding multiple layers @ghulamshabir
Aleksandar Zdravkovski
@azdravkovski
Jan 08 2017 07:16
@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
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
@grantknaver I think you can use loop over arr, never done like that
grantknaver
@grantknaver
Jan 08 2017 07:17
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
anyone help me with translating decimal numbers to Roman numberals?
Ben Carp
@carpben
Jan 08 2017 07:20
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
@carpben are you trying to do if (something === NaN)?
because that doesn't work
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:21
@grantknaver first [] is just there to call concat
llamatarianism
@llamatarianism
Jan 08 2017 07:21
nothing is equal to NaN, not even NaN
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:21
@grantknaver actuall call is like this Array.prototype.concat
Ben Carp
@carpben
Jan 08 2017 07:22

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
@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
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
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
@llamatarianism thanks
CamperBot
@camperbot
Jan 08 2017 07:23
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
blob
Here is the screenshot.
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:23
@grantknaver and second [] is for combining contents other array to []
llamatarianism
@llamatarianism
Jan 08 2017 07:24
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

```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
hmm
llamatarianism
@llamatarianism
Jan 08 2017 07:25
@Sharifdesigns22 you don't have spaces between the words
Ghulam Shabir
@ghulamshabir
Jan 08 2017 07:25
@carpben try value === value for NaN
llamatarianism
@llamatarianism
Jan 08 2017 07:25
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
@carpben change the "return value = ..." to "return value" in the function
grantknaver
@grantknaver
Jan 08 2017 07:26
@llamatarianism you talking to me
llamatarianism
@llamatarianism
Jan 08 2017 07:26
@grantknaver nah, talking to @Sharifdesigns22
__SharifTarver__
@Sharifdesigns22
Jan 08 2017 07:26
ahhh okay, and for spaces am i ending the string with a semicolon for spaces?
grantknaver
@grantknaver
Jan 08 2017 07:26
oh ok
Wilfredo-Ho
@Wilfredo-Ho
Jan 08 2017 07:27
@carpben all metioned above is boolean false
llamatarianism
@llamatarianism
Jan 08 2017 07:27
@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
@llamatarianism can I ask you one more question
llamatarianism
@llamatarianism
Jan 08 2017 07:29
@grantknaver sure
I got nowhere else to be
grantknaver
@grantknaver
Jan 08 2017 07:29
lol ok
llamatarianism
@llamatarianism
Jan 08 2017 07:29
it's 7:30 am on a sunday and my dog's dead
grantknaver
@grantknaver
Jan 08 2017 07:29
fuck sorry man
...
__SharifTarver__
@Sharifdesigns22
Jan 08 2017 07:29
ahh perfect, I'll pst an update momentarily
llamatarianism
@llamatarianism
Jan 08 2017 07:29
nah go ahead with the question
grantknaver
@grantknaver
Jan 08 2017 07:30
well...
llamatarianism
@llamatarianism
Jan 08 2017 07:30
as long as I surround myself with low-quality memes, I won't cry
__SharifTarver__
@Sharifdesigns22
Jan 08 2017 07:30
sorry to heat about your dog @llamatarianism
llamatarianism
@llamatarianism
Jan 08 2017 07:30
thanks @Sharifdesigns22