These are chat archives for FreeCodeCamp/HelpJavaScript

7th
Jan 2017
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 00:00 UTC
i swear this thing is onna drive me nuts
Pieter Stokkink
@forkerino
Jan 07 2017 00:00 UTC
the permutations challenge was the most challenging thing on here for me.
Zaluth
@Zaluth
Jan 07 2017 00:03 UTC
i want to fix my var final in such a way so that it removes all elements in the uniqueArray from the conc array, help?
function diffArray(arr1, arr2) {

  var conc = arr1.concat(arr2);

  var uniqueArray = conc.filter(function(item, pos) {
    return conc.indexOf(item) !== pos;
  });

  var final = uniqueArray.filter(function(remove){
    return remove === uniqueArray;
  });

  return final;
}

//       conc = [1, "calf", 3, "piglet", 1, "calf", 3, 4]
//uniqueArray = [1, "calf", 3]

diffArray([1, "calf", 3, "piglet"], [1, "calf", 3, 4]);
@Zaluth use indexOf
and is uniqueArray what you want it to be?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 00:06 UTC
ok cool thanks @Chrono79
CamperBot
@camperbot
Jan 07 2017 00:06 UTC
heebiegeebee sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3074 | @chrono79 |http://www.freecodecamp.com/chrono79
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 00:07 UTC
var permArray = [];
  if (str.length === 1 ) {
    permArray.push(str);
    }
im also certain this is a good way to start it, lol
Zaluth
@Zaluth
Jan 07 2017 00:07 UTC
@Chrono79 in the commented example, i want my conc array to become ["piglet", 4]
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 00:07 UTC
im still not sure if i should split the string to start with though
Diego Mayer
@Chrono79
Jan 07 2017 00:08 UTC
@Zaluth uniqueArray is storing only the repeated values [1, "calf", 3]
Zaluth
@Zaluth
Jan 07 2017 00:08 UTC
@Chrono79 yes, i want them to be removed from conc
Diego Mayer
@Chrono79
Jan 07 2017 00:08 UTC
@Zaluth then use indexOf on that array
var final = conc.filter(function(remove){
    return uniqueArray.indexOf(remove)===-1;
  });
Lescott Makiwa
@lmakiwa1
Jan 07 2017 00:09 UTC
so 11 % 3 = remainder
Zaluth
@Zaluth
Jan 07 2017 00:09 UTC
@Chrono79 you mean in the function of var final?
Jason Luboff
@JLuboff
Jan 07 2017 00:11 UTC
@lmakiwa1 = is the assignment operator. Your variable should always be on the left
Ashraful Islam
@iashraful
Jan 07 2017 00:11 UTC
@BrianCodes33
@JLuboff my friend @BrianCodes33 has some questions about loops and readability
can you help him a bit?
Lescott Makiwa
@lmakiwa1
Jan 07 2017 00:12 UTC
11 % 3 var = remainder
Jason Luboff
@JLuboff
Jan 07 2017 00:12 UTC
@iashraful I can try :D
Pieter Stokkink
@forkerino
Jan 07 2017 00:12 UTC
:facepalm:
Jason Luboff
@JLuboff
Jan 07 2017 00:12 UTC
@lmakiwa1 var remainder = .....
Ashraful Islam
@iashraful
Jan 07 2017 00:13 UTC
I had been trying to explain some stuff for last 1 hr to him, but he keeps on complaining that one index should not be used for other things
Brian
@BrianCodes33
Jan 07 2017 00:13 UTC

function fearNotLetter(str) {
  var alphabetArray = ("abcdefghijklmnopqrstuvwxyz").split("");
  var lowerCase = str.toLowerCase();
  var first = alphabetArray.indexOf(lowerCase[0]);
  var mismatch = '';
  console.log(first);

  for (var i=0; i<lowerCase.length; i++){
    if (lowerCase[i] === alphabetArray[i]){
          return alphabetArray[i];
      } else {
          mismatch = first + lowerCase[i];
      }
   }
      return mismatch;
 }


