These are chat archives for FreeCodeCamp/HelpJavaScript

3rd
Mar 2017
HeebieGeeBee
@HeebieGeeBee
Mar 03 2017 00:00
@forkerino whats the includes do?
mitron6
@mitron6
Mar 03 2017 00:00
@forkerino includes(3) is es6?
Pieter Stokkink
@forkerino
Mar 03 2017 00:00
checks to see if the array includes e. Might be ES7
ES2016
Mac
@itchick85
Mar 03 2017 00:00
Compound Assignment With Augmented Addition var +=15; 3 + 12
var +=26; 9 + 17
var +=19; 12+ 7
What's wrong with this?
Moisés Man
@moigithub
Mar 03 2017 00:00
[1,2,3].includes(2) // true
[1,2,3].includes(666) // false
@HeebieGeeBee
mitron6
@mitron6
Mar 03 2017 00:01
There is a polyfill for includes. It is not supported on all platforms.
HeebieGeeBee
@HeebieGeeBee
Mar 03 2017 00:01
@moigithub @forkerino @mitron6 cool thanks
CamperBot
@camperbot
Mar 03 2017 00:01
heebiegeebee sends brownie points to @moigithub and @forkerino and @mitron6 :sparkles: :thumbsup: :sparkles:
:cookie: 545 | @mitron6 |http://www.freecodecamp.com/mitron6
:star2: 1318 | @forkerino |http://www.freecodecamp.com/forkerino
:star2: 2775 | @moigithub |http://www.freecodecamp.com/moigithub
Pieter Stokkink
@forkerino
Mar 03 2017 00:02
@HeebieGeeBee yeah, IE doesn't do .includes()
Adam
@GoingAllTheWayUp
Mar 03 2017 00:02

@forkerino ok that I understand that now, but I didn't totaly get the function I found online that would solve this issue. The advanced code solution on this page

function isConsonant(char) {
        return !/[aeiou]/.test(char);
    }

I originaly, if you recall, used two if statments to solve this challenge, but wish to learn this better solution. So if I understand correctly .test() returns true or false and while this function (isConsonant) returns true it does my .push() and .shift(). Im just getting a hang of these return statments and how to use them correctly.

mitron6
@mitron6
Mar 03 2017 00:02
I'm currently reviewing beta.freecodecamp.com but it's a little boring since there are not that many problems.
HeebieGeeBee
@HeebieGeeBee
Mar 03 2017 00:02
@forkerino well you know my feelings about ie users
Jason Luboff
@JLuboff
Mar 03 2017 00:03
@HeebieGeeBee You love it and its all you use?
HeebieGeeBee
@HeebieGeeBee
Mar 03 2017 00:03
lol
Pieter Stokkink
@forkerino
Mar 03 2017 00:03
@HeebieGeeBee :D
Jason Luboff
@JLuboff
Mar 03 2017 00:04
Edge actually isn't too bad. I use it/bing for all my web searches (due to getting Microsoft points)
HeebieGeeBee
@HeebieGeeBee
Mar 03 2017 00:05
theyre paying ppl to use it now?
Pieter Stokkink
@forkerino
Mar 03 2017 00:05
@JLuboff Edge supports .includes(), so we're good there.
thunderbuns
@thunderbuns
Mar 03 2017 00:06

function testSize(num) {
// Only change code below this line
if (num < 5)
{
return "tiny";
}
else if (num 10)
{
return "small"
}
else if (num < 15)
{
return "medium";
}
else if (num < 20)
{
return "huge";
}
else (num >= 20)
{
return "huge";
}
return "Change Me";
// Only change code above this line
}

// Change this value to test
testSize(7);
what is wrong with my "if else" statements?

Jason Luboff
@JLuboff
Mar 03 2017 00:06
@HeebieGeeBee Eh...its been an ongoing program for a while now, but changed names a couple times I believe (I know for sure it used to be Bing rewards). Once I hit 29,000 points, I get a year of Xbox Live for free..so I'm all for it
Pieter Stokkink
@forkerino
Mar 03 2017 00:06
@GoingAllTheWayUp I don't like that advanced solution one bit. :)
Jason Luboff
@JLuboff
Mar 03 2017 00:06
@forkerino Ya, it seems to behave in some manners similar to Chrome (like not liking non-secure Geolocation)
@thunderbuns num 10?
eyesore-
@eyesore-
Mar 03 2017 00:07
@thunderbuns else doesn't need ( ) just else { }
Also what @JLuboff said
You need to do some sort of evaluation there.
Pieter Stokkink
@forkerino
Mar 03 2017 00:09
@GoingAllTheWayUp but yeah, this function returns true for consonants.
HeebieGeeBee
@HeebieGeeBee
Mar 03 2017 00:10
@JLuboff fair enough
Adam
@GoingAllTheWayUp
Mar 03 2017 00:11
@forkerino How would you overcome useing two if statments like I orginal thought in my head, and do something nicer?
HeebieGeeBee
@HeebieGeeBee
Mar 03 2017 00:11
@JLuboff but still no extensions for edge?
Pieter Stokkink
@forkerino
Mar 03 2017 00:11
@GoingAllTheWayUp I'll pm you.
Mac
@itchick85
Mar 03 2017 00:12
im suck
eyesore-
@eyesore-
Mar 03 2017 00:12
@itchick85 what is it?
Jason Luboff
@JLuboff
Mar 03 2017 00:13
@HeebieGeeBee Not sure...I don't really use extensions for any browser :(
Tam Nguyen
@tam-nguyen
Mar 03 2017 00:13
I need to use 1 loop for it
Mac
@itchick85
Mar 03 2017 00:13
@eyesore- Compound Assignment With Augmented Addition var +=15; 3 + 12
var +=26; 9 + 17
var +=19; 12+ 7 whats wrong with this
Tam Nguyen
@tam-nguyen
Mar 03 2017 00:14
currently I use 2 for loops
the requirement is only 1
eyesore-
@eyesore-
Mar 03 2017 00:15

@itchick85

//change
a = a + 12;
b = 9 + b;
c = c + 7;

to equal what it tells you.

Tam Nguyen
@tam-nguyen
Mar 03 2017 00:16
// For a = [1, 2, 3], b = [10, 20, 30, 40], and v = 42, the output should be sumOfTwo(a, b, v) = true.
// I used 2 for loops
// request it should be 1 loop
function sumOfTwo(a, b, v) {
var i , j;
for( i = 0 ; i < a.length; i++){
for( j = 0 ; j < b.length; j++) {
if(a[i] + b[j] == v){
return true;
}
}
}
return false;
}
console.log(sumOfTwo([1,2,3],[10,20,30,40],42));
eyesore-
@eyesore-
Mar 03 2017 00:16
@tam-nguyen If no one else gets to you I'll help you out in a bit.
Pieter Stokkink
@forkerino
Mar 03 2017 00:16
@tam-nguyen you can use .indexOf to your advantage. Check if the difference between the current value of the first array and the sum is in the other array
Tam Nguyen
@tam-nguyen
Mar 03 2017 00:16
dont know how to post the code with Black background
thunderbuns
@thunderbuns
Mar 03 2017 00:16

function testSize(num) {
// Only change code below this line
if (num < 5)
{
return "tiny";
}
else if (num < 10)
{
return "small";
}
else if (num < 15)
{
return "medium";
}
else if (num >= 20)
{
return "large";
}
else
{
return "huge";
}
// Only change code above this line
}

// Change this value to test
testSize(17); It still won't let me pass the lesson

eyesore-
@eyesore-
Mar 03 2017 00:16
@itchick85 so for example you need to make a 15 so you can do a = b + 12
Jason Luboff
@JLuboff
Mar 03 2017 00:17
@thunderbuns Do your strings match what FCC has?
@thunderbuns I just checked..you're strings dont match. The strings are case sensitive
Tam Nguyen
@tam-nguyen
Mar 03 2017 00:18
@eyesore- @forkerino time complexity should be O(n) or O(logn)
thunderbuns
@thunderbuns
Mar 03 2017 00:18
function testSize(num) {
// Only change code below this line
if (num < 5)
{
return "tiny";
}
else if (num < 10)
{
return "small";
}
else if (num < 15)
{
return "medium";
}
else if (num < 20)
{
return "large";
}
else if (num >= 20)
{
return "huge";
}
// Only change code above this line
}
// Change this value to test
testSize(17); @JLuboff they match now
Jason Luboff
@JLuboff
Mar 03 2017 00:19
@thunderbuns No they dont
AJ
@DracIdea
Mar 03 2017 00:19
@moigithub How would I go about "getting" the object from the array?
Jason Luboff
@JLuboff
Mar 03 2017 00:19
@thunderbuns tiny is not the same as Tiny
thunderbuns
@thunderbuns
Mar 03 2017 00:20
well I did not see that thanks @JLuboff
CamperBot
@camperbot
Mar 03 2017 00:20
thunderbuns sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1014 | @jluboff |http://www.freecodecamp.com/jluboff
Arslan
@arslanwd
Mar 03 2017 00:20
Guys
can anyone help me with my css issue
@arslanwd
I need help
http://www.14042290.webdevmmu.uk/2/courses.html
i am trying to keep the image behind Courses
same
how can i keep the shape in position
anyone here?
Pieter Stokkink
@forkerino
Mar 03 2017 00:21
@tam-nguyen I gave you a huge hint above. Maybe try to work with that?
Mac
@itchick85
Mar 03 2017 00:21
@eyesore- I did that but it says You should use the += operator for each variable everything else is right
eyesore-
@eyesore-
Mar 03 2017 00:23
@itchick85 cool. Just to make sure do you understand the += operator?
Arslan
@arslanwd
Mar 03 2017 00:24
Can anyone please help me :worried:
Mac
@itchick85
Mar 03 2017 00:26
@eyesore- I understand the use for it but when I put it in the code like its explained it says its wrong
Pieter Stokkink
@forkerino
Mar 03 2017 00:26
@itchick85 show your code!
Mac
@itchick85
Mar 03 2017 00:27
@forkerino
var +=15; 3 + 12
var +=26; 9 + 17
var +=19; 12+ 7
eyesore-
@eyesore-
Mar 03 2017 00:27
@itchick85 so we already have var a = 3 if you were to do a = 12 then you are re-assigning a to 12 but += will use the old value added by the new value and apply the sum to a
Pieter Stokkink
@forkerino
Mar 03 2017 00:27
@itchick85 yeah, you need variable names between var and +=
Arslan
@arslanwd
Mar 03 2017 00:27
Thats insane. No one is helping :clap:
Pieter Stokkink
@forkerino
Mar 03 2017 00:28
@itchick85 also remove stuff after the ;
eyesore-
@eyesore-
Mar 03 2017 00:28
@forkerino she doesn't because the variables are already defined before.
Jason Luboff
@JLuboff
Mar 03 2017 00:28
@arslanwd Keep in mind this is the Javascript room, not frontend. You may want to try there
eyesore-
@eyesore-
Mar 03 2017 00:29
@forkerino she needs to get rid of var and just use the variable name
Pieter Stokkink
@forkerino
Mar 03 2017 00:29
@eyesore- yeah, true.
Tam Nguyen
@tam-nguyen
Mar 03 2017 00:29

@forkerino it is still exceeded Time Limit. Is there any better way?

function sumOfTwo(a, b, v) {
for(var i = 0; i<a.length;i++){ if(b.indexOf(v-a[i]) >= 0){
return true;
}
}
return false;
}
console.log(sumOfTwo([1,2,3],[10,20,30,40],42));

eyesore-
@eyesore-
Mar 03 2017 00:30
@forkerino @tam-nguyen .indexOf uses a loop within it.
Pieter Stokkink
@forkerino
Mar 03 2017 00:30
@itchick85 so replace var with your variable names as @eyesore- suggests.
Tam Nguyen
@tam-nguyen
Mar 03 2017 00:30
function sumOfTwo(a, b, v) {
  for(var i = 0; i<a.length;i++){
      if(b.indexOf(v-a[i]) >= 0){
          return true;
      }
  }
  return false;
}
console.log(sumOfTwo([1,2,3],[10,20,30,40],42));
Pieter Stokkink
@forkerino
Mar 03 2017 00:31
@tam-nguyen can you give the description of the problem?
in short?
i.e. the question they ask?
Tam Nguyen
@tam-nguyen
Mar 03 2017 00:32

For a = [1, 2, 3], b = [10, 20, 30, 40], and v = 42, the output should be sumOfTwo(a, b, v) = true.

Input/Output

[time limit] 4000ms (js)

@forkerino considering the time efficiency :(
@eyesore- not sure how to do it :)
Pieter Stokkink
@forkerino
Mar 03 2017 00:33
I'm thinking now to concatenate the two arrays... @tam-nguyen
eyesore-
@eyesore-
Mar 03 2017 00:34
@forkerino Are you understanding the prompt? I'm not sure really what it is asking.
Tam Nguyen
@tam-nguyen
Mar 03 2017 00:35
@forkerino the problem description: You have two integer arrays, a and b, and an integer target value v. Determine whether there is a pair of numbers, where one number is taken from a and the other from b, that can be added together to get a sum of v. Return true if such a pair exists, otherwise return false.
BryantWood
@BryantWood
Mar 03 2017 00:35

