These are chat archives for FreeCodeCamp/HelpJavaScript

28th
Nov 2016
Johnny
@JohnnyBizzel
Nov 28 2016 00:00
@Margaret2 The fix is to move the globals inside the function it says
@Bren8802 format your code
Margaret
@Margaret2
Nov 28 2016 00:00
oh really? that is kind of weird
@Margaret2 Must be a mistake in the test somewhere
Azucena Martinez
@azucenareyes
Nov 28 2016 00:02
If anyone has a few minutes to help me via screenhero on my Github branches please let me know
Latasha Marks
@Latasha3535
Nov 28 2016 00:02
hello everyone i need a little help wtih Reverse a String
Margaret
@Margaret2
Nov 28 2016 00:02
@JohnnyBizzel hmm looks like they are not interested in fixing them either, else i would try
Latasha Marks
@Latasha3535
Nov 28 2016 00:03
i was sure this would work

function reverseString(str) {
var myArray= str.split([" "]);
myArray.reverse();
var i= myArray.join("");
return i;

}

reverseString("hello");

Margaret
@Margaret2
Nov 28 2016 00:04
@Latasha3535 str.split(""), no brackets, no space between quotes
Johnny
@JohnnyBizzel
Nov 28 2016 00:04
@Margaret2 Both issues seem to be reported less than a day ago.
Prashis Raghuwanshi
@prashish14
Nov 28 2016 00:04

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

var gloveBoxContents = myStorage.car.inside.glovbox; // Change this line

error : gloveBoxContents should equal "maps"
Johnny
@JohnnyBizzel
Nov 28 2016 00:04
@Latasha3535 Split with no space ('')
Margaret
@Margaret2
Nov 28 2016 00:05
@JohnnyBizzel yeah, but the guy just said "Move your globals" and closed them
Johnny
@JohnnyBizzel
Nov 28 2016 00:05
:worried:
Margaret
@Margaret2
Nov 28 2016 00:05
that seems pretty final ¯_(ツ)_/¯
lol it removes my backslash in the shrug emoji
Latasha Marks
@Latasha3535
Nov 28 2016 00:06
Thank you i just found it.
Johnny
@JohnnyBizzel
Nov 28 2016 00:06
@Margaret2 I put my 2 cents in: FreeCodeCamp/FreeCodeCamp#11832
@Margaret2 You should know how to format code lol!! :D
Margaret
@Margaret2
Nov 28 2016 00:07
ooh reopening the debate :fire:
¯\_(ツ)_/¯
Prashis Raghuwanshi
@prashish14
Nov 28 2016 00:07
@Margaret2 gloveBoxContents should equal "maps"
Margaret
@Margaret2
Nov 28 2016 00:07
:joy:
that looks terrible
Johnny
@JohnnyBizzel
Nov 28 2016 00:07
:D
Margaret
@Margaret2
Nov 28 2016 00:08
¯\(ツ)
wow so does that
Prashis Raghuwanshi
@prashish14
Nov 28 2016 00:08
@Margaret2 // Only change code below this line
myStorage.car["inside"].glove box;
var gloveBoxContents = ""; // Change this line
error is
Use dot and bracket notation to access myStorage
Margaret
@Margaret2
Nov 28 2016 00:09
@prashish14 which challenge is this
Prashis Raghuwanshi
@prashish14
Nov 28 2016 00:10
Accessing nested objects
Margaret
@Margaret2
Nov 28 2016 00:10
@prashish14 use a . for inside and [] for glove box
@prashish14 and set it equal to gloveBoxContents
Venkateswarrao muppa
@mvrchowdary9999
Nov 28 2016 00:23
i am facing one error in this code.

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

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

return "10 or Under";
}

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

can anyone help me
error is "testGreaterThan(101) should return "Over 100""
pops716
@pops716
Nov 28 2016 00:25
change the first if statement from val>101 to val>100
Venkateswarrao muppa
@mvrchowdary9999
Nov 28 2016 00:26
yup....thanx @pops716
CamperBot
@camperbot
Nov 28 2016 00:28
sorry pops716, you can't send brownie points to yourself! :sparkles: :sparkles:
Henrique Voni
@hendriq
Nov 28 2016 00:57
can someone give me a hand with angular please/
Justin Castro
@justmcastro
Nov 28 2016 00:59

var count = 0;

function cc(card) {
// Only change code below this line
switch(card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;

case 10:
case "J":
case "Q":
case "K":
case "A":
count--;
break;

case 7:
case 8:
case 9:
break;

}

if (card>1) {
return count+ " Bet";
}

else {
return count+ " Hold";
}

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(7); cc(8); cc(9); cc(); cc();

Cards Sequence 7, 8, 9 should return "0 Hold"
Can someone help me with this
Walid Ashri
@walidashri
Nov 28 2016 01:04
@justmcastro works fine !
Johnny
@JohnnyBizzel
Nov 28 2016 01:05
@justmcastro Should it say not if (card>1) { but if (count>1) {
Walid Ashri
@walidashri
Nov 28 2016 01:07
@JohnnyBizzel lol but it did return'0 Hold'
Johnny
@JohnnyBizzel
Nov 28 2016 01:08
@walidashri he is half right!
Walid Ashri
@walidashri
Nov 28 2016 01:09
ah cause last call is cc() :+1: @JohnnyBizzel thanks
CamperBot
@camperbot
Nov 28 2016 01:09
walidashri sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 889 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Nov 28 2016 01:10
@walidashri Yes, he must have got a different card :black_joker:
Walid Ashri
@walidashri
Nov 28 2016 01:11
@JohnnyBizzel yea thank God Bridge doesn't have it
CamperBot
@camperbot
Nov 28 2016 01:11
walidashri sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:warning: walidashri already gave johnnybizzel points
Johnny
@JohnnyBizzel
Nov 28 2016 01:12
@walidashri he he :D
João Mhurilo Godoi da Silva
@ebak123
Nov 28 2016 01:12
Guys, i wanna make a button to switch from Celsius to Fahrenheit, and i've to take the value of temperatura and make some maths, but i cant manipulate these values.. How can i do that? Here is the code: http://codepen.io/ebrak123/pen/oYeWBL?editors=1010
John
@flyboy1565
Nov 28 2016 01:14
@ebak123 , this could be accomplished multiple ways. You set a global variable that is changed on click, you could set and input with the value and on click change that value
Justin Castro
@justmcastro
Nov 28 2016 01:16
@JohnnyBizzel Thank you I had to change it to count > 0 and it worked! :smile:
CamperBot
@camperbot
Nov 28 2016 01:16
justmcastro sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 891 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
João Mhurilo Godoi da Silva
@ebak123
Nov 28 2016 01:16
@flyboy1565 sure, but i've to get this values as NUMBERs, because i've to make some math with them. My global variable it seems be a string, idk
Johnny
@JohnnyBizzel
Nov 28 2016 01:16
@justmcastro Bueno :D
DestroyingLight
@DestroyingLight
Nov 28 2016 01:17
this is horrible right?
// jshint esversion:6
function chunkArrayInGroups(arr, size) {
  // Break it up.
 var newArray = [];

  function addToArray(index){
    if(index >= arr.length){
      return newArray;
    }
    newArray.push(arr.slice(index, index + size));
    return addToArray(index+size);
  }

  return addToArray(0);
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Johnny
@JohnnyBizzel
Nov 28 2016 01:17
@ebak123 convert a string to a number: Number(someVar)
@DestroyingLight Dreadful :worried:
DestroyingLight
@DestroyingLight
Nov 28 2016 01:18
I tried to use recursion
Johnny
@JohnnyBizzel
Nov 28 2016 01:18
@DestroyingLight Does it work?
DestroyingLight
@DestroyingLight
Nov 28 2016 01:19
it passes the challenge
Johnny
@JohnnyBizzel
Nov 28 2016 01:19
@DestroyingLight Good enough for me :+1:
João Mhurilo Godoi da Silva
@ebak123
Nov 28 2016 01:19
@JohnnyBizzel Nope, doesnt work
DestroyingLight
@DestroyingLight
Nov 28 2016 01:19
I wanna know how to improve it
johcoh11
@johcoh11
Nov 28 2016 01:19
Can someone stupefy "scope" for me?
João Mhurilo Godoi da Silva
@ebak123
Nov 28 2016 01:20
@JohnnyBizzel it's resulting in NaN
Johnny
@JohnnyBizzel
Nov 28 2016 01:21
@ebak123 I will take a look now
DestroyingLight
@DestroyingLight
Nov 28 2016 01:21
@JohnnyBizzel do you know how to improve it?
Johnny
@JohnnyBizzel
Nov 28 2016 01:21
@ebak123 You should split the text from the number 4.12C°
Walid Ashri
@walidashri
Nov 28 2016 01:22
@ebak123 la tembratura es stringo :)
 $('#botao').on("click", function(){ 
  temperatura2=parseInt(temperatura)*9/5+32;
  $("#Temperatura").html(temperatura2+" -  ");
  });
Johnny
@JohnnyBizzel
Nov 28 2016 01:22
@ebak123 most people have separate fields for the temperatura and the unit
@DestroyingLight
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var newArr = [];
  var i = 0;

  while (i < arr.length) {
    newArr.push(arr.slice(i, i+size));
    i += size;
  }
  return newArr;
}
chunkArrayInGroups(["a", "b", "c", "d"], 2);
João Mhurilo Godoi da Silva
@ebak123
Nov 28 2016 01:24
@walidashri Thank you
CamperBot
@camperbot
Nov 28 2016 01:24
ebak123 sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 704 | @walidashri |http://www.freecodecamp.com/walidashri
João Mhurilo Godoi da Silva
@ebak123
Nov 28 2016 01:24
@JohnnyBizzel Thank you
CamperBot
@camperbot
Nov 28 2016 01:24
ebak123 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 892 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Nov 28 2016 01:24
@ebak123 :+1: good luck
DestroyingLight
@DestroyingLight
Nov 28 2016 01:24
@JohnnyBizzel you think I shouldn't try to force recursion on it?
Johnny
@JohnnyBizzel
Nov 28 2016 01:24
@DestroyingLight no need. Here is where I got that code: https://forum.freecodecamp.com/t/algorithm-chunky-monkey/16005
DestroyingLight
@DestroyingLight
Nov 28 2016 01:28
thanks @JohnnyBizzel
CamperBot
@camperbot
Nov 28 2016 01:28
destroyinglight sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 893 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
DestroyingLight
@DestroyingLight
Nov 28 2016 01:29
I think I try to hard to use recursion and functional constructs
Johnny
@JohnnyBizzel
Nov 28 2016 01:29
@DestroyingLight Anytime. All the answers are in the Forum wiki section
DestroyingLight
@DestroyingLight
Nov 28 2016 01:31
I'm on a crusade on not using loops
Johnny
@JohnnyBizzel
Nov 28 2016 01:31
@DestroyingLight Ha ha. map, reduce, filter , the spread operator. You have a few tools in the box.
DestroyingLight
@DestroyingLight
Nov 28 2016 01:31
that's what I try
Johnny
@JohnnyBizzel
Nov 28 2016 01:32
Make sure your code is readable though!
DestroyingLight
@DestroyingLight
Nov 28 2016 01:32
yeah :(
Michael Morris
@micshot
Nov 28 2016 01:37
So I started using FCC for a few months and was going along well. Life got in the way and knee surgery, ha. So it's been 4 months since I did FCC. How would someone recommend jumping back in?
Walid Ashri
@walidashri
Nov 28 2016 01:43
@micshot Do some physio therapy little walk and no heavy lifting :)
Hope you are good now
Anthony
@jawaka72
Nov 28 2016 01:43
function titleCase(str) {
   str = str.toLowerCase().split(' ');

  for(var i = 0; i < str.length; i++){
        var newStr = str[0];
          return  newStr.toUpperCase();
  }
  return str;
}
titleCase("I'm a little tea pot");
Hey, I'm having trouble trying to access each of the other elements in the string. I need to capitalize the first letter of each word in the string while the rest of the word remains lowercase.What might be the best way to get each element?
Johnny
@JohnnyBizzel
Nov 28 2016 01:46
@micshot Review what you learned before. Should not take you so long.
@jawaka72 Looks close. What exactly are you returning? Also what are you looping over?
Anthony
@jawaka72
Nov 28 2016 01:48
I only return the first letter of the first word.
Yaroslav Newman
@YaroNew
Nov 28 2016 01:48
Hello Guys!
Johnny
@JohnnyBizzel
Nov 28 2016 01:48
@jawaka72 You know why?
Anthony
@jawaka72
Nov 28 2016 01:48
I'm looping over the split string
Johnny
@JohnnyBizzel
Nov 28 2016 01:48
@YaroNew Morning Yaroslav
Anthony
@jawaka72
Nov 28 2016 01:49
I do not know why.
Johnny
@JohnnyBizzel
Nov 28 2016 01:49
@jawaka72 No you are not. var newStr = str[0];
Anthony
@jawaka72
Nov 28 2016 01:50
Right. I tried using i in place of 0, but i only returns the first element. I always thought i represented each element in the array.
Yaroslav Newman
@YaroNew
Nov 28 2016 01:50
@JohnnyBizzel It's evening in Canada, btw. ^)
Johnny
@JohnnyBizzel
Nov 28 2016 01:50
@YaroNew Oh sorry. 1:50 here in England
Yaroslav Newman
@YaroNew
Nov 28 2016 01:50
GUys, help me with that one. ^)
Johnny
@JohnnyBizzel
Nov 28 2016 01:51
@jawaka72 So what about var newStr = str[i]; ?
Yaroslav Newman
@YaroNew
Nov 28 2016 01:51
https://www.freecodecamp.com/challenges/profile-lookup#?solution=%0A%2F%2FSetup%0Avar%20contacts%20%3D%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Akira%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Laine%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220543236543%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Pizza%22%2C%20%22Coding%22%2C%20%22Brownie%20Points%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Harry%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Potter%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220994372684%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Hogwarts%22%2C%20%22Magic%22%2C%20%22Hagrid%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Sherlock%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Holmes%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%220487345643%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Intriguing%20Cases%22%2C%20%22Violin%22%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22firstName%22%3A%20%22Kristian%22%2C%0A%20%20%20%20%20%20%20%20%22lastName%22%3A%20%22Vos%22%2C%0A%20%20%20%20%20%20%20%20%22number%22%3A%20%22unknown%22%2C%0A%20%20%20%20%20%20%20%20%22likes%22%3A%20%5B%22Javascript%22%2C%20%22Gaming%22%2C%20%22Foxes%22%5D%0A%20%20%20%20%7D%0A%5D%3B%0A%0A%0Afunction%20lookUpProfile(firstName%2C%20prop)%7B%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Aif%20(firstName%5B3%5D.lastname%5B3%5D)%3B%20%20%7B%0A%20%20%20%20return%20lastname%5B3%5D%3B%0A%20%20%7D%0A%20%20%0A%20%20else%20if%20(firstName%5B2%5D.likes%5B2%5D)%0A%20%20%20%20%20return%20likes%5B2%5D%3B%0A%20%20%7D%0A%2F%2F%20Only%20change%20code%20above%20this%20line%0A%7D%0A%0A%2F%2F%20Change%20these%20values%20to%20test%20your%20function%0AlookUpProfile(%22Akira%22%2C%20%22likes%22)%3B%0A
Anthony
@jawaka72
Nov 28 2016 01:51
That just returns the first word in the string
Yaroslav Newman
@YaroNew
Nov 28 2016 01:51
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
if (firstName[3].lastname[3]);  {
    return lastname[3];
  }

  else if (firstName[2].likes[2])
     return likes[2];
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Anthony
@jawaka72
Nov 28 2016 01:51
I can access that word fine, but it's also getting the other ones at the same time that is my problem
Johnny
@JohnnyBizzel
Nov 28 2016 01:51
@jawaka72 Yes, don't return in the middle of a for loop in this case.
@YaroNew Your code should be more flexible than that
@jawaka72 I would also look at .substr() function
And do this var newStr = str[i][0]; to get the first letter of the string you are processing in the loop
Khensura25
@Khensura25
Nov 28 2016 01:55
help anyon
CamperBot
@camperbot
Nov 28 2016 01:55
no wiki entry for: anyon
Johnny
@JohnnyBizzel
Nov 28 2016 01:55
@YaroNew Do you know about hasOwnProperty ?
c0d0er
@c0d0er
Nov 28 2016 01:56
@TylerMoeller thanks!
CamperBot
@camperbot
Nov 28 2016 01:56
c0d0er sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1006 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
Khensura25
@Khensura25
Nov 28 2016 01:58
help anyone ??
CamperBot
@camperbot
Nov 28 2016 01:58
no wiki entry for: anyone
Johnny
@JohnnyBizzel
Nov 28 2016 01:58
@Khensura25 With what? I'm off to bed soon
Khensura25
@Khensura25
Nov 28 2016 01:58
instructions
Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr
@JohnnyBizzel my code is

function multiplyAll(arr) {
var product = 1;
for (var i = 0; i < multiplyAll().length; i++) {
for(var j = 0; j < multiplyAll([i]).length; j++) {
console.log(multiplyAll[i][j]* product);
}
}

return product;
}

Mr Dao
@tikikun
Nov 28 2016 01:59
i don't get the point of "Everything Be True" challenge
what does it mean by "truthy" on all elements??
Johnny
@JohnnyBizzel
Nov 28 2016 02:00
@Khensura25 What is the input?
c0d0er
@c0d0er
Nov 28 2016 02:00
@JohnnyBizzel thanks
CamperBot
@camperbot
Nov 28 2016 02:00
c0d0er sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 894 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Nov 28 2016 02:01
@tikikun "truthy" means true but also some other things are classed as true eg 1 is truthy 0 is falsy.
Khensura25
@Khensura25
Nov 28 2016 02:01
multiplyAll([[1,2],[3,4],[5,6,7]]); this @JohnnyBizzel
Johnny
@JohnnyBizzel
Nov 28 2016 02:01
@c0d0er Anytime
Yaroslav Newman
@YaroNew
Nov 28 2016 02:02
@JohnnyBizzel yes. it was in a couple lessons before
Johnny
@JohnnyBizzel
Nov 28 2016 02:03
@Khensura25 You have the function call in the loops. Use arr.length
c0d0er
@c0d0er
Nov 28 2016 02:04
@walidashri thanks!
CamperBot
@camperbot
Nov 28 2016 02:04
c0d0er sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 705 | @walidashri |http://www.freecodecamp.com/walidashri
Yaroslav Newman
@YaroNew
Nov 28 2016 02:04
@JohnnyBizzel as far as i see it should be if\else statments
Johnny
@JohnnyBizzel
Nov 28 2016 02:04
@YaroNew You should be testing the collection ... if (contacts[i].hasOwnProperty(prop)) etc
I used a loop to find the correct record.
@c0d0er What's with all the thanks Bill?
CamperBot
@camperbot
Nov 28 2016 02:06
johnnybizzel sends brownie points to @c0d0er :sparkles: :thumbsup: :sparkles:
:cookie: 315 | @c0d0er |http://www.freecodecamp.com/c0d0er
Yaroslav Newman
@YaroNew
Nov 28 2016 02:06
@JohnnyBizzel thx will try now
CamperBot
@camperbot
Nov 28 2016 02:06
yaronew sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 895 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
c0d0er
@c0d0er
Nov 28 2016 02:07
@JohnnyBizzel thanks for your time
CamperBot
@camperbot
Nov 28 2016 02:07
c0d0er sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:warning: c0d0er already gave johnnybizzel points
Johnny
@JohnnyBizzel
Nov 28 2016 02:07
@c0d0er Anytime. I am following KC at Denver for a while before going to bed :football:
Khensura25
@Khensura25
Nov 28 2016 02:08
@JohnnyBizzel I did this:

var product = 1;
for (var i = 0; i < arr.length; i++) {
for(var j = 0; j < arr.length; j++) {
console.log(arr[i][j]* product);
}
}

return product;
}