fearNotLetter("abce");
Ashraful Islam
@iashraful
Jan 07 2017 00:13 UTC
here is the confusion
^
Brian
@BrianCodes33
Jan 07 2017 00:13 UTC
man that is some ugly code
Zaluth
@Zaluth
Jan 07 2017 00:14 UTC
@Chrono79 i get it, it worked
Ashraful Islam
@iashraful
Jan 07 2017 00:14 UTC
he has confusion as to why that i can be used in alphabetArray
@JLuboff
Zaluth
@Zaluth
Jan 07 2017 00:14 UTC
thanks @Chrono79
CamperBot
@camperbot
Jan 07 2017 00:14 UTC
zaluth sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 3075 | @chrono79 |http://www.freecodecamp.com/chrono79
Lescott Makiwa
@lmakiwa1
Jan 07 2017 00:14 UTC
so var remainder = 11 % 3
Jason Luboff
@JLuboff
Jan 07 2017 00:15 UTC
@iashraful @BrianCodes33 This might be above my pay-grade, but give me a minute to look
@lmakiwa1 Yes
Ashraful Islam
@iashraful
Jan 07 2017 00:15 UTC
@BrianCodes33 direct all your questions here
Lescott Makiwa
@lmakiwa1
Jan 07 2017 00:15 UTC
thanks
rabowlen
@rabowlen
Jan 07 2017 00:16 UTC
I am super confused about this formula to calculate range : Math.floor(Math.random() * (max - min + 1)) + min
Jason Luboff
@JLuboff
Jan 07 2017 00:16 UTC
@BrianCodes33 Whats the goal of this function?
Evan Kalvis
@evan17gr
Jan 07 2017 00:16 UTC
can someone help me with apis?
Ashraful Islam
@iashraful
Jan 07 2017 00:17 UTC
@JLuboff its the "find the missing letter" challenge
^
Jason Luboff
@JLuboff
Jan 07 2017 00:18 UTC
@iashraful Got it. Wasn't recognizing it haha
Evan Kalvis
@evan17gr
Jan 07 2017 00:20 UTC
anyone?
Ashraful Islam
@iashraful
Jan 07 2017 00:20 UTC
@JLuboff the issue is in for loop, Brian is confused as to why it is being used in alphabetArray[i], because he thinks i is only applicable or in scope of lowerCase or something like that
Jason Luboff
@JLuboff
Jan 07 2017 00:21 UTC
@iashraful @BrianCodes33 i is our iterating variable. It is incrementing each loop, starting at 0 until its < lowerCase.length. It can be used to access the index of any variable
Ashraful Islam
@iashraful
Jan 07 2017 00:22 UTC
^
@BrianCodes33 please ask your confusions here, it is really helpful
people here has gone through the same confusions as you did, so they will have good answers
Jason Luboff
@JLuboff
Jan 07 2017 00:23 UTC
@BrianCodes33 Your code is stopping becuase of the return in your if statement
Ashraful Islam
@iashraful
Jan 07 2017 00:23 UTC
no
we discussed and came to if/else part
Greg Duncan
@GregatGit
Jan 07 2017 00:24 UTC
@rabowlen here is how I used it in a project index = Math.floor((Math.random() * quotes.length) + 1) - 1;
Ashraful Islam
@iashraful
Jan 07 2017 00:24 UTC
but Brian is continuously complaining that i should not be used in anything other than lowerCase as it is somehow hurting the readability
Jason Luboff
@JLuboff
Jan 07 2017 00:25 UTC
@iashraful But its stopping on its first iteration becuase lowerCase[i] === alphabetArray[i] is true and the it returns a, we should probably instead test inequality then the return will work how we want.
Ashraful Islam
@iashraful
Jan 07 2017 00:25 UTC
@JLuboff yes, I know
Jason Luboff
@JLuboff
Jan 07 2017 00:25 UTC
@iashraful Well, I disagree with his sedement on that lol
rabowlen
@rabowlen
Jan 07 2017 00:26 UTC
@GregatGit I feel like I am overthinking something. Why are we adding 1 to the minimum and then adding the minimum to the whole thing?
Ashraful Islam
@iashraful
Jan 07 2017 00:26 UTC
the whole thing should be
if (lowerCase[i] !== alphabetArray[i]) { return alphabetArray[i]; }
Pieter Stokkink
@forkerino
Jan 07 2017 00:26 UTC
@evan17gr Ask your question, maybe give your code.
Ashraful Islam
@iashraful
Jan 07 2017 00:26 UTC
but he keeps on complaining about i
@JLuboff
Jason Luboff
@JLuboff
Jan 07 2017 00:26 UTC
@iashraful Yes I agree.
@iashraful Well...we can't help him if he doesn't want to accept that?
Evan Kalvis
@evan17gr
Jan 07 2017 00:27 UTC
@forkerino i really dont understand how to access apis
Greg Duncan
@GregatGit
Jan 07 2017 00:27 UTC
@rabowlen best way to find out is go to https://repl.it/languages/javascript and see what happens when you change something - keep the range low
Ashraful Islam
@iashraful
Jan 07 2017 00:27 UTC
so I encouraged him to share him confusion here so someone else can better explain
because at early stage if you harbor some misconception, it'll come back to bite you in later stages
Greg Duncan
@GregatGit
Jan 07 2017 00:28 UTC
@rabowlen And if you are not fully getting it - don't get stuck on this - knowing how to use properly is enough for now
rabowlen
@rabowlen
Jan 07 2017 00:28 UTC
@GregatGit Thanks!
CamperBot
@camperbot
Jan 07 2017 00:28 UTC
rabowlen sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 817 | @gregatgit |http://www.freecodecamp.com/gregatgit
Pieter Stokkink
@forkerino
Jan 07 2017 00:28 UTC
@evan17gr That is a very broad statement. It really depends on the API, although you will always need an endpoint (url) and something like an $.ajax or $.getJSON function to get the data you want back.
Ashraful Islam
@iashraful
Jan 07 2017 00:29 UTC
^ or fetch if it's a latest browser
Jason Luboff
@JLuboff
Jan 07 2017 00:29 UTC
I like $.getJSON...I find it easy...I never tried $.ajax since it looked more complicated :(
Ashraful Islam
@iashraful
Jan 07 2017 00:30 UTC
:(
$.getJSON returns a promise
Evan Kalvis
@evan17gr
Jan 07 2017 00:30 UTC
@forkerino im doing the random quote machine challenge and im not surewhat to do
Ashraful Islam
@iashraful
Jan 07 2017 00:30 UTC
@evan17gr start with a basic one
Evan Kalvis
@evan17gr
Jan 07 2017 00:31 UTC
@iashraful wdym?
Ashraful Islam
@iashraful
Jan 07 2017 00:31 UTC
make an array of quotes, then try to get one of the quotes from that array randomly and show in a div
Jason Luboff
@JLuboff
Jan 07 2017 00:31 UTC
I didn't even use an API for my quote machine,. I jsut created an array of quotes
Ashraful Islam
@iashraful
Jan 07 2017 00:31 UTC
then once you feel comfortable, you can use some api, but that is strictly not necessary
Jason Luboff
@JLuboff
Jan 07 2017 00:31 UTC
Looks like @iashraful had the same idea as me :laughing:
Ashraful Islam
@iashraful
Jan 07 2017 00:31 UTC
^ no, its the common idea
Evan Kalvis
@evan17gr
Jan 07 2017 00:31 UTC
@iashraful i can do that
Ashraful Islam
@iashraful
Jan 07 2017 00:31 UTC
yes
Brian
@BrianCodes33
Jan 07 2017 00:31 UTC
@iashraful i was trying to do it that way like @JLuboff but u prevented me
Evan Kalvis
@evan17gr
Jan 07 2017 00:31 UTC
i ve done that with the background
Jason Luboff
@JLuboff
Jan 07 2017 00:32 UTC
Pieter Stokkink
@forkerino
Jan 07 2017 00:32 UTC
@iashraful @JLuboff :fearful: But it is called an API project.
Ashraful Islam
@iashraful
Jan 07 2017 00:32 UTC
@BrianCodes33 I am hurt, you backstab me
Brian
@BrianCodes33
Jan 07 2017 00:32 UTC
im not complaining it was just a misunderstanding @JLuboff
Evan Kalvis
@evan17gr
Jan 07 2017 00:32 UTC
fcc had like 7 lessons on it and it was really bad
Brian
@BrianCodes33
Jan 07 2017 00:32 UTC
@iashraful not backstabbing bro
Evan Kalvis
@evan17gr
Jan 07 2017 00:32 UTC
i didnt get anything
Ashraful Islam
@iashraful
Jan 07 2017 00:32 UTC
@BrianCodes33 ok, do it @JLuboff way and show us the code
Jason Luboff
@JLuboff
Jan 07 2017 00:32 UTC
@forkerino http://codepen.io/jluboff/full/GqyXdg/ no one had The Simpsons quotes in an API that I could find :)
Mind you, that project could probably use some re-working now but eh
Ashraful Islam
@iashraful
Jan 07 2017 00:33 UTC
@JLuboff that is my new favorite homepage from now on :D
Brian
@BrianCodes33
Jan 07 2017 00:33 UTC

function fearNotLetter(str) {
  var alphabetArray = ("abcdefghijklmnopqrstuvwxyz").split("");
  var lowerCase = str.toLowerCase();
  var first = alphabetArray.indexOf(lowerCase[0]);
  var mismatch = '';
  console.log(first);

  for (var i=0; i<lowerCase.length; i++){
    if (lowerCase[i] !== alphabetArray[i]){
          return alphabetArray[i];
      } 
   }
}
Jason Luboff
@JLuboff
Jan 07 2017 00:33 UTC
@iashraful thanks, glad you like.
CamperBot
@camperbot
Jan 07 2017 00:33 UTC
jluboff sends brownie points to @iashraful :sparkles: :thumbsup: :sparkles:
:cookie: 556 | @iashraful |http://www.freecodecamp.com/iashraful
Ashraful Islam
@iashraful
Jan 07 2017 00:34 UTC
@BrianCodes33 it is solved then
this code should pass the tests
Jason Luboff
@JLuboff
Jan 07 2017 00:34 UTC
Except...it doesn't account for if a is missing
Brian
@BrianCodes33
Jan 07 2017 00:34 UTC
it doesnt
Jason Luboff
@JLuboff
Jan 07 2017 00:34 UTC
if a is missing, it should return undefined
Ashraful Islam
@iashraful
Jan 07 2017 00:34 UTC
but remove that first and mismatch
and add a return at the end
Brandon Vi
@bvi1994
Jan 07 2017 00:35 UTC
Hi everyone, I'm currently struggling with the JSON for the Wikipedia viewer
Brian
@BrianCodes33
Jan 07 2017 00:35 UTC
eh?
Pieter Stokkink
@forkerino
Jan 07 2017 00:35 UTC
@evan17gr Yes, the lessons are bad. But the projects will help you understand what is going on. It is very common for people to stumble through them at first and not understand what is going on, but you'll learn a lot from them.
@JLuboff :+1:
Brandon Vi
@bvi1994
Jan 07 2017 00:35 UTC
I'm having problems opening the JSON and followed by returning the specified value
Ashraful Islam
@iashraful
Jan 07 2017 00:37 UTC
@BrianCodes33

function fearNotLetter(str) {
  var alphabetArray = ("abcdefghijklmnopqrstuvwxyz").split("");
  var lowerCase = str.toLowerCase();
  var missingChar;

  for (var i=0; i<lowerCase.length; i++){
    if (lowerCase[i] !== alphabetArray[i]){
         missingChar = alphabetArray[i];
         break;
      } 
   }
   return missingChar;
}
Pieter Stokkink
@forkerino
Jan 07 2017 00:37 UTC
@evan17gr You can use a quote API like the one @JLuboff linked to and just read their api documentation, that will give you an idea of the url you need to use to get the right info.
Ashraful Islam
@iashraful
Jan 07 2017 00:37 UTC
^ like this
@forkerino I always fear to point people to APIs due to the horrible CORS issues
Venkatesh Thapan
@thenerdyouknow
Jan 07 2017 00:37 UTC
So for the exact change algorithm problem I managed to isolate the digits and multiply them appropriately so that the tens place was multiplied by 10, hundreds by 100 etc.
But I don't understand how to deduct from CID without making it more complicated than it already is.
Brian
@BrianCodes33
Jan 07 2017 00:37 UTC
ah this is the way i wanted to do it
Jason Luboff
@JLuboff
Jan 07 2017 00:37 UTC
@iashraful His code worked nicely before without the extra code you added ;)
Except as I said returning undefined it a is the first letter
Venkatesh Thapan
@thenerdyouknow
Jan 07 2017 00:38 UTC
Somebody help please?
Ashraful Islam
@iashraful
Jan 07 2017 00:38 UTC
@JLuboff yes, not it should handle the missing a case
@JLuboff also I added the first to handle cases where the test case is not starting from beginning, like defgi
Pieter Stokkink
@forkerino
Jan 07 2017 00:38 UTC
@iashraful yeah, that's a problem for some of them. I have had good results using https://cors-anywhere.herokuapp.com/ to circumnavigate these problems.
Ashraful Islam
@iashraful
Jan 07 2017 00:39 UTC
but meh
@forkerino yes, but I think some APIs outright didn't return anything to cors-anywhere
I forgot which, but I think it was some weather api
didn't understand my queries
Pieter Stokkink
@forkerino
Jan 07 2017 00:40 UTC
@iashraful didn't know that / never bumped into that problem.
Venkatesh Thapan
@thenerdyouknow
Jan 07 2017 00:40 UTC
Anybody?
Ashraful Islam
@iashraful
Jan 07 2017 00:40 UTC
:D
Brian
@BrianCodes33
Jan 07 2017 00:40 UTC
still not working
Ashraful Islam
@iashraful
Jan 07 2017 00:40 UTC
that is odd
let me check
Reggie
@Reggie01
Jan 07 2017 00:41 UTC
@rabowlen adding min guarantees a value no lower than min. ( max - min + 1) this is a value between min and max. so 9 - 4 + 1 = 6
but you can never have a value that equals 6. Math.random will only return between 0 - .99. Therefore Math.floor(Math.random() * 6 ) highest possible value is 5. So if you get 5 you would need to add back min to get a max value of 9. so a number between 9 and 4.
Hmm, lol not sure if this helps
Evan Kalvis
@evan17gr
Jan 07 2017 00:41 UTC
lol why are all the quotes written in russian?
Ashraful Islam
@iashraful
Jan 07 2017 00:42 UTC
@BrianCodes33 the first variable we added back in stoneage, you need it to pass the last two tests
Brian
@BrianCodes33
Jan 07 2017 00:42 UTC
uh
Jason Luboff
@JLuboff
Jan 07 2017 00:42 UTC
@forkerino cors-anywhere similar to https://cross-origin.me?
Pieter Stokkink
@forkerino
Jan 07 2017 00:42 UTC
@thenerdyouknow I don't think you needed to isolate the digits. Just subtract as much as you can from each of the values highest ($100) to lowest ($0.01). So if I have to give back 365.24, return 3 hundreds (or less if you have less), and move on to the other notes and coins. If you end up with 0, you know what to return.
@JLuboff yep
Jason Luboff
@JLuboff
Jan 07 2017 00:43 UTC
Does it work with openweathermap? cross-origin stopped working with it
Pieter Stokkink
@forkerino
Jan 07 2017 00:43 UTC
cross-origin.me was down a lot back when I did my projects and found this alternative.
it did
still does (had to check).
tam1r
@tam1r
Jan 07 2017 00:45 UTC
hi, on chunky monkey I have an unclear problem
Pieter Stokkink
@forkerino
Jan 07 2017 00:45 UTC
@evan17gr hahaha they have 2 languages, you can use a parameter for english.
tam1r
@tam1r
Jan 07 2017 00:45 UTC
function chunkArrayInGroups(arr, size) {
var arr2=[];
var j=0;
var i=0;
var k=0;
var numOfGroups=0;
if(arr.length%size===0)
numOfGroups=arr.length/size;
else numOfGroups=arr.length/size+1;
while((i<numOfGroups)&&(j<arr.length))
{
if(j%size===0)
{
i++;
}
arr2[i].push=(arr[j]);
j++;
}
return arr2;
}
Pieter Stokkink
@forkerino
Jan 07 2017 00:45 UTC
or just use russian quotes @evan17gr
tam1r
@tam1r
Jan 07 2017 00:46 UTC
can anyone help?
Jason Luboff
@JLuboff
Jan 07 2017 00:46 UTC
@forkerino It does indeed work! Sweet. My weather app works across browsers again haha
Evan Kalvis
@evan17gr
Jan 07 2017 00:46 UTC
@forkerino ok ty i ll try
CamperBot
@camperbot
Jan 07 2017 00:46 UTC
evan17gr sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:cookie: 543 | @forkerino |http://www.freecodecamp.com/forkerino
Ashraful Islam
@iashraful
Jan 07 2017 00:47 UTC
@BrianCodes33 here is a layman's solution

function fearNotLetter(str) {

  var alphabets = 'abcdefghijklmnopqrstuvwxyz'.split('');
  var startFrom = alphabets.indexOf(str[0]);
  var missingChar;

  for(var i = 0, len = str.length; i < len; ++i) {
    if (str[i] !== alphabets[startFrom+i]) {
      missingChar = alphabets[startFrom+i];
      break;
    }
  }
  return missingChar;
}

fearNotLetter("abce");
^ seems to pass all tests
Pieter Stokkink
@forkerino
Jan 07 2017 00:47 UTC
@evan17gr use &lang=en in your url.
tam1r
@tam1r
Jan 07 2017 00:48 UTC
Hi can anyone help in chunky monkey http://pastebin.com/0DMUcg66
stevebhansen
@stevebhansen
Jan 07 2017 00:48 UTC
I'm having some troubles with two of the tests from the exact change algorithm. My output isn't passing: [ [ "QUARTER", 0.5 ] ] Does my .5 need to be formatted as 0.50? Not sure how to do this unless I format as a string.
Pieter Stokkink
@forkerino
Jan 07 2017 00:48 UTC
@iashraful @BrianCodes33 It really is a lot easier if you use the suggested methods in the instructions.
Ashraful Islam
@iashraful
Jan 07 2017 00:49 UTC
@forkerino I think it'll be all confusing
the String.fromCharCode and str.charCodeAt looks all magicky
or so it did when I initially did that challenge
Pieter Stokkink
@forkerino
Jan 07 2017 00:50 UTC
probably, but magic is cool, no?
tam1r
@tam1r
Jan 07 2017 00:50 UTC
CHUNKYYYY MONKEYYYY HELPPPPPP DESPERATE http://pastebin.com/0DMUcg66
Pieter Stokkink
@forkerino
Jan 07 2017 00:51 UTC
@5ubz3r0 your push command is not pushing the right thing in the right place
Evan Kalvis
@evan17gr
Jan 07 2017 00:51 UTC
@forkerino so should i put that at the end of this var url="http://api.forismatic.com/api/jsonp/"; ???
tam1r
@tam1r
Jan 07 2017 00:52 UTC
why?
i deleted the =, was a typo
Ashraful Islam
@iashraful
Jan 07 2017 00:53 UTC
here, @forkerino endorsed and recommended way @BrianCodes33

function fearNotLetter(str) {
  var curr;
  var prev;
  var missing;

  for(var i = 1, len = str.length; i < len; ++i) {
    curr = str.charCodeAt(i);
    prev = str.charCodeAt(i-1);
    if (curr > prev+1) {
      missing = String.fromCharCode(prev+1);
      break;
    }
  }

  return missing;
}

fearNotLetter("abce");
Pieter Stokkink
@forkerino
Jan 07 2017 00:53 UTC
@evan17gr you also need to specify a method... Check the site http://www.forismatic.com/en/api/
Ashraful Islam
@iashraful
Jan 07 2017 00:54 UTC
@forkerino I think I used the jsonp method for forismatic
it gave me a lot of pain
for some reasons, forismatic doesn't have CORS support, but its a public api, very strange
Jason Luboff
@JLuboff
Jan 07 2017 00:54 UTC
Have a good weekend all
Ashraful Islam
@iashraful
Jan 07 2017 00:54 UTC
^ Likewise
Pieter Stokkink
@forkerino
Jan 07 2017 00:55 UTC
@5ubz3r0 well, you push only 1 item in the result arr2, instead of an item the size of size, and you push it in a subarray of the result instead of the array itself.
Ashraful Islam
@iashraful
Jan 07 2017 00:55 UTC
^ that sounded very complex @forkerino
Pieter Stokkink
@forkerino
Jan 07 2017 00:56 UTC
well he's making it very complex.
Ashraful Islam
@iashraful
Jan 07 2017 00:56 UTC
what is it?
let me at 'em
Pieter Stokkink
@forkerino
Jan 07 2017 00:56 UTC
Ashraful Islam
@iashraful
Jan 07 2017 00:56 UTC
@forkerino his help message was very SEO optimized
:smile:
Pieter Stokkink
@forkerino
Jan 07 2017 00:57 UTC
indeed
Ashraful Islam
@iashraful
Jan 07 2017 00:57 UTC
a lot of unnecessary if/else there
I think my eyes tried to run off
tam1r
@tam1r
Jan 07 2017 00:57 UTC
mine?
Brian
@BrianCodes33
Jan 07 2017 00:58 UTC
this isnt laymans, but thx anyway
tam1r
@tam1r
Jan 07 2017 00:58 UTC
so how would you do it more simply? :)
Pieter Stokkink
@forkerino
Jan 07 2017 00:59 UTC
@iashraful @BrianCodes33 this was my solution:
function fearNotLetter(str) {
  var start = str.charCodeAt(0);

  for (var i = 1; i<str.length; i++){
    if (str.charCodeAt(i) !== start+i) {
      return String.fromCharCode(start+i);
    }
  }

  return undefined;
}
Ashraful Islam
@iashraful
Jan 07 2017 01:00 UTC
@forkerino nice nice
let me try and beat it
wait
Pieter Stokkink
@forkerino
Jan 07 2017 01:01 UTC
@5ubz3r0 I would push a slice (with a size of size) of the arr to the result and do that as many times as necessary.
Will
@wwhite2011
Jan 07 2017 01:02 UTC
var myStr= 'FirstLine\n\'"SecondLine\"'\rThirdLine'; // Change this line
trying to space out this code
hello??
Pieter Stokkink
@forkerino
Jan 07 2017 01:05 UTC
@iashraful would love to see an even more concise answer, make sure to pm it to me once you found it, because it's 1 am here and am going to sleep.
Ashraful Islam
@iashraful
Jan 07 2017 01:06 UTC
ah
its 2 am here
Pieter Stokkink
@forkerino
Jan 07 2017 01:06 UTC
hahaha
Ashraful Islam
@iashraful
Jan 07 2017 01:06 UTC
and am trying to heat my room before I turn it
too cold today :(
Pieter Stokkink
@forkerino
Jan 07 2017 01:07 UTC
good luck with that. #codeallnight
night night /all
Fernando
@fer408
Jan 07 2017 01:13 UTC
Hows it going im having some trouble getting the last two test cases to work for this algorithm
V
function sumAll(arr) {
arr = arr.sort();
var min = arr[0];
var max = arr[1];
var orig = min;
var result = 0;
while (min <= max) {
min += min + 1 ;
result = min;
min++;
}
return result + orig;
}
Will
@wwhite2011
Jan 07 2017 01:14 UTC
var myStr = "FirstLine\n\'\SecondLine\'\\r;ThirdLine"; // Change this line
Daniel
@doodleslr
Jan 07 2017 01:16 UTC
i'm stuck on the nesting for loops challenge and i keep returning an error "cannot read property 'length' of undefined
but it is defined though it's the array for the challenge

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var a = 0;a < multiplyAll.length;a++){
for (var b = 0;b < multiplyAll[a].length;b++){
product *= multiplyAll([a][b]);
}
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Wael Azar
@Waelazar
Jan 07 2017 01:17 UTC
any one here for helping me with my local weather ???
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:18 UTC
whats wrong @Waelazar
Manish Giri
@Manish-Giri
Jan 07 2017 01:19 UTC
@doodleslr you're using the wrong thing
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:19 UTC
multiplyAkk is the function @doodleslr
Manish Giri
@Manish-Giri
Jan 07 2017 01:19 UTC
multiplyAll is the name of the function
use arr which is the array.
Daniel
@doodleslr
Jan 07 2017 01:19 UTC
arr.length?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:20 UTC
yes
Wael Azar
@Waelazar
Jan 07 2017 01:20 UTC
@HeebieGeeBee i solve it
thx @Manish-Giri
CamperBot
@camperbot
Jan 07 2017 01:20 UTC
waelazar sends brownie points to @heebiegeebee and @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 3599 | @manish-giri |http://www.freecodecamp.com/manish-giri
:cookie: 459 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:20 UTC
product *= multiplyAll([a][b]); i doubt this will work too
Daniel
@doodleslr
Jan 07 2017 01:20 UTC
ill get to that bit when i get past this
Manish Giri
@Manish-Giri
Jan 07 2017 01:21 UTC
welcome @doodleslr
Daniel
@doodleslr
Jan 07 2017 01:21 UTC
do i need to define which array arr.length is for?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:21 UTC
arr is the array
arr[i] will be the sub array
Fernando
@fer408
Jan 07 2017 01:22 UTC
Can anyone help me with this algorithm? I get the first three test cases right just not the last two
function sumAll(arr) {
arr = arr.sort();
var min = arr[0];
var max = arr[1];
var orig = min;
var result = 0;
while (min <= max) {
min += min + 1 ;
result = min;
min++;
}
return result + orig;
}
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:22 UTC
maybe if i had any idea what all that meant
thats definately a unique approach
Fernando
@fer408
Jan 07 2017 01:23 UTC
ill comment it right now
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:24 UTC
its ok you dont have to
mitron6
@mitron6
Jan 07 2017 01:24 UTC
@fer408 What is the name of the exercise?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:24 UTC
i'd suggest you look at the reduce method
im guessing by the name ofthe function he needs to sum all the elements
Fernando
@fer408
Jan 07 2017 01:26 UTC

function sumAll(arr) {
arr = arr.sort(); // sorts array from lowest to highest
var min = arr[0]; // sets variable to the lowest value of array
var max = arr[1]; // sets variable to the highest value of array
var orig = min; // variable for keeping track of initial value of min
var result = 0; // variable to store results
while (min <= max) { //condition
min += min + 1 ; // min is icremented by itself plus 1
result = min; // result is given the value of min
min++; // min is incremented
}
return result + orig; // returns the value of the result plus the initial value of min
}

sumAll([10,5]);

Kuomu Fan
@txbluebee
Jan 07 2017 01:27 UTC
Hello Everyone im stuck in javascript lesson: Understand String Immutability.
Greg Duncan
@GregatGit
Jan 07 2017 01:27 UTC
@fer408 what is the challenge called
Kuomu Fan
@txbluebee
Jan 07 2017 01:27 UTC

// Setup
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "H"; // Fix Me

myStr = "Hello World";

Instructions
Correct the assignment to myStr to achieve the desired effect.
mitron6
@mitron6
Jan 07 2017 01:27 UTC
@fer408 With the name if the exercise we can know the goal of the code. It makes it easier to help you.
Fernando
@fer408
Jan 07 2017 01:27 UTC
@GregatGit sum all numbers in a range
Kuomu Fan
@txbluebee
Jan 07 2017 01:28 UTC
Can someone help me please? thanks
Fernando
@fer408
Jan 07 2017 01:28 UTC
the name of the Algorithm is sum all numbers in a range

function sumAll(arr) {
arr = arr.sort(); // sorts array from lowest to highest
var min = arr[0]; // sets variable to the lowest value of array
var max = arr[1]; // sets variable to the highest value of array
var orig = min; // variable for keeping track of initial value of min
var result = 0; // variable to store results
while (min <= max) { //condition
min += min + 1 ; // min is icremented by itself plus 1
result = min; // result is given the value of min
min++; // min is incremented
}
return result + orig; // returns the value of the result plus the initial value of min
}

sumAll([10,5]);

HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:29 UTC
@txbluebee you cant change parts of strings
mitron6
@mitron6
Jan 07 2017 01:30 UTC
@fer408 You need to add min + (min+1) + (min+2) + ... + (max)
Kuomu Fan
@txbluebee
Jan 07 2017 01:31 UTC
@HeebieGeeBee what should i do?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:31 UTC
if you wanted to change the j in 'jello world' to an h, what would you do?
knowing that you cant change parts of a string
you can only change the whole string into something else
Greg Duncan
@GregatGit
Jan 07 2017 01:32 UTC
@fer408 I built a simple for loop starting at the lowest var lowest = Math.min(arr[0], arr[1]); and finishing at the highest
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:33 UTC
learning about the reduce mthod now might save you some time later @fer408
Drew Seifert
@dseif003
Jan 07 2017 01:33 UTC
can someone help me with the nesting for loops challenge I know how to create for loops I dont understand how to multiply them
Greg Duncan
@GregatGit
Jan 07 2017 01:33 UTC
@fer408 as you loop through you just add to the total that you return in the end
Fernando
@fer408
Jan 07 2017 01:34 UTC
@GregatGit @HeebieGeeBee thanks guys ill try both methods right now
CamperBot
@camperbot
Jan 07 2017 01:34 UTC
fer408 sends brownie points to @gregatgit and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 818 | @gregatgit |http://www.freecodecamp.com/gregatgit
:cookie: 460 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Drew Seifert
@dseif003
Jan 07 2017 01:34 UTC
well I don't know how to multiply the nested arrays rather
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:34 UTC
whats your code look like @dseif003
Drew Seifert
@dseif003
Jan 07 2017 01:35 UTC
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=1; i < arr.length; i++) {
for (var j=1; j < arr[i].length; j++) {
console.log(arr[i][j]);
// Only change code above this line
return product;
}
}
}
// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Aly Shmahell
@AlyShmahell
Jan 07 2017 01:35 UTC
hello
Greg Duncan
@GregatGit
Jan 07 2017 01:35 UTC
@fer408 while this doesn't really require reduce - you can practice at https://repl.it/languages/javascript with reduce and other array functions
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:35 UTC
reduce method might be helpful for you too @dseif003
Daniel
@doodleslr
Jan 07 2017 01:36 UTC
figured out nested loops
if there is only one array, you dont need to define which array to use in a function?
Greg Duncan
@GregatGit
Jan 07 2017 01:36 UTC
@AlyShmahell hello back
Kuomu Fan
@txbluebee
Jan 07 2017 01:36 UTC
@HeebieGeeBee i still dont get it :(
Aly Shmahell
@AlyShmahell
Jan 07 2017 01:36 UTC
:D
Stephen James
@sjames1958gm
Jan 07 2017 01:37 UTC
@dseif003 If you return from inside the loops then it will only loop once.
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:37 UTC
to change'jello world' to 'hello world' you just have to make it 'hello world'
Aly Shmahell
@AlyShmahell
Jan 07 2017 01:37 UTC
I have a little problem with this js specific error! "Cannot assign to read only property", if you could help me out with it :)
Stephen James
@sjames1958gm
Jan 07 2017 01:37 UTC
@dseif003 You need to use the value inside the console.log to build product in the product variable
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:38 UTC
@AlyShmahell where are you getting that?
Drew Seifert
@dseif003
Jan 07 2017 01:38 UTC
ok but this wants me to be able to test all the values I think by plugging in those values that would only solve for one set of values and not the others
Stephen James
@sjames1958gm
Jan 07 2017 01:38 UTC
@AlyShmahell That implies that you have tried to set single character into a string
Aly Shmahell
@AlyShmahell
Jan 07 2017 01:38 UTC
in this simple only function