function palindrome(str) {
var strfoward;
var strbackward;

str = str.toLowerCase();
var letters = /[a-z]/gi;
var arr = str.match(letters);

strfoward = arr;
strbackward = arr.reverse();

strbackward = strbackward.join('');

strfoward = strfoward.join('');

if (strfoward === strbackward){
return true;
}
return false;
}\
palindrome("not a palindrome");

lazylizard12
@lazylizard12
Mar 03 2017 00:35
@forkerino I got rid of the underscore, it still seems to work, but its not quite right.
BryantWood
@BryantWood
Mar 03 2017 00:36
can somone take a look and tell me why this only returns true?
Pieter Stokkink
@forkerino
Mar 03 2017 00:36
@BryantWood .reverse() reverses in place. so it will change arr and therefore strforward
@lazylizard12 show your code again please!
lazylizard12
@lazylizard12
Mar 03 2017 00:37
function palindrome(str) {
var lower = str.toLowerCase("");
var none = /[\W_]/g;
var none2 = lower.replace(none, "");
var split = none2.split("");
var reverse = split.reverse();
var end = reverse.join("");
if (none2 === end){
return "true";
}else;{
return "false";
}
}
Miguel-Castrejon
@Miguel-Castrejon
Mar 03 2017 00:37
Here's this code... I cant seem to make it work with NaN values since it thinks is null... any ideas?
function bouncer(arr) {
  var newArray = arr.filter(isFalsy);
  //return arr;
  return newArray;
}

function isFalsy(val){

  switch(val){
    case "NaN":
      return false;
    case null:
      return false;
    case "":
      return false;
    case 0:
      return false;
    case undefined:
      return false;
    case false:
      return false;
    default:
      return true;
  }
}

bouncer([1, null, NaN, 2, undefined]);
Pieter Stokkink
@forkerino
Mar 03 2017 00:39
@lazylizard12 you have to return booleans, not strings. Also: .toLowerCase() doesn't take an argument.
@tam-nguyen that's a tough one. If that current code is too slow, I'm not sure how to proceed. Will have to think it over for some time...
Tam Nguyen
@tam-nguyen
Mar 03 2017 00:40
@eyesore- any idea?
john94
@lpy1994
Mar 03 2017 00:40
folks
function updateInventory(arr1, arr2) {


  function compare(a,b){
    if(a[1] < b[1]) return -1;
    if(a[1] > b[1]) return 1;
    return 0;
  }

  var itemFromArr1 = [];
    // All inventory must be accounted for or you're fired!

  for(var i = 0; i < arr1.length, i < arr2.length; i++){

    itemFromArr1.push(arr1[i][1]);
 }


  for(var j = 0; j < arr2.length; j++){
        if (itemFromArr1.includes(arr2[j][1])) {
          arr1.forEach(function(item){
            if(item.indexOf(arr2[j][1]) > -1){
              item[0] += arr2[j][0];
            }
          });
        } else {
          arr1.push(arr2[j]);
        // add the item with its quantity from arr2
        } 
      }

  return arr1.sort(compare);

}
// Example inventory lists
var curInv = [
    [21, "Bowling Ball"],
    [2, "Dirty Sock"],
    [1, "Hair Pin"],
    [5, "Microphone"]
];

var newInv = [
    [2, "Hair Pin"],
    [3, "Half-Eaten Apple"],
    [67, "Bowling Ball"],
    [7, "Toothpaste"]
];

updateInventory(curInv, newInv);
BryantWood
@BryantWood
Mar 03 2017 00:40
@forkerino strbackward is correct and strfoward are correct which is what I am comparing.
john94
@lpy1994
Mar 03 2017 00:40
can’t pass when arr1 is empty
BryantWood
@BryantWood
Mar 03 2017 00:41
why would it matter if arr is changed?
Tam Nguyen
@tam-nguyen
Mar 03 2017 00:41
Thanks @forkerino
eyesore-
@eyesore-
Mar 03 2017 00:41
@tam-nguyen Do you have a link or something where I can see the prompt and tests?
CamperBot
@camperbot
Mar 03 2017 00:41
tam-nguyen sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1319 | @forkerino |http://www.freecodecamp.com/forkerino
eyesore-
@eyesore-
Mar 03 2017 00:41
I'm drawing a blank right now.
Pieter Stokkink
@forkerino
Mar 03 2017 00:41
@BryantWood strforward is the same as arr. change arr, you change strforward
john94
@lpy1994
Mar 03 2017 00:41
what kind of condition do i need for arr1??
BryantWood
@BryantWood
Mar 03 2017 00:45
@forkerino so can i create a var = to arr and then reverse that var and set it equal to strbackward?
AJ
@DracIdea
Mar 03 2017 00:46

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

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

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

     return contacts[x][prop];

   }

  else {

    return "No such property";
  }  


   }
This passes a couple of the tests, but not all. Any ideas?
eyesore-
@eyesore-
Mar 03 2017 00:47
@tam-nguyen have you tried includes?
Jason Luboff
@JLuboff
Mar 03 2017 00:47
@forkerino Looks like C9 does use Virtual Machines. They're running Ubuntu
Tam Nguyen
@tam-nguyen
Mar 03 2017 00:48
@eyesore- not yet let me try it
beksil
@beksil
Mar 03 2017 00:48
why Manipulte

Why Manipulate arrays with push not working var myArray = [["John", 23], ["cat", 2]];

// Only change code below this line.

myArray.push = (["dog", 3]);

BryantWood
@BryantWood
Mar 03 2017 00:49
@DracIdea you need to return "No such contact" if the firstName isnt in the array.
Jason Luboff
@JLuboff
Mar 03 2017 00:50
@beksil No =
Tam Nguyen
@tam-nguyen
Mar 03 2017 00:51
@eyesore- the same, it is worse than indexOf
function sumOfTwo(a, b, v) {
  for(var i = 0; i < a.length; i++){
      if(b.includes(v-a[i]) ){
          return true;
      }
  }
  return false;
}
beksil
@beksil
Mar 03 2017 00:51
@JLuboff Thanks.
CamperBot
@camperbot
Mar 03 2017 00:51
beksil sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1017 | @jluboff |http://www.freecodecamp.com/jluboff
John Nunns
@johnnunns
Mar 03 2017 00:51
function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  var splitString = str.split(' ');

  if(splitString.length === 1){
  if(str.substr(-1)===target){
    return true;
  }else{
    return false;
  }
  }else {
   if(){
     return true;
   }else{
     return false;
   }

  }
}

confirmEnding("Bastian", "n");
any advice on this equality test?
wait I may have it
Pieter Stokkink
@forkerino
Mar 03 2017 00:52
@BryantWood compare the string you had with the same string reversed. It might be easier to use a .replace, so that you keep a string instead of an arr to begin with. Saves some steps.
eyesore-
@eyesore-
Mar 03 2017 00:52
@tam-nguyen .includes is faster than .indexOf. Let me look back at it.
John Nunns
@johnnunns
Mar 03 2017 00:53
yeap got overcomplicated
Thiago Cruz
@thy705
Mar 03 2017 00:53

hey guys!

function slasher(arr, howMany) {
  // it doesn't always pay to be first

  var headsOff = arr.splice(howMany, howMany);

  if(howMany === 0){

    return arr.slice();
  }


  if (howMany === 1){

    return arr.slice(howMany,howMany);

  }

  return headsOff;
}

slasher(["burgers", "fries", "shake"], 1);

Why doesn't it return "fries", "shake"?

John Nunns
@johnnunns
Mar 03 2017 00:53

function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  var splitString = str.split(' ');


  if(str.substr(-(target.length))===target){
    return true;
  }else{
    return false;
  }



}

confirmEnding("Bastian", "n");
Miguel-Castrejon
@Miguel-Castrejon
Mar 03 2017 00:54
Could anyone help me on this on?
function bouncer(arr) {
  var newArray = arr.filter(isFalsy);
  //return arr;
  return newArray;
}

function isFalsy(val){

  switch(val){
    case "NaN":
      return false;
    case null:
      return false;
    case "":
      return false;
    case 0:
      return false;
    case undefined:
      return false;
    case false:
      return false;
    default:
      return true;
  }
}