Yaroslav Newman
@YaroNew
Nov 28 2016 02:08
@JohnnyBizzel
function lookUpProfile(firstName, prop){
// Only change code below this line
if (contacts[3].hasOwnProperty(lastname[3]));  {
    return "Vos";

  }
Yaroslav Newman
@YaroNew
Nov 28 2016 02:08
Doesn't work
Khensura25
@Khensura25
Nov 28 2016 02:08
it gave me the output of only 1 @JohnnyBizzel
Yaroslav Newman
@YaroNew
Nov 28 2016 02:09
@JohnnyBizzel
function lookUpProfile(firstName, prop){
// Only change code below this line
if (contacts[3].hasOwnProperty("Vos"));  {
    return "Vos";
Johnny
@JohnnyBizzel
Nov 28 2016 02:09
This is how to format code
'''
CamperBot
@camperbot
Nov 28 2016 02:09
:bulb: to format code use backticks! ``` more info
Yaroslav Newman
@YaroNew
Nov 28 2016 02:09
works like this
Johnny
@JohnnyBizzel
Nov 28 2016 02:10
@YaroNew .hasOwnProperty(prop) use the variable you are passing into the function
Khensura25
@Khensura25
Nov 28 2016 02:11

''' function multiplyAll(arr) {
var product = 1;
for (var i = 0; i < arr.length; i++) {
for(var j = 0; j < arr.length; j++) {
console.log(arr[i][j]*= product);
}
}

return product;
}

CamperBot
@camperbot
Nov 28 2016 02:11
:bulb: to format code use backticks! ``` more info
Khensura25
@Khensura25
Nov 28 2016 02:11

''' js
function multiplyAll(arr) {
var product = 1;
for (var i = 0; i < arr.length; i++) {
for(var j = 0; j < arr.length; j++) {
console.log(arr[i][j]*= product);
}
}

return product;
}

CamperBot
@camperbot
Nov 28 2016 02:11
:bulb: to format code use backticks! ``` more info
Stephen James
@sjames1958gm
Nov 28 2016 02:12
@Khensura25 use `
@Khensura25 At beginning and end of post.
Johnny
@JohnnyBizzel
Nov 28 2016 02:12
` not '
Khensura25
@Khensura25
Nov 28 2016 02:12
function multiplyAll(arr) {
  var product = 1;
  for (var i = 0; i < arr.length; i++) {
    for(var j = 0; j < arr.length; j++) {
      console.log(arr[i][j]*= product);
  }
}

  return product;
}
Johnny
@JohnnyBizzel
Nov 28 2016 02:12
Yay!!
Khensura25
@Khensura25
Nov 28 2016 02:13
thanks lol @JohnnyBizzel @sjames1958gm
CamperBot
@camperbot
Nov 28 2016 02:13
khensura25 sends brownie points to @johnnybizzel and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 896 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
:star2: 4572 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Johnny
@JohnnyBizzel
Nov 28 2016 02:13
@Khensura25 you are not incrementing product
Evan Kalvis
@evan17gr
Nov 28 2016 02:13
var myStr="FirstLine\n\SecondLine\rThridLine" what have i doe wrong?
Johnny
@JohnnyBizzel
Nov 28 2016 02:13
@evan17gr '''
CamperBot
@camperbot
Nov 28 2016 02:13
:bulb: to format code use backticks! ``` more info
Stephen James
@sjames1958gm
Nov 28 2016 02:13
@Khensura25 arr[i][j]*= product this will put the result into the array not into product
@evan17gr - you misspelled Third and it looks like you are missing two `\ after SecondLIne
Johnny
@JohnnyBizzel
Nov 28 2016 02:14
@evan17gr Your actual code will not show properly unless you format it with backticks
Khensura25
@Khensura25
Nov 28 2016 02:15
@JohnnyBizzel what do you mean by I am not incrementing product
Yaroslav Newman
@YaroNew
Nov 28 2016 02:15
@JohnnyBizzel

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


function lookUpProfile(firstName, prop){
// Only change code below this line
if (contacts[3].hasOwnProperty("Vos"));  {
    return "Vos";
  } else if (contacts[2].hasOwnProperty("likes")); {
    return ["Intriguing Cases", "Violin"];   
 }


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Evan Kalvis
@evan17gr
Nov 28 2016 02:16
i dont undersatnd hoe they work @JohnnyBizzel
Yaroslav Newman
@YaroNew
Nov 28 2016 02:16
Cant get any further with this one
Johnny
@JohnnyBizzel
Nov 28 2016 02:16
'''
CamperBot
@camperbot
Nov 28 2016 02:16
:bulb: to format code use backticks! ``` more info
Johnny
@JohnnyBizzel
Nov 28 2016 02:16
^^ click the link here
Evan Kalvis
@evan17gr
Nov 28 2016 02:16
ok
Johnny
@JohnnyBizzel
Nov 28 2016 02:16
@YaroNew You are not looping over the collection still
Khensura25
@Khensura25
Nov 28 2016 02:16
@sjames1958gm I switched it to ```js
João Mhurilo Godoi da Silva
@ebak123
Nov 28 2016 02:17
Guys, how can i make a function for alternates 2 values? Like: I dysplay the number 2 as default. If i click a button, the number change to 10. If i click again, the number return to 2.
Khensura25
@Khensura25
Nov 28 2016 02:17
var product = 1;
  for (var i = 0; i < arr.length; i++) {
    for(var j = 0; j < arr.length; j++) {
      console.log(product *= arr[j]);
  }
}

  return product;
}
Yaroslav Newman
@YaroNew
Nov 28 2016 02:17
@JohnnyBizzel Why should I loop in if I can just give an exact answer to every question?
Johnny
@JohnnyBizzel
Nov 28 2016 02:18
@YaroNew Then why write a function?
@Khensura25 You probably don't need the console log now
@ebak123 In jQuery use toggle, but I'm not really sure what you want to do
Yaroslav Newman
@YaroNew
Nov 28 2016 02:19
@JohnnyBizzel do you mean use While loops?
Johnny
@JohnnyBizzel
Nov 28 2016 02:20
@YaroNew Any loop will do. Just don't hard code values inside the function.
Kenichi
@Kenichiwaa
Nov 28 2016 02:20
var count = 0;

function cc(card) {
  // Only change code below this line
  if(card === 2,3,4,5,6){
    ++count;
  }else if(card === 10,'J','Q','K','A'){
    --count;
  }

  var action = "";

  if( count <= 0 ){
    action = "Hold";
  }else {
    action = "Bet";
  }

  return count + " " + action;
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc('K'); cc('A'); cc('Q'); //cc(8); cc(9);
Khensura25
@Khensura25
Nov 28 2016 02:20

```js
function multiplyAll(arr) {
var product = 1;
for (var i = 0; i < arr.length; i++) {
for(var j = 0; j < arr.length; j++) {
product *= arr[i][j];
}
}

return product;
}
``` @JohnnyBizzel here is my latest attempt, Im getting back null

function multiplyAll(arr) {
var product = 1;
for (var i = 0; i < arr.length; i++) {
for(var j = 0; j < arr.length; j++) {
product *= arr[i][j];
}
}
return product;
}
Kenichi
@Kenichiwaa
Nov 28 2016 02:21
Do yo guys see what is not correct with this code?
Johnny
@JohnnyBizzel
Nov 28 2016 02:21
@Kenichiwaa Close but you might need a space before " Hold" and " Bet"
@Khensura25 Flatten the array first. Is that allowed? Then you only need 1 loop
Yaroslav Newman
@YaroNew
Nov 28 2016 02:23
@JohnnyBizzel
function lookUpProfile(firstName, prop){
// Only change code below this line
if (contacts[3].hasOwnProperty("Vos"));  
    return contacts.push("lastname"[3]);



// Only change code above this line
}
it gives me 5
)))
Instead "Vos" )))
Khensura25
@Khensura25
Nov 28 2016 02:23
@JohnnyBizzel flatten??
Kenichi
@Kenichiwaa
Nov 28 2016 02:23
@JohnnyBizzel the return count is 3 when it should be negative or something else somehow
Johnny
@JohnnyBizzel
Nov 28 2016 02:23
@YaroNew Still no loop?
Yaroslav Newman
@YaroNew
Nov 28 2016 02:24
cant get it
Evan Kalvis
@evan17gr
Nov 28 2016 02:24
@JohnnyBizzel ty for the help
CamperBot
@camperbot
Nov 28 2016 02:24
evan17gr sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 897 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Kenichi
@Kenichiwaa
Nov 28 2016 02:24
@JohnnyBizzel that output should of been -3
Yaroslav Newman
@YaroNew
Nov 28 2016 02:24
give me an wxample pls
lessons are totaly differs from assingments
Johnny
@JohnnyBizzel
Nov 28 2016 02:24
@YaroNew
 for (var i = 0; i < len; i++) {

    if (contacts[i].hasOwnProperty(prop) && contacts[i].firstName == firstName) {
      return (contacts[i][prop]);
    }
@evan17gr :+1:
@Khensura25 flatten - turn a multi dim array into a single dim array
João Mhurilo Godoi da Silva
@ebak123
Nov 28 2016 02:25
@JohnnyBizzel i Need the button for alternate my temperatures from Celsius to Fahrenheit
Stephen James
@sjames1958gm
Nov 28 2016 02:26
@Kenichiwaa card === 2,3,4,5,6 the result of this is 6 the comma is not how you combine comparisons - use || as in card === 2 || card === 3
Kenichi
@Kenichiwaa
Nov 28 2016 02:28
@sjames1958gm oh word! thanks man!
CamperBot
@camperbot
Nov 28 2016 02:28
kenichiwaa sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4573 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Khensura25
@Khensura25
Nov 28 2016 02:28
@JohnnyBizzel that worked but the challenge is specifically trying to deal with the case for a nested array within an array
Johnny
@JohnnyBizzel
Nov 28 2016 02:28
@ebak123 HTML element <a id="temperature" class="retro" href="#" onclick="switchUnits(); . .. etc
@Khensura25 I forget, what is the name of the challenge?
Khensura25
@Khensura25
Nov 28 2016 02:28
@JohnnyBizzel , INSTRUCTIONS: Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr
NESTING FOR LOOPS @JohnnyBizzel
Johnny
@JohnnyBizzel
Nov 28 2016 02:30
@Khensura25 Oh ok. My bad. You have passed then?
Kenichi
@Kenichiwaa
Nov 28 2016 02:31
@sjames1958gm do you think there is a more efficient way to write that out b/c what if there were like 500 || 'or' you need to compare...
Stephen James
@sjames1958gm
Nov 28 2016 02:31
@Kenichiwaa if card >=2 && card <= 6
João Mhurilo Godoi da Silva
@ebak123
Nov 28 2016 02:32
@JohnnyBizzel this wasnt so helpful ...
Khensura25
@Khensura25
Nov 28 2016 02:32
@JohnnyBizzel nope, heres what i got so far and the console output is "null"
Yaroslav Newman
@YaroNew
Nov 28 2016 02:32
@JohnnyBizzel

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


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

    if (contacts[3].hasOwnProperty("prop") && contacts[3].firstName == "Kristian") {
      return (contacts[3].Vos);
    }



// Only change code above this line
}
Johnny
@JohnnyBizzel
Nov 28 2016 02:33
@ebak123 This is how I did it: http://codepen.io/JohnnyBizzel/pen/BKMPpp
Yaroslav Newman
@YaroNew
Nov 28 2016 02:33
Doesn't work
Kenichi
@Kenichiwaa
Nov 28 2016 02:33
@sjames1958gm thanks
CamperBot
@camperbot
Nov 28 2016 02:33
kenichiwaa sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: kenichiwaa already gave sjames1958gm points
Khensura25
@Khensura25
Nov 28 2016 02:33
function multiplyAll(arr) {
  var product = 1;
  for (var i = 0; i < arr.length; i++) {
    for(var j = 0; j < arr.length; j++) {
      product *= arr[i][j];
  }
}

  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
@JohnnyBizzel
Johnny
@JohnnyBizzel
Nov 28 2016 02:35
@YaroNew
Try this instead:
function lookUpProfile(firstName, prop){
// Only change code below this line
var len =contacts.length;
for (var i = 0; i < len; i++) 

    if (contacts[3].hasOwnProperty(prop) && contacts[3].firstName == "Kristian") {
      return (contacts[3][prop]);
    }
// Only change code above this line
}
lookUpProfile('Kristian', "lastName");
@Khensura25 The inner loop should not be over the main array - that's the one with j as the index
Yaroslav Newman
@YaroNew
Nov 28 2016 02:38
@JohnnyBizzel

"Kristian", "lastName" should return "Vos"
"Sherlock", "likes" should return ["Intriguing Cases", "Violin"]
"Harry","likes" should return an array
"Bob", "number" should return "No such contact"
"Akira", "address" should return "No such property"
Khensura25
@Khensura25
Nov 28 2016 02:38
@JohnnyBizzel thanks Sir!!!!!!!!!!!!!!! finally
CamperBot
@camperbot
Nov 28 2016 02:38
khensura25 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:warning: khensura25 already gave johnnybizzel points
Yaroslav Newman
@YaroNew
Nov 28 2016 02:38
It works only for 1st and 3rd
Johnny
@JohnnyBizzel
Nov 28 2016 02:39
@YaroNew You need a loop - this is hard coding the search contacts[3] therefore you never search an other than the 4th element
Anthony
@jawaka72
Nov 28 2016 02:41
function titleCase(str) {
   str = str.toLowerCase().split(' ');
    var newStr;
    for(var i = 0; i < str.length; i++){
       newStr = str[i][0];
  }

  return newStr;
}
titleCase("I'm a little tea pot");
I changed up my code a little bit, but still having a hard time. Now my code only returns the first letter of the last word of the string.
Johnny
@JohnnyBizzel
Nov 28 2016 02:42
@jawaka72 Did you check substr (substring)?
Anthony
@jawaka72
Nov 28 2016 02:43
I did try that, but I didn't find it very useful. Would I append substr to str and not include the [i][0]?
Johnny
@JohnnyBizzel
Nov 28 2016 02:44
@jawaka72 You have the upper cased first letter correct?
If so then you need the rest of the string. You can get this with substr
Anthony
@jawaka72
Nov 28 2016 02:45
No, all of the words in the string are set to lowercase. I figured it would be easier to set everything to lowercase first, then try to capitalize the words after
Yaroslav Newman
@YaroNew
Nov 28 2016 02:46
@JohnnyBizzel It's so hard and frustrating
Anthony
@jawaka72
Nov 28 2016 02:48
@YaroNew lol We're all hurting together
Stephen James
@sjames1958gm
Nov 28 2016 02:48
@jawaka72 You have the first character - then upper case that - add back the rest of the word -
Then you will need to save each word so you can rebuild the sentence
Johnny
@JohnnyBizzel
Nov 28 2016 02:51
@jawaka72 If you want the answer it his here: https://jsfiddle.net/JohnnyBizzel/qd0bzqn9/
@YaroNew If you want the answer it is here: https://jsfiddle.net/JohnnyBizzel/xky73ga9/
Walid Ashri
@walidashri
Nov 28 2016 02:51
@JohnnyBizzel lol
Anthony
@jawaka72
Nov 28 2016 02:52
I'll monkey around with it for a bit, then check out the answer. Thanks @JohnnyBizzel
CamperBot
@camperbot
Nov 28 2016 02:52
jawaka72 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 898 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Nov 28 2016 02:52
It is my bed time!!
@jawaka72 Clue: I used substr on the final sentence also!
Walid Ashri
@walidashri
Nov 28 2016 02:53
@JohnnyBizzel https://repl.it/E8x7
Johnny
@JohnnyBizzel
Nov 28 2016 02:53
@walidashri Nice. Better than mine :D
Hossein Ghanaati
@Hossein-Ghanaati
Nov 28 2016 02:53
hi everyone i am in "Seek and Destroy" challenge and i get type error and i dont understand why? any one can help? this is my code:
blob
Yaroslav Newman
@YaroNew
Nov 28 2016 02:54
@JohnnyBizzel Thx
CamperBot
@camperbot
Nov 28 2016 02:54
yaronew sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:warning: yaronew already gave johnnybizzel points
Yaroslav Newman
@YaroNew
Nov 28 2016 02:55
@JohnnyBizzel But it doesnt work
@JohnnyBizzel

//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 noContactFound = true;
  var noPropertyFound = false;
  var len = contacts.length;
  for (var i = 0; i < len; i++) {

    if (contacts[i].hasOwnProperty(prop) && contacts[i].firstName == firstName) {
      return JSON.stringify(contacts[i][prop]);
    } 
    else if (!contacts[i].hasOwnProperty(prop)) {
      noPropertyFound = true;
    }
    if (contacts[i].firstName == firstName) noContactFound = false;
  }
  if (noContactFound)  return "No such contact";
  if (noPropertyFound) return "No such property";


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Johnny
@JohnnyBizzel
Nov 28 2016 02:55
@YaroNew I'm sure you will figure it out ;)
Kenneth Amanfo Junior
@amanfojnr
Nov 28 2016 02:57
having problems with the record manipulation under javascript :(
Stephen James
@sjames1958gm
Nov 28 2016 02:58
@Hossein-Ghanaati x is a number not an array - arr is [1, 2, 3, 1, 2, 3] - check the link on arguments in the instructions on how to access all the parameters
Yaroslav Newman
@YaroNew
Nov 28 2016 02:59
@JohnnyBizzel should i just hardcode the rest?
Johnny
@JohnnyBizzel
Nov 28 2016 02:59
@YaroNew what is not working?
Hossein Ghanaati
@Hossein-Ghanaati
Nov 28 2016 02:59
@sjames1958gm ok tnx :) so var x = arr[0]; doesnt work?
Stephen James
@sjames1958gm
Nov 28 2016 02:59
@YaroNew Nowhere in the instructions does it say to JSON.stringify before returning
@Hossein-Ghanaati var x = arr[0] is 1 so trying to call 1.filter() fails
Hossein Ghanaati
@Hossein-Ghanaati
Nov 28 2016 03:01
@sjames1958gm ok tnx
Johnny
@JohnnyBizzel
Nov 28 2016 03:01
@sjames1958gm That's my code he is posting
Stephen James
@sjames1958gm
Nov 28 2016 03:01
@JohnnyBizzel Oh, nvm
Johnny
@JohnnyBizzel
Nov 28 2016 03:01
Lol
Stephen James
@sjames1958gm
Nov 28 2016 03:01
@YaroNew Sry
Johnny
@JohnnyBizzel
Nov 28 2016 03:02
@sjames1958gm maybe you can help him. I am going to bed now.
Yaroslav Newman
@YaroNew
Nov 28 2016 03:02
@JohnnyBizzel It meets only 4th and 5th assingment parameters
first 3 are unchecked still
"Kristian", "lastName" should return "Vos"
"Sherlock", "likes" should return ["Intriguing Cases", "Violin"]
"Harry","likes" should return an array
@JohnnyBizzel it worked
I deleted JSON.stringify and it worked
@JohnnyBizzel i realize that it works but it's so illogical for me that I unable to find explatanion for myself "how come it ever worked out"
@JohnnyBizzel
var noContactFound = true;
  var noPropertyFound = false;
David Halls
@DavidHalls
Nov 28 2016 03:08
feedback pls?
Yaroslav Newman
@YaroNew
Nov 28 2016 03:08
we gave to variables. one is true another false and I can't get why ...

@sjames1958gm now this 2 lines of code..

var len = contacts.length;
  for (var i = 0; i < len; i++)

I don't evern realize why we need them

Stephen James
@sjames1958gm
Nov 28 2016 03:10
@YaroNew you could do for (var i = 0; i < contact.length; i++) but to check each contact for a matching first name you have to have a loop
Yaroslav Newman
@YaroNew
Nov 28 2016 03:11
since JS if\else started - every lesson like a torture... HTMl\CSS were so cool and easy
Alex Shaikevich
@sashakevich
Nov 28 2016 03:13
Hello room. Can anyone direct me to a good filters tutorial/explanations/examples page? I'm having trouble combining a for loop and filters and there's no complex example on MDN that I can follow along.
Stephen James
@sjames1958gm
Nov 28 2016 03:13
js requires more logical thinking
Alex Shaikevich
@sashakevich
Nov 28 2016 03:16
I see I"ve scared you all away
Yaroslav Newman
@YaroNew
Nov 28 2016 03:16
@sjames1958gm that's the thing ) this "logical" thinking seems absolutely illogical at first glance and you expect to wright 10 lines of code but needs only 2
seems like i missing some coding fundamentals may be...
Alex Shaikevich
@sashakevich
Nov 28 2016 03:17
very well, good sirs and female equivalent of sirs, I shall return to google, and call upon you with more complex questions at a later time
Omar Hernandez
@comhernandez28
Nov 28 2016 03:17
hello guys
quick question
Hossein Ghanaati
@Hossein-Ghanaati
Nov 28 2016 03:18
hi everyone i am in "Seek and Destroy" challenge and i dont know why my code doesnt work any one can help? this is my code:
Omar Hernandez
@comhernandez28
Nov 28 2016 03:18
im doing the project "find the longest word"
my code works and returns all the correct answers but its not letting me through
Hossein Ghanaati
@Hossein-Ghanaati
Nov 28 2016 03:18
blob
João Mhurilo Godoi da Silva
@ebak123
Nov 28 2016 03:19
Guys, why it's not working this switch function? RRRRGGGG
http://codepen.io/ebrak123/pen/oYeWBL?editors=1010
Hossein Ghanaati
@Hossein-Ghanaati
Nov 28 2016 03:21
@comhernandez28 copy your code refresh the browser
Stephen James
@sjames1958gm
Nov 28 2016 03:23
@Hossein-Ghanaati every function has its own arguments - so a has arguments different that destroyer.
Hossein Ghanaati
@Hossein-Ghanaati
Nov 28 2016 03:24
@sjames1958gm so?
i dont understand
Omar Hernandez
@comhernandez28
Nov 28 2016 03:24
nvm @Hossein-Ghanaati i figured it out
Hossein Ghanaati
@Hossein-Ghanaati
Nov 28 2016 03:25
it cant get arguements from there? i have build a new local variable?
Stephen James
@sjames1958gm
Nov 28 2016 03:25
@Hossein-Ghanaati You need to move destroyer arguments to another variable so you can refernce inside of a
Omar Hernandez
@comhernandez28
Nov 28 2016 03:25
it turns out that tests are run sequentially so you can not use global variables
Stephen James
@sjames1958gm
Nov 28 2016 03:25
@Hossein-Ghanaati yes
Hossein Ghanaati
@Hossein-Ghanaati
Nov 28 2016 03:25
ok i test it tnx :)
@comhernandez28 gj
Omar Hernandez
@comhernandez28
Nov 28 2016 03:26
thanks @Hossein-Ghanaati just a quick look in the bug section helps a lot
CamperBot
@camperbot
Nov 28 2016 03:26
comhernandez28 sends brownie points to @hossein-ghanaati :sparkles: :thumbsup: :sparkles:
:cookie: 253 | @hossein-ghanaati |http://www.freecodecamp.com/hossein-ghanaati
Corey
@squawpaw
Nov 28 2016 03:26
@sashakevich a video that helped me really start to understand filter was this one: https://www.youtube.com/watch?v=BMUiFMZr7vk
the coding starts at about 2 minutes, but the entire thing is worth a watch!
Stephen James
@sjames1958gm
Nov 28 2016 03:26
@ebak123 because you switch units is defined inside of $(document).ready(function(){ it is not in scope to be called by HTML
Alex Shaikevich
@sashakevich
Nov 28 2016 03:27
@Hossein-Ghanaati I'm stuck on the same thing atm. If you neeed a working example of a for loop / filter combination check out: http://stackoverflow.com/questions/34044257/javascript-nesting-a-for-loop-inside-an-array-filter maybe it'll help you
João Mhurilo Godoi da Silva
@ebak123
Nov 28 2016 03:27
k, i tryed this too @sjames1958gm , but if i put outside the $(document).ready(function(){, my variables doesnt count
Stephen James
@sjames1958gm
Nov 28 2016 03:28
@ebak123 You'll need to use jquery to add a click handler to the button then you can put it in the same scope
IanG29
@IanG29
Nov 28 2016 03:30
how can I solve the Sift through Text with Regular Expressions thing, I already tried everything
Alex Shaikevich
@sashakevich
Nov 28 2016 03:30
@squawpaw thanks! I'm on the lookout for a good JS youtube channel. This guy is my favorite so far: https://www.youtube.com/watch?v=q_MXH_Ponpg&list=PL6n9fhu94yhUA99nOsJkKXBqokT3MBK0b&index=22 until I finish watching your share that is
CamperBot
@camperbot
Nov 28 2016 03:30
sashakevich sends brownie points to @squawpaw :sparkles: :thumbsup: :sparkles:
:cookie: 333 | @squawpaw |http://www.freecodecamp.com/squawpaw
Stephen James
@sjames1958gm
Nov 28 2016 03:34
@IanG29 It tells you exactly what to do - replace the . with and
Corey
@squawpaw
Nov 28 2016 03:36
Thanks for the rec @sashakevich ! I'll definitely check that out!
CamperBot
@camperbot
Nov 28 2016 03:36
squawpaw sends brownie points to @sashakevich :sparkles: :thumbsup: :sparkles:
:cookie: 253 | @sashakevich |http://www.freecodecamp.com/sashakevich
Hossein Ghanaati
@Hossein-Ghanaati
Nov 28 2016 03:37
@sjames1958gm it worked man tnx, you were right i was refering to wrong function argument :smile: :+1:
Stephen James
@sjames1958gm
Nov 28 2016 03:37
@Hossein-Ghanaati :+1:
@Hossein-Ghanaati IF you refer to me and type thanks - I get credit :)
CamperBot
@camperbot
Nov 28 2016 03:37
sjames1958gm sends brownie points to @hossein-ghanaati :sparkles: :thumbsup: :sparkles:
:cookie: 254 | @hossein-ghanaati |http://www.freecodecamp.com/hossein-ghanaati
Hossein Ghanaati
@Hossein-Ghanaati
Nov 28 2016 03:37
stupid misttake :D
Stephen James
@sjames1958gm
Nov 28 2016 03:38
@Hossein-Ghanaati Well, kind of a knowledge gap
Hossein Ghanaati
@Hossein-Ghanaati
Nov 28 2016 03:38
nice :)
@sjames1958gm thanks
CamperBot
@camperbot
Nov 28 2016 03:38
hossein-ghanaati sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4574 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Alex Shaikevich
@sashakevich
Nov 28 2016 03:39
@squawpaw yeah, his explanation, and him showing an alternative solution (using push() ) is great, thanks again for the share
CamperBot
@camperbot
Nov 28 2016 03:39
sashakevich sends brownie points to @squawpaw :sparkles: :thumbsup: :sparkles:
:warning: sashakevich already gave squawpaw points
Hossein Ghanaati
@Hossein-Ghanaati
Nov 28 2016 03:39
btw how these brownie point are usefull?
Greg D
@mosaic-greg
Nov 28 2016 03:42
one brownie point equals one bit coin (joke!)
Hossein Ghanaati
@Hossein-Ghanaati
Nov 28 2016 03:42
@mosaic-greg :))) they are so generous :D
bit coin price 734.35 US Dollar
Greg D
@mosaic-greg
Nov 28 2016 03:45
kind of like an "experience point" i guess
mckinsley1
@mckinsley1
Nov 28 2016 03:47
Guys i need some help on the gold Code