function titleCase(str) {

for(var i=0;i<str.length;i++)
if(str[i]==' ')
{
str[i]='g';
}
return str;
}

Stephen James
@sjames1958gm
Jan 07 2017 01:39 UTC
@AlyShmahell you cannot change a character in a string - strings are immutable (recall Jello World challenge)
Drew Seifert
@dseif003
Jan 07 2017 01:39 UTC
also the two loops I have only increment the product if im not mistaken not multiply the nested array values
Aly Shmahell
@AlyShmahell
Jan 07 2017 01:40 UTC
i'll use replace then!, sorry coming from a c background here :D
Stephen James
@sjames1958gm
Jan 07 2017 01:40 UTC
@dseif003 Your two } should be above the return.
@AlyShmahell All string functions in js return new strings.
Kuomu Fan
@txbluebee
Jan 07 2017 01:40 UTC

@HeebieGeeBee like this?
// Setup var myStr = "Hello Jorld";

// Only change code below this line

var myStr = "Hello Jorld";
myStr = "Hello World";
myStr[0] = "H"; // Fix Me

Drew Seifert
@dseif003
Jan 07 2017 01:40 UTC
ok thanks stephen
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:41 UTC
sort of but theres two lines that dont need to be there @txbluebee
Stephen James
@sjames1958gm
Jan 07 2017 01:41 UTC
@txbluebee myStr[0] = "H"; this line must be removed as it is a type error - trying to change single character in string
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:42 UTC
oh sorry
just one
didnt realise that setup line was a comment
@txbluebee
Kuomu Fan
@txbluebee
Jan 07 2017 01:42 UTC
@HeebieGeeBee @sjames1958gm I finally got it
it was kinda misleading. I kept focusing on [0]
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:43 UTC
this no repeats please exercise has depressed me
Kuomu Fan
@txbluebee
Jan 07 2017 01:43 UTC
thank you both!
liamllorin1
@liamllorin1
Jan 07 2017 01:44 UTC
hey guys, any idea how to "remove all non-alphanumeric characters (punctuation, spaces, and symbols)" from a string? any help is greaaaatly appreciated!
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:44 UTC
with regex @liamllorin1
Stephen James
@sjames1958gm
Jan 07 2017 01:44 UTC
@liamllorin1 Have you investigated regex?
liamllorin1
@liamllorin1
Jan 07 2017 01:47 UTC
I shall thanks!
brycemcdonald86
@brycemcdonald86
Jan 07 2017 01:48 UTC
function fearNotLetter(str) {
  var arr = str.split('');
  var charCode = 0;
  for (x=0;x<(arr.length - 1);x++){
    charCode = (str.charCodeAt(x) + 1);
    if (str.charCodeAt(x + 1) != charCode){
      arr.splice((x + 1), 0, (String.fromCharCode(charCode)));
    }
  }
  str = arr.join('');
  return str;
}

