These are chat archives for FreeCodeCamp/HelpJavaScript

28th
Mar 2017
silver537
@silver537
Mar 28 2017 00:00
it's simple,
move
return "No such contact";
outside the loop
done
you pass
FlashHero
@FlashHero
Mar 28 2017 00:00
thanks @SkyCoder01
CamperBot
@camperbot
Mar 28 2017 00:00
flashhero sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 720 | @skycoder01 |http://www.freecodecamp.com/skycoder01
odm275
@odm275
Mar 28 2017 00:00

$(document).ready(function(){
var favoriteStreamers = ["nakat","rushhoursmash","ESL_SC2","lof_hackoru","fightsolfight"];

for(var i=0; i<favoriteStreamers.length; i++){
$.ajax({
///
success: function(data){
if(data.stream===null){
console.log("Offline "+ favoriteStreamers[i]);
}else{
console.log("Online "+data.stream.channel.name); //This works
}

}

why is the offline case returning me undefined?
when i try to access favoriteStreamers[i]
Gulsvi
@gulsvi
Mar 28 2017 00:01
@FlashHero No problem :)
odm275
@odm275
Mar 28 2017 00:01
if i try favoriteStreamers[0] it works
so i can def access the array
FlashHero
@FlashHero
Mar 28 2017 00:05
@SkyCoder01 I target the last thing in the input but I can't get it to work
$(document).ready(function () {
$('.the-button').click(function () {
$('#the-input').val($('#the-input').val() + $(this).text());
});
$('#equals').click(function () {
var arr= $('#the-input').val().split('');
if (arr.slice(-1) == '/', '*', '+', '-') {
arr= arr.pop().join();
}
$('#the-input').val(eval(arr));
});
$("#del").click(function () {
$('#the-input').val('');
});
}); Can anyone help me
Gulsvi
@gulsvi
Mar 28 2017 00:11
@FlashHero I don't think this comparison will work: arr.slice(-1) == '/', '*', '+', '-' you should use a regular expression or put those operators in an array and see if you get .indexOf() greater than -1
ivorygrant
@ivorygrant
Mar 28 2017 00:12
@silver537 lol, sorry i'm not getting it. is it possible it's not working because i have bad brackets somewhere?
FlashHero
@FlashHero
Mar 28 2017 00:13
ok
silver537
@silver537
Mar 28 2017 00:13
@ivorygrant unless you're getting errors then no.
ivorygrant
@ivorygrant
Mar 28 2017 00:13
i don't see any errors on the margin/squigly red lines
silver537
@silver537
Mar 28 2017 00:14
press F12
and then run your code
ivorygrant
@ivorygrant
Mar 28 2017 00:15
pressed f12 then ctrl enter to turn, nothing?
silver537
@silver537
Mar 28 2017 00:15
then your logic is off
keep trying :P
ivorygrant
@ivorygrant
Mar 28 2017 00:16
  var i;
  for (i=0; i<=contacts.length; i++){

    if (contacts[i].firstName===firstName) 

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

          return contacts[i][prop];

        }


    else{

      return "No such property";
    }

  }

  return "No such contact";
it's outside the for loop
silver537
@silver537
Mar 28 2017 00:18
then it should work
post the whole code
ivorygrant
@ivorygrant
Mar 28 2017 00:19
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

    if (contacts[i].firstName===firstName) 

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

          return contacts[i][prop];

        }


    else{

      return "No such property";
    }

  }

  return "No such contact";

// Only change code above this line
}


// Change these values to test your function
lookUpProfile("Akira", "likes");
I thought there was a curly brace missing after the first if statement but i receive no error to indicate so
silver537
@silver537
Mar 28 2017 00:21
which one doesn't pass?
ivorygrant
@ivorygrant
Mar 28 2017 00:21
the only statement that doesn't pass is "bob" "number" which should return "No such contact"
silver537
@silver537
Mar 28 2017 00:24
@ivorygrant your code is right. but there is a minor error
logical error
ivorygrant
@ivorygrant
Mar 28 2017 00:24
the strict === operator?
silver537
@silver537
Mar 28 2017 00:24
@ivorygrant no
let me ask you this; is there a fourth index?
ivorygrant
@ivorygrant
Mar 28 2017 00:25
from 0-3
there are 4 contacts
silver537
@silver537
Mar 28 2017 00:26
@ivorygrant so why is this a problem? i=0; i<=contacts.length; i++
ivorygrant
@ivorygrant
Mar 28 2017 00:26
if i don't put the <= wouldn't it not catch the last member? that's why i put that
silver537
@silver537
Mar 28 2017 00:26
what does contacts.length return?
4 right?
ivorygrant
@ivorygrant
Mar 28 2017 00:27
yes
silver537
@silver537
Mar 28 2017 00:27
so is it possible to get contacts[4].firstname?
ivorygrant
@ivorygrant
Mar 28 2017 00:27
no
there is no fifth index
silver537
@silver537
Mar 28 2017 00:27
fourth*
ivorygrant
@ivorygrant
Mar 28 2017 00:28
0, 1, 2, 3
silver537
@silver537
Mar 28 2017 00:28
exactly. but your code is trying to access
0, 1, 2, 3, 4
because 4 is less than OR equal to 4, so it's true, and the code will try to access 4.
take away the = so the loop will stop at 3
ivorygrant
@ivorygrant
Mar 28 2017 00:31
yep I get that, but maybe i'm not understanding that logic. If there are 4 contacts, and the array has length of 4, i want to hit on all 4 four of those.
silver537
@silver537
Mar 28 2017 00:31
yea but "how many elements in an array", is different than accessing the array's indices
ivorygrant
@ivorygrant
Mar 28 2017 00:32
i see, so that means contacts.length is zero based
silver537
@silver537
Mar 28 2017 00:33
no. indicies are zero based
DomLeong
@DomLeong
Mar 28 2017 00:33
i needhelp with this code
ivorygrant
@ivorygrant
Mar 28 2017 00:33
OH OH OK
DomLeong
@DomLeong
Mar 28 2017 00:33
You should use two double quotes (") and four escaped double quotes (\").
Variable myStr should contain the string: I am a "double quoted" string inside "double quotes".
silver537
@silver537
Mar 28 2017 00:33
1,2,3,4 <- elements in the array
0,1,2,3 <- indices of those elements
DomLeong
@DomLeong
Mar 28 2017 00:33
my code is "var myStr=I am a "double quoted" string inside "double quotes".; // Change this line"
ivorygrant
@ivorygrant
Mar 28 2017 00:33
got it!!!
i confused that
so i=0 is starting from the index
silver537
@silver537
Mar 28 2017 00:34
@ivorygrant index 0 yes
@DomLeong how do you declare a string? there are two ways
ivorygrant
@ivorygrant
Mar 28 2017 00:35
@silver537 thank you so very much
CamperBot
@camperbot
Mar 28 2017 00:35
ivorygrant sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 901 | @silver537 |http://www.freecodecamp.com/silver537
silver537
@silver537
Mar 28 2017 00:35
@ivorygrant no problem. study your code and go back to the previous challenges for a refresher. cause coding is very logically specific.
ivorygrant
@ivorygrant
Mar 28 2017 00:37
@silver537 i struggled mightily on this exercise as it took me a while to figure it out, but in the end i wrote it up without cheating so I definitely think i'm getting it. even if it took me a while :D
yes will do!
silver537
@silver537
Mar 28 2017 00:38
getting the answers is fine, as long as your study those answers.
and always ask your self why when looking at other people's answers
juni
@junipberry
Mar 28 2017 00:42
hi @silver537, can you help me figure out what I did wrong in my Profile lookup section
ivorygrant
@ivorygrant
Mar 28 2017 00:42
LOL
silver537
@silver537
Mar 28 2017 00:42
@ivorygrant i think you can take it from here :P
ivorygrant
@ivorygrant
Mar 28 2017 00:42
hahahha perfect, I will!
silver537
@silver537
Mar 28 2017 00:42
@junipberry post your code
juni
@junipberry
Mar 28 2017 00:43
function lookUpProfile(firstName, prop) {

  contacts.hasOwnProperty("firstName");
  contacts.hasOwnProperty("prop");

if (firstName === true) {
  return contacts.hasOwnProperty("firstName");
}  

else if (firstName === false) {
    return "No such contact";
  }  
else {
    return "No such property";
}
// Only change code above this line
}
silver537
@silver537
Mar 28 2017 00:44
@junipberry what does your code do?
juni
@junipberry
Mar 28 2017 00:46
@silver537
First checks to see if “firstName” exists, then checks for its prop. Then I applied the if/else statement to apply the conditionals as stated in the instructions. But I’m afraid I’m not sure about how to correctly check for the other properties other than the “firstName” section
I didn’t know what to call it, so just left it at prop
ivorygrant
@ivorygrant
Mar 28 2017 00:48
@junipberry so in this case, we are given an array of items to check, not just one object
juni
@junipberry
Mar 28 2017 00:48
oh, so I should check all the arrays within that object..
Stephen James
@sjames1958gm
Mar 28 2017 00:49
@junipberry Isn't contacts an array?
@junipberry The other way check all the objects in the array.
Ricardo G.
@Rubenricardo
Mar 28 2017 00:50
hey guys
some help

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

function checkObj(checkProp) {
// Your Code Here
myObj.hasOwnProperty(checkProp);

return "Not Found";
}

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

does anyone knoe what am i doing wrong?
checkObj("gift") should return "pony".
checkObj("pet") should return "kitten"
i cannot get it to give me a true statement
ivorygrant
@ivorygrant
Mar 28 2017 00:51
@junipberry so currently your code reads, as if someone gave you one specific contact to check if that exists. but practically you'd want to check against the whole phonebook.
juni
@junipberry
Mar 28 2017 00:52
@sjames1958gm , ok ty will try that
CamperBot
@camperbot
Mar 28 2017 00:52
junipberry sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6395 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Mar 28 2017 00:52
@junipberry good luck
juni
@junipberry
Mar 28 2017 00:52
ty!
Stephen James
@sjames1958gm
Mar 28 2017 00:53
@Rubenricardo hasOwnProperty returns a boolean - but you need an if statement to test that boolean
juni
@junipberry
Mar 28 2017 00:53
ok, thanks @ivorygrant
CamperBot
@camperbot
Mar 28 2017 00:53
junipberry sends brownie points to @ivorygrant :sparkles: :thumbsup: :sparkles:
:cookie: 218 | @ivorygrant |http://www.freecodecamp.com/ivorygrant
ivorygrant
@ivorygrant
Mar 28 2017 00:53
@junipberry i just got done completing this exercise with tons of help so i can try to answer your questions
juni
@junipberry
Mar 28 2017 00:54
awesome, thats cool you figured it out! I’ll try to redo it and come back if I get stuck again ;)
FlashHero
@FlashHero
Mar 28 2017 00:54
$(document).ready(function () {
$('.the-button').click(function () {
$('#the-input').val($('#the-input').val() + $(this).text());
});
$('#equals').click(function () {
var arr = $('#the-input').val().split('');
for (var i = 0; i < arr.length; i++) {
if (arr[i].lastIndexOf('/', '*', '+', '-') == -1) {
arr = arr.pop().toString();
}
}
$('#the-input').val(eval(arr));
});
$("#del").click(function () {
$('#the-input').val('');
});
});
Can anyone help me, I'm trying to delete the last thing in the input if it's an operator
Doni Yafi
@yafiwebdev
Mar 28 2017 00:56
hi guys :D
Ray Martinez
@rayjrm
Mar 28 2017 00:56

