These are chat archives for FreeCodeCamp/HelpJavaScript

21st
May 2017
t0cc
@t0cc
May 21 2017 00:01
cmccormack: OK, It looks like I'm not the only one with the same idea and the same problem that it isn't accepted
Christopher McCormack
@cmccormack
May 21 2017 00:01
@t0cc I just got it working myself using your method, I think the problem is your truth statement - you should be assigning the result of the recursive lookup to something
Gotta run for dinner though - ping me later if you don't get it working but I"m sure you will
t0cc
@t0cc
May 21 2017 00:04
np, I will lokk into it
Sohel-ASM
@Sohel-ASM
May 21 2017 00:09
Will anyone plz tell me what I am doing wrong here? it's "Using objects for Lookups" exercise.
function phoneticLookup(val) {
  var result = "";

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

  result = lookup.val;


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

// Change this value to test
phoneticLookup("charlie");
Diego Mayer
@Chrono79
May 21 2017 00:12
@Sohel-ASM you can't use dot notation with vars
Sohel-ASM
@Sohel-ASM
May 21 2017 00:14
@Chrono79 but any previous exercise didn't say anything like that, it said I can use either dot or bracket notation, or use a variable to tap on a property inside the object.
@Chrono79 so, my question is why I can't use dot notation in here then?
lookup.val is the same as lookup["val"] there, and as you can see, there is no "val" property there
Sohel-ASM
@Sohel-ASM
May 21 2017 00:16
@Chrono79 let me check ur link for quick plz.
@Chrono79 oh, now I see it, thank you, sorry, seems like I didn't pay much attention in doing that exercise. I know, it may sound irrelevant, but can you clarify the issue here a little bit more for me plz, it may help me to understand it better, and avoid such mistakes in future.
CamperBot
@camperbot
May 21 2017 00:21
sohel-asm sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4062 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
May 21 2017 00:22
@Sohel-ASM as I said, dot notation looks for the literal word
when you use bracket notation, you use the value contained in the var
lookup[val] is the same as lookup["some string contained in val"]
Dakota Woods
@Dakoa
May 21 2017 00:22

Hello could I please get aome help on the Title Case a Sentence bonfire? My code is returning the first letter capitalized instead of the full string tittle cased and I don't knkw why. Here's the code:
function titleCase(str) {

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

}
}

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

CamperBot
@camperbot
May 21 2017 00:22
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
Diego Mayer
@Chrono79
May 21 2017 00:23
@Dakoa :point_up: 20 de mayo de 2017 20:48
Dakota Woods
@Dakoa
May 21 2017 00:24
@Chrono79 it actually doesn't make a difference
Diego Mayer
@Chrono79
May 21 2017 00:25
@Dakoa you're overwriting str, why?
Sohel-ASM
@Sohel-ASM
May 21 2017 00:25
@Chrono79 makes sense. so when we use dot notation when we exactly know the property name, which value we are trying to find, but in other cases, we use bracket notation, right?
Diego Mayer
@Chrono79
May 21 2017 00:25
@Sohel-ASM exactly, another case you can't use dot notation is when the property name contain spaces
Dakota Woods
@Dakoa
May 21 2017 00:26
@Chrono79 because otherwise it returns the string uneditted. As in just an array of the words per str=str.split(" ");
Diego Mayer
@Chrono79
May 21 2017 00:27
@Dakoa no, you could ovewrite str[i], but overwriting the whole array, you lose data
i is 0
str[i][0] is I, you uppercase that and set it to str, then str[1] doesn't exist
Dakota Woods
@Dakoa
May 21 2017 00:28
@Chrono79 What does you mean by overwriting str[i]?
*do you mean
Sohel-ASM
@Sohel-ASM
May 21 2017 00:28
@Chrono79 yup, I remember that. Do you think it's normal that I misses such precise differences during my exercises, or it's just a lack of paying attention? ( if the question seems irrelevant to you, plz ignore it. I am just trying to understand how I can improve my take from the lessons).
Diego Mayer
@Chrono79
May 21 2017 00:29
@Sohel-ASM it's a common mistake, just make sure you know when you can use one or the other from now on
@Dakoa You could replace each word of the array for a title cased version of each one, and then join before returning, you need to return a string
Title case means you capitalize the first letter and the rest of the word is in lowercase
Sohel-ASM
@Sohel-ASM
May 21 2017 00:31
@Chrono79 Thank you. I asked that because I have run into such issues before, where I failed in exercises due to failure in catching the trivial differences in using JS tools.
CamperBot
@camperbot
May 21 2017 00:31
sohel-asm sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: sohel-asm already gave chrono79 points
Chris
@aznthnder
May 21 2017 00:32
I am not understanding the "Stand In Line" challenge. I do not know where to even start
Diego Mayer
@Chrono79
May 21 2017 00:32
@aznthnder Start reviewing all 4 array manipulation challenges, use 2 of them
Sohel-ASM
@Sohel-ASM
May 21 2017 00:33
@aznthnder will you plz copy paste ur problem here to look into?
t0cc
@t0cc
May 21 2017 00:33
Dakoa: be careful, in JS strings are immutable.
Sohel-ASM
@Sohel-ASM
May 21 2017 00:34
@aznthnder or you can PM me, if you like.
Cascarr Alejandro Ihesie
@cascarr
May 21 2017 00:45
hi guys.. please help me with this

//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 === contacts.hasOwnProperty('firstName')) {

}

// Only change code above this line
}

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

Diego Mayer
@Chrono79
May 21 2017 00:45
@cascarr contacts is an array, to access a single contact, you need to use a loop
hasOwnProperty returns true or false, and firstName contains a string, you can't compare one to the other
Cascarr Alejandro Ihesie
@cascarr
May 21 2017 00:49
@Chrono79 please I don't understand
FlashHero
@FlashHero
May 21 2017 00:50
I don't know how to start the Sum All Odd Fibonacci Numbers
challenge
Diego Mayer
@Chrono79
May 21 2017 00:50
@cascarr start creating a loop to access a single contact
Then check firstName (the function param) against the contact property and see if they match
Mohamed Derhalli
@derhallim
May 21 2017 00:52
@Chrono79 @cmccormack ty wassup?
CamperBot
@camperbot
May 21 2017 00:52
derhallim sends brownie points to @chrono79 and @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 621 | @cmccormack |http://www.freecodecamp.com/cmccormack
:star2: 4063 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
May 21 2017 00:53
@derhallim I was looking weirdly at my cat, and then the pizza arrived ;)
:wave:
Mohamed Derhalli
@derhallim
May 21 2017 00:54
haha
say hi to the cat
Stephen James
@sjames1958gm
May 21 2017 01:00
@derhallim :wave:
@aznthnder The function has two parameters arr and item.
The function is supposed to simulate a queue by adding item to the end of the queue (arr)
Then remove and return the first value in the queue (arr)
Use two of the array functions pop, push, shift, unshift
Mohamed Derhalli
@derhallim
May 21 2017 01:02
@sjames1958gm suppppp
no new pic today? :O
Stephen James
@sjames1958gm
May 21 2017 01:02
@derhallim About to change it for tomorrow.
Mohamed Derhalli
@derhallim
May 21 2017 01:02
can u add .gif?
Stephen James
@sjames1958gm
May 21 2017 01:04
@derhallim Not sure it is through github profile.
Mohamed Derhalli
@derhallim
May 21 2017 01:04
I saw a guy with .gif image in the other day, don't know how .. github won't make it move
Cascarr Alejandro Ihesie
@cascarr
May 21 2017 01:05
@Chrono79 do I need to create a new variable?
FlashHero
@FlashHero
May 21 2017 01:12

function sumFibs(num) {
 var arr=[1,1];
  var result=[];
 arr.reduce(function(previous,current){
      arr.push(previous+current);
 });
  return arr;
}

sumFibs(1);
Is there a way to add only last two numbers in an array
Dakota Woods
@Dakoa
May 21 2017 01:17
@t0cc I'm using a method, though.
Cascarr Alejandro Ihesie
@cascarr
May 21 2017 01:20

@Chrono79 //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 < 5; i++) {
for (var j=0; j < firstName[i].length; j++) {
return contacts[firstName];
}
}

// Only change code above this line
}

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