fearNotLetter("abce");
Console says "potential infinite loop at line 5". Any suggestions? (line 5 is the "charCode = (str.char....... line)
Ps I'm on the "Missing Letters" challenge of intermediate JS
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:54 UTC
what is your thinking behind this?
mitron6
@mitron6
Jan 07 2017 01:54 UTC
@brycemcdonald86 You keep make arr bigger....
Marcin_L
@lotosiauke
Jan 07 2017 01:55 UTC
function sumPrimes(num) {
  var numbers = [];
  var primes = [];  

  for (i = 2; i <= num; i++ ){
    numbers.push(i);    
  } 
  primes = numbers;

  for (i = 0; i < numbers.length; i++){
    for (j = 0; j < numbers.length; j++){
     if (numbers[j+1]%numbers[i] === 0){
       primes.splice(j+1,j+2);
     }
    }
  }
  num = primes.reduce(function(prevVal, currVal, index, array) { return prevVal + currVal;});
  return num;
}

sumPrimes(10);

My problem is why my output is always 2. Both arrays are reduced to one element. Even "numbers" array, despite I didn't operate on that array with splice. What am I missing? It should efficiently delete from "primes" all nonprime numbers.

function sumPrimes(num) {
  var numbers = [];
  var primes = [];  

  for (i = 2; i <= num; i++ ){
    numbers.push(i);    
  } 
  primes = numbers;

  for (i = 0; i < numbers.length; i++){
    for (j = 0; j < numbers.length; j++){
     if (numbers[j+1]%numbers[i] === 0){
       primes.splice(j+1,j+2);
     }
    }
  }
  num = primes.reduce(function(prevVal, currVal, index, array) { return prevVal + currVal;});
  return num;
}

sumPrimes(10);

My problem is why my output is always 2. Both arrays are reduced to one element. Even "numbers" array, despite I didn't operate on that array with splice. What am I missing? It should efficiently delete from "primes" all nonprime numbers.

brycemcdonald86
@brycemcdonald86
Jan 07 2017 01:56 UTC
@mitron6 Oh, right i probs need to split and join the string each time. Thanks a ton
CamperBot
@camperbot
Jan 07 2017 01:56 UTC
brycemcdonald86 sends brownie points to @mitron6 :sparkles: :thumbsup: :sparkles:
:cookie: 433 | @mitron6 |http://www.freecodecamp.com/mitron6
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 01:58 UTC
@lotosiauke do you ever define i or j?
also why do make and array numbers
and array primes
then just make primes = numbers?
and why do you splice j +1 to j+2
well not to j+2
thats the delete amount
brycemcdonald86
@brycemcdonald86
Jan 07 2017 02:02 UTC
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 02:02 UTC
sorry very confused by your logic
Marcin_L
@lotosiauke
Jan 07 2017 02:02 UTC
@HeebieGeeBee Oh! thats whats wrong!
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 02:03 UTC
a few things
are wrong
i dont think youre going to be able to have two loops both using the variable i
but maybe im wrong
Marcin_L
@lotosiauke
Jan 07 2017 02:04 UTC
There's only one loop using var i at once.
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 02:05 UTC
i guess that value will just get changed
but not sure if thats very good practise
i dunno
do they work when you dont define them?
Marcin_L
@lotosiauke
Jan 07 2017 02:06 UTC
What do you mean? You want me to not define i and j?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 02:06 UTC
i mean youre loops dont have i defined with like var i = 0; or summin
just wondered if that works or not
Marcin_L
@lotosiauke
Jan 07 2017 02:07 UTC
ill try

nothing changes. Now when i fixed splice arguments it returns me an array numbers [2,5,9] And dont exactly understand why. I expected [2,3,5,7]. Not long ago I made simple program in Java to search for primes with that algorithm.

Its 3:00am here. Maybe i've got to get some sleep and try in couple of hours. I dunno

HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 02:10 UTC
i dont really fully understand what youre trying to do
Marcin_L
@lotosiauke
Jan 07 2017 02:11 UTC
Sum all the prime numbers up to and including the provided number.
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 02:11 UTC
so youre making an array that is made up of numbers from 2 to num?
Marcin_L
@lotosiauke
Jan 07 2017 02:11 UTC
yes
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 02:11 UTC
and then just trying to remove all the non prime numbers?
Marcin_L
@lotosiauke
Jan 07 2017 02:11 UTC
and then i want to erase nonprime numbers
exactly
at the end sum all of them
i mean these primes
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 02:12 UTC
can you put up your code again?
Marcin_L
@lotosiauke
Jan 07 2017 02:12 UTC
i cant notice when it works wrong.
function sumPrimes(num) {
  var numbers = [];


  for (i = 2; i <= num; i++ ){
    numbers.push(i);    
  } 


  for (i = 0; i < numbers.length; i++){
    for (j = 1; j < numbers.length; j++){
     if (numbers[j]%numbers[i] === 0){
       numbers.splice(j,1);
     }
    }
  }
  num = numbers.reduce(function(prevVal, currVal, index, array) { return prevVal + currVal;});
  return numbers;
}

sumPrimes(10);
Stephen James
@sjames1958gm
Jan 07 2017 02:14 UTC
@lotosiauke I always find it difficult to follow code where you splice the array you are looping on
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 02:15 UTC
sorry yeah its confusing me too
justinbarr00
@justinbarr00
Jan 07 2017 02:15 UTC
How do I make the for statement loop until the end of the array? Right now it only loops once. Is it my increment statement?
function chunkArrayInGroups(arr, size) {
  var newArr = [];
  var arr1 = [0, 0];
  for (var i = 0 ; i < arr.length ; size++) {
      arr1 = arr.slice(i, size);
      newArr.push(arr1);
      return newArr;
  }

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Stephen James
@sjames1958gm
Jan 07 2017 02:15 UTC
@justinbarr00 Don't return inside an for loop
@justinbarr00 At least like that where it has to hit the return and exit the function
justinbarr00
@justinbarr00
Jan 07 2017 02:16 UTC
when i put it outside it is an infinite loop.
Marcin_L
@lotosiauke
Jan 07 2017 02:16 UTC
that's why earlier i made other arrays primes and spliced only primes (initially primes where the same as numbers) but i was surprised to see that numbers array also was spliced.
Stephen James
@sjames1958gm
Jan 07 2017 02:17 UTC
@lotosiauke maybe start your inner loop at i + 1 not 1 ?
@lotosiauke Yeah, that's the issue
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 02:18 UTC
My code is not working for the challenge Check for Palindromes, need help:
Marcin_L
@lotosiauke
Jan 07 2017 02:18 UTC
@HeebieGeeBee @sjames1958gm oh god! thx!
CamperBot
@camperbot
Jan 07 2017 02:18 UTC
lotosiauke sends brownie points to @heebiegeebee and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 461 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:star2: 5199 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 02:18 UTC

function palindrome(str) {
str.replace(/[^a-z|1-9]/g, "");
if (str.toLowerCase() === str.split('').reverse().join('').toLowerCase()){
return true;
}else{// Good luck!
return false;
}
}

palindrome("tsdsdf");

My code is not Working please help
Stephen James
@sjames1958gm
Jan 07 2017 02:18 UTC
@unlawfulspoonisback All string functions return new strings.
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 02:19 UTC
it is for the challenge check for palindromes
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 02:19 UTC
you'll need to make two different strings to compare @unlawfulspoonisback
Marcin_L
@lotosiauke
Jan 07 2017 02:20 UTC
ohh... and now i got it why it didn't worked with j = 1 Thank you all!
Ogundele Olumide
@Lumexralph
Jan 07 2017 02:20 UTC
@unlawfulspoonisback str.replace(/[^a-z|1-9]/g, ""); a new string is returned and you're didn't store it
Stephen James
@sjames1958gm
Jan 07 2017 02:20 UTC
@lotosiauke Yep 3 % 3 is zero :)
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 02:20 UTC
what do you mean @Lumexralph
Stephen James
@sjames1958gm
Jan 07 2017 02:21 UTC
@unlawfulspoonisback var newStr = str.replace()
@unlawfulspoonisback Then use newStr not str
That is what I meant by all string functions return new strings.
Ogundele Olumide
@Lumexralph
Jan 07 2017 02:21 UTC
@unlawfulspoonisback str.replace(/[^a-z|1-9]/g, ""); you have replaced but the new string is not used str like you did is just the str from the parameter
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 02:22 UTC
also youre going to replace all uppercase letters like that too
you'll either need to convert everything to lower case first or add A-Z to your regex
Ogundele Olumide
@Lumexralph
Jan 07 2017 02:23 UTC
@unlawfulspoonisback store that string and use it to replace str in the comparison you did like @sjames1958gm illustrated
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 02:24 UTC
it still did not work
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 02:25 UTC
put your latest code up
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 02:25 UTC

function palindrome(str) {
var newStr = str.replace(/[^a-z|1-9]/g, "");
if (newStr.toLowerCase() === str.split('').reverse().join('').toLowerCase()){
return true;
}else{// Good luck!
return false;
}
}

palindrome("tsdsdf");

Ogundele Olumide
@Lumexralph
Jan 07 2017 02:25 UTC
@unlawfulspoonisback your reg Expression pattern
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 02:26 UTC
/[^a-zA-Z0-9]/g use this for your regez
Ogundele Olumide
@Lumexralph
Jan 07 2017 02:26 UTC
@unlawfulspoonisback str.split('').reverse().join('').toLowerCase() use newStr not str
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 02:27 UTC
and then compare your newStr string with a newStr string reversed
yeah
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 02:27 UTC
thankyou guys so much
it worked
how do i send brownie points
Ogundele Olumide
@Lumexralph
Jan 07 2017 02:28 UTC
tag our names by clicking on it with thanks
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 02:30 UTC
@Lumexralph @HeebieGeeBee @sjames1958gm thanks
CamperBot
@camperbot
Jan 07 2017 02:30 UTC
unlawfulspoonisback sends brownie points to @lumexralph and @heebiegeebee and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 675 | @lumexralph |http://www.freecodecamp.com/lumexralph
:cookie: 462 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:star2: 5200 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Ogundele Olumide
@Lumexralph
Jan 07 2017 02:30 UTC
@unlawfulspoonisback :smile:
Stephen James
@sjames1958gm
Jan 07 2017 02:46 UTC
@unlawfulspoonisback :+1:
tech-tron
@tech-tron
Jan 07 2017 02:50 UTC
whats the difference between string.prototypes.slice()
and string.slice()
string.prototype.slice() *
Antonious Stewart
@Antonious-Stewart
Jan 07 2017 02:50 UTC
can anyone give me hint of what im doiing wrong or what needs to be added

// Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line

var gloveBoxContents = "maps";
myStorage.car.inside["glove box"];// Change this line

Stephen James
@sjames1958gm
Jan 07 2017 02:51 UTC
@tech-tron nothing.
@Astewart400 YOu are supposed to set gloveBoxContents from the object access
tech-tron
@tech-tron
Jan 07 2017 02:52 UTC
so why would you ever use the .prototype?
Ogundele Olumide
@Lumexralph
Jan 07 2017 02:52 UTC
@Astewart400 set it to the last line of code you have there myStorage.car.inside["glove box"] not maps
tech-tron
@tech-tron
Jan 07 2017 02:52 UTC
is it just a reminder that it is a prototype
Stephen James
@sjames1958gm
Jan 07 2017 02:53 UTC
@tech-tron "".slice === String.prototype.slice this is true
Probably not useful here, but you might want to use array function on array-like objects.
Array.prototype.slice(arguments);
Damián Sánchez
@sanchezdam
Jan 07 2017 02:54 UTC
Hi, anyone know what am I doing wrong in this challenge? https://www.freecodecamp.com/challenges/escape-sequences-in-strings#
var myStr = "First Line\n\b\SecondLine\\rThirdLine";
The error is "myStr should have encoded text with the proper escape sequences and no spacing."
Ogundele Olumide
@Lumexralph
Jan 07 2017 02:54 UTC
@sanchezdam \\ that's backslash not \b
@sanchezdam backslash \\ before and after SecondLine
Damián Sánchez
@sanchezdam
Jan 07 2017 02:55 UTC
The instruction is "FirstLine newline backslash SecondLine backslash carriage-return ThirdLine"
Antonious Stewart
@Antonious-Stewart
Jan 07 2017 02:56 UTC
so im to put myStorage.car.inside["glove box"] inside var gloveBoxContents ""
Damián Sánchez
@sanchezdam
Jan 07 2017 02:56 UTC
aaah ok, i'm going to test @Lumexralph
Ogundele Olumide
@Lumexralph
Jan 07 2017 02:56 UTC
@sanchezdam that's what's missing in the string you constructed
Damián Sánchez
@sanchezdam
Jan 07 2017 02:56 UTC
thks!! @Lumexralph
Ogundele Olumide
@Lumexralph
Jan 07 2017 02:56 UTC
@Astewart400 yes
@sanchezdam :+1:
Antonious Stewart
@Antonious-Stewart
Jan 07 2017 02:58 UTC

like this @Lumexralph
// Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line
var gloveBoxContents = "myStorage.car.inside[glove box]"; // Change this line

Ogundele Olumide
@Lumexralph
Jan 07 2017 02:58 UTC
@Astewart400 no, don't make it a string remove the double quotes, but double quotes should be around "glove box"
Antonious Stewart
@Antonious-Stewart
Jan 07 2017 03:00 UTC
@Lumexralph so they only put the "" so that the var would have a value....
Ogundele Olumide
@Lumexralph
Jan 07 2017 03:00 UTC
@Astewart400 i don't understand
Antonious Stewart
@Antonious-Stewart
Jan 07 2017 03:02 UTC
the var gloveBoxContents = ""; what threw me off was the double quotes so i was asking is the only reason they put "" is so that the var would have a value
@Lumexralph
Ogundele Olumide
@Lumexralph
Jan 07 2017 03:03 UTC
@Astewart400 i think so, maybe so you won't declare it again, have you done it?
Antonious Stewart
@Antonious-Stewart
Jan 07 2017 03:04 UTC
o yes it ran i just wanted to make sure i understand
@Lumexralph thanks
CamperBot
@camperbot
Jan 07 2017 03:04 UTC
astewart400 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 676 | @lumexralph |http://www.freecodecamp.com/lumexralph
tech-tron
@tech-tron
Jan 07 2017 03:08 UTC
thanks @sjames1958gm , i just dont understand why we call it .prototype, seems like a waste of space other than saying its something that is built in
CamperBot
@camperbot
Jan 07 2017 03:08 UTC
tech-tron sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 5201 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Ogundele Olumide
@Lumexralph
Jan 07 2017 03:10 UTC
@tech-tron showing a kind of inheritance or object linkage
gupgdown
@r1nc3w1nd
Jan 07 2017 03:14 UTC
doing the javascript lessons. using "+=" to concatenate strings. cant figure out where to put it. any one help?
Ogundele Olumide
@Lumexralph
Jan 07 2017 03:15 UTC
@r1nc3w1nd put your code up
gupgdown
@r1nc3w1nd
Jan 07 2017 03:17 UTC
i an idiot. wasnt paying attention to the example.
*i'm
figured it out
Ogundele Olumide
@Lumexralph
Jan 07 2017 03:17 UTC
@r1nc3w1nd okay, cool
Victoria Zambrano
@vzambrano98
Jan 07 2017 03:21 UTC
@khaduch Just got your link, thanks for sending that my way!!!
CamperBot
@camperbot
Jan 07 2017 03:21 UTC
vzambrano98 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2224 | @khaduch |http://www.freecodecamp.com/khaduch
Victoria Zambrano
@vzambrano98
Jan 07 2017 03:22 UTC
Anyone have hints as to what sections i should look back at to figure out the Profile Lookup challenge?
Ogundele Olumide
@Lumexralph
Jan 07 2017 03:23 UTC
@vzambrano98 i can't remember but what are you to do?
jechan6
@jechan6
Jan 07 2017 03:23 UTC
I'm using an api to grab quotes in my random quote generator using ajax call and pushing the data onto an array. When i get out of the ajax call function, my array is empty, can anyone help me with this?
Victoria Zambrano
@vzambrano98
Jan 07 2017 03:28 UTC

@Lumexralph

//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) && contacts.hasOwnProperty(prop)){
      if (firstName===undefined){
        return "No such contact";
      } else if (prop===undefined){
        return "No such property";
      }
      return contacts[prop];

    }
);

  //second for loop

    //first for loop

// Only change code above this line
}

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

instructions:
We have an array of objects representing different people in our contacts lists.

A lookUpProfile function that takes firstName and a property (prop) as arguments has been pre-written for you.

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

Ogundele Olumide
@Lumexralph
Jan 07 2017 03:30 UTC
@vzambrano98 contacts is an array of objects, you'll need a loop to get to the objects in contacts
Ken Haduch
@khaduch
Jan 07 2017 03:31 UTC
@vzambrano98 - you're welcome (re: the link). As far as the Profile lookup...
  • It's an array - look up array iteration (again)
  • It has objects - and variables passed with properties - look up the accessing object properties using variables
  • Look at .hasOwnProperty
  • Watch out for returning the "No such contact" - many people do that incorrectly, think it through...
babajide odusola
@cesarecaravaggio
Jan 07 2017 03:33 UTC

Q? 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.

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

  return item;  // Change this line
}

I don't understand the wording of this question whatsoever. anyone have a link to read up on and or wanna help? Pls

Victoria Zambrano
@vzambrano98
Jan 07 2017 03:33 UTC

@Lumexralph so I think I'm over thinking the loop. If the loop is as follows:

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

won't it just keep going through? What will make it stop at the appropriate firstName or prop?
and I will definitely re check myself @khaduch

maybe I should just stop asking questions and go back and read lol!
Ogundele Olumide
@Lumexralph
Jan 07 2017 03:34 UTC
@cesarecaravaggio push item into arr and return the the first element in arr
Ken Haduch
@khaduch
Jan 07 2017 03:34 UTC
@cesarecaravaggio - there are array functions that add and remove elements from the start and end of the array. .shift, .unshift, .push and .pop (I think I have those right...) Along with the description "Add the number to the end of the array, then remove the first element of array. " you have to figure out which Array methods do those things. Then try it - post code and ask more questions!
Ogundele Olumide
@Lumexralph
Jan 07 2017 03:36 UTC
@vzambrano98 using the if control statement and return what you're to will exit the function after returning the value so that stops the loop and moreover i<contacts.length stops the loop to when the condition is false
Ken Haduch
@khaduch
Jan 07 2017 03:36 UTC

@vzambrano98 - look for the secret word:

  • If both are true, then return the "value" of that property.

  • If firstName does not correspond to any contacts then return "No such contact"

  • If prop does not correspond to any valid properties then return "No such property"

:)

Victoria Zambrano
@vzambrano98
Jan 07 2017 03:38 UTC
@khaduch @Lumexralph oooooooh okay okay. Thanks guys! I'm gonna go try again lol
CamperBot
@camperbot
Jan 07 2017 03:38 UTC
vzambrano98 sends brownie points to @khaduch and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 677 | @lumexralph |http://www.freecodecamp.com/lumexralph
:warning: vzambrano98 already gave khaduch points
Ogundele Olumide
@Lumexralph
Jan 07 2017 03:40 UTC
@vzambrano98 :+1:
sahilkatia1
@sahilkatia1
Jan 07 2017 03:42 UTC
i didn't get why I am stuck
Brandon Vi
@bvi1994
Jan 07 2017 03:43 UTC
Hi everyone. I need help with Javascropt
For some reason, my values aren't being returned
function randomArticle(){
    location.href = 'https://en.wikipedia.org/wiki/Special:Random';
}

function getSearchTerm(){
    var term = $("#searchTerm").val(); 
    return term;
}

function getJson(term){
    var jsonURL = 'https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=' + term;
    return jsonURL; 
}

function processJSON(jsonURL){
    var data = $.getJSON(jsonURL, function(data){
        getTitles(data);
    });
}

function getTitles(json){
    var titles = [];
    if (json && json.query && json.query.pages){
        var pages = json.query.pages;
    } else {
        alert("Unable to process json");
        return;
    }
    for(var id in pages){
        var title = pages[id].title; // We will assign the current title to the variable title
        if(title){
            titles.push(title); // Push the current title into the array of titles
        } else { 
            alert('Unable retreive title');
            return;
        }
    }
    alert(titles);
    return titles;
}

$(document).ready(function(){
    $('#searchWiki').on('click', function(){
        var searchTerm = getSearchTerm();
        var jsonURL = getJson(searchTerm);
        processJSON(jsonURL);
    });
});
specifically in my processJSON
It's not returning anything, or in any case, not even giving me an alert
I think something's up with my jQuery but I can't tell what
jainishpanchal
@jainishpanchal
Jan 07 2017 03:46 UTC
how to use word blanks ?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 03:47 UTC
@bvi1994 where do you call all these functions?
Huzaifa Gadiwala
@huzaifa83
Jan 07 2017 03:48 UTC

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;
var playerNumber =["Montana"]; // Change this Line
var player = testObj[16]; // Change this Line

jainishpanchal
@jainishpanchal
Jan 07 2017 03:48 UTC

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

// Your code above this line
return result;
}

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