function golfScore(par, strokes) {
// Only change code below this line
if (strokes <= par - 3) {
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 {
return "Go Home!";
}

return "Change Me";
// Only change code above this line
}

João Mhurilo Godoi da Silva
@ebak123
Nov 28 2016 03:47
@sjames1958gm thank you
CamperBot
@camperbot
Nov 28 2016 03:47
ebak123 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4575 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Kirby James
@kirbygit
Nov 28 2016 03:53
can somebody explain this to me
but dont give the answers right away
I wanted to understand it
function golfScore(par, strokes) {
  // Only change code below this line


  return "Change Me";
  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);

golfScore(4, 1) should return "Hole-in-one!"
golfScore(4, 2) should return "Eagle"
golfScore(5, 2) should return "Eagle"
golfScore(4, 3) should return "Birdie"
golfScore(4, 4) should return "Par"
golfScore(1, 1) should return "Hole-in-one!"
golfScore(5, 5) should return "Par"
golfScore(4, 5) should return "Bogey"
golfScore(4, 6) should return "Double Bogey"
golfScore(4, 7) should return "Go Home!"
golfScore(5, 9) should return "Go Home!"

function golfScore(par, strokes) {
// Only change code below this line

return "Change Me";
// Only change code above this line
}

// Change these values to test
golfScore(5, 4);

1

2
function golfScore(par, strokes) {
3
// Only change code below this line
4

5

6
return "Change Me";
7
// Only change code above this line
8
}
9

10
// Change these values to test
11
golfScore(5, 4);
12

function golfScore(par, strokes) {
  // Only change code below this line


  return "Change Me";
  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
golfScore(4, 1) should return "Hole-in-one!"
golfScore(4, 2) should return "Eagle"
golfScore(5, 2) should return "Eagle"
golfScore(4, 3) should return "Birdie"
golfScore(4, 4) should return "Par"
golfScore(1, 1) should return "Hole-in-one!"
golfScore(5, 5) should return "Par"
golfScore(4, 5) should return "Bogey"
golfScore(4, 6) should return "Double Bogey"
golfScore(4, 7) should return "Go Home!"
golfScore(5, 9) should return "Go Home!"
Alex Shaikevich
@sashakevich
Nov 28 2016 03:57
@kboygit sure. But which part? You're basically asked to figure out which scenario is happening.
Kirby James
@kirbygit
Nov 28 2016 03:57
I dont understand yet how to use the table

1 "Hole-in-one!"
<= par - 2 "Eagle"
par - 1 "Birdie"
par "Par"
par + 1 "Bogey"
par + 2 "Double Bogey"

= par + 3 "Go Home!"

Michael J Kusdya
@michael-kusdya
Nov 28 2016 03:57
what's wrong with this code ? i can't get past the " Stand in Line" challenge
function nextInLine(arr, item) {
  // Your code here
  testArr.push(item);
  return testArr.shift();  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Kirby James
@kirbygit
Nov 28 2016 03:58
@MJKno1 arr.push
not testArr
Alex Shaikevich
@sashakevich
Nov 28 2016 03:58
gotcha. So think of a player that's about to start playing golf
Kirby James
@kirbygit
Nov 28 2016 03:58
testArr is already declared
Alex Shaikevich
@sashakevich
Nov 28 2016 03:58
this player has some number of hits that's acceptable
Kirby James
@kirbygit
Nov 28 2016 03:58
hmm okey let me think it
Alex Shaikevich
@sashakevich
Nov 28 2016 03:59
if the player scores the ball (or whatever it's called in golf) in fewer than those number of hits then he's a good player
if it takes more than the acceptable / average number of hits to score then he's a bad player
how good or how bad is what that table tell you
if the average is 4 hits, but the player scores in just 1, the player is really good - he got a hole in one
if the player player makes it in 2, he's not as good as the hole-in-one, but he's still good and getting 2 less than average is called "eagle"
Michael J Kusdya
@michael-kusdya
Nov 28 2016 04:01
@kboygit you're right, thank you
CamperBot
@camperbot
Nov 28 2016 04:01
mjkno1 sends brownie points to @kboygit :sparkles: :thumbsup: :sparkles:
:cookie: 193 | @kboygit |http://www.freecodecamp.com/kboygit
Kirby James
@kirbygit
Nov 28 2016 04:08
@sashakevich how do I write down a line of code for this
example
sandeepwalia
@sandeepwalia
Nov 28 2016 04:11
Hi can anyone guide me on how did they use transition effects in the Random Quote Machine challenge?
Here is my pen http://codepen.io/sandeepwalia/pen/ENmvMj
Eder Rodriguez
@Ederrod
Nov 28 2016 04:16
Java!?
Alex Shaikevich
@sashakevich
Nov 28 2016 04:18
@kboygit
if (something VS something) { do this} 
else if (something vs something  else) { do this other thing }
...
Kirby James
@kirbygit
Nov 28 2016 04:19
@sashakevich holdo n
@sashakevich now I understand
lol
Alex Shaikevich
@sashakevich
Nov 28 2016 04:22
It's the end of the night for me. But, what I've done was, copy the code over here for you: http://codepen.io/sashatouye/pen/vyJbjm
If you get stuck and want to look at the solution that got me past that exercise, you can peak over there.
good luck
Michael Karpinski
@karpimpski
Nov 28 2016 04:25
for(var k = 0; k < thisGroup.words.length; k++){
          dpd.words.get(thisGroup.words[k], function (result) {
            alert("Result: " + result.title + ", " + result.definition);
            definitionsList.push(result.definition);
            wordsList.push(result.title);
            alert("Definitions: " + definitionsList);
          });
        }
        alert("loop completed");
the loop completed alert comes before the loop is completed. can anybody tell me why?
Kirby James
@kirbygit
Nov 28 2016 04:26
@sashakevich how do I write this down
<= par - 2 "Eagle"
lol
in an else if statement
if ( par <= -2) { return "Eagle" ; }
?
Diego Mayer
@Chrono79
Nov 28 2016 05:05
@kboygit you have to compare strokes with the values of the table
Ashan Mohammed
@AshanMohammed
Nov 28 2016 05:26
Hello GUYS! I need to get the country of the user in JavaScript. i wrote the jQuery code to get the country but how do i return the value to javascript or call the function in javascript?
My Code
$.getJSON("http://freegeoip.net/json/", function(data) {
    var country = data.country_name;
    return country;
Manish Giri
@Manish-Giri
Nov 28 2016 05:27
@kboygit
else if(….)
Kirby James
@kirbygit
Nov 28 2016 05:33
@Manish-Giri @Chrono79 I already figured it out cheers guys
MoNag1
@MoNag1
Nov 28 2016 05:37
@AshanMohammed have you figured it out yet?
Ashan Mohammed
@AshanMohammed
Nov 28 2016 05:38
@MoNag1 nope!
Abhisek Pattnaik
@abhisekp
Nov 28 2016 05:39
@mckinsley1
```js  [shift + enter for newline]

<code here>

```    [ctrl + enter to post] 
Manish Giri
@Manish-Giri
Nov 28 2016 05:40
:point_up: November 28, 2016 12:26 AM
@abhisekp for this problem :point_up: , will it work if you set the info obtained from the geoIP.net API into a bunch of global variables outside, and then use those global variables for an API call to openweathermap down the code? Or will that fail?
Ashan Mohammed
@AshanMohammed
Nov 28 2016 05:41
@MoNag1 Any Help?!!!!!!!
MoNag1
@MoNag1
Nov 28 2016 05:41
@AshanMohammed lemme try
Ashan Mohammed
@AshanMohammed
Nov 28 2016 05:41
@MoNag1 ok
Manish Giri
@Manish-Giri
Nov 28 2016 05:41
@AshanMohammed pm me your codepen link
vivek
@myth-vivek
Nov 28 2016 05:41
iam stck at challenge 94. anyone one for help plz. thank you guys
Ashan Mohammed
@AshanMohammed
Nov 28 2016 05:42
@Manish-Giri I am writing this code locally on my computer
MoNag1
@MoNag1
Nov 28 2016 05:43
@AshanMohammed have you trying console logging the variable country
$.getJSON("http://freegeoip.net/json/",function(data){
  var country = data.country_name;
  console.log(country);

})
that works^and I can't seem to find the difference between yours and mine
alex_wang
@wangzhenalex
Nov 28 2016 05:44
could any boy can tell me How to split a sentence (like 'thisIsSpinalTap') into words?
Abhisek Pattnaik
@abhisekp
Nov 28 2016 05:44
@Manish-Giri async functions will run one after the other and it will be a race condition. Sometimes, it might work and other times, it will fail.
In callbacks, better to call another function for use in the openweathermap
e.g.
getJSON(url, function (data) {
  // ... data received
  getOpenWeather(data);
})

function getOpenWeather(data) {}
Ashan Mohammed
@AshanMohammed
Nov 28 2016 05:45
@MoNag1 Yep. That works fine!
Abhisek Pattnaik
@abhisekp
Nov 28 2016 05:45
@wangzhenalex only "boys"? ;) :point_up: November 28, 2016 11:14 AM
Manish Giri
@Manish-Giri
Nov 28 2016 05:46
@abhisekp so basically a getJSON inside another one right?
Abhisek Pattnaik
@abhisekp
Nov 28 2016 05:46
@Manish-Giri better to call another function
nijeshk2011
@nijeshk2011
Nov 28 2016 05:47
hi..
Abhisek Pattnaik
@abhisekp
Nov 28 2016 05:47
otherwise, it will be a callback hell :imp:
Manish Giri
@Manish-Giri
Nov 28 2016 05:47
lol
nijeshk2011
@nijeshk2011
Nov 28 2016 05:47
i need a help in Title a case a sentence.
Manish Giri
@Manish-Giri
Nov 28 2016 05:47
or, Promises
but I’m not sure I know that completely yet
Abhisek Pattnaik
@abhisekp
Nov 28 2016 05:47
yeah! getJSON supports promises
Manish Giri
@Manish-Giri
Nov 28 2016 05:47
@abhisekp do you have any good resources for promises?
nijeshk2011
@nijeshk2011
Nov 28 2016 05:47
var change;
str=str.toLowerCase();
var nstr=str.split(" ");
for(var i=0;i<nstr.length;i++)
{ change=nstr[i].charAt(0);
change=change.toUpperCase();
}
Abhisek Pattnaik
@abhisekp
Nov 28 2016 05:48
@Manish-Giri "promisees" maybe
Darren Haynes
@Darren-Haynes
Nov 28 2016 05:48
Howdy all! How do you post your code snippets in here from freecodecamp?
just like they look in the freecodecamp code editor?
alex_wang
@wangzhenalex
Nov 28 2016 05:48
@abhisekp Ha-ha
Abhisek Pattnaik
@abhisekp
Nov 28 2016 05:49
Manish Giri
@Manish-Giri
Nov 28 2016 05:51
@abhisekp already looked at the first link, had no idea what was going on. Will go thru the 2nd link, thx..
CamperBot
@camperbot
Nov 28 2016 05:51
manish-giri sends brownie points to @abhisekp :sparkles: :thumbsup: :sparkles:
:star2: 3224 | @abhisekp |http://www.freecodecamp.com/abhisekp
MoNag1
@MoNag1
Nov 28 2016 05:51
'''
CamperBot
@camperbot
Nov 28 2016 05:51
:bulb: to format code use backticks! ``` more info
MoNag1
@MoNag1
Nov 28 2016 05:51
@Darren-Haynes ^
Darren Haynes
@Darren-Haynes
Nov 28 2016 05:51
Thanks :)
tanglongyang
@tanglongyang
Nov 28 2016 05:51
who solved this problem . I have got a stock here 2 days ..https://www.freecodecamp.com/challenges/profile-lookup
Abhisek Pattnaik
@abhisekp
Nov 28 2016 05:52
@Darren-Haynes
```js  [shift + enter for newline]

<code here>

```    [ctrl + enter to post] 
Darren Haynes
@Darren-Haynes
Nov 28 2016 05:52
```

function destroyer(arr) {
  var args = Array.from(arguments);
  var myArray = args.shift();

  for (var i=0; i < args.length; i++) {
    myArray = myArray.filter(function(val) {
      return val !== args[i];
    });
  }
  return myArray;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Abhisek Pattnaik
@abhisekp
Nov 28 2016 05:53
@tanglongyang if you're stuck for 20 mins for then ask for challenges (not for algorithms though)
Darren Haynes
@Darren-Haynes
Nov 28 2016 05:55
Not sure if anyone can help me on this one (code pasted above). What i wrote worked and passed the "Seek and Destroy" algorithm, but I did get a note in the editor that said "don't use functions in for loops"
tanglongyang
@tanglongyang
Nov 28 2016 05:55
@abhisekp sorry, I don't catch your point
Darren Haynes
@Darren-Haynes
Nov 28 2016 05:56
wondering if I should redo without a function in the for loop? Even though it worked
MoNag1
@MoNag1
Nov 28 2016 05:56
@Darren-Haynes I think they just mean define the function outside the loop
and then call it in .filter()
that should get rid of the error
tanglongyang
@tanglongyang
Nov 28 2016 05:57
function lookUpProfile(firstName, prop){
// Only change code below this line
for ( var i = 0; i < contacts.length; i++){
  for (var j = 0; j < contacts[i].length; j++){
    if (firstName !== contacts[i].firstName){
      console.log("No such contact");
    }else if (prop !== contacts[i][j])
      console.log("No such property");
    }if (firstName === contacts[i].firstName && prop === contacts[i][j])
      {
        console.lgo(contacts[i].j);
      }
  }

// Only change code above this line
}

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

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

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

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

MoNag1
@MoNag1
Nov 28 2016 05:58
function destroyer(arr) {
  var args = Array.from(arguments);
  var myArray = args.shift();
  function test (val) {
    return val !== args[i];
  }
  for (var i=0; i < args.length; i++) {
    myArray = myArray.filter(test);
  }
  return myArray;
}
like this instead ^ @Darren-Haynes
Darren Haynes
@Darren-Haynes
Nov 28 2016 06:00
Oh I see, that's neat! thanks @MoNag1 -
CamperBot
@camperbot
Nov 28 2016 06:00
:cookie: 371 | @monag1 |http://www.freecodecamp.com/monag1
darren-haynes sends brownie points to @monag1 :sparkles: :thumbsup: :sparkles:
MoNag1
@MoNag1
Nov 28 2016 06:00
:thumbsup:
Markus Kiili
@Masd925
Nov 28 2016 06:05
@MoNag1 It would be better to filter only once and put the loop inside the filter callback.
Abhisek Pattnaik
@abhisekp
Nov 28 2016 06:07
@tanglongyang if you're stuck for more than 20 mins in any challenge, please feel free to ask. (not applicable for algorithm challenges though)
Asking within right time will actually help you save your time and learn more exponentially as other experienced guys can help you learn more insights of the challenge.
Getting stuck for more than 20 mins, our brain adversely affects our mood to learn more.
So better get help quick :D
Dusliat
@Alchemistioc
Nov 28 2016 06:07
Good evening guys, hope things are well for you all. I'm stuck on the "Early Pattern for Functions challenge." How am I trying to get "undefined" without placing it in as a string.
Markus Kiili
@Masd925
Nov 28 2016 06:08
@Alchemistioc Just return undefined; will do it.
undefined is a special value used by the JS engine. It is the only value in the type Undefined.
Dusliat
@Alchemistioc
Nov 28 2016 06:09
Agreed. @abhisekp if you do get stuck on a challenge for too long, take a quick break to relieve your brain of the frustration.
Abhisek Pattnaik
@abhisekp
Nov 28 2016 06:09
yeah! :+1: agreed that too
Dusliat
@Alchemistioc
Nov 28 2016 06:10
Thanks @Masd925
CamperBot
@camperbot
Nov 28 2016 06:10
:star2: 3016 | @masd925 |http://www.freecodecamp.com/masd925
alchemistioc sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
Dusliat
@Alchemistioc
Nov 28 2016 06:10
Could you explain?
Markus Kiili
@Masd925
Nov 28 2016 06:11
@Alchemistioc JS functions return undefined by default if no explicit return is made. You can also stop the execution by return undefined; or return;
Dusliat
@Alchemistioc
Nov 28 2016 06:12
You guys are awesome!!
alex_wang
@wangzhenalex
Nov 28 2016 06:14
var s =t.match(/[A-Z][a-z]*/g); Just forget about it.
Abhisek Pattnaik
@abhisekp
Nov 28 2016 06:14
...but explicit return undefined; is good :+1:
Markus Kiili
@Masd925
Nov 28 2016 06:15
@abhisekp I have been stuck on the Personal portfolio project for 20 weeks. Give me a nudge.
Abhisek Pattnaik
@abhisekp
Nov 28 2016 06:15
lol
nijeshk2011
@nijeshk2011
Nov 28 2016 06:15
any1 can help me solve the level Title a sentence
Markus Kiili
@Masd925
Nov 28 2016 06:16
@Alchemistioc Usually it is best to leave undefined for the engine and use null instead. Helps debugging.
nijeshk2011
@nijeshk2011
Nov 28 2016 06:16

function titleCase(str) {
var change;
str=str.toLowerCase();
var nstr=str.split(" ");
for(var i=0;i<nstr.length;i++)
{ change=nstr[i].charAt(0);
change=change.toUpperCase();
var nstr1=nstr[i].slice();

    }

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

Abhisek Pattnaik
@abhisekp
Nov 28 2016 06:16
@Masd925 :100: you're completely helpless and quit ;P
@nijeshk2011
```js  [shift + enter for newline]

<code here>

```    [ctrl + enter to post] 
nijeshk2011
@nijeshk2011
Nov 28 2016 06:18

function titleCase(str) {
var change;
str=str.toLowerCase();
var nstr=str.split(" ");
for(var i=0;i<nstr.length;i++)
{ change=nstr[i].charAt(0);
change=change.toUpperCase();
var nstr1=nstr[i].slice();

    }

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

Greg Duncan
@GregatGit
Nov 28 2016 06:18
@nijeshk2011 you have no return value
nijeshk2011
@nijeshk2011
Nov 28 2016 06:18
now i want to change the first letter of every array.
once i changed the values i will join arrays to string and return.
Greg Duncan
@GregatGit
Nov 28 2016 06:19
@nijeshk2011 you have to make change an array
so change[i] = nstr[i].charAt(0);
nijeshk2011
@nijeshk2011
Nov 28 2016 06:21
when i assign nstr1[0]=change its showing error.
Greg Duncan
@GregatGit
Nov 28 2016 06:22
you needed to run this line by line through the debugger
nijeshk2011
@nijeshk2011
Nov 28 2016 06:22
error now cannot assign to read only property of I
cannot assign to read only property of '0' of I
Greg Duncan
@GregatGit
Nov 28 2016 06:23
@nijeshk2011 you don't need a new variable here
var nstr=str.split(" ");
// just do this
str=str.split(" ");
Abhisek Pattnaik
@abhisekp
Nov 28 2016 06:23
@Masd925 i mean helpless :point_up: November 28, 2016 11:46 AM
nijeshk2011
@nijeshk2011
Nov 28 2016 06:24
@GregatGit : yea. then.?
Markus Kiili
@Masd925
Nov 28 2016 06:25
@abhisekp I will actually do some FCC again in next weeks.
Greg Duncan
@GregatGit
Nov 28 2016 06:26
@nijeshk2011 and put some spaces when you can
str=str.split(" ");
str = str.split(" ");
Abhisek Pattnaik
@abhisekp
Nov 28 2016 06:26
@Masd925 :+1: noice!
nijeshk2011
@nijeshk2011
Nov 28 2016 06:26
@GregatGit : done
@GregatGit : next.?
Greg Duncan
@GregatGit
Nov 28 2016 06:29
@nijeshk2011 so how does it look now - and don't forget ``` on a seperate line before and after you code
nijeshk2011
@nijeshk2011
Nov 28 2016 06:30

@GregatGit : '''function titleCase(str) {

str = str.toLowerCase();
var nstr=str.split(" ");

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

CamperBot
@camperbot
Nov 28 2016 06:30
:bulb: to format code use backticks! ``` more info
Abhisek Pattnaik
@abhisekp
Nov 28 2016 06:30
```js  [shift + enter for newline]

<code here>

```    [ctrl + enter to post] 
Greg Duncan
@GregatGit
Nov 28 2016 06:30
``` not '''
CamperBot
@camperbot
Nov 28 2016 06:30
:bulb: to format code use backticks! ``` more info
Greg Duncan
@GregatGit
Nov 28 2016 06:31
and on a seperate line
nijeshk2011
@nijeshk2011
Nov 28 2016 06:31
```js
Greg Duncan
@GregatGit
Nov 28 2016 06:31
don't write js on the line
nijeshk2011
@nijeshk2011
Nov 28 2016 06:32
function titleCase(str) {

  str = str.toLowerCase();
  var nstr=str.split(" ");



}
titleCase("I'm a little tea pot");
Greg Duncan
@GregatGit
Nov 28 2016 06:33
you dont need nstr str will do
nijeshk2011
@nijeshk2011
Nov 28 2016 06:34
function titleCase(str) {

  str = str.toLowerCase();
  str =str.split(" ");



}
titleCase("I'm a little tea pot");
Greg Duncan
@GregatGit
Nov 28 2016 06:34
put spaces either side of you =
your last line could be return str;
nijeshk2011
@nijeshk2011
Nov 28 2016 06:34
yea i have done it nw. once i saw the code.
@GregatGit noticed and edited.
@GregatGit : whats next.?
Greg Duncan
@GregatGit
Nov 28 2016 06:37
I would start by trying to make the first word in the array capitalised
then you try that in a loop
it is now up to you to try an figure it out
nijeshk2011
@nijeshk2011
Nov 28 2016 06:38
should i split the str further into one dimensonal array..
Greg Duncan
@GregatGit
Nov 28 2016 06:38
give it a try
nijeshk2011
@nijeshk2011
Nov 28 2016 06:39
like [i'am] and [a] like that.?
Greg Duncan
@GregatGit
Nov 28 2016 06:39
yeah
Markus Kiili
@Masd925
Nov 28 2016 06:41
@nijeshk2011 You could loop the array of words and make a new titlecased word with string operations and assign it back to the array. No need to split the word into an array of characters.
nijeshk2011
@nijeshk2011
Nov 28 2016 06:42
function titleCase(str) {

  str = str.toLowerCase();
  str = str.split(" ");
  for(var i=0;i<str.length;i++)
    {
      for(var j=0;j<str[i].length;j++)
        {

        }
    }

 return str; 
}
titleCase("I'm a little tea pot");
Norbert1986
@Norbert1986
Nov 28 2016 06:44
Help me please
CamperBot
@camperbot
Nov 28 2016 06:44
no wiki entry for: me please
Norbert1986
@Norbert1986
Nov 28 2016 06:44
Understanding Case Sensitivity in Variables
Abhisek Pattnaik
@abhisekp
Nov 28 2016 06:45
@camperbot do you need help?
MoNag1
@MoNag1
Nov 28 2016 06:45
@Norbert1986 send your code
Norbert1986
@Norbert1986
Nov 28 2016 06:46

// Declarations
var StUdLyCapVaR;
var propercAmelCase;
var TitleCaseOver;

// Assignments
STUDLYCAPVAR = 10;
PRopercAmelCAse = "A String";
tITLEcASEoVER = 9000;

Abhisek Pattnaik
@abhisekp
Nov 28 2016 06:46
@Norbert1986 what is case sensitivity?
Tom Landis
@TomLandis
Nov 28 2016 06:47
im stuck on roman numeral converter.
here is a sea of code that isn't working
var answer=[];




function convertOnes(num) {
    switch (num) {
  case 1:
    answer.push("I");
    break;
  case 2:
    answer.push("II");
    break;
  case 3:
    answer.push("III");
    break;
  case 4:
    answer.push("IV");    
          break;
  case 5:
    answer.push("V");
          break;
  case 6:
    answer.push("VI");
          break;
  case 7:
    answer.push("VII");
          break;
  case 8:
    answer.push("VIII");
    break;
  case 9:
    answer.push("IX");
    break;  
  case 0:

          break;

}}
      function convertTens(it) {
      switch (it) {
  case 1:
    answer.push("X");
    break;
  case 2:
    answer.push("XX");
    break;
  case 3:
    answer.push("XXX");
    break;
  case 4:
    answer.push("XL");    
          break;
  case 5:
    answer.push("L");
          break;
  case 6:
    answer.push("LX");
          break;
  case 7:
    answer.push("LXX");
          break;
  case 8:
    answer.push("LXXX");
    break;
  case 9:
    answer.push("XC");
    break;  
  case 0:

          break;

}}
         function convertHun(it) {
      switch (it) {
  case 1:
    answer.push("C");
    break;
  case 2:
    answer.push("CC");
    break;
  case 3:
    answer.push("CCC");
    break;
  case 4:
    answer.push("CD");    
          break;
  case 5:
    answer.push("D");
          break;
  case 6:
    answer.push("DC");
          break;
  case 7:
    answer.push("DCC");
          break;
  case 8:
    answer.push("DCCC");
    break;
  case 9:
    answer.push("CM");
    break;  
  case 0:

          break;

}
    }
        function convertThou(it) {
      switch (it) {
  case 1:
    answer.push("M");
    break;
  case 2:
    answer.push("MM");
    break;
  case 3:
    answer.push("MMM");
    break;
      }}

function convertToRoman(num) {

  if (num.length === 1){
  var  digit = num;
   convertOnes(digit);



  }
  else if (num.length === 2) {

    convertTens(num[0]);
    convertOnes(num[1]);

  }
  else if (num.length === 3) {

    convertHun(num[0]);
    convertTens(num[1]);
    convertOnes(num[2]);
}
  else{
    convertThou(num[0]);
    convertHun(num[1]);
    convertTens(num[2]);
    convertOnes(num[3]);

  }
}
 console.log(convertToRoman(2));
console.log( convertToRoman(2222));
Norbert1986
@Norbert1986
Nov 28 2016 06:48
what do i have to do with the code @abhisekp
MoNag1
@MoNag1
Nov 28 2016 06:48
@TomLandis I've been stuck on this for 3 days lol. today I gave up and watched a tutorial explaining it
Abhisek Pattnaik
@abhisekp
Nov 28 2016 06:48
@Norbert1986 paste the challenge link along with the code
```js  [shift + enter for newline]

<code here>

```    [ctrl + enter to post] 
Tom Landis
@TomLandis
Nov 28 2016 06:49
@MoNag1 what's killing me is i have an idea that should work. But the code won't run
MoNag1
@MoNag1
Nov 28 2016 06:52
@TomLandis just from first glance, have you converted num to a string so that you can target individual digits using num[0] and num[1] etc
Jason Goodney
@JasonGoodney
Nov 28 2016 06:53
@nijeshk2011 When you split str, you do not have to look through every character because you know the character you want is at index 0.
MoNag1
@MoNag1
Nov 28 2016 06:54
@TomLandis because otherwise num[0] and num[1] return undefined
Markus Kiili
@Masd925
Nov 28 2016 06:54
@TomLandis There is lot of hardcoding going on there. If you started by putting the basis of Roman numerals on two arrays as numbers and letters, and then iterated the array of numbers, the solution would be short and easy to understand. It would also be easy to make it work with larger numbers later.
grupaty
@grupaty
Nov 28 2016 06:55
how do i remove some characters from my string ??
nijeshk2011
@nijeshk2011
Nov 28 2016 06:56
@JasonGoodney : how do i change the value of first character.?
Tom Landis
@TomLandis
Nov 28 2016 06:56
thanks @Masd925 @MoNag1 I'll try putting those ideas to work
CamperBot
@camperbot
Nov 28 2016 06:56
tomlandis sends brownie points to @masd925 and @monag1 :sparkles: :thumbsup: :sparkles:
:star2: 3017 | @masd925 |http://www.freecodecamp.com/masd925
:cookie: 373 | @monag1 |http://www.freecodecamp.com/monag1
nijeshk2011
@nijeshk2011
Nov 28 2016 06:57
i am not able to change the value directly..
MoNag1
@MoNag1
Nov 28 2016 06:58
@grupaty .replace()?
amir cohen
@amir0900
Nov 28 2016 06:58
help Golf Code
CamperBot
@camperbot
Nov 28 2016 06:58
no wiki entry for: golf code
Abhisek Pattnaik
@abhisekp
Nov 28 2016 06:59
@kboygit what is a function?
Kirby James
@kirbygit
Nov 28 2016 07:00
declared by a function keyword
MoNag1
@MoNag1
Nov 28 2016 07:03
@kboygit ok what have you tried so far?
Kirby James
@kirbygit
Nov 28 2016 07:03
i declared var a; and var b;
since undefined is a hint
MoNag1
@MoNag1
Nov 28 2016 07:04
@kboygit a and b are parameters and not variables so don't declare them as such
basically all you have to do it check if a is less that 0 or if b is less than 0. If either of them are return undefined
@kboygit are you aware of what an if statement is?
tanglongyang
@tanglongyang
Nov 28 2016 07:07
if (prop === contacts[i][prop])
is this sentence write?
nijeshk2011
@nijeshk2011
Nov 28 2016 07:07
```
function titleCase(str) {

  str = str.toLowerCase();
  str = str.split(" ");
  for(var i=0;i<str.length;i++)
    {
      return str[i].charAt(0).toUpperCase();
    }

 //return str;
}
titleCase("I'm a little tea pot");
i am able to locate the first element and capitalized but how do i change to array
tanglongyang
@tanglongyang
Nov 28 2016 07:09
whether this sentence can make sense ?
 if (prop === contacts[i][prop])
Jody LeCompte
@jodylecompte
Nov 28 2016 07:09
@nijeshk2011 .join(' ');
@tanglongyang Syntatically, that makes sense. Its a strict equality of does prop equal contacts[i][prop]
but without the rest of your code I have no idea if it does what you intend it to do
nijeshk2011
@nijeshk2011
Nov 28 2016 07:10
@jodylecompte : but i should replace the previous element
Markus Kiili
@Masd925
Nov 28 2016 07:10
@tanglongyang For the property existence test, you need to use .hasOwnProperty() or .propertyIsEnumerable() method.
nijeshk2011
@nijeshk2011
Nov 28 2016 07:11
@jodylecompte : i should replace existing element.
Jody LeCompte
@jodylecompte
Nov 28 2016 07:11
That's a different matter, .join will convert your array (once you are finished) back to a string to be returned
Your loop is stepping through each word in the original string currently, but you don't want to return. You want to change the first character, then push the new word to a new array
Then .join() that array back into a string once done and return that
amir cohen
@amir0900
Nov 28 2016 07:12
help Returning Boolean Values from Functions
CamperBot
@camperbot
Nov 28 2016 07:12
no wiki entry for: returning boolean values from functions
tanglongyang
@tanglongyang
Nov 28 2016 07:14
for (var i=0; i < contacts.length; i++){
  if (firstName === contacts[i].firstName){
    if (prop === contacts[i][prop]/*contacts[i].hasOwnProperty(prop)*/){
      return contacts[i][prop];
    }
    return "No such property";
  }

  }
 return "No such contact";  
}
this my solution, but it doesn't work. and this grey part does work.
Munyaneza jean francois
@jeanfrancoiscoder
Nov 28 2016 07:14
Using bracket notation select an element from myArray such that myData is equal to 8.how to do this?

// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[0][8];

Manish Giri
@Manish-Giri
Nov 28 2016 07:16
@jeanfrancoiscoder which sub array is the number 8 in, in the array myArray?
tanglongyang
@tanglongyang
Nov 28 2016 07:17
thx @jodylecompte @Masd925
CamperBot
@camperbot
Nov 28 2016 07:17
:cookie: 266 | @jodylecompte |http://www.freecodecamp.com/jodylecompte
:star2: 3018 | @masd925 |http://www.freecodecamp.com/masd925
tanglongyang sends brownie points to @jodylecompte and @masd925 :sparkles: :thumbsup: :sparkles:
Vejil
@Icehao
Nov 28 2016 07:19

function factorialize(num) {
var arr=[];
var newArr;
var n;
if(num===0){return 1;}
else{ for(n=1;n<=num;n++){

newArr=arr.push(n);    

}
}
var multiply=newArr.reduce(function(previousVal,currentVal){return previousVal*currentVal;});
return multiply;

}
factorialize(5);

Abhisek Pattnaik
@abhisekp
Nov 28 2016 07:19
@Icehao
```js  [shift + enter for newline]

<code here>

```    [ctrl + enter to post] 
Vejil
@Icehao
Nov 28 2016 07:20
i'm stuck at factorialize a number
Abhisek Pattnaik
@abhisekp
Nov 28 2016 07:20
you may edit your message
nijeshk2011
@nijeshk2011
Nov 28 2016 07:20
function titleCase(str) {

  str = str.toLowerCase();
  str = str.split(" ");
  for(var i=0;i<str.length;i++)
    {
      var nstr1=str[i].charAt(0).toUpperCase();
      str[i].unshift();
    }

 //return str;
}
titleCase("I'm a");
why array method unshift() showing error here..?
grupaty
@grupaty
Nov 28 2016 07:21
how do i make that in ma .replace(/ /gi,"") can store for example space and _ ?? because as lon as it is spearate it works
Vejil
@Icehao
Nov 28 2016 07:21

```js [shift + enter for newline]
function factorialize(num) {
var arr=[];
var newArr;
var n;
if(num===0){return 1;}
else{ for(n=1;n<=num;n++){

newArr=arr.push(n);    

}

 }

var multiply=newArr.reduce(function(previousVal,currentVal){return previousVal*currentVal;});
return multiply;

}
factorialize(5);

``` [ctrl + enter to post]

sorry
nijeshk2011
@nijeshk2011
Nov 28 2016 07:22
@abhisekp : any luck bro..?
Markus Kiili
@Masd925
Nov 28 2016 07:23
@Icehao The return value of push is not the mutated array.
Vejil
@Icehao
Nov 28 2016 07:24
@Masd925 how to correct?
Markus Kiili
@Masd925
Nov 28 2016 07:25
@Icehao Just use one empty array where you push those numbers.
fernando Reyna
@frr225
Nov 28 2016 07:25
I was wondering if any one can tell me what is my err in the Roman numeral conversion everything works except converting 649 even though the number 9 is correctly converted to IX and 49 to0 649 converts to this DCIL instead of DCXLIX" here is my code

function convertToRoman(num) {
var Rnum="";

while(num>=1000){num=num - 1000;Rnum=Rnum+"M";}
while(num>=900){ num=num - 900;Rnum=Rnum+"CM";}
//while(num>=649){num=num - 649;Rnum= Rnum + "DCXLIX";}
while(num>=500){ num=num - 500;Rnum=Rnum+"D";}
if(num>=400){num=num - 400;Rnum=Rnum+"CD"; }

while(num>=100){num=num - 100;Rnum=Rnum+"C"; }
if(num>=90){num=num - 90;Rnum=Rnum+"XC";}
while(num>=50){num=num - 50;Rnum=Rnum+"L";}
while(num>=49){ num=num - 49; Rnum=Rnum+"IL"; }

while(num>=45){num=num - 45;Rnum= Rnum + "XLV";}
while(num>=44){num=num - 44;Rnum= Rnum + "XLIV";}
while(num>=40){num=num - 40; Rnum= Rnum + "XL";}
while(num>=10){ num=num - 10;Rnum=Rnum+"X"; }
while(num>=9){num=num - 9; Rnum=Rnum+"IX"; }
while(num>=5){num=num - 5;Rnum=Rnum+"V"; }
while(num==4){ num=num - 4; Rnum=Rnum+"IV"; }
while(num>=1){num=num - 1;Rnum=Rnum+"I";}

return Rnum;
}

convertToRoman(649);

Abhisek Pattnaik
@abhisekp
Nov 28 2016 07:27
@frr225
```js  [shift + enter for newline]

<code here>

```    [ctrl + enter to post] 
fernando Reyna
@frr225
Nov 28 2016 07:28
djdjjdjdjjjdjdjdjjdd
i'm trying
Abhisek Pattnaik
@abhisekp
Nov 28 2016 07:28

@abhisekp : any luck bro..?

@nijeshk2011 i'm unlucky most of the time ;P
var nstr1=str[i].charAt(0).toUpperCase();

console.log nstr1

fernando Reyna
@frr225
Nov 28 2016 07:29
'''js
hdhdhhdhdh''''
CamperBot
@camperbot
Nov 28 2016 07:29
:bulb: to format code use backticks! ``` more info
nijeshk2011
@nijeshk2011
Nov 28 2016 07:29
@abhisekp : he he he
Mitch
@MitchWilkins
Nov 28 2016 07:29
@nijeshk2011 I don't think I shift does what you think it does. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift
nhanly91
@nhanly91
Nov 28 2016 07:29
function processData(input) {
    //Enter your code here
    dict = []
    inputArray = input.split('\n');
    for(var i = 1; i<= parseInt(inputArray[0]);i++){

        var key = inputArray[i].split(' ')[0]
        var value = inputArray[i].split(' ')[1]
        dict.push({
            key : value
        })
        console.log(dict)
    }   
}
I want to push new key-value element to dict array, but the output is not correct, key always 'key'
Output:
[ { key: '99912222' } ]
[ { key: '99912222' }, { key: '11122222' } ]
[ { key: '99912222' }, { key: '11122222' }, { key: '12299933' } ]
Abhisek Pattnaik
@abhisekp
Nov 28 2016 07:29
@nijeshk2011 strings are immutable
var str = 'Nijesh';
str[0] = 'J';
console.log( str ); // 'Nijesh'
Mitch
@MitchWilkins
Nov 28 2016 07:29
Unshift*
vaishnavi prasad
@vaishnaviprasad
Nov 28 2016 07:30
Hi guys
please help me out with this challenge
Escape Sequences in Strings
WhiteLeaf1103
@WhiteLeaf1103
Nov 28 2016 07:30
// On line 2, declare a variable myName and give it your name.
var myName= "ThaBiggestBoss"
// On line 4, use console.log to print out the myName variable.
console.long(myName);
// On line 7, change the value of myName to be just the first 2 
// letters of your name.
myName = myName.substring(0,2);
// On line 9, use console.log to print out the myName variable.
console.log(myName);
Abhisek Pattnaik
@abhisekp
Nov 28 2016 07:30
@vaishnaviprasad what is an escape sequence?
vaishnavi prasad
@vaishnaviprasad
Nov 28 2016 07:31
@abhisekp var myStr="FirstLine\n\SecondLine\ \nThirdLine";
fernando Reyna
@frr225
Nov 28 2016 07:31

'''
function convertToRoman(num) {
var Rnum="";

while(num>=1000){num=num - 1000;Rnum=Rnum+"M";}
while(num>=900){ num=num - 900;Rnum=Rnum+"CM";}
//while(num>=649){num=num - 649;Rnum= Rnum + "DCXLIX";}
while(num>=500){ num=num - 500;Rnum=Rnum+"D";}
if(num>=400){num=num - 400;Rnum=Rnum+"CD"; }

while(num>=100){num=num - 100;Rnum=Rnum+"C"; }
if(num>=90){num=num - 90;Rnum=Rnum+"XC";}
while(num>=50){num=num - 50;Rnum=Rnum+"L";}
while(num>=49){ num=num - 49; Rnum=Rnum+"IL"; }

while(num>=45){num=num - 45;Rnum= Rnum + "XLV";}
while(num>=44){num=num - 44;Rnum= Rnum + "XLIV";}
while(num>=40){num=num - 40; Rnum= Rnum + "XL";}
while(num>=10){ num=num - 10;Rnum=Rnum+"X"; }
while(num>=9){num=num - 9; Rnum=Rnum+"IX"; }
while(num>=5){num=num - 5;Rnum=Rnum+"V"; }
while(num==4){ num=num - 4; Rnum=Rnum+"IV"; }
while(num>=1){num=num - 1;Rnum=Rnum+"I";}

return Rnum;
}

convertToRoman(649);
'''

CamperBot
@camperbot
Nov 28 2016 07:31
:bulb: to format code use backticks! ``` more info
Abhisek Pattnaik
@abhisekp
Nov 28 2016 07:31
:expressionless:
WhiteLeaf1103
@WhiteLeaf1103
Nov 28 2016 07:32
can anyone help me?
nijeshk2011
@nijeshk2011
Nov 28 2016 07:32
@abhisekp : what should i do to change the existing first letter of the array..?
WhiteLeaf1103
@WhiteLeaf1103
Nov 28 2016 07:32
can you change the var with substring?
vaishnavi prasad
@vaishnaviprasad
Nov 28 2016 07:32
@abhisekp var myStr="FirstLine\n\SecondLine\ \nThirdLine";
Abhisek Pattnaik
@abhisekp
Nov 28 2016 07:32
@nijeshk2011 change then concat
that was a hint ;)
@vaishnaviprasad What does the instruction say to do?
vaishnavi prasad
@vaishnaviprasad
Nov 28 2016 07:33
```var myStr="FirstLine\n\SecondLine\ \nThirdLine";
Abhisek Pattnaik
@abhisekp
Nov 28 2016 07:34
@vaishnaviprasad
```js  [shift + enter for newline]

<code here>

```    [ctrl + enter to post] 
vaishnavi prasad
@vaishnaviprasad
Nov 28 2016 07:34
FirstLine
\SecondLine\
ThirdLine @abhisekp
var myStr="FirstLine\n\\SecondLine\\ \nThirdLine";
WhiteLeaf1103
@WhiteLeaf1103
Nov 28 2016 07:35
can anyone assist me?
nijeshk2011
@nijeshk2011
Nov 28 2016 07:35
@abhisekp :ooopss..
WhiteLeaf1103
@WhiteLeaf1103
Nov 28 2016 07:35
// On line 2, declare a variable myName and give it your name.
var myName= "ThaBiggestBoss"
// On line 4, use console.log to print out the myName variable.
console.long(myName);
// On line 7, change the value of myName to be just the first 2 
// letters of your name.
myName = myName.substring(0,2);
// On line 9, use console.log to print out the myName variable.
console.log(myName);
fernando Reyna
@frr225
Nov 28 2016 07:35
function convertToRoman(num) {
  var Rnum="";

  while(num>=1000){num=num - 1000;Rnum=Rnum+"M";}
  while(num>=900){  num=num - 900;Rnum=Rnum+"CM";} 
   //while(num>=649){num=num - 649;Rnum= Rnum + "DCXLIX";}   
  while(num>=500){ num=num - 500;Rnum=Rnum+"D";}
   if(num>=400){num=num - 400;Rnum=Rnum+"CD"; }

  while(num>=100){num=num - 100;Rnum=Rnum+"C"; } 
  if(num>=90){num=num - 90;Rnum=Rnum+"XC";}
  while(num>=50){num=num - 50;Rnum=Rnum+"L";}    
  while(num>=49){ num=num - 49; Rnum=Rnum+"IL";  }

  while(num>=45){num=num - 45;Rnum= Rnum + "XLV";}
  while(num>=44){num=num - 44;Rnum= Rnum + "XLIV";}
  while(num>=40){num=num - 40; Rnum= Rnum + "XL";}
  while(num>=10){ num=num - 10;Rnum=Rnum+"X"; }
  while(num>=9){num=num - 9; Rnum=Rnum+"IX";  }    
  while(num>=5){num=num - 5;Rnum=Rnum+"V";  }  
  while(num==4){  num=num - 4; Rnum=Rnum+"IV"; }
  while(num>=1){num=num - 1;Rnum=Rnum+"I";}    

 return Rnum;
}

convertToRoman(649);
```
vaishnavi prasad
@vaishnaviprasad
Nov 28 2016 07:35
@abhisekp I need to print
FirstLine
\SecondLine\
ThirdLine
fernando Reyna
@frr225
Nov 28 2016 07:36
@frr225 I was wondering if any one can tell me what is my err in the Roman numeral conversion everything works except converting 649 even though the number 9 is correctly converted to IX and 49 to0 649 converts to this DCIL instead of DCXLIX" here is my code
Mitch
@MitchWilkins
Nov 28 2016 07:36
@nhanly91 what challenge is that?
Abhisek Pattnaik
@abhisekp
Nov 28 2016 07:36
@vaishnaviprasad i guess you're adding an extra space
Markus Kiili
@Masd925
Nov 28 2016 07:37
@frr225 Refactoring that code would start by putting the numbers and letters on arrays like this and making a loop that iterates the array of numbers:
  var NUM = [1000,900,500,400,100,90,50,40,10,9,5,4,1];
  var ROM = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'];
instead of making a loop for each number explicitly.
vaishnavi prasad
@vaishnaviprasad
Nov 28 2016 07:39
i used \r
@abhisekp thanks
CamperBot
@camperbot
Nov 28 2016 07:39
vaishnaviprasad sends brownie points to @abhisekp :sparkles: :thumbsup: :sparkles:
:star2: 3225 | @abhisekp |http://www.freecodecamp.com/abhisekp
vaishnavi prasad
@vaishnaviprasad
Nov 28 2016 07:39
Hi guys
can any body tell me difference between \n and \r
fernando Reyna
@frr225
Nov 28 2016 07:39
but i don't un derstand refractoring plus the instrucctions don't mention anything about it!! I'll try thou but i want to understand what is wrong on this approach.
vaishnavi prasad
@vaishnaviprasad
Nov 28 2016 07:40
what is the practical difference btewwen \n and \r
fernando Reyna
@frr225
Nov 28 2016 07:40
@Masd925 but i don't un derstand refractoring plus the instrucctions don't mention anything about it!! I'll try thou but i want to understand what is wrong on this approach.
Markus Kiili
@Masd925
Nov 28 2016 07:43
@frr225 I just mean that you have some code that repeats there. You could remove it by making those arrays and then iterating the array of numbers. Your code would first take the first number 1000 and check how many times it fits into num etc. It would do the same as your code but without repeating the code for each number.
WhiteLeaf1103
@WhiteLeaf1103
Nov 28 2016 08:05
var foodDemand = function(food) {
    console.log("I want to eat" + " " + food);

    };
keeps saying did not call foodDemand
Eric Bezanson
@ericbezanson
Nov 28 2016 08:06
@WhiteLeaf1103 you would need to call it after the function block. Like foodDemand();
Your code is just setting up the function foodDemand("steak"); is what runs it
WhiteLeaf1103
@WhiteLeaf1103
Nov 28 2016 08:08

so I never call whats inside the function() which is called the parameters?

and I just call something by outside the brackets by nameing variable and adding something to parameters?

Eric Bezanson
@ericbezanson
Nov 28 2016 08:10
Basically the code you wrote creates a machine that when you input a parameter (which is represented by the keyword food in your code) it will spit out that string.
In order to turn the machine on and run it you need to press on by typing foodDemand(); and tell it what food you want by putting it in the brackets
FoodDemand(); tells the browser to run that function.
WhiteLeaf1103
@WhiteLeaf1103
Nov 28 2016 08:14

how come. I do foodDemand(""); im just confused. why do I use the food inside the console.log.? if im calling the variable and defining that?

Idk if im making sense x.x

Eric Bezanson
@ericbezanson
Nov 28 2016 08:17
Food in this case is just a keyword. It could be anything whatever you write there the function is going to put it in the string and log it to the console
You could write "x" and it would log I want to eat x
It's only a variable if you use var = ""
What your function is doing is it's looking at whatever is called (whatever is put in the brackets) and concatenating it to the string "I want to eat "
So foodDemand("bacon"); runs your function with the string bacon. It would log "I want to eat bacon"
Jefferson
@jeffersonnnn
Nov 28 2016 08:21

Hi all, can i get help someone to help with the Find the Longest Word in a String challenge? Here is my code:




function findLongestWord(str) {
  var findLongestWord = str.split(" ");
  for (var i = 0; i < findLongestWord.length; i++){
   var the = findLongestWord[0]; 
    return 6;
  }
}

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

I need someone to give me tips on how to update the variable that keeps tracks of the length and when the loop is done, return the length.

Eric Bezanson
@ericbezanson
Nov 28 2016 08:23
Hey @jeffersonnnn you are on the right track
Jefferson
@jeffersonnnn
Nov 28 2016 08:24
@ericbezanson thank you. Any tips?
CamperBot
@camperbot
Nov 28 2016 08:24
jeffersonnnn sends brownie points to @ericbezanson :sparkles: :thumbsup: :sparkles:
:cookie: 290 | @ericbezanson |http://www.freecodecamp.com/ericbezanson
Eric Bezanson
@ericbezanson
Nov 28 2016 08:24
You can update the longest word var by just setting it each time you go through the for loop
What you want to do is have a condition where it will only update he longestword var when it's looking at a string that is longer then the last
Jefferson
@jeffersonnnn
Nov 28 2016 08:26
@ericbezanson i just copied this to my notepad and i will work on this right now. Thank you.
CamperBot
@camperbot
Nov 28 2016 08:26
jeffersonnnn sends brownie points to @ericbezanson :sparkles: :thumbsup: :sparkles:
:warning: jeffersonnnn already gave ericbezanson points
Philipp Scholz
@philipp32
Nov 28 2016 08:26
Hey, why does my code always return 0?
function getIndexToIns(arr, num) {
  arr.sort();
  var i=0;
  while (num<arr[i]){
    i++;
  }

  return i;
}

getIndexToIns([3, 54, 43, 17, 2, 10, 20, 15], 50);
Riveniers
@Riveniers
Nov 28 2016 08:28
Initialize the three variables a, b, and c with 5, 10, and "I am a" respectively so that they will not be undefined. that is teh question. my answer: var a = 5;
var b = 10;
var c = "i am a";
why the hell isnt it working?
Philipp Scholz
@philipp32
Nov 28 2016 08:29
@Riveniers yuo need a big I
var c = "I am a"
Riveniers
@Riveniers
Nov 28 2016 08:29
@philipp32 thank you
CamperBot
@camperbot
Nov 28 2016 08:29
:cookie: 256 | @philipp32 |http://www.freecodecamp.com/philipp32
riveniers sends brownie points to @philipp32 :sparkles: :thumbsup: :sparkles:
Eric Bezanson
@ericbezanson
Nov 28 2016 08:29
No prob @jeffersonnnn The first two lines of the code are more or less correct. Basically you want a variable to store the length of the string and set up a condition so that each time it runs through the for loop IF the length of that word is > then the .length of the variable you created then set that variable to = that array element
Markus Kiili
@Masd925
Nov 28 2016 08:29
@philipp32 The default sort is not numerical sort.
Philipp Scholz
@philipp32
Nov 28 2016 08:30
@Masd925 That's what I suspected... :/ How can I fix it?
Markus Kiili
@Masd925
Nov 28 2016 08:30
@philipp32 You need to pass a suitable callback function to sort that defines the sorting. You can google it.
Philipp Scholz
@philipp32
Nov 28 2016 08:34
@Masd925
function getIndexToIns(arr, num) {
  arr  = arr.sort(function (a, b) {  return a - b;  });
  var i=0;
  while (num<arr[i]){
    i++;
  }
  return i;
}

getIndexToIns([40, 60, 3, 6, 14, 24, 255, 10, 20, 30], 50);
Here it is. It gets sorted the right way. Why doesn't it work still?
I always get 0.
Markus Kiili
@Masd925
Nov 28 2016 08:35
@philipp32 You need to check the condition.
Philipp Scholz
@philipp32
Nov 28 2016 08:36
@Masd925 Okay. I will. Can you explain to me why my condition doesn't work? I don't understand.
.
Markus Kiili
@Masd925
Nov 28 2016 08:36
The logic is to move forward if the array element is smaller and to stop once you find a number that is equal or larger than num.
You are moving on if the element is larger than num.
Philipp Scholz
@philipp32
Nov 28 2016 08:37
@Masd925 Guess what I just found out. ;)
John Snow
@nghiata
Nov 28 2016 08:37
Record Collection
what's wrong in my code
Philipp Scholz
@philipp32
Nov 28 2016 08:37

function getIndexToIns(arr, num) {
  arr  = arr.sort(function (a, b) {  return a - b;  });
  var i=0;
  while (num>arr[i]){
    i++;
  }
  return i;
}

getIndexToIns([40, 60, 3, 6, 14, 24, 255, 10, 20, 30], 50);
John Snow
@nghiata
Nov 28 2016 08:37

function updateRecords(id, prop, value) {

if (prop !== 'tracks' && value !== '') {
collection[id][prop] = value;
}
else if ( prop == 'tracks' && typeof collection[id][prop] == 'undefined') {
collection[id][prop] = [];
collection[id][prop] = value;
}
else if (prop == 'tracks' && value !== '') {
collection[id][prop].push(value);
}
else if(value === '') {
delete collection[id][prop];
}
return collection;
}

Philipp Scholz
@philipp32
Nov 28 2016 08:37
@Masd925 thank you
CamperBot
@camperbot
Nov 28 2016 08:37
philipp32 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3019 | @masd925 |http://www.freecodecamp.com/masd925
Riveniers
@Riveniers
Nov 28 2016 08:41

var myVar = 87;

// Only change code below this line
myVar = myVar ++;
why isnt it working?

Krzysztof Borowy
@Krizzu
Nov 28 2016 08:42
Morning
Jefferson
@jeffersonnnn
Nov 28 2016 08:45
@ericbezanson could you give the steps to creating a condition you mentioned?
Eric Bezanson
@ericbezanson
Nov 28 2016 08:45
@jeffersonnnn you would want to use an IF statement
Riveniers
@Riveniers
Nov 28 2016 08:46

Change the code to use the ++ operator on myVar. my answer :
var myVar = 87;

// Only change code below this line
myVar = ++myVar;

what is wrong with it ??

fernando Reyna
@frr225
Nov 28 2016 08:46
@Masd925 i figured out the Roman converter thank you men. i'm so exited that ill just share my code . haven't seen the answer thou.function convertToRoman(num) { var Rnum=""; var NUM = [1000,900,500,400,100,90,50,40,10,9,5,4,1]; var ROM = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']; for(var i=0; i<NUM.length; i++){ if(num>= NUM[i]){num=num - NUM[i];Rnum=Rnum+ROM[i]; i--; }
CamperBot
@camperbot
Nov 28 2016 08:46
frr225 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3020 | @masd925 |http://www.freecodecamp.com/masd925
Eric Bezanson
@ericbezanson
Nov 28 2016 08:47
The syntax is :
If (condition) {
Run this code
}
Jean Baptiste Kwizera
@jbkwizera
Nov 28 2016 08:49
Does someone want to pair for the basic JavaScript Aligorithm challenges?
jayden8388
@jayden8388
Nov 28 2016 08:52
hi gues
guys
Markus Kiili
@Masd925
Nov 28 2016 08:52
@frr225 Yes. That is a good solution. It would be even better using a while loop instead of that i--. The logic would be clearer imo.
jayden8388
@jayden8388
Nov 28 2016 08:54
this is wrong bu i dont know how to fix it var myStr="FirstLine\n'SecondLine \r'ThirdLine" ;
toekn33cow
@toekn33cow
Nov 28 2016 08:55
var myStr; FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
whats the correct way for escape sequences?
var myStr;"Firstline\n.\.\SecondLine\..\rThirdline"
jayden8388
@jayden8388
Nov 28 2016 08:58
@toekn33cow looks like your stuck too
toekn33cow
@toekn33cow
Nov 28 2016 08:58
@jayden8388 same problem...
kirbyedy
@kirbyedy
Nov 28 2016 08:58
@toekn33cow why are you using those dots ?
@jayden8388 no need for those '
guys remember how to escape characters
jayden8388
@jayden8388
Nov 28 2016 08:58
@kirbyedy thank u
CamperBot
@camperbot
Nov 28 2016 08:58
jayden8388 sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star2: 1587 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
kirbyedy
@kirbyedy
Nov 28 2016 08:59
especially the \
then the n and r
Jean Baptiste Kwizera
@jbkwizera
Nov 28 2016 08:59
while I was doing the where do i belong bonfire...i realized there is no need for a loop.
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  arr.push(num);
  arr.sort();
  arr.sort(function(a, b){
    return a-b;
  });
  return arr.indexOf(num);
}

getIndexToIns([10, 20, 30, 40, 50], 30);
toekn33cow
@toekn33cow
Nov 28 2016 09:01
i dunno
@jayden8388 have you got it right?
kirbyedy
@kirbyedy
Nov 28 2016 09:02
@toekn33cow https://www.freecodecamp.com/challenges/escape-sequences-in-strings if you did this challenge you should know
Johnny
@JohnnyBizzel
Nov 28 2016 09:02
@YaroNew Don't give up. Keep practising. If you prefer design, concentrate on that. Designing a website is not easy and there is a lot to learn in CSS. If you want me to explain more of the code, just ask.
jayden8388
@jayden8388
Nov 28 2016 09:02
@toekn33cow uhhh i mean i tried doing it but i still seems wrong
@toekn33cow how bout u
toekn33cow
@toekn33cow
Nov 28 2016 09:02
@kirbyedy that's the question im trying to figure out
kirbyedy
@kirbyedy
Nov 28 2016 09:03
the answer is in the instruction on the left
Blauelf
@Blauelf
Nov 28 2016 09:03

@jbkwizera First sort can be removed. I prefer counting the elements that are less than num for its linear runtime, while sort has at least O(n log n).
Like

  var count = 0;
  for (var i = 0; i < arr.length; i++)
    if (arr[i] < num)
      count++;
  return count;

or

  return arr.reduce(function(count, elem) { return count + (elem < num); }, 0);
jayden8388
@jayden8388
Nov 28 2016 09:04
@kirbyedy wow thank u i had a mind blank
CamperBot
@camperbot
Nov 28 2016 09:04
jayden8388 sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:warning: jayden8388 already gave kirbyedy points
jayden8388
@jayden8388
Nov 28 2016 09:04
@kirbyedy i realised that i put the backlash in front of the newline
toekn33cow
@toekn33cow
Nov 28 2016 09:05
@jayden8388 what is it?
Jean Baptiste Kwizera
@jbkwizera
Nov 28 2016 09:06
YES @Blauelf thanks. Just forgot to remove it. It adds nothing.
CamperBot
@camperbot
Nov 28 2016 09:06
jbkwizera sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 3049 | @blauelf |http://www.freecodecamp.com/blauelf
jayden8388
@jayden8388
Nov 28 2016 09:07
@toekn33cow i can give it to u but do you really want it
toekn33cow
@toekn33cow
Nov 28 2016 09:07
@jayden8388 im going crazy atm
jayden8388
@jayden8388
Nov 28 2016 09:08
@toekn33cow ok "FirstLine\n\SecondLine\\rThirdLine" ;
"FirstLine\n\SecondLine\rThirdLine" ;
it keeps on removing the backlash
but just put the backlash in
Blauelf
@Blauelf
Nov 28 2016 09:10
@jayden8388 Use backticks in chat: `inline code` => inline code (inside, \ are not interpreted by chat)
Jean Baptiste Kwizera
@jbkwizera
Nov 28 2016 09:10
@Blauelf I like the use of the for loop
toekn33cow
@toekn33cow
Nov 28 2016 09:11
@jayden8388 i still have this problem: myStr should have encoded text with the proper escape sequences and no spacing. myStr should have two correctly escaped backslash characters \
'''
CamperBot
@camperbot
Nov 28 2016 09:13
:bulb: to format code use backticks! ``` more info
Johnny
@JohnnyBizzel
Nov 28 2016 09:13
^^ readme
Blauelf
@Blauelf
Nov 28 2016 09:14
@toekn33cow What does your current code look like? (Code formatting for chat in the wiki/the forum)
jayden8388
@jayden8388
Nov 28 2016 09:15
"FirstLine\n(backlash)SecondLine(backlash)\rThirdLine";
Johnny
@JohnnyBizzel
Nov 28 2016 09:16
@jayden8388 backslash should be escaped \\
Blauelf
@Blauelf
Nov 28 2016 09:17
@jayden8388 Use backticks in chat: `inline code` => inline code (inside, \ are not interpreted by chat)
(Code formatting for chat in the wiki/the forum)
jayden8388
@jayden8388
Nov 28 2016 09:17
@JohnnyBizzel yeah and i havent read the code formatting stuff yet
toekn33cow
@toekn33cow
Nov 28 2016 09:17
@Blauelf current code var myStr="FirstLine\n\SecondLine\rThirdline";
Johnny
@JohnnyBizzel
Nov 28 2016 09:18
@jayden8388 making code readable is a skill
Blauelf
@Blauelf
Nov 28 2016 09:19
@toekn33cow Added backticks: var myStr="FirstLine\n\SecondLine\rThirdline";
First backslash is not escaped. Second backslash sequence (after SecondLine) is missing. It's ThirdLine with uppercase L.
jayden8388
@jayden8388
Nov 28 2016 09:20
\\
@JohnnyBizzel thanks
CamperBot
@camperbot
Nov 28 2016 09:20
jayden8388 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 899 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Nov 28 2016 09:21
@jayden8388 :+1: ;)
toekn33cow
@toekn33cow
Nov 28 2016 09:22
@Blauelf that's exactly what i have done and i'm still getting it wrong: myStr should have encoded text with the proper escape sequences and no spacing.
Johnny
@JohnnyBizzel
Nov 28 2016 09:22

@toekn33cow

backslash should be escaped \\

Blauelf
@Blauelf
Nov 28 2016 09:23
@toekn33cow What's exactly what you have done? You have escaped the first backslash correctly and added the missing backslash sequence after SecondLine, and fixed case in ThirdLine? Show your code.
toekn33cow
@toekn33cow
Nov 28 2016 09:25
@Blauelf var myStr="Firstline\n(backslash)\Secondline(backslash)\rThirdLine";
Blauelf
@Blauelf
Nov 28 2016 09:26
@toekn33cow Replace the (backslash) with the proper escape sequence \\. And this time, you messed up with the case in FirstLine and SecondLine (uppercase L)
Johnny
@JohnnyBizzel
Nov 28 2016 09:26
@toekn33cow If you can't figure it out, I have provided an answer here: https://jsfiddle.net/JohnnyBizzel/1jrseyq5/
toekn33cow
@toekn33cow
Nov 28 2016 09:28
oh goodness gracious me; how do i send you all brownie points
@Blauelf @JohnnyBizzel thank you!!!
CamperBot
@camperbot
Nov 28 2016 09:31
toekn33cow sends brownie points to @blauelf and @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 900 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
:star2: 3050 | @blauelf |http://www.freecodecamp.com/blauelf
Johnny
@JohnnyBizzel
Nov 28 2016 09:32
@toekn33cow anytime ;)
Blauelf
@Blauelf
Nov 28 2016 09:32
Somewhat round numbers for both of us :)
Riveniers
@Riveniers
Nov 28 2016 09:38
Can anybody give me the answer for " Escape Sequences in Strings " i dont get it. " FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine"
the code:
var myStr; // Change this line
function golfScore(par, strokes) {
  // Only change code below this line
  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!";
    }

  return "Change Me";
  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
can anybody see where I went wrong here ? 8 (
Krzysztof Borowy
@Krizzu
Nov 28 2016 09:41
@Riveniers To escape a character, use backslash ( \ ), then character you want to escape (with no space between them.
Example: escaping backlash (as You can just put \ and expect it to output). You do: \
WAINGOR
@WAINGOR
Nov 28 2016 09:43
never mind!
I got it
:))
Krzysztof Borowy
@Krizzu
Nov 28 2016 09:43
@WAINGOR I bet you changed strokes == par + 2 :)
Riveniers
@Riveniers
Nov 28 2016 09:46
@Krizzu var myStr="FirstLine\n \SecondLine\r ThirdLine"; it s still wrong.
Krzysztof Borowy
@Krizzu
Nov 28 2016 09:48
@Riveniers try var myStr="FirstLine\n SecondLine\r ThirdLine"; As you put \ before SecondLine
jayden8388
@jayden8388
Nov 28 2016 09:48
@Riveniers the answer is up above look
Maximiliaan Strother III
@Mdlkxzmcp
Nov 28 2016 09:50
Hi! Can someone tell me what is wrong with this code for Record Collection? I've been stuck on this one for sooooooooooooo frekking long ;;;;
  if (prop != 'tracks' && value !== ""){
    collection[id][prop] = value;
  }
  else if (prop == 'tracks' && typeof collection[id][prop] == 'undefined') {
    collection[id][prop] = [];
    collection[id][prop] = value;
  }
  else if (prop == 'tracks' && value !== "") {
    colllection[id][prop].push(value);
  }
  else if (value === "") {
    delete collection[id][prop];
  }
Riveniers
@Riveniers
Nov 28 2016 09:50
@Krizzu this doesnt work for some reasons.
Krzysztof Borowy
@Krizzu
Nov 28 2016 09:51
@Krizzu \n makes a new line. \r is a carriage return. If you want a new, third line, do \n
Ogundele Olumide
@Lumexralph
Nov 28 2016 09:51
@Mdlkxzmcp
else if (prop == 'tracks' && typeof collection[id][prop] == 'undefined') {
    collection[id][prop] = [];
    collection[id][prop] = value;    //i spotted this so far, you didn't push value in the array you created
Markus Kiili
@Masd925
Nov 28 2016 09:52
@Mdlkxzmcp Correct way to test property existence is .hasOwnProperty() or .propertyIsEnumerable(). A property can exist and have value undefined.
Ogundele Olumide
@Lumexralph
Nov 28 2016 09:52
@Masd925 hey man !
Markus Kiili
@Masd925
Nov 28 2016 09:52
@Lumexralph Yo!
Ogundele Olumide
@Lumexralph
Nov 28 2016 09:53
good morning
Maximiliaan Strother III
@Mdlkxzmcp
Nov 28 2016 09:53
@Lumexralph @Masd925 Ohh ok!!!! Thank you so much <3333
CamperBot
@camperbot
Nov 28 2016 09:53
mdlkxzmcp sends brownie points to @lumexralph and @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3021 | @masd925 |http://www.freecodecamp.com/masd925
:cookie: 494 | @lumexralph |http://www.freecodecamp.com/lumexralph
Markus Kiili
@Masd925
Nov 28 2016 09:53
@Mdlkxzmcp You could also just assign [value].
Ogundele Olumide
@Lumexralph
Nov 28 2016 09:53
@Masd925 like you went on hols somewhere, right?
@Masd925 how's "Javascript".substring(0, 4) coming up?
Maximiliaan Strother III
@Mdlkxzmcp
Nov 28 2016 09:55
@Masd925 oh ok that also works, great to know :D
Ogundele Olumide
@Lumexralph
Nov 28 2016 09:55
@Mdlkxzmcp :+1:
Markus Kiili
@Masd925
Nov 28 2016 09:57
@Lumexralph Yeah, brushing up my java now.
Ogundele Olumide
@Lumexralph
Nov 28 2016 09:59
okay
FisKusT
@FisKusT
Nov 28 2016 10:07
ho===hello please help how to create function in object create
Ogundele Olumide
@Lumexralph
Nov 28 2016 10:12
@FisKusT Object.create is a method used to create another object that's prototype linked to the the object used to create it but you can specify the value by configuring the characteristics of the property using the value characteristics
Anabel
@AnabelSalomone
Nov 28 2016 10:14
Can somebody explain to me the difference between array[i].charAt(0) and array[i][0]
if there is any difference... :/
Markus Kiili
@Masd925
Nov 28 2016 10:16
@AnabelSalomone They both return the character (string of length 1), but the first is more preferred way. It makes string access look different from array or object access, it has better browser compatibility with old browsers, and the latter might make you think that you can assign to characters (mutate a string).
So str[i] is evil!
Seepamore
@seepsmore
Nov 28 2016 10:17
changed rooms, hello
Ogundele Olumide
@Lumexralph
Nov 28 2016 10:18
@seepsmore hey
Anabel
@AnabelSalomone
Nov 28 2016 10:18
@Masd925 thanks! :clap:
CamperBot
@camperbot
Nov 28 2016 10:18
anabelsalomone sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3022 | @masd925 |http://www.freecodecamp.com/masd925
FisKusT
@FisKusT
Nov 28 2016 10:22
help how to create private property inside an object
CamperBot
@camperbot
Nov 28 2016 10:22
no wiki entry for: how to create private property inside an object
Blauelf
@Blauelf
Nov 28 2016 10:22
@AnabelSalomone There is a difference when you access a non-existent letter. When you write "0211".charAt(4711) (string is obviously much shorter), your return value is "", while "0211"[4711] will result in undefined. In many cases, you want the former.
@FisKusT There are no private properties. You could however have a variable inside your constructor, and define functions that all use that variable, and attach them to this. They still share access to that one even after the constructor is left.
Freddy Meijer
@Freddy-Meijer
Nov 28 2016 10:24
Hey all
Does someone have to time to help me?
Anabel
@AnabelSalomone
Nov 28 2016 10:26
@Blauelf oh, that makes a big difference! Thanks :+1:
CamperBot
@camperbot
Nov 28 2016 10:26
anabelsalomone sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 3051 | @blauelf |http://www.freecodecamp.com/blauelf
Stephen James
@sjames1958gm
Nov 28 2016 10:27
@Freddy-Meijer What do you need?
Freddy Meijer
@Freddy-Meijer
Nov 28 2016 10:28
He stephen, I have a question regarding a bindEvent method I have, it executed the function in the listener right away on page load without having clicked anything
window.addEventListener('load', function () {
    'use strict';

    var arise = {
        init: function () {
            this.cacheDOM();
            this.bindEvents();
        },
        cacheDOM: function () {
            this.ariseLogo = document.getElementById('arise-logo');
            this.nav = document.getElementById('nav');
            this.articleMain = document.getElementById('article-main');
        },
        bindEvents: function () {
            this.ariseLogo.addEventListener('click', this.test(event));
        },
        render: function (change) {
            this.articleMain.innerHTML = change;
        },
        changeArticleMain: function (event) {
            console.log(event);
        },
        test: function (event) {
            alert('clicked ' + event);
        },
        pages: {
            home: "Home",
            whoWeAre: "Who we are",
            getHelp: "Get help",
            getInvolved: "Get involved"
        }
    };

    arise.init();
});
Here's my code
Stephen James
@sjames1958gm
Nov 28 2016 10:29
@Freddy-Meijer You need to pass the name of the function you are calling it and then passing the result.
this.ariseLogo.addEventListener('click', this.test);
FisKusT
@FisKusT
Nov 28 2016 10:30
help with make a person challenge
Object.keys(bob).length should return 6.
bob instanceof Person should return true.
bob.firstName should return undefined.
bob.lastName should return undefined.
bob.getFirstName() should return "Bob".
bob.getLastName() should return "Ross".
bob.getFullName() should return "Bob Ross".
bob.getFullName() should return "Haskell Ross" after bob.setFirstName("Haskell").
bob.getFullName() should return "Haskell Curry" after bob.setLastName("Curry").
bob.getFullName() should return "Haskell Curry" after bob.setFullName("Haskell Curry").
bob.getFirstName() should return "Haskell" after bob.setFullName("Haskell Curry").
bob.getLastName() should return "Curry" after bob.setFullName("Haskell Curry").
i have failed only in the first one
CamperBot
@camperbot
Nov 28 2016 10:30
no wiki entry for: with make a person challenge objectkeysboblength should return 6bob instanceof person should return truebobfirstname should return undefinedboblastname should return undefinedbobgetfirstname should return bobbobgetlastname should return rossbobgetfullname should return bob rossbobgetfullname should return haskell ross after bobsetfirstnamehaskellbobgetfullname should return haskell curry after bobsetlastnamecurrybobgetfullname should return haskell curry after bobsetfullnamehaskell currybobgetfirstname should return haskell after bobsetfullnamehaskell currybobgetlastname should return curry after bobsetfullnamehaskell curryi have failed only in the first one
FisKusT
@FisKusT
Nov 28 2016 10:30

//var newPerson =
var Person = function(firstAndLast) {
this.first = firstAndLast.split(" ")[0];
this.last = firstAndLast.split(" ")1;
this.getFirstName = function(){
return this.first;
};
this.setFirstName = function(firstName){
this.first= firstName;
};
this.getLastName = function(){
return this.last;
};
this.setLastName = function(lastName){
this.last= lastName;
};
this.getFullName = function(){
return this.first +" "+this.last;
};
this.setFullName = function(fullName){
this.first= fullName.split(" ")[0];
this.last= fullName.split(" ")1;
};
};

var bob = new Person('Bob Ross');
//bob.setFirstName("tal");
var t= Object.keys(bob);
t;

here is my code
Freddy Meijer
@Freddy-Meijer
Nov 28 2016 10:30
@sjames1958gm I want to delegate the click later on so I need to pass the event right?
Stephen James
@sjames1958gm
Nov 28 2016 10:31
@Freddy-Meijer The event will be passed by the system when it detects the click.
Freddy Meijer
@Freddy-Meijer
Nov 28 2016 10:32
@sjames1958gm Hmm, indeed, removing (event) works just fine
Stephen James
@sjames1958gm
Nov 28 2016 10:32
@FisKusT first and last should not be used with this, but with var
then don't use this.first but just first (closure handles this)
Freddy Meijer
@Freddy-Meijer
Nov 28 2016 10:32
@sjames1958gm Why is that?
Stephen James
@sjames1958gm
Nov 28 2016 10:33
@Freddy-Meijer Because you want to give a reference to the function to the event handler (which is this.test)
The contract with the system is that it will pass an event back when it calls the function.
Ndumiso
@Ndumiso89
Nov 28 2016 10:33
Hey guys please help i have an issue with a basic javasript challenge where we are told to initialize the three variables a, b, and c with 5, 10, and "I am a" respectively so that they will not be undefined.
Freddy Meijer
@Freddy-Meijer
Nov 28 2016 10:34
@sjames1958gm I think I got it :)
Stephen James
@sjames1958gm
Nov 28 2016 10:34
@Freddy-Meijer :+1:
Freddy Meijer
@Freddy-Meijer
Nov 28 2016 10:34
@sjames1958gm thanks!
CamperBot
@camperbot
Nov 28 2016 10:34
freddy-meijer sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4576 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 28 2016 10:34
@Ndumiso89 Can you show what have you done?
Ndumiso
@Ndumiso89
Nov 28 2016 10:35
// Initialize these three variables
var a; 5;
var b; 10;
var c; "I am a";
// Initialize these three variables
var a; 5;
var b; 10;
var c; "I am a"
STKGSF
@STKGSF
Nov 28 2016 10:36
var a = 5;
Ogundele Olumide
@Lumexralph
Nov 28 2016 10:36
@Ndumiso89 you Initialize like @STKGSF has pointed out
Ayo
@ayondot
Nov 28 2016 10:36
@Ndumiso you have to assign those variables a, b, c with the values provided beside them.
Ndumiso
@Ndumiso89
Nov 28 2016 10:37

look it says // Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";

Ogundele Olumide
@Lumexralph
Nov 28 2016 10:38
@Ndumiso89 means what is on the right is assigned to what's on the left
Ndumiso
@Ndumiso89
Nov 28 2016 10:40
so i assumed that var a; will be 5 because below you have to add 1 to give the total 6 which should define a?
Bled A
@TUcode
Nov 28 2016 10:40

var oldArray = [1,2,3,4,5];

var newArray = oldArray.map(function(jep){
return jep + '3';

});// Only change code below this line.

console.log(newArray);
can somebody check this code
i cant pass
== You should add three to each value in the array. ==
it is already there [13, 23, 33, 43, 53]
Ayo
@ayondot
Nov 28 2016 10:42
@TUcode why are you adding '3' and not 3?
STKGSF
@STKGSF
Nov 28 2016 10:42
@TUcode should be return jep + 3;
Bled A
@TUcode
Nov 28 2016 10:43
```
You should add three to each value in the array.
miasarahb
@miasarahb
Nov 28 2016 10:43
Hi! Im stuck on the Storing Values with the Assignment Operator challenge? I can't figure out how to assign variable a to b. Can anyone help?
Bled A
@TUcode
Nov 28 2016 10:44
yeahhhh ur correct i have just removed the ' ' and passed
Ayo
@ayondot
Nov 28 2016 10:44
@TUcode :thumbsup:
miasarahb
@miasarahb
Nov 28 2016 10:45
blob
Blauelf
@Blauelf
Nov 28 2016 10:46
@miasarahb You mean the one where one has variables a and b? For that, note that both "Assign X to Y" and "Assign Y the value of X" mean Y = X (left side is the variable to assign to, right side is an expression that tells the value that will be assigned)
Krzysztof Borowy
@Krizzu
Nov 28 2016 10:46
@miasarahb = is an assign operator. In expression a = 3, it assings value 3 to variable a. Try assign b to variable a
ChukCharles
@ChukCharles
Nov 28 2016 10:46
Hi everyone!
Seepamore
@seepsmore
Nov 28 2016 10:46
escape
Krzysztof Borowy
@Krizzu
Nov 28 2016 10:46
Hey Chuck!
Seepamore
@seepsmore
Nov 28 2016 10:47
blob
Blauelf
@Blauelf
Nov 28 2016 10:47
I think task is to first assign 7 to a, then a to b.
miasarahb
@miasarahb
Nov 28 2016 10:47
@Blauelf @Krizzu it worked thanks so much! So simple and yet I feel so stupid haha
CamperBot
@camperbot
Nov 28 2016 10:47
miasarahb sends brownie points to @blauelf and @krizzu :sparkles: :thumbsup: :sparkles:
:cookie: 412 | @krizzu |http://www.freecodecamp.com/krizzu
:star2: 3052 | @blauelf |http://www.freecodecamp.com/blauelf
ChukCharles
@ChukCharles
Nov 28 2016 10:47
can please somebody explain me what does it mean:
const binaryArrayToNumber = arr => {
// your code
};
I don't understan this =>
Krzysztof Borowy
@Krizzu
Nov 28 2016 10:48
@miasarahb we've all started there, just keep going :)
Ndumiso
@Ndumiso89
Nov 28 2016 10:48
thsnks people
Blauelf
@Blauelf
Nov 28 2016 10:48
@seepsmore Remove those " from your string. And the escape sequences after SecondLine seem a bit off.
ChukCharles
@ChukCharles
Nov 28 2016 10:48
Tried to google that but no result(
Stephen James
@sjames1958gm
Nov 28 2016 10:49
@ChukCharles That is called an arrow function a new syntax for anonymous functions.
It is equvalent to fucntion(arr) { };
Krzysztof Borowy
@Krizzu
Nov 28 2016 10:49
@ChukCharles That's arrow function - new ES6 function style
Blauelf
@Blauelf
Nov 28 2016 10:49
@ChukCharles const declares a block-scope variable that's assigned with its initialization, and read-only after (cannot be re-assigned).
arr => { } is similar to function(arr){ } (in contrast to regular functions, arrow functions do not have an own this or arguments).
miasarahb
@miasarahb
Nov 28 2016 10:50
@Krizzu thanks will do :D
CamperBot
@camperbot
Nov 28 2016 10:50
miasarahb sends brownie points to @krizzu :sparkles: :thumbsup: :sparkles:
:warning: miasarahb already gave krizzu points
Stephen James
@sjames1958gm
Nov 28 2016 10:50
@ChukCharles Arrow functions have two distinctions from non-arrow functions - they do not set the this value or the arguments value
shenjiuer
@shenjiuer
Nov 28 2016 10:51
how to make the tic tac toe
ChukCharles
@ChukCharles
Nov 28 2016 10:51
@sjames1958gm , @Krizzu @Blauelf Thanks!
CamperBot
@camperbot
Nov 28 2016 10:51
chukcharles sends brownie points to @sjames1958gm and @krizzu and @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 3053 | @blauelf |http://www.freecodecamp.com/blauelf
:star2: 4577 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:cookie: 413 | @krizzu |http://www.freecodecamp.com/krizzu
ChukCharles
@ChukCharles
Nov 28 2016 10:52
now i think i should google for arrow functions))
Blauelf
@Blauelf
Nov 28 2016 10:54

@ChukCharles For very simple functions like

function(arg1, arg2) { // any number of arguments
  return someExpression;
}

there is the version without {}

(arg1, arg2) => someExpression

That's where arrow functions are great.
For a single argument, parentheses around that argument are optional, but for no or multiple arguments, they are required.

ChukCharles
@ChukCharles
Nov 28 2016 10:55
@Blauelf Thanks a lot!
CamperBot
@camperbot
Nov 28 2016 10:55
chukcharles sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: chukcharles already gave blauelf points
FreeHandz
@FreeHandz
Nov 28 2016 11:16
hey guys

// Setup
var myStr = "Jello World";

// Only change code below this line

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

what should i do here?
Codemzy
@codemzy
Nov 28 2016 11:18
@FreeHandz you can't just change one character of a string like that, strings are immutable... so you need to overwrite the entire string (reassign the variable to the new string you want it to store)
Stephen James
@sjames1958gm
Nov 28 2016 11:19
@adityac0620 Depends on what going wrong :) - give us a try
FreeHandz
@FreeHandz
Nov 28 2016 11:20

@codemzy // Setup
var myStr = "Jello World";

// Only change code below this line
myString ="Hello world";
myStr[0] = "H"; // Fix Me

i tried it like this.

Stephen James
@sjames1958gm
Nov 28 2016 11:20
@FreeHandz Make sure you replace the line that says fix Me or the test will still fail because fix me line throws an exception
@FreeHandz Use the correct variable as well
Codemzy
@codemzy
Nov 28 2016 11:21
@FreeHandz yeah, what @sjames1958gm said !
FreeHandz
@FreeHandz
Nov 28 2016 11:21
@sjames1958gm yep
thanks @codemzy @sjames1958gm
CamperBot
@camperbot
Nov 28 2016 11:21
freehandz sends brownie points to @codemzy and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1397 | @codemzy |http://www.freecodecamp.com/codemzy
:star2: 4578 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
adityac0620
@adityac0620
Nov 28 2016 11:23
Can anyone help me figuring out what's going wrong on my side?
The challenge's name is "Truncate a string"
The Link : https://www.freecodecamp.com/challenges/truncate-a-string
Here is my code:
function truncateString(str, num) {
  // Clear out that junk in your trunk
  if (str.length>num && str.length<3){
  str=str.slice(0,num);
    str+="...";
  }
  else if (str.length>(num-3)){
     str=str.slice(0,(num-3));
    str+="...";
  }
  return str;
}

truncateString("Absolutely Longer", 2);
heroiczero
@heroiczero
Nov 28 2016 11:25
@adityac0620 if num is less than or equal to three you do not have to add three dots.<-- do you have this condition in your function
Diego Mayer
@Chrono79
Nov 28 2016 11:26
@adityac0620 isn't it num<3 ? `if (str.length>num && str.length<3){`there
Aarya Bhorra
@aarya1302
Nov 28 2016 11:27
function killKthBit(n, k) {
  return n & ~(1 << (k - 1)) ;
}
can anyone explain to me this code?
Bled A
@TUcode
Nov 28 2016 11:27
var array = [4,5,6,7,8];
var singleVal = 0;

singleVal = array.reduce(function(toti, currentVal){
  return toti + currentVal;
});
// Only change code below this line.

singleVal = array;
ChukCharles
@ChukCharles
Nov 28 2016 11:27
As I remember in this Challenge you should use not three dots
Dut symbol of three dots
Diego Mayer
@Chrono79
Nov 28 2016 11:27
@TUcode // Only change code below this line.
What are you supposed to do there?
Bled A
@TUcode
Nov 28 2016 11:29
oh my god
ChukCharles
@ChukCharles
Nov 28 2016 11:29
Bled A
@TUcode
Nov 28 2016 11:30
var array = [4,5,6,7,8];
var singleVal = 0;

// Only change code below this line.
singleVal = array.reduce(function(toti, currentVal){
  return toti + currentVal;
});
Diego Mayer
@Chrono79
Nov 28 2016 11:30
@TUcode delete the last line, and move your code below the comment (it could work there)
:+1:
Bled A
@TUcode
Nov 28 2016 11:30
this one works fine
@Chrono79 Thank you
CamperBot
@camperbot
Nov 28 2016 11:30
tucode sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 2647 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Nov 28 2016 11:30
np
Aarya Bhorra
@aarya1302
Nov 28 2016 11:31
function killKthBit(n, k) {
  return n & ~(1 << (k - 1)) ;
}
can anyone explain to me this code?
Diego Mayer
@Chrono79
Nov 28 2016 11:32
@aarya1302 << is a bitwise operator
adityac0620
@adityac0620
Nov 28 2016 11:32
@Chrono79 well thhat didnt happen to work out it is supposed to have the dots i think
Stephen James
@sjames1958gm
Nov 28 2016 11:32
@aarya1302 The ~ symbol is the operation for binary NOT which converts the value to 32 bit value and inverts the bits
The value 1 << (k - 1) sets one bit in the kth position, so after this and the ~ you will have all 1s except for the kth bit
When combined with & it will clear the kth bit and leave all the rest unchanged
Diego Mayer
@Chrono79
Nov 28 2016 11:33
@adityac0620 it's num<=3
ChukCharles
@ChukCharles
Nov 28 2016 11:33
@adityac0620 As I remember in this Challenge you should use not three dots, but ellipsis, which is 1 symbol (not 3): https://en.wikipedia.org/wiki/Ellipsis
Stephen James
@sjames1958gm
Nov 28 2016 11:34
@ChukCharles It is the string '...' Note that inserting the three dots to the end will add to the string length.
adityac0620
@adityac0620
Nov 28 2016 11:34

Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a ... ending.

Note that inserting the three dots to the end will add to the string length.

However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string. @Chrono79 Here is the exact statement for the chalenge.

Diego Mayer
@Chrono79
Nov 28 2016 11:34
@adityac0620 you better use nested ifs there
@aarya1302 no problem
Aarya Bhorra
@aarya1302
Nov 28 2016 11:36
Thanks @Chrono79 and @sjames1958gm
CamperBot
@camperbot