bouncer([1, null, NaN, 2, undefined]);
Pieter Stokkink
@forkerino
Mar 03 2017 00:55
@johnnunns make it one line!
Miguel-Castrejon
@Miguel-Castrejon
Mar 03 2017 00:55
Nan is being evaluated as null... :/ so it doesnt get rid of it..
AJ
@DracIdea
Mar 03 2017 00:55
@BryantWood OK, just need to figure out how to do this. I'll try a few things....
Pieter Stokkink
@forkerino
Mar 03 2017 00:55
@Miguel-Castrejon that is because NaN == NaN is false in JS
Tam Nguyen
@tam-nguyen
Mar 03 2017 00:55
@eyesore- when we use .includes or .indexOf the time complexity will be O(n^2)
that's the problem
Pieter Stokkink
@forkerino
Mar 03 2017 00:56
@Miguel-Castrejon I recommend not using a switch. Try the Boolean function (read the docs). If you want to use an if/else, you can make it work, there is a special function to detect NaN
Jason Luboff
@JLuboff
Mar 03 2017 00:56
@forkerino Staying up late tonight?
Pieter Stokkink
@forkerino
Mar 03 2017 00:56
@JLuboff apparently
I should probably go to sleep
eyesore-
@eyesore-
Mar 03 2017 00:57
@tam-nguyen yeah, I agree. Do you know how to traverse a binary tree? That will change it to log(n)
Tam Nguyen
@tam-nguyen
Mar 03 2017 00:57
@eyesore- unfortunately I don't :(
Jason Luboff
@JLuboff
Mar 03 2017 00:57
@forkerino Eh...who needs sleep right?
Tam Nguyen
@tam-nguyen
Mar 03 2017 00:57
@eyesore- log(n) will solve the problem
Pieter Stokkink
@forkerino
Mar 03 2017 00:58
Eversince you mentioned it I started yawning, @JLuboff
Steven Stinson
@rufusBot
Mar 03 2017 00:58
How am I supposed to use /n and /r to make 1 string into 3 lines?
Pieter Stokkink
@forkerino
Mar 03 2017 00:58
@rufusBot try \n and \r
Adam
@GoingAllTheWayUp
Mar 03 2017 00:58
https://www.freecodecamp.com/challenges/missing-letters
would you go about makeing an array of the alphabet for this one or do you think there is a better solution
Johnny
@JohnnyBizzel
Mar 03 2017 00:58
@Miguel-Castrejon also, switch/ case usually needs break statements
https://www.w3schools.com/js/js_switch.asp
Jason Luboff
@JLuboff
Mar 03 2017 00:58
@forkerino Hahahaha Sorry bud. Which on that note...time to head home
John Nunns
@johnnunns
Mar 03 2017 00:58
@forkerino
str.substr(-(target.length))===target ? true: false;
Tam Nguyen
@tam-nguyen
Mar 03 2017 00:59
@eyesore- could you implement it for me?
John Nunns
@johnnunns
Mar 03 2017 00:59
what's wrong with this?
Jason Luboff
@JLuboff
Mar 03 2017 00:59
@johnnunns Just use return infront of your str.substr...
Pieter Stokkink
@forkerino
Mar 03 2017 00:59
@johnnunns I don't see a return?
John Nunns
@johnnunns
Mar 03 2017 00:59
gotcha!
Pieter Stokkink
@forkerino
Mar 03 2017 00:59
and you can leave out the ? true : false;
Nick DiMoro
@ekleinem
Mar 03 2017 00:59
```
John Nunns
@johnnunns
Mar 03 2017 00:59
thanks @forkerino @JLuboff
CamperBot
@camperbot
Mar 03 2017 00:59
johnnunns sends brownie points to @forkerino and @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1018 | @jluboff |http://www.freecodecamp.com/jluboff
:star2: 1320 | @forkerino |http://www.freecodecamp.com/forkerino
eyesore-
@eyesore-
Mar 03 2017 00:59
@tam-nguyen So basically you make sure the array is sorted then check if the middle value is less than or equal to what you need. That way every time it traverses it checks half of what it would previously.
Nick DiMoro
@ekleinem
Mar 03 2017 01:00
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");
Johnny
@JohnnyBizzel
Mar 03 2017 01:00
@GoingAllTheWayUp I used charCodeAt and looped through the string
Nick DiMoro
@ekleinem
Mar 03 2017 01:00
can someone explain how to do this?
Jeff
@Garanimal
Mar 03 2017 01:00
hey all Just curious if i am on the right track for the Contact Lookup challenge, or if I should scrap and start over
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

for (var i=0; i<contacts.length; i++) {
 if (contacts[i].firstName==firstName) {
  if (contacts[i].prop==prop){
    var contact=prop;
    return contact;
  } else {
    return "No such property";
  }
 }
 else {
     return "No such contact";
 } 

}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Steven Stinson
@rufusBot
Mar 03 2017 01:00
I'm at the lesson where it explains escaping with all sorts of things but I don't understand what it wants me to do with /r and /n.
Johnny
@JohnnyBizzel
Mar 03 2017 01:00
@Garanimal if (contacts[i].prop==prop){ :x:
@rufusBot Read the instructions
Jeff
@Garanimal
Mar 03 2017 01:01
@JohnnyBizzel thats what I thought, im trying to figure a way around that little wrinkle since none of the objects have a property called prop
Miguel-Castrejon
@Miguel-Castrejon
Mar 03 2017 01:01
@forkerino Alright, thanks. :)
CamperBot
@camperbot
Mar 03 2017 01:01
miguel-castrejon sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1321 | @forkerino |http://www.freecodecamp.com/forkerino
Jeff
@Garanimal
Mar 03 2017 01:01
@JohnnyBizzel is that my issue there?
Johnny
@JohnnyBizzel
Mar 03 2017 01:02
@ekleinem function at the bottom is passing arguments to the declared function - which uses parameters scope level variables
Adam
@GoingAllTheWayUp
Mar 03 2017 01:02
@JohnnyBizzel well you would get a code instead of a letter so i don't see how I would not still need some kind of alphabet array, can you eleberate?
Johnny
@JohnnyBizzel
Mar 03 2017 01:02
@GoingAllTheWayUp do you know hasOwnProperty()?
Steven Stinson
@rufusBot
Mar 03 2017 01:02
The instructions are not even remotely clear.
Nick DiMoro
@ekleinem
Mar 03 2017 01:02
how do I turn it into a complete sentence string
Steven Stinson
@rufusBot
Mar 03 2017 01:02

Instructions
Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine
\SecondLine\
ThirdLine
You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

Johnny
@JohnnyBizzel
Mar 03 2017 01:02
@rufusBot copy paste them
Pieter Stokkink
@forkerino
Mar 03 2017 01:03
@GoingAllTheWayUp the charCodes of the alphabet are in order. So you just need to find the missing one.
Jeff
@Garanimal
Mar 03 2017 01:03
@JohnnyBizzel I had been using that. I will go back at it with the hasOwnProperty, I thought that might come into play. Thanks
CamperBot
@camperbot
Mar 03 2017 01:03
garanimal sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1400 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Tam Nguyen
@tam-nguyen
Mar 03 2017 01:03
thanks @eyesore- , what about traverse a binary tree, i'd like to see how implement it. could you help me?
CamperBot
@camperbot
Mar 03 2017 01:03
tam-nguyen sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 61 | @eyesore- |http://www.freecodecamp.com/eyesore-
Johnny
@JohnnyBizzel
Mar 03 2017 01:03
@rufusBot this might help - see about half way down... https://www.w3schools.com/js/js_strings.asp
@Garanimal :+1:
Pieter Stokkink
@forkerino
Mar 03 2017 01:04
OK @JLuboff thanks for reminding me. I'm off to bed.
CamperBot
@camperbot
Mar 03 2017 01:04
forkerino sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1019 | @jluboff |http://www.freecodecamp.com/jluboff
Pieter Stokkink
@forkerino
Mar 03 2017 01:04
Night night people.
Adam
@GoingAllTheWayUp
Mar 03 2017 01:05
Yes, I belive it checks an arrays properties and returns true/false if its argument is contained @JohnnyBizzel
@forkerino i see said the blind man
Night
Johnny
@JohnnyBizzel
Mar 03 2017 01:05
@forkerino Slaap lekker
Keerthiikeerthika
@Keerthiikeerthika
Mar 03 2017 01:05
Hi guys Am new to codecamp.. i wanna learn JS
eyesore-
@eyesore-
Mar 03 2017 01:05
@tam-nguyen It's a little involved. Here is a post about it though https://tylerreckart.com/journal/writing-a-binary-search-algorithm-in-javascript
Johnny
@JohnnyBizzel
Mar 03 2017 01:07
@Keerthiikeerthika welcome
Christopher Earle
@chrise61793
Mar 03 2017 01:07

Heya, everyone. Just started java script. I am instructed to:
"Assign the value 7 to variable a.

Assign the contents of a to variable b"

I have:
var a = 7;
var b = 7;

It says "a should be assigned to b with =" but i can't figure it out

any help?
Johnny
@JohnnyBizzel
Mar 03 2017 01:08
@chrise61793 what is your best guess?
Tam Nguyen
@tam-nguyen
Mar 03 2017 01:08
@eyesore- thank you
CamperBot
@camperbot
Mar 03 2017 01:08
tam-nguyen sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:warning: tam-nguyen already gave eyesore- points
Christopher Earle
@chrise61793
Mar 03 2017 01:08
@JohnnyBizzel var a = var b;
but it won't let me
eyesore-
@eyesore-
Mar 03 2017 01:08
@tam-nguyen no problem.
Johnny
@JohnnyBizzel
Mar 03 2017 01:08
@chrise61793 that's declaring a variable. Different to assigning variables.
eyesore-
@eyesore-
Mar 03 2017 01:08
@chrise61793 You use var to assign a variable.
Declaring* whooops
Johnny
@JohnnyBizzel
Mar 03 2017 01:09
You use var to assign a variable.
Thiago Cruz
@thy705
Mar 03 2017 01:09

function slasher(arr, howMany) {
  // it doesn't always pay to be first

  var headsOff = arr.splice(howMany, howMany);

  if(howMany === 0){

    return arr.slice();
  }


  if (howMany === 1){

    return arr.reverse().splice(0,2);

  }

  return headsOff;
}

slasher(["burgers", "fries", "shake"], 1);
Christopher Earle
@chrise61793
Mar 03 2017 01:09
@JohnnyBizzel I don't understand how to assign the contents of a to variable b
eyesore-
@eyesore-
Mar 03 2017 01:09
@chrise61793 Once you declare it there is no need to use var anymore
Christopher Earle
@chrise61793
Mar 03 2017 01:10
@eyesore- so i can just type var b = a;
?
Johnny
@JohnnyBizzel
Mar 03 2017 01:10
@chrise61793 Seriously?
eyesore-
@eyesore-
Mar 03 2017 01:10
Yes
Christopher Earle
@chrise61793
Mar 03 2017 01:10
@JohnnyBizzel Yeah, it's literally the 3rd java script lesson for freecodecamp.
Jeff
@Garanimal
Mar 03 2017 01:10
haha
Johnny
@JohnnyBizzel
Mar 03 2017 01:10
Thiago Cruz
@thy705
Mar 03 2017 01:11
All the tests are passing, but the last anyone know why?
Allan Oloo
@OlooAllaN
Mar 03 2017 01:11
Does anyone here know how to design a entity relation diagram for a database?
Thiago Cruz
@thy705
Mar 03 2017 01:11

function slasher(arr, howMany) {
  // it doesn't always pay to be first

  var headsOff = arr.splice(howMany, howMany);

  if(howMany === 0){

    return arr.slice();
  }


  if (howMany === 1){

    return arr.reverse().splice(0,2);

  }

  return headsOff;
}

slasher(["burgers", "fries", "shake"], 1);
Johnny
@JohnnyBizzel
Mar 03 2017 01:11
@thy705 I forget what slice and splice do. Can you tell me?
Christopher Earle
@chrise61793
Mar 03 2017 01:11
@eyesore- Word, it worked. Thanks.
CamperBot
@camperbot
Mar 03 2017 01:11
chrise61793 sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 62 | @eyesore- |http://www.freecodecamp.com/eyesore-
John Nunns
@johnnunns
Mar 03 2017 01:11
return str.length>num && str.length>3 ? str.slice(0,num-3)+"...": str.slice(0,num)+'...' :str;
@forkerino so how do I phrase an else if statement
Christopher Earle
@chrise61793
Mar 03 2017 01:11
@JohnnyBizzel I shall, thank you.
CamperBot
@camperbot
Mar 03 2017 01:11
chrise61793 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1401 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Mar 03 2017 01:12
@chrise61793 my pleasure. Thanks for the visit.
CamperBot
@camperbot
Mar 03 2017 01:12
:cookie: 123 | @chrise61793 |http://www.freecodecamp.com/chrise61793
johnnybizzel sends brownie points to @chrise61793 :sparkles: :thumbsup: :sparkles:
Thiago Cruz
@thy705
Mar 03 2017 01:12
@JohnnyBizzel they seem to do almost the same thing. the difference I guess is that splice gives coordinates
eyesore-
@eyesore-
Mar 03 2017 01:12
@chrise61793 no problem. If you have a hard time understanding something make sure to read the documentation. MDN and devdocs are good for that.
Johnny
@JohnnyBizzel
Mar 03 2017 01:12
@johnnunns he's gone to bed
Christopher Earle
@chrise61793
Mar 03 2017 01:12
@eyesore- MDN?
John Nunns
@johnnunns
Mar 03 2017 01:12
oh missed that. do you know the answer? do I just have to write two lines of code?
@JohnnyBizzel
Christopher Earle
@chrise61793
Mar 03 2017 01:13
@JohnnyBizzel I'm sure I'll be back. I've only been learning for about a month
Kang Chen
@kangchen
Mar 03 2017 01:13
@tam-nguyen all loops can converted into a recursion
@tam-nguyen @kangchen recursion is not always the best idea if you are worried about time complexity. Keep that in mind.
Johnny
@JohnnyBizzel
Mar 03 2017 01:13
@chrise61793 Do lots of background reading and look at using : pythontutor.com/javascript.html#mode=edit for debugging.
Christopher Earle
@chrise61793
Mar 03 2017 01:14
@JohnnyBizzel is FCC not sufficient?
Joseph
@revisualize
Mar 03 2017 01:14
@kangchen But that is NOT always best practice.
Thiago Cruz
@thy705
Mar 03 2017 01:14
@JohnnyBizzel I've read it multiple times, but nowhere there I can find why splice(1,1) doesn't take out the first element
Christopher Earle
@chrise61793
Mar 03 2017 01:14
@eyesore- Thanks, added to my bookmarks
CamperBot
@camperbot
Mar 03 2017 01:14
chrise61793 sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:warning: chrise61793 already gave eyesore- points
Johnny
@JohnnyBizzel
Mar 03 2017 01:14
@johnnunns That code might be one line but it's hard to read!
eyesore-
@eyesore-
Mar 03 2017 01:15
Oh, shit Joseph is here.
John Nunns
@johnnunns
Mar 03 2017 01:15
@JohnnyBizzel it doesn't work, I was having forkerino explain concising an if else statement. And i got to where I needed an else if
Johnny
@JohnnyBizzel
Mar 03 2017 01:15
@thy705 I think zero will be the start element. so splice(0,1)
John Nunns
@johnnunns
Mar 03 2017 01:15
wasn't sure how to make that into one life or if it's even possible
Johnny
@JohnnyBizzel
Mar 03 2017 01:16
end
Zaluth
@Zaluth
Mar 03 2017 01:16
i have multiple buttons with a class, but my event listener isn't working, help?
var button = document.querySelectorAll(".button");

for(var i = 0; i < button.length; i++){
    button[i].addEventListener("click", function(){
      wrap2.classList.remove("wrap2");
      wrap2.className = "show";
      button[i].className = "hide";
      back.className = "backshow";
    });
  }
Thiago Cruz
@thy705
Mar 03 2017 01:16
@JohnnyBizzel I've tried that, but instead of deleting the first element, it prints it.
Jeff
@Garanimal
Mar 03 2017 01:17
@JohnnyBizzel I solved it, but I honestly dont understand my own code so Im trying to figure out how the hell its operating
Johnny
@JohnnyBizzel
Mar 03 2017 01:18
@johnnunns I've lost your code. I can only see part of it.
Kang Chen
@kangchen
Mar 03 2017 01:18
@revisualize of course, small data will not help, but when you are talking about into millions, then you are talking about from O(n*n) to O(logn)
Johnny
@JohnnyBizzel
Mar 03 2017 01:18
@Garanimal one of the few!
Joseph
@revisualize
Mar 03 2017 01:18
@kangchen I don't know what O(n*n) to O(logn) means.
Johnny
@JohnnyBizzel
Mar 03 2017 01:18
@thy705 Remind me the challenge name
eyesore-
@eyesore-
Mar 03 2017 01:19
@revisualize quadratic to log
Thiago Cruz
@thy705
Mar 03 2017 01:19
@JohnnyBizzel Slasher Flick
Joseph
@revisualize
Mar 03 2017 01:19
@eyesore- English ********* ... do you speak it? (Pulp Fiction)
eyesore-
@eyesore-
Mar 03 2017 01:19
@revisualize using recursion can quickly go exponential though. I was tell you what O(n*n) to O(logn) is
Johnny
@JohnnyBizzel
Mar 03 2017 01:20
@thy705
function slasher(arr, howMany) {
  // it doesn't always pay to be first
  return arr.splice(howMany, arr.length - howMany);
}
@thy705 Sorry, I don't normally post answers but this was easier than trying to explain!
Joseph
@revisualize
Mar 03 2017 01:21
@eyesore- Let me get this straight .. I mention I don't understand what O(n*n) to O(logn) means.. You mention quadratic to log ... And guess what I'm going to say.. .... quadratic to log ... What is this?
eyesore-
@eyesore-
Mar 03 2017 01:21
@revisualize Big O notation. It's for time complexity in programming.
Joseph
@revisualize
Mar 03 2017 01:22
@eyesore- I've heard of it. That's about it.
I've seen people talk about Big O ... I don't understand it.
Johnny
@JohnnyBizzel
Mar 03 2017 01:22
It went over my head! :confused:
eyesore-
@eyesore-
Mar 03 2017 01:22
@revisualize It's not something you really have to worry about unless you are programming at large scale and running through thousands of lines.
Thiago Cruz
@thy705
Mar 03 2017 01:22
@JohnnyBizzel Thanks a lot Johnny!
CamperBot
@camperbot
Mar 03 2017 01:22
:star2: 1402 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
thy705 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
Johnny
@JohnnyBizzel
Mar 03 2017 01:23
@thy705 Hope that makes sense ;)
Jeff
@Garanimal
Mar 03 2017 01:23
@revisualize Thanks, that is actually pretty helpful. Its still bending my brain a bit
CamperBot
@camperbot
Mar 03 2017 01:23
garanimal sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3399 | @revisualize |http://www.freecodecamp.com/revisualize
eyesore-
@eyesore-
Mar 03 2017 01:23
@revisualize It's really all about efficiency. If you want to learn about it, you can start here https://www.interviewcake.com/article/java/big-o-notation-time-and-space-complexity
Thiago Cruz
@thy705
Mar 03 2017 01:24
@JohnnyBizzel Yep. This one was simpler than I thought.
Joseph
@revisualize
Mar 03 2017 01:25
@eyesore- Looks like I need to understand Java to get that.
eyesore-
@eyesore-
Mar 03 2017 01:26
@revisualize nah, it's relevant to any language
Joseph
@revisualize
Mar 03 2017 01:26
I see.. I can change it from Java to JavaScript.
AJ
@DracIdea
Mar 03 2017 01:26
Hey guys
function lookUpProfile(firstName, prop){
// Only change code below this line

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

    if (contacts.hasOwnProperty(firstName)){

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

        return contacts[x][prop];
}
           else {

            return "No such property";                           
}  
}
 else {

            return "No such contact";
    }

}  




  // Only change code above this line
}
Joseph
@revisualize
Mar 03 2017 01:26
@DracIdea Yor loop isn't looping.

@DracIdea

for ( ..... ) {
    if (evaluation) {
        return "truth";
    } else {
        return "lies";
    }
 }

This exact loop.. Does not loop. Because as we know:
The return statement ends function execution and specifies a value to be returned to the function caller.
Syntax
return [[expression]];
expression
The expression to return. If omitted, undefined is returned instead.

Zaluth
@Zaluth
Mar 03 2017 01:27
i have multiple buttons with a class, but my event listener isn't working, help?
var button = document.querySelectorAll(".button");

for(var i = 0; i < button.length; i++){
    button[i].addEventListener("click", function(){
      wrap2.classList.remove("wrap2");
      wrap2.className = "show";
      button[i].className = "hide";
      back.className = "backshow";
    });
  }
Joseph
@revisualize
Mar 03 2017 01:27
@DracIdea if (contacts.hasOwnProperty(firstName)){ .. This will always be false
Johnny
@JohnnyBizzel
Mar 03 2017 01:28
@Zaluth won't all the buttons need unique ids?
Zaluth
@Zaluth
Mar 03 2017 01:29
@JohnnyBizzel is it really necessary? i was trying to do it without having to write the same code again
AJ
@DracIdea
Mar 03 2017 01:29
@revisualize I wanted it to move on to the next if statement if it was true, and skip down to the last return if not....how would I correct this?
Joseph
@revisualize
Mar 03 2017 01:29
@DracIdea But, it will never be true.
@DracIdea You have two different lines of code:
if (contacts.hasOwnProperty(firstName)){
if (contacts[x].hasOwnProperty(prop)){
Why are you doing .hasOwnProperty() differently inside of your for loop?
AJ
@DracIdea
Mar 03 2017 01:30
would a firstName == firstName be a better way to go?
Joseph
@revisualize
Mar 03 2017 01:30
@DracIdea firstName == firstName will ALWAYS be true
Johnny
@JohnnyBizzel
Mar 03 2017 01:31
@Zaluth Is the event doing the same thing on all buttons?
John Nunns
@johnnunns
Mar 03 2017 01:32
that worked, thanks @eyesore-
CamperBot
@camperbot
Mar 03 2017 01:32
johnnunns sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 63 | @eyesore- |http://www.freecodecamp.com/eyesore-
AJ
@DracIdea
Mar 03 2017 01:32
@revisualize honestly Im just grasping at straws. I want to pop this challenge so I can use it as an example to build off of moving forward.
Zaluth
@Zaluth
Mar 03 2017 01:32
@JohnnyBizzel yes
Joseph
@revisualize
Mar 03 2017 01:32
@DracIdea You need to change your logic.
eyesore-
@eyesore-
Mar 03 2017 01:32
@johnnunns No problem! Anytime.
Joseph
@revisualize
Mar 03 2017 01:32
@DracIdea The function should check if firstName is an actual contact's firstName
@DracIdea You're not doing that. You're checking if the contacts array has a property of firstName
Carey Van
@thisiscarey
Mar 03 2017 01:33
I'm stuck on Mutations. All of my true statements are working but I can't figure out why my false statements don't work. If I switch the true with false, the opposite checks work, so I'm not sure what that means
function mutation(arr) {
  //var splitStringSort1 = arr[0].split('').sort();
  //var splitStringSort2 = arr[1].split('').sort();
  //var arrayOfString = [];
  var split1stString = arr[0].split('');
  var split2ndString = arr[1].split('');
  //var indexed = arr[0].indexOf(split2ndString[0]);
  for (i = 0; i < arr[0].length; i++) {
    if (arr[1].indexOf(split1stString[i]) > 0) {
        return true;
    } 
  } 

}

mutation(["hello", "hey"]);
Joseph
@revisualize
Mar 03 2017 01:33
@DracIdea Array elements are accessed by indexes.
Carey Van
@thisiscarey
Mar 03 2017 01:34
I kinda just want to reset everything and start over. I think I wrote too much and am confusing myself
Joseph
@revisualize
Mar 03 2017 01:35
@thisiscarey > 0 shouldn't be that.
AJ
@DracIdea
Mar 03 2017 01:35
@revisualize I dont suppose you know of a previous challenge I can look at to figure this out?
Joseph
@revisualize
Mar 03 2017 01:35
@DracIdea You need to read the instructions and write a better if condition.
Zaluth
@Zaluth
Mar 03 2017 01:35
@JohnnyBizzel is there a way to do that in pure javascript? i'm not familiar with jquery
Carey Van
@thisiscarey
Mar 03 2017 01:36
yea, i was originally trying to push anything positive to the array, and if a negative number came up, it would return false.
Johnny
@JohnnyBizzel
Mar 03 2017 01:36
@Zaluth you can mix javascript and jquery.
AJ
@DracIdea
Mar 03 2017 01:36
@revisualize so the if (contacts[x].hasOwnProperty(prop)) is ok then? Just the other one needs to be approached differently?
Joseph
@revisualize
Mar 03 2017 01:37
@DracIdea The function should check if firstName (referring to the parameter) is an actual contact's firstName (referring to the object property inside of the object array element.)
@DracIdea check if firstName (referring to the parameter) is an actual contact's firstName (referring to the object property inside of the object array element.)
Johnny
@JohnnyBizzel
Mar 03 2017 01:37
@Zaluth Once you try jQuery, you won't want to go back.
Joseph
@revisualize
Mar 03 2017 01:38
@DracIdea if firstName is contact's firstName (referring to the object property inside of the object array element.)
Johnny
@JohnnyBizzel
Mar 03 2017 01:38
@revisualize ty - brownie for you!
CamperBot
@camperbot
Mar 03 2017 01:38
johnnybizzel sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3400 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 03 2017 01:38
@DracIdea if firstName === contact's firstName (referring to the object property inside of the object array element.)
@DracIdea Do you kind of see what I'm doing here?
Johnny
@JohnnyBizzel
Mar 03 2017 01:38
That's the 3400's person who got stuck on Profile Lookup
Zaluth
@Zaluth
Mar 03 2017 01:39
@JohnnyBizzel it's because i'm studying javascript at the moment, i'd like to be more comfortable with it before jumping into jquery
Joseph
@revisualize
Mar 03 2017 01:39
@JohnnyBizzel Thanks
CamperBot
@camperbot
Mar 03 2017 01:39
revisualize sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1403 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Mar 03 2017 01:39
lol
AJ
@DracIdea
Mar 03 2017 01:39
@revisualize I do totally, just need to figure out how to do this
Johnny
@JohnnyBizzel
Mar 03 2017 01:39
@Zaluth Well I'm not comfortable writing javascript. What shall we do????
Joseph
@revisualize
Mar 03 2017 01:39
@DracIdea The instructions tell you excatly what to do
AJ
@DracIdea
Mar 03 2017 01:41
So the if statement should use some type of firstName===contact[firstName]
Joseph
@revisualize
Mar 03 2017 01:41
@DracIdea That's close.
@DracIdea Can I ask you 4 quick questions?
Zaluth
@Zaluth
Mar 03 2017 01:41
@JohnnyBizzel desperate and cry?
AJ
@DracIdea
Mar 03 2017 01:42
@revisualize sure
Joseph
@revisualize
Mar 03 2017 01:42
@DracIdea Okay. I want quick answers.

@DracIdea Let's say you have an object.

var myFriend = {
        "firstName": "Happy",
        "lastName": "Feet",
        "number": "-i",
        "likes": ["rhythm", "dancing", "soul"]
    }

How do you access the "firstName" of myFriend?

AJ
@DracIdea
Mar 03 2017 01:42
myFriend.firstName?
Joseph
@revisualize
Mar 03 2017 01:43
@DracIdea Don't use ? if you're unsure.. Be sure of yourself.
That's correct.
@DracIdea Let's say we have an array:
var contacts = [ "A" , "H" , "S" , "K" ];
How do you access "H"?
AJ
@DracIdea
Mar 03 2017 01:43
contacts1
Joseph
@revisualize
Mar 03 2017 01:43

@DracIdea Let's say we have an array of objects:

var contacts = [ { f: "A" } , { f: "H" } , { f: "S" } , { f: "K" } ];

How do you output "H"?

Freddy López
@freddygllz
Mar 03 2017 01:44
@thisiscarey I think your problem is th logic, because as soon as the if stament check true it will end the function because of the return, you need to check if is false first
Johnny
@JohnnyBizzel
Mar 03 2017 01:45
@Zaluth Learn about the force Luke!!
https://www.w3schools.com/jquery/
AJ
@DracIdea
Mar 03 2017 01:45
contacts[0].f?
Joseph
@revisualize
Mar 03 2017 01:46
@DracIdea No ?
@DracIdea Incorrect.
@DracIdea That is "A"
Prakash Shiwakoti
@pshiwakoti1
Mar 03 2017 01:46
hi @JohnnyBizzel how to solve fibonacci challenge
AJ
@DracIdea
Mar 03 2017 01:47
contacts[1].f
Joseph
@revisualize
Mar 03 2017 01:47
@DracIdea Okay. What if f: was firstName: ?
@DracIdea What if "H" was actually "Harry"?
@DracIdea What's wrong with this:firstName === contact[firstName]
Aaron Dwayne Gebana
@adgebana
Mar 03 2017 01:48
contacts[1][firstName]
Joseph
@revisualize
Mar 03 2017 01:48
@adgebana Incorrect.
Johnny
@JohnnyBizzel
Mar 03 2017 01:48
contacts[1].firstName ?
Joseph
@revisualize
Mar 03 2017 01:49
:|
You kids.
AJ
@DracIdea
Mar 03 2017 01:49
contacts[1].f
Johnny
@JohnnyBizzel
Mar 03 2017 01:49
What was the question :P
eyesore-
@eyesore-
Mar 03 2017 01:49
Harsh
Joseph
@revisualize
Mar 03 2017 01:49
I ask people questions and other people chime in.
Johnny
@JohnnyBizzel
Mar 03 2017 01:49
Sorry I will be quiet
AJ
@DracIdea
Mar 03 2017 01:49
was i correct sir lol
Joseph
@revisualize
Mar 03 2017 01:50
@DracIdea You were correct. Can you answer my other 3 questions about your code?
Aaron Dwayne Gebana
@adgebana
Mar 03 2017 01:50
Ok I have a question:
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
}
Is there a way to use contacts.hasOwnProperty() to check for a property on the.. "second layer" of the array?
Joseph
@revisualize
Mar 03 2017 01:51
@adgebana contacts is an array
AJ
@DracIdea
Mar 03 2017 01:51
@adgebana this is what im stuck on too
Joseph
@revisualize
Mar 03 2017 01:51
@adgebana You have to first access the array element .. Then you access the object .. just like you access any object.
Aaron Dwayne Gebana
@adgebana
Mar 03 2017 01:52
Ah, I was hoping to avoid another if statement inside my for loop
Joseph
@revisualize
Mar 03 2017 01:52
@adgebana Just one loop
Aaron Dwayne Gebana
@adgebana
Mar 03 2017 01:52
Okidoki, giving it a shot, thanks!
Joseph
@revisualize
Mar 03 2017 01:53
@DracIdea Okay. What if f: was firstName: ?
@DracIdea What if "H" was actually "Harry"?
@DracIdea What's wrong with this:firstName === contact[firstName]
vanessamuller
@vanessamuller
Mar 03 2017 01:53
hi if anyone can help me on the intermediate algorith called sum all numbers in a range
I am using the reduce method and I don't know why it is not returning the value I want

function sumAll(arr) {
var max =Math.max.apply(null, arr);
var min = Math.min.apply(null,arr);
var nums = [];
for(var i=min; i<=max; i++){
nums.push(i);
}

nums.reduce(
function (
accumulator,
currentValue,
currentIndex,
array
) {
return accumulator + currentValue;
}
);
}

sumAll([1, 4]);

AJ
@DracIdea
Mar 03 2017 01:54
@revisualize Processing lol
eyesore-
@eyesore-
Mar 03 2017 01:55
@adgebana @DracIdea If you are still super confused about this after Master Joseph goes through it PM me and I will walk through it step by step.
Joseph
@revisualize
Mar 03 2017 01:55
@eyesore- I already have the lesson explained step by step.
It's in my notes.
AJ
@DracIdea
Mar 03 2017 01:56
@eyesore- cheers
eyesore-
@eyesore-
Mar 03 2017 01:56
Cool.
Mo.
@mokyox
Mar 03 2017 01:56
Hey guys, got a problem with the Testing Objects for properties lesson. I'm trying to find a way to return all the values of the object myObj but I can't seem to find the answer online. Any ideas?

// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here


  if (myObj.hasOwnProperty("gift" || "pet" || "bed")) {
    return myObj; //Object value?
  }

 else {
  return "Not Found";
}

}

// Test your code by modifying these values
checkObj("gift");
eyesore-
@eyesore-
Mar 03 2017 01:56
I was just saying if they needed another walkthrough. Not trying to step over your explanation.
Joseph
@revisualize
Mar 03 2017 01:56
@mokkyun That is NOT how you use hasOwnProperty()
@mokkyun function checkObj(checkProp) { Do you know what checkProp is?
@eyesore- Check my github
eyesore-
@eyesore-
Mar 03 2017 01:59
@revisualize You are very prepared. I haven't even done the majority of the lessons.
Mo.
@mokyox
Mar 03 2017 02:00
@revisualize checkProp is the value that goes into the value that goes into the function, right? The argument?
Joseph
@revisualize
Mar 03 2017 02:00
@eyesore- I've done every lesson before the basic Algos at least three times.
@mokkyun It's called a parameter .. It is passed it's value from the argument in the function call.
Theo M.
@cnngraphics
Mar 03 2017 02:00
@mokkyun After you check if the hasOwnPoperty, you have to iterate over the object to get each property out:
Joseph
@revisualize
Mar 03 2017 02:00
@cnngraphics No you don't.
@mokkyun The parameter is used JUST like a variable.
@mokkyun It's a variable that's defined by whatever is passed via the function call.
Jeff
@Garanimal
Mar 03 2017 02:01
Hey all, Question about expressions and \d digit selector
Joseph
@revisualize
Mar 03 2017 02:02
@mokkyun And of course.. You already know how to access object properties using a variable.
Theo M.
@cnngraphics
Mar 03 2017 02:02
@revisualize can you show an example of that, I need to understand this concept well
Joseph
@revisualize
Mar 03 2017 02:02
@cnngraphics An example of what?
@cnngraphics How to access object properties with variables?
Jeff
@Garanimal
Mar 03 2017 02:02
This message was deleted
manish
@kumarheemanshu
Mar 03 2017 02:02
how to solve palindrome problem
Mo.
@mokyox
Mar 03 2017 02:02
Thanks for that @cnngraphics and @revisualize . So, checkProp is a parameter.
CamperBot
@camperbot
Mar 03 2017 02:02
mokkyun sends brownie points to @cnngraphics and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 233 | @cnngraphics |http://www.freecodecamp.com/cnngraphics
CamperBot
@camperbot
Mar 03 2017 02:02
:star2: 3401 | @revisualize |http://www.freecodecamp.com/revisualize
Jeff
@Garanimal
Mar 03 2017 02:03
var testString = "There are 3 cats but 4 dogs.";
var expression = /\d/g;  
var digitCount = testString.match(expression);

This will output ["3","4"]
and If I change

var expression = /\d+/g

it will still output ["3","4"]
so what does the \d+ really do?

Joseph
@revisualize
Mar 03 2017 02:03
@mokkyun How do you use parameters?
Mo.
@mokyox
Mar 03 2017 02:03
myObj.hasOwnProperty(); checks whether the object has a certain property name. So it will return "true" or "false", right?
Joseph
@revisualize
Mar 03 2017 02:03
@mokkyun Correct.
@mokkyun But, you have to pass it an argument.
AJ
@DracIdea
Mar 03 2017 02:04
@revisualize Thanks for the help, I think I'm on the right track now
CamperBot
@camperbot
Mar 03 2017 02:04
dracidea sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3402 | @revisualize |http://www.freecodecamp.com/revisualize
Theo M.
@cnngraphics
Mar 03 2017 02:04
@revisualize Thanks for that link. Exactly what I needed...
CamperBot
@camperbot
Mar 03 2017 02:04
cnngraphics sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3403 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 03 2017 02:05
@Garanimal http://regexr.com/
Jeff
@Garanimal
Mar 03 2017 02:06
@revisualize nvm I figured it out by changing the number of cats from 3 to 31. It doesnt do anything here because its only single digits but if it was double it keeps them doubled instead of treating them as two seperate ones
jdl2017
@jdl2017
Mar 03 2017 02:06
What's the difference between \n and \r?
Mo.
@mokyox
Mar 03 2017 02:06
@revisualize Parameters, are used when a function contains a statement that is executed when we use a function
Joseph
@revisualize
Mar 03 2017 02:07
@mokkyun
@mokkyun The parameter is used JUST like a variable.
Jeff
@Garanimal
Mar 03 2017 02:07
@revisualize thanks though
CamperBot
@camperbot
Mar 03 2017 02:07
garanimal sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: garanimal already gave revisualize points
Joseph
@revisualize
Mar 03 2017 02:08
@mokkyun I asked How do you use a parameter .. Not When
jdl2017
@jdl2017
Mar 03 2017 02:08
@revisualize I'm on "Escape Sequences in Strings" and I used this:
var myStr = "FirstLine\r\n\SecondLine\\r\nThirdLine";
why is that wrong?
Joseph
@revisualize
Mar 03 2017 02:08
@jdl2017 a bunch
Mo.
@mokyox
Mar 03 2017 02:08
@revisualize For example
function (x) {
return x + x;
}
Steven Stinson
@rufusBot
Mar 03 2017 02:08
I'm stuck at the queue lesson
Joseph
@revisualize
Mar 03 2017 02:08
@jdl2017 You have to assign 'FirstLine newline backslash SecondLine backslash carriage-return ThirdLine' to the variable myStr.
But, You have to replace the escape words with the proper escape sequences. (And per the instructions: remove all spaces.)
How do you escape a newline?
How do you escape a backslash?
How do you escape a carriage-return?
Steven Stinson
@rufusBot
Mar 03 2017 02:08
I can't even.
Joseph
@revisualize
Mar 03 2017 02:09

@rufusBot Gist by revisualize / FreeCodeCamp - Stand in Line.js

How do you add a number (item) to the end of an array (arr)? What does this method return?
How do you remove the first element from an array (arr)? What does this method return?

You're supposed to:
Write a function nextInLine which has two parameters
an array (arr) and a number (item).
That part has been done for you here:

function nextInLine(arr, item) { }

Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.

You just need to add a number (item) to the end of an array (arr).
You also need to remove the first element from an array (arr).
But, there is another part of this challenge. You need to know What the methods that do those two things return.
@rufusBot ----^

@mokkyun Did you solve your lesson?
Mo.
@mokyox
Mar 03 2017 02:10

@mokkyun Sorry, used like a variable. So we need to pass
myObj.hasOwnProperty(); an argument, which are the real values.

I haven't solved the lesson yet

Joseph
@revisualize
Mar 03 2017 02:11
@mokkyun You need to pass .hasOwnProperty() an argument.
May I suggest passing the parameter?
Steven Stinson
@rufusBot
Mar 03 2017 02:12
well testArr.shift removes the first item right?
Joseph
@revisualize
Mar 03 2017 02:13
@rufusBot You need to re-read the instructions.
@rufusBot The instructions don't tell you to use the variable testArr in your function.
Steven Stinson
@rufusBot
Mar 03 2017 02:13
I know that testArr.push(item); would push the parameter item onto the end of the array.
Mo.
@mokyox
Mar 03 2017 02:13
@revisualize Ah, I see. hasOwnProperty(checkProp) as it's the real value. Then we return each object's property value?
jdl2017
@jdl2017
Mar 03 2017 02:13
@revisualize does that mean \r and \n do the same thing in JS?
Joseph
@revisualize
Mar 03 2017 02:13
@jdl2017 No.
@jdl2017 They actually do different things.
But, the output to the screen looks the same.
Steven Stinson
@rufusBot
Mar 03 2017 02:14
Do i return the name of the array?
@rufusBot No.
@rufusBot You're supposed to return the element that was removed from the array (arr).
Steven Stinson
@rufusBot
Mar 03 2017 02:15
I mean "testArr.push(item)" pushes the 6 as a parameter onto the end of the array
Joseph
@revisualize
Mar 03 2017 02:15
@rufusBot testArr isn't the arr
Steven Stinson
@rufusBot
Mar 03 2017 02:16
What?
Joseph
@revisualize
Mar 03 2017 02:16
@rufusBot Re-read the instructions.
@rufusBot You do NOT use testArr inside of your function. The array is arr
Jeff
@JSchock16
Mar 03 2017 02:17
I'm going with buttons that toggle via transition="" from a company picture to a text overlay for the first project how should I build my body? I'm working on style right now and trying bootstrap
jdl2017
@jdl2017
Mar 03 2017 02:17
@revisualize I googled that stuff before coming here but what I'm curious about is why \n was used to break the first line onto the second and then from the second to the third \r was used
Steven Stinson
@rufusBot
Mar 03 2017 02:17
Oh that's jus the test setup
So wait do I write my own array in the function?
Joseph
@revisualize
Mar 03 2017 02:17

@jdl2017 This lesson is not trying to teach you how to get some green check marks to pass onto the next lesson. It is trying to teach you a really valuable skill. If you have a string in JavaScript that is instantiated with double quotes (") (Example: var myStr = "Hello World";) you can also instantiate a string with single quotes (') (Example: var myStr = 'Hello World';)

How do you add a " to that string? Let's say you instantiated the string with double quotes and you want to put in a quote that someone said. You have to use an escape character.
Example: var myQuote = 'Happy Feet said, \"I really like the rhythm.\"';
Or what happens if you want to add a tab to your string? You can't really add 3 spaces and expect it to show up as a tab. You have to use the escape character for a tab (\t).

OR let's say your trying to output a bunch of text and paragraphs within your JavaScript string. You can't really just make a bunch of variables.
var myParagraph1 = "a bunch of characters";
var myParagraph2 = "a bunch more characters";
I mean you could... but, why not just:
var myStr = "A bunch of characters/sentences.\nThe second paragraph of characters and sentences.";

@rufusBot NO
Steven Stinson
@rufusBot
Mar 03 2017 02:18
Why is this so god damn confusing?
Joseph
@revisualize
Mar 03 2017 02:18

@rufusBot Gist by revisualize / FreeCodeCamp - Stand in Line.js
Write a function nextInLine which has two parameters
an array (arr) and a number (item).

That part has been done for you here:

function nextInLine(arr, item) { }
Steven Stinson
@rufusBot
Mar 03 2017 02:18
Yeah
Jeff
@JSchock16
Mar 03 2017 02:19
omg I hate this lesson took me a day to figure out what they were asking
Joseph
@revisualize
Mar 03 2017 02:19
@rufusBot arr is the array
@rufusBot Do you understand what parameters are?
Steven Stinson
@rufusBot
Mar 03 2017 02:20
Yeah. They're in the parenthesis of a function and you use them to pass variables through.
Jeff
@JSchock16
Mar 03 2017 02:20

function nextInLine(arr, item) {
// Your code here
arr.push(item);
return arr.shift(); // Change this line
}

// Test Setup
var testArr = [5,6,7,8,9];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
I really had a hard time with this one and maybe seeing the solution will help but do NOT progress until you see why it works.

Joseph
@revisualize
Mar 03 2017 02:20
@rufusBot Correct.
@rufusBot So...
Jeff
@JSchock16
Mar 03 2017 02:21
they variables arr and item are initialized on function call as the parameters
the
Joseph
@revisualize
Mar 03 2017 02:21
@rufusBot How do you add a number (item) to the end of an array (arr)? What does this method return?
How do you remove the first element from an array (arr)? What does this method return?
jSwtch
@jSwtch
Mar 03 2017 02:21
@revisualize is it correct that a function should not run unless it is called?
Joseph
@revisualize
Mar 03 2017 02:22
@jswtch Depends on the type of function.
@jswtch IIFE
Steven Stinson
@rufusBot
Mar 03 2017 02:22
You add a number (item) to the end of an array by pushing it.
jdl2017
@jdl2017
Mar 03 2017 02:22
@revisualize thanks, I understood those points but my original question remains unanswered. I pmed you
Joseph
@revisualize
Mar 03 2017 02:23
@jdl2017 I don't read my pms.
jdl2017
@jdl2017
Mar 03 2017 02:23
Got it
here you go
I guess I'm confused as to why that code won't give me the output they're wanting
Or do I simply have to follow their set directions? As in the code I wrote is correct as well?
Joseph
@revisualize
Mar 03 2017 02:23
@jdl2017 You have to assign 'FirstLine newline backslash SecondLine backslash carriage-return ThirdLine' to the variable myStr.
But, You have to replace the escape words with the proper escape sequences. (And per the instructions: remove all spaces.)
How do you escape a newline?
How do you escape a backslash?
How do you escape a carriage-return?
Jeff
@JSchock16
Mar 03 2017 02:23
.push() is the operation covered earlier in that section
jdl2017
@jdl2017
Mar 03 2017 02:23
Why use one and then the other to accomplish the same result?
Joseph
@revisualize
Mar 03 2017 02:23
@jdl2017 The code you wrote is NOT correct.
jdl2017
@jdl2017
Mar 03 2017 02:23
They're saying they're interchangeable?
Mo.
@mokyox
Mar 03 2017 02:23
Thanks @revisualize . I accessed myObj values using `myObj[checkProp] and returned that value.
 if (myObj.hasOwnProperty(checkProp)) {
    return myObj[checkProp];
CamperBot
@camperbot
Mar 03 2017 02:23
mokkyun sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: mokkyun already gave revisualize points
Jeff
@JSchock16
Mar 03 2017 02:24
you need to manipulate the passed in variables with testArray
jdl2017
@jdl2017
Mar 03 2017 02:24
sorry if this is annoying lol
Joseph
@revisualize
Mar 03 2017 02:24

@jdl2017 You have to assign 'FirstLine newline backslash SecondLine backslash carriage-return ThirdLine' to the variable myStr.
But, You have to replace the escape words with the proper escape sequences. (And per the instructions: remove all spaces.)
How do you escape a newline? With: \n
How do you escape a backslash? With: \\
How do you escape a carriage-return? With \r
So, you have break the problem down.
FirstLine newline backslash SecondLine backslash carriage-return ThirdLine
FirstLine \n backslash SecondLine backslashcarriage-return ThirdLine
FirstLine \n \\ SecondLine backslash carriage-return ThirdLine
FirstLine \n \\ SecondLine \\ carriage-return ThirdLine
FirstLine \n \\ SecondLine \\ \r ThirdLine
You have to follow the instructions and remove all of the spaces
Then assign that to myStr as a string.

This lesson is not trying to teach you how to get some green check marks to pass onto the next lesson. It is trying to teach you a really valuable skill. If you have a string in JavaScript that is instantiated with double quotes (") (Example: var myStr = "Hello World";) you can also instantiate a string with single quotes (') (Example: var myStr = 'Hello World';)

How do you add a " to that string? Let's say you instantiated the string with double quotes and you want to put in a quote that someone said. You have to use an escape character.
Example: var myQuote = 'Happy Feet said, \"I really like the rhythm.\"';
Or what happens if you want to add a tab to your string? You can't really add 3 spaces and expect it to show up as a tab. You have to use the escape character for a tab (\t).

OR let's say your trying to output a bunch of text and paragraphs within your JavaScript string. You can't really just make a bunch of variables.
var myParagraph1 = "a bunch of characters";
var myParagraph2 = "a bunch more characters";
I mean you could... but, why not just:
var myStr = "A bunch of characters/sentences.\nThe second paragraph of characters and sentences.";

Jeff
@JSchock16
Mar 03 2017 02:24
try it and tell us if it works
it seems harder to maintain
Aaron Dwayne Gebana
@adgebana
Mar 03 2017 02:25
Just wanted to clarify for regular expressions, if you use \s you don't need to add +, \s by itself returns all white space am I correct?
jSwtch
@jSwtch
Mar 03 2017 02:25
I commented out a function call but it is still running on doc.ready. I am not sure why
https://codepen.io/jswtch/pen/dvooaR?editors=1010
Jeff
@JSchock16
Mar 03 2017 02:27
just for function it'd be nice to search a blank field and it behave as if it is searching all
Joseph
@revisualize
Mar 03 2017 02:27
@jdl2017 Does that make sense?
Aaron Dwayne Gebana
@adgebana
Mar 03 2017 02:27
..forget what I asked, I'm sorted out
Joseph
@revisualize
Mar 03 2017 02:28
Wow.. My example is wrong.
John P Penaloza
@johnpyp
Mar 03 2017 02:29

Hey guys, I'm having trouble with the "Symmetric Difference" and I think it might be a bug. Here is my code:


function sym(args) {
  args = arguments;
  function symdif(arr, arr2) {
    var newArr = [];
    for (var i = 0; i < arr.length; i++) {
      if (arr2.indexOf(arr[i]) == -1) {
        newArr.push(arr[i]);
      }
    }
    for (var j = 0; j < arr2.length; j++) {
      if (arr.indexOf(arr2[j]) == -1) {
        newArr.push(arr2[j]);
      }
    }
    return newArr;
  }
  var symm = arguments[0];
  for (i = 1; i < args.length; i++) {
    symm = symdif(symm, args[i]);
  }
  function uniq(a) {
    return a.sort().filter(function(item, pos, ary) {
        return !pos || item != ary[pos - 1];
    });
}
  symm = uniq(symm);
  return symm;
}

sym([3, 3, 3, 2, 5], [2, 1, 5, 7], [3, 4, 6, 6], [1, 2, 3]);

The problem is all of my returns are exactly what the problems wants, but it isn't confirming it.

jdl2017
@jdl2017
Mar 03 2017 02:29
@revisualize yes it does and that wasn't what was confusing. Like I mentioned, I'm trying to figure out the difference between the two. When is it appropriate to use each. It seems both break lines. Why is one used instead of the other and vice versa
Joseph
@revisualize
Mar 03 2017 02:30
@jdl2017 Bro. I don't know.
I just use \n
jdl2017
@jdl2017
Mar 03 2017 02:30
Got it
Steven Stinson
@rufusBot
Mar 03 2017 02:30
Thanks for the answer @jdl2017. This stuff makes me feel fucking stupid. This is the second time I've tried learning JS.
CamperBot
@camperbot
Mar 03 2017 02:30
rufusbot sends brownie points to @jdl2017 :sparkles: :thumbsup: :sparkles:
:cookie: 146 | @jdl2017 |http://www.freecodecamp.com/jdl2017
Steven Stinson
@rufusBot
Mar 03 2017 02:30
Where does it pull the parameters from?
jdl2017
@jdl2017
Mar 03 2017 02:31
So they're interchangeable it seems
Steven Stinson
@rufusBot
Mar 03 2017 02:31
Aren't they just empty parameters?
jdl2017
@jdl2017
Mar 03 2017 02:31
@revisualize thanks
CamperBot
@camperbot
Mar 03 2017 02:31
jdl2017 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3404 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 03 2017 02:31
@rufusBot Parameters are "defined" from the function call.
That isn't the correct word.
Cesar Peguero
@cape07
Mar 03 2017 02:31
@revisualize @jdl2017 I'm stuck on the same exercise.... I think I'm getting the string right but it's still giving me 1 error: "myStr should have encoded text with the proper escape sequences and no spacing"
jdl2017
@jdl2017
Mar 03 2017 02:32
@cape07 you have to do it exactly how they word it out
what's your code
Steven Stinson
@rufusBot
Mar 03 2017 02:32
So even without variables, the function is called with the parameters ([ ], 1) in that instance?
Joseph
@revisualize
Mar 03 2017 02:33
@rufusBot If you're doing a function call to .... nextInLine([], 1)
Cesar Peguero
@cape07
Mar 03 2017 02:33

@jdl2017 this is what I'm doing: var myStr ="FirstLine\n\SecondLine\ThirdLine\r";

it's the right wording.. I think

Joseph
@revisualize
Mar 03 2017 02:33
@rufusBot arr becomes [] and item becomes 1
@cape07 That's incorrect.
@cape07 You're not escaping the carriage-return in the correct spot.
Cesar Peguero
@cape07
Mar 03 2017 02:34
oooh that makes sense
Steven Stinson
@rufusBot
Mar 03 2017 02:34
You need two slashes on either side of "SecondLine"
jdl2017
@jdl2017
Mar 03 2017 02:34
@cape07 also you're missing escapes for the forward slash
Joseph
@revisualize
Mar 03 2017 02:35
@rufusBot they have it correct.
No @cape07 is not
Try putting 12 \ in this chat
Steven Stinson
@rufusBot
Mar 03 2017 02:35
\
\\\\\
jdl2017
@jdl2017
Mar 03 2017 02:35
\\\
Steven Stinson
@rufusBot
Mar 03 2017 02:35
Ah
Joseph
@revisualize
Mar 03 2017 02:35
See what gitter does?
It strips them.
jdl2017
@jdl2017
Mar 03 2017 02:35
\\\\
Halves them?
Joseph
@revisualize
Mar 03 2017 02:35
You have to quote the person to see what they actually type
Yes
\\ gets output as \
\\\\ gets output as \\
jdl2017
@jdl2017
Mar 03 2017 02:36
"\"
Joseph
@revisualize
Mar 03 2017 02:36
SO
To see what a person actually types you have to Quote them
jdl2017
@jdl2017
Mar 03 2017 02:36
Nice, got it
'test'
'\'
Cesar Peguero
@cape07
Mar 03 2017 02:37
@revisualize @jdl2017 Yeah it was the \r in the wrong spot.. I had \ idk why it copied 1 :worried:
jdl2017
@jdl2017
Mar 03 2017 02:37
\
Joseph
@revisualize
Mar 03 2017 02:37
@cape07 Gitter chat strips them. It's fine.
jdl2017
@jdl2017
Mar 03 2017 02:37
test
Cesar Peguero
@cape07
Mar 03 2017 02:38
@revisualize thanks!!
CamperBot
@camperbot
Mar 03 2017 02:38
cape07 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3405 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 03 2017 02:39
@rufusBot Do you need more explanation on parameters?
Steven Stinson
@rufusBot
Mar 03 2017 02:46
I understand parameters, just not queues.
Or maybe I don't . I have no idea.
This shit is obtuse.
Joseph
@revisualize
Mar 03 2017 02:47
@rufusBot It actually isn't.
@rufusBot What's the basic idea of a queue?
Steven Stinson
@rufusBot
Mar 03 2017 02:48
To cycle through an array.
Joseph
@revisualize
Mar 03 2017 02:48
You're thinking too technically.
Steven Stinson
@rufusBot
Mar 03 2017 02:49
Put a parameter onto the end of an array and return the first item of the array.
Joseph
@revisualize
Mar 03 2017 02:50
@rufusBot A first-in first-out data structure used to sequence objects. Objects are added to the tail of the queue ("enqueued") and taken off the head ("dequeued").
@rufusBot So, we are trying to make a function that adds an element to the end of the queue (an array) and gets the next element in the queue and outputs it
@rufusBot So.
@rufusBot You're supposed to:
Write a function nextInLine which has two parameters
an array (arr) and a number (item).
That part has been done for you here:
function nextInLine(arr, item) { }
@rufusBot How do you add a number (item) to the end of an array (arr)?
@rufusBot How do you remove the first element from an array (arr)?
@rufusBot The nextInLine function should then return the element that was removed.
@rufusBot So after you answer the question: How do you remove the first element from an array (arr)? ... I'd ask you ... What does that method return?
@rufusBot You're going to tell me it doesn't return anything.. I'm going to tell you that's wrong.. Because all functions and methods return something.
Then I'll ask you this question.

@rufusBot Question:

function getName() { return "Happy Feet"; }
var name = getName();
console.log(name);

What do you think is output to the console when you log the variable name?
Why do you think that is?

@rufusBot Then ... I'll end up repeating myself by asking: How do you remove the first element from an array (arr)? What does this method return?
Joseph
@revisualize
Mar 03 2017 02:56
@rufusBot Eventually, I'll just point out that you can have your function return what is returned from the method that removes the first element from the array (arr).
@rufusBot Then you'll flip out because you learned some :shit: and actually solved the lesson.
Steven Stinson
@rufusBot
Mar 03 2017 02:57
Well I could've told you that code will log "Happy Feet" into the console.
But that makes more sense when you say it like that.
Because .pop() is a function.
Joseph
@revisualize
Mar 03 2017 02:58
@rufusBot It is a method .. and most methods are actually just functions.
@rufusBot It's not one of the methods used in this lesson though.
@eyesore- ---^^^
Steven Stinson
@rufusBot
Mar 03 2017 03:00
I'll have to ruminate on that. lol
Joseph
@revisualize
Mar 03 2017 03:01

The push() method adds one or more elements to the end of an array and returns the new length of the array.

The pop() method removes the last element from an array and returns that element.

The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.

The shift() method removes the first element from an array and returns that element.

eyesore-
@eyesore-
Mar 03 2017 03:01
@revisualize Happy Feet again?
Joseph
@revisualize
Mar 03 2017 03:01
@eyesore- I like "Happy Feet"
eyesore-
@eyesore-
Mar 03 2017 03:01
@revisualize I've been out of this chat. Any way I can help? haha
Joseph
@revisualize
Mar 03 2017 03:01
/collapse-all
eyesore-
@eyesore-
Mar 03 2017 03:03
Haha nice
Joseph
@revisualize
Mar 03 2017 03:04
@eyesore- I'm lazy. I just copy and paste from there.
eyesore-
@eyesore-
Mar 03 2017 03:05
Not giving that artisanal help. Made with love.
Joseph
@revisualize
Mar 03 2017 03:09
@rufusBot So... How you doing with that lesson?
Nayenne Abgail
@Nayenne
Mar 03 2017 03:14
http://codepen.io/NayNay_s2/pen/NdzLxo
what am i doing wrong?
the quotes won't show in the cloud like i want
Joseph
@revisualize
Mar 03 2017 03:17
@Nayenne Z index?
DavHobbs
@DavHobbs
Mar 03 2017 03:18

Find the Longest Word in a String - Need HELP

Why isnt this code passing?

function findLongestWord(str) {
var splitWord = str.split(' ');
var longestString = 0;

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

}

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

CamperBot
@camperbot
Mar 03 2017 03:18
find the longest word in a string - need helpwhy isnt this code passing function findlongestwordstr var splitword strsplit var longeststring 0 for var i 0 i splitwordlength i if splitwordilength longeststring longeststring splitwordilength findlongestwordthe quick brown fox jumped over the lazy dog
nothing found
Nayenne Abgail
@Nayenne
Mar 03 2017 03:19
@revisualize whats the problem?
Joseph
@revisualize
Mar 03 2017 03:20
@Nayenne No idea.
@replymedia You don't have a return statement
Nayenne Abgail
@Nayenne
Mar 03 2017 03:20
@revisualize but why did yoou question mark z index?
Leon
@clexpectation
Mar 03 2017 03:20

var count = 0;

function cc(card) {
// Only change code below this line

switch(card){
case 2: case 3: case 4: case 5: case 6: count++; break;
case 10: case 'J': case 'Q': case 'K': case 'A': count--; break;
}
if(count>0){
return console.log(count , " Bet");
}
else{
return console.log(count , " Hold");
}

// Only change code above this line
}

// Add/remove calls to test your function.
// 提示: Only the last will display
cc(5); cc(3); cc(2); cc(4); cc(6);

DavHobbs
@DavHobbs
Mar 03 2017 03:21
@revisualize aaaahhhh
Leon
@clexpectation
Mar 03 2017 03:21
???
DavHobbs
@DavHobbs
Mar 03 2017 03:21
@revisualize thank you
CamperBot
@camperbot
Mar 03 2017 03:21
replymedia sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3407 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 03 2017 03:21
@clexpectation You don't return console.log
@Nayenne I was just trying to offer a suggestion. I was trying to figure what's going on... I can't figure out your problem.
DavHobbs
@DavHobbs
Mar 03 2017 03:22
@revisualize Do you know how I can print out each iteration so I can see what is happening through each iteration?
Leon
@clexpectation
Mar 03 2017 03:23
@revisualize don't know
Joseph
@revisualize
Mar 03 2017 03:23
@clexpectation You don't know that you do not return console.log()?
@clexpectation Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.
Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
Leon
@clexpectation
Mar 03 2017 03:24
yes
Joseph
@revisualize
Mar 03 2017 03:24
@clexpectation Well, let me tell you.. You don't return console.log() ...
@clexpectation You either have a console.log() ... or a return statement.. You don't combine the two.
Nayenne Abgail
@Nayenne
Mar 03 2017 03:31
@revisualize hey, i know what you mean now, someone actually suggested that i add z index to my .bump class and it worked =] just need to tweak it now
@revisualize thanks
CamperBot
@camperbot
Mar 03 2017 03:31
nayenne sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3408 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 03 2017 03:31
@Nayenne I was just spitting an idea when I I was first looking at the code.
Joseph
@revisualize
Mar 03 2017 03:37
Okay. I'm still at work.
I need to leave.
Leon
@clexpectation
Mar 03 2017 03:45
@revisualize if(count>0){
return count + " Bet";
}
else{
return count +" Hold";
}
Mac
@itchick85
Mar 03 2017 03:47
whats wrong tried time and time again Compound Assignment With Augmented Addition
a += 15 +3 + 12;
b += 26 + 9 + 17;
c += 19 +12 + 7;
DavHobbs
@DavHobbs
Mar 03 2017 03:47

HOW DO I PRINT OUT THE longest word and also the value at the same time?

function findLongestWord(str) {
var splitWord = str.split(' ');
var longestString = 0;

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

return longestString;
}

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

ESLMiguel
@ESLMiguel
Mar 03 2017 03:48
hello all :wave:
Robert Richey
@0x0936
Mar 03 2017 03:51
@ESLMiguel :wave:
@replymedia read the directions again. it only wants the length of the longest word
DavHobbs
@DavHobbs
Mar 03 2017 03:53
@revisualize I know but I am trying to learn some more and am playing around with my understanding
Robert Richey
@0x0936
Mar 03 2017 03:54
@itchick85 the directions are saying, for the lines below // Only modify code below this line to change them into using compound addition. Instead of a = a + 12; what does that statement look like when using the += operator?
ESLMiguel
@ESLMiguel
Mar 03 2017 03:57
i got a c9 account and starting a git page. i guess im going all in :smirk_cat:
Robert Richey
@0x0936
Mar 03 2017 03:58
@ESLMiguel you don't need to go "all in" with a gomix.me account (free, no cc on registration)
ESLMiguel
@ESLMiguel
Mar 03 2017 03:58
@0x0936 but i cant do a lot of the fcc lessons/projects without a c9 page
DavHobbs
@DavHobbs
Mar 03 2017 03:58

@revisualize Do you know how the inner array is incrementing through? I am getting stuck on the increment value i=0 being the same as the i within the inner array

for (var i = 0; i < splitWord.length; i++) {
if (splitWord[i].length > longestString) {
longestString = splitWord[i].length;

Robert Richey
@0x0936
Mar 03 2017 03:59
@ESLMiguel you don't need c9 at all
Joseph
@revisualize
Mar 03 2017 03:59
@replymedia You don't need to.
Robert Richey
@0x0936
Mar 03 2017 03:59
c9 is an optional challenge, but all the backend projects can use whatever you want
Joseph
@revisualize
Mar 03 2017 03:59
@replymedia What inner array?
@replymedia There is only 1 array
DavHobbs
@DavHobbs
Mar 03 2017 04:00

function findLongestWord(str) {
var splitWord = str.split(' ');
var longestString = 0;

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

return longestString;
}

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

Joseph
@revisualize
Mar 03 2017 04:00
@replymedia There is only 1 array.
ESLMiguel
@ESLMiguel
Mar 03 2017 04:00
@0x0936 well, i already got one. i can delete the account later i guess
are other (free) ide's better than c9?
eyesore-
@eyesore-
Mar 03 2017 04:00
If anyone needs help hit me up.
DavHobbs
@DavHobbs
Mar 03 2017 04:00
@revisualize I am looking at splitWord[i] and wondering how the i increments through the loop.
eyesore-
@eyesore-
Mar 03 2017 04:01
@ESLMiguel You don't like text editors?
ESLMiguel
@ESLMiguel
Mar 03 2017 04:01
@eyesore- i have brackets
Robert Richey
@0x0936
Mar 03 2017 04:01
@ESLMiguel probably. just make sure you're paying attention to the terms of use. you don't want your cc getting charged if your website exceeds some bandwidth - and it probably won't, unless someone decides to randomly DDoS your site
eyesore-
@eyesore-
Mar 03 2017 04:02
@ESLMiguel Brackets is cool. I use Atom. I know a ton of people love VS Code and Webstorm, but Webstorm is subscription based.
ESLMiguel
@ESLMiguel
Mar 03 2017 04:02
@0x0936 good to know... i thought it was a bit sketchy that they require a cc
maybe i will just do the tutorials and cancel it
@eyesore- can i do all the backend stuff with just brackets or atom?
Robert Richey
@0x0936
Mar 03 2017 04:03
@ESLMiguel c9 is owned by Amazon now. afaik, it's all free until bandwidth limits are exceeded, then the cc gets charged
eyesore-
@eyesore-
Mar 03 2017 04:04
@ESLMiguel What do you mean? Like spinning up a VM?
Robert Richey
@0x0936
Mar 03 2017 04:05
@ESLMiguel no, you cannot do the backend projects with only brackets or atom - those are text editors. you need a persistent server for those backend challenges (gomix.me is the best offering atm)
eyesore-
@eyesore-
Mar 03 2017 04:05
@ESLMiguel You may have to ignore me on that because FCC may have you do it with presets or a build tool.
ESLMiguel
@ESLMiguel
Mar 03 2017 04:06
@eyesore- i just mean being able to every required fcc challenge
@0x0936 thanks for all the info
CamperBot
@camperbot
Mar 03 2017 04:06
eslmiguel sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star2: 2680 | @0x0936 |http://www.freecodecamp.com/0x0936
eyesore-
@eyesore-
Mar 03 2017 04:06
@ESLMiguel With that being said. You should also look into actually writing your backend from scratch using Express or something like that. Trust me it will really help you.
@ESLMiguel It will give you experience on the terminal as well.
ESLMiguel
@ESLMiguel
Mar 03 2017 04:08
@eyesore- any good docs or tuts i can start with?
Leon
@clexpectation
Mar 03 2017 04:08
@replymedia function findLongestWord(str) {
var splitWord = str.split(' ');
var longestString = 0;
var j=0;
for (var i = 0; i < splitWord.length; i++) {
if (splitWord[i].length > longestString) {
longestString = splitWord[i].length;
j=i;
}
}
return longestString + splitWord[j];
}
findLongestWord("The quick brown fox jumped over the lazy dog");
ESLMiguel
@ESLMiguel
Mar 03 2017 04:08
assume i should start somewhere like here?
https://expressjs.com/en/starter/basic-routing.html
I have 0 experience in this stuff btw (besides what i have done on c9 so far today)
eyesore-
@eyesore-
Mar 03 2017 04:10
@ESLMiguel Yeah, that works hahah https://expressjs.com/en/starter/hello-world.html I believe there is a Node lesson in FCC. That is kind of a start point.
Robert Richey
@0x0936
Mar 03 2017 04:11
@ESLMiguel check out any of the youtube videos also. some of them may be a little out dated, but they should all help give you an idea of what's going on with Node Express
my favorites from that list are Derek Banas, LearnCode.academy, and TheNewBoston
ESLMiguel
@ESLMiguel
Mar 03 2017 04:12
@0x0936 ive taught myself most of what i didnt learn from fcc via youtube
Robert Richey
@0x0936
Mar 03 2017 04:12
same
ESLMiguel
@ESLMiguel
Mar 03 2017 04:12
i have an hour commute to/from work so lots of time for YT
Derek Banas is the shit
Robert Richey
@0x0936
Mar 03 2017 04:13
yus
Jason Luboff
@JLuboff
Mar 03 2017 04:13
I find it hard to stay focused on videos a lot of times, albeit I know they're great resources
ESLMiguel
@ESLMiguel
Mar 03 2017 04:14
never seen a person be able to fill a 300 page book into an hour video before lol
Robert Richey
@0x0936
Mar 03 2017 04:14
Derek Banas videos are like watching at 2x by default
with normal speech - content flies
ESLMiguel
@ESLMiguel
Mar 03 2017 04:15
there should be a beginners guide to Banas tuts
step 1: get out a notebook and a pen
step 2: put your mouse cursor over the pause button
step 3:...
eyesore-
@eyesore-
Mar 03 2017 04:15
@ESLMiguel if you get super stuck on setting up servers or deployment shoot me an email and I will help you out if you'd like.
Robert Richey
@0x0936
Mar 03 2017 04:16
@ESLMiguel yep :+1: :)
Jason Luboff
@JLuboff
Mar 03 2017 04:16
I'll check out derek banas...see what I think
DavHobbs
@DavHobbs
Mar 03 2017 04:17
@revisualize Thank you
CamperBot
@camperbot
Mar 03 2017 04:17
:warning: replymedia already gave revisualize points
replymedia sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
ESLMiguel
@ESLMiguel
Mar 03 2017 04:19
@eyesore- thanks so much for the offer. I will see how far I get on my own first, but will definitely keep that in mind
CamperBot
@camperbot
Mar 03 2017 04:19
eslmiguel sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 64 | @eyesore- |http://www.freecodecamp.com/eyesore-
eyesore-
@eyesore-
Mar 03 2017 04:19
@ESLMiguel Yeah, of course! Happy to help.
Joseph
@revisualize
Mar 03 2017 04:23
@ESLMiguel Do you know that you can just hit the k key on your keyboard or the spacebar to pause youtube videos?
Jason Luboff
@JLuboff
Mar 03 2017 04:24
@revisualize what if I have no keyboard?
ESLMiguel
@ESLMiguel
Mar 03 2017 04:24
@revisualize knew about spacebar. not about k though. was just part of the joke lol
Dave Junta
@dijital2016
Mar 03 2017 04:33
Can anyone help? My primes array isn't increasing....like [2,2,2,2,2,]
https://codepen.io/Hoonta/pen/xqVPWw
Jeff
@Garanimal
Mar 03 2017 04:40
@dijital2016 your pretty far ahead of me but what is the purpose of the console.log(primes) in your second function?
mitron6
@mitron6
Mar 03 2017 04:47
@dijital2016 The problem is caused because your two loops on i are using the global variable i. The loops should be written as for (var i=...) with the varbefore the i so each loop uses its own i variable. Also you need to move the return true in the isPrime function outside the loop.
Parvesh garg
@parveshgarg24
Mar 03 2017 04:50
anyone send the task code 205 of testing objects for properties
__SharifTarver__
@Sharifdesigns22
Mar 03 2017 04:51

``` so confused right now // Setup
function testStrictNotEqual(val) {
// Only Change Code Below this Line

if (val)

// Only Change Code Above this Line

return "Not Equal";

}
return "Equal";
}

// Change this value to test
testStrictNotEqual(12); ```

Comparison with strict inequality Operator
mitron6
@mitron6
Mar 03 2017 04:52
@Sharifdesigns22 What is the name of this exercise?
__SharifTarver__
@Sharifdesigns22
Mar 03 2017 04:53
"Comparison with strict inequality operator
*"
Saif Eldin
@saifeldin87
Mar 03 2017 04:54
can somebody help me to know, why I am getting this error: "Cannot read property 'toLowerCase' of undefined"
while running the code, in my "Title Case a Sentence" challenge ?\
mitron6
@mitron6
Mar 03 2017 04:54
@Sharifdesigns22 So look at examples in the yellow box. Do you understand what these examples mean?
__SharifTarver__
@Sharifdesigns22
Mar 03 2017 04:55
Yeah I understand @mitron6 are they values that I should test? how can i declare them in this function?
the test example doesn't really give me much context
mitron6
@mitron6
Mar 03 2017 04:56

@Sharifdesigns22 So

Add the strict inequality operator to the if statement so the function will return "Not Equal" when val is not strictly equal to 17

heroiczero
@heroiczero
Mar 03 2017 04:56
@saifeldin87 try lowercasing the the whole string then try using https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice maybe
__SharifTarver__
@Sharifdesigns22
Mar 03 2017 04:56
if (17 !== "17") @mitron6 Like so?
mitron6
@mitron6
Mar 03 2017 04:56
@Sharifdesigns22 Not exactly.
Saif Eldin
@saifeldin87
Mar 03 2017 04:57
ok I will try it now @heroiczero
__SharifTarver__
@Sharifdesigns22
Mar 03 2017 04:57
What am I missing @mitron6 ?
mitron6
@mitron6
Mar 03 2017 04:57
@Sharifdesigns22 How could you write val does not strictly equal 17?
Dave Junta
@dijital2016
Mar 03 2017 04:58
@Garanimal I wanted to see what the primes array looked like at that point
__SharifTarver__
@Sharifdesigns22
Mar 03 2017 04:58
val !== 17 how about that @mitron6
Dongtu
@Dongtuhust
Mar 03 2017 04:58
help me!!!!

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

// Only change code below this line
result= {
"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");

mitron6
@mitron6
Mar 03 2017 04:58
@dijital2016 Hi Dave. I've given you the solutions in two different chat rooms. Ask me if you don't understand them, right?
@Sharifdesigns22 Right. That is the solution. Put that in the if statement and test it.
heroiczero
@heroiczero
Mar 03 2017 04:59
@Dongtuhust gotta use val for your result
Dave Junta
@dijital2016
Mar 03 2017 05:00
Thank you @mitron6 ! That did it!
CamperBot
@camperbot
Mar 03 2017 05:00
dijital2016 sends brownie points to @mitron6 :sparkles: :thumbsup: :sparkles:
__SharifTarver__
@Sharifdesigns22
Mar 03 2017 05:00
@mitron6 that's simple enough thanks. Although it still hasn't gone through here's the code
CamperBot
@camperbot
Mar 03 2017 05:00
:cookie: 549 | @mitron6 |http://www.freecodecamp.com/mitron6
sharifdesigns22 sends brownie points to @mitron6 :sparkles: :thumbsup: :sparkles:
:cookie: 550 | @mitron6 |http://www.freecodecamp.com/mitron6
__SharifTarver__
@Sharifdesigns22
Mar 03 2017 05:00

``` function testStrictNotEqual(val) {
// Only Change Code Below this Line

if (val!== 17)

// Only Change Code Above this Line

return "Not Equal";

}
return "Equal";
}

// Change this value to test
testStrictNotEqual(12); ```

Parvesh garg
@parveshgarg24
Mar 03 2017 05:00
@Dongtuhust
Dongtu
@Dongtuhust
Mar 03 2017 05:00
I dont undertand
help me right code
mitron6
@mitron6
Mar 03 2017 05:00
@Sharifdesigns22 You need a space val !== 17
Saif Eldin
@saifeldin87
Mar 03 2017 05:01
Thanks @heroiczero
CamperBot
@camperbot
Mar 03 2017 05:01
saifeldin87 sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:cookie: 917 | @heroiczero |http://www.freecodecamp.com/heroiczero
mitron6
@mitron6
Mar 03 2017 05:02
@Sharifdesigns22 if (val !== 17)... . Should be working now?
__SharifTarver__
@Sharifdesigns22
Mar 03 2017 05:02
@mitron6 that helped plus there was a return statement outside of my bracket. Much appreciated
Dongtu
@Dongtuhust
Mar 03 2017 05:03
not run

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

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

// Only change code above this line
return result[val];
}

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

Dave Junta
@dijital2016
Mar 03 2017 05:03
@mitron6 I also learned the point about using var i = 0 in for loops. Never knew that until tonight. Thanks!
CamperBot
@camperbot
Mar 03 2017 05:03
dijital2016 sends brownie points to @mitron6 :sparkles: :thumbsup: :sparkles:
:warning: dijital2016 already gave mitron6 points
Parvesh garg
@parveshgarg24
Mar 03 2017 05:05
@Dongtuhust send the task name
heroiczero
@heroiczero
Mar 03 2017 05:06

@Dongtuhust

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

not result should be var lookup .

Leon
@clexpectation
Mar 03 2017 05:06

@parveshgarg24 // Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

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

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

heroiczero
@heroiczero
Mar 03 2017 05:10
@clexpectation that looks right :confused:
Joseph
@revisualize
Mar 03 2017 05:11
@clexpectation What's your issue?
eyesore-
@eyesore-
Mar 03 2017 05:11
@clexpectation What error are you getting? You've got styling no-no's, but it shouldn't stop the code
from running
Joseph
@revisualize
Mar 03 2017 05:11
@Dongtuhust The object should be named lookup .. That's in the instructions.
Aaron Dwayne Gebana
@adgebana
Mar 03 2017 05:11

Hi. I'm currently on the Check for Palindrome challenge, I have a quick question on regular expressions.

The challenge wants me to convert the input string into lower case and only alphanumeric characters. What I did:
function palindrome(str) {
// Good luck!
// What we want: lowercase, remove symbols, only alphanumeric

str = str.toLowerCase();

// to remove symbols, convert it into an array first
var regex = /\w/;
var strArray = str.split(regex);

My question is, my regex uses \w and I read that \w includes underscore. I do not want to include underscore, how would I go about making a regex like \w but without underscore?

icodeyouso
@icodeyouso
Mar 03 2017 05:11
would anyone happen to know the best way to write java code using javascript?..i have a hackathon tomorrow and its pretty much android(which is in java)and i dont know very much java. thanks
jSwtch
@jSwtch
Mar 03 2017 05:12
@icodeyouso java is different from js
Joseph
@revisualize
Mar 03 2017 05:12
@icodeyouso You can't write Java using JavaScript
@icodeyouso They aren't even related
Ken Haduch
@khaduch
Mar 03 2017 05:13
@Dongtuhust - @heroiczero was right about the name of the object, it should be var lookup, and then you just have to get a value into the result variable before it is returned. The line will start with result = and you have to access thelookup object with the val variable - the example in the lesson shows you the idea of what you should do, you just have to use the elements in the code and assign to the result variable.
eyesore-
@eyesore-
Mar 03 2017 05:13
@icodeyouso You would have to use something like React Native or Ionic.
__SharifTarver__
@Sharifdesigns22
Mar 03 2017 05:13

function testGreaterThan(val) {
if (val > 100) {
return "Over 100";
}

if (val > 10 ) {
return "Over 10";
}

if (val < 10 )
return "10 or Under";
}

// Change this value to test
testGreaterThan(10);

What's wrong with my code?
eyesore-
@eyesore-
Mar 03 2017 05:14
@icodeyouso it all depends on what framework you want to use.
Dongtu
@Dongtuhust
Mar 03 2017 05:14
@revisualize thanks I understanded.. I made a mistake ";" "," :smile:
CamperBot
@camperbot
Mar 03 2017 05:14
dongtuhust sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3409 | @revisualize |http://www.freecodecamp.com/revisualize
icodeyouso
@icodeyouso
Mar 03 2017 05:14
maybe i asked that wrong..im aware they are totally different..i guess what im asking is there a way i can use my javascript knowledge to help me somewhat implement it into writing java
Dongtu
@Dongtuhust
Mar 03 2017 05:14
@camperbot thanks u :))
CamperBot
@camperbot
Mar 03 2017 05:14
dongtuhust sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 3058 | @camperbot |http://www.freecodecamp.com/camperbot
jSwtch
@jSwtch
Mar 03 2017 05:14
@adgebana replace(/[^a-z|0-9]/g, '');
Dongtu
@Dongtuhust
Mar 03 2017 05:15
code right

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"
};
result=lookup[val];

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

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

