These are chat archives for FreeCodeCamp/HelpJavaScript

16th
Mar 2016
yelsneH
@yelsneh
Mar 16 2016 00:01
Does anyone want to compare solutions for "Title Case a Sentence" I'm interested in seeing how others did it vs myself
LuciusR11
@LuciusR11
Mar 16 2016 00:09
@yelsneh Sorry, I had to go for awhile, did you figure anything out?
yelsneH
@yelsneh
Mar 16 2016 00:10
oh yeah I figured it out :)
do you want to see my solution?
LuciusR11
@LuciusR11
Mar 16 2016 00:11
Sure, I feel like mine should work, its just that one "me" test.
yelsneH
@yelsneh
Mar 16 2016 00:11
ok take a look at mine and we'll figure out why yours doesn't work
LuciusR11
@LuciusR11
Mar 16 2016 00:13
function end(str, target) {
  var answer;
  var myArray = str.split(" ");
  if (target == str[str.length - 1] || target == myArray[myArray.length - 1]){
    answer = true;
  }else{
    answer = false;
  }
  return answer;
}

end("Bastian", "n");
That's mine.
yelsneH
@yelsneh
Mar 16 2016 00:14
You see my PM?
LuciusR11
@LuciusR11
Mar 16 2016 00:14
yeah I got it.
hnry
@hnry
Mar 16 2016 00:18
@MisterMan123 you can check out https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every to see if you like to use that instead
Henry Quinn
@Quinncuatro
Mar 16 2016 00:20
help show
CamperBot
@camperbot
Mar 16 2016 00:20
no wiki entry for: show
Yosafat Ariel
@yoskakomba
Mar 16 2016 00:24
smallest common multiple
Matthew
@aspiringguru
Mar 16 2016 00:25
just started 'Caesars Cipher'. tips?
Dustin
@Key-Banger
Mar 16 2016 00:30
someone mind helping me out. I've tried this every way but the right one.
function diff(arr1, arr2) {
  var newArr = [];
  for (i=0; i<arr1.length; i++)
    for (j=0; j<arr2.length; j++)
      if (arr1[i].indexOf(i) !== arr2[j].indexOf(j) {
        newArr.push(arr1[i]);
        newArr.push(arr2[j]);
        return newArr;
}
}
It's Diff two arrays
Trevor Baker
@noizehack
Mar 16 2016 00:31
@Key-Banger I think you are missing some {}
the for loops should be like for( ) { }
Collin
@collinferry
Mar 16 2016 00:32
@Key-Banger Yep, check out the examples on the for loop page: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for
Dustin
@Key-Banger
Mar 16 2016 00:34
No change. I'm here.
function diff(arr1, arr2) {
  var newArr = [];
  for (i=0; i<arr1.length; i++) {
    for (j=0; j<arr2.length; j++) {
      if (arr1[i].indexOf(i) !== arr2[j].indexOf(j)) {
        newArr.push(arr1[i]);
        newArr.push(arr2[j]);
        return newArr;
      }
    }
}
}

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Trevor Baker
@noizehack
Mar 16 2016 00:36
@Key-Banger what exactly are you trying to find about the arrays? numbers that are in one but no the other?
Dustin
@Key-Banger
Mar 16 2016 00:37
@noizehack from the challenge
"Compare two arrays and return a new array with any items only found in one of the two given arrays, but not both. In other words, return the symmetric difference of the two arrays."
Daniel Adams
@MisterMan123
Mar 16 2016 00:38
@hnry I've done a bit more work on it but I'm having a hard time picking out exactly where my logic errors are, if you wouldn't mind taking a look.
function smallestCommons(arr) {
  var min = Math.min(...arr);
  var max = Math.max(...arr);
  var divisors = [];
  var check = 1;
  var checkArr = [];
  var scm = 0;

  function dividable(num) {
    return num === true;
  }

  for (i = min; i <= max; i++) {
    divisors.push(i);
  }

  while (checkArr.every(dividable) !== true) {
    for (i = 0; i < divisors.length; i++) {
      if (check % divisors[i] === 0) {
        checkArr.push(true);
      } else {
        checkArr.push(false);
      }
    }
    check++;
  }
  return checkArr;
}


smallestCommons([5,1]);
Trevor Baker
@noizehack
Mar 16 2016 00:40
@Key-Banger maybe you are trying to find the index of the wrong thing? it looks like you are looking for the index of i and j with your if statement
Collin
@collinferry
Mar 16 2016 00:42
@MisterMan123 Think about the order these functions and loops will run in
hnry
@hnry
Mar 16 2016 00:43
@MisterMan123 dividable doesn't work right
Collin
@collinferry
Mar 16 2016 00:44
@MisterMan123 Actually scratch that. In your "if" statement, do you need the word "check" - I've not seen that before
hnry
@hnry
Mar 16 2016 00:44
@MisterMan123 also you don't need checkArr
Daniel Adams
@MisterMan123
Mar 16 2016 00:45
@collinferry I was using it as the number that's being iterated and having all the modding done to it
hnry
@hnry
Mar 16 2016 00:45
@MisterMan123 it's nice that you are evualuating the result of every for the while loop :+1:
Daniel Adams
@MisterMan123
Mar 16 2016 00:45
@hnry Could you elaborate on dividable not working right?
Collin
@collinferry
Mar 16 2016 00:46
@MisterMan123 ah, right, sorry. I've been out in the cold all day and my brain is obviously not running at full power yet :/
hnry
@hnry
Mar 16 2016 00:46
@MisterMan123 you want dividable to test whether or not the current number is divisible so the return should be return current_number % num === 0
@MisterMan123 really the while loops job is to just increase the current number (check) you don't need anything else in there
Dustin
@Key-Banger
Mar 16 2016 00:48
a different direction I was headed if anyone has help.
function diff(arr1, arr2) {
  var newArr = [];
  function array(val) {
  for (i=0; i<arr1.length; i++) {
    return  val = arr1[i];
    }
    newArr = arr2.filter(array);
    return newArr;
    }
}

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
hnry
@hnry
Mar 16 2016 00:49
@MisterMan123 oh also you're calling array on the wrong array
Daniel Adams
@MisterMan123
Mar 16 2016 00:52
the wrong array?
hnry
@hnry
Mar 16 2016 00:54
@MisterMan123 you want it to be for divisors not checkArr (you can remove checkArr) entirely even
Daniel Adams
@MisterMan123
Mar 16 2016 00:57
@hnry so is this a bit closer in line
function smallestCommons(arr) {
  var min = Math.min(...arr);
  var max = Math.max(...arr);
  var divisors = [];
  var check = 1;
  var scm = 0;

  function dividable(num) {
    return check % num === 0;
  }

  for (i = min; i <= max; i++) {
    divisors.push(i);
  }

  while (divisors.every(dividable) !== true) {
    check++;
  }
  return scm;
}


smallestCommons([5,1]);
I'm a little stuck on how to assign scm the value that will return true for the every though
hnry
@hnry
Mar 16 2016 00:58
@MisterMan123 you don't need the scm, you have the number in check
Daniel Adams
@MisterMan123
Mar 16 2016 00:58
ohhhh
hnry
@hnry
Mar 16 2016 00:59
the loop will break once every returns true for every numbers in divisors
Daniel Adams
@MisterMan123
Mar 16 2016 00:59
OH
hnry
@hnry
Mar 16 2016 00:59
@MisterMan123 :D much smaller than what you started out with too :+1:
Daniel Adams
@MisterMan123
Mar 16 2016 01:00
alright, so it's worked for 1 to 5 but is still failing on 1 to 13
Apparently there's some sort of infinite loop issue
Dustin
@Key-Banger
Mar 16 2016 01:00
Giving up. Goodnight y'all.
Daniel Adams
@MisterMan123
Mar 16 2016 01:00
ohh I know what the issue is
Since the correct value is 360360 I think it's warning me lol
Yep, it worked. Thank you @hnry !
CamperBot
@camperbot
Mar 16 2016 01:01
misterman123 sends brownie points to @hnry :sparkles: :thumbsup: :sparkles:
:star: 151 | @hnry | http://www.freecodecamp.com/hnry
yelsneH
@yelsneh
Mar 16 2016 01:02
@LuciusR11 if you're here I PMed you
Luke Pasquill
@LeoRussus
Mar 16 2016 01:08
Has anybody here passed Caesers Cipher?
pgjones72
@pgjones72
Mar 16 2016 01:13
function lookUp(firstName, prop){
// Only change code below this line

  if(firstName in contacts === true && prop in contacts.firstName === true){
    return prop(value);
  }
  else{
    return "No such contact";
  }
hey guys. should this function work?
i didn't know we could use 'in' in JS :)
@LeoRussus i did, but not in this course :)
Chris
@MrChristofferson
Mar 16 2016 01:14
@pgjones72, did you try it? ;)
pgjones72
@pgjones72
Mar 16 2016 01:15
@MrChristofferson one green check-
Luke Pasquill
@LeoRussus
Mar 16 2016 01:15
@pgjones72 Then maybe you could tell me why my code returned all the decodings right but wouldn't let me pass

``function rot13(str) { // LBH QVQ VG!
var result = " ";
for (i = 0; i <str.length; i++) {
if(str.charCodeAt(i) == 32){result += ' ';}

else if(str.charCodeAt(i) < 65 || str.charCodeAt(i) > 91){
result += str[i];
}
else if(str.charCodeAt(i)<78){
result += String.fromCharCode(str.charCodeAt(i) + 13);
}
else{
result += String.fromCharCode(str.charCodeAt(i) - 13);
}
}
return result;
}

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

yelsneH
@yelsneh
Mar 16 2016 01:16
I challenge anyone to do Confirm the Ending more efficiently than I did it :D
pgjones72
@pgjones72
Mar 16 2016 01:17
@LeoRussus i did it in C
Luke Pasquill
@LeoRussus
Mar 16 2016 01:17
balls, alright thanks @pgjones72
CamperBot
@camperbot
Mar 16 2016 01:17
leorussus sends brownie points to @pgjones72 :sparkles: :thumbsup: :sparkles:
:star: 231 | @pgjones72 | http://www.freecodecamp.com/pgjones72
pgjones72
@pgjones72
Mar 16 2016 01:18
@LeoRussus read over the instructions carefully step by step. You might have missed a tiny detail in the instructions somewhere. That happens to me all the time
yoni chanowitz
@yonichanowitz
Mar 16 2016 01:20
random question,
i was messing with the Jquery Api geolocator lesson.
i put in this code trying to get it to give input if i'm in brooklyn. but id DOESN"T WORK!!!
anybody know what i did wrong?????
<script>
  // Only change code below this line.

  if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
    $("#data").html("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);


     if(position.coords.latitude > 40.65 && position.coords.latitude < 40.7){
      if(position.coords.longitude > 73.93 && position.coords.longitude < 74){
         $("#brooklyn").html("you are in brooklyn");

      }
    }
  });

}

  // Only change code above this line.
</script>
<div id = "data">
  <h4>You are here:</h4>

</div>
<div id = "brooklyn">
  <h3>dude</h3>