Brandon Vi
@bvi1994
Jan 07 2017 03:48 UTC
@HeebieGeeBee At the bottom of the script
jainishpanchal
@jainishpanchal
Jan 07 2017 03:48 UTC
@HeebieGeeBee hello
Huzaifa Gadiwala
@huzaifa83
Jan 07 2017 03:48 UTC
I am not able to get playerNumber
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 03:49 UTC
$(document).ready(function(){
$('#searchWiki').on('click', function(){
var searchTerm = getSearchTerm();
var jsonURL = getJson(searchTerm);
processJSON(jsonURL);
});
this?
@jainishpanchal hi
Victoria Zambrano
@vzambrano98
Jan 07 2017 03:50 UTC
okay @Lumexralph will you rephrase what you just told me? I thought I got it but I don't, there was a little typo and I missed the mark lol
using the if control statement and return what you're to will exit the function after returning the value so that stops the loop and moreover i<contacts.length stops the loop to when the condition is false
Brandon Vi
@bvi1994
Jan 07 2017 03:50 UTC
@HeebieGeeBee Correct
jainishpanchal
@jainishpanchal
Jan 07 2017 03:51 UTC
@HeebieGeeBee say how to use worldblanks
Ogundele Olumide
@Lumexralph
Jan 07 2017 03:52 UTC
@sahilkatia1
function processJSON(jsonURL){
    var data = $.getJSON(jsonURL, function(data){ // request here is asynchronous and not synchronous
        getTitles(data);     //this function is called while the data is still being requested which will return data as undefined
    });
   data is toring whatever value getTitles returns, remove the `var data`
}`
Huzaifa Gadiwala
@huzaifa83
Jan 07 2017 03:52 UTC
I need some help for playerNumber
please help
jainishpanchal
@jainishpanchal
Jan 07 2017 03:52 UTC

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

// Your code above this line
return result;
}

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

Ogundele Olumide
@Lumexralph
Jan 07 2017 03:52 UTC
@huzaifa83 assign 16 to playerNumber and use that variable to access testObj
jainishpanchal
@jainishpanchal
Jan 07 2017 03:52 UTC
anyone can help me
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 03:53 UTC
@jainishpanchal make result equal a string that is made up of all the parameters plus spaces and wahatever other words you want to add
Ogundele Olumide
@Lumexralph
Jan 07 2017 03:54 UTC
@vzambrano98 when you return the value it all stops, don't worry about that....just get the logics of your if statement right
Ken Haduch
@khaduch
Jan 07 2017 03:55 UTC
@vzambrano98 - using i < contacts.length as your loop control variable will make the for loop exit after looking at all of the contacts. If you get to this point, you haven't found a contact that matches the firstName (hint... hint... )
Within the loop, you should have an if statement to check for the name match, and if one is found, you return one of the two return values that are possible when you match the firstName. (Which will end the loop at that point.)
jainishpanchal
@jainishpanchal
Jan 07 2017 03:55 UTC
@HeebieGeeBee not understand yet?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 03:55 UTC
i dont?
babajide odusola
@cesarecaravaggio
Jan 07 2017 03:56 UTC
@Lumexralph @khaduch working on it now
Brandon Vi
@bvi1994
Jan 07 2017 03:56 UTC
@Lumexralph Ah I see. how would get around opening JSON syncronously?
Victoria Zambrano
@vzambrano98
Jan 07 2017 03:57 UTC
@khaduch ooh okay, I really appreciate your help.
jainishpanchal
@jainishpanchal
Jan 07 2017 03:57 UTC
@HeebieGeeBee wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
Ogundele Olumide
@Lumexralph
Jan 07 2017 03:57 UTC
@bvi1994 can't remember but it'll be in the documentation but it's not a good idea
jainishpanchal
@jainishpanchal
Jan 07 2017 03:58 UTC

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

// Your code above this line
return result;
}

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

HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 03:58 UTC
result = myNoun + ' ' + myAdjective + ' ' + .....................
jainishpanchal
@jainishpanchal
Jan 07 2017 03:59 UTC
ok
Ayush Bahuguna
@relentless-coder
Jan 07 2017 03:59 UTC

why does

{foo: 'bar'} === x

yield true?

Dylan Hsiao
@greedylan
Jan 07 2017 03:59 UTC
hello everyone, I am doing "Convert HTML Entities". I wonder if my thinking is right. Do we start building an object variable with special character for the property and HTML entities for the property value and plug it into .replace() method?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:00 UTC
foo is true?
Ogundele Olumide
@Lumexralph
Jan 07 2017 04:01 UTC
@relentless-coder what is x ?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:01 UTC
@greedylan why not just replace the charcter with the html entity?
jainishpanchal
@jainishpanchal
Jan 07 2017 04:02 UTC

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

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

Dylan Hsiao
@greedylan
Jan 07 2017 04:02 UTC
@HeebieGeeBee could not find a native javascript for doing that, please advise??
Ogundele Olumide
@Lumexralph
Jan 07 2017 04:02 UTC
@jainishpanchal typo myNone should be myNoun put space also in the string literals
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:03 UTC
replace using regex and the html entity?
@jainishpanchal you also need to put in spaces
Dylan Hsiao
@greedylan
Jan 07 2017 04:03 UTC
@HeebieGeeBee yeah but I have multiple characters therefore the object properties and properties values
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:04 UTC
switch, if statements?
Dylan Hsiao
@greedylan
Jan 07 2017 04:04 UTC
@HeebieGeeBee that takes up many lines of codes?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:05 UTC
how else you gonna do it?
jainishpanchal
@jainishpanchal
Jan 07 2017 04:06 UTC
@Lumexralph ok 1 min
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:06 UTC
youve only got 5 symbols to replace
Ryan
@Azbo400
Jan 07 2017 04:06 UTC
@greedylan I used replace and regular expressions for that challenge
Dylan Hsiao
@greedylan
Jan 07 2017 04:06 UTC
@HeebieGeeBee thru object and accessing the property and the property values as stated in the beginning
Ryan
@Azbo400
Jan 07 2017 04:07 UTC
on one solution I saw they used switch statements too
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:07 UTC
RegExp
HTML Entities
String.prototype.replace()
this is the suggested reading material for the exercise right? @greedylan
jainishpanchal
@jainishpanchal
Jan 07 2017 04:08 UTC

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

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

not working
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:08 UTC
add spaces @jainishpanchal
and its myNoun not mynone
Dylan Hsiao
@greedylan
Jan 07 2017 04:09 UTC
@HeebieGeeBee yes they are
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:09 UTC
well i think youre going to have to write a few lines @greedylan
i dunno how else youre gonna do it
Dylan Hsiao
@greedylan
Jan 07 2017 04:10 UTC
@HeebieGeeBee @Azbo400 Imma try stuff right now
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 04:12 UTC
I need help for challenge Find the Longest Word in a String:

function findLongestWord(str) {
var newStr = str.split(",");
var x = newStr[""];
var y = newStr[""];
if( x > y){
return newStr[x].length;
}
}

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

HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:12 UTC
@unlawfulspoonisback why are splitting by ','?
Ogundele Olumide
@Lumexralph
Jan 07 2017 04:13 UTC
@unlawfulspoonisback split the string, to an array loop through it and keep track of the length of each word in the array and return the largest
mitron6
@mitron6
Jan 07 2017 04:13 UTC
@unlawfulspoonisback most,sentences,are,not,written,like,this,right?
jainishpanchal
@jainishpanchal
Jan 07 2017 04:13 UTC
@HeebieGeeBee thanks man
CamperBot
@camperbot
Jan 07 2017 04:13 UTC
jainishpanchal sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 463 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Ryan
@Azbo400
Jan 07 2017 04:14 UTC
@greedylan Yeah that algo was really easy
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 04:15 UTC
@Lumexralph @HeebieGeeBee thanks
CamperBot
@camperbot
Jan 07 2017 04:15 UTC
unlawfulspoonisback sends brownie points to @lumexralph and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 464 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:cookie: 678 | @lumexralph |http://www.freecodecamp.com/lumexralph
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 04:20 UTC
how do I assign a variable to each element in the array
@Lumexralph
@HeebieGeeBee
without knowing what it is
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:21 UTC
why do you need to?
you can do something like var word1 = arr[0] or summin
but dont know why you need to
Brian
@BrianCodes33
Jan 07 2017 04:22 UTC
i cant wrap my head around sorted union
Albert L. C.
@sirus3020
Jan 07 2017 04:22 UTC
guys I have a question about recursion.

var countdown = function(value) {
if (value > 0) {
console.log(value);
return countdown(value - 1);
} else {
return value;
}
};
countdown(10);

how is this looping?

HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:24 UTC
becuase theres nothing stopping it?
Albert L. C.
@sirus3020
Jan 07 2017 04:24 UTC
doesn't the return command stop it?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:24 UTC
if it gets called
Ogundele Olumide
@Lumexralph
Jan 07 2017 04:25 UTC
@unlawfulspoonisback you don't need to assign a variable to each element, just keep track of the length of each element
@sirus3020 it's not looping per say...it's just a function calling itself again
@sirus3020 but you can mimic it to be a loop, it calls itself over and over again until the condition is met
Albert L. C.
@sirus3020
Jan 07 2017 04:27 UTC
oh ok. thanks! @HeebieGeeBee @Lumexralph
CamperBot
@camperbot
Jan 07 2017 04:27 UTC
sirus3020 sends brownie points to @heebiegeebee and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 465 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:cookie: 679 | @lumexralph |http://www.freecodecamp.com/lumexralph
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:27 UTC
if value is 10 its going to be greater than 0 so the return is the function but 9 as parameter now and so on and so on
Derek Frankel
@TuvyaYis
Jan 07 2017 04:29 UTC
how are you supposed to copy and send code again???
formatting it correctly
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:30 UTC
'''
CamperBot
@camperbot
Jan 07 2017 04:30 UTC
:bulb: to format code use backticks! ``` more info
Ryan
@Azbo400
Jan 07 2017 04:31 UTC
:point_up:
hariharanguru83
@hariharanguru83
Jan 07 2017 04:31 UTC
var singleVal = array.reduce(function(previousVal, currentVal){
  return previousVal - currentVal;
});

Use the reduce method to sum all the values in array and assign it to singleVal.

Need help

Ogundele Olumide
@Lumexralph
Jan 07 2017 04:32 UTC
@hariharanguru83 what do you need help with?
hariharanguru83
@hariharanguru83
Jan 07 2017 04:32 UTC
singleVal should be equal to the sum of all items in the array variable.
can you please explain
Brian
@BrianCodes33
Jan 07 2017 04:33 UTC
you just need to add
why are you subtracting
Ogundele Olumide
@Lumexralph
Jan 07 2017 04:33 UTC
@hariharanguru83 reduce takes the element from index 0 as previous and the next at index i 1 as nextvalue...but here you sum + not -
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:34 UTC
is there way to import into codepen?
or do you just have to copy and paste
Ogundele Olumide
@Lumexralph
Jan 07 2017 04:34 UTC
hariharanguru83
@hariharanguru83
Jan 07 2017 04:34 UTC
ok
Brian
@BrianCodes33
Jan 07 2017 04:34 UTC
can someone help me w/ sorted union challenge? i am so stuck don’t know where to begin or what question is asking
Ogundele Olumide
@Lumexralph
Jan 07 2017 04:34 UTC
@HeebieGeeBee just copy the link and paste
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:35 UTC
i mean like the full code of a project
whats the problem @BrianCodes33
Ogundele Olumide
@Lumexralph
Jan 07 2017 04:35 UTC
@HeebieGeeBee import to where exactly?
Brian
@BrianCodes33
Jan 07 2017 04:35 UTC
i really dont understand the question @HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:35 UTC
i just meant you know like you can export all the files
Brian
@BrianCodes33
Jan 07 2017 04:35 UTC
@HeebieGeeBee i think its only for css js html i don’t think you can import a bunch of files in codepen
but i may be wrong
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:36 UTC
if you could work in a desktop and editor and just import all the files
yeah
or maybe its a paid feature
Brian
@BrianCodes33
Jan 07 2017 04:37 UTC
perhaps. its not used for production just as a ‘playground for front end’ as they call it
Ogundele Olumide
@Lumexralph
Jan 07 2017 04:37 UTC
@HeebieGeeBee search for it you never know...but it should be possible only if it doesn't have the feature
Victoria Zambrano
@vzambrano98
Jan 07 2017 04:37 UTC
@khaduch I know you are practically giving my the answer I just don't understand lol! I have a really hard time with logical order, so maybe that's what this is. but also, my code isn't recognizing my arguments "firstName" or "prop", and therefor always returning the last return statement I have(I ran it through pythontutor.com, i obviously had no idea lol)

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


function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i=0; i<contacts.length; i++){
for (var j=0; j<contacts[i].length;j++){
    if (contacts[i][j][prop]===undefined){
      return "No such property";
    } else if (contacts[i][j][firstName]===undefined){
      return "No such contact";
    } else if (contacts[i][j].hasOwnProperty(firstName) && contacts[i].hasOwnProperty(prop)){ 
      return contacts[i][j][prop];
    }}
  }
// Only change code above this line
}
// Change these values to test your function
lookUpProfile("Akira", "likes");
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:38 UTC
@BrianCodes33 do you understand about arguments?
Brian
@BrianCodes33
Jan 07 2017 04:38 UTC
i think i get the arguments object
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:39 UTC
well first thing i saw
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 04:39 UTC
my code is not working:

function findLongestWord(str) {
var words = str.split(" ");
var max = 0;
for (i = 0; i < max.length; i++) {
if (words[i].length > max.length) {
return words[i].lenghth;
}
}
}

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

HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:40 UTC
@BrianCodes33 was that arr needs to be made into a proper array of all the arguments
Brian
@BrianCodes33
Jan 07 2017 04:40 UTC
ok but i still dont get the question
i mean i dont get what im trying to do
i think thats the biggest prob
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 04:40 UTC
and how do you show a picture of you code like other people
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:41 UTC
youre trying to create an array of all the elements of all the arrays but without adding doubles and with keeping the order
''' @unlawfulspoonisback
CamperBot
@camperbot
Jan 07 2017 04:41 UTC
:bulb: to format code use backticks! ``` more info
Brian
@BrianCodes33
Jan 07 2017 04:42 UTC
ohhh
ok
Bryan Reese
@breese8009
Jan 07 2017 04:42 UTC
hey guys
Brian
@BrianCodes33
Jan 07 2017 04:42 UTC
hey @breese8009
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 04:43 UTC
my code is not working:

function findLongestWord(str) {
var words = str.split(" ");
var max = 0;
for (i = 0; i < max.length; i++) {
if (words[i].length > max.length) {
max.length = words[i].lenghth;
}
}
return words[i].length;
}

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

HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:44 UTC
@unlawfulspoonisback not max.length
just max, max is already a number
also look at your spelling mistakes @unlawfulspoonisback
Bryan Reese
@breese8009
Jan 07 2017 04:44 UTC
converting an object literal into array of arrays
array of arrays*
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 04:45 UTC
still not working:

function findLongestWord(str) {
var words = str.split(" ");
var max = 0;
for (i = 0; i < max; i++) {
if (words[i].length > max) {
max = words[i].length;
}
}
return words[i].length;
}

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

Brian
@BrianCodes33
Jan 07 2017 04:45 UTC
like this @HeebieGeeBee

function uniteUnique(arr) {
  var args = Array.prototype.slice.call(arguments);
  console.log(args);
  args.reduce(function(){

  });
  return arr;
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:46 UTC
@unlawfulspoonisback are you meant to return how long the word is or the word thats the longest?>
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 04:46 UTC
how long the longest word is
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:47 UTC
no idea what that method is @BrianCodes33
then dont you think you should return that? @unlawfulspoonisback
Ken Haduch
@khaduch
Jan 07 2017 04:47 UTC

@vzambrano98 - sorry, I spaced out for a while... getting late! :)
Let's see - you do not need a second forloop- this is an array of objects, so you need the loop with the contacts.length to iterate through the array. The objects, which are accessed with contacts[i] as the reference to the object, can be directly accessed with the properties in one form or another. It looks like you have the basic idea, but that inner loop is doing something that is not useful. If it was an array of arrays, then that would be a different story.

So you're on the right track - contacts[i].firstName can be used directly to access the firstName property of each contact object.

To access the other values (other properties) you will be given property names in the variable (function argument) prop - and you can use contacts[i][prop] to access those, contacts[i].hasOwnProperty(prop) to check that the property exists on a given object.

Why don't you digest that and try to make some changes. I'm going to be on for a short while, see if you get closer... (BTW, there is still a problem with the conditions under which you are returning "No such contact"

Brian
@BrianCodes33
Jan 07 2017 04:47 UTC
@HeebieGeeBee well i thought i need to use reduce
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:47 UTC
Array.prototype.slice.call its this one i dont know what is
Victoria Zambrano
@vzambrano98
Jan 07 2017 04:48 UTC
@Khaduch Okay, yes, digestion of these things.
Thanks again for your time and patience! I'm probably not going to get this before I zonk out as well lol! but I am definitely finding that no matter what it is returning "No such contact" so I will sort through that.
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:48 UTC
and reduce will need a function that actually has something in it
Brian
@BrianCodes33
Jan 07 2017 04:48 UTC
i know im just setting it up
havent figured that out yet
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:49 UTC
what does Array.prototype.slice.call do?
Bryan Reese
@breese8009
Jan 07 2017 04:49 UTC
who can write a function that turns an object literal into an array of arrays?? anyone??
Ken Haduch
@khaduch
Jan 07 2017 04:49 UTC
@breese8009 - is this one of the lessons - which one?
Brian
@BrianCodes33
Jan 07 2017 04:49 UTC
gives me the arguments to work with in an objec
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 04:50 UTC
@HeebieGeeBee I am trying to return the length of the longest word
Bryan Reese
@breese8009
Jan 07 2017 04:50 UTC

var obj={
name:"Holly",
age:35,
role:"producer"

}
function convertObjectToList(obj) {

return ;

}

Brian
@BrianCodes33
Jan 07 2017 04:50 UTC
@breese8009 can you post the challenge or code
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:50 UTC
then return that @unlawfulspoonisback
Bryan Reese
@breese8009
Jan 07 2017 04:50 UTC
its not a challenge from FCC
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:50 UTC
what does your function return at the moment @unlawfulspoonisback
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 04:50 UTC
nothing
CamperBot
@camperbot
Jan 07 2017 04:51 UTC
:bulb: to format code use backticks! ``` more info
Ken Haduch
@khaduch
Jan 07 2017 04:51 UTC
@breese8009 - what is this "array of arrays" supposed to look like? would it be [ ["name", "Holly"], ["age", 35} etc.?
Bryan Reese
@breese8009
Jan 07 2017 04:51 UTC
@khaduch exactly
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:51 UTC
the backticks then shift enter @unlawfulspoonisback
then paste
Brian
@BrianCodes33
Jan 07 2017 04:52 UTC
@breese8009 if you want to iterate an object literal i’d check out the for in loop
Ogundele Olumide
@Lumexralph
Jan 07 2017 04:52 UTC
@BrianCodes33 return max
Brian
@BrianCodes33
Jan 07 2017 04:52 UTC
@Lumexralph ?
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 04:52 UTC

function findLongestWord(str) {
  var words = str.split(" ");
  var max = 0;
  for (i = 0; i < max; i++) {
    if (words[i].length > max) {
      max = words[i].length;
    }
  }
  return words[i].length;
  }

findLongestWord("The quick brown fox jumped over the lazy dog");
Brian
@BrianCodes33
Jan 07 2017 04:52 UTC
no answers haha
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:52 UTC
he means @unlawfulspoonisback
Ken Haduch
@khaduch
Jan 07 2017 04:53 UTC
@breese8009 - there is a function, or method Object.keys (if I remember correctly) that will give you an array of the object keys. Then you could just iterate over that array, and generate the sub arrays. Does that give you something to go on?
Ogundele Olumide
@Lumexralph
Jan 07 2017 04:53 UTC
@BrianCodes33 :laughing: my bad sorry
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:53 UTC
return words[i].length; change to return max;
Ogundele Olumide
@Lumexralph
Jan 07 2017 04:53 UTC
@unlawfulspoonisback return max
@HeebieGeeBee :+1:
Bryan Reese
@breese8009
Jan 07 2017 04:54 UTC
@khaduch I think so, let me go play with it a little bit
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 04:54 UTC
still does not work
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:54 UTC
lol was trying to make him figure it out a bit but since you gave the answer
Doegena Fennich
@Doegena
Jan 07 2017 04:55 UTC
@unlawfulspoonisback var word is unnecessary
Ogundele Olumide
@Lumexralph
Jan 07 2017 04:55 UTC
@HeebieGeeBee sorry bro.....lol
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:55 UTC
lol no worries
Doegena Fennich
@Doegena
Jan 07 2017 04:55 UTC
@unlawfulspoonisback str = str.split(" ") is the same
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 04:56 UTC
still does not work

function findLongestWord(str) {
  var words = str.split(" ");
  var max = 0;
  for (i = 0; i < max; i++) {
    if (words[i].length > max) {
      max = words[i].length;
    }
  }
  return words[i].length;
  }

findLongestWord("The quick brown fox jumped over the lazy dog");
Doegena Fennich
@Doegena
Jan 07 2017 04:56 UTC
return max
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 04:56 UTC
hold on
function findLongestWord(str) {
  var words = str.split(" ");
  var max = 0;
  for (i = 0; i < max; i++) {
    if (words[i].length > max) {
      max = words[i].length;
    }
  }
  return max;
  }

findLongestWord("The quick brown fox jumped over the lazy dog");
Ogundele Olumide
@Lumexralph
Jan 07 2017 04:57 UTC
@Doegena it's not the same, remember the order of operation? right to left
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 04:57 UTC
does not work
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 04:57 UTC
why did you change it to i < max?
i < words.length
Bryan Reese
@breese8009
Jan 07 2017 04:59 UTC
@HeebieGeeBee careful wasting your time with this guy, he is a known troll and it looks like hes taking u for a ride. Take a look at the Admin room...
CamperBot
@camperbot
Jan 07 2017 04:59 UTC
:trollface: troll problems? notify admins here
Doegena Fennich
@Doegena
Jan 07 2017 05:00 UTC

@Lumexralph

var count = 0;
  var max = str.split(' ');
  for (var i = 0; i < max.length; i++) {   
          if ( max[i].length > count ) {
            count = max[i].length;
          }   
  }

is the same as (well same results)

str = str.split(' ');
  for (var i = 0; i < str.length; i++) {   
          if ( str[i].length > count ) {
            count = str[i].length;
          }   
  }
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 05:00 UTC

function findLongestWord(str) {
  var words = str.split(' ');
  var max = 0;

  for (var i = 0; i < words.length; i++) {
    if (words[i].length > max) {
      max = words[i].length;
    }
  }

  return max;
}
findLongestWord("The quick brown fox jumped over the lazy dog");
Ogundele Olumide
@Lumexralph
Jan 07 2017 05:00 UTC
@Doegena seen it now?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 05:01 UTC
cus its the solution
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 05:02 UTC
what do you mean
I changed max to words.length
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 05:03 UTC
yes
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 05:03 UTC
@Lumexralph @HeebieGeeBee thanks
CamperBot
@camperbot
Jan 07 2017 05:03 UTC
unlawfulspoonisback sends brownie points to @lumexralph and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:warning: unlawfulspoonisback already gave heebiegeebee points
:warning: unlawfulspoonisback already gave lumexralph points
6thSen
@6thSen
Jan 07 2017 05:04 UTC
hey guys need some help with the profile lookup excerise. I've gotten it to the point where it can return the property if the name matches and also when there is no such property. but for some reason it won't return "no such contact". a 2nd pair of eyes would be appreciated.
Jordan
@jl-code1721
Jan 07 2017 05:04 UTC
I don't get what I'm meant to do in the 155th Challenge
Can someone explain
6thSen
@6thSen
Jan 07 2017 05:04 UTC
here's what I got so far:
function lookUpProfile(firstName, prop){
// Only change code below this line
var i = 0;
while (i < contacts.length) {
  if (contacts[i].firstName == firstName) {
    if(contacts[i].hasOwnProperty(prop) === true) {
      return contacts[i][prop];
    } else {
      return "No such property";
    }
  } else {
      if (i < contacts.length) {
        i++;
      } else {
        return "No such contact";
      }
  }

}
// Only change code above this line
}
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 05:05 UTC
what is the name
@jl-code1721
Jordan
@jl-code1721
Jan 07 2017 05:05 UTC
Word Blanks
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 05:07 UTC
ok hold on
show code @jl-code1721
Ken Haduch
@khaduch
Jan 07 2017 05:09 UTC
@jl-code1721 - you are given four words as the four function arguments. You are only supposed to use string concatenation to connect them together, with a space " " between each word, and return that "sentence" to the caller. Fairly straightforward (although this seems to be a challenge that stumps a lot of people.)
Ogundele Olumide
@Lumexralph
Jan 07 2017 05:09 UTC
@6thSen when you're done looking through the contacts, return no such contacts
Jordan
@jl-code1721
Jan 07 2017 05:10 UTC
@khaduch Where do I put the spaces
6thSen
@6thSen
Jan 07 2017 05:10 UTC
@Lumexralph I think I did that
Ken Haduch
@khaduch
Jan 07 2017 05:11 UTC
@6thSen - you will never reach that condition for your "else" because once you increment i past the length, the while loop will terminate. You should put your return "No such contact"; in a place after the loop ends, because then you will know that you found no match.
@jl-code1721 - between each word - myNoun + " " + myVerb, etc.
Jordan
@jl-code1721
Jan 07 2017 05:11 UTC
Nevermind, I worked it out. Thanks, @khaduch
CamperBot
@camperbot
Jan 07 2017 05:11 UTC
jl-code1721 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2225 | @khaduch |http://www.freecodecamp.com/khaduch
Ogundele Olumide
@Lumexralph
Jan 07 2017 05:12 UTC
@6thSen you sure about that?
Ken Haduch
@khaduch
Jan 07 2017 05:12 UTC
@jl-code1721 - great!
6thSen
@6thSen
Jan 07 2017 05:12 UTC
@khaduch okay, that makes sense. let me see if I can do it
@Lumexralph I think I understand what you meant now after @khaduch explained it to me
Ken Haduch
@khaduch
Jan 07 2017 05:13 UTC
@6thSen - okay. As you probably figured out, your returns of matching contacts happens inside the for loop - while you are within the list. After you finish the list, your loop will end, and if you haven't returned from within the loop, return after the body of the loop.
AnshulDawar
@anshuldawar
Jan 07 2017 05:13 UTC

ERROR :worried: nextInLine([], 1) should return 1
function nextInLine(arr, item) {
// Your code here

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, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

RJ
@IronyOfRyan
Jan 07 2017 05:14 UTC
Theres also an extra closing bracket you dont need.
khaduch @khaduch - all done for the night... I hate to leave but my eyes are telling me to. I hope you all have happy coding hours ahead! :) :zzz:
Ogundele Olumide
@Lumexralph
Jan 07 2017 05:15 UTC
@anshuldawar push item to arr before returning the first element in arr
Ayush Bahuguna
@relentless-coder
Jan 07 2017 05:15 UTC
recently I missed a job opportunity because I didn't how to implement jsonp to retrieve data from a on system json file. Can anyone help me with this, I don't want this to happen again
6thSen
@6thSen
Jan 07 2017 05:15 UTC
bingo
```
function lookUpProfile(firstName, prop){
// Only change code below this line
var i = 0;
while (i < contacts.length) {
if (contacts[i].firstName == firstName) {
if(contacts[i].hasOwnProperty(prop) === true) {
return contacts[i][prop];
} else {
return "No such property";
}
} else {
i++;
}
}
return "No such contact";
@khaduch @Lumexralph thanks
CamperBot
@camperbot
Jan 07 2017 05:15 UTC
6thsen sends brownie points to @khaduch and @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 680 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 2226 | @khaduch |http://www.freecodecamp.com/khaduch
Yori Garcia Rosario
@Yori1
Jan 07 2017 05:16 UTC

Guys I'm completely stuck on this one.

Assignment:In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.

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.

Code:


// Example
var ourArray = ["Stimpson", "J", ["cat"]];
removedFromOurArray = ourArray.shift();
// removedFromOurArray now equals "Stimpson" and ourArray now equals ["J", ["cat"]].

// Setup
var myArray = [["John", 23], ["dog", 3]];

// Only change code below this line.
var removedFromMyArray;
Ogundele Olumide
@Lumexralph
Jan 07 2017 05:16 UTC
@6thSen :smile:
Ken Haduch
@khaduch
Jan 07 2017 05:16 UTC
@6thSen :+1: and you should check out the markdown code posting technique - follow the info in the link that will post next. '''
CamperBot
@camperbot
Jan 07 2017 05:16 UTC
:bulb: to format code use backticks! ``` more info
Yori Garcia Rosario
@Yori1
Jan 07 2017 05:16 UTC
wait that's the wrong one sorry
6thSen
@6thSen
Jan 07 2017 05:17 UTC
will do :)
Yori Garcia Rosario
@Yori1
Jan 07 2017 05:17 UTC

In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.

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.


function nextInLine(arr, item) {
  // Your code here
  arr = testArr;
  item = 5;

  testArr.push(item);
  testArr.shift();

  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));
Ogundele Olumide
@Lumexralph
Jan 07 2017 05:18 UTC
@Yori1 a function helps you put a value at the end of an array, what is it? and another helps you remove and return the first element in an array , if you know both you're done
@Yori1 arr is the array not testArray, use the parameter
Yori Garcia Rosario
@Yori1
Jan 07 2017 05:19 UTC
@Lumexralph Oh that's where I made a mistake then, thanks a lot
CamperBot
@camperbot
Jan 07 2017 05:19 UTC
yori1 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 681 | @lumexralph |http://www.freecodecamp.com/lumexralph
Yori Garcia Rosario
@Yori1
Jan 07 2017 05:19 UTC
@Lumexralph what's a parameter?
Ogundele Olumide
@Lumexralph
Jan 07 2017 05:21 UTC
@Yori1 it's a variable/placeholder/ container in a function that holds the value of the argument passed to a function when called
AnshulDawar
@anshuldawar
Jan 07 2017 05:21 UTC
@Lumexralph THanks
arr.push(item);
var shiftt = arr.shift();
return shiftt; // Change this line
}
it worked!
CamperBot
@camperbot
Jan 07 2017 05:21 UTC
anshuldawar sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 682 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Jan 07 2017 05:21 UTC
@anshuldawar cool
Yori Garcia Rosario
@Yori1
Jan 07 2017 05:22 UTC
@Lumexralph Oh that makes sense, so my code didn't work there because I was using a variable instead of a parameter in the function
Ogundele Olumide
@Lumexralph
Jan 07 2017 05:24 UTC
@Yori1 not really, i said like a variable....not a variable but it acts like a variable in a function cos both of them holds values
it holds a value for your function when it's called
Yori Garcia Rosario
@Yori1
Jan 07 2017 05:26 UTC
@Lumexralph Ok, I'll keep that in mind
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 05:29 UTC
dont know what to do in title case a sentence can you give me an idea @Lumexralph
tech-tron
@tech-tron
Jan 07 2017 05:29 UTC
thanks @Lumexralph
CamperBot
@camperbot
Jan 07 2017 05:29 UTC
tech-tron sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 683 | @lumexralph |http://www.freecodecamp.com/lumexralph
tech-tron
@tech-tron
Jan 07 2017 05:31 UTC
@unlawfulspoonisback i used charAt index 0 and set it toUpperCase the added a slice of the rest of the string if that helps
Bryan Reese
@breese8009
Jan 07 2017 05:31 UTC
@khaduch hey u still there?
tech-tron
@tech-tron
Jan 07 2017 05:32 UTC
nothing fancy, i think i did it all with just the return statement
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 05:32 UTC
can you explain to me what charat is @tech-tron
or what is does
tech-tron
@tech-tron
Jan 07 2017 05:33 UTC
yeah. see with the slice being the entire string except the first letter, i used the charAt(0) to return the character at index 0 (i.e. the first letter)
ahhh, im new at this
i ve been studying arrays and stuff and i PROMISE it gets better
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 05:34 UTC
oh thankyou
tech-tron
@tech-tron
Jan 07 2017 05:34 UTC
np
most of them are really simple in theory its just the fact you have to do everything in code that makes it hard
Ken Haduch
@khaduch
Jan 07 2017 05:35 UTC
@breese8009 - I came back just for you... what's up?
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 05:35 UTC
oh thankyou
tech-tron
@tech-tron
Jan 07 2017 05:35 UTC
in your example i went for
a simple
1 make first charachter capital
2 add the entire string minus the first letter
i almost quit when i made it to the algorithmic section then i took some time through youtube to learn all these prototypes and now im currently going through it a second time and it is not pretty, the codes are long and overdrawn but they're my codes
Ken Haduch
@khaduch
Jan 07 2017 05:42 UTC
@breese8009 - still there??
Bryan Reese
@breese8009
Jan 07 2017 05:42 UTC

@khaduch haha thanks, I cant figure out the solution to that same code from before var obj={
name:"Holly",
age:35,
role:"producer"

}
function convertObjectToList(obj) {
return;

} cant figure out how to turn object literal into an array of arrays...

CamperBot
@camperbot
Jan 07 2017 05:42 UTC
breese8009 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2227 | @khaduch |http://www.freecodecamp.com/khaduch
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 05:43 UTC
my code is not working for the challenge title case a sentence:
John Gu
@loop1
Jan 07 2017 05:43 UTC

function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor

if(str.substr(-1)==target){

return true;}

else {return false;}
}

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

Ken Haduch
@khaduch
Jan 07 2017 05:43 UTC
@breese8009 - I'm signing out again - not sure if this does exactly what you want, but try this:
var obj = {
  name: 'Holly',
  age: 35,
  role: 'producer'
}
function convertObjectToList(obj) {
  var myArr = [
  ];
  for (var i in obj) {
    console.log(i);
    console.log(obj[i]);
    myArr.push([i,
    obj[i]]);
  }
  return myArr;
}
var result = convertObjectToList(obj);
console.log(result)
jrsbali
@jrsbali
Jan 07 2017 05:44 UTC

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

var myStr = "FirstLine\n\SecondLine\\rThirdline";

I keep getting an error for this. Can anyone help me or is this a bug?

Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 05:44 UTC
function titleCase(str) {
  var word = str.split("");
  word.slice().charCodeAt(0).toUpperCase();

}

titleCase("I'm a little tea pot");
My code is not working for the challenge title case a sentence
John Gu
@loop1
Jan 07 2017 05:45 UTC
what is wrong with this program?
Ken Haduch
@khaduch
Jan 07 2017 05:45 UTC
@loop1 - sometimes your "target" is longer than one character, that could be it...
John Gu
@loop1
Jan 07 2017 05:45 UTC
str.substring(str.length-target.length) === target;
Ken Haduch
@khaduch
Jan 07 2017 05:46 UTC
@loop1 - you do have to use target.length in there.
Ogundele Olumide
@Lumexralph
Jan 07 2017 05:46 UTC
@jrsbali \\ before and after SecondLine
John Gu
@loop1
Jan 07 2017 05:46 UTC
what this mean?
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 05:46 UTC
function titleCase(str) {
  var word = str.split("");
  word.slice().charCodeAt(0).toUpperCase();

}

titleCase("I'm a little tea pot");
MY CODE IS NOT WORKING NEED HELP
ml3ha
@ml3ha
Jan 07 2017 05:47 UTC
what are you trying to do? @unlawfulspoonisback
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 05:47 UTC
title case a sentence
John Gu
@loop1
Jan 07 2017 05:48 UTC
@khaduch what is this mean ?(str.length-target.length)
ml3ha
@ml3ha
Jan 07 2017 05:48 UTC
why aren't you splitting by spaces? word = str.split(" ");
Isnt title casing making the first letter of each word capital
超峰
@fenghuilu
Jan 07 2017 05:49 UTC

function lookUp(firstName, prop){
// Only change code below this line
for(var i=0;i<contacts.length;i++){

if(contacts[i].firstName == firstName){
if(contacts[i].hasOwnProperty(prop)){
return contacts[i].prop;
}else{
return "No such property";
}
}

if(i == contacts.length-1){
return "No such contact";
}

}

Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 05:49 UTC
yes
ml3ha
@ml3ha
Jan 07 2017 05:49 UTC
You are splitting the word by letter, not by spaces. So that's the first change
Ogundele Olumide
@Lumexralph
Jan 07 2017 05:49 UTC
@fenghuilu prop is a variable dot method won't work use [ ] method
Ken Haduch
@khaduch
Jan 07 2017 05:49 UTC
@loop1 - you take the length of the str argument, and subtract the length of the target argument, and that is what you pass to the .substring method. It tells you where in the string (the index) to start extracting the substring, and if you only pass one argument, it will extract all the way to the end.
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 05:49 UTC
ok what do i do next
ml3ha
@ml3ha
Jan 07 2017 05:50 UTC
then you could just do a for loop for each element of your word variable and do a toUpperCase() to the first letter
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 05:50 UTC
how do I select the first letter thought
khaduch @khaduch - now I'm leaving again for the night... happy coding everyone!
ml3ha
@ml3ha
Jan 07 2017 05:51 UTC

function titleCase(str) {
var word = str.split(" ");
for (var i = 0; i < word.length; i++) {
word[i].substring(0,1).toUpperCase();
}

}

Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 05:52 UTC
your code did not work
ml3ha
@ml3ha
Jan 07 2017 05:53 UTC
You need to return the string
do a .join() on word.
Ogundele Olumide
@Lumexralph
Jan 07 2017 05:53 UTC
@unlawfulspoonisback @ml3ha is on the way with you, this is how you'll continue.....word is an array, right?
超峰
@fenghuilu
Jan 07 2017 05:54 UTC

function lookUp(firstName, prop){
// Only change code below this line
for(var i=0;i<contacts.length;i++){

if(contacts[i][firstName] === firstName){
if(contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
}else{
return "No such property";
}
}

if(i == contacts.length-1){
return "No such contact";
}

}

it does not work too
ml3ha
@ml3ha
Jan 07 2017 05:55 UTC
Oh ok im on the page, looks like theres some edge cases @unlawfulspoonisback
Ogundele Olumide
@Lumexralph
Jan 07 2017 05:55 UTC
@unlawfulspoonisback you'll use for loop like you did
@fenghuilu if(contacts[i][firstName] === firstName){ should be if(contacts[i]["firstName"] === firstName){
ml3ha
@ml3ha
Jan 07 2017 05:55 UTC
Here, i just did the challenge:

function titleCase(str) {
var splitted = str.split(" ");
for (var i = 0; i < splitted.length; i++) {
splitted[i] = splitted[i].substring(0,1).toUpperCase() + splitted[i].substring(1).toLowerCase();
}
return splitted.join(" ");
}

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

passed the test cases
try to understand what im doing there though
Coy Sanders
@coymeetsworld
Jan 07 2017 05:56 UTC
@ml3ha try not to give out the answer when helping please
ml3ha
@ml3ha
Jan 07 2017 05:56 UTC
ok
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 05:56 UTC
@Lumexralph you sure about that?
grantknaver
@grantknaver
Jan 07 2017 05:56 UTC
how to use func... arr.func doesn't work
ml3ha
@ml3ha
Jan 07 2017 05:56 UTC
my bad
Coy Sanders
@coymeetsworld
Jan 07 2017 05:57 UTC
its ok no worries, people won't learn if you just give answers out
then they move on without understanding things they need to know to complete other challenges
grantknaver
@grantknaver
Jan 07 2017 05:57 UTC
Ive been trying if (arr.func ){
here is the challenge
Ogundele Olumide
@Lumexralph
Jan 07 2017 05:57 UTC
@HeebieGeeBee about what?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 05:58 UTC
['firstName']?
if(i == contacts.length-1){
return "No such contact"; @fenghuilu this is a problem
Ogundele Olumide
@Lumexralph
Jan 07 2017 05:58 UTC
@HeebieGeeBee either Object.firstName or Object["firstName"] they are both properties in object
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 05:59 UTC
i think its [firstName]
超峰
@fenghuilu
Jan 07 2017 05:59 UTC
if(contacts[i][firstName] === firstName){ should be if(contacts[i]["firstName"] === firstName){ this works,but i do not understand...
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 05:59 UTC
['firstName'] would imply its a string 'firstName' wouldnt it?
超峰
@fenghuilu
Jan 07 2017 06:00 UTC
firstName already has ""
Ogundele Olumide
@Lumexralph
Jan 07 2017 06:00 UTC
@HeebieGeeBee he's accessing the firstName property in contacts to check against firstName parameter
Aman
@amansat
Jan 07 2017 06:01 UTC
Stuck here. Don't know what to do. Please help.
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:01 UTC
yeah and firstName is a parameter not a string
isnt it?
超峰
@fenghuilu
Jan 07 2017 06:01 UTC
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"]
}
];
lookUp("Akira", "likes");
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:01 UTC
oh ok sorry
its a string
grantknaver
@grantknaver
Jan 07 2017 06:02 UTC
any idea guys
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:02 UTC
think im getting mixed up with the record one
jakobmara
@jakobmara
Jan 07 2017 06:02 UTC
can someone help me with the "Title Case Sentence"?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:02 UTC
@Lumexralph sorry
Ogundele Olumide
@Lumexralph
Jan 07 2017 06:02 UTC
@fenghuilu when you're done looking through the contacts i.e when the loop is done...just return no such contacts outside the loop.....
超峰
@fenghuilu
Jan 07 2017 06:03 UTC
firstName already has "" ,why i have to add another "" when iuse it?
Ogundele Olumide
@Lumexralph
Jan 07 2017 06:03 UTC
@fenghuilu :point_up: :point_up: January 7, 2017 6:57 AM look at what @HeebieGeeBee said here too
@HeebieGeeBee keine Probleme :smile:
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 06:04 UTC
can someone help I still dont know what to do on Title Case a Sentence
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:05 UTC
find the first letter in a word and turn it into an uppercase letter
CamperBot
@camperbot
Jan 07 2017 06:05 UTC
find the first letter in a word and turn it into an uppercase letter
nothing found
Ogundele Olumide
@Lumexralph
Jan 07 2017 06:05 UTC
@fenghuilu it's the property/key of the object and it's a string
Nathan Parsons
@10milliondollarwebpage
Jan 07 2017 06:05 UTC
know but I dont gut how I am suppost to do it
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:05 UTC
thats why its challenging
how do you think you would go about it
what do you think the steps would be
Monroe Mann
@monroemann
Jan 07 2017 06:06 UTC
Could someone give me a hand? I don't know why my code isn't working. Perhaps it's completely wrong:

function destroyer(arr) {

    var removeOne = arr.arguments([0][1]);
    var removeTwo = arr.arguments([0][2]);
    arr2 = [];

    for(var i = 1; i < arguments.length; i++) {
      if(arr[i] === removeOne || arr[i] === removeTwo) {
        arr2.push(arr[i]);
      }

    }
  arr = arr2;
  return arr;
}  

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:08 UTC
what you meant to be doing in the challenge? @monroemann
Monroe Mann
@monroemann
Jan 07 2017 06:08 UTC
You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments. @HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:09 UTC
so you should be returning [1, 1] here?
超峰
@fenghuilu
Jan 07 2017 06:09 UTC
so if i use a key which is a string ,i must add another "" with it ? for example ""xxxx""?
Monroe Mann
@monroemann
Jan 07 2017 06:09 UTC
Correct. I just changed the equality to !== but still doesn't work: TypeError: arr.arguments is not a function
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:10 UTC
arguments.length is just gonna be 3
is that what you want?
Monroe Mann
@monroemann
Jan 07 2017 06:10 UTC
@fenghuilu I am not sure
@HeebieGeeBee no, I want arguments[0][0].length correct?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:11 UTC
possibly yeah
and now youve seen that
Ademola Adegbuyi
@ooade
Jan 07 2017 06:11 UTC
@monroemann arr.arguments doesn't exist
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:11 UTC
is that what you want removeone to really equal?
John Gu
@loop1
Jan 07 2017 06:11 UTC
@khaduch why is this sentance "He has to give me a new name", "me" also return true?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:11 UTC
and removetwo
Monroe Mann
@monroemann
Jan 07 2017 06:12 UTC
@ooade But I thought it was a function?
超峰
@fenghuilu
Jan 07 2017 06:12 UTC
@HeebieGeeBee so if i use a key which is a string ,i must add another "" with it ? for example xxx[""xxxx""]?
Ademola Adegbuyi
@ooade
Jan 07 2017 06:12 UTC
@monroemann no, it isn't.
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:12 UTC
@fenghuilu all i saw was that your last if statement was wrong
trupal
@Trupal24
Jan 07 2017 06:12 UTC

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch(val){
case "a":
return "apple";
break;
case "b":
return "bird";
break;
case "c":
return "cat";
break;
default:
default "stuff";

}

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

// Change this value to test
switchOfStuff(1);

Adding a default option in Switch statements. Plz help me to solve this challenge

Monroe Mann
@monroemann
Jan 07 2017 06:12 UTC
@ooade So how then does it know what arguments I want it to refer to?
Ademola Adegbuyi
@ooade
Jan 07 2017 06:13 UTC
@monroemann maybe you wanted arguments object
@monroemann arguments object grabs all arguments in the braces
Monroe Mann
@monroemann
Jan 07 2017 06:13 UTC
@ooade yes, but how to use it? Someone told me it's a function. So confused
超峰
@fenghuilu
Jan 07 2017 06:14 UTC

@HeebieGeeBee no the right function bellow function lookUp(firstName, prop){
// Only change code below this line
for(var i=0;i<contacts.length;i++){

if(contacts[i]["firstName"] == firstName){
if(contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
}else{
return "No such property";
}
}

if(i == contacts.length-1){
return "No such contact";
}

}
// Only change code above this line
}

Monroe Mann
@monroemann
Jan 07 2017 06:14 UTC
Is this better?
function destroyer(arr) {

    var removeOne = arguments[0][1];
    var removeTwo = arguments[0][2];
    arr2 = [];

    for(var i = 1; i < arguments[0][0].length; i++) {
      if(arr[i] !== removeOne || arr[i] !== removeTwo) {
        arr2.push(arr[i]);
      }

    }

  arr = arr2;
  return arr;
}  


destroyer([1, 2, 3, 1, 2, 3], 2, 3);
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:14 UTC
@monroemann console.log(arguments) and see what you get
Monroe Mann
@monroemann
Jan 07 2017 06:14 UTC
@HeebieGeeBee ok
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:15 UTC
arguments[0][1] is gonna be the second element of the array
Monroe Mann
@monroemann
Jan 07 2017 06:15 UTC
@HeebieGeeBee yes, that is what I want
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:15 UTC
why?
Monroe Mann
@monroemann
Jan 07 2017 06:16 UTC
@HeebieGeeBee because I want to remove any numbers that match arguments[0][1] or arguments[0][2]
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:16 UTC
dont you want to be comparing the array objects with arguments[1] and arguments[2]?
Ademola Adegbuyi
@ooade
Jan 07 2017 06:16 UTC
@monroemann what you need is the main arr: [1, 2, 3, 1, 2, 3] and the rest arguments: 2, 3
Monroe Mann
@monroemann
Jan 07 2017 06:17 UTC
but isn't the main arr found via arguments[0][0]?
Ademola Adegbuyi
@ooade
Jan 07 2017 06:17 UTC
@Trupal24
default:
return "stuff";
Monroe Mann
@monroemann
Jan 07 2017 06:17 UTC
@HeebieGeeBee yes, correct
@HeebieGeeBee
But what is arguments[1]?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:17 UTC
also remember there might be more than just 2 numbers to be comparing it with
console.log(arguments[1]) and see
it should be 2
Monroe Mann
@monroemann
Jan 07 2017 06:18 UTC
@HeebieGeeBee I run that command, but don't see anything.
Ademola Adegbuyi
@ooade
Jan 07 2017 06:18 UTC
@Trupal24 You weren't supposed to return em directly tho. You were meant to set "stuff" and d rest of em to answer because you wouldn't be needing a break statement when using return in a switch statement
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:19 UTC
wheres the code? @monroemann
Monroe Mann
@monroemann
Jan 07 2017 06:19 UTC

function destroyer(arr) {
  console.log(arguments);
    var removeOne = arguments[1];
    var removeTwo = arguments[2];
    arr2 = [];

    for(var i = 1; i < arguments[0].length; i++) {
      if(arr[i] !== removeOne || arr[i] !== removeTwo) {
        arr2.push(arr[i]);
      }

    }

  arr = arr2;
  return arr;
}  


destroyer([1, 2, 3, 1, 2, 3], 2, 3);
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:20 UTC
and what does the console give you?
Monroe Mann
@monroemann
Jan 07 2017 06:20 UTC
I don't know how to see the console.
trupal
@Trupal24
Jan 07 2017 06:20 UTC

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case "a":
answer = "apple";
break;
case "b":
answer ="bird";
break;
case "c":
answer = "cat";
break;
default:
default = "stuff";

}

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

// Change this value to test
switchOfStuff(1);

Adding a default option in Switch statements. Plz anyone help me to solve this challenge

HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:20 UTC
f12 if youre using chrome
jainishpanchal
@jainishpanchal
Jan 07 2017 06:20 UTC

@HeebieGeeBee
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));

@HeebieGeeBee nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:21 UTC
you need to push item into the array and then return the number you shift from the array @jainishpanchal
trupal
@Trupal24
Jan 07 2017 06:21 UTC

@ooade
function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case "a":
return"apple";
break;
case "b":
return"bird";
break;
case "c":
return "cat";
break;
default:
return "stuff";

}

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

// Change this value to test
switchOfStuff(1);

Like this?

Ademola Adegbuyi
@ooade
Jan 07 2017 06:21 UTC
@Trupal24 yeah
Monroe Mann
@monroemann
Jan 07 2017 06:22 UTC
@HeebieGeeBee
Arguments[3]
0
:
Array[2]
1
:
"tree"
2
:
53
callee
:
destroyer(arr)
length
:
3
Symbol(Symbol.iterator)
:
values()
__proto__
:
Object
trupal
@Trupal24
Jan 07 2017 06:22 UTC
@ooade ok thanks
CamperBot
@camperbot
Jan 07 2017 06:22 UTC
trupal24 sends brownie points to @ooade :sparkles: :thumbsup: :sparkles:
:cookie: 800 | @ooade |http://www.freecodecamp.com/ooade
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:23 UTC
right yeah forgot it was gonna show you all the test arguments too
Monroe Mann
@monroemann
Jan 07 2017 06:24 UTC
@HeebieGeeBee I am getting there. This just got me 4 checks. I have just one X:
function destroyer(arr) {

    var removeOne = arguments[1];
    var removeTwo = arguments[2];
    arr2 = [];

    for(var i = 0; i < arr.length; i++) {
      if(arr[i] !== removeOne && arr[i] !== removeTwo) {
        arr2.push(arr[i]);
      }

    }

  arr = arr2;
  return arr;
}  


destroyer([1, 2, 3, 1, 2, 3], 2, 3);
I changed the || to &&
hariharanguru83
@hariharanguru83
Jan 07 2017 06:24 UTC
var singleVal = array.reduce(function(previousVal, currentVal){

  return previousVal+currentVal;

});
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:24 UTC
why arr.length?
hariharanguru83
@hariharanguru83
Jan 07 2017 06:24 UTC
singleVal should be equal to the sum of all items in the array variable.
Ademola Adegbuyi
@ooade
Jan 07 2017 06:24 UTC
@monroemann the result of calling arguments shows it's an object. it has keys(0, 1, callee, length, Symbol.iterator and prototype)
Monroe Mann
@monroemann
Jan 07 2017 06:25 UTC
@ooade @HeebieGeeBee This is the only one not working: destroyer([3, 5, 1, 2, 2], 2, 3, 5) should return [1].
Ademola Adegbuyi
@ooade
Jan 07 2017 06:25 UTC
@monroemann cos you're doing em wrong
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:25 UTC
cus you have more than two things to sort through
jainishpanchal
@jainishpanchal
Jan 07 2017 06:25 UTC
@HeebieGeeBee not still working
Monroe Mann
@monroemann
Jan 07 2017 06:26 UTC
@HeebieGeeBee Yeah, just realized that.
@HeebieGeeBee Hmmm, now how to fix that...
I have already create removeOne, and removeTwo, but if there are more than two arguments, it won't work
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:26 UTC
arr.push(item);
return arr.shift();
@jainishpanchal but think why this is the solution
jainishpanchal
@jainishpanchal
Jan 07 2017 06:27 UTC
ok
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:27 UTC
yeah maybe you should do it in a different way @monroemann what if the array was 50 numbers long and there was 30 numbers to sort through
Ademola Adegbuyi
@ooade
Jan 07 2017 06:27 UTC
@monroemann normally, you don't have to list out arguments yourself cos they can add up to 100 arguments, you might wanna loop through arguments; arguments.length to grab the first n values
Sparkin
@seanparkin
Jan 07 2017 06:28 UTC
I need some help with "Return Largest Numers in Arrays" I get a null on one of the "requirements".......
function largestOfFour(arr) {
  // You can do this!

  var largest = [];
  var larger = 0;
  for (i=0; i < arr.length; i++){
    for (j=0; j < arr[i].length; j++) {
      if (arr[i][j] > larger) {        
        larger = arr[i][j];
        largest[i] = arr[i][j];           
        }

    }

  }

  return largest;
}
Monroe Mann
@monroemann
Jan 07 2017 06:28 UTC
@HeebieGeeBee @ooade Yeah, I know. I guess I will work on this tomorrow. I'm very tired now, and hard to concentrate. Thank you for your help. I have copied your last two bits of advice and will try to figure them out tomorrow
CamperBot
@camperbot
Jan 07 2017 06:28 UTC
monroemann sends brownie points to @heebiegeebee and @ooade :sparkles: :thumbsup: :sparkles:
:cookie: 466 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:cookie: 801 | @ooade |http://www.freecodecamp.com/ooade
Ademola Adegbuyi
@ooade
Jan 07 2017 06:29 UTC
@monroemann :+1:
hariharanguru83
@hariharanguru83
Jan 07 2017 06:30 UTC
var singleVal = array.reduce(function(previousVal , currentVal){

  return previousVal + currentVal;

});
need help
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:31 UTC
@seanparkin maybe think about doing itn a different way
Ademola Adegbuyi
@ooade
Jan 07 2017 06:31 UTC
@hariharanguru83 what values do array contain?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:31 UTC
@seanparkin look into the sort() method
Sparkin
@seanparkin
Jan 07 2017 06:32 UTC
@HeebieGeeBee yeah that would make it easier to code. Thank you. I will try that
CamperBot
@camperbot
Jan 07 2017 06:32 UTC
seanparkin sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 467 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
hariharanguru83
@hariharanguru83
Jan 07 2017 06:36 UTC
@ooade var array = [4,5,6,7,8];
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:37 UTC
whats the problem with it?
Ademola Adegbuyi
@ooade
Jan 07 2017 06:37 UTC
@hariharanguru83 it should work fine
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:38 UTC
is that all your code?
hariharanguru83
@hariharanguru83
Jan 07 2017 06:38 UTC
Error:- singleVal should be equal to the sum of all items in the array variable.
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:38 UTC
do you want to return singleVal?
hariharanguru83
@hariharanguru83
Jan 07 2017 06:38 UTC
yes
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:38 UTC
well make sure you do then
Ademola Adegbuyi
@ooade
Jan 07 2017 06:38 UTC
@hariharanguru83 hope you didnt delete the initialized singleVal value: 0?
hariharanguru83
@hariharanguru83
Jan 07 2017 06:39 UTC
Here is the full code
var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.
var singleVal = array.reduce(function(previousVal , currentVal){

  return previousVal + currentVal;

});

singleVal = array;
Ademola Adegbuyi
@ooade
Jan 07 2017 06:39 UTC
@hariharanguru83 Haa!!
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:39 UTC
oh
youve just turned singleVal into array
at the end
Ademola Adegbuyi
@ooade
Jan 07 2017 06:40 UTC
@hariharanguru83 remove singleVal = array; and undeclare singleVal by removing the var keyword
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:40 UTC
yeah
and return singleVal
hariharanguru83
@hariharanguru83
Jan 07 2017 06:41 UTC
@ooade & @HeebieGeeBee thanks
CamperBot
@camperbot
Jan 07 2017 06:41 UTC
hariharanguru83 sends brownie points to @ooade and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 468 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:cookie: 802 | @ooade |http://www.freecodecamp.com/ooade
Brandon Vi
@bvi1994
Jan 07 2017 06:41 UTC
Hi everyone. I'm trying to figure out how to do:
<div class='class1 class2' id='id1'>Content here</div>
to add on jquery
I think it's something like
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:42 UTC
add what?
Brandon Vi
@bvi1994
Jan 07 2017 06:43 UTC
$('.class1 class2' '#id1').append('Content here')
Appending HTML code with a class and id using jquery
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:43 UTC
just $('#id1').append('content here') will be enough
Brandon Vi
@bvi1994
Jan 07 2017 06:44 UTC
Would I need another line to add my div classes?
Ademola Adegbuyi
@ooade
Jan 07 2017 06:44 UTC
@bvi1994 no
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:44 UTC
why do you need to?
you only want it to go into id1 right?
Brandon Vi
@bvi1994
Jan 07 2017 06:45 UTC
So I have a for loop that runs to add div and classes
that I would like to append to my HTML code
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:45 UTC
sorry dont know what you mean
Corey
@kuehlc
Jan 07 2017 06:45 UTC
Does anyone understand what you're supposed to do for 197 in javascript? I don't get what they want the function to do
Brandon Vi
@bvi1994
Jan 07 2017 06:46 UTC
Basically I want to create a number of objects with all the same divs but unique IDs
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:46 UTC
you need to give the name not the number of the challenge @kuehlc
Brandon Vi
@bvi1994
Jan 07 2017 06:46 UTC
I know how to create unique IDs for each of the boxes
Corey
@kuehlc
Jan 07 2017 06:46 UTC
Card sequence?
babajide odusola
@cesarecaravaggio
Jan 07 2017 06:46 UTC
function nextInLine(arr, item) {
  // Your code here
  nextInline.shift();
  nextInLine.unshift(item);
guys i'm stuck
Brandon Vi
@bvi1994
Jan 07 2017 06:46 UTC
but I need to figure out how to apply the divs to each of the boxes
babajide odusola
@cesarecaravaggio
Jan 07 2017 06:47 UTC
someone help me with this pls
function nextInLine(arr, item) {
  // Your code here
  nextInline.shift();
  nextInLine.unshift(item);
Corey
@kuehlc
Jan 07 2017 06:47 UTC
build a function that takes in a card and then returns whether you bet or hold
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:47 UTC
push item and return the shift @cesarecaravaggio
Brandon Vi
@bvi1994
Jan 07 2017 06:47 UTC
@cesarecaravaggio One of variables also has a cap and lower case
Corey
@kuehlc
Jan 07 2017 06:47 UTC
I feel like my code should handle that but i keep failing everything
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:47 UTC
need to show the code @kuehlc
babajide odusola
@cesarecaravaggio
Jan 07 2017 06:48 UTC
@HeebieGeeBee llike this?
function nextInLine(arr, item) {
  // Your code here
  item.push();


  return shift;  // Change
Corey
@kuehlc
Jan 07 2017 06:48 UTC
How do I post my code in here?
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:48 UTC
no arr.push()
Brandon Vi
@bvi1994
Jan 07 2017 06:48 UTC
@kuehlc Do <Your code here>
hm
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:48 UTC
and return arr.shift();
but think about why thats the answer before you move on
Brandon Vi
@bvi1994
Jan 07 2017 06:49 UTC
sa<your code here>sa without the "s" and "a" @kuehlc
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:49 UTC
sorry
arr.push(item) @cesarecaravaggio
Corey
@kuehlc
Jan 07 2017 06:49 UTC

<function cc(card) { // Only change code below this line if (++hand < 5) { if (card > 1 || card < 7) {
count++;
} else if (card == 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A') {
count--;
}
} else {
count = 0;
hand = 1;
if (card > 1 || card < 7) {
count++;
} else if (card == 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A') {
count--;
}
}

if (count > 0) {
return count + " Bet";
} else {
return count + " Hold";
}
// Only change code above this line
}>

Brandon Vi
@bvi1994
Jan 07 2017 06:49 UTC
...
I suck
Corey
@kuehlc
Jan 07 2017 06:49 UTC
well i did it wrong

'<function cc(card) { // Only change code below this line if (++hand < 5) { if (card > 1 || card < 7) {
count++;
} else if (card == 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A') {
count--;
}
} else {
count = 0;
hand = 1;
if (card > 1 || card < 7) {
count++;
} else if (card == 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A') {
count--;
}
}

if (count > 0) {
return count + " Bet";
} else {
return count + " Hold";
}
// Only change code above this line
}>'

Nope, that didn't work either
sorry for the accidental spam
babajide odusola
@cesarecaravaggio
Jan 07 2017 06:50 UTC
yeah that's my main problem. I dont get the wordings that well yet and I know that comes with time and practice but still.
HeebieGeeBee
@HeebieGeeBee
Jan 07 2017 06:50 UTC
why have you done it twice @kuehlc
babajide odusola
@cesarecaravaggio
Jan 07 2017 06:52 UTC
what does the .push object do exactly ?
Corey
@kuehlc
Jan 07 2017 06:52 UTC
i tried it two different ways
babajide odusola
@cesarecaravaggio
Jan 07 2017 06:52 UTC
@bvi1994 same here haha keep on practicing though :)
Brandon Vi
@bvi1994
Jan 07 2017 06:53 UTC
@cesarecaravaggio Well, I mean how to show the code using the 3 `s thing
except it would format automatically even if I try to trick it