Joseph
@revisualize
Mar 03 2017 05:15
@icodeyouso .... Do you realize that Java and JavaScript are NOT at all the same.
jSwtch
@jSwtch
Mar 03 2017 05:15
@icodeyouso I think your problem solving logic should transfer - syntax is different
heroiczero
@heroiczero
Mar 03 2017 05:15
@Dongtuhust yep looks right :+1:
Joseph
@revisualize
Mar 03 2017 05:15
@icodeyouso Just because JavaScript have Java in the name.. ... That's about it.
Jeff
@Garanimal
Mar 03 2017 05:15
can i get some help understanding the signifigance of the last 0 in this code
var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.

singleVal = array.reduce(function(previousVal, currentVal){
  return previousVal-currentVal;},0);
icodeyouso
@icodeyouso
Mar 03 2017 05:15
@jswtch n thanks alot , no sleep tonight but this could help
CamperBot
@camperbot
Mar 03 2017 05:15
icodeyouso sends brownie points to @jswtch :sparkles: :thumbsup: :sparkles:
:cookie: 306 | @jswtch |http://www.freecodecamp.com/jswtch
eyesore-
@eyesore-
Mar 03 2017 05:15
@icodeyouso Yes you can. Majority of languages have the same fundamentals so you would just have to change your way of thinking a bit.
Aaron Dwayne Gebana
@adgebana
Mar 03 2017 05:16
Ohh, thanks @jswtch
CamperBot
@camperbot
Mar 03 2017 05:16
adgebana sends brownie points to @jswtch :sparkles: :thumbsup: :sparkles:
:cookie: 307 | @jswtch |http://www.freecodecamp.com/jswtch
jSwtch
@jSwtch
Mar 03 2017 05:16
@adgebana np ;)
eyesore-
@eyesore-
Mar 03 2017 05:17
@icodeyouso Java will confuse the shit out of you because it uses a ton of extras, but you can still make correlations.
Joseph
@revisualize
Mar 03 2017 05:18
@icodeyouso You need to change your question and your thought process.. First when they called JavaScript ... JavaScript it was a marketing ploy because Java was popular at the time.
@icodeyouso Second... Let's just dive into it.
jSwtch
@jSwtch
Mar 03 2017 05:18
Hey can someone please help me with this - I am finishing twitch api - I got everything working except my offline/online status. I tried creating a sperate call to function and now I dont understand why the function is even running while I have commented out the call (line 50)
https://codepen.io/jswtch/pen/dvooaR?editors=0010
icodeyouso
@icodeyouso
Mar 03 2017 05:19
i was totally unaware that java and javascript are not related..geeze i let those names get the best of me
Joseph
@revisualize
Mar 03 2017 05:19
@icodeyouso A function is a function. A for loop is a for loop. A while loop is a while loop. A variable is a variable. A class is a class. A try catch finally is a try catch finally. The concepts are all the same.. How they are implemented may be different but, the idea behind them are the same.
icodeyouso
@icodeyouso
Mar 03 2017 05:20
 hmmm i like your explanation please continue @jswtch 