</div>
Chris
@MrChristofferson
Mar 16 2016 01:21
@yonichanowitz Delete the white space between id = "brooklyn"
@yonichanowitz So it's: id="brooklyn"
pgjones72
@pgjones72
Mar 16 2016 01:21
@yonichanowitz is your first if actually a condition?
Chris
@MrChristofferson
Mar 16 2016 01:22
Same with data :)
yoni chanowitz
@yonichanowitz
Mar 16 2016 01:22
@MrChristofferson , didnt work,
@MrChristofferson thanks
CamperBot
@camperbot
Mar 16 2016 01:22
yonichanowitz sends brownie points to @mrchristofferson :sparkles: :thumbsup: :sparkles:
:star: 47 | @mrchristofferson | http://www.freecodecamp.com/mrchristofferson
Chris
@MrChristofferson
Mar 16 2016 01:23
@pgjones72 Passing one parameter to an if statement will run the code if it's not undefined :)
If(navigator.geoposition exists) {etc.}
pgjones72
@pgjones72
Mar 16 2016 01:23
@MrChristofferson ahh ok.
yoni chanowitz
@yonichanowitz
Mar 16 2016 01:23
@pgjones72 yes it is, i added stuff the lesson didnt ask for, i wanted to play around with geolocation
thanks @pgjones72
CamperBot
@camperbot
Mar 16 2016 01:23
yonichanowitz sends brownie points to @pgjones72 :sparkles: :thumbsup: :sparkles:
pgjones72
@pgjones72
Mar 16 2016 01:23
cool
CamperBot
@camperbot
Mar 16 2016 01:23
:star: 232 | @pgjones72 | http://www.freecodecamp.com/pgjones72
pgjones72
@pgjones72
Mar 16 2016 01:24
@yonichanowitz could I use the same thing in the code I just posted?
yoni chanowitz
@yonichanowitz
Mar 16 2016 01:24
@pgjones72 , where?
pgjones72
@pgjones72
Mar 16 2016 01:25
function lookUp(firstName, prop){
// Only change code below this line

  if(firstName in contacts === true && prop in contacts.firstName === true){
    return prop(value);
  }
  else{
    return "No such contact";
  }
i guess not. it wouldn't be defined
just a horribly hopeful thought. I should have known better :(
yoni chanowitz
@yonichanowitz
Mar 16 2016 01:27
@pgjones72 , yeah, it is dependant on the value defined bythe callback function of the geolocation thing
pgjones72
@pgjones72
Mar 16 2016 01:27
ahhh
lol how do I send you brownie points?
yoni chanowitz
@yonichanowitz
Mar 16 2016 01:28
the code passes requirements, but spits out no "you are in brooklyn" staement
type thanks and my name !
like this
pgjones72
@pgjones72
Mar 16 2016 01:29
@yonichanowitz thanks!
CamperBot
@camperbot
Mar 16 2016 01:29
pgjones72 sends brownie points to @yonichanowitz :sparkles: :thumbsup: :sparkles:
:star: 283 | @yonichanowitz | http://www.freecodecamp.com/yonichanowitz
yoni chanowitz
@yonichanowitz
Mar 16 2016 01:29
nice!, your welcome @pgjones72
Jas
@JB2016
Mar 16 2016 01:51
Anyone know why this returns Frank and not Adams?
This message was deleted
Jas
@JB2016
Mar 16 2016 01:56

Anyone know why this isn't returning Adams?

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

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

return result;
}
phoneticLookup(["alpha"]);

prestonk25
@prestonk25
Mar 16 2016 01:59
// Setup
function abTest(a, b) {
  // Only change code below this line
  if(a && b < 0) {
    return;
  } 

  // Only change code above this line

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

// Change values below to test your code
abTest(-2,2);

I can't get all the conditions to work. The only one I can't is abTest(-2,2) should return undefined

The instructions are:
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.

cannelflow
@cannelflow
Mar 16 2016 02:00
@JB2016 i think you need to assign value to result first which exercise?
@prestonk25 condition is (a less then zero or b less then zero)
@JB2016 @prestonk25 ?
prestonk25
@prestonk25
Mar 16 2016 02:03
// Setup
function abTest(a, b) {
  // Only change code below this line
  if(a || b < 0) {
    return;
  } 

  // Only change code above this line

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

// Change values below to test your code
abTest(-2,2);

When i try this the ones that need to be undefined work but none that should return a number.

For example:
abTest(2,2) should return 8
Is not satisfied.

cannelflow
@cannelflow
Mar 16 2016 02:07
@prestonk25 hey pls do tag user who are following your question
you need to check a less then 0 also @prestonk25 and after that return undefined
@JB2016 ?
Josh Bivens
@joshbivens
Mar 16 2016 02:10
Need a little help on the card counting question.
cannelflow
@cannelflow
Mar 16 2016 02:10
@joshbivens TRIED SOMETHING ?
Gwendolyn Faraday
@gwenf
Mar 16 2016 02:11
@JB2016 did you figure out the answer, I can help you with it if you want
Josh Bivens
@joshbivens
Mar 16 2016 02:11
@cannelflow Yeah, a bunch of if statements.
prestonk25
@prestonk25
Mar 16 2016 02:11
// Setup
function abTest(a, b) {
  // Only change code below this line
  if(a || b < 0) {
    return;
  } 

  if(a && b < 0) {
    return "test";
  }

  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
@cannelflow Is this what you mean? If so only the undefined ones are still satisfied
cannelflow
@cannelflow
Mar 16 2016 02:11
if is good but switch is cleaner @joshbivens
Josh Bivens
@joshbivens
Mar 16 2016 02:11
Ah cool! Thank you @cannelflow
CamperBot
@camperbot
Mar 16 2016 02:11
joshbivens sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
:star: 927 | @cannelflow | http://www.freecodecamp.com/cannelflow
cannelflow
@cannelflow
Mar 16 2016 02:13
you don't need if(a && b < 0) {
return "test";
} condition is if (a is less then 0 or b is less then 0)then return undefined so it is like if(a<0||b<0) return undefined @prestonk25
prestonk25
@prestonk25
Mar 16 2016 02:16
@cannelflow It worked! thanks so much!
CamperBot
@camperbot
Mar 16 2016 02:16
prestonk25 sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
:star: 928 | @cannelflow | http://www.freecodecamp.com/cannelflow
Leslie Covington
@LesCov610
Mar 16 2016 02:16
Why will this not work in the "Check For Palindrome" challenge?
   newStr = str.replace(/W_\s/g);
   newStr.toLowerCase();
   twoStr = newStr.split('').reverse().join('');

   if (twoStr === newStr) {
    return true;

   } else  {
   return false;
   }
cannelflow
@cannelflow
Mar 16 2016 02:16
@LesCov610 which condition is not passing?
Leslie Covington
@LesCov610
Mar 16 2016 02:20
@cannelflow
Correct -- palindrome("eye") should return a boolean.
Correct -- palindrome("eye") should return true.
Incorrect -- palindrome("race car") should return true.
Correct -- palindrome("not a palindrome") should return false.
Incorrect -- palindrome("A man, a plan, a canal. Panama") should return true.
Incorrect -- palindrome("never odd or even") should return true.
Correct -- palindrome("nope") should return false.
Correct -- palindrome("almostomla") should return false.
Incorrect -- palindrome("My age is 0, 0 si ega ym.") should return true.
Correct -- palindrome("1 eye for of 1 eye.") should return false.
Incorrect -- palindrome("0_0 (: /-\ :) 0-0") should return true.
cannelflow
@cannelflow
Mar 16 2016 02:21
use this regex replace(/[^A-Z^a-z^0-9]/g, '') should remove everything except number and word
@LesCov610
oh you have others incorrect also let me check
yelsneH
@yelsneh
Mar 16 2016 02:23
I used replace(/[^a-z0-9]/gi,"")
var remPunc = str.replace(/[^a-z0-9]/gi,"").toLowerCase();
  var revStr = remPunc.split("").reverse().join("");
Leslie Covington
@LesCov610
Mar 16 2016 02:26
@cannelflow @yelsneh Your suggestions both made it better. Still not totally correct. I have been fussing with this for about a week! I don't want to just copy one of the solutions. That's no help. But I cannot figure out what the problem is.
cannelflow
@cannelflow
Mar 16 2016 02:27
@LesCov610 basically your line newStr.toLowerCase(); is doing nothing do like newStr = str.replace(/[^A-Z^a-z^0-9]/g, '').toLowerCase();
yelsneH
@yelsneh
Mar 16 2016 02:27
yeah append toLowerCase();
cannelflow
@cannelflow
Mar 16 2016 02:28
@LesCov610 https://repl.it/Bwjx you can see newStr.toLowerCase(); is doing nothing here
so do like newStr = str.replace(/[^A-Z^a-z^0-9]/g, '').toLowerCase();
yelsneH
@yelsneh
Mar 16 2016 02:29
remPunc = str.replace(/[^a-z0-9]/gi,"").toLowerCase();
/gi ignores case
well the i does
so you can shorten than regex
Leslie Covington
@LesCov610
Mar 16 2016 02:31
@cannelflow @yelsneh YES!!! Thank you SO MUCH!! It finally works!!! I should have asked you way before this. I really appreciate your help. Thank you @cannelflow & @yelsneh!!!
CamperBot
@camperbot
Mar 16 2016 02:31
lescov610 sends brownie points to @cannelflow and @yelsneh :sparkles: :thumbsup: :sparkles:
:star: 929 | @cannelflow | http://www.freecodecamp.com/cannelflow
:star: 260 | @yelsneh | http://www.freecodecamp.com/yelsneh
yelsneH
@yelsneh
Mar 16 2016 02:31
np
cannelflow
@cannelflow
Mar 16 2016 02:31
@LesCov610 :+1:
Leslie Covington
@LesCov610
Mar 16 2016 02:32
@yelsneh @cannelflow This is such a relief to FINALLY be able to move on. Maybe I can learn to do this after all.
yelsneH
@yelsneh
Mar 16 2016 02:32
You can definitely learn, trust me. remember the difference between you and people that already can "code" is they know how to google things better
:)
@cannelflow let's compare Title Case a Sentence challenges :D
cannelflow
@cannelflow
Mar 16 2016 02:33
@LesCov610 just keep trying and trying
yelsneH
@yelsneh
Mar 16 2016 02:33
I'm going to have to go ahead and say I have the shortest solution possible
cannelflow
@cannelflow
Mar 16 2016 02:33
@yelsneh perhaps you can tech me
yelsneH
@yelsneh
Mar 16 2016 02:34
no lol I just learned the way I did this today
cannelflow
@cannelflow
Mar 16 2016 02:34
@yelsneh let me see what i did
Leslie Covington
@LesCov610
Mar 16 2016 02:35
@yelsneh :smile: @cannelflow :clap:
yelsneH
@yelsneh
Mar 16 2016 02:35
wait I meant "Confirm the ending"
but my title case isn't bad
yelsneH
@yelsneh
Mar 16 2016 02:42
http://regexr.com/ is so awesome
if like me you are a little lost on regex
Daniel Adams
@MisterMan123
Mar 16 2016 02:46

So I'm currently doing the drop it bonfire and I could use some help understanding my logic errors.

function drop(arr, func) {
  // Drop them elements.
  for (i = 0; i < arr.length; i++) {
    if (arr.indexOf(arr[i]) !== arr.lastIndexOf(arr[i])) {
      arr.slice(arr[i]);
      arr = arr.filter(func);
    } else {
      arr = arr.filter(func);
    }
  }
  return arr;
}

drop([0, 1, 0, 1], function(n) {return n === 1;});

Right now this outputs [1,1], and I believe that's because it's taking zero out instead of one. How would I go about solving this?

Sidharth Kriplani
@sidkrip
Mar 16 2016 02:52
@MisterMan123 I had the same problem as well. You can try using shift instead of filter if you dont understand it well enough and then work it out again using filter when you will get it
your output should be [1, 0, 1] not [1, 1] and your code is filtering out all the values which do not agree with the provided function func. That is not how the output should be. Your code has to shift all the elements from the beginning until a value agrees with the provided func and then stop at that.
Sidharth Kriplani
@sidkrip
Mar 16 2016 02:57
wiki Arguments Optional
CamperBot
@camperbot
Mar 16 2016 02:57

:point_right: algorithm arguments optional [wiki]

Explanation:

It can be quite complicated to understand what needs to be done. There are always many ways to do something when coding but regardless of the algorithm used, we have to create a program that does the following:

  • It has to add two numbers passed as parameters and return the sum.
  • It has to check if any of the numbers are actual numbers, otherwise return undefined and stop the program right there.
  • It has to check if it has one or two arguments passed. More are ignored.
  • If it has only one argument then it has to return a function that uses that number and expects another one, to then add it.

:pencil: read more about algorithm arguments optional on the FCC Wiki

Alex N.
@N0bl3
Mar 16 2016 03:05
@sidkrip can i help u?
Devlin
@devlindigital
Mar 16 2016 03:07
Would anyone be willing to help me with the the destroyer problem in the algorithms section?
my function isn't producing the filter results I'm expecting.
function destroyer(arr) {

  function argumentsFilter(argumentVariable) {
    for (i=1; i < arguments.length; i++) { // Loop through second through nth arguments
      if (argumentVariable == i) { //Check argument value against current array value
        return true; // Return true if argument value matches current array value
      } else return false; // Return false if the argument value does not match current array value
    }
  }

arr = arr.filter(argumentsFilter); 

return arr;  
}

destroyer(["tree", "hamburger", 53], "tree", 53); // Passes an array and 2 numbers as arguments
oops, sorry. meant to embed that code.
Andrew Charlebois
@andrewchar
Mar 16 2016 03:09
@devlindigital you can edit your posts
Daniel Adams
@MisterMan123
Mar 16 2016 03:09
@sidkrip I've nearly gotten it, but drop([1, 2, 3, 4], function(n) {return n > 5;}); returns [3,4] instead of []. Why is this? Code below:
function drop(arr, func) {
  // Drop them elements.
  for (i = 0; i < arr.length; i++) {
    if (func(arr[0])) {
      break;
    } else {
      arr.shift();
    }
  }
  return arr;
}

drop([1, 2, 3, 4], function(n) {return n > 5;});
Sidharth Kriplani
@sidkrip
Mar 16 2016 03:11
@MisterMan123 try out your code on http://www.pythontutor.com/visualize.html#mode=edit
it will help you understand how your code is working for a certain input
Devlin
@devlindigital
Mar 16 2016 03:13
@andrewchar is there some inline markup I should use? This is my first attempt at seeking help though chat.
Andrew Charlebois
@andrewchar
Mar 16 2016 03:13
help format
CamperBot
@camperbot
Mar 16 2016 03:13

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Sidharth Kriplani
@sidkrip
Mar 16 2016 03:13
I think you dont need a for loop here to traverse the whole array. A "while(arr.length!=0" will do just fine
@MisterMan123
hnry
@hnry
Mar 16 2016 03:13
@MisterMan123 i think i normally see that you might overthink the problem in the details
try to think about what the challenge is really asking you to do, like the simplest way to implement it
Daniel Adams
@MisterMan123
Mar 16 2016 03:15
@sidkrip yep, a while loop did the trick for it. Thanks for the help on it. And @hnry yeah heh, that does seem to be a recurring theme for me
CamperBot
@camperbot
Mar 16 2016 03:15
misterman123 sends brownie points to @sidkrip and @hnry :sparkles: :thumbsup: :sparkles:
:star: 152 | @hnry | http://www.freecodecamp.com/hnry
:star: 359 | @sidkrip | http://www.freecodecamp.com/sidkrip
Devlin
@devlindigital
Mar 16 2016 03:16
thank you @andrewchar
CamperBot
@camperbot
Mar 16 2016 03:16
devlindigital sends brownie points to @andrewchar :sparkles: :thumbsup: :sparkles:
:star: 354 | @andrewchar | http://www.freecodecamp.com/andrewchar
hnry
@hnry
Mar 16 2016 03:17
@MisterMan123 like for the drop example, it's basically telling you whatever func returns as true, from that point return the rest of the array, so you just have to find the index of the first element that returns true, and once you have that you return what comes after
so the key is really finding the index of the first element that returns true for func
joyam09
@joyam09
Mar 16 2016 03:28
I need help with the remainder
Sidharth Kriplani
@sidkrip
Mar 16 2016 03:35
@joyam09 paste the code
@hnry are you done with the bonfire Arguments Optional?
joyam09
@joyam09
Mar 16 2016 03:38

var remainder= 2;

35 % 3 = 2;

@hnry
bitgrower
@bitgrower
Mar 16 2016 03:38
ready to dive into closures, @sidkrip ?
hnry
@hnry
Mar 16 2016 03:39
@sidkrip yea
bitgrower @bitgrower thks @andrewchar ... just general principle
CamperBot
@camperbot
Mar 16 2016 03:39
bitgrower sends brownie points to @andrewchar :sparkles: :thumbsup: :sparkles:
:star: 355 | @andrewchar | http://www.freecodecamp.com/andrewchar
Sidharth Kriplani
@sidkrip
Mar 16 2016 03:40
@joyam09 it is asking you to set the var remainder = 11%3
Andrew Charlebois
@andrewchar
Mar 16 2016 03:40
huh
Sidharth Kriplani
@sidkrip
Mar 16 2016 03:40
not 35%3
joyam09
@joyam09
Mar 16 2016 03:41
what is than
bitgrower
@bitgrower
Mar 16 2016 03:41
huh what, @andrewchar ?
joyam09
@joyam09
Mar 16 2016 03:41
thanks @sidkrip
CamperBot
@camperbot
Mar 16 2016 03:41
joyam09 sends brownie points to @sidkrip :sparkles: :thumbsup: :sparkles:
:star: 360 | @sidkrip | http://www.freecodecamp.com/sidkrip
Andrew Charlebois
@andrewchar
Mar 16 2016 03:41
what you thank me for
Sidharth Kriplani
@sidkrip
Mar 16 2016 03:41
@bitgrower @hnry here is my messed up code in which I think I have included all the functionality which the wiki page asked me to
function add() {

  var num=arguments.length;
  var undef="undefined";
  //checkIfNum(arguments[0]);

  for(var i=0; i<2; i++) {
    if(arguments[i]=="undefined") {
      break;
    }
    return undef;
  }

  if (num==1) {
    add();
  }

  function checkIfNum(arg) {
  var ret=false;
  if(typeof arg == 'number')
    ret=true;
  return ret;
}

  return false;
}
bitgrower
@bitgrower
Mar 16 2016 03:42
being a great example of a code learner ... :)
Sidharth Kriplani
@sidkrip
Mar 16 2016 03:42
yes @bitgrower closures are good and easy
Andrew Charlebois
@andrewchar
Mar 16 2016 03:42
haha
so for this algorithm. im challenging myself
im only going to use .substr
or regex
bitgrower
@bitgrower
Mar 16 2016 03:42
cool ...
okay ... well, you need to return the function if you have one argument, and your function has to do something, @sidkrip
Sidharth Kriplani
@sidkrip
Mar 16 2016 03:46
@bitgrower that's what the 14th line is for where I am checking if the number of arguments is 1
bitgrower
@bitgrower
Mar 16 2016 03:46
okay, what happens if you have 2 arguments ?
Sidharth Kriplani
@sidkrip
Mar 16 2016 03:46
@bitgrower that....is what I didnt include;
bitgrower
@bitgrower
Mar 16 2016 03:47
your conditional for # of arguments being 1 simply recursively calls the current function, it doesn't define a new one :)
hnry
@hnry
Mar 16 2016 03:47
@sidkrip you don't need a variable for "undefined" there is already a type undefined
Sidharth Kriplani
@sidkrip
Mar 16 2016 03:48
@hnry yeah I corrected that just now. my bad :D
hnry
@hnry
Mar 16 2016 03:48
if you wanted to know if variable is defined to not you do typeof x
or*
ok i see you know that one, sorry reading it line by line and just saying what i see, i don't think you need checkIfNum, you could group checking the type of the arguments together if number and defined
Sidharth Kriplani
@sidkrip
Mar 16 2016 03:50
@bitgrower I have to define another function for that now?
@hnry yes, that eliminates one more function
Francis
@Francis-p
Mar 16 2016 03:51
good afternoon people!
hnry
@hnry
Mar 16 2016 03:51
@sidkrip so i would simplify and group your argument type checking in one place, then make your closure and return
Sidharth Kriplani
@sidkrip
Mar 16 2016 03:54
@bitgrower @hnry here is the changed code:
function add() {

  var num=arguments.length;
  var sum=0;
  //checkIfNum(arguments[0]);
  for(var i=0; i<2; i++) {if(typeof arguments[i]!=="number") return undefined;}

  if (num==1) {add();}
  else if(num==2) {sum=arguments[0]+arguments[1];}

  function enterAnother() {

  }

  return false;
}
Francis
@Francis-p
Mar 16 2016 03:54
@devlindigital you manage to solve the issue? i am having some understanding problem with arguments
so argument is use like a array?
bitgrower
@bitgrower
Mar 16 2016 03:56

@sidkrip .... you can write the skeleton like this ...

if (num === 1) {
retun function (){};

buuug7
@buuug7
Mar 16 2016 03:57
help
CamperBot
@camperbot
Mar 16 2016 03:57

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. ex: find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • Algorithm BONFIRENAME info on a Algorithm

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Sidharth Kriplani
@sidkrip
Mar 16 2016 03:57
@bitgrower okay
buuug7
@buuug7
Mar 16 2016 03:57
in the future the react will kill angular2.js?
Sidharth Kriplani
@sidkrip
Mar 16 2016 03:57
and then?
hnry
@hnry
Mar 16 2016 03:57
@sidkrip ok, i don't think you need the for loop or use of arguments, that's putting extra dazzle for no reason, but that's my opinion, and calling add() is an issue, but yes finish your closure
bitgrower
@bitgrower
Mar 16 2016 03:57
then see if you can follow the instructions given in the challenge
@buuug7 -- I don't think so -- they had angular earlier from what I understand, and switched to react
hnry
@hnry
Mar 16 2016 03:58
@buuug7 that's probably true already, though angular2 isn't even officially released
buuug7
@buuug7
Mar 16 2016 03:58
which framwork i choices? react or angular2?
Sidharth Kriplani
@sidkrip
Mar 16 2016 03:58
@bitgrower how should I make the closure expect another argument?
hnry
@hnry
Mar 16 2016 03:58
@sidkrip you don't
bitgrower
@bitgrower
Mar 16 2016 03:59
how do you write any function to "expect" (actually, accept) another argument ?
hnry
@hnry
Mar 16 2016 03:59
the closure only takes 1 argument
buuug7
@buuug7
Mar 16 2016 03:59
angular1 i will not learn it more
Sidharth Kriplani
@sidkrip
Mar 16 2016 03:59
@hnry so the closure takes the arguments and passes it back to add?
(argument
*argument
hnry
@hnry
Mar 16 2016 04:00
no
buuug7
@buuug7
Mar 16 2016 04:00
@hnry you means i learn react?
hnry
@hnry
Mar 16 2016 04:00
the "closure" is the final stop, it should do the adding
@buuug7 yea i think react is more popular and angular2 doesn't look like it'll bring anything new to take people away from react
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:02
@hnry okay so the add() function receives the first argument and then the closure accesses it using add().argument[0]? and then the argument which has been passed to it, gets added to the previous one and it returns the result
?
oh, no. I store the argument[0] in a global var and then closure accesses it
buuug7
@buuug7
Mar 16 2016 04:03
@hnry o_o
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:03
@hnry that's what happens when I get dazed
Scott
@iBrunch
Mar 16 2016 04:03

Need help on "No Repeats Please".

The right answer returns when I test each condition in permAlone() one by one, but for some reason it won't let me pass. Conditions 4, 5 and 6 still have an X by them even though they work individually.

```

buuug7
@buuug7
Mar 16 2016 04:04
but i still confused with them
Scott
@iBrunch
Mar 16 2016 04:04
Need help on "No Repeats Please".
The right answer returns when I test each condition in permAlone() one by one, but for some reason it won't let me pass. Conditions 4, 5 and 6 still have an X by them even though they work individually.
var num;
var dup = 0;
var xDup = 2;
var len = 0;
var cond= false;

function permAlone(str) {
  var arrLetters = str.split("");
  var arrPerm = [];

  dupes(arrLetters);
  if (cond===true){
    return 0;
  }
  num = calc(dup,xDup,str.length);

  return num;
}

var calc = function(dup,xDup,len){
  var num1 = factorialize(len)-(((len-dup)*(xDup*dup))*factorialize(len-xDup));

  return num1; 
};

var dupes = function(data){
  data = data.sort();

  for(r=0;r<data.length;r++){
    if(data[r]==data[r+2]){
      console.log(r + " " + data[r]+data[r+2]);
      cond=true;

    } else if(data[r]===data[r+1]){
      dup=dup+1;

    }
  }
};

function factorialize(number) {
 var factorial=1;
  for(p=1; p<=number;p++){
    factorial*=p;
  }
  console.log(factorial);
  return factorial;
}
//permAlone("aabb");
//permAlone("abcdefa");
//permAlone("abfdefa");
// Randall Arakawa or Scrimpton1, pair programmed.


permAlone('aab');
hnry
@hnry
Mar 16 2016 04:04
add().argument[0] no this isn't valid, but yes the general idea i think you got it, but it needs to be a variable
not argument[0]
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:05
*arguments[0] then?
hnry
@hnry
Mar 16 2016 04:05
you don't need to use arguments, it overcomplicates things here
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:05
@hnry here is the new code:
function add() {

  var num=arguments.length;
  var sum=0;
  var arg0=arguments[0];
  //checkIfNum(arguments[0]);
  for(var i=0; i<2; i++) {if(typeof arguments[i]!=="number") return undefined;}

  if (num==1) {return add().enterAnother;}
  else if(num==2) {sum=arguments[0]+arguments[1];}

  function enterAnother(arg) {
    sum=arg+arg0;
  }

  return false;
}
buuug7
@buuug7
Mar 16 2016 04:06
angular2.js will be killed by react in the future?
hnry
@hnry
Mar 16 2016 04:06
@sidkrip http://jsbin.com/janurijimi/edit?js,console look at this example, it'll help you understand how the closure works
bitgrower
@bitgrower
Mar 16 2016 04:06
okay -- @hnry he definitely should not be using arguments[0], that would be bad form even if does work, because it makes the code less comprehensible ... he should definitely define a NEW local variable within the outer function and set arguments[0] to it
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:07
@hnry wait a second, I will paste it again with a few minor changes
@bitgrower did exactly that
hnry
@hnry
Mar 16 2016 04:07
@sidkrip do you see how in my example, returned_function has access to a ?
bitgrower
@bitgrower
Mar 16 2016 04:07
THAT new local variable then becomes the "closure" when the returned function references it ...
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:08
@bitgrower @hnry here, the new one:
function add() {

  var num=arguments.length;
  var sum=0;
  var arg0=arguments[0];
  //checkIfNum(arguments[0]);
  for(var i=0; i<2; i++) {if(typeof arguments[i]!=="number") return undefined;}


  function enterAnother(arg) {
    sum=arg+arg0;
    return sum;
  }

  if (num==1) {return enterAnother();}
  else if(num==2) {enterAnother();}

  return false;
}
hnry
@hnry
Mar 16 2016 04:09
sum is pointless, the return false is pointless too
Rahul
@rahulshinde235
Mar 16 2016 04:09
someone help how to increment in js
bitgrower
@bitgrower
Mar 16 2016 04:09
that looks close ... I wouldn't bother giving the function a name though ... just define it in the return statement ...
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:09
@hnry I removed the false thing.
hnry
@hnry
Mar 16 2016 04:09
and you are calling enterAnother which you should not do unless you had both arguments already
Rahul
@rahulshinde235
Mar 16 2016 04:09
myVar =myVar ++i;
bitgrower
@bitgrower
Mar 16 2016 04:10
increment i++ i += 1 i = i+1
hnry
@hnry
Mar 16 2016 04:10
@sidkrip but you are close, a function when you have 1 argument, return the output of the function when you have 2
return the function* when you have 1 arg i mean
Rahul
@rahulshinde235
Mar 16 2016 04:10
that is wrong how to do it
bitgrower
@bitgrower
Mar 16 2016 04:10
yeah, def true @hnry -- when you do enterAnother() -- you are calling the function immediately ...
excuse me @rahulshinde235 ... ?!?
Rahul
@rahulshinde235
Mar 16 2016 04:11

```
myVar =myVar ++i;

```help me solve this it is wrong

Sidharth Kriplani
@sidkrip
Mar 16 2016 04:12
@rahulshinde235 replace your line with myVar++
bitgrower
@bitgrower
Mar 16 2016 04:12
okay .. my internet is too wonky ...
Rahul
@rahulshinde235
Mar 16 2016 04:12
@sidkrip i did not working
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:12
@rahulshinde235 this is your complete console:
var myVar = 87;

// Only change code below this line
myVar++;
and this is working. Reset the console and try again
Rahul
@rahulshinde235
Mar 16 2016 04:13
oh like this
bitgrower
@bitgrower
Mar 16 2016 04:14
exasperation++
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:14
@hnry @bitgrower stupid question. If I am defining a skeleton function with no name and calling it when the number of arguments is just one, what do I call when there are two arguments?
function add() {

  var num=arguments.length;
  var sum=0;
  var arg0=arguments[0];
  //checkIfNum(arguments[0]);
  for(var i=0; i<2; i++) {if(typeof arguments[i]!=="number") return undefined;}

  if (num==1) {return function () {
    sum=arg+arg0;
    return sum;
  };}
  else if(num==2) {}
  else return;
}
bitgrower
@bitgrower
Mar 16 2016 04:15
they DO tell you how to increment a variable in the instructions, @rahulshinde235 ...
Rahul
@rahulshinde235
Mar 16 2016 04:15
forgot to tell u guys thanks @bitgrower @sidkrip
CamperBot
@camperbot
Mar 16 2016 04:15
rahulshinde235 sends brownie points to @bitgrower and @sidkrip :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Mar 16 2016 04:15
though telling people to use i++ is a bit dangerous without further explanation ...
CamperBot
@camperbot
Mar 16 2016 04:15
:star: 361 | @sidkrip | http://www.freecodecamp.com/sidkrip
:star: 868 | @bitgrower | http://www.freecodecamp.com/bitgrower
hnry
@hnry
Mar 16 2016 04:16
@sidkrip you can't, so don't make it an anonymous function, and why do you insist on using arguments
Rafael
@rafaelpdl
Mar 16 2016 04:17
Hi Guys, can someone please help me with the "Profile Lookup" challenge?
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:17
@hnry @bitgrower thanks guys. I think I will take a break from it and come back again. Steamroller now. Help needed with that as well.
CamperBot
@camperbot
Mar 16 2016 04:17
sidkrip sends brownie points to @hnry and @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 153 | @hnry | http://www.freecodecamp.com/hnry
:star: 869 | @bitgrower | http://www.freecodecamp.com/bitgrower
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:18
@rafaelpdl yeah paste your code
hnry
@hnry
Mar 16 2016 04:18
@sidkrip ok that sounds good, but you were actually very very close in your 2nd to last paste
99% of the way there
Francis
@Francis-p
Mar 16 2016 04:18
function(a, b, ...theArgs) {
  // ...
}
what is …theArgs?
hnry
@hnry
Mar 16 2016 04:19
theArgs is the rest of the arguments
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:19
@hnry I will resume digging again after Steamroller. I have to figure out how to flatten the array using recursion
here is my code for it
function steamroller(arr) {
  // I'm a steamroller, baby
  var len=arr.length;
  var arra=[];
  for(var i=0; i<len; i++) {
    if(arr.isArray()) {
      flatten(arr[i]);
      arra.push(arr[i]);
    }
    else {
      arra.push(arr[i]);
    }
  }
  return arr;
}

function flatten(arr) {
  while(arr.isArray()) {

  }
  return;
}
Rafael
@rafaelpdl
Mar 16 2016 04:19

My code is the following. The problem is that I am getting some multiple errors, and I dont understand why. Some of the errors are:

  • "Kristian", "lastName" should return "Vos"
  • "Sherlock", "likes" should return ["Intriguing Cases", "Violin"]
    -"Harry","likes" should return an array
  • "Akira", "address" should return "No such property"

The only thing I get right is: "Bob", "number" should return "No such contact"

//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 lookUp(firstName, prop){
// Only change code below this line
var j=0;

while (j<contacts.length) {

  if (contacts[j][0]===firstName) {

  if (contacts[j][prop]===undefined) {
    return "No such property";
      }

    else if (contacts[j][prop]!==undefined) {
    return contacts[j][prop];
      }
  } 

  else if (contacts[j][0]!==firstName) {

    return "No such contact";
  }

// Only change code above this line
}
}
// Change these values to test your function
lookUp("Akira", "address");
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:19
@bitgrower
Francis
@Francis-p
Mar 16 2016 04:20
@hnry how do we call an argument?
Rahul
@rahulshinde235
Mar 16 2016 04:20
@sidkrip why do i need to use += doesnt only using + work
hnry
@hnry
Mar 16 2016 04:20
@Francis-p what do you mean call an argument?
Rahul
@rahulshinde235
Mar 16 2016 04:21
whats an asisignment?
Francis
@Francis-p
Mar 16 2016 04:21
@hnry i am doing seek and destroy. but i don’t know how to get the argument
Gabe Pressman
@gpressman
Mar 16 2016 04:22
Hi can someone help me with Accessing Objects Properties with Variables
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:23
@rahulshinde235 rephrase your doubt again?
@gpressman paste your code
Rahul
@rahulshinde235
Mar 16 2016 04:24
to add 5 to myVar. Since this is such a common pattern, there are operators which do both a mathematical operation and assignment in one step........here what do you mean by assignment
Gabe Pressman
@gpressman
Mar 16 2016 04:24

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

Francis
@Francis-p
Mar 16 2016 04:25
@hnry i read that article 3 times! :worried:
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:25
to add 5 to your myVar, use += which translates to myVar=myVar+5
@rahulshinde235
Rahul
@rahulshinde235
Mar 16 2016 04:26
@sidkrip got that but what do we mean by assignment?
hnry
@hnry
Mar 16 2016 04:26
@Francis-p http://jsbin.com/kikoxinani/edit?js,console an example of it
Francis
@Francis-p
Mar 16 2016 04:26
how do i get arr to return hello
function destroyer(arr) {
arr = arr[2];
return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 'hello’);
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:27
@Francis-p what is it returning?
hnry
@hnry
Mar 16 2016 04:27
use arguments object like shown in the example i made
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:27
@rahulshinde235 assignment operator is used for assigning values to variables
@Francis-p as @hnry said, use argument2
*arguments
Rafael
@rafaelpdl
Mar 16 2016 04:28
@sidkrip Hi! Is it possible that you help me with the doubt I pasted a little above? I really dont know how to procceed from where I am
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:28
@Francis-p
arguments[2]
Francis
@Francis-p
Mar 16 2016 04:28
@sidkrip done. tried that syntex just now but it didn’t work. but it is okay now.
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:29
@gpressman change your lines like this:
var playerNumber=16;       // Change this Line
var player = testObj[playerNumber];   // Change this Line
Francis
@Francis-p
Mar 16 2016 04:29
@sidkrip i will continue from here. thanks @hnry @sidkrip
CamperBot
@camperbot
Mar 16 2016 04:29
francis-p sends brownie points to @sidkrip and @hnry :sparkles: :thumbsup: :sparkles:
:star: 154 | @hnry | http://www.freecodecamp.com/hnry
:star: 362 | @sidkrip | http://www.freecodecamp.com/sidkrip
Gabe Pressman
@gpressman
Mar 16 2016 04:30
thanks @sidkrip that probably should have been obvious
CamperBot
@camperbot
Mar 16 2016 04:30
gpressman sends brownie points to @sidkrip :sparkles: :thumbsup: :sparkles:
:star: 363 | @sidkrip | http://www.freecodecamp.com/sidkrip
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:31
@rafaelpdl there is a very concise way to do it. I cant really point out your error as I am running out of time but you can tally it with my code and figure it out on your own. Here it is:

function lookUp(firstName, prop){
// Only change code below this line
for (var x = 0; x < contacts.length; x++){
    if (contacts[x].firstName === firstName) {
        if (contacts[x][prop]) {
            return contacts[x][prop];
        } else {
            return "No such property";
        }
    }
}
return "No such contact";

// Only change code above this line
}
joyam09
@joyam09
Mar 16 2016 04:32
im confused about convert celsius to fahrenheut
Rafael
@rafaelpdl
Mar 16 2016 04:33
Thanks @sidkrip !
CamperBot
@camperbot
Mar 16 2016 04:33
rafaelpdl sends brownie points to @sidkrip :sparkles: :thumbsup: :sparkles:
:star: 364 | @sidkrip | http://www.freecodecamp.com/sidkrip
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:34
@joyam09 paste your problem quickly
joyam09
@joyam09
Mar 16 2016 04:34
i dont know how to do it
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:34
copy paste it
joyam09
@joyam09
Mar 16 2016 04:34

function convert(celsius) {
// Only change code below this line

// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

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

Sidharth Kriplani
@sidkrip
Mar 16 2016 04:34
help format
CamperBot
@camperbot
Mar 16 2016 04:34

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Sidharth Kriplani
@sidkrip
Mar 16 2016 04:35
@joyam09 where is your formula?

@joyam09 enter your formula between these two line:
// Only change code below this line

// Only change code above this line

and this is the formula you have to use:
var fahrenheit=((celsius*9)/5)+32;
@hnry if you are there, help me with the US telephone numbers bonfire man
CamperBot
@camperbot
Mar 16 2016 04:38
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Gabe Pressman
@gpressman
Mar 16 2016 04:43
am I missing something obvious on this one?
// Setup
function phoneticLookup(val) {
  var result = "";

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

  };



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

// Change this value to test
phoneticLookup("charlie");
Coy Sanders
@coymeetsworld
Mar 16 2016 04:45
@gpressman you are not doing anything with lookup in your function, so it will only return "";
Rachel
@chellybear
Mar 16 2016 04:45
oh my god, i just finished the Where Art Thou algorithm. that was annoying
Andrew Charlebois
@andrewchar
Mar 16 2016 04:46
@gpressman give results dat sweet sweet information!!!!!!!!!!
Rahul
@rahulshinde235
Mar 16 2016 04:46
this is annoying .:(
Andrew Charlebois
@andrewchar
Mar 16 2016 04:46
@chellybear did that earlier today, my god that one upset me
@chellybear 5 hours to get it
@chellybear with help :(
Coy Sanders
@coymeetsworld
Mar 16 2016 04:47
im doing the diff 2 arrays so i'm going to get to it soon @andrewchar @chellybear
Andrew Charlebois
@andrewchar
Mar 16 2016 04:48
i just finished up pig latin
Coy Sanders
@coymeetsworld
Mar 16 2016 04:48
oh nice
Rachel
@chellybear
Mar 16 2016 04:48
i feel like there was a better way to do this, nesting so many statements makes me want to cry
function where(collection, source) {
  var arr = [];
  var search = Object.keys(source); // array with our properties
  for(var obj = 0; obj < collection.length; obj++){ // iterate through objects
    for(var i = 0; i < search.length; i++){
      if(collection[obj].hasOwnProperty(search[i]) && (i+1 == search.length) &&
         collection[obj][search[i]] == source[search[i]]){ // check values of matching properties
            arr.push(collection[obj]);   
      }
    }
  }
  return arr;
}
Andrew Charlebois
@andrewchar
Mar 16 2016 04:49
@chellybear giving @coymeetsworld the answers :P
Rachel
@chellybear
Mar 16 2016 04:49
@andrewchar right? i kept deleting mine over and over cause there were so many nested loops i was like..totally forgot where i was
Coy Sanders
@coymeetsworld
Mar 16 2016 04:49
nah i wont do that :)
Gabe Pressman
@gpressman
Mar 16 2016 04:49
@andrewchar I put result = val; and nothing
Coy Sanders
@coymeetsworld
Mar 16 2016 04:49
and @chellybear it looks good, nesting isn't so bad especially if you can write less lines of code
Andrew Charlebois
@andrewchar
Mar 16 2016 04:49
@chellybear
function where(collection, source) {

  var foo = Object.keys(source);

  var bar = [];

  for (var j = 0; j < collection.length; j++ ) {
    var boolean = true;
    for (var i = 0; i < foo.length; i++ ) {
      if (!collection[j].hasOwnProperty(foo[i]) || collection[j][foo[i]] !== source[foo[i]]) {
            boolean = false;     
      } 

      }
        if (boolean === true) {
      bar.push(collection[j]);


    }

    }
  console.log(bar);
  return bar;



}

where([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
Gabe Pressman
@gpressman
Mar 16 2016 04:50
@andrewchar nvm I figured it out
@andrewchar @coymeetsworld thanks guys
CamperBot
@camperbot
Mar 16 2016 04:50
gpressman sends brownie points to @andrewchar and @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 346 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
:star: 357 | @andrewchar | http://www.freecodecamp.com/andrewchar
Coy Sanders
@coymeetsworld
Mar 16 2016 04:50
np @gpressman gj
Andrew Charlebois
@andrewchar
Mar 16 2016 04:51
@chellybear there is a way to do it with filter which im going to try in the next few days
once i get over the hate for this algorithm lol
@coymeetsworld i skipped roman numerals if you wanna pair for it
Rachel
@chellybear
Mar 16 2016 04:53
yeah i read up on that.. was like nah. my brain is fried, i'll just nest a bunch of stuff
Coy Sanders
@coymeetsworld
Mar 16 2016 04:53
yeah maybe how late you going to be around @andrewchar ? going to be in the middle of something for another hour
Andrew Charlebois
@andrewchar
Mar 16 2016 04:54
not that long, its almost 1a.m here
maybe tomorrow if you still on it tomorrow
or have not started
Coy Sanders
@coymeetsworld
Mar 16 2016 04:55
oh ok yeah let me know, ill save it just in case i get to it tonight
Andrew Charlebois
@andrewchar
Mar 16 2016 04:55
i tried it for a bit and just went to the next one lol
have yet to go back to it
and did the calculator project in between, got bored of algorithms
Coy Sanders
@coymeetsworld
Mar 16 2016 04:56
i see, i know how to do the diff i think im just thinking of the right way to do it, i.e less lines of code
i did calculator already, because before it was listed as one of the first projects
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:56
@rahulshinde235 what's the problem now?
Coy Sanders
@coymeetsworld
Mar 16 2016 04:56
also did the pomodoro clock
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:56
@coymeetsworld you da man! Help me with Steamroller
?
Andrew Charlebois
@andrewchar
Mar 16 2016 04:56
@coymeetsworld nice
Coy Sanders
@coymeetsworld
Mar 16 2016 04:57
but that was before they changed the projects around back in feb or whenever it was
@sidkrip Steamoller?
*steamroller?
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:57
yep
Coy Sanders
@coymeetsworld
Mar 16 2016 04:57
whats that?
Andrew Charlebois
@andrewchar
Mar 16 2016 04:57
algorithm
3/4th way down the list
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:57
@coymeetsworld its a bonfire
Andrew Charlebois
@andrewchar
Mar 16 2016 04:58
hes not there yet i dont think
Coy Sanders
@coymeetsworld
Mar 16 2016 04:58
oh no im not there lol
those projects i did before the algorithms because thats how it was listed
Kyle Morton
@kmorton1988
Mar 16 2016 04:58
hi folks
Andrew Charlebois
@andrewchar
Mar 16 2016 04:58
we just saying we did some projects that are past the algos
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:58
@andrewchar have you done it?
Coy Sanders
@coymeetsworld
Mar 16 2016 04:58
they changed it like in Feb
Andrew Charlebois
@andrewchar
Mar 16 2016 04:58
nope
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:58
@kmorton1988 Hey
Andrew Charlebois
@andrewchar
Mar 16 2016 04:58
my calc is done for that reason to
Sidharth Kriplani
@sidkrip
Mar 16 2016 04:58
:(
Andrew Charlebois
@andrewchar
Mar 16 2016 04:58
i was half way done before the track changed
Coy Sanders
@coymeetsworld
Mar 16 2016 04:59
yeah oh well that means i just have 2 projects and these algorithms and im done with front end :)
Andrew Charlebois
@andrewchar
Mar 16 2016 05:00
we close!
Coy Sanders
@coymeetsworld
Mar 16 2016 05:00
yep yep :clap: high 5
Andrew Charlebois
@andrewchar
Mar 16 2016 05:00
i think the rest of the projects for front end will take a while thou
Sidharth Kriplani
@sidkrip
Mar 16 2016 05:00
I have all the projects and some algos and I am done with front end. not so good
Andrew Charlebois
@andrewchar
Mar 16 2016 05:00
for me anyway
Coy Sanders
@coymeetsworld
Mar 16 2016 05:00
yeah perhaps
Andrew Charlebois
@andrewchar
Mar 16 2016 05:00
i hear tic tax toe can be a pain to try and make the game really hard
Coy Sanders
@coymeetsworld
Mar 16 2016 05:01
yeah i can see it taking some time
Rachel
@chellybear
Mar 16 2016 05:01
ughhh i wanna get started on the projects. they look more fun to do than these algorithms (╯°□°)╯︵ ┻━┻
Coy Sanders
@coymeetsworld
Mar 16 2016 05:02
algorithms are fun! @chellybear lol
Andrew Charlebois
@andrewchar
Mar 16 2016 05:02
best fun youll ever have
:)
Kyle Morton
@kmorton1988
Mar 16 2016 05:02
@chellybear how do you expect to be able to do the projects if you can't pass the algorithms?
there's a reason it's in this order lol.
Coy Sanders
@coymeetsworld
Mar 16 2016 05:03
i didn't need to do them to do the projects @kmorton1988 :)
Rachel
@chellybear
Mar 16 2016 05:03
i've done most of these harder ones before in school but i think they were so horrifying my brain blocked them out lol
Kyle Morton
@kmorton1988
Mar 16 2016 05:03
hmm. shrugs even still. I feel like it's good practice.
Rachel
@chellybear
Mar 16 2016 05:04
i've gotten started on my tictactoe project but i feel like i should finish these algos, theyre still annoying tho
Coy Sanders
@coymeetsworld
Mar 16 2016 05:04
but then again the curriculum had me doing the projects before these algorithms
Andrew Charlebois
@andrewchar
Mar 16 2016 05:04
i feel like algo's are meant to get you to think like a programmer
Coy Sanders
@coymeetsworld
Mar 16 2016 05:04
yes definitely
Andrew Charlebois
@andrewchar
Mar 16 2016 05:04
seems like thats the boundary
once the brain can think in code
hnry
@hnry
Mar 16 2016 05:05
@sidkrip i'm here now, what's up?
Rachel
@chellybear
Mar 16 2016 05:05
how often do they change the curriculum? i'm p new at FCC so should i be worried theyll like remove something i'm still working on?
Andrew Charlebois
@andrewchar
Mar 16 2016 05:06
ive been here 3-4 months, happened once that i noticed
Coy Sanders
@coymeetsworld
Mar 16 2016 05:06
i just started this year @chellybear, yaeh it only happened once
its not a big concern, they just try to improve on things when they can
the founder talks about this a bit on the blog or somewhere i think
Rachel
@chellybear
Mar 16 2016 05:08
cool
hnry
@hnry
Mar 16 2016 05:08
@chellybear i signed up like a year ago and dropped it for like 6 months, and all my works is still there as far as i can tell
Rachel
@chellybear
Mar 16 2016 05:08
oh cool, okay
hnry
@hnry
Mar 16 2016 05:09
no not a year ago lol, more like 6 months ago and left for like 4 months
kevharvell
@kevharvell
Mar 16 2016 05:09
omg, this roman numeral algorithm is making my head explode!
Andrew Charlebois
@andrewchar
Mar 16 2016 05:09
@kevharvell i skipped it lol
Rachel
@chellybear
Mar 16 2016 05:09
i've been here almost a month, haven't seen any changes yet but maybe i'm just oblivious ahah..
kevharvell
@kevharvell
Mar 16 2016 05:10
@andrewchar it is so freakin hard... I have no idea what the best approach is
hnry
@hnry
Mar 16 2016 05:10
@kevharvell what have you done so far?
Rachel
@chellybear
Mar 16 2016 05:11
@kevharvell i hated that one. i had a friend help me through it but i still don't fully understand it q_q gotta go back and redo it
kevharvell
@kevharvell
Mar 16 2016 05:12
@hnry random crap leading no where :/ i have the idea of dividing the input by multiples of roman numerals. i.e. 1000, 500, 100, etc. then using for loops to iterate, but then the problem is the weird ones like 9 (IX) or 90 (XC)
hnry
@hnry
Mar 16 2016 05:12
oh speaking of changes, they changed roman numerals challenge to have more tests since i last did it
Rachel
@chellybear
Mar 16 2016 05:12
oooo thanks @coymeetsworld
CamperBot
@camperbot
Mar 16 2016 05:12
chellybear sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 347 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
hnry
@hnry
Mar 16 2016 05:13
@kevharvell why about just translating it into roman numerals?
and not trying to convert it
kevharvell
@kevharvell
Mar 16 2016 05:14
so you there should be data somewhere? lol is there a json file
hnry
@hnry
Mar 16 2016 05:15
@kevharvell well javascript supports record types or key value pairs they are just objects { 10: X } for instance
kevharvell
@kevharvell
Mar 16 2016 05:16
right, so make my own object basically?
hnry
@hnry
Mar 16 2016 05:16
yea i think that's the simplest approach
kevharvell
@kevharvell
Mar 16 2016 05:16
i'll try that approach, sounds like i can get somewhere
thanks bruh @hnry
CamperBot
@camperbot
Mar 16 2016 05:16
kevharvell sends brownie points to @hnry :sparkles: :thumbsup: :sparkles:
:star: 155 | @hnry | http://www.freecodecamp.com/hnry
evolvednight
@evolvednight
Mar 16 2016 05:17
Hi guys, I am on "seek and destroy"
function destroyer(arr) {
// Remove all the values
var newArr = arr.filter(function(val) {
return arr !== val;
});
}
Francis
@Francis-p
Mar 16 2016 05:17
can we have a funtion within a function?
Kyle Morton
@kmorton1988
Mar 16 2016 05:17
yup!
it's just that its scope is reserved to within that parent-function
Francis
@Francis-p
Mar 16 2016 05:18
@kmorton1988 what do you mean by scope?
Andrew Charlebois
@andrewchar
Mar 16 2016 05:19
thats a big question
Francis
@Francis-p
Mar 16 2016 05:19
@andrewchar in the simplest way?
Rachel
@chellybear
Mar 16 2016 05:20
@evolvednight i don't think you can compare a whole array to a single value
Kyle Morton
@kmorton1988
Mar 16 2016 05:20
let's say you make a function, like so:
function myFunction(args) {
  function anotherFunction(){
    do stuff
  }
}
Andrew Charlebois
@andrewchar
Mar 16 2016 05:20
Scope is the area within which the variable is active.
tbaotran
@tbaotran
Mar 16 2016 05:20
Can someone help look and see what I am missing?
``` js
evolvednight
@evolvednight
Mar 16 2016 05:20
Hi guys, I am on "seek and destroy"
function destroyer(arr) {
// Remove all the values
var newArr = arr.filter(function(val) {
return arr !== val;
});
}
I dont understand how filter works here.
Andrew Charlebois
@andrewchar
Mar 16 2016 05:20
global scope, local scope
Kyle Morton
@kmorton1988
Mar 16 2016 05:20
the function "anotherFunction" would only be available to code that is written INSIDE of the myFunction functidon
V Arun Kumar
@arunvkumr
Mar 16 2016 05:21
@tbaotran post your code
Kyle Morton
@kmorton1988
Mar 16 2016 05:21
so if a different function or argument OUTSIDE of myFunction tried to call anotherFunction, it would fail, with the "function doesn't exists: anotherFunction" error
tbaotran
@tbaotran
Mar 16 2016 05:21

function convert(celsius) {
// Only change code below this line

farenheit = 9/5 *(celsius + 32);
// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

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

Francis
@Francis-p
Mar 16 2016 05:21
@kmorton1988 that’s not hard to understand :smile:
Kyle Morton
@kmorton1988
Mar 16 2016 05:21
nope :)
relatively simple.
Francis
@Francis-p
Mar 16 2016 05:21
@kmorton1988 thanks!
CamperBot
@camperbot
Mar 16 2016 05:21
francis-p sends brownie points to @kmorton1988 :sparkles: :thumbsup: :sparkles:
:star: 281 | @kmorton1988 | http://www.freecodecamp.com/kmorton1988
Kyle Morton
@kmorton1988
Mar 16 2016 05:21
sure thing :)
V Arun Kumar
@arunvkumr
Mar 16 2016 05:22
@tbaotran the formula.. it's not right.. you have multiply celsius with 9/5 then add... not other way around
dkennell
@dkennell
Mar 16 2016 05:22
@tbaotran You've got the order of operations wrong. The addition is supposed to come after the multiplication. :)
Rachel
@chellybear
Mar 16 2016 05:22
@evolvednight afaik filter returns a new array with only values that are true through your callback function
Coy Sanders
@coymeetsworld
Mar 16 2016 05:23
correct @chellybear
he's comparing an array to a value, that part isn't right
tbaotran
@tbaotran
Mar 16 2016 05:23
celsius = 5/9 * (fahrenheit -32)
evolvednight
@evolvednight
Mar 16 2016 05:23
@chellybear Thanks! in this case do i just split the array into two? ?
CamperBot
@camperbot
Mar 16 2016 05:23
evolvednight sends brownie points to @chellybear :sparkles: :thumbsup: :sparkles:
dkennell
@dkennell
Mar 16 2016 05:23
@tbaotran So you just have to change where the parentheses are in the math part of your code.
CamperBot
@camperbot
Mar 16 2016 05:23
:star: 288 | @chellybear | http://www.freecodecamp.com/chellybear
V Arun Kumar
@arunvkumr
Mar 16 2016 05:24
@tbaotran fahrenheit = celsius*9/5 + 32;
tbaotran
@tbaotran
Mar 16 2016 05:24
let me try that and report back.
evolvednight
@evolvednight
Mar 16 2016 05:24
@coymeetsworld I was thinking about comparing to the rest of the array. but how do i do that?
Rachel
@chellybear
Mar 16 2016 05:25
@evolvednight you want to iterate through the entire array somehow to compare each element in your array to the value
Coy Sanders
@coymeetsworld
Mar 16 2016 05:25
yep
evolvednight
@evolvednight
Mar 16 2016 05:26
@coymeetsworld @chellybear ok let me try it out and i will let you guys know! Thanks!
CamperBot
@camperbot
Mar 16 2016 05:26
evolvednight sends brownie points to @coymeetsworld and @chellybear :sparkles: :thumbsup: :sparkles:
:warning: evolvednight already gave chellybear points
:star: 348 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
V Arun Kumar
@arunvkumr
Mar 16 2016 05:26
@evolvednight filter automatically iterates through the array, and returns true if the condition matches and only those elements are returned back into the new array...
Coy Sanders
@coymeetsworld
Mar 16 2016 05:27
yeah gl @evolvednight maybe take a look at the documentation for array.filter for help: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
tbaotran
@tbaotran
Mar 16 2016 05:27
@arunkumrv that works.
thanks.
Sidharth Kriplani
@sidkrip
Mar 16 2016 05:27
@arunkumrv you da man! help me with some bonfires?
CamperBot
@camperbot
Mar 16 2016 05:27
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
V Arun Kumar
@arunvkumr
Mar 16 2016 05:27
@tbaotran :grinning: :+1:
Matthew Steiner
@Novakarma
Mar 16 2016 05:27

I can't get this to pass, any thoughts?
function myTest(val) {
if (val) != 99 {
return "Not Equal";
}
return "Equal";
}

// Change this value to test
myTest(12);

V Arun Kumar
@arunvkumr
Mar 16 2016 05:28
@sidkrip which bonefire you are doing?
Sidharth Kriplani
@sidkrip
Mar 16 2016 05:28
@Novakarma which challenge?
Matthew Steiner
@Novakarma
Mar 16 2016 05:28
Comparison with the Inequality Operator
Coy Sanders
@coymeetsworld
Mar 16 2016 05:28
@Novakarma you need to fix the parenthesis
Matthew Steiner
@Novakarma
Mar 16 2016 05:28
how so?
Rachel
@chellybear
Mar 16 2016 05:28
This message was deleted
Coy Sanders
@coymeetsworld
Mar 16 2016 05:28

if (expression to evaluate) {

}

NormalWare
@Centuriom
Mar 16 2016 05:29
Hello guys, what is the
@media screen and (){}
Of jQuery ?
Coy Sanders
@coymeetsworld
Mar 16 2016 05:29

i.e.

if (val != 99) {

}

Sidharth Kriplani
@sidkrip
Mar 16 2016 05:29
@arunkumrv I am stuck at many at the moment. US Telephone Numbers, Steamroller, SUm All Odd Fibonacci, Friendly Date Ranges, Arguments Optional
dkennell
@dkennell
Mar 16 2016 05:29
@Novakarma You're missing the 'else' keyword after your 'if'
Matthew Steiner
@Novakarma
Mar 16 2016 05:29
very cool!
Sidharth Kriplani
@sidkrip
Mar 16 2016 05:30
Lets start with US Telephone Numbers
Rachel
@chellybear
Mar 16 2016 05:30
oh wait nevermind i didnt see the parentheses. i'm blind
Coy Sanders
@coymeetsworld
Mar 16 2016 05:30
@dkennell you actually don't need the else statement for that
dkennell
@dkennell
Mar 16 2016 05:30
@dkennell Whoops, nevermind. Derp
Matthew Steiner
@Novakarma
Mar 16 2016 05:30
Yeah, i forgot to put it all in the parenthesis
thanks!
Sidharth Kriplani
@sidkrip
Mar 16 2016 05:30
@dkennell it doesnt need an else. Unless there would have been if elses before it, there is no need for an else
dkennell
@dkennell
Mar 16 2016 05:30
@coymeetsworld You're right, good call, Coy.
Yep. Sorry, all. Lol
Olawale Akinseye
@brainyfarm
Mar 16 2016 05:31
@sidkrip, I did the US telephone number validation some days ago and learning the basics of regex helped a lot.
V Arun Kumar
@arunvkumr
Mar 16 2016 05:31
@sidkrip wow, you are working on all of those at once?
i didn't start these bonefires but i think i can help you with sum all odd fibo.. post your code
Sidharth Kriplani
@sidkrip
Mar 16 2016 05:32
@brainyfarm this is my code for US Telephone Numbers:
function telephoneCheck(str) {
  // Good luck!
  var regex=new RegExp(/1?[\s-]?\(?(\d{3})\)?[\s-]?\d{3}[\s-]?\d{4}/g);
  var res=false;
  for(var j=0; j<6; j++) {
    if (str==regex) {
      res=true;
    }
  } 
  return res;
}
Olawale Akinseye
@brainyfarm
Mar 16 2016 05:32
I did not even finish the tutorial at regexone.com when I got the aha!
V Arun Kumar
@arunvkumr
Mar 16 2016 05:32
@sidkrip for US Telephone.. you need to be good at regexp man.. i'm still learning about them, cant much help you in those...
Sidharth Kriplani
@sidkrip
Mar 16 2016 05:33

@arunkumrv and this is the code for Fibonacci:

function sumFibs(num) {
  var result;
  var a=1, b=1, c, sum;
  var arr=[a, b];
  for(var i=0; i<num; i++) {
  c=a+b;
  sum=c+b;
  arr.push(c);
  c=sum;
  b=c;
  }
  return arr;
}

the thing is, I am trying to generate num numbers of FIbonacci terms

Coy Sanders
@coymeetsworld
Mar 16 2016 05:33
try using this to test regex: https://regex101.com/
Sidharth Kriplani
@sidkrip
Mar 16 2016 05:33
@brainyfarm I have figured out the Regex for the bonfire but I cant work out the rest. Check my code
Olawale Akinseye
@brainyfarm
Mar 16 2016 05:34
@sidkrip, here is the suggestion! You do not need that for loop, put all the valid stuff into regex101.com and match one line at a time.
Sidharth Kriplani
@sidkrip
Mar 16 2016 05:35
@brainyfarm dont need the regex sites any longer. That regexp works for all the provided samples.
Olawale Akinseye
@brainyfarm
Mar 16 2016 05:35
@sidkrip, you can use | as OR so you keep chaining the regex together.
Oh! I see @sidkrip.
That is one good regex.
Sidharth Kriplani
@sidkrip
Mar 16 2016 05:36
@brainyfarm the problem with my code is, that it is returning false for all the inputs because hardcoded. The for loop isnt working idk why and I am 100% sure the regexp is working
Olawale Akinseye
@brainyfarm
Mar 16 2016 05:37
Hold on @sidkrip, let me get my computer.
Sidharth Kriplani
@sidkrip
Mar 16 2016 05:37
yep sure
Coy Sanders
@coymeetsworld
Mar 16 2016 05:37
@sidkrip i don't get the loop, why is it hardcoded to loop 6 times?
Sidharth Kriplani
@sidkrip
Mar 16 2016 05:38
@coymeetsworld because the number of valid US number formats are 6
Coy Sanders
@coymeetsworld
Mar 16 2016 05:39
don't think that's right
also nothing different happens in the loop, you're executing the same thing 6 times
Olawale Akinseye
@brainyfarm
Mar 16 2016 05:39
@sidkrip, won't . test() be Okay?
Kyle Morton
@kmorton1988
Mar 16 2016 05:39
how come a function I'm trying to call is coming back as "undefined is not a function"?
function destroyer(arr) {
  // Remove all the values

  function isInArguments(thing) {
    for (i = 0; i<thing[0][i]; i++){
      if (thing[0][i] !== arguments[1] || thing[0][i] !== arguments[2]){
        return arr[0][i];
      }
    }
  }

 var newArray = arr.filter(isInArguments(arr));
  return newArray;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Sidharth Kriplani
@sidkrip
Mar 16 2016 05:40
@coymeetsworld I get it now! I dont think it will work. Forgot to change the code after I had combined all the 6 regexps into one :D
Coy Sanders
@coymeetsworld
Mar 16 2016 05:40
yeah shouldn't need a loop thats what i was confused about @sidkrip
Sidharth Kriplani
@sidkrip
Mar 16 2016 05:41
@coymeetsworld @brainyfarm okay so after removing the loop, this is the code:
function telephoneCheck(str) {
  // Good luck!
  var regex=new RegExp(/1?[\s-]?\(?(\d{3})\)?[\s-]?\d{3}[\s-]?\d{4}/g);
  var res=false;
  if (str==regex) {
      res=true;
  } 
  return res;
}
Coy Sanders
@coymeetsworld
Mar 16 2016 05:41
@kmorton1988 problem is what you're passing into destroyer
its expecting an array
Kyle Morton
@kmorton1988
Mar 16 2016 05:42
OH!
ok that makes things a bit more clear, I'll work on it.
thanks @coymeetsworld
CamperBot
@camperbot
Mar 16 2016 05:42
kmorton1988 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 349 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Mar 16 2016 05:43
np
Sidharth Kriplani
@sidkrip
Mar 16 2016 05:44
@brainyfarm @coymeetsworld I changed the str==regex to str.match(regex) and it changed the output completely. True for everything
Olawale Akinseye
@brainyfarm
Mar 16 2016 05:44
@sidkrip
Why not just get it done ins such a way you can do
return regex.test(str) ?
I do not know if your regex is good yet @sidkrip .
V Arun Kumar
@arunvkumr
Mar 16 2016 05:45
@sidkrip once your done with US Telephone number.. let me know i'll tell you about sum of fibs.. :grinning:
Jonathan
@jcadle
Mar 16 2016 05:46
I think I'm doing something a little silly with an if test here.
for (i = 0; i <= contacts.length; i++) {
if (firstName == contacts[i].firstName) {
if (contacts[i].prop) {
return contacts[i].prop;
}
else {
return "No such property";
}
}
else {
return "No such contact";
}
}
ah damnit, that's not the right markdown either
Olawale Akinseye
@brainyfarm
Mar 16 2016 05:47

@sidkrip
I just tested your code, while it matched the correct formats, it also matches incorrect inputs

Test it out here
https://regex101.com/r/cW3yW0/1

Sidharth Kriplani
@sidkrip
Mar 16 2016 05:47
@brainyfarm have checked it out on regexr so the regex is working.
@arunkumrv yes as soon as I am done with this one :D
Jonathan
@jcadle
Mar 16 2016 05:48
I'll try again
for (i = 0; i <= contacts.length; i++) {
  if (firstName == contacts[i].firstName) {
    if (contacts[i].prop) {
      return contacts[i].prop;
    }
    else {
      return "No such property";
    }
  }
  else {
    return "No such contact";
  }
}
Olawale Akinseye
@brainyfarm
Mar 16 2016 05:49
@jcadle
Can you post the whole thing with the objects and all so we can test?
Bruno Miguel Pereira
@bmpereira
Mar 16 2016 05:49
Hi
Jonathan
@jcadle
Mar 16 2016 05:49
oh, sure
Bruno Miguel Pereira
@bmpereira
Mar 16 2016 05:50
Need a little input from you relating to the temperature converter JS challenge
Jonathan
@jcadle
Mar 16 2016 05:50
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 lookUp(firstName, prop){
// Only change code below this line

for (i = 0; i <= contacts.length; i++) {
  if (firstName == contacts[i].firstName) {
    if (contacts[i].prop) {
      return contacts[i].prop;
    }
    else {
      return "No such property";
    }
  }
  else {
    return "No such contact";
  }
}
// Only change code above this line
}
Olawale Akinseye
@brainyfarm
Mar 16 2016 05:50
Thanks @jcadle :D
CamperBot
@camperbot
Mar 16 2016 05:50
brainyfarm sends brownie points to @jcadle :sparkles: :thumbsup: :sparkles:
:star: 218 | @jcadle | http://www.freecodecamp.com/jcadle
Bruno Miguel Pereira
@bmpereira
Mar 16 2016 05:50
var fahrenheit = celcius * 1.8 + 32;
Can't find celsius variable
Sidharth Kriplani
@sidkrip
Mar 16 2016 05:51
@brainyfarm damn that is scary
@bmpereira *celsius
typo error
Jonathan
@jcadle
Mar 16 2016 05:52
I think I found one problem; the else for no such contact shouldn't be in the for loop
Olawale Akinseye
@brainyfarm
Mar 16 2016 05:52
@jcadle
You need to use if (contacts[i].hasOwnProperty(prop)) to check if that property exists.
@sidkrip
Try to match one at a time ;)
Bruno Miguel Pereira
@bmpereira
Mar 16 2016 05:53
@sidkrip thank you so much! it's too early over here, brain still waking up...
CamperBot
@camperbot
Mar 16 2016 05:53
bmpereira sends brownie points to @sidkrip :sparkles: :thumbsup: :sparkles:
:star: 365 | @sidkrip | http://www.freecodecamp.com/sidkrip
Jonathan
@jcadle
Mar 16 2016 05:53
Thanks brainyfarm
Olawale Akinseye
@brainyfarm
Mar 16 2016 05:53
Enjoy @jcadle :D
Sidharth Kriplani
@sidkrip
Mar 16 2016 05:54
@brainyfarm this is where that regexp comes from: http://regexone.com/problem/matching_phone_numbers
Jonathan
@jcadle
Mar 16 2016 05:55
Hmm. still isn't working though
Olawale Akinseye
@brainyfarm
Mar 16 2016 05:56
I used that site to learn the basic of regex @sidkrip so I made my own stuff instead and remember, that problem is only matching the area codes!
Share your code again @jcadle :D
Sidharth Kriplani
@sidkrip
Mar 16 2016 05:56
@brainyfarm I will get back to it later then
thanks though
*thanks @brainyfarm
CamperBot
@camperbot
Mar 16 2016 05:57
sidkrip sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1629 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Jonathan
@jcadle
Mar 16 2016 05:57
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 lookUp(firstName, prop){
// Only change code below this line

for (i = 0; i <= contacts.length; i++) {
  if (firstName == contacts[i].firstName) {
    if (contacts[i].hasOwnProperty(prop)) {
      return contacts[i].prop;
    }
    else {
      return "No such property";
    }
  }
  else {
    return "No such contact";
  }
}
// Only change code above this line
}
Olawale Akinseye
@brainyfarm
Mar 16 2016 05:59
@jcadle
return contacts[i][prop];
Remember, you use the dot notation when the property is a variable @jcadle .
Francis
@Francis-p
Mar 16 2016 06:00
function destroyer(arr) {

  function destory(value) {
    return value = arguments[1];
  }
return destory(arr);

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
i am still trying out with arguments :worried:
Jonathan
@jcadle
Mar 16 2016 06:00
isn't the property a variable here? I'm not sure I understand.
Coy Sanders
@coymeetsworld
Mar 16 2016 06:00
you're sending 3 arguments @Francis-p, but destroyer only takes one
Markus Kiili
@Masd925
Mar 16 2016 06:00
@jcadle The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants". Bracket notation works with keys that can be arbitrary strings cat["lives left"]; //returns 3, variables var key="clothes"; cat[key]; //returns "pants", or expressions cat["lives"+" "+"left"]; //returns 3.
Olawale Akinseye
@brainyfarm
Mar 16 2016 06:01
@Francis-p
Array.prototype.slice.call(arguments)
You changed @Masd925 :D
Jonathan
@jcadle
Mar 16 2016 06:02
Hmm. I'll have to review object properties in js
thanks for all of your help
Coy Sanders
@coymeetsworld
Mar 16 2016 06:02
wait nvm on my comment @Francis-p im wrong
Francis
@Francis-p
Mar 16 2016 06:03
@coymeetsworld no prob
@brainyfarm so i have to slice the arguments?
Coy Sanders
@coymeetsworld
Mar 16 2016 06:03
it is a little more complicated than that though, take a look at the links that are posted there regarding Arguments and the filter function, you need to use both
Markus Kiili
@Masd925
Mar 16 2016 06:04
@brainyfarm I am a changed man, yes.
Francis
@Francis-p
Mar 16 2016 06:04
@coymeetsworld yes. i am trying to understand how to use arguments. not touching the task yet :worried:
Coy Sanders
@coymeetsworld
Mar 16 2016 06:04
Francis
@Francis-p
Mar 16 2016 06:04
@coymeetsworld done that.
V Arun Kumar
@arunvkumr
Mar 16 2016 06:05
@Francis-p when you use arguments, the arguments are taking of the current function... in your code the arguments it's referring to arguments of destroy not destroyer...
Olawale Akinseye
@brainyfarm
Mar 16 2016 06:06
@Francis-p
Yes and in the case you do something like destroyer([1, 2, 3, 1, 2, 3], 2, 3);, using Array.prototype.slice.call(arguments); would convert the arguments into [[1, 2, 3, 1, 2, 3], [2, 3]] and now it becomes easier to filter.
V Arun Kumar
@arunvkumr
Mar 16 2016 06:06
@Francis-p read that up.. :point_up: March 16, 2016 11:34 AM
Sultan Ahmed
@sultanshaik
Mar 16 2016 06:08
hi ppl, how do I traverse a two dimensional array using map?
function largestOfFour(arr) {
  // You can do this!
  arr1=arr.map(function(arr,index){
    return Math.max(arr[index]);
  });
  return arr1;

}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
I have to find the largest number in each subarray
Olawale Akinseye
@brainyfarm
Mar 16 2016 06:09
This message was deleted
Kyle Morton
@kmorton1988
Mar 16 2016 06:09
@sultanshaik you have to itterate through each subarray, so you'll need some kind of for loop.
oh or the map function, seemingly.
Markus Kiili
@Masd925
Mar 16 2016 06:11
@sultanshaik You can use loop or Math.max.apply(null,subArray) to get the largest numbers of a subArray.
Kyle Morton
@kmorton1988
Mar 16 2016 06:12
function destroyer(arr, a, b, c) {

  var newArray = [];

  // Remove all the values
  function removeIt(thing, num1, num2, num3) {
    for (i=0;i<arr.length;i++){
      if (num1 !== thing[i]){
        if (num2 !== thing[i])
          if (num3 !== thing[i])
            return thing[i];
      } 
     }  
    }  
 newArray = arr.filter(removeIt(arr, a, b, c));

 return newArray;
}

destroyer([1, 2, 3, 1, 2, 3],2,3);
why is it trying to run "1" as a function?
Sultan Ahmed
@sultanshaik
Mar 16 2016 06:13
Can't I use the map function?
Olawale Akinseye
@brainyfarm
Mar 16 2016 06:13

@sultanshaik

arr.map(function(item){ 
   // item is the current sub array so return max of the sub array here
  });

I am not trying to give the answer but you are not mapping properly

Geo Galagaran
@geeofree
Mar 16 2016 06:13
how do you guys edit your messages here? :O
Kyle Morton
@kmorton1988
Mar 16 2016 06:14
click the ... next to it and click edit
Geo Galagaran
@geeofree
Mar 16 2016 06:14
test
Kyle Morton
@kmorton1988
Mar 16 2016 06:14
hover your mouse over next to the time it was sent
Sultan Ahmed
@sultanshaik
Mar 16 2016 06:15
@brainyfarm I have tried
arr1=arr.map(function(index){
    return Math.max(index);
  });
  return arr1;
but i returns an array of null
Geo Galagaran
@geeofree
Mar 16 2016 06:15
weird. It seems to be unavailable for me. I can only do Reply and Quote
Olawale Akinseye
@brainyfarm
Mar 16 2016 06:15
@sultanshaik
return Math.max(...index); alternatively, use Math.max.apply(0, index)
Kyle Morton
@kmorton1988
Mar 16 2016 06:15
that's cause you're trying to click on someone elses?
V Arun Kumar
@arunvkumr
Mar 16 2016 06:15
@sultanshaik , you can use map.. the call back function takes first element of arr, in your case it's subarray.. so to return max element of subarray, use Math.max.apply(null,subarr);
Geo Galagaran
@geeofree
Mar 16 2016 06:15
no Seriously. Look I'll even print screen it.
Sultan Ahmed
@sultanshaik
Mar 16 2016 06:16
@brainyfarm it works but I don't understand the logic..how does ... give the right answer?
Olawale Akinseye
@brainyfarm
Mar 16 2016 06:16
And remember, index is a subarray so you might want to use a more descriptive name @sultanshaik .
V Arun Kumar
@arunvkumr
Mar 16 2016 06:17
@sultanshaik map fuction take 1st arg as element. and you are using the an 2d array so the elem is the subarray of array arr... and to find the max of an array you can use what @brainyfarm posted.. :point_up: March 16, 2016 11:45 AM
Sultan Ahmed
@sultanshaik
Mar 16 2016 06:17
@arunkumrv : I tried that but no answer..again a null array
Sidharth Kriplani
@sidkrip
Mar 16 2016 06:18
@brainyfarm I included all the regexps individually now but it is returning true and false for some of the cases and other inputs are incorrect. Problem is with the regexps again?
Sultan Ahmed
@sultanshaik
Mar 16 2016 06:18
@brainyfarm : What does ...before index mean?
Kyle Morton
@kmorton1988
Mar 16 2016 06:18
did anyone get a chance to look through my code I posted a bit ago?
V Arun Kumar
@arunvkumr
Mar 16 2016 06:18
@sultanshaik you have used index.. so the Math.max function would be Math.max.apply(null,index); or Math.max(...index);
Olawale Akinseye
@brainyfarm
Mar 16 2016 06:19
@sultanshaik
It is known as spread operator, check on that documentation to find out more.
@kmorton1988 ?
Hi @sidkrip
Could you share your regex ?
Sultan Ahmed
@sultanshaik
Mar 16 2016 06:20
@arunkumrv @brainyfarm Thanks a ton you ppl
CamperBot
@camperbot
Mar 16 2016 06:20
sultanshaik sends brownie points to @arunkumrv and @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1630 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
:star: 367 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Olawale Akinseye
@brainyfarm
Mar 16 2016 06:21
@da7thsin ?
Geo Galagaran
@geeofree
Mar 16 2016 06:21
I cant edit or delete messages here
Sidharth Kriplani
@sidkrip
Mar 16 2016 06:21
@brainyfarm working on it again
but atleast I know now where the problem is :D
Olawale Akinseye
@brainyfarm
Mar 16 2016 06:21
Are you serious @da7thsin ? :confused:
Good job @sidkrip !!
Geo Galagaran
@geeofree
Mar 16 2016 06:22
@brainyfarm y-yes... :worried:
Olawale Akinseye
@brainyfarm
Mar 16 2016 06:22
Oh!
Can't~
Geo Galagaran
@geeofree
Mar 16 2016 06:23
@brainyfarm no. I can't
:(
Olawale Akinseye
@brainyfarm
Mar 16 2016 06:23
@da7thsin
You can only edit if the message is not later than 10minutes from the time of posting.
Geo Galagaran
@geeofree
Mar 16 2016 06:24
another test
nope I still cant
Olawale Akinseye
@brainyfarm
Mar 16 2016 06:25
That might be a bug or something @da7thsin , maybe you should contact Gitter support.
Or try logout and login again.
Geo Galagaran
@geeofree
Mar 16 2016 06:26
@brainyfarm maybe some other time :P it's really not that big of a deal. Though it would be convenient if I could use edit/delete. But eh, I can live without those I guess :P
@brainyfarm thanks for the suggestion though :P
Olawale Akinseye
@brainyfarm
Mar 16 2016 06:27
Yes @da7thsin , if you are not me who make lots of mistakes :P
Geo Galagaran
@geeofree
Mar 16 2016 06:28
@brainyfarm haha. I probably am like you in that way :smile:
Olawale Akinseye
@brainyfarm
Mar 16 2016 06:30
LOL
Geo Galagaran
@geeofree
Mar 16 2016 06:38

question about For Loops. I'll be using what I did for the Chunky Monkey Challenge as an example:

function chunk(arr, size) {
  var daArray = [];
  var startNum = 0;
  var endNum = size;
  for(i = 0;i<arr.length/size; i++){
    startNum = size * i;
    endNum *= 1+i;
    daArray[i] = arr.slice(startNum,endNum);
  }
    return daArray;
}

chunk([0, 1, 2, 3, 4, 5, 6, 7, 8], 4);

How does a for loop handle Decimals for the condition in it? I'm just confused as to how I got the correct answer when I divided arr.length by size. o_o Can anyone explain?

Markus Kiili
@Masd925
Mar 16 2016 06:39
@da7thsin There is no problem with using floats there. If the arr.length/size is 2.5, the loop block is executed for i=0,1,2.
@da7thsin The solution is simpler if you loop to <arr.length and increment by +=size.
Geo Galagaran
@geeofree
Mar 16 2016 06:44
@Masd925 hm. Why did my daArray return an index with 1 element in it? ([[0,1,2,3],[4,5,6,7],[8]])
where did [8] come from when the other 2 indexes have 4 elements?
I can't seem to visualize it in my head.
Fatah N
@fatahn
Mar 16 2016 06:46

hello guys. Been struggling with Seek & Destroy Exercise for days now!! Finally cracked it :) with a crappy code:

function destroyer(arr) {
var args = Array.prototype.slice.call(arguments);
  var arrVal = '';
  var newArr = args[0];
  function chk(val){          //my filter function
   return val !== arrVal;    //compares with elements from 2nd arguments
  }
  for(var i = 1;i<=args.length-1;i++){
    arrVal = args[i];                    //sets arrVal to the value in the 2nd...3rd...arguments
    newArr = newArr.filter(chk);  //filters each time its compared
  }
  return newArr;

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

I would love to see how shorter you codes are? Any comments will be appreviated

Markus Kiili
@Masd925
Mar 16 2016 06:46
@da7thsin The last slice is to the end of arr.
Fatah N
@fatahn
Mar 16 2016 06:48
@da7thsin I think because you used a < operator meaning the value of your arr.length will always be less than the decimal number?
Markus Kiili
@Masd925
Mar 16 2016 06:48
@nfatah This is one standard way to do it:
function destroyer(arr) {
  var args = [];
  for (var i = 0; i < arguments.length; i++) args[i] = arguments[i];

  return arr.filter(function(val) {
    return args.indexOf(val,1)===-1;
  });
}
Geo Galagaran
@geeofree
Mar 16 2016 06:49
@Masd925 ohhh. Okay. I finally get it haha. :D thanks!
@nfatah I know that. I just couldn't get how one of the arrays from daArray returned 1 element for its index while the other had more than one. :p
CamperBot
@camperbot
Mar 16 2016 06:49
da7thsin sends brownie points to @masd925 and @nfatah :sparkles: :thumbsup: :sparkles:
:star: 1169 | @masd925 | http://www.freecodecamp.com/masd925
:star: 268 | @nfatah | http://www.freecodecamp.com/nfatah
Fatah N
@fatahn
Mar 16 2016 06:50
@da7thsin hehe
@Masd925 thanks
CamperBot
@camperbot
Mar 16 2016 06:51
nfatah sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1170 | @masd925 | http://www.freecodecamp.com/masd925
Francis
@Francis-p
Mar 16 2016 07:02
This message was deleted
Jeff Day
@realitygenerator
Mar 16 2016 07:04
I'm having trouble with syntax for switch statements. I get the errors "expected } to match { from line 1"
"expected assignment or function call and instead saw an expression"
"Missing semicolon"
Francis
@Francis-p
Mar 16 2016 07:04
@Masd925 what is function (val)
Coy Sanders
@coymeetsworld
Mar 16 2016 07:04
thats an anonymous function
Stefan Gisi
@stgisi
Mar 16 2016 07:05
Ok,ok,ok before... before the inventory update challenge I had THOUGHT that some of the tests for some of the challenges were wrong. But now, I'm on inventory update and there HAS to be a bug or something....
Jeff Day
@realitygenerator
Mar 16 2016 07:05
so I added a } to match { from line one and got "Unrecoverable syntax error 14% scanned"
Geo Galagaran
@geeofree
Mar 16 2016 07:05
@realitygenerator can you post your code here?
Jeff Day
@realitygenerator
Mar 16 2016 07:06

function myTest(val) {
var answer = "";
// Only change code below this line

case val === 1:
answer = 'alpha';
break;

case val === 2:
answer = 'beta';
break;

case val === 3:
answer = 'gamma';
break;

case val === 4:
answer = 'delta';
break;

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

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

Olawale Akinseye
@brainyfarm
Mar 16 2016 07:08
@realitygenerator
You should have something like
switch(val){
// Other stuff goes here
}
Your switch statement is missing.
Geo Galagaran
@geeofree
Mar 16 2016 07:09

@realitygenerator you didn't put a switch(expression) before the cases. Try this:
```
function myTest(val) {
var answer = "";
// Only change code below this line
switch(val){
case val === 1:
answer = 'alpha';
break;

case val === 2:
answer = 'beta';
break;

case val === 3:
answer = 'gamma';
break;

case val === 4:
answer = 'delta';
break;

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

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

woopsie
damn it I cant delete.
Olawale Akinseye
@brainyfarm
Mar 16 2016 07:09
LOL
You said it would not be a problem @da7thsin :P
Geo Galagaran
@geeofree
Mar 16 2016 07:09
@brainyfarm ughhhhhh haha :smile:
NormalWare
@Centuriom
Mar 16 2016 07:10

Hello guys, everytime i use slideToggle();
If the element display: inline, it will change to display:none
else if the element display:none, it will change to display:inline ?

That's how slideToggle(); works ??

Geo Galagaran
@geeofree
Mar 16 2016 07:10
yea. :p I got too excited and pressed enter way too fast before ending the markup :package:
Olawale Akinseye
@brainyfarm
Mar 16 2016 07:10

@realitygenerator
In addition you do not have to do

case val === 1:, just do case 1:

Jeff Day
@realitygenerator
Mar 16 2016 07:12
what is markdown?
Kyle Morton
@kmorton1988
Mar 16 2016 07:13
click the M icon next to the text entry box @realitygenerator
function destroyer(arr, a, b, c) {

  var newArray = [];

  // Remove all the values
  function removeIt(thing, num1, num2, num3) {
    for (i=0;i<arr.length;i++){
      if (num1 !== thing[i]){
        if (num2 !== thing[i])
          if (num3 !== thing[i])
            return thing[i];
      } 
     }  
    }  
 newArray = arr.filter(removeIt(arr, a, b, c));

 return newArray;
}

destroyer([1, 2, 3, 1, 2, 3],2,3);
when this is run, it returns "1 is not a function"
any ideas as to why?
Jeff Day
@realitygenerator
Mar 16 2016 07:16
thank you @brainyfarm and @da7thsin I got it
CamperBot
@camperbot
Mar 16 2016 07:16
realitygenerator sends brownie points to @brainyfarm and @da7thsin :sparkles: :thumbsup: :sparkles:
:star: 1632 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
:star: 265 | @da7thsin | http://www.freecodecamp.com/da7thsin
Francis
@Francis-p
Mar 16 2016 07:18
function destroyer(arr) {
  // Remove all the values
  var sliceArr = Array.prototype.slice.call(arguments,1);
    function destory(value) {
    return value;
    }

  var survival = arr.filter(destory(sliceArr));

return survival;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
object array is not a function! why???
Kyle Morton
@kmorton1988
Mar 16 2016 07:18
help seek and destroy
CamperBot
@camperbot
Mar 16 2016 07:18

:point_right: algorithm seek and destroy [wiki]

Explanation:

This problem is a bit tricky because you have to familiarize yourself with Arguments, as you will have to work with two or more but on the script you only see two. Many people hardcode this program for three arguments. You will remove any number from the first argument that is the same as any other other arguments.

:pencil: read more about algorithm seek and destroy on the FCC Wiki

Olawale Akinseye
@brainyfarm
Mar 16 2016 07:19
@kmorton1988
Array.prototype.slice.call(arguments) would convert argument like [1, 2, 3, 1, 2, 3],2,3 into [[1, 2, 3, 1, 2, 3],[2,3]] so it becomes easy for you to filter.
If you are trying to track all individual arguments the way you are going at it would be difficult @kmorton1988
Kyle Morton
@kmorton1988
Mar 16 2016 07:21
I guess I still am not sure where I"m going wrong.
I feel like what I"m doing Should work.
but obviously it doesn't.
Akhil
@akhilsura7
Mar 16 2016 07:22
How to Assign the contents of a to variable b?
Francis
@Francis-p
Mar 16 2016 07:22
@brainyfarm i find my destory function is a bit redundant
b = a; @akhilsura7
Akhil
@akhilsura7
Mar 16 2016 07:23
It worked @Francis-p :D thanks!
CamperBot
@camperbot
Mar 16 2016 07:23
akhilsura7 sends brownie points to @francis-p :sparkles: :thumbsup: :sparkles:
:star: 271 | @francis-p | http://www.freecodecamp.com/francis-p
Francis
@Francis-p
Mar 16 2016 07:24
@akhilsura7 no prob
Olawale Akinseye
@brainyfarm
Mar 16 2016 07:24
@Francis-p
arr.filter(destory(sliceArr)); is wrong, change to arr.filter(destory);
You do not have to pass anything into the callback.
Francis
@Francis-p
Mar 16 2016 07:25
@brainyfarm where should i put destroy(sliceArr) ?
Olawale Akinseye
@brainyfarm
Mar 16 2016 07:26
@Francis-p
You do not need to put it anywhere, remember what you are trying to do it to filter the first array and return only items not in the second array (sliceArr)
So everything is done inside your destory function.
Francis
@Francis-p
Mar 16 2016 07:29
@brainyfarm return value = sliceArr; ???
Olawale Akinseye
@brainyfarm
Mar 16 2016 07:31
@Francis-p Here is an example
// Example, filter the first array and return only items not inside the second array

var firstArr = [1,2,3,4,5,6,7];
var secondArr = [2,3,4];

function filterIt(value){
 // Return items not inside second arr
 return secondArr.indexOf(value) === -1;

}

firstArr.filter(filterIt) // [1, 5, 6, 7]
In your case @Francis-p , remember arguments[0] (The first array) is what you want to filter and you want to return items not present in sliceArr
Francis
@Francis-p
Mar 16 2016 07:34
@brainyfarm why we don’t have to define (value)?
Olawale Akinseye
@brainyfarm
Mar 16 2016 07:35
@Francis-p
value is a just placeholder variable so it is like iterating through each element in the array and they are temporarily assigned a place holder name value.
Aleksander Gębicki
@Takumar
Mar 16 2016 07:40
@Francis-p function filterIt(value){} in such case parameter value is also local variable but it is declared by JS in the background that is why you don't have to use var keyword, it is just done like that.
Francis
@Francis-p
Mar 16 2016 07:43
This message was deleted
Olawale Akinseye
@brainyfarm
Mar 16 2016 07:44
Classified Message
This message was deleted
Olawale Akinseye
@brainyfarm
Mar 16 2016 07:46
Nice so it is checking if that current item value is present 0and above or absent-1 @Francis-p
Francis
@Francis-p
Mar 16 2016 07:51
correct me if i am wrong, return secondArr.indexOf(value) === -1; is just to prove that it is -1 regardless of value?
Olawale Akinseye
@brainyfarm
Mar 16 2016 07:53
@Francis-p
It is like saying return this current item value if it is not present inside secondArr
.filter() handles that for you.
Shivaji
@psrijan
Mar 16 2016 08:03
solution to 149
mystr = "\ \t \t \r \n";
?
str = "\ \t \t \r \n "; ?
kirbyedy
@kirbyedy
Mar 16 2016 08:04
@psrijan read the instructions on the left
you need 2 backlashes
and to declare the variable
Aleksander Gębicki
@Takumar
Mar 16 2016 08:05
@psrijan var myStr = "\\ \t....
jovbe
@jovbe
Mar 16 2016 08:10

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

I have no idea how to start this "Word Blanks" challenge

We will now use our knowledge of strings to build a "Mad Libs" style word game we're calling "Word Blanks". You will create an (optionally humorous) "Fill in the Blanks" style sentence.

You will need to use string operators to build a new string, result, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb.

You will also need to provide additional strings, which will not change, in between the provided words.

We have provided a framework for testing your results with different words. The tests will run your function with several different inputs to make sure all of the provided words appear in the output, as well as your extra strings.

Can someone help?
Shivaji
@psrijan
Mar 16 2016 08:11
@kirbyedy I did add two back slashes. for some reason it didn't show in the chat
kirbyedy
@kirbyedy
Mar 16 2016 08:12
ok, than just declare your variable and try again @psrijan
Shivaji
@psrijan
Mar 16 2016 08:12
also is it necessary to go through all the basics of javascript. This is simply like C++ or Java. I've already learnt c++ , datastructures and algorithms , java and this walkthrough is a bit beginner for me
Aleksander Gębicki
@Takumar
Mar 16 2016 08:12
@jovbe create a sentence using function parameters myNoun, myAdjective... and assign it to result variable. Remember to separate words of your sentence with space. You can add your words to it using concatenation: "This is " + myNoun + ...
kirbyedy
@kirbyedy
Mar 16 2016 08:13
@psrijan its up to you, you dont have to if you dont want to :)
Shivaji
@psrijan
Mar 16 2016 08:15
@kirbyedy yea that's for sure but for the community project's later on. Also what did you do. What would you suggest?
Danny McCollins
@dmccollins
Mar 16 2016 08:15
Can some one point me in the right direction? I’m stuck on Profile Lookup. This is what I have so far…
for (var i = 0; i < contacts.length; i++) {
        if (firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
            return contacts[i][prop];
        } else if (firstName !== contacts[i].firstName) {
            return "No such value";
        } else if (prop !== contacts[i].hasOwnProperty(prop)) {
            return "No such property";
        }
    }
kirbyedy
@kirbyedy
Mar 16 2016 08:16
@psrijan I am a beginner, so everything here is new to me, and I just went through the map from the beginning
Shivaji
@psrijan
Mar 16 2016 08:16
@kirbyedy cool
@kirbyedy which section are you currently at?
kirbyedy
@kirbyedy
Mar 16 2016 08:16
once you get to the projects, you will have to research anyway, because those small challenges wont cover the knowledge you need
I am stuck at the TicTacToe game
Shivaji
@psrijan
Mar 16 2016 08:17
@kirbyedy oh great you are way ahead of me
@kirbyedy i wanted someone to review my personal profile challenge. Are you interested?
kirbyedy
@kirbyedy
Mar 16 2016 08:18
doesn`t mean a thing... I am still lost like a donkey in a fog :D
sometimes so confused :)
sure thing
Shivaji
@psrijan
Mar 16 2016 08:20
http://codepen.io/shivji/pen/EKgPYP
@kirbyedy be all honest here. I am really open to criticism. Also, I'm only partially done. Not the final version.
kirbyedy
@kirbyedy
Mar 16 2016 08:23
@psrijan you have to adjust the margins and paddings, so that the text and the spongebob picture does not stick to the window edge
also your navbar does not collapse to the burger menu
personally I think this background images are very distracting, so its hard to read the text
jovbe
@jovbe
Mar 16 2016 08:25
Thanks @Takumar got it!
CamperBot
@camperbot
Mar 16 2016 08:25
jovbe sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 2743 | @takumar | http://www.freecodecamp.com/takumar
Shivaji
@psrijan
Mar 16 2016 08:27
@kirbyedy thanks :) Also your calculator is fab. ciao
CamperBot
@camperbot
Mar 16 2016 08:27
psrijan sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 663 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
kirbyedy
@kirbyedy
Mar 16 2016 08:28
@psrijan thanks
CamperBot
@camperbot
Mar 16 2016 08:28
kirbyedy sends brownie points to @psrijan :sparkles: :thumbsup: :sparkles:
:star: 154 | @psrijan | http://www.freecodecamp.com/psrijan
negyvenketto
@negyvenketto
Mar 16 2016 08:41
@dmccollins you need to take the "No such property" out of your loop. you only want to return that after checking for every i.
jayhomz
@jayhomz
Mar 16 2016 08:42
Need help with this, Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
// Setup
function abTest(a, b) {
  // Only change code below this line

  if (a < 0 && b < 0) { return "undefined";}

  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
J Player
@Heyjp
Mar 16 2016 08:44
@jayhomz if its either or, then using || in your if statement instead of && might work
|| being or btw
jayhomz
@jayhomz
Mar 16 2016 08:45
@Heyjp i tried that first but it didn't work
David Alexis
@r0nind
Mar 16 2016 08:45

Greetings All. Ran into a stump. In the "Nesting for Loops" Module, I was not able to get a satisfactory result. Here's my code
```js
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i < arr.length; i++) {
for (var yo = 0; yo < arr[i].length; yo++) {
return product * arr[i][yo];
}
}
// Only change code above this line
return product;
}

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

```js

Coy Sanders
@coymeetsworld
Mar 16 2016 08:46
@jayhomz did you try return undefined, no quotes?
"undefined" is a string
although im not sure what campfire this is just wondering
negyvenketto
@negyvenketto
Mar 16 2016 08:46
@jayhomz i agree with @Heyjp about the ||. also, if the value has to be undefined, then try to write if (a < 0 || b < 0) { return;}
Coy Sanders
@coymeetsworld
Mar 16 2016 08:47
yeah and the || needs to be there for sure
negyvenketto
@negyvenketto
Mar 16 2016 08:47
because that way you are literally returning an undefined value