Diego Mayer
@Chrono79
May 21 2017 01:23
@cascarr no, you only need one loop, and you have to use contacts array in it
Rick Riggs
@wikiwiggs
May 21 2017 01:24
@FlashHero
var lastTwoSum = arr[arr.length-1]+arr[arr.length-2];
joy33joy
@joy33joy
May 21 2017 01:37
how do you initialize the remainder
I tried var remainder = %; , but it says "expected as an identifier and instead saw %
Moisés Man
@moigithub
May 21 2017 01:37
remainder = some value or formula
% is an operator like + (adition) or - (substraction )or / (division)
soo what values u gonna use to do that calc ?
ie.. if u wanna sum 1 and 2 u do something like
result = 1 + 2
joy33joy
@joy33joy
May 21 2017 01:39
I am learning Finding a Remainder in Javascript, and The Variable remainder should be initalized
And % is symbol of Remainder, but 11 % 3 doesn't work
do you know why % is unexpected token
Moisés Man
@moigithub
May 21 2017 01:40
check that last line above..
u doing result = +
whats missing ?? compare those 2 black lines
the operator by itself do nothing.. u need also numbers
Stephen James
@sjames1958gm
May 21 2017 01:42
@joy33joy % is a binary operator just like / or + you need to have variables/numbers on each side of %
Gilbert
@gilbertp97
May 21 2017 01:42
hello coders
i have a question
getActiveTodos: function () {
      debugger;
            return this.todos.filter(function (todo) {
                return !todo.completed;
            });
i want to know if return !todo.completed; only looks for a false value because of the bang operator
Stephen James
@sjames1958gm
May 21 2017 01:44
@gilbertp97 This code will only return the values where completed is false because !false is true
Roxroy
@roxroy
May 21 2017 01:44
@gilbertp97 , yes, it 's the same as return todo.completed === false
Gilbert
@gilbertp97
May 21 2017 01:44
okay i understand now :D
joy33joy
@joy33joy
May 21 2017 01:44
The remainder operator % gives the remainder of the division of two numbers.
I'm still not sure how to use remainder.. Can you show me an example of using it?
Gilbert
@gilbertp97
May 21 2017 01:45
    getCompletedTodos: function () {
            return this.todos.filter(function (todo) {
                return todo.completed;
            });
will this return todo.completed only look for a true completed value?
Roxroy
@roxroy
May 21 2017 01:46
@gilbertp97 , Yes .You can give it a go to see
Moisés Man
@moigithub
May 21 2017 01:46

remainder is just one math operator like + or - or /

sum = 1  + 2
substraction = 2 - 1
div = 10 / 3

remainder = _______

Gabe Rotberg
@grotberg
May 21 2017 01:47
@joy33joy lets say you had hours in 24 hour time but you wanted to display it in 12 hour time. You could do var newHours = oldHours % 12; this would give you newHours = 5 for oldHours = 17 or oldHours = 5, etc
amelink
@amelink
May 21 2017 01:47
hi, can someone help me for the exercise Sort Arrays with sort please?
Gabe Rotberg
@grotberg
May 21 2017 01:48
@joy33joy (it wouldn't really work right for noon though: 12%12 is 0)
amelink
@amelink
May 21 2017 01:48
I don't know how to sort from largest to smallest
joy33joy
@joy33joy
May 21 2017 01:48
var remainder = 11 % 3;
Like this right?
Oh it worked thank you so much!!! @grotberg @moigithub
MastermindPT
@MastermindPT
May 21 2017 01:49
how do you post print screens?
Gabe Rotberg
@grotberg
May 21 2017 01:49
@joy33joy exactly. remainder would == 2 in this case.
Moisés Man
@moigithub
May 21 2017 01:51
use backticks click more info below ''' @MastermindPT
CamperBot
@camperbot
May 21 2017 01:51
:bulb: to format code use backticks! ``` more info
J. Cardenas
@ewrjontan
May 21 2017 01:52
So I am doing the DNA pairing challenge, and my code is returning EXACTLY what is required...but it isn't being accepted
this happen to anyone?
joy33joy
@joy33joy
May 21 2017 01:53
@MastermindPT at the right bottom corner click M button and read the lastest thing
J. Cardenas
@ewrjontan
May 21 2017 01:53
I've compared the results with the and they are legit, 100% the same.
Roxroy
@roxroy
May 21 2017 01:53
@ewrjontan , yes. Save you code then reset and add past the code.
J. Cardenas
@ewrjontan
May 21 2017 01:53
tried that as well
Gabe Rotberg
@grotberg
May 21 2017 01:54
@ewrjontan which test are failing? can you show us your code?
J. Cardenas
@ewrjontan
May 21 2017 01:54
Here is a fiddle
abhi4singhal
@abhi4singhal
May 21 2017 01:54
var myStr='FirstLine\nSecondLine';
This gives the output as :
var myStr='FirstLine\nSecondLine';
instead of
myStr="FirstLine
Secondline";
can someone please explain what am i doing wrong here ?
J. Cardenas
@ewrjontan
May 21 2017 01:55
All of the tests fail, but the required results and my codes results are the same
as far as I can tell atleast
I'm probably just missing something super simple :/
@abhi4singhal that outputs like you want, for me
Gabe Rotberg
@grotberg
May 21 2017 01:59
@ewrjontan I'm not seeing why its failing either
J. Cardenas
@ewrjontan
May 21 2017 01:59
Well, glad it's not just me lol.
abhi4singhal
@abhi4singhal
May 21 2017 01:59
@ewrjontan then this must be a bug on part of freeCodeCamp
J. Cardenas
@ewrjontan
May 21 2017 01:59
I figured it was Chrome since I tend to keep it open for obnoxiously long periods of time. I tried it in IE and does the same thing
@abhi4singhal perhaps. I tried your code in jsfiddle.
abhi4singhal
@abhi4singhal
May 21 2017 02:00
@ewrjontan What's jsfiddle ?
Rick Riggs
@wikiwiggs
May 21 2017 02:02
@amelink did someone help you yet?
PhoenixFarhan
@PhoenixFarhan
May 21 2017 02:03
'''
CamperBot
@camperbot
May 21 2017 02:03
:bulb: to format code use backticks! ``` more info
PhoenixFarhan
@PhoenixFarhan
May 21 2017 02:03

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

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

Hi I am having trouble with that multiplication array
Rick Riggs
@wikiwiggs
May 21 2017 02:03
@PhoenixFarhan Try the key right above your tab key
PhoenixFarhan
@PhoenixFarhan
May 21 2017 02:04

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

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

hmm? what does that do?
Rick Riggs
@wikiwiggs
May 21 2017 02:04
@PhoenixFarhan do that three times, hit shift+enter, paste your code, hit shift+enter again, do that three more times.
PhoenixFarhan
@PhoenixFarhan
May 21 2017 02:05
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i < arr.length; i++) {
    product *= arr[i];
     for (var j = 0; j < arr[i].length; j++) {
    product *= arr[i[j]];
     }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
oo thats cool
thanks!
Rick Riggs
@wikiwiggs
May 21 2017 02:05
:clap:
PhoenixFarhan
@PhoenixFarhan
May 21 2017 02:05
Thanks @wikiwiggs Rick Riggs
CamperBot
@camperbot
May 21 2017 02:05
phoenixfarhan sends brownie points to @wikiwiggs :sparkles: :thumbsup: :sparkles:
:cookie: 298 | @wikiwiggs |http://www.freecodecamp.com/wikiwiggs
Rick Riggs
@wikiwiggs
May 21 2017 02:06
@PhoenixFarhan Glad to help
PhoenixFarhan
@PhoenixFarhan
May 21 2017 02:07
now for the problem at hand, i seem to be having trouble targeting the 2nd and 3rd elements of the mutiplyAll function.. thats what the 2nd for loop and var j is for
Rick Riggs
@wikiwiggs
May 21 2017 02:08
so you are trying to flatten the array, and then multiply every value together?
PhoenixFarhan
@PhoenixFarhan
May 21 2017 02:09
yep
Rick Riggs
@wikiwiggs
May 21 2017 02:09
OK, I would recommend setting up a blank array, and then pushing each value into that new array first and foremost.
var newArr = [];
PhoenixFarhan
@PhoenixFarhan
May 21 2017 02:12
~~~var arr = [
[1,2], [3,4], [5,6]
];
for (var i=0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++) {
console.log(arr[i][j]);
}
}
var arr = [
  [1,2], [3,4], [5,6]
];
for (var i=0; i < arr.length; i++) {
  for (var j=0; j < arr[i].length; j++) {
    console.log(arr[i][j]);
  }
}
thats the example given, i think they want us to use nested for loops
to solve the problem
Rick Riggs
@wikiwiggs
May 21 2017 02:13
@PhoenixFarhan
var a = [[1,2],[3,4],[5,6,7]];
var newArr = [];
for(var x=0;x<a.length;x++){
  for(var y=0;y<a[x].length;y++){
    newArr.push(a[x][y]);
  }
}
@PhoenixFarhan are you with me so far?
PhoenixFarhan
@PhoenixFarhan
May 21 2017 02:15
Yes
Rick Riggs
@wikiwiggs
May 21 2017 02:15
Awesome.
PhoenixFarhan
@PhoenixFarhan
May 21 2017 02:16
Thanks @wikiwiggs
CamperBot
@camperbot
May 21 2017 02:16
phoenixfarhan sends brownie points to @wikiwiggs :sparkles: :thumbsup: :sparkles:
:warning: phoenixfarhan already gave wikiwiggs points
Rick Riggs
@wikiwiggs
May 21 2017 02:16
@PhoenixFarhan do you have it from here?
Md Abu Zafar
@mdaz78
May 21 2017 02:20
Math.floor(Math.random() * (max - min + 1)) + min
This code is used to generate a number between a maximum and a minimum number.
Can anybody please explain why we are doing (max-min+1) and than adding min to the whole equation.
@wikiwiggs @PhoenixFarhan any Help?
Rick Riggs
@wikiwiggs
May 21 2017 02:26
@mdaz78 Math.random() produces a number between 0.00 and 1.00
FlashHero
@FlashHero
May 21 2017 02:27
@wikiwiggs thanks
CamperBot
@camperbot
May 21 2017 02:27
flashhero sends brownie points to @wikiwiggs :sparkles: :thumbsup: :sparkles:
:cookie: 299 | @wikiwiggs |http://www.freecodecamp.com/wikiwiggs
Rick Riggs
@wikiwiggs
May 21 2017 02:27
the modifications on the end are to give you a number above 1.00, so that you can floor the value to an integer
EDIT: sorry that was not enough of an explanation to be clear.
Math.random() is not inclusive of 1.00 (eg. it returns a number between 0.00 and something less than 1.00), so you also have to add that back in, hence the min value at the very end and the + 1 within the parenthesis.
Colin
@SkateCarbonCopy
May 21 2017 02:37
Could anyone help me understand why the code I have added works for every case in the mutations basic algorithm challenge except the first one?
function mutation(arr) {
  var word1 = arr[0].toLowerCase();
  var word2 = arr[1].toLowerCase();
  for (i=0; i<word2.length; i++) {
    if (word1.indexOf(word2[i]) != -1) {
      return true;
    }
  return false;
}
}
mutation(["hello", "hey"]);
Dakota Woods
@Dakoa
May 21 2017 02:42
Hello, I need help with the Title Case a Sentence challenge. I don't understand why my code is returning
Diego Mayer
@Chrono79
May 21 2017 02:42
@SkateCarbonCopy you're only comparing the first letter like that
Dakota Woods
@Dakoa
May 21 2017 02:43
Whoops, my code is reutning "I" instead of the whole input title cased and I don't knkw why. Here's the code

function titleCase(str) {

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

}
return str;
}

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

Diego Mayer
@Chrono79
May 21 2017 02:43
@Dakoa again, because you overwrite str
do str[i] = something, where something is the first letter of the word capitalized plus the rest of the word
Dakota Woods
@Dakoa
May 21 2017 02:44
@Chrono79 Okay, I'll show you what happens when I don't overwrite
Rick Riggs
@wikiwiggs
May 21 2017 02:44
@Dakoa All caps
Dakota Woods
@Dakoa
May 21 2017 02:44
@Chrono79 ["i'm","a","little","tea","pot"]
Is what it returns
Colin
@SkateCarbonCopy
May 21 2017 02:45
@Chrono79 Ahh, ok I see that now. Thanks!
CamperBot
@camperbot
May 21 2017 02:45
skatecarboncopy sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4064 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
May 21 2017 02:45
@Dakoa when you don't overwrite (and with your code like it is) you should get ["I", "A", "L", "T", "P"]
Dakota Woods
@Dakoa
May 21 2017 02:46

function titleCase(str) {

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

}
return str;
}

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

It doesn't though
Diego Mayer
@Chrono79
May 21 2017 02:46
@Dakoa I said, str[i] = instead of str =
Dakota Woods
@Dakoa
May 21 2017 02:47
Oh shit
I didn't understand
Diego Mayer
@Chrono79
May 21 2017 02:47
:+1:
Rick Riggs
@wikiwiggs
May 21 2017 02:47
@Dakoa try this:

function titleCase(str) {

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

titleCase("I'm a little tea pot");
Diego Mayer
@Chrono79
May 21 2017 02:48
@Dakoa use slice, substr or substring to get the rest of the word and concatenate that to the first letter capitalized
Remember to use join before returning, you should return a string, not an array
Dakota Woods
@Dakoa
May 21 2017 02:48
@Chrono79 @wikiwiggs thank you very much
CamperBot
@camperbot
May 21 2017 02:48
dakoa sends brownie points to @chrono79 and @wikiwiggs :sparkles: :thumbsup: :sparkles:
:cookie: 300 | @wikiwiggs |http://www.freecodecamp.com/wikiwiggs
:star2: 4065 | @chrono79 |http://www.freecodecamp.com/chrono79
Dakota Woods
@Dakoa
May 21 2017 02:49
I understand, will be back with the results
Diego Mayer
@Chrono79
May 21 2017 02:49
good luck
chameleon07
@chameleon07
May 21 2017 02:49

Help

function factorialize(num) {
  array = [num];

  for (i = num; i > 0; i--){
    newA = array.concat(i);
  }

 return newA;
  //return array.reduce(function(prev,cur){return prev*cur;},1);
}

factorialize(5);

I dont understand why my for loop is not producing the array = [1,2,3,4,5]...

Rick Riggs
@wikiwiggs
May 21 2017 02:50
@Dakoa Ignore my advice completely, strings are not changeable this way without creating a new one. I don't know what I was thinking telling you that.
chameleon07
@chameleon07
May 21 2017 02:50
It gives a loop of [5,1]...
my array has the name newA
Dakota Woods
@Dakoa
May 21 2017 02:51
Thank you, and one more thing @Chrono79, how would I concat the capitalized letter to the substring without simply adding the array to the end of the substring? I mean how would I pair up the first word with the first capital letter and so on?
CamperBot
@camperbot
May 21 2017 02:51
dakoa sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: dakoa already gave chrono79 points
Diego Mayer
@Chrono79
May 21 2017 02:52
@chameleon07 array = array.concat(i); initialize array as an empty array
Rick Riggs
@wikiwiggs
May 21 2017 02:52
@chameleon07
function factorialize(num) {
  array = [num];
  var newA = [];
  for (i = num; i > 0; i--){
    newA.push(array.concat(i));
  }
  return newA;
}
factorialize(5);
Dakota Woods
@Dakoa
May 21 2017 02:52
Okay, thanks again
chameleon07
@chameleon07
May 21 2017 02:53
Ahhhhh
@Chrono79 Thank you! :D
CamperBot
@camperbot
May 21 2017 02:53
chameleon07 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4066 | @chrono79 |http://www.freecodecamp.com/chrono79
chameleon07
@chameleon07
May 21 2017 02:54
@wikiwiggs Thank you too :D
CamperBot
@camperbot
May 21 2017 02:54
chameleon07 sends brownie points to @wikiwiggs :sparkles: :thumbsup: :sparkles:
:cookie: 301 | @wikiwiggs |http://www.freecodecamp.com/wikiwiggs
Rick Riggs
@wikiwiggs
May 21 2017 02:54
@chameleon07 :smile:
Netrunner21
@Netrunner21
May 21 2017 03:03
Would anyone like to pair program Sum All Primes?
Jake R.
@theaquacadet
May 21 2017 03:09
Hey guys, I'm having difficulty with the "Profile Lookup" challenge. I'm trying to get it to see if a name exists, and if it does, if the property it asks exists, and if it does, echo the property. I'm not entirely sure what I'm doing wrong.
function lookUpProfile(firstName, prop){
// Only change code below this line
if (contacts.hasOwnProperty(firstName)) {
  if (contacts.hasOwnProperty(prop)) {
    return contacts[prop];
  }  else {
    return "No such property";
  }
} else {
  return "No such contact";
}
// Only change code above this line
}
Netrunner21
@Netrunner21
May 21 2017 03:09
@theaquacadet I remember having to loop through the data
@theaquacadet i secifically remember the line return contacts[i][prop];
sorry, * specifically
@theaquacadet you're definitely on the right track
it's very close
Gaurav khanna
@gomzk85
May 21 2017 03:11
Hi
Netrunner21
@Netrunner21
May 21 2017 03:11
Hi
kerafyrm02
@kerafyrm02
May 21 2017 03:11
function diffArray(arr1, arr2) {

  var newArray = [];
  var answer = [];

  newArray = arr1.concat(arr2);

  for (var i = 0; i < newArray.length; i++){
    if ( newArray.indexOf(newArray[i]) === newArray.lastIndexOf(newArray[i]) ) { 
      answer.push(newArray[i]);
      }
  }

  return answer;
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Is there better?
Netrunner21
@Netrunner21
May 21 2017 03:12
@kerafyrm02 yes
Jake R.
@theaquacadet
May 21 2017 03:12
@Netrunner21 thanks for the advice
CamperBot
@camperbot
May 21 2017 03:12
theaquacadet sends brownie points to @netrunner21 :sparkles: :thumbsup: :sparkles:
:cookie: 310 | @netrunner21 |http://www.freecodecamp.com/netrunner21
Gaurav khanna
@gomzk85
May 21 2017 03:12
Guys does any one know where can i get some machine coding interview questions ?
Netrunner21
@Netrunner21
May 21 2017 03:12
@kerafyrm02 mine has a little less code. Does yours work?
kerafyrm02
@kerafyrm02
May 21 2017 03:12
Yes mine works.
Netrunner21
@Netrunner21
May 21 2017 03:13
Here's what I have
Gaurav khanna
@gomzk85
May 21 2017 03:13
Guys does any one know where can i get some javascript machine coding interview questions ?
Netrunner21
@Netrunner21
May 21 2017 03:13
function diffArray(arr1, arr2) {
  var newArr = arr1.concat(arr2);  
  return newArr.filter(function(elem) {
    return newArr.indexOf(elem) == newArr.lastIndexOf(elem);
  });
}

diffArray([1, "calf", 3, "piglet"], [1, "calf", 3, 4]);
kerafyrm02
@kerafyrm02
May 21 2017 03:13
ah filter
Netrunner21
@Netrunner21
May 21 2017 03:13
It doesn't appear that you need the for loop
@theaquacadet no problem. Good luck.
kerafyrm02
@kerafyrm02
May 21 2017 03:14
I need the for loop since im not using filter
filter is slower than loops
but yours is probably easier to read
Yeah-- much cleaner
Netrunner21
@Netrunner21
May 21 2017 03:17
speed probably is preferable
I just read where the for loop is twice as fast when tested
one of the few native methods that are much slower than expected.
kerafyrm02
@kerafyrm02
May 21 2017 03:18
yeah.
Netrunner21
@Netrunner21
May 21 2017 03:24
I need some help with Where For Art Thou
Anyone available?
Gaurav khanna
@gomzk85
May 21 2017 03:25
Guys does any one know where can i get some javascript machine coding interview questions ?
Jake R.
@theaquacadet
May 21 2017 03:28
Gaurav khanna
@gomzk85
May 21 2017 03:30
@theaquacadet hey thanks but i need javascript coding interview questions not machine learning
CamperBot
@camperbot
May 21 2017 03:30
gomzk85 sends brownie points to @theaquacadet :sparkles: :thumbsup: :sparkles:
:cookie: 221 | @theaquacadet |http://www.freecodecamp.com/theaquacadet
Jake R.
@theaquacadet
May 21 2017 03:32
@gomzk85 sorry, I misread your question. google is a valuable tool though, make sure to check there.
Gaurav khanna
@gomzk85
May 21 2017 03:32
@theaquacadet i checked but was not able to find much on it
Santi Valdez
@SantiValdez
May 21 2017 03:33
Hello guys, i am having real trouble getting images to resize properly in flexbox. They stretch their width instead of actualy keeping their square shape
Andrae M
@andraemarcus
May 21 2017 03:34
Hello FCC, I'm having problems with my toggle menu and hope someone can help out. Upon clicking on the animated Hamburger icon, I would like a navigation menu to appear. However, when clicking on the icon, the slide menu doesn't take up the entire page. Here is my code ---->>>>
Screen Shot 2017-05-20 at 8.29.15 PM.png
Screen Shot 2017-05-20 at 8.29.27 PM.png
Jake R.
@theaquacadet
May 21 2017 03:35
@gomzk85 what kind of questions are you looking for? from what I understand interviews will have you actually write some code to solve some imaginary problem. https://www.interviewcake.com/javascript-interview-questions Is this kinda what your looking for?
Andrae M
@andraemarcus
May 21 2017 03:35
Screen Shot 2017-05-20 at 8.35.45 PM.png
Screen Shot 2017-05-20 at 8.28.37 PM.png
Screen Shot 2017-05-20 at 8.28.29 PM.png
Rick Riggs
@wikiwiggs
May 21 2017 03:37
@andraemarcus are you looking for a javascript solution?
Rick Riggs
@wikiwiggs
May 21 2017 03:40
@andraemarcus Oh nevermind, I didn't see the jquery screenshot for some reason.
Gaurav khanna
@gomzk85
May 21 2017 03:40
@theaquacadet yaa type of these are helpful thanks
CamperBot
@camperbot
May 21 2017 03:40
:warning: gomzk85 already gave theaquacadet points
gomzk85 sends brownie points to @theaquacadet :sparkles: :thumbsup: :sparkles:
arrozconfrijoles
@arrozconfrijoles
May 21 2017 03:41
hey question about the .sort() function
Andrae M
@andraemarcus
May 21 2017 03:41
@wikiwiggs hey bro, thanks for the quick response. The js screenshot just uploaded not too long ago. Do you see it?
CamperBot
@camperbot
May 21 2017 03:41
andraemarcus sends brownie points to @wikiwiggs :sparkles: :thumbsup: :sparkles:
:cookie: 302 | @wikiwiggs |http://www.freecodecamp.com/wikiwiggs
arrozconfrijoles
@arrozconfrijoles
May 21 2017 03:42
does it not work well when a number is there twice? I am trying to sort an array of [3, 5, 20, 3] and my algorithm works for everything but that specific one
Rick Riggs
@wikiwiggs
May 21 2017 03:43
@andraemarcus I think you might be referencing the wrong thing to toggle, do you really want your icon to be the thing that fills the screen? If you do, that's ok, it just logically sounds suspect to me...
Luis Felipe López G.
@luishendrix92
May 21 2017 03:45
[3, 5, 20, 3].sort((a, b) => a > b) should do the trick
arrozconfrijoles
@arrozconfrijoles
May 21 2017 03:46
@luishendrix92 I ended up adding a little function similar to that.
 function sortaa(a,b){
    return (a-b);
  }

  arr.sort(sortaa);
thanks @luishendrix92
CamperBot
@camperbot
May 21 2017 03:46
mouthfullofgoldteeth sends brownie points to @luishendrix92 :sparkles: :thumbsup: :sparkles:
:star2: 1573 | @luishendrix92 |http://www.freecodecamp.com/luishendrix92
Rick Riggs
@wikiwiggs
May 21 2017 03:49
@andraemarcus I would try the add/remove methods instead of toggle, that may get it to work for you.
Andrae M
@andraemarcus
May 21 2017 03:50
@wikiwiggs, ok. I'm not sure what you mean by add/remove methods. Do you have an example? Also, did I write the HTML and CSS properly?
Rick Riggs
@wikiwiggs
May 21 2017 03:52
@andraemarcus give me a few minutes to transpose and modify your code...
@andraemarcus Try this:
$(document.ready(function() {
  $('.icon').click(function(){
    $('.icon').toggleClass('active', 'open');
  }
}
ArchivalBoat50
@ArchivalBoat50
May 21 2017 03:57
Hey guys, I'm having trouble here: I'm trying to have it return true if the first element of the array contains all the letters of the second element of the array, but I don't know where to start:
function mutation(arr) {
  return arr;
}

mutation(["hello", "hey"]);
Andrae M
@andraemarcus
May 21 2017 03:58
@wikiwiggs ok, let me make changes to the js real quick.
ArchivalBoat50
@ArchivalBoat50
May 21 2017 04:00
My code so far:
function mutation(arr) {
  if (arr.indexOf(0) == arr.indexOf(1)) {
    return true; 
  } else {
    return false;
  }



}

mutation(["hello", "hey"]);
Andrae M
@andraemarcus
May 21 2017 04:01
@wikiwiggs I tried modifying my code and having the same issue.
Rick Riggs
@wikiwiggs
May 21 2017 04:01
@ArchivalBoat50 strings have a includes() method, just test out each character in a loop via:
for (var i=0,i<arr[1].length;i++) {
  return arr[0].includes(arr[1][i]);
}
Andrae M
@andraemarcus
May 21 2017 04:01
Screen Shot 2017-05-20 at 9.01.48 PM.png
Screen Shot 2017-05-20 at 9.02.00 PM.png
Rick Riggs
@wikiwiggs
May 21 2017 04:02
@andraemarcus I suspect that your transform: translate(-50%, -50%) on your open class is causing the problem
ArchivalBoat50
@ArchivalBoat50
May 21 2017 04:04
@wikiwiggs thx but is there a way to pass with the way im doing it here:
function mutation(arr) {
  if (arr.indexOf(0) == arr.indexOf(1)) {
    return true; 
  } else {
    return false;
  }



}

mutation(["hello", "hey"]);
CamperBot
@camperbot
May 21 2017 04:04
archivalboat50 sends brownie points to @wikiwiggs :sparkles: :thumbsup: :sparkles:
:cookie: 303 | @wikiwiggs |http://www.freecodecamp.com/wikiwiggs
Rick Riggs
@wikiwiggs
May 21 2017 04:05
@ArchivalBoat50 Let me see if I can get close.
arrozconfrijoles
@arrozconfrijoles
May 21 2017 04:08
function mutation(arr) {
  var g = "";
  for (var x = 0; x < arr.length; x ++){
    g += arr[x] + " ";
  }
  g = g.substring(0, g.length - 1);

  g = g.toLowerCase();

  var k = [];
  k = g.split(" ");

  var identity = "";
  for (var z = 0; z < k[1].length; z++){
    var a = k[1][z];
    var count = 0;
    for (var aa = 0; aa < k[0].length; aa++){
      if (k[0][aa] == k[1][z] && count === 0){
        identity += k[1][z];
        count ++;
      }
    }
  }if (identity == k[1]) {
    return true;
  }else {
    return false;
  }
}
Andrae M
@andraemarcus
May 21 2017 04:08
@wikiwiggs you guessed right. Should I remove it?
arrozconfrijoles
@arrozconfrijoles
May 21 2017 04:09
I should have commented my code :l
If I remember correctly they are going to give you upper and lower case letters
so you have to pick upper or lower for the comparison
Rick Riggs
@wikiwiggs
May 21 2017 04:10
@andraemarcus What exactly did you do to confirm that my guess was correct?
@ArchivalBoat50 I'm not really finding a way that is close to your code to accomplish this.
The indexOf() method searches for the index number of an item in the array, you are passing a number, which returns a -1 in both cases, so it will always return true.
Andrae M
@andraemarcus
May 21 2017 04:20
@wikiwiggs for the .open class, I have the transform set to translate(-50%, -50%)
Rick Riggs
@wikiwiggs
May 21 2017 04:21
@andraemarcus I understand this, but I'm wondering how you confirmed that removing this fixed your problem?
Ty Tia
@TyTia77
May 21 2017 04:25
that is extremely hard to read @mouthfullofgoldteeth
lol
dinosaurjude
@dinosaurjude
May 21 2017 04:27
im trying to do the mutations algorithm and its not letting me arr.split(' '). it says that split is not a function? can someone help me
Rick Riggs
@wikiwiggs
May 21 2017 04:29

@ArchivalBoat50

function mutation(arr) {
  var newArr = arr[1].split('');
  var truth;
  newArr.forEach(function(x) {
    if (arr[0].includes(x) && truth != false) {
      truth = true; 
    } else {
      truth = false;
    }
  });
  return truth;
}
mutation(["hello", "he"]);
//returns true

versus

function mutation(arr) {
  var newArr = arr[1].split('');
  var truth;
  newArr.forEach(function(x) {
    if (arr[0].includes(x) && truth != false) {
      truth = true; 
    } else {
      truth = false;
    }
  });
  return truth;
}
mutation(["hello", "hey"]);
//returns false

This is about as close as I could get, and it is working

@andraemarcus I would actually try to change these to positive 50% values first.
Abhishek Tiwari
@fillopfy
May 21 2017 04:37
hello, in repeat a string basic algorithm callenge, I used a built in method str.repeat(num) . I sit wrong? should i make a similar function instead of using built in method
Andrae M
@andraemarcus
May 21 2017 04:39
@wikiwiggs I remove the transform: translate (-50%,-50%) and it didn't fix the problem. Sorry for the misunderstanding before.
@wikiwiggs maybe you can review the source code here: http://andraemarcus.co/wnm250/One%20Page/
Netrunner21
@Netrunner21
May 21 2017 04:42
I have a question about Arguments Optional
quanmap612
@quanmap612
May 21 2017 04:42
Can anyone help me with basic algorithm of Javascript?
Netrunner21
@Netrunner21
May 21 2017 04:43
is the challenge not clearly defined or am I just not getting something?
@quanmap612 I can, what challenge?
quanmap612
@quanmap612
May 21 2017 04:46
falsy bouncer
How can I turn something into boolean type?
Jor
@joreyesl
May 21 2017 04:48
@fillopfy if you just want to pass the challenge than using built-in is fine, but if you want to learn then you could try to implement the function yourself
Netrunner21
@Netrunner21
May 21 2017 04:50
@quanmap612 you're removing boolean values.
there's no need to turn something into a boolean
Abhishek Tiwari
@fillopfy
May 21 2017 04:51
@joreyesl hmm...got it
can anyone please explain me what I need to do in Truncate a string challenge. I am not understanding what it means
quanmap612
@quanmap612
May 21 2017 04:55
@Netrunner21 even though null, 0, "", undefined, and NaN. are boolean?
Michael Pimentel Jr
@mtpjr88
May 21 2017 04:56
I solved the algorythm and return the largest numbers in array but it will not pass
function largestOfFour(arr) {
  for (var i = 0; i < arr.length; i++){
   arr[i].sort(function(a, b) {
     return a - b;
   });
    return arr[i].pop();

}
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Netrunner21
@Netrunner21
May 21 2017 05:00
@quanmap612 Yeah. You're removing them. They are already boolean. They don't need to be turned into booleans.
Lanitta
@DivaWeb
May 21 2017 05:00
@mtpjr88 did you get the largest number from all four arrrays?
Michael Pimentel Jr
@mtpjr88
May 21 2017 05:00
yep
check it in code pen
Lanitta
@DivaWeb
May 21 2017 05:01
@mtpjr88 I just ran your code it only gave me 5
Abhishek Tiwari
@fillopfy
May 21 2017 05:02
@mtpjr88 use push to insert the largest number from each of the subarray(first sort out the elements of each subarrays) and then return that array
Michael Pimentel Jr
@mtpjr88
May 21 2017 05:03
@DivaWeb run it in code pen or node or js fiddle it will return all four
Abhishek Tiwari
@fillopfy
May 21 2017 05:04
@DivaWeb because it is popping out the largest element of first sub array only
Lanitta
@DivaWeb
May 21 2017 05:04
@mtpjr88 I have ran it in repl.it and google tools and still only get 5
Abhishek Tiwari
@fillopfy
May 21 2017 05:05
@DivaWeb use push to insert the largest number from each of the subarray(first sort out the elements of each subarrays) and then return that array
vik555
@vik555
May 21 2017 05:06

how can I improve this code ?
function truncateString(str, num) {

var len = str.length;

if (len>num && num>3){

var truncStr= str.slice (0, (num-3));

return (truncStr + "...");}

else if (len>num && num<3) {

  var newStr= str.slice (0,num);
return newStr + "...";
}

else {

return str;

}

}

Lanitta
@DivaWeb
May 21 2017 05:07
@mtpjr88 did you check to see if you have a typo
Michael Pimentel Jr
@mtpjr88
May 21 2017 05:07
@DivaWeb Ill check again
I'll
Lanitta
@DivaWeb
May 21 2017 05:09
@mtpjr88 check where your return is
Netrunner21
@Netrunner21
May 21 2017 05:11
Can anyone help me with Arguments Optional?
quanmap612
@quanmap612
May 21 2017 05:11
thank you @Netrunner21
CamperBot
@camperbot
May 21 2017 05:11
quanmap612 sends brownie points to @netrunner21 :sparkles: :thumbsup: :sparkles:
:cookie: 312 | @netrunner21 |http://www.freecodecamp.com/netrunner21
Lanitta
@DivaWeb
May 21 2017 05:12
@mtpjr88 did you figure it out?
Jor
@joreyesl
May 21 2017 05:13
@Netrunner21 whats up?
Netrunner21
@Netrunner21
May 21 2017 05:13
@quanmap612 np
@joreyesl I've been working on it for a while. The instructions seem unclear.
Jor
@joreyesl
May 21 2017 05:15
@Netrunner21 what do you need cleared up?
Netrunner21
@Netrunner21
May 21 2017 05:15
@joreyesl where there is a second argument in parenthesis after the first argument. When I test for it, it says type error.
I've got green check marks on the other three..
The instructions don't match the test cases
Rick Riggs
@wikiwiggs
May 21 2017 05:16

@andraemarcus
Replace

transform: translate(-50%,-50%);

WITH

line-height: normal;
Netrunner21
@Netrunner21
May 21 2017 05:16
It references addTogether(2) in the intructions, but the test cases are addTogether(2)(3) and addTogether(2)([3])
Jor
@joreyesl
May 21 2017 05:16
oh when there is a 2nd set of parenthesis they are calling the function that you should be returning from the first argument
Lanitta
@DivaWeb
May 21 2017 05:17
@Netrunner21 copy and past the test to see what error message you get for that one
Jor
@joreyesl
May 21 2017 05:17
if they only pass in 1 argument then you should be returning a function, the 2nd set of parenthesis then calls that function with that argument
Netrunner21
@Netrunner21
May 21 2017 05:17
TypeError: addTogether(...) is not a function
That's what happens when I use the test case
addTogether(2)(3);
If it's supposed to be written a different way, it shouldn't be written that way in the test case
sorry I'm salty, but I feel like they're being purposefully confusing with little learning value involved here.
haha
just my thoughts
I get what you two are saying, I've tried creating the second function and returning it, calling it later, or calling it inside the other functions. Just not getting it I guess.
Rick Riggs
@wikiwiggs
May 21 2017 05:23
@Netrunner21 I tend to agree, I think the idea that is truly behind this is worth learning, but... there is a lack of describing to the student why such things are useful.
@Netrunner21 are you using the arguments array to see how many arguments you have first?
Netrunner21
@Netrunner21
May 21 2017 05:26
@wikiwiggs If the point is "you'll have to learn on your own at some point" I get it. But this is supposed to be the hand holding stage (they've been phenominal so far, just not here). It's not that they're doing a bad job on this one describing javascript, it's they don't tell you at all how to pass the challenge, which is a useless lesson in my opnion
@wikiwiggs I did have an if statement to test whether there was only one argument using arguments.length == 1;
the issue is the error message I get when I throw in the test cases such as addTogether(2)(3);
it says I can't do that, and in the instructions it uses addTogether(2); but doesn't tell you how or where to call the function.
When they don't give you any instructions that's "lets see how you do without help", but I feel the instructions make things worse and provide unnecessary confusion. I'll stop being salty about it, haha. Just my 2 cents.
Rick Riggs
@wikiwiggs
May 21 2017 05:30
@Netrunner21 were you able to ultimately pass?
Netrunner21
@Netrunner21
May 21 2017 05:31
@wikiwiggs no. I have checks on the three test cases with two arguments. That was fairly simple.
I'm getting "TypeError: addTogether(...) is not a function" when I try to use the other two test cases
addTogether(2)(3); and addTogether(2)([3]);
Rick Riggs
@wikiwiggs
May 21 2017 05:32
@Netrunner21 let's hop into a private chat real quick.
Netrunner21
@Netrunner21
May 21 2017 05:32
sure
Caleb Grapes
@CalebGrapes
May 21 2017 05:38
Is it a problem to be able to do the code but not really understand how it works
feels like im just copying what looks right and not knowing whats going on at all
Jor
@joreyesl
May 21 2017 05:40
kinda, how do you know its correct unless you understand it
Caleb Grapes
@CalebGrapes
May 21 2017 05:40
just replacing the stuff on the tutorials basically
I've only been doing it a few weeks though
ur0sh
@ur0sh
May 21 2017 05:59
Good morning, quick question regarding while/for loops. Since the “for” loop is most widely used are the circumstances which prefer a “while" loop over “for?
Netrunner21
@Netrunner21
May 21 2017 06:03
@wikiwiggs Thanks again. That was a big help.
CamperBot
@camperbot
May 21 2017 06:03
netrunner21 sends brownie points to @wikiwiggs :sparkles: :thumbsup: :sparkles:
:cookie: 304 | @wikiwiggs |http://www.freecodecamp.com/wikiwiggs
Rick Riggs
@wikiwiggs
May 21 2017 06:03
@CalebGrapes - are you talking about doing a google search for a problem, finding a solution, copying it to the clipboard, and pasting it into the exercise, with slight massaging, and then running it?
Netrunner21
@Netrunner21
May 21 2017 06:04
@wikiwiggs Thanks again. That was a big help.
CamperBot
@camperbot
May 21 2017 06:04
netrunner21 sends brownie points to @wikiwiggs :sparkles: :thumbsup: :sparkles:
:warning: netrunner21 already gave wikiwiggs points
Rick Riggs
@wikiwiggs
May 21 2017 06:04
@Netrunner21 Glad to do it, you are very welcome
@ur0sh yes
@ur0sh if you have a defined set of something, a for loop is designed for this.
@ur0sh a while loop is slightly more flexible, but it can also be forced quite easily to act exactly like a for loop.
Mario A. Carlos
@MarioC3
May 21 2017 06:09
Hello Guys!
I'm trying to do the palindrome excercise
Idrees
@Idrees5
May 21 2017 06:09
Hi guys
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 06:09
@MarioC3 Hello!
Rick Riggs
@wikiwiggs
May 21 2017 06:09
@ur0sh a while loop operates on a true/false principle
Mario A. Carlos
@MarioC3
May 21 2017 06:09
But everything is returning false
:(
This is my code
Idrees
@Idrees5
May 21 2017 06:10
I'm doing "Stand in Line" and i'm trying hard to figure out what is going on
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 06:10
@MarioC3 We are waiting for it.
Mario A. Carlos
@MarioC3
May 21 2017 06:10
function palindrome(str) {
  // Good luck!
  var s = str;

  s = s.toLowerCase();
  s = s.replace(/\W/g, '').replace(/[0-9]/g, '');

  var arrayS = s.split('');
  var sReversed = arrayS.reverse();
  sReversed = sReversed.join('');

  console.log(s);
  console.log(sReversed);

  if (s == s.reversed) {
    console.log(true);
    return true;
  } else {
    console.log(false);
    return false;
  }
}


palindrome("eye");
Rick Riggs
@wikiwiggs
May 21 2017 06:10
@ur0sh so you can run a while loop while a condition is met/not met, and when it is, or you crash something you will exit the loop.
Mario A. Carlos
@MarioC3
May 21 2017 06:11
Any ideas?
Rick Riggs
@wikiwiggs
May 21 2017 06:12
@Idrees5 let's hop into a private message, so we can keep the code from spamming the room. sound alright?
Mihir Shanishchara
@MihirNS
May 21 2017 06:12
@MarioC3 s == sReversed
Idrees
@Idrees5
May 21 2017 06:13
ok sure
Mario A. Carlos
@MarioC3
May 21 2017 06:13
It still returning false :(
Mihir Shanishchara
@MihirNS
May 21 2017 06:13
@MarioC3 check your if condition its a typo
Mario A. Carlos
@MarioC3
May 21 2017 06:13
I changed it
but it's still returning false
even though 'eye' is a palindrome in fact
image.png
^ That is what the console outputs
Idrees
@Idrees5
May 21 2017 06:15
@wikiwiggs is there a way to pm u on in this? or are we looking at 3rd party
Mihir Shanishchara
@MihirNS
May 21 2017 06:16

function palindrome(str) {
// Good luck!
var s = str;

s = s.toLowerCase();
s = s.replace(/\W/g, '').replace(/[0-9]/g, '');

var arrayS = s.split('');
var sReversed = arrayS.reverse();
sReversed = sReversed.join('');

console.log(s);
console.log(sReversed);

if (s == s.reversed) {
console.log(true);
return true;
} else {
console.log(false);
return false;
}
}

palindrome("eye");
VM1284:12 eye
VM1284:13 eye
VM1284:16 true
true

Markus Ivancsics
@ivancsicsmarkus
May 21 2017 06:16
Képernyőfotó 2017-05-21 - 8.16.17.png
Coy Sanders
@coymeetsworld
May 21 2017 06:16
@MarioC3 using \W won't work, because that's shorthand for [^A-Za-z0-9_], you don't want to ignore underscores, as per the instructions
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 06:16
Reload the page!!
Also, you need to remove the underlines with regexp too!
Mario A. Carlos
@MarioC3
May 21 2017 06:18
@ivancsicsmarkus
Why is my console outputting false?
Coy Sanders
@coymeetsworld
May 21 2017 06:19
also you don't want to replace numbers either, replace(/[0-9]/g, ''); this is not needed
Mario A. Carlos
@MarioC3
May 21 2017 06:19
image.png
Ok. Let's tackle one problem at a time...
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 06:20
@MarioC3 You still did not change it to sReversed...
Mario A. Carlos
@MarioC3
May 21 2017 06:20
why is my console and the test results in FCC outputing false though?
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 06:20
In the if statement.
Coy Sanders
@coymeetsworld
May 21 2017 06:20
your regex needs to be fixed
@MarioC3
Mario A. Carlos
@MarioC3
May 21 2017 06:21
Ah I see....
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 06:21
@MarioC3 Man
if (s == sReversed){
Mario A. Carlos
@MarioC3
May 21 2017 06:21
Cool... I did not catch that dot there..
Now....
Let's tackle RegExp
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 06:21
@MarioC3 Now, in Regex you should kill the underlines too.
Alex
@alextran1502
May 21 2017 06:21

Hello, can anyone see what is wrong with my code?
// Setup
function phoneticLookup(val) {
var result = "";
val = {
"alpha":"Adams",
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank",
"":undefined
};
return result;
}

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

Markus Ivancsics
@ivancsicsmarkus
May 21 2017 06:22
@MarioC3 Remove all the numbers and underlines.
Coy Sanders
@coymeetsworld
May 21 2017 06:22
you don't want to set val to the object @alextran1502
val is the key you want to use on the object to return the appropriate value so you don't want to overwrite that
Mario A. Carlos
@MarioC3
May 21 2017 06:22
What's the RegExp for underlines?
s = s.replace(/\W/g, '').replace(/[0-9]/g, '');
Coy Sanders
@coymeetsworld
May 21 2017 06:23
@MarioC3 its not just underlines
any non-alphanumeric character must be removed
Mario A. Carlos
@MarioC3
May 21 2017 06:23
That will take care of all non-alphanumeric numbers and any numbers correct?
Coy Sanders
@coymeetsworld
May 21 2017 06:23
\W excludes underlines so that won't work
no, because as I wrote above \W keeps underline values
Alex
@alextran1502
May 21 2017 06:24
@coymeetsworld thanks Coy, what is the next hint you suggest to make this syntax works?
CamperBot
@camperbot
May 21 2017 06:24
alextran1502 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2601 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 21 2017 06:24
you need to use something different and again the second replace is wrong and not needed
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 06:24
Képernyőfotó 2017-05-21 - 8.24.15.png
This message was deleted
Coy Sanders
@coymeetsworld
May 21 2017 06:24
@ivancsicsmarkus thats not right, and please don't provide answers
@alextran1502 instructions say to make a variable named lookup that is assigned to the object
then you use val to "lookup" the value in lookup, using the bracket notation syntax you learned in prev lessions
Mario A. Carlos
@MarioC3
May 21 2017 06:25
@coymeetsworld whoa... why not?
He's making a good job helping me
Alex
@alextran1502
May 21 2017 06:26
@coymeetsworld Thankx!
CamperBot
@camperbot
May 21 2017 06:26
alextran1502 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: alextran1502 already gave coymeetsworld points
Coy Sanders
@coymeetsworld
May 21 2017 06:27
alright then @MarioC3, ill let you guys work on it then. But he's not supposed to be giving you answers. We can give out hints and point out problems but the idea is you work on the code and provide your own solutions
you don't learn as much rotely copying answers than figuring it out
Mario A. Carlos
@MarioC3
May 21 2017 06:27
Oh gotcha....
I'm still trying to understand regExp.
Coy Sanders
@coymeetsworld
May 21 2017 06:28
http://regexr.com/ is a good place to test
Mario A. Carlos
@MarioC3
May 21 2017 06:28
So @coymeetsworld, we can pass numbers then?
Qulu Mammadli
@qulu1
May 21 2017 06:28
hey Guys! What call function does in JS? i searched everywhere, still cant get
Mario A. Carlos
@MarioC3
May 21 2017 06:28
In this specific excercise right?
Coy Sanders
@coymeetsworld
May 21 2017 06:28
https://www.youtube.com/watch?v=EkluES9Rvak&t=1s this was also a helpful video, if you have time
Coy Sanders
@coymeetsworld
May 21 2017 06:29
regex is pretty important, it would be good to at least learn the basics. Alot of the more adv javascript challenges require more regex
Mario A. Carlos
@MarioC3
May 21 2017 06:29
HUZZZAAAHHHH!!!! MADE IT!
function palindrome(str) {
  // Good luck!
  var s = str;

  s = s.toLowerCase();
  s = s.replace(/\W/g, '').replace(/_/g, '');

  var arrayS = s.split('');
  var sReversed = arrayS.reverse();
  sReversed = sReversed.join('');

  console.log(s);
  console.log(sReversed);

  if (s == sReversed) {
    console.log(true);
    return true;
  } else {
    console.log(false);
    return false;
  }
}


palindrome("eye");
Coy Sanders
@coymeetsworld
May 21 2017 06:29
@MarioC3 you want to remove anything that is not alphanumeric in the string. Alphanumeric is letters and numbers
yeah that'll work
you can reduce that code quite a bit though
Mario A. Carlos
@MarioC3
May 21 2017 06:30
Yeah I figured as much...
Coy Sanders
@coymeetsworld
May 21 2017 06:30
for example instead of that if/else statement you can just return the result of s == sReversed
Qulu Mammadli
@qulu1
May 21 2017 06:30
@MihirNS mate, i already checked that resource too, cant understand the point of it. What is the difference with normally calling an array or whatever argument?
Mario A. Carlos
@MarioC3
May 21 2017 06:30
but hey for 2 weeks of coding... this feels like an amazing accomplishment...
Coy Sanders
@coymeetsworld
May 21 2017 06:30
since that itself will return a true/false value
right of course
Mario A. Carlos
@MarioC3
May 21 2017 06:31
right...
Coy Sanders
@coymeetsworld
May 21 2017 06:31
just saying, I did these challenges a year ago and I go back once in a while and try to make a better solution
my answer now only uses 2 lines
Mario A. Carlos
@MarioC3
May 21 2017 06:31
I'm saving all of these problems, so I can come and refactor once I get more experience in it
Coy Sanders
@coymeetsworld
May 21 2017 06:31
i think i mightve had 10 or so last time
@MarioC3 they're saved for you already, go to freecodecamp.com/yourusername
Mario A. Carlos
@MarioC3
May 21 2017 06:32
I know...
so 2 lines of code?
wow impressive
Coy Sanders
@coymeetsworld
May 21 2017 06:32
could make it one but it would look ugly
Mario A. Carlos
@MarioC3
May 21 2017 06:32
Thanks @coymeetsworld
CamperBot
@camperbot
May 21 2017 06:32
marioc3 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2602 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 21 2017 06:32
np @MarioC3 nice job figuring it out
Mario A. Carlos
@MarioC3
May 21 2017 06:33
and thanks @ivancsicsmarkus
Mihir Shanishchara
@MihirNS
May 21 2017 06:33
@qulu1 what do you mean? can you give any example you can't understand?
Rick Riggs
@wikiwiggs
May 21 2017 06:37

@Idrees5

@wikiwiggs is there a way to pm u on in this? or are we looking at 3rd party
For future reference: Sorry, I missed this, you can just click on a user's image, and then click the green chat privately button.

Idrees
@Idrees5
May 21 2017 06:39
^^ no worries thanks!
Rick Riggs
@wikiwiggs
May 21 2017 06:41
@Idrees5 :+1:
Joseph
@revisualize
May 21 2017 06:46
Hello.
Mukul Agrawal
@mukul09
May 21 2017 06:48
@revisualize hello
priyanka bhalla
@priyanka-bhalla
May 21 2017 06:49

var Car = function() {
//Change this constructor
this.wheels = 4;
this.seats = 5;
this.engines = 1;
};

//Try it out here
var myCar= new Car(4,4,2);

Calling new Car(3,1,2) should produce an object with a wheels property of 3, a seats property of 1, and an engines property of 2.
Calling new Car(4,4,2) should produce an object with a wheels property of 4, a seats property of 4, and an engines property of 2.
Calling new Car(2,6,3) should produce an object with a wheels property of 2, a seats property of 6, and an engines property of 3.
whats wrong with this
lagasi
@lagasi
May 21 2017 06:50
@priyanka-bhalla You have the change the constructor so that it can pass in three arguments: wheels, seats, and engines. Right now, they are always 4, 5, 1.
Mukul Agrawal
@mukul09
May 21 2017 06:51
@priyanka-bhalla you have to receive argument in the function like
var car=function(wheels,seats,engines) and then assign it to this.wheels , this.seats,this.engines
Rick Riggs
@wikiwiggs
May 21 2017 06:53
@mukul09 :+1:
priyanka bhalla
@priyanka-bhalla
May 21 2017 06:55
thanks dear
still not working
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 07:00
@priyanka-bhalla You have to assign it...
Mukul Agrawal
@mukul09
May 21 2017 07:01
@priyanka-bhalla can you share your latest code
priyanka bhalla
@priyanka-bhalla
May 21 2017 07:01

var Car = function(wheels,seats,engines ) {
//Change this constructor
this.wheels = 4;
this.seats = 5;
this.engines = 1;
};

//Try it out here
var myCar= new Car(4,4,2);

Coy Sanders
@coymeetsworld
May 21 2017 07:02
you want to remove 4 5 and 1 and replace it with the parameters you're passing in @priyanka-bhalla
i.e. wheels, seats, engines. If you don't do that then every car you build will always have 4 wheels 5 seats and 1 engine regardless of what you're passing into the constructor
Mukul Agrawal
@mukul09
May 21 2017 07:02
@priyanka-bhalla in the function you have to assign the parameters like
this.wheel=wheels; and so on
Arunika Yadav
@arunikayadav42
May 21 2017 07:03
hey can anyone please help me out with this card counting game?
in javascript?
Ashcon313
@Ashcon313
May 21 2017 07:03
Having trouble with Accessing Objects Properties with Variables
```
Arunika Yadav
@arunikayadav42
May 21 2017 07:04
i have written the code
priyanka bhalla
@priyanka-bhalla
May 21 2017 07:04
thanks dear
Ashcon313
@Ashcon313
May 21 2017 07:04
ar testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;       // Change this Line
var player = "Montana";

var testObj = {
  playerNumber: ""
};
Arunika Yadav
@arunikayadav42
May 21 2017 07:04
and the output is correct too
Ashcon313
@Ashcon313
May 21 2017 07:04
how do I use bracket notation to access testObj
Arunika Yadav
@arunikayadav42
May 21 2017 07:05
but the red crosses aren't turning red
Coy Sanders
@coymeetsworld
May 21 2017 07:07
@Ashcon313 I would revisit the Accessing Objects Properties with Bracket Notation challenge
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 07:07
@Ashcon313
testObj.playerNumber === testObj["playerNumber"]
Coy Sanders
@coymeetsworld
May 21 2017 07:07
but essentially it would look like testObj[number]
Mukul Agrawal
@mukul09
May 21 2017 07:07
@arunikayadav42 share your code
Arunika Yadav
@arunikayadav42
May 21 2017 07:07
ok
Coy Sanders
@coymeetsworld
May 21 2017 07:07
@ivancsicsmarkus jeez man, why do you keep doing this?
that answer is WRONG again, stop posting WRONG answers
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 07:07
@coymeetsworld Did I give him the answer?
@coymeetsworld :D
@coymeetsworld Nope.
Coy Sanders
@coymeetsworld
May 21 2017 07:08
you tried to
but you keep failing at it
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 07:08
@coymeetsworld I know the answer.
@coymeetsworld What I wrote is correct. He can find out how to do that from mine.
Coy Sanders
@coymeetsworld
May 21 2017 07:08
well then idk why you posted that code above, that makes no sense
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 07:08
@coymeetsworld You gave him the answer, I just helped...
Coy Sanders
@coymeetsworld
May 21 2017 07:08
playerNumber is a variable
Ashcon313
@Ashcon313
May 21 2017 07:08

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

// Only change code below this line;

var playerNumber = 16; // Change this Line
var player = "Montana";

var testObj = {
playerNumber: ""
};

testObj.[16];
// Change this Line

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

// Only change code below this line;

var playerNumber = 16;       // Change this Line
var player = "Montana";

var testObj = {
  playerNumber: ""
};

testObj.[16];
  // Change this Line
It didn't work
Coy Sanders
@coymeetsworld
May 21 2017 07:09
I did not give any answer, I showed him syntax.
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 07:09
@Ashcon313 Now you are mixing dot and bracket notation.
Coy Sanders
@coymeetsworld
May 21 2017 07:09
@Ashcon313 remove the second declaration for testObj, thats not needed
and you don't want to pass in 16, you want to pass the variable you created holding 16
Ashcon313
@Ashcon313
May 21 2017 07:10
How do I use player number in the bracket
Coy Sanders
@coymeetsworld
May 21 2017 07:10
@Ashcon313 look what I wrote above, and if that doesn't make sense go back to Accessing Objects Properties with Bracket Notation challenge as that was covered earlier
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 07:11
@Ashcon313 You can prass variables into the bracket notation.
@Ashcon313 Your variable now is playerNumber.
Ashcon313
@Ashcon313
May 21 2017 07:11
thank you
Arunika Yadav
@arunikayadav42
May 21 2017 07:12

@mukul09 var count = 0;

function cc(card) {
// Only change code below this line
if(card===2 || card===3 || card===4 || card===5 || card===6)
count++;
else if(card===7 || card===8 || card===9)
count=count;
else
count--;
if(count>0)
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);

here is the code
Ashcon313
@Ashcon313
May 21 2017 07:13
thank you @coymeetsworld
CamperBot
@camperbot
May 21 2017 07:13
ashcon313 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2606 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 21 2017 07:13
np @Ashcon313, did you figure it out?
@arunikayadav42 you don't need those slashes in your return statement
Arunika Yadav
@arunikayadav42
May 21 2017 07:13
but
the output demands
the quotation marks
Coy Sanders
@coymeetsworld
May 21 2017 07:14
no that's not right
should just be 5 bet or 0 hold or something like that
Arunika Yadav
@arunikayadav42
May 21 2017 07:14
Example Output
"-3 Hold"
"5 Bet"
Mukul Agrawal
@mukul09
May 21 2017 07:14
@arunikayadav42 just return it like this return count+" Bet";
Arunika Yadav
@arunikayadav42
May 21 2017 07:14
this is the sample output
let me try
Coy Sanders
@coymeetsworld
May 21 2017 07:14
well ok that just means you're returning a string
Md Abu Zafar
@mdaz78
May 21 2017 07:15

function findLongestWord(str) {
  var strArr = str.split(' ');
  var i = 0;
  var j = strArr.length - 1;
  var max = '';

  while (i <= j) {
    if (strArr[i].length > strArr[j].length) {
      max = strArr[i];
      j--;
    } else if (strArr[i].length < strArr[j].length) {
      max = strArr[j];
      i++;
    } else {
      i++;
      j++;
    }
  }

  return max;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
It shows a TypeError on line number 9
Can anyone please help.
Coy Sanders
@coymeetsworld
May 21 2017 07:15
you don't need additional quotes inside the string
Arunika Yadav
@arunikayadav42
May 21 2017 07:15
oh I see
nice
that works
thanks a lot
Coy Sanders
@coymeetsworld
May 21 2017 07:16
np
Md Abu Zafar
@mdaz78
May 21 2017 07:16
@coymeetsworld any help?
Coy Sanders
@coymeetsworld
May 21 2017 07:16
my guess @mdaz78 is some error in your logic
shouldn't need two variables like that
just iterate through your array with a for loop, check each word and if its length is greater than max's length, then set max to that word
you're most likely getting an array out of bounds error when you increment j past the size of the array
priyanka bhalla
@priyanka-bhalla
May 21 2017 07:18

var Car = function() {
// this is a private variable
var speed = 10;
var gear = 2;
// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

var Bike = function() {

// Only change code below this line.
this.getGear = function(){
return gear;
};
this.setGear= function(){
return gear;
};
};

var myCar = new Car();

var myBike = new Bike();
myBike.getGear(4);

Coy Sanders
@coymeetsworld
May 21 2017 07:18
@priyanka-bhalla you need to declare a gear variable for Bike, similar to how you did for Car
also setGear for Bike doesn't just return gear like getGear does, it needs to modify the gear variable
priyanka bhalla
@priyanka-bhalla
May 21 2017 07:21

var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

var Bike = function() {
var gear;
// Only change code below this line.
this.getGear = function(){
return gear;
};
this.setGear= function(){
return gear;
};
};

var myCar = new Car();

var myBike = new Bike(myBike.getGear(4));

Coy Sanders
@coymeetsworld
May 21 2017 07:21
your setGear still needs work
it needs to take a variable in like the accelerate function does for Car. and use that to set the bike's gear
priyanka bhalla
@priyanka-bhalla
May 21 2017 07:22
@coymeetsworld please explain how
Coy Sanders
@coymeetsworld
May 21 2017 07:22
This message was deleted
@priyanka-bhalla look what you did for accelerate for Car
it takes in a variable named change and that's what you increment to the speed
setGear is going to look similar to accelerate
where it takes a value parameter and uses it to modify the speed/gear
still having issues
Coy Sanders
@coymeetsworld
May 21 2017 07:27
you don't modify gear like that in setGear
Ivo Tsolov
@ivoTsolov
May 21 2017 07:28
guys
Coy Sanders
@coymeetsworld
May 21 2017 07:28
look at the examples
Ivo Tsolov
@ivoTsolov
May 21 2017 07:28
can someone help me
with my javascript
Coy Sanders
@coymeetsworld
May 21 2017 07:28
or rather tests
Ivo Tsolov
@ivoTsolov
May 21 2017 07:28
i am stuck
Coy Sanders
@coymeetsworld
May 21 2017 07:28
when you call setGear(4), the gear is 4. If you call setGear(6) afterwards, gear will be 6. Not 10 @priyanka-bhalla
Nick Forlivio
@whackdev
May 21 2017 07:28
Can anyone point me in the right direction to get the url to the article for my wikipedia viewer?
I can only get the titles
priyanka bhalla
@priyanka-bhalla
May 21 2017 07:29
thanks
done
Coy Sanders
@coymeetsworld
May 21 2017 07:29
np
hope it made sense
priyanka bhalla
@priyanka-bhalla
May 21 2017 07:30
yes thanks for help
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 07:34
@whackdev Well done! This is great!
tahashin
@tahashinegp
May 21 2017 07:35

Manipulating Complex Objects
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
];
// Add record here

myMusic[1]=[
{
"artist":"tahahsin",
"title":"Behalka",
"release_year":2001,
"formats":[
"CS",
"8T"
]

}
];

why its not working? can anyone help me?
?
Mukul Agrawal
@mukul09
May 21 2017 07:41
@tahashinegp just add that new album in myMusic array
@tahashinegp you do not have to write like myMusic[1]{}
tahashin
@tahashinegp
May 21 2017 07:47
okok
priyanka bhalla
@priyanka-bhalla
May 21 2017 07:49

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

// Only change code below this line.
var timesThree = oldArray.map(function(val){
return val+3;
});
var newArray = oldArray;
console.log(timesThree);

whats wrong with this
Ty Tia
@TyTia77
May 21 2017 07:50
what are you trying to do
the name says times 3
but you are adding 3
priyanka bhalla
@priyanka-bhalla
May 21 2017 07:50
@tahashinegp there is no need to write myMusic[1]

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

// Only change code below this line.
var addThree = oldArray.map(function(val){
return val+3;
});
var newArray = oldArray;
console.log(addThree);

Coy Sanders
@coymeetsworld
May 21 2017 07:51
@priyanka-bhalla you're adding 3
priyanka bhalla
@priyanka-bhalla
May 21 2017 07:52
now
Harut
@harut-g
May 21 2017 07:53
What will be output of this code?
var a = new Array(1,2), b = new Array(3);
alert(a[0] + b[0]);
priyanka bhalla
@priyanka-bhalla
May 21 2017 07:54
@coymeetsworld m adding 3
but its not working
Coy Sanders
@coymeetsworld
May 21 2017 07:54
my guess is you're not assigning newArray correctly
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 07:55
@harut-g NaN.
Harut
@harut-g
May 21 2017 07:55
@ivancsicsmarkus why?
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 07:56
Because you are using the array constructor.
src
Képernyőfotó 2017-05-21 - 9.55.59.png
Harut
@harut-g
May 21 2017 07:57
@ivancsicsmarkus good, thanks
CamperBot
@camperbot
May 21 2017 07:57
harut-g sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:cookie: 503 | @ivancsicsmarkus |http://www.freecodecamp.com/ivancsicsmarkus
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 07:57

@harut-g So with

b = new Array(3);

you are using the

new Array(arrayLength)

„syntax“
Then:

console.log(b) // => [undefined,undefined,undefined]
Harut
@harut-g
May 21 2017 07:57
@ivancsicsmarkus :+1:
priyanka bhalla
@priyanka-bhalla
May 21 2017 07:59

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

// Only change code below this line.
var addThree = oldArray.map(function(val){
return val+3;
});
var newArray = oldArray.addThree;

Paweł Karniej
@Karniej
May 21 2017 08:00
Hello anybody knows why after transpiling this es6 function:
"function removeTransition(e) {
if (e.propertyName !== 'transform') return; //skip if it's not a transform
this.classList.remove('playing');
}" through babel and webpack
doesn't work?
Coy Sanders
@coymeetsworld
May 21 2017 08:01
@priyanka-bhalla no, the map function returns another array and you're setting that to addThree
there is no oldArray.addThree value
Paweł Karniej
@Karniej
May 21 2017 08:03
Anyone there could help me with setting up webpack and babel ?
Madhusoodhan
@Madhusoodhan
May 21 2017 08:09

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

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

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

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

how to use objects here
Harut
@harut-g
May 21 2017 08:12
What will be output of this code ?
var obj = {
 "0": 1,
 0: 2
};

alert( obj["0"] + obj[0] );
Markus Kiili
@Masd925
May 21 2017 08:13
@harut-g Those key:value pairs use the same key, so the second one overwrites the first.
youUnion619
@youUnion619
May 21 2017 08:13
hi guys, how can i set a value in my constructor
Madhusoodhan
@Madhusoodhan
May 21 2017 08:13
@youUnion619 lookup copy constructor
Markus Kiili
@Masd925
May 21 2017 08:14
@youUnion619 What value?
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 08:14
@harut-g 4
Harut
@harut-g
May 21 2017 08:15
@Masd925 Thanks I understood!
CamperBot
@camperbot
May 21 2017 08:15
harut-g sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4106 | @masd925 |http://www.freecodecamp.com/masd925
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 08:15
@harut-g The second overwrites the first, because obj["0"] will be converted to integer 0.
Harut
@harut-g
May 21 2017 08:15
@ivancsicsmarkus thanks
CamperBot
@camperbot
May 21 2017 08:15
harut-g sends brownie points to @ivancsicsmarkus :sparkles: :thumbsup: :sparkles:
:warning: harut-g already gave ivancsicsmarkus points
youUnion619
@youUnion619
May 21 2017 08:16
the gear value
Markus Kiili
@Masd925
May 21 2017 08:16
@ivancsicsmarkus No, the key "0" is used there. On the literal, 0 and "0" both mean key "0".
Madhusoodhan
@Madhusoodhan
May 21 2017 08:16
could someone help me
Harut
@harut-g
May 21 2017 08:17
@Masd925 second just overwrites the first
Markus Kiili
@Masd925
May 21 2017 08:17
@harut-g Yes.
youUnion619
@youUnion619
May 21 2017 08:17
this.getGear = function(){
Harut
@harut-g
May 21 2017 08:18
And output of this code what will be ?
for(var i=0; i<10; i++) {
  setTimeout(function() {
    alert(i);
  }, 100);
}
Markus Kiili
@Masd925
May 21 2017 08:18
@harut-g All print 10?
Harut
@harut-g
May 21 2017 08:19
@Masd925 Yes :clap:
Omargrigsby
@Omargrigsby
May 21 2017 08:22
hey how do i input the remainder of 2 with the % operator?
Harut
@harut-g
May 21 2017 08:22
@liyana08 You just need to use push and shift functions
Omargrigsby
@Omargrigsby
May 21 2017 08:22
var remainder = 2;
Madhusoodhan
@Madhusoodhan
May 21 2017 08:22
@Omargrigsby what is your dividend?
Omargrigsby
@Omargrigsby
May 21 2017 08:23
11/3
gives me a rem of 2
Markus Ivancsics
@ivancsicsmarkus
May 21 2017 08:23
@Omargrigsby Yes.
Madhusoodhan
@Madhusoodhan
May 21 2017 08:23
@Omargrigsby just use var remainder = 11%3;
youUnion619
@youUnion619
May 21 2017 08:24
this.setGear = function(){
;

};

this.getGear = function(){
return gear;
};
i have a problem with the set method any help?

Omargrigsby
@Omargrigsby
May 21 2017 08:24
@Madhusoodhan ok thx
CamperBot
@camperbot
May 21 2017 08:24
omargrigsby sends brownie points to @madhusoodhan :sparkles: :thumbsup: :sparkles:
:warning: @madhusoodhan's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Madhusoodhan
@Madhusoodhan
May 21 2017 08:25
@youUnion619 i think you should try function(){ this.setGear = gear; }
Mark
@markwuu
May 21 2017 08:26
Hi guys so Im on the palindrome problem on freecodecamp. All the actual palindromes return true but none of the false ones return false. I looked up the answer so i know how to approach the problem in a different way. I was just now curious to why my code doesnt work correctly.
function palindrome(str) {
if
(str.replace(/[\W]/g, "").toLowerCase().split("").reverse().join("") === str.replace(/[\W]/g, "").toLowerCase().split("").reverse().join(""))
return true;
else
return false;
}
youUnion619
@youUnion619
May 21 2017 08:27
@Madhusoodhan didn't work
Harut
@harut-g
May 21 2017 08:29
What is the output of this code should be ?
alert( 20e-1['toString'](2) );
Dan Couper
@DanCouper
May 21 2017 08:29
@youUnion619 What is your full code? It's impossible to tell what your doing wrong without seeing what your doing wrong
Harut
@harut-g
May 21 2017 08:29
2
10
20
NaN
youUnion619
@youUnion619
May 21 2017 08:30
@DanCouper

var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

var Bike = function() {

var gear;

this.setGear = function(){

this.setGear = gear;
};

this.getGear = function(){
return gear;
};

};

var myCar = new Car();

var myBike = new Bike();

Markus Ivancsics
@ivancsicsmarkus
May 21 2017 08:31

@harut-g

20e-1 // => 2

So, tostring with a radix of 2 will give 10.

Dan Couper
@DanCouper
May 21 2017 08:31
@youUnion619 When you set a gear, you need to actually give it a value. It doesn't know what geear you want to set at the minute.
getGear -> gets the current value of gear
May Kittens Devour Your Soul
@diomed
May 21 2017 08:33
yeah. are u in 2n gear or 6th gear?
or are u going in reverse?
Dan Couper
@DanCouper
May 21 2017 08:33
setGear -> set a value for gear
Pieter Stokkink
@forkerino
May 21 2017 08:33
@markwuu
You are comparing two things that are exactly the same. You should only reverse one of them.
youUnion619
@youUnion619
May 21 2017 08:33
yes so i should create a new value? inside the set method? and assign it to the gear values?
@DanCouper
Mark
@markwuu
May 21 2017 08:35

@forkerino
Sorry this is what I actually meant to send..

function palindrome(str) {
if
(str.replace(/[\W]/g, "").toLowerCase().split("").reverse().join("") === str.replace(/[\W]/g, "").toLowerCase())
return true;
else
return false;
}

palindrome("eye");

Dan Couper
@DanCouper
May 21 2017 08:35
It is just a function, so it has to take an argument. See the accelerate function a in the example. And you are setting the gear with the setGear function, so you should set the gear value
Seby B Joseph
@sebybjoseph
May 21 2017 08:37

$(document).ready(function(){

$("#quoteButton").on("click",function(){

    $.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1", function(json){
        $("#quote").html(JSON.stringify(json)); 
    });


});

});

Hello All, Can someone tell me what's wrong with the code?
Pieter Stokkink
@forkerino
May 21 2017 08:38
@markwuu well, yes, that code works.
@sebybjoseph any errors in your developer console?
Seby B Joseph
@sebybjoseph
May 21 2017 08:41
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. @forkerino
Mark
@markwuu
May 21 2017 08:42
@forkerino it works well with the actual palindromes, but the false ones do not return false
Pieter Stokkink
@forkerino
May 21 2017 08:43
@sebybjoseph well, there you go. Seems like your have a CORS issue. Try using https in your url.
Markus Kiili
@Masd925
May 21 2017 08:43
@markwuu Are you removing underscore?
Pieter Stokkink
@forkerino
May 21 2017 08:43
@markwuu this code passes the tests when I paste it in.
Seby B Joseph
@sebybjoseph
May 21 2017 08:44
Will do that @forkerino Thanks
CamperBot
@camperbot
May 21 2017 08:44
sebybjoseph sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2320 | @forkerino |http://www.freecodecamp.com/forkerino
Seby B Joseph
@sebybjoseph
May 21 2017 08:44
@Masd925 Where?
Markus Kiili
@Masd925
May 21 2017 08:44
@sebybjoseph Sorry, tagged the wrong person.
Pieter Stokkink
@forkerino
May 21 2017 08:45
@sebybjoseph it might not solve everything, I didn't work with this API, so you might have to use a proxy like https://cors-anywhere.herokuapp.com/
Kelechi Chinaka
@ke1echi
May 21 2017 08:48
got ideas how i can push key: value to an array @forkerino @coymeetsworld
myCollection.push(key);  //pushing key
 myCollection.push(obj[key]); //pushing values
@forkerino @coymeetsworld
priyanka bhalla
@priyanka-bhalla
May 21 2017 08:50

function reverseString(str) {
return str;
}

reverseString("hello");

Pieter Stokkink
@forkerino
May 21 2017 08:51
@kelechichinaka can you give an example of how you want the output to look like
?
priyanka bhalla
@priyanka-bhalla
May 21 2017 08:51
reverseString("hello") should become "olleh".
reverseString("Howdy") should become "ydwoH".
reverseString("Greetings from Earth") should return "htraE morf sgniteerG".
Pieter Stokkink
@forkerino
May 21 2017 08:51
@priyanka-bhalla hint: you can only reverse arrays directly.
Kelechi Chinaka
@ke1echi
May 21 2017 08:53
giveMeFive({Pears:"than",apple:"sweet"}),["Pears","apple","sweet"])
@forkerino
Pieter Stokkink
@forkerino
May 21 2017 08:54
@kelechichinaka are you meant to skip the "than"? Or is that a typo? Otherwise the code you have above looks ok.
i think the description is not too clear @forkerino
priyanka bhalla
@priyanka-bhalla
May 21 2017 08:57
still not working
Pieter Stokkink
@forkerino
May 21 2017 08:57
@kelechichinaka looks like you only need to push them if their length is 5, so a simple if around each of those pushes to check the length would probably work.
priyanka bhalla
@priyanka-bhalla
May 21 2017 08:57

var reverseString=["hello"];

reverseString.reverse();
console.log(reverseString);

Pieter Stokkink
@forkerino
May 21 2017 08:58
@priyanka-bhalla another hint: you have to split the word into an array of letters
Kelechi Chinaka
@ke1echi
May 21 2017 08:59
oh, i got it..the grammar is not that clear @forkerino
looked to me like it needed the key : value = 5 ..thanks @forkerino
CamperBot
@camperbot
May 21 2017 09:00
kelechichinaka sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2321 | @forkerino |http://www.freecodecamp.com/forkerino
curiousNoob
@curiousNoob
May 21 2017 09:02
hi everyone
has anyone ever checked vanilla JS source code of TodoMVC
?
I have a few questions
Jason Luboff
@JLuboff
May 21 2017 09:21
@forkerino nice weather so far :+1:
Qulu Mammadli
@qulu1
May 21 2017 09:22
hey guys. Anyone did "Caesars Cipher" algorithm task, can give me a hint? Pls not the actual answer, but hint, have no idea where to begin to search
Jason Luboff
@JLuboff
May 21 2017 09:23
Best to use .charCodeAt and .fromCharCode to switch between letter and letter number. You want to stay between 65-90 (character numbers for A-Z)
Qulu Mammadli
@qulu1
May 21 2017 09:26
@JLuboff okay, thank you
CamperBot
@camperbot
May 21 2017 09:26
qulu1 sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1819 | @jluboff |http://www.freecodecamp.com/jluboff
mithun
@dmithun
May 21 2017 09:31

// Setup
function abTest(a, b) {
// Only change code below this line
// Only change code above this line
a=a<0;
b=b<0;
return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

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

help me!!!!!
Jason Luboff
@JLuboff
May 21 2017 09:32
You need an if statement, a and b are already defined
Pieter Stokkink
@forkerino
May 21 2017 09:34
@JLuboff yeah, it's good. What are the plans for today?
Jason Luboff
@JLuboff
May 21 2017 09:40
@forkerino not sure. Still waiting on my dad to wake up lol. I've been up for a bit over an hour and my wife got up a little after me. The first thing will be breakfast...maybe at the pancake bakery?
harshdalal442
@harshdalal442
May 21 2017 09:42
Hi, i am in reverse a string challenge.
Can anyone help me
function reverseString(str) {
var a = [];
var reverse = [];
a = str.split(" ");
//console.log(a);
var ans = "";
for(var i = 0;i<a.length;i++) { for(var j=a[i].length-1;j>=0;j--)
{
ans+=a[i][j];
}
ans+=" ";
}
return ans;
}
Anshul Adlakha
@anshuladlakha
May 21 2017 09:42
Can anyone tell me why my Tweet out button is not working?
https://codepen.io/anshuladlakha/pen/LyXWpJ
Pieter Stokkink
@forkerino
May 21 2017 09:43
@JLuboff sounds like fun. Dutch pancakes are usually a lot thinner than the North American ones. But they put stuff in it (your choice, of course).
Jason Luboff
@JLuboff
May 21 2017 09:43
@harshdalal442 just wondering...want not use the built it reverse() method?
@forkerino similar to a crepe then?
Pieter Stokkink
@forkerino
May 21 2017 09:43
@JLuboff somewhere in the middle
harshdalal442
@harshdalal442
May 21 2017 09:44
@JLuboff Because inbuilt reverse method of array will reverse the order of elements inside it. which means if we have "a","b","c". It will return "c","b","a". But in my case the input is only "a". So it returns me "a". which is wrong
Jason Luboff
@JLuboff
May 21 2017 09:45
@forkerino gotcha. What about a Dutch baby?
Pieter Stokkink
@forkerino
May 21 2017 09:45
@harshdalal442 you know, you can split a string into characters.
@JLuboff come again?
harshdalal442
@harshdalal442
May 21 2017 09:46
@forkerino I will try that thanka you
Jason Luboff
@JLuboff
May 21 2017 09:47
@forkerino Dutch baby pancake? Maybe different name here?
harshdalal442
@harshdalal442
May 21 2017 09:47
@forkerino Thanks it worked (y)
CamperBot
@camperbot
May 21 2017 09:47
harshdalal442 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2322 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
May 21 2017 09:48
@JLuboff aaaah, poffertjes!
Yeah, those are great too.
I was really confused with the words Dutch baby.
@harshdalal442 :+1:
Jason Luboff
@JLuboff
May 21 2017 09:49
Those look tasty
Maybe I'm just really hungry...haven't had a real meal ina while. Even last night just had appetizers lol
devpaaji
@devpaaji
May 21 2017 09:51
<div class="widgetServer">http://ctest.discount.test.com</div>.
in this case
what is domain server vs DNS
@forkerino
Jason Luboff
@JLuboff
May 21 2017 09:52
The domain is test.com. DNS translates words to IP addresses
Pieter Stokkink
@forkerino
May 21 2017 09:52
@AnshulAdlakha your variable twitterQuote is out of scope. It is only defined inside the newQuote function. Easiest solution would be to make it a global variable, but better would be to somehow attach the eventlistener in the newQuote from the JS, instead of coding it in the html.
Augusto Wang
@GusWng
May 21 2017 09:54
help me pls, where am i going wrong?
function sym(args) {
  var vals = [].slice.call(arguments);
  var dif = [];
function symDif(now,next){ //filter function
  for(var a = 0; a<vals[now].length; a++){
  if(vals[next].indexOf(vals[now][a])!== -1){
    return true;
    } // for loop end
  }
} // function end
  for(var i =0; i<vals.length-1; i++){
  dif = vals.filter(symDif(i,i+1));

  }
  return dif;
}

sym([1, 2, 3], [5, 2, 1, 4]);
Anshul Adlakha
@anshuladlakha
May 21 2017 09:55
@forkerino how can i make it global?
Pieter Stokkink
@forkerino
May 21 2017 09:56
@AnshulAdlakha declare it outside the function and inside only overwrite it when you get a new quote.
@GusWng that function you pass into filter won't behave as you expect it. the .filter function always automatically passes in the following three arguments (often people only use one or two): the current element, the index of that element, and the array itself.
Anshul Adlakha
@anshuladlakha
May 21 2017 09:57
@forkerino i understand.
So all i have to do is copy the same declaration outside the function and leave he functiion as is?
Pieter Stokkink
@forkerino
May 21 2017 09:58
You actually don't pass a function into the .filter method, but the result of the function. @GusWng
@AnshulAdlakha outside do var twitterQuote, inside do twitterQuote = .... (don't use var inside, otherwise it will never overwrite the global variable but create a local one that shadows the global one inside the function.
Anshul Adlakha
@anshuladlakha
May 21 2017 09:59
@forkerino ok thankyou
I'll try
Augusto Wang
@GusWng
May 21 2017 10:00
@forkerino hmm i see... so the filter parameters should be a and vals[i]?
Jason Luboff
@JLuboff
May 21 2017 10:01
@forkerino anything exciting we should check out today?
Pieter Stokkink
@forkerino
May 21 2017 10:03
@JLuboff Just enjoy the nice weather, have a walk around and be careful which 'coffeeshop' you choose.
Paweł Karniej
@Karniej
May 21 2017 10:03
Hello, anybody here could help me with babel-webpack thingy?
Pieter Stokkink
@forkerino
May 21 2017 10:04
@GusWng No the filter has only one parameter, which is a function (not a function call).
@Karniej maybe, what's the problem?
Jason Luboff
@JLuboff
May 21 2017 10:05
@forkerino meaning difference between coffee and weed or difference between shady shops?
Pieter Stokkink
@forkerino
May 21 2017 10:05
the former.
:joy:
Paweł Karniej
@Karniej
May 21 2017 10:05
@forkerino can I write you pm?
Anshul Adlakha
@anshuladlakha
May 21 2017 10:05
@forkerino thanks it works now
But there's still one small issue
After I once click the new quote button it works
But if i run it before clicking the new quote button atleast once
Instead of using the default quote it says undefined
What should i do?
CamperBot
@camperbot
May 21 2017 10:05
anshuladlakha sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2323 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
May 21 2017 10:05
@Karniej yes
@AnshulAdlakha you could assign the default value to the variable where you declare it outside the function.
Jason Luboff
@JLuboff
May 21 2017 10:06
@forkerino haha :+1: I knew that much ;)
Anshul Adlakha
@anshuladlakha
May 21 2017 10:07
@forkerino Wow you're really good
Thanks
CamperBot
@camperbot
May 21 2017 10:07
anshuladlakha sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:warning: anshuladlakha already gave forkerino points
HeebieGeeBee
@HeebieGeeBee
May 21 2017 10:25
@JLuboff lol why are you here in the chatroom and not out doing stuff in amsterdam?
@JLuboff @forkerino :wave:
Pieter Stokkink
@forkerino
May 21 2017 10:26
Yo
HeebieGeeBee
@HeebieGeeBee
May 21 2017 10:27
hows it going?
Jason Luboff
@JLuboff
May 21 2017 10:29
Because my dad just finally got his ass out of bed lol. Going to go now. See ya
Aimy24
@Aimy24
May 21 2017 10:30
Define a variable a with var and initialize it to a value of 9.
java script

var ourVar = 19;

var myVar = a;

Pieter Stokkink
@forkerino
May 21 2017 10:30
@JLuboff later, have fun!
@HeebieGeeBee Good, good. Not being productive.
Keon Samuel
@keonsam
May 21 2017 10:31
doing what?lol.
Aimy24
@Aimy24
May 21 2017 10:32
i can't understand this
Long Nguyen
@longnt80
May 21 2017 10:34
@Aimy24 var a = 9;
Daniel Narilton
@spaganger
May 21 2017 10:35

hey, guys! I've been trying to slice the 'px' characters from the array var myArray = ["12px", "-13px" , " ", "4px", " ", "red,", " ", "-12px", " ", "-14px", " ", "4px", " ", "red ,", " ", "14px", " ", "12px ", " 4px", "", "red,", " ", "-12px"," ", "13px", " ", "4px", "", "red"]; so I tried using the foor loop with if statements but it's not working for me: for(i = 0; i<counter.length; i++){

console.log(myArray[i].slice(0,2));
if(counter[i] === 3) console.log(myArray[3].slice(0,1));

}

HeebieGeeBee
@HeebieGeeBee
May 21 2017 10:38
@forkerino my god my computer was amking this awful vibrating sound, so i just unplugged the case fan, which seemed to be the problem now its, sounds virtually silent in comaprison, i just thought i always had a well noisy computer
all the time was just this little fecking fan
anyways, how bad can it be to not have any case vent fans? lol
Pieter Stokkink
@forkerino
May 21 2017 10:39
:joy:
Dan Couper
@DanCouper
May 21 2017 10:41
@Vigariuoluvi the array has other non-px strings in, and the value is of different sizes, so that won't work. Try myarr.filter(v => v.includes('px').map(v => parseInt(v, 10))
Daniel Narilton
@spaganger
May 21 2017 10:47
@DanCouper thanks, Couper. What is 'v'?
CamperBot
@camperbot
May 21 2017 10:47
vigariuoluvi sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 726 | @dancouper |http://www.freecodecamp.com/dancouper
Dan Couper
@DanCouper
May 21 2017 10:50
It is the current value (if it were written as a loop, it would be arr[i])

@Vigarioulivi, crap, got that wrong, missed a bracket:

I have an array with strings, mixed up beween empty strings and px values. I want just the px values, without the 'px'. So filter out non-px strings, then convert all the px strings to just numbers:

myarr
.filter(v => v.includes('px')) // leave only values with px
.map(v => parseInt(v, 10)); // parse the numbers out of those values
ms-dosx86
@ms-dosx86
May 21 2017 10:59

hi! i learn JavaScript Profile Lookup and i wrote function lookUpProfile, but it doesnt work

function lookUpProfile(firstName, prop){
var i = 0;
while (true) {
if (contacts[i].firstName == firstName)
if (contacts[i].lastName == prop)
return contacts[i].lastName;
else
if (contacts[i].number == prop)
return contacts[i].number;
else
return contacts[i].likes;
i++;
}
}

lookUpProfile("Akira", "address");

i dont understand why??

Dan Couper
@DanCouper
May 21 2017 11:00

Just written imperatively, as a loop rather than filter/map:

myarr = ["12px", "-13px" , " ", "4px", " ", "red,", " ", "-12px", " ", "-14px", " ", "4px", " ", "red ,", " ", "14px", " ", "12px ", " 4px", "", "red,", " ", "-12px"," ", "13px", " ", "4px", "", "red"];
newarr = [];

If you want to keep it the same, but without 'px':

for (var i = 0; i < myarr.length; i++) {
  if (myarr[i].includes(px)) {
    newarr.push(myarr[i].replace('px', '');
  } else {
    newarr.push(myarr[i]);
  }
}
return newarr;

If you just want the numbers:

for (var i = 0; i < myarr.length; i++) {
  if (myarr[i].includes(px)) {
    newarr.push(parseInt(myarr[i], 10);
  }
}
return newarr;
Crap, px in the includes should be 'px'
Madhusoodhan
@Madhusoodhan
May 21 2017 11:02

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

// Only change code below this line
val = {
alpha : "Adams",
bravo: "Boston",

charlie:"Chicago",

delta:"Denver",

echo:"Easy",

foxtrot:"Frank"

};
result = val;

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

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

some one help me
Abhishek Tiwari
@fillopfy
May 21 2017 11:07
@Madhusoodhan what is the instruction
SirG
@BoySirG
May 21 2017 11:08
the name of that object is wrong, i think u should reset it back @Madhusoodhan
Pieter Stokkink
@forkerino
May 21 2017 11:08
@ms-dosx86 please make a habit out of using { } to surround your if and else blocks. It will be easier to read for others and for your future you. Instead of checking each property separately (and incorrect, as you compare keys to values), it is better to use .hasOwnProperty to check if an object has a certain prop. You can then return it by using prop in your return statement instead of the other names.
Madhusoodhan
@Madhusoodhan
May 21 2017 11:08
ex : when phoneticLookup("echo") is called it should return Easy
Pieter Stokkink
@forkerino
May 21 2017 11:09
@Madhusoodhan don't overwrite val, instead create a new variable called lookup as per the instructions.
ms-dosx86
@ms-dosx86
May 21 2017 11:13
@forkerino when i use .hasOwnProperty
if (contacts[i].hasOwnProperty(firstName))
console show me TypeError: Cannot read property 'hasOwnProperty' of undefined
SirG
@BoySirG
May 21 2017 11:14
the argument charlie is passed in when the function is called and then it is assigned to the variable val, now you have to look up for charlie in the lookup object by writing lookup[val] before assigning it to the result variable
@Madhusoodhan
Pieter Stokkink
@forkerino
May 21 2017 11:15
@ms-dosx86 yes, your loop doesn't stop at the last contact, but keeps looping. It therefore tries to access contacts in the array that don't exist. The condition of your while should probably check if i is below the length of the array.
astonfred
@astonfred
May 21 2017 11:21
hey guys, could you tell me where's the issue here: ````

// Setup
function abTest(a, b) {
  // Only change code below this line

  if (a < 0 || b < 0); {

    return undefined;

  }


  // Only change code above this line

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


}

// Change values below to test your code
abTest(2,0);
Pieter Stokkink
@forkerino
May 21 2017 11:22
@astonfred there should be no ; after your if.
astonfred
@astonfred
May 21 2017 11:22
@forkerino thanks so much!
CamperBot
@camperbot
May 21 2017 11:22
:star2: 2324 | @forkerino |http://www.freecodecamp.com/forkerino
astonfred sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
ms-dosx86
@ms-dosx86
May 21 2017 11:23
@forkerino how I do have find "Akira" (firstName's value) with .hasOwnProperty if it finds Property, but "Akira" is Value?
Pieter Stokkink
@forkerino
May 21 2017 11:24
@ms-dosx86 that first if was good. The second if is where you use .hasOwnProperty. At that point you know you found the right person, so you just have to check if the property exists and return it if it does.
so don't use .hasOwnProperty for the first name
Abhishek Tiwari
@fillopfy
May 21 2017 11:31

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var m=[[]];
  for(var i=0;i<arr.length;i++)
    {
      m[i].push(arr.slice(size));
    }
  return m;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
what is wrong with my code
ms-dosx86
@ms-dosx86
May 21 2017 11:32
@forkerino it works! my thanks. But i dont understand why my IFs doesnt work? I just compare values of propertys with arg prop
CamperBot
@camperbot
May 21 2017 11:32
ms-dosx86 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2325 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
May 21 2017 11:33
@fillopfy arr.slice returns an array, you don't have to create a nested array for your result. You will need two arguments for your .slice to make it an actual slice.
@ms-dosx86 prop contains the name of a prop (the key), which is not the same as the value of the prop.
Abhishek Tiwari
@fillopfy
May 21 2017 11:34
@forkerino and how to do that?
ms-dosx86
@ms-dosx86
May 21 2017 11:36
@forkerino exactly, i dont know how i did that stupid mistake. Thanks
CamperBot
@camperbot
May 21 2017 11:36
ms-dosx86 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:warning: ms-dosx86 already gave forkerino points
Pieter Stokkink
@forkerino
May 21 2017 11:38
@fillopfy you have to find a way to know where the slice should start and where the slice should end based on the value of i in your loop.
Abhishek Tiwari
@fillopfy
May 21 2017 11:39
@forkerino what will be the output of this code:
var m=[[]];

      m.push(arr.slice(size));

  return m;
}
Pieter Stokkink
@forkerino
May 21 2017 11:40
Why don't you just run it and see for yourself? @fillopfy
Abhishek Tiwari
@fillopfy
May 21 2017 11:42
@forkerino i did, it's giving me: [[],[c,d]] and i don't know from where the empty array is comming in the first place
ms-dosx86
@ms-dosx86
May 21 2017 11:44
another one question: how insert code image instead the code itself?
Abhishek Tiwari
@fillopfy
May 21 2017 11:46
@ms-dosx86 press 3 times the key below esc, then shift+enter, put code and then ctr+enter
ms-dosx86
@ms-dosx86
May 21 2017 11:48

```
function randomFraction() {

// Only change code below this line.

return 0;

// Only change code above this line.
}

:D
Abhishek Tiwari
@fillopfy
May 21 2017 11:50
@ms-dosx86 you can use this syntax: (shift+enter)put code here(ctr+enter)
@ms-dosx86 and use the key below esc before and after the above syntax
ms-dosx86
@ms-dosx86
May 21 2017 11:50
my code
aqleemali
@aqleemali
May 21 2017 11:51
image.png
ms-dosx86
@ms-dosx86
May 21 2017 11:51
okay, i got it
@fillopfy thanks
CamperBot
@camperbot
May 21 2017 11:51
ms-dosx86 sends brownie points to @fillopfy :sparkles: :thumbsup: :sparkles:
:cookie: 250 | @fillopfy |http://www.freecodecamp.com/fillopfy
ms-dosx86
@ms-dosx86
May 21 2017 11:52
@aqleemali thats another way :smile:
aqleemali
@aqleemali
May 21 2017 11:52
how
var myStr = "<a href=\"http://www.example.com\"target='_blank'>Link</a>";
:smile:
..................?
ms-dosx86
@ms-dosx86
May 21 2017 11:55
@aqleemali guy above wrote how do this, read it
Abhishek Tiwari
@fillopfy
May 21 2017 11:58
@aqleemali you can use this syntax: (shift+enter)put code here(ctr+enter)
and use the key below esc before and after the above syntax
Abubakar Sambo
@sastech
May 21 2017 12:00
hi guys!! help
function randomFraction() {

  // Only change code below this line.

  return math.random();

  // Only change code above this line.
}
Kelechi Chinaka
@ke1echi
May 21 2017 12:01
what does the instruction say @sastech
ms-dosx86
@ms-dosx86
May 21 2017 12:01
@sastech return Math.random(0, 1);
Abubakar Sambo
@sastech
May 21 2017 12:03
@ms-dosx86 its saying math is not defined
@kelechichinaka Change randomFraction to return a random number instead of returning 0.
ms-dosx86
@ms-dosx86
May 21 2017 12:04
@sastech you should write Math instead of math
Abhishek Tiwari
@fillopfy
May 21 2017 12:04
@sastech use Math.random();
harshdalal442
@harshdalal442
May 21 2017 12:04
hi, I need help for Seek and Destroy inside freecodecamp. I have problem reading input. The whole input is not being read inside the given starter code.
Abubakar Sambo
@sastech
May 21 2017 12:04
@ms-dosx86 thanks! it works
CamperBot
@camperbot
May 21 2017 12:04
sastech sends brownie points to @ms-dosx86 :sparkles: :thumbsup: :sparkles:
:cookie: 219 | @ms-dosx86 |http://www.freecodecamp.com/ms-dosx86
harshdalal442
@harshdalal442
May 21 2017 12:05

function destroyer(arr) {
// Remove all the values
return arr;
}

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

Abubakar Sambo
@sastech
May 21 2017 12:05
@fillopfy thanks, gotten it