function truncateString(str, num) {

  if (str.length <= 3) {
    console.log("less than or three");
    return str.slice(0, num) + "...";
  } 

  else if (str.length > num) {
    console.log("greater than num");
    return str.slice(0, num - 3) + "...";
  } else {
    return str;    
  }

}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Met every test case except "truncateString("Absolutely Longer", 2) should return "Ab..."." How is it slipping by? Thanks
console logs are just for my own testing
Joseph
@revisualize
Mar 28 2017 00:58
Hi.
Ciuleafarul
@Ciuleafarul
Mar 28 2017 00:59
function largestOfFour(arr) {
  // You can do this!
  var rok = arr.max;
  var mare =0;

  for (i=0; i < arr.max; i++) {
    if (mare[i].max > rok);
    rok = mare[i].max;
  }
  return mare;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
hey guys, need some help with this challenge
this is the best i could think of so far
Ray Martinez
@rayjrm
Mar 28 2017 01:00
I dodnt think you should use max
i would use a loop to cycle through the items, and push them into a new array
Joseph
@revisualize
Mar 28 2017 01:01
It is an array of objects.
Ray Martinez
@rayjrm
Mar 28 2017 01:01
no, its an array of arrays
Ciuleafarul
@Ciuleafarul
Mar 28 2017 01:01
is that Math.max method i know about for situations u have to find mx number from an array
@rayjrm what loop? for ?
Ray Martinez
@rayjrm
Mar 28 2017 01:03
i only used loops and push() for this challenge
so your first loop should cycle through the arr
and a second loop should cycle through each array inside arr
Gulsvi
@gulsvi
Mar 28 2017 01:04
@FlashHero You're on an advanced Front-end project it looks like - you probably want to do some more studying on .replace(), .indexOf(), and .lastIndexOf() to make it an easier assignment. Here's one way to do it: $('#the-input').val().replace(/[+|-|*|\/]$/,'');. I'm not that far yet, so there might be better ways to do it.
That regular expression will remove a +,-, *, or / if it is at the end of the string.
Andy Em
@andyemnem63
Mar 28 2017 01:04
anybody else working on the Roman Numeral Converter Challenge ?
Ciuleafarul
@Ciuleafarul
Mar 28 2017 01:06
@rayjrm so the first loop should be smth like for (i=0; i<arr; i++); ?
Ray Martinez
@rayjrm
Mar 28 2017 01:07
Yep!
FlashHero
@FlashHero
Mar 28 2017 01:08
@SkyCoder01 I'm just doing this because I'm learning jquery so I was just trying to make something but anyway thanks
CamperBot
@camperbot
Mar 28 2017 01:08
flashhero sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 723 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Ray Martinez
@rayjrm
Mar 28 2017 01:08
and your second loop will run through the four arrays, you can then push the highest number into a new array using conditional state ments @Ciuleafarul
the new array is what you'll return
Olivier
@blindman78
Mar 28 2017 01:10
// Example
var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop(); 
// removedFromOurArray now equals 3, and ourArray now equals [1,2]

// Setup
var myArray = [["John", 23], ["cat", 2]];

// Only change code below this line.
var n = myArray[1];
var a = [[myArray[1]],[myArray[0]]];
myArray = a.pop();
var removedFromMyArray = n;
Hello i have a bug for Manipulate Arrays With pop ;my 2nd instrution is not validate why ?
Ciuleafarul
@Ciuleafarul
Mar 28 2017 01:11
@rayjrm ok, i'm on it
Hasham Babar
@hash004
Mar 28 2017 01:12

Hi, I'm stuck on Seek and Destroy. I've got the following solution so far:

function destroyer(arr) {
  // Remove all the values
  var args = [].slice.call(arguments);
  args.shift();
  return arr.filter(function(value){
    return (value in args);
  });
}

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

I'm missing something but I can't work out what

Ray Martinez
@rayjrm
Mar 28 2017 01:13
@blindman78 which challenge is that?
Adam Doyle
@Adoyle2014
Mar 28 2017 01:13
@Rubenricardo Look at this https://repl.it/BAQ0/17
Olivier
@blindman78
Mar 28 2017 01:15
@rayjrm a Manipulate Arrays With pop
Ray Martinez
@rayjrm
Mar 28 2017 01:16
@blindman78 They have actually givien you the solution In the ourArray example
Riadh
@KWFE
Mar 28 2017 01:16
hey anyone here want to help with this challenge!!
https://www.freecodecamp.com/challenges/accessing-nested-objects
Ciuleafarul
@Ciuleafarul
Mar 28 2017 01:16
@rayjrm ok, so how could i define the 4 small arrays for my new loop?
Joseph
@revisualize
Mar 28 2017 01:16
Hello.
Ray Martinez
@rayjrm
Mar 28 2017 01:17
@blindman78 all you need to do is apply the pop function to myArray
Riadh
@KWFE
Mar 28 2017 01:17
@revisualize hey man
Joseph
@revisualize
Mar 28 2017 01:18
@hash004 Is this correct (value in args) .. I haven't seen that before.
Hasham Babar
@hash004
Mar 28 2017 01:18

@revisualize yeah. If you look at this link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter

under the polyfill section you can see an example

Ray Martinez
@rayjrm
Mar 28 2017 01:21
@Ciuleafarul youll use the second loop to cycle though the first item in arr which is [4, 5, 1, 3]. you'll want to create a a var initialized to zero so that if your condion finds arr[i][j] is greater zero.
@Ciuleafarul For example...
Olivier
@blindman78
Mar 28 2017 01:22
@rayjrm ok thx but i don't understand lol
CamperBot
@camperbot
Mar 28 2017 01:22
blindman78 sends brownie points to @rayjrm :sparkles: :thumbsup: :sparkles:
:cookie: 11 | @rayjrm |http://www.freecodecamp.com/rayjrm
Joseph
@revisualize
Mar 28 2017 01:24
Ray Martinez
@rayjrm
Mar 28 2017 01:25
var newarr = [];

for (//cycles through arr.length) {
var num = 0;
for (// cycles through arr[i].length ) {
//if arr[i][j] > num, num += arr[i][j]
}
// finally push num into newarray

}
pseudocode for ya
@Ciuleafarul
Mauricio Londoño
@mauricio1585
Mar 28 2017 01:27

function testGreaterThan(val) {
if (val > 101) { // Change this line
return "Over 100";
}

if (val > 11) { // Change this line
return "Over 10";
}

return "10 or Under";
}

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

testGreaterThan(0) should return "10 or Under"
testGreaterThan(10) should return "10 or Under"
testGreaterThan(11) should return "Over 10"
testGreaterThan(99) should return "Over 10"
testGreaterThan(100) should return "Over 10"
testGreaterThan(101) should return "Over 100"
testGreaterThan(150) should return "Over 100"
You should use the > operator at least twice

function testGreaterThan(val) {
if (val > 101) { // Change this line
return "Over 100";
}

if (val > 11) { // Change this line
return "Over 10";
}

return "10 or Under";
}

// Change this value to test
testGreaterThan(0);
1

2
function testGreaterThan(val) {
3
if (val > 101) { // Change this line
4
return "Over 100";
5
}
6

7
if (val > 11) { // Change this line
8
return "Over 10";
9
}
10

11
return "10 or Under";
12
}
13

14
// Change this value to test
15
testGreaterThan(0);
16

What Am I doing wrong?
Ray Martinez
@rayjrm
Mar 28 2017 01:28
@blindman78 see, how in the example they popped the last item off of ourArray with .pop()
Joseph
@revisualize
Mar 28 2017 01:28
A lot
Ray Martinez
@rayjrm
Mar 28 2017 01:28
@blindman78 do the same thing but to myArray, you dont need to make any of those variables
Riadh
@KWFE
Mar 28 2017 01:29
```

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

// Only change code below this line

var gloveBoxContents = ""; // Change this line
Ray Martinez
@rayjrm
Mar 28 2017 01:31
Whats the problem? @KWFE
have you attempted yet?
Riadh
@KWFE
Mar 28 2017 01:31
i dont even know what they are looking for
Andrew Overshiner
@andrewlo3
Mar 28 2017 01:31

`// Latitude and longitude
navigator.geolocation.getCurrentPosition(function(location) {
var latitude = location.coords.latitude;
var longitude = location.coords.longitude;
});

console.log(latitude);`

Why does that not log to console in codepen?
Ray Martinez
@rayjrm
Mar 28 2017 01:32
@KWFE can you tell me the name of the challenge?
Olivier
@blindman78
Mar 28 2017 01:33
@rayjrm oh thx i find lol
CamperBot
@camperbot
Mar 28 2017 01:33
blindman78 sends brownie points to @rayjrm :sparkles: :thumbsup: :sparkles:
:warning: blindman78 already gave rayjrm points
Ray Martinez
@rayjrm
Mar 28 2017 01:33
great
Ray Martinez
@rayjrm
Mar 28 2017 01:38
@KWFE okay, so you will need to pull that final value from the myStorage object
and store it in glovebox contents
berom816
@berom816
Mar 28 2017 01:38
@andrewlo3 put the console.log(latitude) inside the function
Andrew Overshiner
@andrewlo3
Mar 28 2017 01:39
@berom816 so if I’m needing the latitude and longitude to call an xmlhttprequest for an api, does it all have to be in that function? because that didn’t work either
Ray Martinez
@rayjrm
Mar 28 2017 01:40
@KWFE we can target the "glove box" property using dot notation, like so...
obj.obj.obj //.... and so on
but dot notation doesnt work for values so at the end of our dot notation we will use bracket notation to access the value like so
obj["property"];
attempt this and then share your code if it still doesnt work
berom816
@berom816
Mar 28 2017 01:50
@andrewlo3 the snippet that you showed, the variable latitude wouldn't log to console because it's outside of the scope it's declared in
can you do console.log(location) inside the function instead
Andrew Overshiner
@andrewlo3
Mar 28 2017 01:51

@berom816 I need to access latitude later down in my code. How would I get this function to work properly?

function getLatitude() {
navigator.geolocation.getCurrentPosition(function(location) {
var latitude = location.coords.latitude;
});
return latitude;
}

Ricardo G.
@Rubenricardo
Mar 28 2017 01:55
@Adoyle2014 thanks mate
CamperBot
@camperbot
Mar 28 2017 01:55
rubenricardo sends brownie points to @adoyle2014 :sparkles: :thumbsup: :sparkles:
:cookie: 352 | @adoyle2014 |http://www.freecodecamp.com/adoyle2014
Andrew Overshiner
@andrewlo3
Mar 28 2017 01:56
basically, I need to make an api call using a url that has the latitude and longitude in it, so I need to define the latitude and longitude inside that function and store it in a variable that can be accessed later to append to the url.
Jayden Williams
@jaydkeith
Mar 28 2017 01:59
var a = 7;
var b = a;
can someone tell me the problem
Chuck Taylor
@cbtaylor2
Mar 28 2017 02:00
Escaping literal quotes in strings.var myStr = "I am a \"double quoted\" string inside \"double quotes\".";
Andrew Overshiner
@andrewlo3
Mar 28 2017 02:00
@jaydkeith what are you expecting the value of b to be?
David Amanze
@GodKingShogun
Mar 28 2017 02:00
i cant for the life of me create an array in an object :cry:
Gulsvi
@gulsvi
Mar 28 2017 02:02
function expandedForm(num) {
  return num.toString()
    .split('')
    .reverse()
    .map((val, i) => val * Math.pow(10, i))
    .reverse()
    .filter(a => a != 0)
    .join(' + ');
}

expandedForm(70304) // '70000 + 300 + 4'
Is there an elegant way to do this without reversing twice? (Edit: linted the code)
David Amanze
@GodKingShogun
Mar 28 2017 02:02
this is what i have so far
  collection[id][prop]= [].push(value);
Riadh
@KWFE
Mar 28 2017 02:03
@rayjrm thanks man
CamperBot
@camperbot
Mar 28 2017 02:03
:cookie: 12 | @rayjrm |http://www.freecodecamp.com/rayjrm
kwfe sends brownie points to @rayjrm :sparkles: :thumbsup: :sparkles:
Ray Martinez
@rayjrm
Mar 28 2017 02:04
no problem :)
David Amanze
@GodKingShogun
Mar 28 2017 02:05
@SkyCoder01 :wave:
Gulsvi
@gulsvi
Mar 28 2017 02:05
@GodKingShogun Hello! :)
David Amanze
@GodKingShogun
Mar 28 2017 02:05
@SkyCoder01 what part are you on right now
Gulsvi
@gulsvi
Mar 28 2017 02:06
Symmetric Difference
But taking a break for some codewars
David Amanze
@GodKingShogun
Mar 28 2017 02:06
@SkyCoder01 advanced algorithm or advance projects
Gulsvi
@gulsvi
Mar 28 2017 02:06
Advanced Algorithms
DomLeong
@DomLeong
Mar 28 2017 02:06
how to remove all backslashes without making it wrong
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
David Amanze
@GodKingShogun
Mar 28 2017 02:07
@SkyCoder01 thats one more ahead of me lol
@SkyCoder01 how did you create a new property with a new array
  collection[id][prop]= [].push(value);
Gulsvi
@gulsvi
Mar 28 2017 02:07
I don't know if this is the right way, but it worked lol [value]
David Amanze
@GodKingShogun
Mar 28 2017 02:07
@SkyCoder01 ^that should be working but it is not
Ray Martinez
@rayjrm
Mar 28 2017 02:08
function truncateString(str, num) {

  if (str.length <= 3) {
    console.log("less than or three");
    return str.slice(0, num) + "...";
  } 

  else if (str.length > num) {
    console.log("greater than num");
    return str.slice(0, num - 3) + "...";
  } else {
    return str;    
  }

}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
It doesn't meet the test case "truncateString("Absolutely Longer", 2) should return "Ab..."." Need help, thanks
David Amanze
@GodKingShogun
Mar 28 2017 02:08
@SkyCoder01 ive tried it that way too but it doesnt work
Gulsvi
@gulsvi
Mar 28 2017 02:08
Maybe another bug on the line above @GodKingShogun ?
That's what I used and it passed
Patrick O'Hara
@pohara9720
Mar 28 2017 02:09

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

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

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

does anybody know what this is asking
and what a code is supposed to look like for this
David Amanze
@GodKingShogun
Mar 28 2017 02:10
@SkyCoder01 this is what i have as my if statement
   if (prop==="tracks"&& !collection[id][prop]) {
    collection[id][prop]= [value];

    }
@pohara9720 so you are giving a variable and a convertion equation. use the information you already have
Gulsvi
@gulsvi
Mar 28 2017 02:11
@GodKingShogun That's basically the same as me, but I have an if else after checking if (prop === 'tracks')
David Amanze
@GodKingShogun
Mar 28 2017 02:11
@SkyCoder01 let me run it on python tutor and see what is going on
@SkyCoder01 that is the only one that is not passing
Gulsvi
@gulsvi
Mar 28 2017 02:12
If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.
If prop is "tracks" and value isn't empty (""), push the value onto the end of the album's existing tracks array.
I did one check if prop === tracks for those two cases above. If / else for the two cases
Patrick O'Hara
@pohara9720
Mar 28 2017 02:13
Do i plug in 9/5 + 32 where it says celsius?
c0d0er
@c0d0er
Mar 28 2017 02:14
@alpox thanks
CamperBot
@camperbot
Mar 28 2017 02:14
c0d0er sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:cookie: 886 | @alpox |http://www.freecodecamp.com/alpox
David Amanze
@GodKingShogun
Mar 28 2017 02:14
@SkyCoder01 oh wow. so the order i had my if statement mattered. i switched the two tracks statement around and it moved me to the next challenge... let me read the instructions for the next one and let me see if i can provide u with some insight
Gulsvi
@gulsvi
Mar 28 2017 02:14
@pohara9720 Celsius is the number they want you to convert, so it's like an algebra equation. var fahrenheit = ....
Patrick O'Hara
@pohara9720
Mar 28 2017 02:14
I dont know what an algorithm is supposed to look like. Do i copy the first code and then plug in numbers? do i just start writing equations? I don't understand the format its supposed to be in or where or how i plug in variables
so var fahrenheit= 9/5 + 32?
Gulsvi
@gulsvi
Mar 28 2017 02:15
use celsius on the other side of the = sign to plug it into the equation
David Amanze
@GodKingShogun
Mar 28 2017 02:15
@pohara9720 so you are trying to solve for x which is Fahrenheit and you are given the Celsius and conversion equation which is your known variables. so basically x=knowninfo. hope that makes sense
Gulsvi
@gulsvi
Mar 28 2017 02:16
if it's fahrenheit= 9/5 + 32 then Fahrenheit will always be the same answer no matter what Celsius is, you have to use Celsius on the other side of the = sign
Patrick O'Hara
@pohara9720
Mar 28 2017 02:16

where does x go in

n convertToF(celsius) {
var fahrenheit;

Gulsvi
@gulsvi
Mar 28 2017 02:16
var feet = inches * 12
Same principle
var kilometers = meters * 1000
Patrick O'Hara
@pohara9720
Mar 28 2017 02:17
so celsius=9/5 + 32
how do i write that as a code
Gulsvi
@gulsvi
Mar 28 2017 02:18
@pohara9720 If you do celsius = 9/5 + 32, how does it change if Fahrenheit is 100 or 32?
silver537
@silver537
Mar 28 2017 02:18
weeeeeeeeeeeeeeeeeeeeeeeeee
Johnny Hu
@heyitsjhu
Mar 28 2017 02:18
It'll help if you look up the actual formula for converting fahrenheit to celsius, and vice versa.
Patrick O'Hara
@pohara9720
Mar 28 2017 02:20

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

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

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

To test your learning, you will create a solution "from scratch". Place your code between the indicated lines and it will be tested against multiple test cases.

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.

You are given a variable celsius representing a temperature in Celsius. Use the variable fahrenheit already defined and apply the algorithm to assign it the corresponding temperature in Fahrenheit.

Note
Don't worry too much about the function and return statements as they will be covered in future challenges. For now, only use operators that you have already learned.

this is what I'm asked, and I don't understand what they are looking for. Other then 9/5 + 32 I have no other information. So what am i solving for and how do I write whatever Im supposed to solve for

Johnny Hu
@heyitsjhu
Mar 28 2017 02:21
@pohara9720 You're missing a variable in your formula, which is the celsius variable.
which is the value being passed into the function. You'll need to modify the equation in your fahrenheit variable so that it includes the celsius variable being passed in.
JAPerera
@JAPerera
Mar 28 2017 02:23
Celsius should be the parameter - not the variable.
Johnny Hu
@heyitsjhu
Mar 28 2017 02:23
Right, parameter. Sorry, wrong vocab.
JAPerera
@JAPerera
Mar 28 2017 02:23
Try reassigning the given variable, fahrenheit, to the formula given.
Patrick O'Hara
@pohara9720
Mar 28 2017 02:24
how do i do what you just said

function convertToF(celsius) {
var fahrenheit;

is this the formula youre talking about? and if so what variable am i changing? celsius isn't given a value its simply just assigned "celsius"

JAPerera
@JAPerera
Mar 28 2017 02:25
I was confused on that too cause they only tell you to modify the code below line 4. They declare var fahrenheit on line 3. On line 5, just assign it a new value. The value should be the formula that they give you for converting celsius to fahrenheit.

Celsius is just a parameter. So on line 2, it's declaring a function convertToF and assigning it a parameter celsius. So when you call the function later, you can say:

convertToF(30) with 30 being the temperature in celsuis.

Patrick O'Hara
@pohara9720
Mar 28 2017 02:27

so to do what you just said would it look like this

function convertToF(9/5 +32) {
var fahrenheit;

JAPerera
@JAPerera
Mar 28 2017 02:27
Sorry - trying my best to explain without outright giving you the answer lol
Gulsvi
@gulsvi
Mar 28 2017 02:27

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.

^^ The answer is right here

Patrick O'Hara
@pohara9720
Mar 28 2017 02:29
I understand how celsius converts to fahrenheit but I have no idea what a code for that looks like.
Gulsvi
@gulsvi
Mar 28 2017 02:29
If you do Celsius * 9/5 + 32, what do you get?
Patrick O'Hara
@pohara9720
Mar 28 2017 02:30
celsius needs a value. otherwise the formula is useless
otherwise its just 33 degrees
Johnny Hu
@heyitsjhu
Mar 28 2017 02:30
Celsius is passed in as a parameter when the function is called, ie. convertToF(30)
JAPerera
@JAPerera
Mar 28 2017 02:30
Celsius is given a value later when you call the function. Lines 1-9 are defining what the function does.
Patrick O'Hara
@pohara9720
Mar 28 2017 02:31
so am i just putting random numbers in convertToF()
and what goes into lines 5&6 then?
Johnny Hu
@heyitsjhu
Mar 28 2017 02:31
take a look at @SkyCoder01 's suggestion again
he doesn't include random numbers, he includes the parameter celsius.
Gulsvi
@gulsvi
Mar 28 2017 02:32
function add(number) {
var sum = 5 + number;
return sum;
}
add(2)
Or, look at a simpler function -> What does sum = ?
Johnny Hu
@heyitsjhu
Mar 28 2017 02:32
7
Patrick O'Hara
@pohara9720
Mar 28 2017 02:32
7
Gulsvi
@gulsvi
Mar 28 2017 02:33
No you @iamjhu :p
Patrick O'Hara
@pohara9720
Mar 28 2017 02:33
is that an algorithm ?
JAPerera
@JAPerera
Mar 28 2017 02:33
Excellent example @SkyCoder01
Gulsvi
@gulsvi
Mar 28 2017 02:33
Yes @pohara9720 The same thing is happening with the convert(30) function - they are passing in 30 as the value for Celsius
Johnny Hu
@heyitsjhu
Mar 28 2017 02:33
So in your example, number (the parameter) is used in the formula/equation of var sum.
You need to do something similar in your convertToFfunction. You need to use the parameter celsius in your var fahrenheit equation
Andrew Shieh
@andrewlikes
Mar 28 2017 02:34
parameter is just the name, the real values come from the arguments
Patrick O'Hara
@pohara9720
Mar 28 2017 02:34

so my lines 5 & 6 would read

function convertToF(30) {
var fahrenheit; 9/5+5+30?

JAPerera
@JAPerera
Mar 28 2017 02:35
Not quite. You need to assign var fahrenheit the formula for converting celsius to fahrenheit using the assignment operater =.
Patrick O'Hara
@pohara9720
Mar 28 2017 02:36
function convertToF(30) {
var fahrenheit = celsius * 9/5+30
?
MR-Em
@MR-Em
Mar 28 2017 02:36

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

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

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

help with this?
iaannn
@iaannn
Mar 28 2017 02:37
I need hlep on 140
Andrew Shieh
@andrewlikes
Mar 28 2017 02:37
@pohara9720 your parameter should be a name, not number
MR-Em
@MR-Em
Mar 28 2017 02:37
getting error: total is undefined. when it should equal 20
Andrew Shieh
@andrewlikes
Mar 28 2017 02:37
@iaannn challenges go by names
MR-Em
@MR-Em
Mar 28 2017 02:37
i put i = 20 but that is still the same
Patrick O'Hara
@pohara9720
Mar 28 2017 02:38
can someone please send me what the answer is supposed to look like so i can visualize what everybody is talking about
iaannn
@iaannn
Mar 28 2017 02:38
@andrewlikes sorry, and thank you for letting me know :) the challenge is titled as "convert celsius to fahrenheit"
CamperBot
@camperbot
Mar 28 2017 02:38
iaannn sends brownie points to @andrewlikes :sparkles: :thumbsup: :sparkles:
:cookie: 431 | @andrewlikes |http://www.freecodecamp.com/andrewlikes
Andrew Shieh
@andrewlikes
Mar 28 2017 02:38
@MR-Em your code doesn't return a value
DomLeong
@DomLeong
Mar 28 2017 02:38
i cant solve this problem
Remove all the backslashes ()
You should have two single quotes ' and four double quotes
Andrew Shieh
@andrewlikes
Mar 28 2017 02:38
@iaannn what have you done
@DomLeong are you escaping using \
MR-Em
@MR-Em
Mar 28 2017 02:39
@andrewlikes how would i return a value?
Andrew Shieh
@andrewlikes
Mar 28 2017 02:39
keyword return
iaannn
@iaannn
Mar 28 2017 02:39
@andrewlikes I haven't done anything. the prior examples were easier, but i am confused with how to start this one ;/
Andrew Shieh
@andrewlikes
Mar 28 2017 02:39
show the code
Johnny Hu
@heyitsjhu
Mar 28 2017 02:40
@pohara9720 your latest example is much better because you're including the celsius parameter in your formula. Have you tried running your code again?
Patrick O'Hara
@pohara9720
Mar 28 2017 02:40
yes its 100% incorrect
JAPerera
@JAPerera
Mar 28 2017 02:40
@pohara9720 Very close.
Johnny Hu
@heyitsjhu
Mar 28 2017 02:41
What was the value
JAPerera
@JAPerera
Mar 28 2017 02:41
Try adding parenthesis around 9/5
DomLeong
@DomLeong
Mar 28 2017 02:41
i did but it is an error
JAPerera
@JAPerera
Mar 28 2017 02:41
Also - it's + 32
Andrew Shieh
@andrewlikes
Mar 28 2017 02:42
would help to see the code
Roxroy
@roxroy
Mar 28 2017 02:42
@iamjhu , let me see what you have so far?
Johnny Hu
@heyitsjhu
Mar 28 2017 02:42
?
Patrick O'Hara
@pohara9720
Mar 28 2017 02:42
function convertToF(30) {
var fahrenheit = celsius * (9/5)+32
DomLeong
@DomLeong
Mar 28 2017 02:42
it didnt help
Johnny Hu
@heyitsjhu
Mar 28 2017 02:42
that's correct @pohara9720
Patrick O'Hara
@pohara9720
Mar 28 2017 02:42
it still says its incorrect
Johnny Hu
@heyitsjhu
Mar 28 2017 02:42
what does it say?
JAPerera
@JAPerera
Mar 28 2017 02:42
You changed the parameter
DomLeong
@DomLeong
Mar 28 2017 02:42
<a href="http://www.example.com\" target=\"_blank\">Link</a>
Johnny Hu
@heyitsjhu
Mar 28 2017 02:42
what's the error?
Andrew Shieh
@andrewlikes
Mar 28 2017 02:42
@pohara9720 that's not the right parameter
JAPerera
@JAPerera
Mar 28 2017 02:42
Change the parameter back to celsius
Johnny Hu
@heyitsjhu
Mar 28 2017 02:42
oh, didn't catch that @JAPerera
DomLeong
@DomLeong
Mar 28 2017 02:42
unexpected identifier
Roxroy
@roxroy
Mar 28 2017 02:43
@DomLeong , which challenge are you on?
Johnny Hu
@heyitsjhu
Mar 28 2017 02:43
function convertToF(celsius) <- change this back to celsius
DomLeong
@DomLeong
Mar 28 2017 02:43
Quoting Strings with Single Quotes @roxroy
Patrick O'Hara
@pohara9720
Mar 28 2017 02:43
function convertToF(celsius) {
var fahrenheit = celsius * (9/5)+32
??
convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86
Andrew Shieh
@andrewlikes
Mar 28 2017 02:44
@pohara9720 your function also needs to return the value
Patrick O'Hara
@pohara9720
Mar 28 2017 02:44
I dont know what that means^^^
it says not to worry about the return function for this challenge
JAPerera
@JAPerera
Mar 28 2017 02:45
@pohara9720 Did you remove the return function? It says not to worry about it cause it was already there at the beginning of the challenge - but it should stay there.
Johnny Hu
@heyitsjhu
Mar 28 2017 02:45
@andrewlikes I think the return statement is in his code; just not in what he's providing on here.
Roxroy
@roxroy
Mar 28 2017 02:45
@DomLeong , in this case you want to start the single quote '
Patrick O'Hara
@pohara9720
Mar 28 2017 02:45
no i left it as it i just haven't touched anything on that line
Andrew Shieh
@andrewlikes
Mar 28 2017 02:45
@pohara9720 can you paste your entire code in these ```
back and front
DomLeong
@DomLeong
Mar 28 2017 02:46
got it thx @roxroy
CamperBot
@camperbot
Mar 28 2017 02:46
domleong sends brownie points to @roxroy :sparkles: :thumbsup: :sparkles:
:cookie: 483 | @roxroy |http://www.freecodecamp.com/roxroy
JAPerera
@JAPerera
Mar 28 2017 02:46
Hmm. That should be correct then. If anything you might wanna refresh the page or take a second look at your syntax. I see that you're missing an ending semicolon at the end of your variable assignment.
Patrick O'Hara
@pohara9720
Mar 28 2017 02:46

'''

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
function convertToF(30) {
var fahrenheit = celsius * (9/5)+32
// Only change code above this line
return fahrenheit;
}

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

'''

CamperBot
@camperbot
Mar 28 2017 02:46
:bulb: to format code use backticks! ``` more info
Andrew Shieh
@andrewlikes
Mar 28 2017 02:46
you put a function in your function
JAPerera
@JAPerera
Mar 28 2017 02:47
Oh - you don't need to declare the function again.
Patrick O'Hara
@pohara9720
Mar 28 2017 02:47
its challenge 138 if anyone has does it
JAPerera
@JAPerera
Mar 28 2017 02:47
remove function converToF(30) {
Andrew Shieh
@andrewlikes
Mar 28 2017 02:48

function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line


 fahrenheit = celsius * (9/5)+32;


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

// Change the inputs below to test your code
convertToF(30);
``` not '''
CamperBot
@camperbot
Mar 28 2017 02:48
:bulb: to format code use backticks! ``` more info
Andrew Shieh
@andrewlikes
Mar 28 2017 02:48
btw
Patrick O'Hara
@pohara9720
Mar 28 2017 02:48
thank god okay that worked.thank you everyone who just helped
PhamLinh0889
@PhamLinh0889
Mar 28 2017 02:49
hello everyone
MR-Em
@MR-Em
Mar 28 2017 02:49

@andrewlikes var total = 0;

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

got it
PhamLinh0889
@PhamLinh0889
Mar 28 2017 02:49
i need help this exercise
Patrick O'Hara
@pohara9720
Mar 28 2017 02:49
I was just confused on how it was supposed to be written.
MR-Em
@MR-Em
Mar 28 2017 02:49
had myTotal instead of total
PhamLinh0889
@PhamLinh0889
Mar 28 2017 02:49

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

FirstLine
\SecondLine\
ThirdLine`

this is my code
var myStr="FirstLine\n\\SecondLine\\\nThirdLine"; // Change this line
Andrew Shieh
@andrewlikes
Mar 28 2017 02:49
@MR-Em i figured, you didn't show your whole code so I couldn't help
PhamLinh0889
@PhamLinh0889
Mar 28 2017 02:50
but it not true
MR-Em
@MR-Em
Mar 28 2017 02:51
@andrewlikes ah oops. i didn't know. thanks for trying.
CamperBot
@camperbot
Mar 28 2017 02:51
mr-em sends brownie points to @andrewlikes :sparkles: :thumbsup: :sparkles:
:cookie: 432 | @andrewlikes |http://www.freecodecamp.com/andrewlikes
PhamLinh0889
@PhamLinh0889
Mar 28 2017 02:51
please help me
thanks
Sohel-ASM
@Sohel-ASM
Mar 28 2017 02:51
Will anyone please help me in solving this counting card exercise?
blob
Any suggestions or example?
Owa Aquino
@owaaquino
Mar 28 2017 02:53
Hello
have a question on how to get the property key names using for loop
example 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"]
}
];
how would I know if all objects has the prop key of firstName or lastName?
Aaron Light
@aaronlightcodes
Mar 28 2017 02:57
@owaaquino have you tried with boolean obj.hasOwnProperty(property)
Sohel-ASM
@Sohel-ASM
Mar 28 2017 02:57
blob
Anyone please help me with this counting card exercise.
Owa Aquino
@owaaquino
Mar 28 2017 02:57
@aaronlightcodes nope not yet i was trying like this
Patrick O'Hara
@pohara9720
Mar 28 2017 02:57

Use backslashes to assign a string to the myStr variable so that if you were to print it to the console, you would see:

I am a "double quoted" string inside "double quotes".

var myStr = " I am a \"double quoted\"string inside \"double quotes\".";

why is this incorrect?

Owa Aquino
@owaaquino
Mar 28 2017 02:57
for(var i=0; i < contacts.length; i++){
for(var j=0; j< contacts[i].length; j++){
if(firstName === contacts[i].firstName){
return true;
}
for(var property in contacts[i][j]){
if(prop === property){
return true;
}
}
}
}
Aaron Light
@aaronlightcodes
Mar 28 2017 02:59
@owaaquino place ``` start and end of code.
@owaaquino look at markdown help. It helps in displaying code in chat.
tech-tron
@tech-tron
Mar 28 2017 03:00
just curious?! i used a plus equal operator to add any matches to a key value pair and it returned object Object
is the key an "object" and its property and "Object"
also how do i get it to show the values instead
i was += them into an empty array
Owa Aquino
@owaaquino
Mar 28 2017 03:02
@aaronlightcodes
  for(var i=0; i < contacts.length; i++){
    for(var j=0; j< contacts[i].length; j++){
      if(firstName === contacts[i].firstName){
        return true;
      }
      for(var property in contacts[i][j]){
        if(prop === property){
          return true;
        }
      }
    }
  }
sorry just new here :)
Aaron Light
@aaronlightcodes
Mar 28 2017 03:02
@owaaquino No worries.
LorandMezei
@LorandMezei
Mar 28 2017 03:02
how do i post a pic of my code like owa did?
Aaron Light
@aaronlightcodes
Mar 28 2017 03:03
@LorandMezei place ``` start and end of code.
@owaaquino contacts[i] is object. So, you don't need to loop. Try again. It may be difficult in the beginning.
@tech-tron show me code?
tech-tron
@tech-tron
Mar 28 2017 03:11

function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line
var key = Object.keys(source)[0];

for(var i = 0; i < collection.length; i++){
if(collection[i][key] === source[key]){
arr += collection[i];
}
}
return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });

i dont know how to do the screen shot
Owa Aquino
@owaaquino
Mar 28 2017 03:12
" your goes here "
that doesnt work hahah xD
```
code here
```
like this
Sohel-ASM
@Sohel-ASM
Mar 28 2017 03:13
Anyone please help me with the counting card exercise
LorandMezei
@LorandMezei
Mar 28 2017 03:14
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
Any hints?
function nextInLine(arr, item) {
  // Your code here

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Aaron Light
@aaronlightcodes
Mar 28 2017 03:15
@tech-tron arr.push(collection[i]);
Patrick O'Hara
@pohara9720
Mar 28 2017 03:15

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

var myStr=FirstLine\n\SecondLine\ThirdLine\r;

does anyone know why this code is wrong

Aaron Light
@aaronlightcodes
Mar 28 2017 03:15
@Sohel-ASM show me code?
Sohel-ASM
@Sohel-ASM
Mar 28 2017 03:16
@aaronlightcodes alright, I am uploading a screen shot of how I am approaching the porblem
LorandMezei
@LorandMezei
Mar 28 2017 03:16
do I have to use .push ?
Aaron Light
@aaronlightcodes
Mar 28 2017 03:16
@Sohel-ASM you can paste here.
Sohel-ASM
@Sohel-ASM
Mar 28 2017 03:16
blob
@aaronlightcodes am I doing it right?
@LorandMezei you will have use push first to add an item in the array
Aaron Light
@aaronlightcodes
Mar 28 2017 03:18
@Sohel-ASM I can't see the whole code. You can private message me and paste all code if you wish.
Sohel-ASM
@Sohel-ASM
Mar 28 2017 03:18
@aaronlightcodes sure, thank you.
tech-tron
@tech-tron
Mar 28 2017 03:18
hahah, thanks so much @aaronlightcodes , do you know why it said object Object, does it just return it that way or is it key:value
CamperBot
@camperbot
Mar 28 2017 03:18
sohel-asm sends brownie points to @aaronlightcodes :sparkles: :thumbsup: :sparkles:
:cookie: 289 | @aaronlightcodes |http://www.freecodecamp.com/aaronlightcodes
Sohel-ASM
@Sohel-ASM
Mar 28 2017 03:19
@aaronlightcodes How can I go to private chat option?
Aaron Light
@aaronlightcodes
Mar 28 2017 03:19
@tech-tron I don't know it too. :smile:
tech-tron
@tech-tron
Mar 28 2017 03:21
okay so later on the same js task it has 2 items you should match, so my key variable is going to have to expand and then ill probably just throw a for loop with another for loop inside that. is there a better way of doing this
im on the wherefore art thou challange
Frank
@FrankMusic
Mar 28 2017 03:21
anybody konws how to split a word to array ,no space
Aaron Light
@aaronlightcodes
Mar 28 2017 03:22
@pohara9720 between SecondLine and ThirdLine, there should be line break
@FrankMusic word.split('')
Frank
@FrankMusic
Mar 28 2017 03:22
like "hello" split to ['h','e','l','l','o'];
Patrick O'Hara
@pohara9720
Mar 28 2017 03:23
@FrankMusic it still doesn't work
Do you know what the code is supposed to look like
Frank
@FrankMusic
Mar 28 2017 03:24
@aaronlightcodes that still a string.
@pohara9720 split ?
Aaron Light
@aaronlightcodes
Mar 28 2017 03:25
@FrankMusic var arr = "hello".split('');
Patrick O'Hara
@pohara9720
Mar 28 2017 03:26
@FrankMusic Split??
@FrankMusic Split what
Frank
@FrankMusic
Mar 28 2017 03:27
@aaronlightcodes got it
Frank
@FrankMusic
Mar 28 2017 03:27
@pohara9720 i think i solve it
@FrankMusic thx
CamperBot
@camperbot
Mar 28 2017 03:28
sorry frankmusic, you can't send brownie points to yourself! :sparkles: :sparkles:
Frank
@FrankMusic
Mar 28 2017 03:28
@aaronlightcodes thx
CamperBot
@camperbot
Mar 28 2017 03:28
frankmusic sends brownie points to @aaronlightcodes :sparkles: :thumbsup: :sparkles:
:cookie: 290 | @aaronlightcodes |http://www.freecodecamp.com/aaronlightcodes
Frank
@FrankMusic
Mar 28 2017 03:28
@rjcool9 thx
CamperBot
@camperbot
Mar 28 2017 03:28
:cookie: 300 | @rjcool9 |http://www.freecodecamp.com/rjcool9
Patrick O'Hara
@pohara9720
Mar 28 2017 03:28
How do i add \n \ and \r correctly @FrankMusic
CamperBot
@camperbot
Mar 28 2017 03:28
frankmusic sends brownie points to @rjcool9 :sparkles: :thumbsup: :sparkles:
Frank
@FrankMusic
Mar 28 2017 03:30
@pohara9720 add to ?
Patrick O'Hara
@pohara9720
Mar 28 2017 03:31

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

what does that look like as a code?

i tried var myStr=FirstLine\n\SecondLine\ThirdLine\r;

but thats incorrect

Aaron Light
@aaronlightcodes
Mar 28 2017 03:33
@pohara9720 there should be \n character between second and third. and you need to insert \SecondLine\ '\' char. to write it, '\'
Frank
@FrankMusic
Mar 28 2017 03:33
@pohara9720 sorry im just a newcomer to front end
Patrick O'Hara
@pohara9720
Mar 28 2017 03:35
@aaronlightcodes Ive tried all kinds of combinations I have no idea how to write it
do you put \n before firstlineand \ after? or \nfirstline\n?
Aaron Light
@aaronlightcodes
Mar 28 2017 03:36
\SecondLine\\nThirdLine @pohara9720
Patrick O'Hara
@pohara9720
Mar 28 2017 03:37
@aaronlightcodes Why would i add \n after second line??
Aaron Light
@aaronlightcodes
Mar 28 2017 03:37
because you need to go to new line after \SecondLine\ right?
SecondLine and ThirdLine are not same line.
Roxroy
@roxroy
Mar 28 2017 03:38
@pohara9720 , make those changes and post the updated code.
Patrick O'Hara
@pohara9720
Mar 28 2017 03:39
\nFirstLine\SecondLine\n\rThirdLine\

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

I just need to turn those words into the correct code and I'm just not sure where to put the escape codes around the words

Aaron Light
@aaronlightcodes
Mar 28 2017 03:47
str = "FirstLine\n\\SecondLine\\\n\rThirdLine";
Patrick O'Hara
@pohara9720
Mar 28 2017 03:51
that was incorrect it says
Matthew
@IMDBLM
Mar 28 2017 03:51
@pohara9720 I'd like to make a suggestion. If you aren't taking notes as you go through the challenges I'd encourage you to. Not of the challenges themselves but of the different operators, checking string lengths, etc.
@pohara9720 Look at @aaronlightcodes and check it against your instructions.
Patrick O'Hara
@pohara9720
Mar 28 2017 03:53
@IMDBLM The biggest issue I'm having is that these challenged instruct you to put these items into code without giving any reference on how the code is actually supposed to look. So often times I know exactly what the code needs to have in it but zero idea how to write it correctly
Moisés Man
@moigithub
Mar 28 2017 03:53
@aaronlightcodes u have 2 new lines.. re-read instructins
Matthew
@IMDBLM
Mar 28 2017 03:54
@pohara9720 brother that's not true. The very last part of that instruction spells it out for you
I mean, it's hard, yeah.
Moisés Man
@moigithub
Mar 28 2017 03:54
@pohara9720 check ur escaped sequence positions... should be exactly as instruction says
Matthew
@IMDBLM
Mar 28 2017 03:54
I'm getting caught up on my 2nd run-through
@pohara9720 so.... "FirstLine newline backslash SecondLine backslash carriage-return ThirdLine" You spell it out, using the escape sequences that are in the table at the beginning of the instructions. Don't give up, keep going!
Patrick O'Hara
@pohara9720
Mar 28 2017 03:58

It spells it out yes but when put exactly what it says in

Firstline\n\ secondline\\r Thirdline

thats word for word what that written code translates to.
and thats incorrect

from the code that worked it looks like i needed to add
FirstLine\n\SecondLine\\rThirdLine;

i needed to add another \ before the second line i just don't know why

Matthew
@IMDBLM
Mar 28 2017 04:00
Backslash needs its own escape. @pohara9720
Patrick O'Hara
@pohara9720
Mar 28 2017 04:01
to me this is what I would write
first line\n\secondline\\rthirdline.
Matthew
@IMDBLM
Mar 28 2017 04:01
You'd be wrong because you didn't escape a backslash
Remember \\is how you'd write a backslash
Right now you're writing \SecondLine\ which won't actually give you \SecondLine\
Patrick O'Hara
@pohara9720
Mar 28 2017 04:03
so would it be \\ after second line
\\
"\\"
Matthew
@IMDBLM
Mar 28 2017 04:03
If all backslash need that where else would you put it?
Patrick O'Hara
@pohara9720
Mar 28 2017 04:03
it won't let me put 3 of \ I dont know why
Matthew
@IMDBLM
Mar 28 2017 04:03
show me your code again
Harsh Chandra
@HarshHC
Mar 28 2017 04:03
can anyone help me with the "Mutations " challenge?
heres my code

function mutation(arr) {
  var accepted=0;
  for(var i=0;i<=arr[1].length;i++){
    var ch=arr[1].charAt[i];
    if(arr[0].indexOf(ch)>=0){
      accepted++;
    }
  }
  if(accepted==arr[1].length){
      return true;
    }
    return false;
}

mutation(["hello", "hey"]);
Ken Ly
@kly94
Mar 28 2017 04:04

Hi Guys, I've been comparing answers and I just wanted to know why this code works for the Golf Challenge as I can't wrap my head around it

if (strokes == 1){
return "Hole-in-one!";
} else if (strokes <=par-2) {
return"Eagle";
} else if (strokes <=par -1) {
return "Birdie";
} else if (strokes == par) {
return "Par";
} else if (strokes<=par+1) {
return "Bogey";
}else if (strokes<=par+2) {
return"Double Bogey";
}else if (strokes >=par+3) {
return "Go Home!";
}else {

return "Change Me";}

Matthew
@IMDBLM
Mar 28 2017 04:04
@pohara9720 show me your code please. I didn't tag you before, sorry.
Harsh Chandra
@HarshHC
Mar 28 2017 04:04
@kly94 it goes in the if which suits the condition
@kly94 the end is wrong though, u should remove change me part of else
Ken Ly
@kly94
Mar 28 2017 04:06
@HarshHC I'm unsure because It allows me to pass that lesson, which I found weird

@HarshHC as I've seen else if (strokes == par +1) {
return "Bogey";
} else if (strokes

instead of my <=par+1

Harsh Chandra
@HarshHC
Mar 28 2017 04:07
@kly94 it will pass u since it will never use the else statement coz they call the function with values which will fit all your if statements
Sohel-ASM
@Sohel-ASM
Mar 28 2017 04:08
@IMDBLM will you plz help me with my counting card exercise?
John Sanchez
@JohnnyPark78
Mar 28 2017 04:08
@kly94 golfScore takes two arguments... it runs down each condition to see if it's true. Once it meets a true condition, it returns whatever is in that if statement. Once a function returns, it doesn't go any further and stops running. You CAN use the less-than-or-equals operator to do the comparison because none of the comparisons above it are true, but using double equals is probably more technically correct.
Matthew
@IMDBLM
Mar 28 2017 04:09
@Sohel-ASM I can try, sure
Ken Ly
@kly94
Mar 28 2017 04:09
@HarshHC I've removed the else! It works, thanks!
CamperBot
@camperbot
Mar 28 2017 04:09
kly94 sends brownie points to @harshhc :sparkles: :thumbsup: :sparkles:
:cookie: 250 | @harshhc |http://www.freecodecamp.com/harshhc
Matthew
@IMDBLM
Mar 28 2017 04:10
How's it coming @pohara9720?
Ken Ly
@kly94
Mar 28 2017 04:10
@JohnnyPark78 Thanks for your help! now I understand!
CamperBot
@camperbot
Mar 28 2017 04:10
kly94 sends brownie points to @johnnypark78 :sparkles: :thumbsup: :sparkles:
:cookie: 364 | @johnnypark78 |http://www.freecodecamp.com/johnnypark78
Harsh Chandra
@HarshHC
Mar 28 2017 04:10
@kly94 yw
Sohel-ASM
@Sohel-ASM
Mar 28 2017 04:10
@IMDBLM May I open a private window, it will help me to save ur suggestions to , for later purpose
John Sanchez
@JohnnyPark78
Mar 28 2017 04:10
@kly94 yw
Matthew
@IMDBLM
Mar 28 2017 04:10
@Sohel-ASM Just keep your expectations low
Joseph
@revisualize
Mar 28 2017 04:10
How's it going?
Duane
@DuaneYaiser
Mar 28 2017 04:10
var myStr = "FirstLine\n\SecondLine\\rThirdline"
Matthew
@IMDBLM
Mar 28 2017 04:11
Hey hey
Duane
@DuaneYaiser
Mar 28 2017 04:11
I am not seeing my problem
Sohel-ASM
@Sohel-ASM
Mar 28 2017 04:11
@IMDBLM oh, sorry
Harsh Chandra
@HarshHC
Mar 28 2017 04:11
can anyone help me with mutations challenge?

function mutation(arr) {
  var accepted=0;
  for(var i=0;i<=arr[1].length;i++){
    var ch=arr[1].charAt[i];
    if(arr[0].indexOf(ch)>=0){
      accepted++;
    }
  }
  if(accepted==arr[1].length){
      return true;
    }
    return false;
}

mutation(["hello", "hey"]);
Matthew
@IMDBLM
Mar 28 2017 04:11
@DuaneYaiser All backslashes need to be escaped
Duane
@DuaneYaiser
Mar 28 2017 04:11
I had it better a moment ago actually, darn it. I'll show what didn't pass . . .
Matthew
@IMDBLM
Mar 28 2017 04:12
@Sohel-ASM you can PM me I'm just saying bear with me. But now that big daddy @revisualize is here he might be a faster help than I am.
Nefer Lopez
@thatguynef
Mar 28 2017 04:12

I'm stumped

Why do I get NaN when I add two functions together but not when I return one function on its own?

Joseph
@revisualize
Mar 28 2017 04:13
@Sohel-ASM 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.
Duane
@DuaneYaiser
Mar 28 2017 04:13
var myStr = "FirstLine\n\SecondLine\\rThirdline"
LeSean Johnson
@leseanbiz
Mar 28 2017 04:14
anyone immediately familiar with the profile lookup challenge?
Joseph
@revisualize
Mar 28 2017 04:14
@DuaneYaiser Thirdline is not the same as ThirdLine
@leseanbiz I've solved that challenge about 5 different ways
LeSean Johnson
@leseanbiz
Mar 28 2017 04:15
sweet, im having some trouble with it
John Sanchez
@JohnnyPark78
Mar 28 2017 04:15
@HarshHC One thing is that it might be failing because because of capitalization errors.... "H" !== "h" so it's not counting that as an accepted character. Before anything else, use a .toLowerCase() to compare.
LeSean Johnson
@leseanbiz
Mar 28 2017 04:15
im assuming i need to use a for…in loop?
Joseph
@revisualize
Mar 28 2017 04:15
@leseanbiz What's the current state of your function? (just the function .. Not the large array.)
@leseanbiz What's a for...in loop used for?
LeSean Johnson
@leseanbiz
Mar 28 2017 04:15
@revisualize looping through objects
Harsh Chandra
@HarshHC
Mar 28 2017 04:15
@JohnnyPark78 k I will toLowerCase it all
LeSean Johnson
@leseanbiz
Mar 28 2017 04:16
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var firstName in contacts) {
if (contacts.hasOwnProperty(firstName)) {
console.log('contacts.' + firstName + ' = ' + contacts[firstName]);
}
}
Joseph
@revisualize
Mar 28 2017 04:16
@leseanbiz Is contacts an object?
LeSean Johnson
@leseanbiz
Mar 28 2017 04:16
im screwing up about 5 different ways lol
yes
Joseph
@revisualize
Mar 28 2017 04:16
@leseanbiz It is?
LeSean Johnson
@leseanbiz
Mar 28 2017 04:16
ummm, shit
its just a multi dim array?
Joseph
@revisualize
Mar 28 2017 04:16
@leseanbiz Nope.
Duane
@DuaneYaiser
Mar 28 2017 04:17
@revisualize Thank you!! This is driving me crazy, I know I did that right before reseting . . . I'll try to submit what I'm really wondering about not passing . . .
CamperBot
@camperbot
Mar 28 2017 04:17
duaneyaiser sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3611 | @revisualize |http://www.freecodecamp.com/revisualize
LeSean Johnson
@leseanbiz
Mar 28 2017 04:17
…its an array of objects
hrmmm, that helps
so i need to be starting off with a more traditional for loop to loop theorugh the arary then using a bit of what i pasted above to
get the value
Manish Giri
@Manish-Giri
Mar 28 2017 04:19
yes
@leseanbiz
Harsh Chandra
@HarshHC
Mar 28 2017 04:19
@JohnnyPark78 did I do it correct? It still didnt work .....

function mutation(arr) {
  var accepted=0;
  arr2=arr[0].toLowerCase();
  for(var i=0;i<=arr[1].length;i++){
    var ch=arr[1].charAt[i].toLowerCase();
    if(arr2[0].indexOf(ch)>=0){
      accepted++;
    }
  }
  if(accepted==arr[1].length){
      return true;
    }
    return false;
}

mutation(["hello", "hey"]);
Joseph
@revisualize
Mar 28 2017 04:19
@leseanbiz Correct.

@leseanbiz Gist by revisualize / FreeCodeCamp - Profile Lookup.js

We have an array of objects representing different people in our contacts lists.
Example: var contacts = [ { ... } , { ... } , { ... } , { ... } ];

John Sanchez
@JohnnyPark78
Mar 28 2017 04:22
@HarshHC change charAt[i] to charAt(i)
@HarshHC That gets up one step closer.
Harsh Chandra
@HarshHC
Mar 28 2017 04:22
ohh xD
John Sanchez
@JohnnyPark78
Mar 28 2017 04:22
@HarshHC Still not quite there... but closer.
Harsh Chandra
@HarshHC
Mar 28 2017 04:23
yup.... @JohnnyPark78
@JohnnyPark78 its so hard to debug
John Sanchez
@JohnnyPark78
Mar 28 2017 04:24
@HarshHC Yeah... I usually paste it into the browser console and add console.log in a few places to see what's going on... in this one, it's only showing up true for 2 characters instead of 3... going through to see what might be happeneing.
Harsh Chandra
@HarshHC
Mar 28 2017 04:26
@JohnnyPark78 umm shouldn't it be arr2.indexOf(...) instead of arr2[0].indexOf(...)
Sohel-ASM
@Sohel-ASM
Mar 28 2017 04:26
@revisualize may I PM you?
John Sanchez
@JohnnyPark78
Mar 28 2017 04:26
@HarshHC Maybe... validates for this solution
....but not all of them
Harsh Chandra
@HarshHC
Mar 28 2017 04:27
@JohnnyPark78 since arr2 contains arr[0]
wait a second where did i initialize arr2
John Sanchez
@JohnnyPark78
Mar 28 2017 04:28
oh oh oh
@HarshHC I got it...
Harsh Chandra
@HarshHC
Mar 28 2017 04:28
@JohnnyPark78 yes?
Duane
@DuaneYaiser
Mar 28 2017 04:28
For "Escape Sequences" I'm getting -- TypeError: "FirstLine \SecondLine\ ThirdLine" is not a function . . . Thoughts?
Scott
@mcleodrs
Mar 28 2017 04:29
I am lost on the nesting for loops, ugh
John Sanchez
@JohnnyPark78
Mar 28 2017 04:29
@HarshHC in your for loop, you're incrementing i to be greater or equal to arr[1].length. Because arrays index starting at zero, i should only go up to arr.length -1
@HarshHC either add in the arr[1].length -1 or change it to be less than arr[1].length
Harsh Chandra
@HarshHC
Mar 28 2017 04:30
@JohnnyPark78 removing the [0] from arr2 did more wrong though earlier the tests which needed to return false were correct now all are wrong
@JohnnyPark78 k lemme try it
@JohnnyPark78 oh yeaaah it worked THANKS!
CamperBot
@camperbot
Mar 28 2017 04:30
harshhc sends brownie points to @johnnypark78 :sparkles: :thumbsup: :sparkles:
:cookie: 365 | @johnnypark78 |http://www.freecodecamp.com/johnnypark78
Duane
@DuaneYaiser
Mar 28 2017 04:30
@DuaneYaiser Foolish Boy . . . All this time and you just forgot the semi-colon!!!!
John Sanchez
@JohnnyPark78
Mar 28 2017 04:31
@HarshHC Yay!
Harsh Chandra
@HarshHC
Mar 28 2017 04:37
i didnt understand the boolean object properly =_=
it returns true for all false charecters?
anyone?
Emmanuel Pierre
@epierr14
Mar 28 2017 04:40

function bouncer(arr) {
  // Don't show a false ID to this bouncer.

  var array = arr.filter(Boolean(false));
  return array;
}

bouncer([7, "ate", "", false, 9]);
help
Harsh Chandra
@HarshHC
Mar 28 2017 04:41
@epierr14 i am stuck at the same
@epierr14 but my code is completely different

function bouncer(arr) {
  var newArr=[];
  for(var i=0;i<arr.length;i++){
    var test=new Boolean(arr[i]);
    if(test===false){
      newArr.push(arr[i]);
    }
  }

  return newArr;
}

bouncer([7, "ate", "", false, 9]);
Jai Mitch
@jaimitch
Mar 28 2017 04:43
hello everyone. I'm completely stuck trying to complete algorithms using JavaScript. I'm new to Free Code Camp and this board so I'm not completely sure how to show you what I'm talking about. Any assistance would be greatly appreciated.
Harsh Chandra
@HarshHC
Mar 28 2017 04:44
@jaimitch stuck in which one
John Sanchez
@JohnnyPark78
Mar 28 2017 04:44
@HarshHC This is a confusing one... but let me try. If you create a new Boolean Object (var x = new Boolean(false); ) Then you have just created an Object that exists. If you put that in an if statement if(x), That if statement is only checking to see if an object exists. Since you created it, it exists and will return true, no matter what its VALUE is. To use Booleans in an if statement, you have to make that variable's VALUE true or false. var x = false. Now you have a variable with a value of false that will fail the if statement.
remember that "new" keyword creates an OBJECT. Not really what you want in most cases. In most cases, you just want a true/false value.
Harsh Chandra
@HarshHC
Mar 28 2017 04:46
@JohnnyPark78 uhm u seem to be logical however in the mozzila docs it did somethign similar to me
something similar to what i have done
have u completed this challenge?
well then how can i check if something is false charecter or not
Joseph
@revisualize
Mar 28 2017 04:48
@Sohel-ASM I don't respond to PMs
John Sanchez
@JohnnyPark78
Mar 28 2017 04:48
@HarshHC Yes... For the time being, I would forget about the word "Boolean". A boolean is just a value of true/false. Anytime you say var x = true or var y = false (without the double quotes) you've created a boolean variable.
Joseph
@revisualize
Mar 28 2017 04:48
@Sohel-ASM I don't even read them.
Emmanuel Pierre
@epierr14
Mar 28 2017 04:50
@HarshHC try using filter .... Return a filter with a function
Harsh Chandra
@HarshHC
Mar 28 2017 04:51
umm k.....
Matthew
@IMDBLM
Mar 28 2017 04:51
@revisualize Man but I send you such great PMs
John Sanchez
@JohnnyPark78
Mar 28 2017 04:51
@HarshHC Anything that "exists" has a truthy value. The only things that are falsey are 0, -0, null, false, NaN, undefined, or the empty string (""), If you put any of those in an if statement, they'll return false. Everything else will return true.
if(NaN){
    //false, so code doesn't run
}

if("string"){
  //true, so code will run
}
Matthew
@IMDBLM
Mar 28 2017 04:51
@revisualize cats and flowers and all sorts of otter gifs
Harsh Chandra
@HarshHC
Mar 28 2017 04:52
OH that worked! thanks again @JohnnyPark78
CamperBot
@camperbot
Mar 28 2017 04:52
harshhc sends brownie points to @johnnypark78 :sparkles: :thumbsup: :sparkles:
:warning: harshhc already gave johnnypark78 points
Markus Kiili
@Masd925
Mar 28 2017 04:53
@revisualize Morning.
John Sanchez
@JohnnyPark78
Mar 28 2017 04:55
@epierr14 You need to define a function to call in .filter(). Something like
function isFalsey(val){
  //some code
}

var arr2 = arr.filter(isFalsey);

return arr2;
Markus Kiili
@Masd925
Mar 28 2017 04:56
@HarshHC You shouldn't create Boolean objects with new Boolean(). They are just for the engine to use under the hood. You should just use Boolean values true/false and the Boolean() function that coerces values to type Boolean.
Harsh Chandra
@HarshHC
Mar 28 2017 04:57
ow ok thnx for the info :)
Emmanuel Pierre
@epierr14
Mar 28 2017 04:58
@JohnnyPark78 thank you... I tried return arr.filter(Boolean); just one line code.
CamperBot
@camperbot
Mar 28 2017 04:58
epierr14 sends brownie points to @johnnypark78 :sparkles: :thumbsup: :sparkles:
:cookie: 366 | @johnnypark78 |http://www.freecodecamp.com/johnnypark78
Harsh Chandra
@HarshHC
Mar 28 2017 04:58
these challenges are getting harder and harder....
the next one is tricky as well
John Sanchez
@JohnnyPark78
Mar 28 2017 05:01
@epierr14 that works because they are literally passing you true/false values. Anything more complicated, and you'd have to use the function.
SidKaphalia
@SidKaphalia
Mar 28 2017 05:03

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val){
case (1):
answer += "alpha";
break;
case (2):
answer += "beta";
break;
case (3):
answer += "gamma";
break;
case (4):
answer += "delta";

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

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

can figure out what im doing wrong
Matthew
@IMDBLM
Mar 28 2017 05:04
@SidKaphalia Why are you using +=?
SidKaphalia
@SidKaphalia
Mar 28 2017 05:04
adding to the answer =""
do i not need to concatenate
Matthew
@IMDBLM
Mar 28 2017 05:06
@SidKaphalia Nope, why would you? You're answer to something
whoops @SidKaphalia you're assigning answer to something
John Sanchez
@JohnnyPark78
Mar 28 2017 05:07
Seek and destroy is tricky because I think that's the first time you have to use the arguments object.... function destroyer(arr) only shows you the array of numbers... it doesn't mention the other values passed in. You have to get those values in from the arguments object. So for destroyer([1, 2, 3, 1, 2, 3], 2, 3), the array is arr... the 2 and 3 are called like other objects.... arguments[1] = 2 and arguments[2] = 3.
That's my hint for that one.
Harsh Chandra
@HarshHC
Mar 28 2017 05:12
I think im tired or idk but im messing up every program now.....
kishore sriramula
@KISHORESSK
Mar 28 2017 05:12
any technique to compare strings
i always get -1
Markus Kiili
@Masd925
Mar 28 2017 05:12
@KISHORESSK Equality operator === compared strings.
Harsh Chandra
@HarshHC
Mar 28 2017 05:12
again not getting output in seek and destroy challenge.....

function destroyer(arr) {
  var newArr=[];
  for(var i=0;i<arr[0].length;i++){
      for(var j=1;j<arr.length;j++){
        var check=arr[j];
        if(check!==arr[0][i]){
          newArr.push(arr[0][i]);
        }
      }
  }


}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Markus Kiili
@Masd925
Mar 28 2017 05:13
@HarshHC arr[0] is a number.
First number of passed array.
Harsh Chandra
@HarshHC
Mar 28 2017 05:13
umm isnt it the array itself
Markus Kiili
@Masd925
Mar 28 2017 05:14
The only parameter arr only catches the first passed argument [1, 2, 3, 1, 2, 3]
Harsh Chandra
@HarshHC
Mar 28 2017 05:14
uhm why?
Markus Kiili
@Masd925
Mar 28 2017 05:14
You need to use the arguments object for the rest of the arguments there.
John Sanchez
@JohnnyPark78
Mar 28 2017 05:14
Yeah... arr[0] will return the first number in the first argument... arr[0] = 1, but arguments[0] = [1,2,3,1,2,3]
Harsh Chandra
@HarshHC
Mar 28 2017 05:14
agh im confused
John Sanchez
@JohnnyPark78
Mar 28 2017 05:15
arr = arguments[0], the array.
Markus Kiili
@Masd925
Mar 28 2017 05:15
@HarshHC There is only one parameter but variable number of passed arguments.
Owa Aquino
@owaaquino
Mar 28 2017 05:16
hi
Harsh Chandra
@HarshHC
Mar 28 2017 05:16
oh so that means the function only is accepting 1 argument and the first argument is the array
did i get it right?
Owa Aquino
@owaaquino
Mar 28 2017 05:16
how do we get the property keyword of an object?
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"]
    }
];
how do you check if the firstName exist in all objects?
Markus Kiili
@Masd925
Mar 28 2017 05:17
@HarshHC Only parameter arr only holds the first passed argument. You need to use arguments object for the rest of the arguments.
Melissa Knapp
@MelEKn
Mar 28 2017 05:17

Hi, sometimes the properties of an object are put in quotation marks, and sometimes they aren't, and I'm not sure what the pattern is. For example, in "Accessing Objects with the Dot Operator" challenge, the sample on the left says
var myObj = {
prop1: "val1",
prop2: "val2"
};
var prop1val = myObj.prop1; // val1
var prop2val = myObj.prop2; // val2

but in the actual coding part to the right, it says
var testObj = {
"hat": "ballcap",
"shirt": "jersey",
"shoes": "cleats"
};

Markus Kiili
@Masd925
Mar 28 2017 05:18
@MelEKn In an object literal there is a freedom to use or not to use quotes on property keys. Some special keys need quotes, if it for example has a space in it.
John Sanchez
@JohnnyPark78
Mar 28 2017 05:18
When you call the function, you're passing multiple arguments. the function definition only explicitly requires the first one. All of them are passed into the function definition, but only arr is assigned... the rest are hiding in the arguments object.
Melissa Knapp
@MelEKn
Mar 28 2017 05:19
@Masd925 Ok... so in the above case it can be either?
Markus Kiili
@Masd925
Mar 28 2017 05:19
@MelEKn Yes.
Harsh Chandra
@HarshHC
Mar 28 2017 05:19
something like this?

function destroyer(arr) {
  var newArr=[];
  for(var i=0;i<arr[0].length;i++){
      for(var j=1;j<arguments.length;j++){
        var check=argument[j];
        if(check!==arr[0][i]){
          newArr.push(arr[0][i]);
        }
      }
  }


}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
or wait should be this

function destroyer(arr) {
  var newArr=[];
  for(var i=0;i<arr[0].length;i++){
      for(var j=1;j<arguments.length;j++){
        var check=argument[j];
        if(check!==arr[i]){
          newArr.push(arr[i]);
        }
      }
  }


}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Melissa Knapp
@MelEKn
Mar 28 2017 05:20
@Masd925 Ok, thank you :)
CamperBot
@camperbot
Mar 28 2017 05:20
melekn sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3669 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Mar 28 2017 05:20
@MelEKn Don't confuse that with JSON, which is a syntax for storing objects on a string or text. It has similar rules and there you need those quotes always.
Melissa Knapp
@MelEKn
Mar 28 2017 05:20
@Masd925 I don't think I'm there yet, but I'll keep it in mind!
Markus Kiili
@Masd925
Mar 28 2017 05:21
@owaaquino Property keyword?
Owa Aquino
@owaaquino
Mar 28 2017 05:21
yes
the exercises said I should check if the property keyword exist on every objects
Markus Kiili
@Masd925
Mar 28 2017 05:23
You don't need to check for firstName property. Just loop the array and test each object for correct firstName and property existence (use .hasOwnProperty() method)).
Owa Aquino
@owaaquino
Mar 28 2017 05:24
okay i'll try that
LeSean Johnson
@leseanbiz
Mar 28 2017 05:27
@revisualize still around?
Harsh Chandra
@HarshHC
Mar 28 2017 05:28
I quit for now.....
LeSean Johnson
@leseanbiz
Mar 28 2017 05:29
@Masd925 im on the same exercise. and scratching my head
function lookUpProfile(firstName, prop){
// Only change code below this line
  /*
  for (var i = 0; i < contacts.length; i++) {
        if (contacts[i].firstName != firstName) {
          return "No such contact"; 
        }else if (contacts[i].hasOwnProperty(prop) !== true){
          return "No such property";
        }else{
           return contacts[i][prop];
        }
    } 
    */

    for (var i = 0; i < contacts.length; i++) {
        if (contacts[i].firstName == firstName) {
           return contacts[i][prop];

        }
    } 
// Only change code above this line
}
if i submit the bottom for loop, i pass the last two functions……..if i run the top loop i pass the first 3
care to elaborate whats wrong with it?
Markus Kiili
@Masd925
Mar 28 2017 05:30
@leseanbiz Two nested if's is the simplest structure.
Jason
@thesnowlizard
Mar 28 2017 05:31
hello
Markus Kiili
@Masd925
Mar 28 2017 05:31
@leseanbiz You need a second if for property existence test with .hasOwnProperty()
LeSean Johnson
@leseanbiz
Mar 28 2017 05:31
ok, is that not two nested if’s in my code? in the top for loop?
yes, i was describing what i have ere in the text above
Markus Kiili
@Masd925
Mar 28 2017 05:32
@leseanbiz It is better to just make two positive tests for correct first name and property existence.
Joseph
@revisualize
Mar 28 2017 05:32
@leseanbiz You only have 1 array.
Matthew
@IMDBLM
Mar 28 2017 05:32
@revisualize Do you sleep?
LeSean Johnson
@leseanbiz
Mar 28 2017 05:32
yes, i know. there is only 1 array
Joseph
@revisualize
Mar 28 2017 05:32
@IMDBLM Yes.

@leseanbiz Gist by revisualize / FreeCodeCamp - Profile Lookup.js

We have an array of objects representing different people in our contacts lists.
Example: var contacts = [ { ... } , { ... } , { ... } , { ... } ];

Let's say you were at a big business event and you're quite popular (with all those skills you have) throughout the event you got handed 200 business cards (Which will remain unordered). Now, I walk up to you at the end and ask you.. Do you have a Business Card for "Jane Smith"? Now you loop look through your stack of 200 business cards. When would you tell me that you didn't have a business card for Jane?
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.
  // code before a for loop.
for (..........) {
  // Code inside of a for loop.
}
  // code after a for loop.
log
CamperBot
@camperbot
Mar 28 2017 05:34
Archives for HelpJavaScript
Jason
@thesnowlizard
Mar 28 2017 05:35
can anyone help me with my code?
Markus Kiili
@Masd925
Mar 28 2017 05:36
@thesnowlizard You can just post the question and relevant code.
Joseph
@revisualize
Mar 28 2017 05:36

If I was to do this example where I was looking for a letter in an array of strings.
If the letter is found return the string "True" otherwise return the string "False"

var value = "e"
var arr = ["a", "b", "c", "d", "e"];
for (var i = 0; i < arr.length; i++) {
      if (value === arr[i]) { return "True"; }
}
return "False";

Then if you redid that challenge with the letter "z" as the value of the variable value

Jason
@thesnowlizard
Mar 28 2017 05:37
@Masd925 cool, first off how do people post their code screen shot?
Markus Kiili
@Masd925
Mar 28 2017 05:37
'''
CamperBot
@camperbot
Mar 28 2017 05:37
:bulb: to format code use backticks! ``` more info
Markus Kiili
@Masd925
Mar 28 2017 05:37
@thesnowlizard Follow that link.
LeSean Johnson
@leseanbiz
Mar 28 2017 05:37
im confused because the logic seems to work in my code
Joseph
@revisualize
Mar 28 2017 05:37
@leseanbiz Your logic isn't correct.
LeSean Johnson
@leseanbiz
Mar 28 2017 05:38
just in pieces, yet they are the exact inverse of one another
ok
Jason
@thesnowlizard
Mar 28 2017 05:38
function factorialize(num) {
  while (num > 1){
    var product = 1;
    product = product * num;
    num = num - 1;
  }
  return product;
}

factorialize(5);
thanks!
ZenZate
@ZenZate
Mar 28 2017 05:39
http://codepen.io/ZenZate/pen/JWBWGv?editors=1011 why is my setINterval running when I never called it to run
Joseph
@revisualize
Mar 28 2017 05:39
@leseanbiz Question
LeSean Johnson
@leseanbiz
Mar 28 2017 05:39
ok
Joseph
@revisualize
Mar 28 2017 05:39
var value = "e"
var arr = ["a", "b", "c", "d", "e"];
for (var i = 0; i < arr.length; i++) {
      if (value === arr[i]) { return "True"; }
      else if (value !== arr[i]) { return "False" }
}
@leseanbiz How many times would this loop run?
Jason
@thesnowlizard
Mar 28 2017 05:40
@Masd925 can you tell me what i'm doing wrong? trying to make it factorialize
Markus Kiili
@Masd925
Mar 28 2017 05:40
@thesnowlizard Initialize the result variable before the loop.
LeSean Johnson
@leseanbiz
Mar 28 2017 05:40
assuming this is a typo !=== ?
and 5?
Joseph
@revisualize
Mar 28 2017 05:41
@leseanbiz It is a typo and incorrect.
LeSean Johnson
@leseanbiz
Mar 28 2017 05:41
0-4
Joseph
@revisualize
Mar 28 2017 05:41
@leseanbiz Umm.. Give me an exact number of times.
Jason
@thesnowlizard
Mar 28 2017 05:41
@Masd925 you're a genius! but why do you have to initialize the result variable before the loop?
LeSean Johnson
@leseanbiz
Mar 28 2017 05:41
i did man, 5
you said i was wrong
Joseph
@revisualize
Mar 28 2017 05:41
@leseanbiz That is 100% incorrect.
LeSean Johnson
@leseanbiz
Mar 28 2017 05:41
index would go from 0-4
Joseph
@revisualize
Mar 28 2017 05:42
@leseanbiz No it won't.
Markus Kiili
@Masd925
Mar 28 2017 05:42
@thesnowlizard Otherwise it is overwritten on each loop.
Joseph
@revisualize
Mar 28 2017 05:42
@leseanbiz Read the logic
@leseanbiz What is the value of the variable value?
Jason
@thesnowlizard
Mar 28 2017 05:42
@Masd925 ah i c, makes sense. thanks a lot :)
CamperBot
@camperbot
Mar 28 2017 05:42
thesnowlizard sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3670 | @masd925 |http://www.freecodecamp.com/masd925
LeSean Johnson
@leseanbiz
Mar 28 2017 05:42
e
Joseph
@revisualize
Mar 28 2017 05:42
@leseanbiz What is the value of arr[i] if i is 0?
alpox
@alpox
Mar 28 2017 05:42
@leseanbiz Its actually 1
LeSean Johnson
@leseanbiz
Mar 28 2017 05:42
a
Joseph
@revisualize
Mar 28 2017 05:43
@leseanbiz value === arr[i] is this true or false?
LeSean Johnson
@leseanbiz
Mar 28 2017 05:43
if i == true, yes, else, false
i == 4*
Joseph
@revisualize
Mar 28 2017 05:43
Look.
IF i is 0
is that true or false?
LeSean Johnson
@leseanbiz
Mar 28 2017 05:44
false
Joseph
@revisualize
Mar 28 2017 05:44
@leseanbiz (value !== arr[i]) is this true or false?
LeSean Johnson
@leseanbiz
Mar 28 2017 05:44
true
Joseph
@revisualize
Mar 28 2017 05:44
@leseanbiz else if (value !== arr[i]) { return "False" }
@leseanbiz What does a return statement do to your function?
LeSean Johnson
@leseanbiz
Mar 28 2017 05:44
ok
end it
Joseph
@revisualize
Mar 28 2017 05:44
Correct.
@leseanbiz Look at your code and see what you're doing.
alpox
@alpox
Mar 28 2017 05:45
@thesnowlizard Because otherwise the variable product gets reinitialized to 1 in each iteration - so you always just say product = 1 * num; if you have the variable declared inside of the loop
LeSean Johnson
@leseanbiz
Mar 28 2017 05:46
@revisualize are you referring to this code block?
Joseph
@revisualize
Mar 28 2017 05:46
@leseanbiz Do you see why I just took the time to point that out?
LeSean Johnson
@leseanbiz
Mar 28 2017 05:46
  for (var i = 0; i < contacts.length; i++) {
        if (contacts[i].firstName != firstName) {
          return "No such contact"; 
        }else if (contacts[i].hasOwnProperty(prop) !== true){
          return "No such property";
        }else{
           return contacts[i][prop];
        }
    }
Joseph
@revisualize
Mar 28 2017 05:46
@leseanbiz I am referring to that code block
@leseanbiz That loop does not loop.
Jason
@thesnowlizard
Mar 28 2017 05:46
@alpox got it :)
bilaal-s
@bilaal-s
Mar 28 2017 05:46
Hello guys, how do I set thecode editor in FCC to use ES6?
Markus Kiili
@Masd925
Mar 28 2017 05:47
@leseanbiz You need to return inside the loop if you find the right contact, so make positive tests.
LeSean Johnson
@leseanbiz
Mar 28 2017 05:47
ok
alpox
@alpox
Mar 28 2017 05:47
@leseanbiz Since there is no case that none of the if or else inside of the loop are entered, there will be a return executed right in the first iteration of the loop already. The return breaks the loop instantly and returns from the current function.
Joseph
@revisualize
Mar 28 2017 05:48
@leseanbiz Are you seeing why I'm pointing out what I'm pointing out?
bilaal-s
@bilaal-s
Mar 28 2017 05:48
@Masd925 Hey! I remember you telling me once how to set the editor to use ES^, what was it again?
LeSean Johnson
@leseanbiz
Mar 28 2017 05:48
not sure, ill statre at it for a while.
Markus Kiili
@Masd925
Mar 28 2017 05:49
@bilaal-s Try // jshint esversion:6 at the top of the code.
bilaal-s
@bilaal-s
Mar 28 2017 05:49
@Masd925 thanks
CamperBot
@camperbot
Mar 28 2017 05:49
bilaal-s sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3671 | @masd925 |http://www.freecodecamp.com/masd925
Joseph
@revisualize
Mar 28 2017 05:50
@leseanbiz Anyhow. I'm off to bed. Good luck.
LeSean Johnson
@leseanbiz
Mar 28 2017 05:50
@revisualize thanks!
CamperBot
@camperbot
Mar 28 2017 05:50
:star2: 3612 | @revisualize |http://www.freecodecamp.com/revisualize
leseanbiz sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
Matthew
@IMDBLM
Mar 28 2017 05:53
Night folks
obscuredetour
@obscuredetour
Mar 28 2017 05:54
@leseanbiz Try leaving the return "no such contact" outside of your loop as the final aspect.
LeSean Johnson
@leseanbiz
Mar 28 2017 05:54
ok
obscuredetour
@obscuredetour
Mar 28 2017 05:55
If it makes you feel any better you almost have it. Also do what @Masd925 said and make positive tests.
LeSean Johnson
@leseanbiz
Mar 28 2017 06:04
@obscuredetour thanks, i know im really close. i think this is the toughestchallenge ive encountered here so far
CamperBot
@camperbot
Mar 28 2017 06:04
leseanbiz sends brownie points to @obscuredetour :sparkles: :thumbsup: :sparkles:
:cookie: 241 | @obscuredetour |http://www.freecodecamp.com/obscuredetour
LeSean Johnson
@leseanbiz
Mar 28 2017 06:04

  for (var i = 0; i < contacts.length; i++) {
        if (contacts[i].firstName == firstName) {
          if (contacts[i].hasOwnProperty(prop))  {
            return contacts[i][prop];
          }else{
            return "No such property";
          }
          return "No such contact";
          }
        }
// Only change code above this line
}
so, that’s passing 4 of 5 tests
its not returning no such contact, not sure why
Markus Kiili
@Masd925
Mar 28 2017 06:06
@leseanbiz When do you know that you have checked all the contacts for correct first name?
LeSean Johnson
@leseanbiz
Mar 28 2017 06:06
i see it
man, if i could do a backflip……i fuckin would right now\
thanks everybody
Ken Haduch
@khaduch
Mar 28 2017 06:07
@leseanbiz - it looks like your "No such contact" return is within the conditions where you have a firstName match ?
LeSean Johnson
@leseanbiz
Mar 28 2017 06:07
yep
it just passed
Ken Haduch
@khaduch
Mar 28 2017 06:08
@leseanbiz - great!
Markus Kiili
@Masd925
Mar 28 2017 06:10
@leseanbiz :+1:
LeSean Johnson
@leseanbiz
Mar 28 2017 06:11
now that i look back at the first code block i see the logic problem clear as day
i need sleep, been staring at that one for a couple of hours. thanks again guys, have a good night!
Maximus
@maximusfi
Mar 28 2017 06:12
Laters !!
Ogundele Olumide
@Lumexralph
Mar 28 2017 06:13
@Masd925 Good morning
Markus Kiili
@Masd925
Mar 28 2017 06:13
@Lumexralph Morning.
Ogundele Olumide
@Lumexralph
Mar 28 2017 06:14
@Masd925 How's your night?
obscuredetour
@obscuredetour
Mar 28 2017 06:14
good job @leseanbiz ! :) and I'm off to bed too
Maximus
@maximusfi
Mar 28 2017 06:14
var myStr = "Jello World";
myStr = "[0]"; How do I make this hello world by only changing the second line ?
Markus Kiili
@Masd925
Mar 28 2017 06:15
@Lumexralph Fine. No problems in that department.
Maximus
@maximusfi
Mar 28 2017 06:15
I need a better explanation then what Codecamp is telling me.
Sampea
@Sampea
Mar 28 2017 06:17
Good morning all, I was hoping for some help on this JS challenge, I just can't get past/ I'm working on the reminder operator. Can't figure out how to do it. I have done two different ways and neither work.

// Only change code below this line

var remainder;
11 % 3 = 3
3 * 3 = 9
11 - 9 = 2

Or ...
// Only change code below this line

var remainder; 11 % 3 = 3

Any advice would be much appreciated
Owa Aquino
@owaaquino
Mar 28 2017 06:19
I used @leseanbiz code for the same exercise but somehow mine does not return any values from the object -_-
function lookUpProfile(firstName, prop){
  for (var i = 0; i < contacts.length; i++) {
          if (contacts[i].firstName === firstName) {
            if (contacts[i].hasOwnProperty(prop)){
              return contacts[i][prop];
            }else{
              return "No such property";
            }
            }
              return "No such contact";
          }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Gabriel Moreno
@esclavosoy
Mar 28 2017 06:20
@Sampea Are you stuck on a waypoint?
Javier Pons
@JavierPons
Mar 28 2017 06:24
hi guys! morning
Jesse Nixon
@CallMeJess
Mar 28 2017 06:25
With "Sort Arrays with sort" I understand not passing a function in will result in the strings in my array being sorted alphabetically.. Is there a way to reverse the strings by passing in a function? Or is the easiest way to do this just running array.sort(); and then running array.reverse()?
Sampea
@Sampea
Mar 28 2017 06:25
@esclavosoy So embarrassing. yes thank you!
CamperBot
@camperbot
Mar 28 2017 06:25
sampea sends brownie points to @esclavosoy :sparkles: :thumbsup: :sparkles:
:cookie: 219 | @esclavosoy |http://www.freecodecamp.com/esclavosoy
kishore sriramula
@KISHORESSK
Mar 28 2017 06:26
@JavierPons hi good morning Javier
Rahul Jangid
@rjcool9
Mar 28 2017 06:26
@maximusfi to change a string you have to assign it a whole new value,you can't change a single character at a time
Jor
@joreyesl
Mar 28 2017 06:26
@Sampea you should be assigning to remainder, 11 % 3 will return 3. So you assign that operation to remainder.
suhaschauhan
@suhaschauhan
Mar 28 2017 06:27
Can someone explain me [^A-Z^a-z^0-9] reg exp ?
Jor
@joreyesl
Mar 28 2017 06:28
@suhaschauhan [ ] defines a set. Any characters defined inside will be matched. If the set starts with ^ then it will match anything not in the set.
rakesh
@itzmehunter
Mar 28 2017 06:29
plz help......https://goo.gl/bDTTBM
Jesse Nixon
@CallMeJess
Mar 28 2017 06:29
@suhaschauhan "For example, [^abc] is the same as [^a-c]. They initially match 'r' in "brisket" and 'h' in "chop.""
Julio Henriquez
@jhenriquez
Mar 28 2017 06:34
@itzmehunter how can I help you?
rakesh
@itzmehunter
Mar 28 2017 06:35
click on this link https://goo.gl/bDTTBM
kishore sriramula
@KISHORESSK
Mar 28 2017 06:35
@itzmehunter you need to assign it with a number
Julio Henriquez
@jhenriquez
Mar 28 2017 06:36
I saw the problem, but what exactly you don't understand? Maybe I could clarify your doubts.
kishore sriramula
@KISHORESSK
Mar 28 2017 06:36
@itzmehunter you can either declare a variable as var c; or initialize it with a number var c = 1;
Julio Henriquez
@jhenriquez
Mar 28 2017 06:36
@KISHORESSK is right. One of the variables is currently unassigned, the exercise already tells you what value to assign. @itzmehunter
suhaschauhan
@suhaschauhan
Mar 28 2017 06:37
hey @CallMeJess how come [^abc] match r in "brisket".
it wil match a b or c right ?
Julio Henriquez
@jhenriquez
Mar 28 2017 06:39
@suhaschauhan because the ^ is for negation in regex character classes. It will match something that IS NOT the indicated characters. In this case, r is the first match.
kishore sriramula
@KISHORESSK
Mar 28 2017 06:39
@itzmehunter at present your variable "c" is undefined that means , variable c has no value after "=" .. you have yo assign it with a string or number . but in this case the assignment is about initializing C with a string
Jesse Nixon
@CallMeJess
Mar 28 2017 06:39
@suhaschauhan it matches anything that is not enclosed in the brackets.
@suhaschauhan If you want a-c to match don't use ^.
Francesco Lippolis
@flipps-dev
Mar 28 2017 06:43
ok, i try for the fourth time.. how can i loop my function with a callback?
$(function(){
//set animation
$('.fa-arrow-left').on('click', function set_animation(){
$('.container .set').css({'transform':'translate(27px)'});
$('.fa-arrow-left').css({'transform':'rotate(180deg)'});
$('.fa-arrow-left').on('click', function(){
$('.container .set').css({'transform':'translate(220px)'});
$('.fa-arrow-left').css({'transform':'rotate(0deg)'});
})
});
})
Owa Aquino
@owaaquino
Mar 28 2017 06:46
I got it now
function lookUpProfile(firstName, prop){
  for (var i = 0; i < contacts.length; i++) {
          if (contacts[i].firstName == firstName) {
            if (contacts[i].hasOwnProperty(prop))  {
              return contacts[i][prop];
              }else{
                return "No such property";
              }
            }
  }
     return "No such contact";     
// Only change code above this line
}
my question is how so?
what is the purpose of putting the ```
return "No such contact";
JAPerera
@JAPerera
Mar 28 2017 06:46
Having some trouble with a switch statement if someone can help:
function switchOfStuff(val) {
  var answer = "";
  // Only change code below this line
  switch (answer) {
    case "a":
      return("apple");
      break;
    case "b":
      return("bird");
      break;
    case "c":
      return("cat");
      break;
    default:
      return("stuff");
  }


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

// Change this value to test
switchOfStuff(1);
Owa Aquino
@owaaquino
Mar 28 2017 06:46
outside the for loop?

what is the purpose of putting the ```
return "No such contact";

``` out side the for loop?

suhaschauhan
@suhaschauhan
Mar 28 2017 06:47
@CallMeJess therefor [^abc] should match which is not present in brackets i.e anything other than abc , so if we use [^abc] for "brisket" it should match r ,i,s,k,e,t , or am i still wrong?
Alfredo Salazar
@Freedo2012
Mar 28 2017 06:47
quick question. Would I need to use Global Scope and Functions to solve the Stand In Line Problem?
Saz
@SazWebDesigns
Mar 28 2017 06:48
Anyone have trouble with the seek and destroy challenge testing?
Manish Giri
@Manish-Giri
Mar 28 2017 06:49
@Freedo2012 nope
Saz
@SazWebDesigns
Mar 28 2017 06:49
if(arr[i] !== arguments[j]) newArr.push(arr[i]); This keeps testing true even if both values are the same
ZenZate
@ZenZate
Mar 28 2017 06:50
Where can i find a .mp3 link that says times up for my pomodoro clock
Julio Henriquez
@jhenriquez
Mar 28 2017 06:53
@suhaschauhan You're partially right. It is matching. But the match is giving you the first match, in this case r. If you want the result of the whole thing you need to add a global indicator.
So, your regex should be something like this /[^abc]/g
That would give you the expected array
Saz
@SazWebDesigns
Mar 28 2017 06:54
@owaaquino The purpose of the return "no such contact"; on the outside of the loop is that if the first if statements fails then you return that not in contact list. It would propably work if you had it outside the if statements inside the loop
Markus Kiili
@Masd925
Mar 28 2017 06:55
@SazWebDesigns It needs to be outside the loop block.
Conor Murphy
@cmurphy580
Mar 28 2017 06:56

I have two arrays i'm looking for the letters that are common.
Here are the strings that I converted into arrays

s1: "aabcc"
s2: "adcaa"

This is how I was going about it.

function commonCharacterCount(s1, s2) {
    s1 = s1.split(""); 
    s2 = s2.split("");  
   for (var i=0; i<s2.length; i++) {
      var same = (value) => value === s2[i]; 
       return s1.filter(same); 
   }

}

but when return the results I get the two "a's" but not "c", can anyone tell me what the deal is?

Markus Kiili
@Masd925
Mar 28 2017 06:57
@owaaquino The logic is to return inside the loop if you find the right contact and after the loop you know there was no right contact (because the loop didn't return).
suhaschauhan
@suhaschauhan
Mar 28 2017 06:57
@jhenriquez gotcha, thank you !
CamperBot
@camperbot
Mar 28 2017 06:57
suhaschauhan sends brownie points to @jhenriquez :sparkles: :thumbsup: :sparkles:
:cookie: 160 | @jhenriquez |http://www.freecodecamp.com/jhenriquez
Julio Henriquez
@jhenriquez
Mar 28 2017 06:58
@suhaschauhan Always welcome!
Markus Kiili
@Masd925
Mar 28 2017 06:59
@cmurphy580 When you always return on the loop block, the loop only runs once.
Jesse Nixon
@CallMeJess
Mar 28 2017 06:59
@jhenriquez There is no difference between /.+/g and /.+/ though, no? They both only ever match the whole string once.
Conor Murphy
@cmurphy580
Mar 28 2017 07:00
@Masd925 then why am I return two "a"s? I take it outside of the for look and it returns an empty array. I have no idea whats going on
Javier Pons
@JavierPons
Mar 28 2017 07:01
I have to do an algorithm that do next: a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array. I have make till this:
 var temp = [];
 var result = [];

 for (var i = 0; i < arr.length; i++) {
  // arr.slice(0,size).push(temp);
   result.push(temp);
 }
  return result;
}
Markus Kiili
@Masd925
Mar 28 2017 07:01
@cmurphy580 It compares characters of the one string to the first character of the other string.
Javier Pons
@JavierPons
Mar 28 2017 07:01
some advices
JAPerera
@JAPerera
Mar 28 2017 07:01
Hey guys, I'm having some trouble with a switch statement and I'm not sure what's wrong. Any advice?
function switchOfStuff(val) {
  var answer = "";
  // Only change code below this line
  switch (answer) {
    case "a":
      return("apple");
      break;
    case "b":
      return("bird");
      break;
    case "c":
      return("cat");
      break;
    default:
      return("stuff");
  }


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

// Change this value to test
switchOfStuff(1);
Abhushan Gautam
@Avusan09
Mar 28 2017 07:02
hi guys, could you help me with this problem?
JAPerera
@JAPerera
Mar 28 2017 07:02
The only case that's working is the default one.
Markus Kiili
@Masd925
Mar 28 2017 07:02
@JavierPons result.push(...); <- push slices of arr here.
Conor Murphy
@cmurphy580
Mar 28 2017 07:02
@Masd925 ok! if i wanted to do more than one character i have to take it outside the for loop?
Markus Kiili
@Masd925
Mar 28 2017 07:02
@JavierPons Solution is simpler if you increment i+=size.
@cmurphy580 You could use filter and indexOf instead of looping.
Julio Henriquez
@jhenriquez
Mar 28 2017 07:03
@CallMeJess I believe this is called making it greedy. By adding, the plus you're telling the engine to continue matching until the end. The difference is more on the result you're going to get. Actually using the + would ive the full matching string, risket, using the the g will subsequently match the regex against the string, giving you an array of chars that match ['r','i','s','k','e','t']
Hope this helps clarify, I'm actually a bit rusty with regex :)
Jesse Nixon
@CallMeJess
Mar 28 2017 07:04
@jhenriquez Good to know, thanks!
CamperBot
@camperbot
Mar 28 2017 07:04
callmejess sends brownie points to @jhenriquez :sparkles: :thumbsup: :sparkles:
:cookie: 161 | @jhenriquez |http://www.freecodecamp.com/jhenriquez
Julio Henriquez
@jhenriquez
Mar 28 2017 07:05
:+1:
Conor Murphy
@cmurphy580
Mar 28 2017 07:05
@Masd925 alright thanks for the tip. I'll work for that for now.
CamperBot
@camperbot
Mar 28 2017 07:05
cmurphy580 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3672 | @masd925 |http://www.freecodecamp.com/masd925
Abhushan Gautam
@Avusan09
Mar 28 2017 07:08
hello everyone, im having problem in the exercise "Escape Sequences in Strings".
var myStr = "First\tLine\n\"Second\tLine\"\rThird\tLine"; this isn't giving me the solution, could you please help?
Javier Pons
@JavierPons
Mar 28 2017 07:09
@Masd925 I have till here. Works better but not still perfect.
for (var i = 0; i < arr.length; i+ temp = arr.slice(0,i+=size); result.push(temp); } return result; }
Julio Henriquez
@jhenriquez
Mar 28 2017 07:09
@Avusan09 I think I just did that one and I don't recall using tab is it possible you have a different one?
JAPerera
@JAPerera
Mar 28 2017 07:10
@Avusan09 Your string should read 'FirstLine\n\\SecondLine\\\rThirdLine'
Javier Pons
@JavierPons
Mar 28 2017 07:10
@Masd925 sorry in the code are a mistake
DomLeong
@DomLeong
Mar 28 2017 07:11
what did i do wrong in this code "var myStr = "First\tLine\n\"Second\tLine\"\rThird\tLine";"
Question for the code:
myStr should have encoded text with the proper escape sequences and no spacing.
myStr should have one newline character \n
myStr should have one carriage return character \r
myStr should have two correctly escaped backslash characters \
Abhushan Gautam
@Avusan09
Mar 28 2017 07:11
Wow, @JAPerera , it worked. Also thanks, @jhenriquez
CamperBot
@camperbot
Mar 28 2017 07:11
avusan09 sends brownie points to @japerera and @jhenriquez :sparkles: :thumbsup: :sparkles:
:cookie: 80 | @japerera |http://www.freecodecamp.com/japerera
:cookie: 163 | @jhenriquez |http://www.freecodecamp.com/jhenriquez
Julio Henriquez
@jhenriquez
Mar 28 2017 07:11
@DomLeong The expected text result is:
FirstLine
\SecondLine\
ThirdLine
Javier Pons
@JavierPons
Mar 28 2017 07:12
@Masd925 here the code:
 var temp = [];
 var result = [];

 for (var i = 0; i < arr.length; i++){ 
  temp =  arr.slice(0,i+=size);
   result.push(temp);
 }
 return result;
}
Julio Henriquez
@jhenriquez
Mar 28 2017 07:12
I believe you have a couple of extra escape sequences there :)
JAPerera
@JAPerera
Mar 28 2017 07:13
^^ yeah it was the tabs
Aiight - trying one last time before I go to sleep. I'm not sure what's wrong with my switch statement, the only case that's working is the default one:
function switchOfStuff(val) {
  var answer = "";
  // Only change code below this line
  switch (answer) {
    case "a":
      return("apple");
      break;
    case "b":
      return("bird");
      break;
    case "c":
      return("cat");
      break;
    default:
      return("stuff");
  }


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

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