Joseph
@revisualize
Mar 03 2017 05:20
@icodeyouso Number in JavaScript may be an int or a float or a whatever in Java. (I don't actually know Java.) But, the concept of what they are is the same.
eyesore-
@eyesore-
Mar 03 2017 05:20
@icodeyouso Yeah, whatever way you look at it I would advice to not master a language, but to master the concepts behind them. That way you can easily go from one to another.
Joseph
@revisualize
Mar 03 2017 05:21
@icodeyouso So, as you look at migrating from JavaScript to programming in Java or really any other language for that matter.. You just have to have a core understanding of programming in general.
icodeyouso
@icodeyouso
Mar 03 2017 05:21
@eyesore- that seems to make more sense thanks
CamperBot
@camperbot
Mar 03 2017 05:21
icodeyouso sends brownie points to @eyesore- :sparkles: :thumbsup: :sparkles:
:cookie: 65 | @eyesore- |http://www.freecodecamp.com/eyesore-
Joseph
@revisualize
Mar 03 2017 05:22
@icodeyouso
How do I make a function call?
How do I make a for loop?
How do I make a while loop?
When do I use a while loop instead of a for loop?
How do I write a try catch?
How do I make if / else if / else statements?
How are conditional statements written?
NaveenRathor
@NaveenRathor
Mar 03 2017 05:22

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

switch (val) {
case 1:
answer = "Marley";
break;
case 2:
answer = "The Answer";
break;
case 3:
answer = "There is no #1";
break;
case 4:
answer = "Missed me by this much!";
break;
default:
answer = "Ate Nine";
}

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

// Change this value to test
chainToSwitch(7);

eyesore-
@eyesore-
Mar 03 2017 05:22
@icodeyouso No problem!
NaveenRathor
@NaveenRathor
Mar 03 2017 05:22
what's wrong in my code
Joseph
@revisualize
Mar 03 2017 05:23
@icodeyouso All of these concepts should be familiar to you in JavaScript.. It's just how do you do ... x ... in the new language.
@NaveenRathor Make sure your strings are EXACT?
jSwtch
@jSwtch
Mar 03 2017 05:23
@NaveenRathor check upper lower case spellings
NaveenRathor