These are chat archives for FreeCodeCamp/HelpJavaScript

27th
Mar 2016
Zabe Sangary
@zabesangary
Mar 27 2016 00:00
ah yeh in that sense it is not that friendly
using repl right now
and want to know how to reverse a string in jS : )
Ramana Venkata
@vramana
Mar 27 2016 00:02
@zabefloyd Step 2 is reverse an array.
Google it.
Islam Ibakaev
@dagman
Mar 27 2016 00:03
i am doing local weather app it's in progress. Just it work for you? http://codepen.io/dagman/pen/eZRBeq?editors=0110
Ramana Venkata
@vramana
Mar 27 2016 00:04
@dagman It does work for me.
Islam Ibakaev
@dagman
Mar 27 2016 00:10
@vramana does it turns to fahrenheit when you click on temperature?
Ramana Venkata
@vramana
Mar 27 2016 00:10
@dagman It does.
I haven't checked the calculation though.
Zabe Sangary
@zabesangary
Mar 27 2016 00:15
var str = ["h", "e", "l", "o"];
function myFunction() {
str.reverse();
return str;
}
myFunction()
did it
Ramana Venkata
@vramana
Mar 27 2016 00:15
@zabefloyd Good Job. Now Combine. Steps 1 & 2 in the same function.
Zabe Sangary
@zabesangary
Mar 27 2016 00:19
trying
Miguel T Rivera
@mtrivera
Mar 27 2016 00:23
function destroyer(arr){
    //convert arguments into an array
    arr = Array.prototype.slice.call(arguments);
    var finalAry = [];

    var checked = arr[0].filter(function(val){
      var testA = arr[1];
      var testB = arr[arr.length - 1];

    if(val !== testA && val !== testB){
      finalAry.push(val);
    }
  });
  return finalAry;
}
need help with seek and destroy, one condition does not work: destroyer([3, 5, 1, 2, 2], 2, 3, 5) should return [1].
Islam Ibakaev
@dagman
Mar 27 2016 00:24
@migueltrivera is it bonfire?
Miguel T Rivera
@mtrivera
Mar 27 2016 00:25
@dagman this is the result i get: [3,1]
Islam Ibakaev
@dagman
Mar 27 2016 00:26
@migueltrivera which bonfire it is
?
Miguel T Rivera
@mtrivera
Mar 27 2016 00:27
@dagman idk what bonfire is?
Islam Ibakaev
@dagman
Mar 27 2016 00:31
@migueltrivera maybe you want this
function destroyer(arr){
    //convert arguments into an array
    var rest = Array.prototype.slice.call(arguments, 1);
    return arr.filter(function(el) {
        return rest.indexOf(el) === -1;
    });


}

destroyer([3, 5, 1, 2, 2], 2, 3, 5);
Kurt Johnson
@pompan129
Mar 27 2016 00:31
@migueltrivera bonfire is old name for algorithm challenge
Miguel T Rivera
@mtrivera
Mar 27 2016 00:32
@dagman Seek and Destroy
@pompan129 thanks
CamperBot
@camperbot
Mar 27 2016 00:32
migueltrivera sends brownie points to @pompan129 :sparkles: :thumbsup: :sparkles:
:star: 445 | @pompan129 | http://www.freecodecamp.com/pompan129
Islam Ibakaev
@dagman
Mar 27 2016 00:32
@migueltrivera look at code above
Lavie Ruan
@LavieMaru
Mar 27 2016 00:33
find Profile Lookup
CamperBot
@camperbot
Mar 27 2016 00:33

find profile lookup

:zero: checkpoint profile lookup

Miguel T Rivera
@mtrivera
Mar 27 2016 00:36
@dagman thanks
CamperBot
@camperbot
Mar 27 2016 00:36
migueltrivera sends brownie points to @dagman :sparkles: :thumbsup: :sparkles:
:star: 361 | @dagman | http://www.freecodecamp.com/dagman
Zabe Sangary
@zabesangary
Mar 27 2016 00:45

@vramana I need help var str = "hello";
function reverseString(str) {
return str;
var strReverse = str.split('').reverse().join('');
}

reverseString(strReverse);

var str = "hello";
function reverseString() {

var strReverse = str.split('').reverse().join('');
console.log(strReverse);
}

reverseString(strReverse);

this it! it should pass but it doesn't
Reckoo
@Reckoo
Mar 27 2016 00:56

@zabefloyd did you try with return ? Like

 var str = "hello";
function reverseString(str) {  
  return str;
var strReverse = str.split('').reverse().join('');
}

reverseString(strReverse);

var str = "hello";
function reverseString() {  

var strReverse = str.split('').reverse().join('');
return(strReverse);
}

Try to simplify your code.
reverseString(strReverse);

@zabefloyd Ho I see, your function starts with return, the argument return does terminate your function, it's a bit like console.log() but it stop the process of your function. Don't put it at the beginning.
Clare Dickerson
@claredickerson
Mar 27 2016 00:59

2 seconds into javascript and I'm getting tripped up. :(
"Assign the value 7 to variable a.
Assign the contents of a to variable b."

var a = 7;
var b = 7;

I can't figure out how to assign a and b together. I try to follow the "myVar = 5;
myNum = myVar;" example but it doesn't seem to be making sense.

Zabe Sangary
@zabesangary
Mar 27 2016 01:00
something like that? function reverseString() {
var str = "hello";
var strReverse = str.split('').reverse().join('');
return(strReverse);
}
reverseString()
Kurt Johnson
@pompan129
Mar 27 2016 01:00
@claredickerson just like the example. substitute a for myVar & b for myNum
Joseph
@revisualize
Mar 27 2016 01:01
@zabefloyd return strReverse;
Islam Ibakaev
@dagman
Mar 27 2016 01:02
@claredickerson b = a
Zabe Sangary
@zabesangary
Mar 27 2016 01:03
var a = 7;
var b = 7;
b = a
console.log(b, a)
Clare Dickerson
@claredickerson
Mar 27 2016 01:04
i'm certain that i tried var b = a; but perhaps i missed a semicolor or something. thanks @dagman
CamperBot
@camperbot
Mar 27 2016 01:04
claredickerson sends brownie points to @dagman :sparkles: :thumbsup: :sparkles:
:star: 362 | @dagman | http://www.freecodecamp.com/dagman
Clare Dickerson
@claredickerson
Mar 27 2016 01:04
I think i need to just get up and walk away from the computer for a bit haha. Spent all day finishing my portfolio and I think my brain is numb.
Zabe Sangary
@zabesangary
Mar 27 2016 01:04
@claredickerson yes!
Islam Ibakaev
@dagman
Mar 27 2016 01:05
@claredickerson good advise for everyone
Zabe Sangary
@zabesangary
Mar 27 2016 01:05
get cookies from jar
how do I get the code highlight?
test
function reverseString() {  
var str = "hello";
var strReverse = str.split('').reverse().join('');
return strReverse;
}
reverseString()
awesome got it
this code is not passing
ah no wait
Blake Harris
@bharris62
Mar 27 2016 01:08
problem 219, this is saying i need to use bracket notation to access
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;       // Change this Line
var player = testObj[16];   // Change this Line
dunno what i need to do to pass this one
Zabe Sangary
@zabesangary
Mar 27 2016 01:08
function reverseString() { var str = ["hello", "Howdy", "Greetings"]; var strReverse = str.split('').reverse().join(''); return strReverse; } reverseString() this should work but it doesn't
Pascal T.
@omegga
Mar 27 2016 01:09
@bharris62 maybe
var player = testObj[nameOfVariable]; //instead of number
Blake Harris
@bharris62
Mar 27 2016 01:10

i tried

var player = testObj['Montana']

but that didn't work

oh could be playernumber
Pascal T.
@omegga
Mar 27 2016 01:11
@bharris62 yes perhaps, try it
Kurt Johnson
@pompan129
Mar 27 2016 01:12
@bharris62 'Montana' is the valuenot the key. to get "Montana" you need testObj["16"]
Pascal T.
@omegga
Mar 27 2016 01:12
@bharris62 a litteral object structure is key:value , when you ask the key it will return associated value
Kurt Johnson
@pompan129
Mar 27 2016 01:12
barcket notation only takes strings
Blake Harris
@bharris62
Mar 27 2016 01:13
neither '16' or 'playerNumber' worked
Kurt Johnson
@pompan129
Mar 27 2016 01:14
@bharris62 hmmm ... let me look
Blake Harris
@bharris62
Mar 27 2016 01:14
its still saying i need to use bracket notation
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = 16;       // Change this Line
var player = testObj["16"];   // Change this Line
first 3 pass, fourth fails
got it

you have to do

var player = testObj[playerNumber]

not in strings

so bracket notation can take in non strings, if its a variable?
hrokr
@hrokr
Mar 27 2016 01:16
This message was deleted
Pascal T.
@omegga
Mar 27 2016 01:16
@bharris62 yes because variable returns its value which is 16
Kurt Johnson
@pompan129
Mar 27 2016 01:17
@bharris62 it does conversion for you. like "a" + 2 --> "a2"
Joseph
@revisualize
Mar 27 2016 01:20
@zabefloyd Because your STR is an array already.
Blake Harris
@bharris62
Mar 27 2016 01:21
ah ok
Joseph
@revisualize
Mar 27 2016 01:22

@zabefloyd

function reverseString() { 
    var str = ["hello", "Howdy", "Greetings"]; 
    var strReverse = str.split('').reverse().join(''); 
    return strReverse;
 } 
reverseString()

This won't split the array.
You'll just get a:
TypeError: str.split is not a function
Because you can't split an array based upon ''.

@zabefloyd if you want to use an array like that .. You'll need to use a for loop.
Or while loop.
@zabefloyd What exactly are you trying to do?
@zabefloyd If you are trying to do the Challenge for Reverse a String. I regret to inform you that you broke your function and it is no longer accepting an input variable.
This is how the challenge starts:
function reverseString(str) {
  return str;
}
reverseString("hello");
Zabe Sangary
@zabesangary
Mar 27 2016 01:26
function reverseString() { var str = 'hello'; var str1 = 'Howdy'; var str2 = 'Greetings from Earth'; var strReverse = str str1 str2.split('').reverse().join(''); return strReverse; } reverseString(str)
Blake Harris
@bharris62
Mar 27 2016 01:26
what are the advantages/disadvantages to dot notation vs bracket?
Zabe Sangary
@zabesangary
Mar 27 2016 01:26
reverseString("hello") should return a string. reverseString("hello") should become "olleh". reverseString("Howdy") should become "ydwoH". reverseString("Greetings from Earth") should return "htraE morf sgniteerG".
sorry I wasn't paying attention to screen
Joseph
@revisualize
Mar 27 2016 01:27

@zabefloyd to complete that challenge all you need to do is change 1 line.

return str.split('').reverse().join('');

You'll notice that str gets passed into the function as a variable.
You then split the str variable based on no element. (item is now an array.)
You then reverse the order of the array.
Then you join the item back together from an array to a string.

@zabefloyd You need to reset your code.
Ramana Venkata
@vramana
Mar 27 2016 01:28
@zabefloyd Your missing the argument to your function.
Zabe Sangary
@zabesangary
Mar 27 2016 01:28
happy to hear your advise
Joseph
@revisualize
Mar 27 2016 01:28
@vramana That's what I just said.
Zabe Sangary
@zabesangary
Mar 27 2016 01:28
i get error when add the arg
Ramana Venkata
@vramana
Mar 27 2016 01:28
@revisualize Yeah just read that.
Joseph
@revisualize
Mar 27 2016 01:29
@zabefloyd What error?
Kurt Johnson
@pompan129
Mar 27 2016 01:30
@bharris62 with bracket you can put a variable in there. so if your Key is unknown at start of program you can still do a reference. Maybe you want to return a value based on user input. if, in ur example, the user inut "16" your program could return "Montana", but anther player if the input another key. you can't use a variable with dot notation
Joseph
@revisualize
Mar 27 2016 01:30
@zabefloyd Seriously, you broke the code.
This solves it:
function reverseString(str) {
  return str.split('').reverse().join('');
}
Blake Harris
@bharris62
Mar 27 2016 01:30
ok thank you @pompan129
CamperBot
@camperbot
Mar 27 2016 01:30
bharris62 sends brownie points to @pompan129 :sparkles: :thumbsup: :sparkles:
:star: 446 | @pompan129 | http://www.freecodecamp.com/pompan129
Blake Harris
@bharris62
Mar 27 2016 01:31
@Scriptonaut thank you too
CamperBot
@camperbot
Mar 27 2016 01:31
bharris62 sends brownie points to @scriptonaut :sparkles: :thumbsup: :sparkles:
:star: 333 | @scriptonaut | http://www.freecodecamp.com/scriptonaut
Joseph
@revisualize
Mar 27 2016 01:32
@Scriptonaut You're now half evil.
Pascal T.
@omegga
Mar 27 2016 01:32
@revisualize lol
Matthew Kenneth McMasters
@mkmcmast
Mar 27 2016 01:34
Can anyone help me with the Symetric Difference challenge? I have put way too much time into this particular approach and I'd like to see if it can be made to work. Here is my code: https://codepen.io/mkmcmast/pen/oxZeJz?editors=0012 It's hideous and long but if you feel like flexing your js brain I would much appreciate it:)
Joseph
@revisualize
Mar 27 2016 01:35
@mkmcmast Good Luck. ... /me quietly exits stage left.
Ramana Venkata
@vramana
Mar 27 2016 01:35
@mkmcmast Symmetric difference is binary function.
Just solve it for that case.
No need to solve it n- variables.
Zabe Sangary
@zabesangary
Mar 27 2016 01:37

''' function reverseString(str) {
var str = 'hello', 'so';

var strReverse = str.split('').reverse().join('');
return strReverse;
}
reverseString(str) '''

CamperBot
@camperbot
Mar 27 2016 01:37
:bulb: to format code use backticks! ``` more info
Ramana Venkata
@vramana
Mar 27 2016 01:38
Also you should not use the arguments as a variable. It is a reserved keyword.
Jacob Hanawalt
@JacobHanawalt
Mar 27 2016 01:38
Hey all, can someone explain to me what is meant by "falsy" values in the exercise "Falsy Bouncer"? I assumed the examples given of falsy values (false, null, 0, "", undefined, NaN) would all have a "false" boolean value, but they apparently don't. My question is, if this isn't what makes them falsy, what does?
Zabe Sangary
@zabesangary
Mar 27 2016 01:38
it is 4 hours now
I don't know.....
Ramana Venkata
@vramana
Mar 27 2016 01:38
@zabefloyd don't declare str in your function.
Matthew Kenneth McMasters
@mkmcmast
Mar 27 2016 01:38
@revisualize @vramana I figured I'd throw it out there before I try another approach;)
Zabe Sangary
@zabesangary
Mar 27 2016 01:38
okay
Ramana Venkata
@vramana
Mar 27 2016 01:38
That's all you need to do.
Zabe Sangary
@zabesangary
Mar 27 2016 01:38
removed it
Ramana Venkata
@vramana
Mar 27 2016 01:38
Does it work now?
Zabe Sangary
@zabesangary
Mar 27 2016 01:39
nope
Joseph
@revisualize
Mar 27 2016 01:39
@zabefloyd Why are you overwriting the str variable that you're passing in?
Zabe Sangary
@zabesangary
Mar 27 2016 01:39
Unexpected string(…)
Joseph
@revisualize
Mar 27 2016 01:40
var str = 'hello', 'so'; ... ERROR.
Zabe Sangary
@zabesangary
Mar 27 2016 01:40
yes
Joseph
@revisualize
Mar 27 2016 01:40
How do you set a variable to a string?
Zabe Sangary
@zabesangary
Mar 27 2016 01:40
var strGing = "Hello";
Joseph
@revisualize
Mar 27 2016 01:40
GREAT!
var str = 'hello', 'so'; ... why are you doing it like this?
In fact, if you COMPLETELY remove that line from your code. The assessment will pass.
please have a look at this if you don't mind that's what I am trying to do
Joseph
@revisualize
Mar 27 2016 01:42
@zabefloyd
function reverseString(str) {
var str = 'hello', 'so';       // .... REMOVE THIS LINE.
var strReverse = str.split('').reverse().join('');
return strReverse;
}
reverseString(str)
Ramana Venkata
@vramana
Mar 27 2016 01:42
@zabefloyd as @revisualize said just remove the second line.
Zabe Sangary
@zabesangary
Mar 27 2016 01:42
yes that way it will work I know
Joseph
@revisualize
Mar 27 2016 01:42
Okay.
What are you trying to do?
Ramana Venkata
@vramana
Mar 27 2016 01:42
Oh I see the problem
Zabe Sangary
@zabesangary
Mar 27 2016 01:42
but is asking this reverseString("hello") should return a string.
reverseString("hello") should become "olleh".
reverseString("Howdy") should become "ydwoH".
reverseString("Greetings from Earth") should return "htraE morf sgniteerG".
good @vramana :D
Ramana Venkata
@vramana
Mar 27 2016 01:43
str is not defined. outside. And he is calling that
Joseph
@revisualize
Mar 27 2016 01:43
function reverseString(str) {
var str = 'hello', 'so';       // .... REMOVE THIS LINE.
var strReverse = str.split('').reverse().join('');
return strReverse;
}
reverseString(str); // <- fix this line.
/* ..... STR is not defined. 
You're trying to pass a variable INTO your function. 
Not a string.
*/
Ramana Venkata
@vramana
Mar 27 2016 01:44
@zabefloyd Is it good now??
Zabe Sangary
@zabesangary
Mar 27 2016 01:44
when you add var str = value;
that's define no?
Joseph
@revisualize
Mar 27 2016 01:44
That is defined INSIDE the function.
Ramana Venkata
@vramana
Mar 27 2016 01:44
But that inside the function.
Vik
@vvang044
Mar 27 2016 01:45
hello all......i am hoping if someone could give me a hint on how to get my head around " Repeat a string, repeat a string"
Joseph
@revisualize
Mar 27 2016 01:45
@zabefloyd Functions have a SCOPE. It is something that you'll learn about.
Sephem
@Sephem
Mar 27 2016 01:46
the tasks does not ask to define str, just accept it and revers it. @zabefloyd . The actual call to the function should be a sting not a variable and is only there for testing
Ramana Venkata
@vramana
Mar 27 2016 01:46
@vvang044 Do you know how to write a for-loop??
Vik
@vvang044
Mar 27 2016 01:46
yep.....
Ramana Venkata
@vramana
Mar 27 2016 01:47
Do you know how to add two strings??
Joseph
@revisualize
Mar 27 2016 01:47
@zabefloyd Think about this.. Let's say you have a bunch of cans of food.
Inside one of the cans is a pea. Let's say you have var pea = "green"; You can't access the pea inside of the can (function) unless you open the can.
Ramana Venkata
@vramana
Mar 27 2016 01:47
@revisualize :+1:
Zabe Sangary
@zabesangary
Mar 27 2016 01:48
sorry guys I might pain in neck but this is not working still
that's the lesson
Sephem
@Sephem
Mar 27 2016 01:48
so in effect @zabefloyd you can just make reverseString("anywordyouwant") as it is just teting
Ramana Venkata
@vramana
Mar 27 2016 01:48
@zabefloyd You still didn't remove the second line.
Joseph
@revisualize
Mar 27 2016 01:48
Okay. I'm going away. You're clearly not reading what I am actually saying.
Zabe Sangary
@zabesangary
Mar 27 2016 01:49
oh no :)
I am reading just confused and lost
Ramana Venkata
@vramana
Mar 27 2016 01:49
@zabefloyd Don't copy paste the code. Change it as others tell.
Joseph
@revisualize
Mar 27 2016 01:49
@zabefloyd Then why aren't you removing the lines that I'm telling you to remove?
read the text that I'm typing.
Zabe Sangary
@zabesangary
Mar 27 2016 01:50
well I need to return or reverse a value no?
Vik
@vvang044
Mar 27 2016 01:50
@zabefloyd step aside for a min and come back ......read what @revisualize and @vramana have written above...... the answer is in one line
Zabe Sangary
@zabesangary
Mar 27 2016 01:50
wow
sorry
yes that worked
Vik
@vvang044
Mar 27 2016 01:51
guess that worked
Ramana Venkata
@vramana
Mar 27 2016 01:51
@zabefloyd Just take a break. Come back tomorrow with a fresh mind.
Zabe Sangary
@zabesangary
Mar 27 2016 01:51
ok is just do with how the editor is here... I thought you need to add the value or the string what ever you call it
Thanks everyone :)
I will! vramana
Ramana Venkata
@vramana
Mar 27 2016 01:52
@vvang044 Do you know how to add two strings??
Vik
@vvang044
Mar 27 2016 01:52
thats where i got lost
Clare Dickerson
@claredickerson
Mar 27 2016 01:52
I gotta say, I got a chuckle out of learning to add, subtract, etc. in JavaScript. "JavaScript uses the symbol + as addition operation..." hahaha. Now THIS is some stuff I can figure out! :D
Ramana Venkata
@vramana
Mar 27 2016 01:52
@vvang044 c = "Hell" + "o"
Joseph
@revisualize
Mar 27 2016 01:53
var a = "hel";
var b = "lo";
var conCat = a + b;
Vik
@vvang044
Mar 27 2016 01:53
yep....
i got that part
Joseph
@revisualize
Mar 27 2016 01:53
@vvang044 Great.
Ramana Venkata
@vramana
Mar 27 2016 01:53
@vvang044 Do you want me give you the idea of the solution? I'll let you work out the code.
Vik
@vvang044
Mar 27 2016 01:54
yep i want to work on the code....but i just neeed a hint
Ramana Venkata
@vramana
Mar 27 2016 01:54
Start with an empty string and add the given string to it using a for loop.
@vvang044 Do you think that will help?? or want me to elaborate a bit more??
Vik
@vvang044
Mar 27 2016 01:55
thats the start...... how about when the num is " -3"....how do i return ...... " "
Ramana Venkata
@vramana
Mar 27 2016 01:56
@vvang044 Now just solve it when num > 0
Let's worry about the other case later.
Vik
@vvang044
Mar 27 2016 01:57
ok.....now let me scratch my head and try to write that code
Ramana Venkata
@vramana
Mar 27 2016 01:58
@vvang044 A rule of thumb I follow while solving a problem is don't try to solve all of it at once. Solve it bit by bit. Just simply solve the part you think you can and then move to more difficult parts.
Vik
@vvang044
Mar 27 2016 01:58
ok....ty
Paul Borawski
@iAmNawa
Mar 27 2016 02:02
HELLO hola el mundo
Vik
@vvang044
Mar 27 2016 02:06
i think im lost......looks like im thinking way over my head
Ramana Venkata
@vramana
Mar 27 2016 02:09
@vvang044 Can you write a simple for loop? And paste it here.
Vik
@vvang044
Mar 27 2016 02:11
var repeatOne = "";
for( i=0; i < repeatOne; i++)
Ramana Venkata
@vramana
Mar 27 2016 02:11
@vvang044 That is slightly incorrect.
for (var i = 0; i < 5; i++) {
}
Vik
@vvang044
Mar 27 2016 02:12
i ate the var in my for loop
Ramana Venkata
@vramana
Mar 27 2016 02:13
@vvang044 Also since i is an integer and repeatOne is a string
You can't compare them using <
Vik
@vvang044
Mar 27 2016 02:14
yikes....true
Ramana Venkata
@vramana
Mar 27 2016 02:15
@vvang044 Little diversion from the original problem. Can you use that for-loop to write a program that sums all numbers from 0 to 4??
Vik
@vvang044
Mar 27 2016 02:20
i guess
Vik
@vvang044
Mar 27 2016 02:27
ok i give up.....cant think straight
Ramana Venkata
@vramana
Mar 27 2016 02:28
@vvang044 Can you read some for-loop examples ?? And attempt again...
zkonrad
@zkonrad
Mar 27 2016 02:32
Would someone be able to tell me how the following works? I was using it for sorting an array by string length, but I'm not sure why it worked.
var word = wordLength.sort(function(a, b){
return b.length - a.length;
Also, how do I get the format correct to post code?
Ramana Venkata
@vramana
Mar 27 2016 02:34
@zkonrad Do you know how Array.sort works??
zkonrad
@zkonrad
Mar 27 2016 02:35
I know how it works when you don't insert a method/function. It just basically sorts it alphabetically.
Right, that's where I got the idea to use that.
It's the (function(a,b){
return b.length - a.length;
}); that I'm struggling to understand.
It works for what I was trying to do, but I'd like to better understand how.
Ramana Venkata
@vramana
Mar 27 2016 02:36
@zkonrad That function is used to compare the elements.
@zkonrad Read the paragraph after the example in the Description section.
kilik42
@kilik42
Mar 27 2016 02:43
working on this challenge: Use the map function to add 3 to every value in the variable oldArray, and save the results into variable newArray. oldArray should not change.

here is my code:var oldArray = [1,2,3,4,5];

// Only change code below this line.

var newArray = oldArray.map(function(val){

         return val + 3;

});

not working any ideas?
Vik
@vvang044
Mar 27 2016 02:43
hey @vramana
i got it
i re-read what you wrote above.....
Ramana Venkata
@vramana
Mar 27 2016 02:45
@vvang044 Show your solution.
Vik
@vvang044
Mar 27 2016 02:45
obviously ic annot compare the integer to string....
function repeatStringNumTimes(str, num) {
  // repeat after me

  var repeatOne = "";

  for ( var i = 0; i < num; i++){

    repeatOne += str;

  }

  return  repeatOne;
}

repeatStringNumTimes("abc", 3);
Ramana Venkata
@vramana
Mar 27 2016 02:45
@kilik42 Your code looks fine. What is the problem??
@vvang044 Congrats!!
Vik
@vvang044
Mar 27 2016 02:46
ok.....here is my question.....is there any other way to do this?
kilik42
@kilik42
Mar 27 2016 02:47
I reloaded the page and it worked! funny
Ramana Venkata
@vramana
Mar 27 2016 02:48
@vvang044 str.repeat(num) But your browser may or may not support it.
Kent
@kenthub
Mar 27 2016 02:48

2 problems on my Portfolio page. #1 is the first div container has elements that overflow into the next image when the screen is shrunk to phone/tablet size. #2 the hamburger icon will not expand. Any suggestions?

http://codepen.io/kenthub/pen/BKZLbZ?editors=1100

zkonrad
@zkonrad
Mar 27 2016 02:51
@vramana I've read through that paragraph about 10 times, but I believe it's making sense. I'm going to regurgitate to make sure I have an understanding. The a,b refers to the general order of two indexes (appropriate term?) in the array. Let's say, my first two strings are "cat" and "mouse". It would compare the length of cat (3) to the length of mouse (5). Since a is less than b, and, according to the function (b.length - a.length) greater than 0, then b ("mouse") would be sorted to a lower index, or earlier in the array. It would then continue through the array, thus sorting all the words in the string by length. Am I getting that correctly?
Ramana Venkata
@vramana
Mar 27 2016 02:52
@zkonrad Yes. That's all. A small correction is a & b are the elements not related to indices at all.
zkonrad
@zkonrad
Mar 27 2016 02:53
Gotcha. Thank you for your help.
Vik
@vvang044
Mar 27 2016 02:55
oh geez the next bonfire is crazy.....i need to sleep over it
Ramana Venkata
@vramana
Mar 27 2016 02:56
@vvang044 It's a nice problem. There are multiple ways to do it. And you already solved it indirectly.
You just need to realize it.
Vik
@vvang044
Mar 27 2016 02:57
truncate a string?
Ramana Venkata
@vramana
Mar 27 2016 02:57
@vvang044 The Bonfire is factorialize a number right??
Vik
@vvang044
Mar 27 2016 02:58
nope.....truncate a string.....
Josh Bivens
@joshbivens
Mar 27 2016 02:58
/help Profile Lookup
CamperBot
@camperbot
Mar 27 2016 02:58

:point_right: checkpoint profile lookup [wiki]

Checkpoint: Profile Lookup

Instructions

We have an array of objects representing different people in our contacts lists.

A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you.

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

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

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

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

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about checkpoint profile lookup on the FCC Wiki

Vik
@vvang044
Mar 27 2016 02:58
function truncateString(str, num) {
  // Clear out that junk in your trunk
  return str;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
^^^^ that one
Ramana Venkata
@vramana
Mar 27 2016 03:00
@vvang044 Even this you have solved in some sense.
You need to add a little more logic.
Vik
@vvang044
Mar 27 2016 03:01
i didnt under the three dot's part
*understand
Ramana Venkata
@vramana
Mar 27 2016 03:02
@vvang044 Forget the Dots. Just truncate it first.
For example, truncateString('Hello', 2) should return 'He...'
Vik
@vvang044
Mar 27 2016 03:07
very similar to slice() right?
Ramana Venkata
@vramana
Mar 27 2016 03:09
Yeah. Or you can draw inspiration from your previous solution and solve it.
Vik
@vvang044
Mar 27 2016 03:13
ok......let me do that in the morning.....thank you
@vramana thank you
oh no the brownie points doesnt want to work
i need some sleep.....laterz
EternityElephant
@EternityElephant
Mar 27 2016 03:23
function palindrome(str) {
  // Good luck!
  str.toLowerCase();
  str.replace(/\s/g,'');  
  return str == str.split('').reverse().join('');

}
Could someone help me figure out why this seeminly wont remove spaces in the palindrome challenge.
harpoon747
@harpoon747
Mar 27 2016 03:36

Can some one please help me with the below code ' function lookUp(firstName, prop){
// Only change code below this line
for(i=0; i < contacts.length; i++)
{
for(j=0; j < contacts[i].length;j++)
{
if(firstName === contacts[i][firstName] && prop == contacts[i][prop])
return contacts[i][prop][j];
else if( firstName != contacts[i][firstName] )
return "No such contact";
else if(prop != contacts[i][prop][j])
return "No such property";
}

}
// Only change code above this line
}

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

Elbert Cortez
@trip16661
Mar 27 2016 03:37
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

  }
 return "No such contact" ;
// Only change code above this line
}

// Change these values to test your function
lookUp("Harry", "likes");
what am i doing wrong now?
Matt Green
@mattxgreen
Mar 27 2016 03:38
@harpoon747 Your for loop is not iterating. You are always returning on the first pass
@trip16661 Same with you trip
@trip16661 @harpoon747 Don't return no such contact until you have reached the last contact
Elbert Cortez
@trip16661
Mar 27 2016 03:40
@mattxgreen how?
Matt Green
@mattxgreen
Mar 27 2016 03:40
@trip16661 wait, yours might be right
Elbert Cortez
@trip16661
Mar 27 2016 03:41
@mattxgreen still not running thought
Artur Sęp
@a-sep
Mar 27 2016 03:41
@trip16661 you need var here: for( var a=0; ...
Elbert Cortez
@trip16661
Mar 27 2016 03:41
i don't think it would matter much
did it still not running
Matt Green
@mattxgreen
Mar 27 2016 03:42
what's the challeng name?
Elbert Cortez
@trip16661
Mar 27 2016 03:42
Profile Lookup
EternityElephant
@EternityElephant
Mar 27 2016 03:44
function palindrome(str) {
  // Good luck!
  str.toLowerCase();
  str.replace(/\s/g, "") ;
  return str == str.split('').reverse().join('');

}
Could someone help me to understand why this wouldnt get rid of the white spaces in a string to see if they are palindromes?
atleast i assume thats what the problem is
Matt Green
@mattxgreen
Mar 27 2016 03:44
@trip16661 Your problem is your trying to iterate over an object as if it were an array
Elbert Cortez
@trip16661
Mar 27 2016 03:45
what do you mean
Ramana Venkata
@vramana
Mar 27 2016 03:46
@EternityElephant I don't think you need to remove whitespaces. Is it stated in the problem?? Let me check.
Matt Green
@mattxgreen
Mar 27 2016 03:46
@trip16661 A for loop (as written) won't work like that. You have to use a for-in loop
Elbert Cortez
@trip16661
Mar 27 2016 03:46
but it's not an array of oject?
Robert Richey
@0x0936
Mar 27 2016 03:46
@trip16661 the issue appears to be using prop, the variable, as a literal property. change return contacts[a].prop to return contacts[a][prop]
harpoon747
@harpoon747
Mar 27 2016 03:46
@trip16661 you need to change your else if conditions to !==
Matt Green
@mattxgreen
Mar 27 2016 03:46
@trip16661 oh, it is... my mistake
Elbert Cortez
@trip16661
Mar 27 2016 03:47
oh
Ramana Venkata
@vramana
Mar 27 2016 03:47
@mattxgreen I personally avoid for-in loop.
EternityElephant
@EternityElephant
Mar 27 2016 03:47
@vramana I assumed that was the prblem because the strings with spaces are the ones that have X's on them, the others are checkmarks
Elbert Cortez
@trip16661
Mar 27 2016 03:48
@0x0936 oh cuz it's reading it as it were a property that i already made
and not as an argument
right?
Robert Richey
@0x0936
Mar 27 2016 03:49
@trip16661 dot notation only works if the object has that exact property. it will not interpolate the value of a variable for the property name. need to use brackets to interpolate variables.
Elbert Cortez
@trip16661
Mar 27 2016 03:49
yeah make sense
@0x0936 oh but now it says unexpected token xDDD
Robert Richey
@0x0936
Mar 27 2016 03:51
what is the unexpected token
Elbert Cortez
@trip16661
Mar 27 2016 03:51
nvm im dumb
Ramana Venkata
@vramana
Mar 27 2016 03:51
@EternityElephant I remember this problem. I cheated on this. I didn't want to go through trouble of building regexes. So i just lifted a regex from an StackOverflow answer. I just don't like regex. They are useful but I was never enthusiastic enough to learn them. I feel a bit bad now.
Matt Green
@mattxgreen
Mar 27 2016 03:51
@vramana me2
Elbert Cortez
@trip16661
Mar 27 2016 03:52
i was trying to use brakets notation without deleting the dot notation
Ramana Venkata
@vramana
Mar 27 2016 03:52
Hehe
Matt Green
@mattxgreen
Mar 27 2016 03:52
@vramana just trying to help with a similar loop syntax for ease
Elbert Cortez
@trip16661
Mar 27 2016 03:52
that was relly helpful thanks man
Robert Richey
@0x0936
Mar 27 2016 03:52
@trip16661 :+1:
Elbert Cortez
@trip16661
Mar 27 2016 03:52
@0x0936 @mattxgreen thanks
CamperBot
@camperbot
Mar 27 2016 03:52
trip16661 sends brownie points to @0x0936 and @mattxgreen :sparkles: :thumbsup: :sparkles:
:star: 1254 | @0x0936 | http://www.freecodecamp.com/0x0936
:star: 381 | @mattxgreen | http://www.freecodecamp.com/mattxgreen
Matt Green
@mattxgreen
Mar 27 2016 03:52
@trip16661 absolutely
Ramana Venkata
@vramana
Mar 27 2016 03:54
You can use some sort of filter function to look that charCode of the letter is certain range. A bit tedious though.
Josh Bivens
@joshbivens
Mar 27 2016 03:55
So I have an issue: Inside of $.get(uri, function...) for a call to a weather api, I have access to the response data. But outside of it, I don't. What am I missing here?
harpoon747
@harpoon747
Mar 27 2016 03:57

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

  {
    if(firstName === contacts[i][firstName] && prop === contacts[i].hasOwnProperty(prop))
       return contacts[i].prop;

    else if( contacts[i].firstName !== firstName )
      return "No such contact";

    else if(contacts[i].prop !== prop)
      return "No such property";
  }

}
// Only change code above this line
}'''

CamperBot
@camperbot
Mar 27 2016 03:57
:bulb: to format code use backticks! ``` more info
Ramana Venkata
@vramana
Mar 27 2016 03:57
@joshbivens You have to manipulate the DOM inside your function. There won't be code outside that funtion.
harpoon747
@harpoon747
Mar 27 2016 03:57
Can someone help with the above code it always returns No such property or no such contact
Ramana Venkata
@vramana
Mar 27 2016 04:00
@harpoon747 I think you should edit your message. Just good etiquitte. I am looking at your code. Give me a sec
Tien Anh Nguyen
@tienanh2007
Mar 27 2016 04:06
help Seek and Destroy
CamperBot
@camperbot
Mar 27 2016 04:06

:point_right: algorithm seek and destroy [wiki]

Explanation:

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

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

Paul Borawski
@iAmNawa
Mar 27 2016 04:07
hello!
Ramana Venkata
@vramana
Mar 27 2016 04:11
@iAmNawa Hi
Paul Borawski
@iAmNawa
Mar 27 2016 04:13
how are you? @vramana
Ramana Venkata
@vramana
Mar 27 2016 04:14
I am good. Just chilling here. Helping with whatever I can. You??
@harpoon747 Hey I want to go over the logic you have written. What you are trying to do in the first if statement? Just describe it.No code needed.
scottmike0
@scottmike0
Mar 27 2016 04:19
Sooo
Using array.filter
how would i know the values it cannot be in seek and destroy?
 function destroyer(arr) {// there is only 1 param... I am confused
  // Remove all the values
  return arr.filter(function b(value){return value!== 2 && value!= 3;});
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
anthonyjl92
@anthonyjl92
Mar 27 2016 04:21
why does my check Obj function not work?

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

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

return "Not found";
}

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

Ramana Venkata
@vramana
Mar 27 2016 04:21
help format
CamperBot
@camperbot
Mar 27 2016 04:21

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

scottmike0
@scottmike0
Mar 27 2016 04:21
Does anyone understand the seek and destroy
algorithm?
Ramana Venkata
@vramana
Mar 27 2016 04:22
@anthonyjl92 Can you repaste you code as described above??
anthonyjl92
@anthonyjl92
Mar 27 2016 04:22
yea one sec

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

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

return "Not found";
}

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

CamperBot
@camperbot
Mar 27 2016 04:23
:bulb: to format code use backticks! ``` more info
Ramana Venkata
@vramana
Mar 27 2016 04:23
@scottmike0 Yes.
@anthonyjl92 :frowning: Try again. You have to use ` on '
anthonyjl92
@anthonyjl92
Mar 27 2016 04:24
sorry! new to this
scottmike0
@scottmike0
Mar 27 2016 04:24
@vramana can ya help me on where I am going wrong?
Ramana Venkata
@vramana
Mar 27 2016 04:26
@scottmike0 Do you know that there is inside every function you have a arguments variable that has list of all arguments of the function it is called with ??
scottmike0
@scottmike0
Mar 27 2016 04:26
@vramana
function destroyer(arr) {
  // Remove all the values
  return arr.filter(function b(value){return value!== 2 && value!== 3 && value!== 5 && value!== "tree" && value!== 53});
}
Ramana Venkata
@vramana
Mar 27 2016 04:27
@scottmike0 You should not hard code values like that.
Tien Anh Nguyen
@tienanh2007
Mar 27 2016 04:28
can someone tell me what is this line of code is doing ?
anthonyjl92
@anthonyjl92
Mar 27 2016 04:28
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

  return "Not found";
}

// Test your code by modifying these values
checkObj("gift");
Tien Anh Nguyen
@tienanh2007
Mar 27 2016 04:28
var args = Array.prototype.slice.call(arguments);
scottmike0
@scottmike0
Mar 27 2016 04:28
@vramana how would i know the arguments?
@vramana as the function only accepts 1 param
Ramana Venkata
@vramana
Mar 27 2016 04:29
@scottmike0 arguments is reserved keyword and it is available with a function.
@scottmike0 You can declare function with no arguments but still call it with any number of arguments you like.
scottmike0
@scottmike0
Mar 27 2016 04:30
@vramana and on a side note, the hard coded method does not work, as I am not getting the 2nd part to work
Tien Anh Nguyen
@tienanh2007
Mar 27 2016 04:30
``` var args = Array.prototype.slice.call(arguments);
Tien Anh Nguyen
@tienanh2007
Mar 27 2016 04:32
could some one explain to me this line of code ?
var args = Array.prototype.slice.call(arguments);
what is .call
and is the call function only for arguments ?
scottmike0
@scottmike0
Mar 27 2016 04:33
@tienanh2007 aguments of the array
anthonyjl92
@anthonyjl92
Mar 27 2016 04:33
anyone know why this doesnt work?
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

  return "Not found";
}

// Test your code by modifying these values
checkObj("gift");
Tien Anh Nguyen
@tienanh2007
Mar 27 2016 04:33
yeah but could you explain it how it work ?
like what is it doing?
I know what the output is
but I want to know what it is doing
bitgrower
@bitgrower
Mar 27 2016 04:34
yes ... you can't use checkProp in dot notation
Ramana Venkata
@vramana
Mar 27 2016 04:34
@tienanh2007 It converts the arguments object into an array.
anthonyjl92
@anthonyjl92
Mar 27 2016 04:34
o tyty
gotta use brackets
bitgrower
@bitgrower
Mar 27 2016 04:34
I also believe the "Not found" has to be "Not Found", with a capital F, to pass
scottmike0
@scottmike0
Mar 27 2016 04:35
@vramana there I changed the code, but I still do not understand while 1 of my test cases fail
function destroyer(arr) {
  // Remove all the values
  var args = Array.prototype.slice.call(arguments);
  return arr.filter(function b(value){return value!== args[0] && value!==args[1] && value!== args[2];});
}
anthonyjl92
@anthonyjl92
Mar 27 2016 04:36
@bitgrower ty for the help!
bitgrower
@bitgrower
Mar 27 2016 04:36
yw
anthonyjl92
@anthonyjl92
Mar 27 2016 04:36
why cant we use . notation in this case
scottmike0
@scottmike0
Mar 27 2016 04:36
@vramana any hint on what exactly I am doing wrong?
DJ
@qualitymanifest
Mar 27 2016 04:37
@scottmike0 because it has more than 2 arguments
bitgrower
@bitgrower
Mar 27 2016 04:37
you can only use dot notation if it's referencing the specific property name
scottmike0
@scottmike0
Mar 27 2016 04:37
@qualitymanifest i have 3 arguments, for the return statement though
DJ
@qualitymanifest
Mar 27 2016 04:37
hmm
scottmike0
@scottmike0
Mar 27 2016 04:38
@qualitymanifest 0,1,2 = 3
bitgrower
@bitgrower
Mar 27 2016 04:38
@scottmike0 -- some of the test cases have more than 2 arguments, iirc
Ramana Venkata
@vramana
Mar 27 2016 04:38
@scottmike0 YOu need to use the arguments object to get all the arguments that your function is called with.
Is it a bit confusing??
scottmike0
@scottmike0
Mar 27 2016 04:38
@vramana yes, because i have that statement
bitgrower
@bitgrower
Mar 27 2016 04:38
@vramana -- he's grabbing the variables with the slice.call statement
Ramana Venkata
@vramana
Mar 27 2016 04:39
@scottmike0 I just saw your code.
bitgrower
@bitgrower
Mar 27 2016 04:39
I mean the arguments ...
Tien Anh Nguyen
@tienanh2007
Mar 27 2016 04:39
@vramana so does it always work ? I mean could it convert every type of Object? What kind of Object is valid for .call ?
scottmike0
@scottmike0
Mar 27 2016 04:39
@vramana i see, did ya type that before seeing or after
Ramana Venkata
@vramana
Mar 27 2016 04:39
@scottmike0 You are almost there. Instead of hardcodign args1 args2 You should use a for loop to filter.
repeatedly.
@scottmike0 I don't think so. Never got a chance to think about it. Probably on objects with length property. I don't know.
DJ
@qualitymanifest
Mar 27 2016 04:41
@scottmike0 args[0] is arr. with your failing test, the one that slips in, 5 is args[3]
bitgrower
@bitgrower
Mar 27 2016 04:41
This message was deleted
Tien Anh Nguyen
@tienanh2007
Mar 27 2016 04:41
@vramana Yep thx you I just gg it and it said the Object has to have length property
CamperBot
@camperbot
Mar 27 2016 04:41
tienanh2007 sends brownie points to @vramana :sparkles: :thumbsup: :sparkles:
:star: 218 | @vramana | http://www.freecodecamp.com/vramana
DJ
@qualitymanifest
Mar 27 2016 04:42
destroyer([3, 5, 1, 2, 2], 2, 3, 5); // for this function call:
args[0] === [3, 5, 1, 2, 2]
args[1] === 2
args[2] === 3
args[3] === 5
@scottmike0
so you could hardcode args[3] in there.... or you could just use indexOf()
bitgrower @bitgrower says ... hardcoding is oooglee
Ramana Venkata
@vramana
Mar 27 2016 04:43
@scottmike0 Array.prototype.slice documentation says It can convert Array like objects here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
qualitymanifest @qualitymanifest agrees
Ramana Venkata
@vramana
Mar 27 2016 04:44
@tienanh2007 Nice.
DJ
@qualitymanifest
Mar 27 2016 04:45
@vramana nowadays, with ES6 you could use Array.from(arguments)
bitgrower
@bitgrower
Mar 27 2016 04:45
oooh, cool, @qualitymanifest
scottmike0
@scottmike0
Mar 27 2016 04:46
okay I used a loop but I am now getting an error claiming args.length() is not a function
 var args = Array.prototype.slice.call(arguments);
function destroyer(arr) {
  // Remove all the values

  return arr.filter(function b(value){for(var i = 0;i<args.length();i++){ if(value==args[i])return value!=args[i]; } return value!== args[0];
});
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Olawale Akinseye
@brainyfarm
Mar 27 2016 04:47
@scottmike0
You so not have to loop.
jorgon1022
@jorgon1022
Mar 27 2016 04:47
hey guys can someone help me out wtih my javascript code
DJ
@qualitymanifest
Mar 27 2016 04:47
@scottmike0 .length doesnt need parenthesis. also, just read about indexOf()
Olawale Akinseye
@brainyfarm
Mar 27 2016 04:47
Sure @jorgon1022 .
jorgon1022
@jorgon1022
Mar 27 2016 04:47
I have two files. One is an html file and another is a javascript file
in my javascript file I have the following
bitgrower
@bitgrower
Mar 27 2016 04:47
your var args statement has to be within the function ...
DJ
@qualitymanifest
Mar 27 2016 04:47
and that
scottmike0
@scottmike0
Mar 27 2016 04:47
@bitgrower am using a global args
jorgon1022
@jorgon1022
Mar 27 2016 04:47
function random(){
    document.getElementById('demo').outerHTML=math.random();
}
in my html file i have this
bitgrower
@bitgrower
Mar 27 2016 04:48
the arguments object changes with every new scope
you are getting the wrong arguments object
jorgon1022
@jorgon1022
Mar 27 2016 04:48
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script type="text/javascript" src="Execution.js"> </script>
    <title>Title</title>
</head>
<body>
<p id='demo'></p>
<button onclick="random()">Generate Random Number</button>


</body>
</html>
Olawale Akinseye
@brainyfarm
Mar 27 2016 04:48
@jorgon1022
Math.random() ?
jorgon1022
@jorgon1022
Mar 27 2016 04:48
@brainyfarm so when I click the onclic button on html, it does nothing
what am i doing wrong?
Olawale Akinseye
@brainyfarm
Mar 27 2016 04:49
@jorgon1022
function random(){
    document.getElementById('demo').innerHTML=Math.random();
}
Joseph
@revisualize
Mar 27 2016 04:49
Crap. I just realized that I haven't gotten a brownie from helping that guy earlier today. Does someone need some help with something on the Free Code Camp Map?
bitgrower @bitgrower thanks @revisualize for being helpful ...
jorgon1022
@jorgon1022
Mar 27 2016 04:50
grrr. im so freaking stupid @brainyfarm . THank you @brainyfarm
CamperBot
@camperbot
Mar 27 2016 04:50
jorgon1022 sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1692 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Olawale Akinseye
@brainyfarm
Mar 27 2016 04:50
LOL @revisualize :P
Chetna
@chetna-4
Mar 27 2016 04:51
need help on seek and destroy.
Olawale Akinseye
@brainyfarm
Mar 27 2016 04:51
:wave: @bitgrower
bitgrower
@bitgrower
Mar 27 2016 04:51
I've spent hours helping someone and not gotten any brownie points ... or worse yet, thanks were given, and then @camperbot refused to see them ...
CamperBot
@camperbot
Mar 27 2016 04:51
bitgrower sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star: 1442 | @camperbot | http://www.freecodecamp.com/camperbot
Olawale Akinseye
@brainyfarm
Mar 27 2016 04:51
Explain the issue @chetna-4
CamperBot
@camperbot
Mar 27 2016 04:51
no wiki entry for: the issue @chetna-4
Ramana Venkata
@vramana
Mar 27 2016 04:51
@chetna-4 What have you tried till now??
bitgrower
@bitgrower
Mar 27 2016 04:52
great question, @vramana
Chetna
@chetna-4
Mar 27 2016 04:52
@vramana actually m confused how to pass one or more no. of arguments to the function!
bitgrower
@bitgrower
Mar 27 2016 04:52
@chetna-4 -- have you read the suggested page on the arguments object ?
scottmike0
@scottmike0
Mar 27 2016 04:53
@brainyfarm what am I doing wrong with iterating through the arguments?

function destroyer(arr) {
  // Remove all the values

  return arr.filter(function b(value){
    var args = Array.prototype.slice.call(arguments);
  for(var i = 0;i<args.length;i++)
  { if(value==args[i])
     value = false;//make it false if its one of the arguments..
  } 
                        return value;

                                     });
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Ramana Venkata
@vramana
Mar 27 2016 04:54
@chetna-4 Can you just go above an read my conversation with @scottmike0 . He is solving the same challenge
bitgrower
@bitgrower
Mar 27 2016 04:54
@scottmike0 -- you need to put the slice.call outside of the array filter callback function ... that, too, is a new scope and the argument object gets re-defined
scottmike0
@scottmike0
Mar 27 2016 04:54
@brainyfarm well to be fair, I am confused on how to set it to not be able to be the value, it seems making it false does not work
@bitgrower i see, so every function has a args?
@bitgrower and it worked
Olawale Akinseye
@brainyfarm
Mar 27 2016 04:55
@scottmike0,
@bitgrower is trying to explain to you that you need to make args global.
bitgrower
@bitgrower
Mar 27 2016 04:55
for every new scope, the arguments object gets re-defined ...
scottmike0
@scottmike0
Mar 27 2016 04:55
@bitgrower no, it did not work when global
@brainyfarm it worked when inside the local function
Joseph
@revisualize
Mar 27 2016 04:55
Well, I gotta go. Peace.
Ramana Venkata
@vramana
Mar 27 2016 04:55
@scottmike0 arguments represents the function arguments of the closest function scope. But you want the arguments of destroyer function so you have to use arguments outside. Does it make sense?
@revisualize Got your brownie points??
bitgrower
@bitgrower
Mar 27 2016 04:56
LOL ... not sure what @brainyfarm was saying, but that wasn't what I was saying, as I already told ya not to put it outside the function ...
Joseph
@revisualize
Mar 27 2016 04:56
Naw. I guess I didn't earn one today.
It's all good.
scottmike0
@scottmike0
Mar 27 2016 04:56
@vramana not really, because i got different results when i had it within the function versuses inside the inner function vs global
Chetna
@chetna-4
Mar 27 2016 04:56
@bitgrower yup i did but still i dont know how to decide 'the no.' of arguments! @vramana okay :)
bitgrower @bitgrower feels like chopped liver ... sheesh !!! Gives @revisualize a brownie point and doesn't get acknowledged .. sniff !!!
bitgrower
@bitgrower
Mar 27 2016 04:57
one of the few properties an arguments object has is length ... :)
scottmike0
@scottmike0
Mar 27 2016 04:58
@bitgrower @vramana @brainyfarm thanks though
CamperBot
@camperbot
Mar 27 2016 04:58
scottmike0 sends brownie points to @bitgrower and @vramana and @brainyfarm :sparkles: :thumbsup: :sparkles:
Clare Dickerson
@claredickerson
Mar 27 2016 04:58

For this task: "Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator." the code I am given is

var remainder;

Am I supposed to add the equation to it, under it, or in place of it? This task doesn't make as much sense to me (no clear example given.)

CamperBot
@camperbot
Mar 27 2016 04:58
:star: 1693 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
:star: 219 | @vramana | http://www.freecodecamp.com/vramana
Ramana Venkata
@vramana
Mar 27 2016 04:58
@chetna-4 arguments.length is the number of arguments the function is called with. Just read about arguments. And look at couple of examples
CamperBot
@camperbot
Mar 27 2016 04:58
:star: 932 | @bitgrower | http://www.freecodecamp.com/bitgrower
DJ
@qualitymanifest
Mar 27 2016 04:59
var remainder = the remainder of 11 divided by 3 using the remainder (%) operator
bitgrower
@bitgrower
Mar 27 2016 04:59
awww @scottmike0 -- that wasn't for you ... that was because @revisualize said they hadn't gotten any brownie points today, when I gave them one ...
thanks, though !!!
scottmike0
@scottmike0
Mar 27 2016 05:00
@bitgrower huh
Olawale Akinseye
@brainyfarm
Mar 27 2016 05:00
@bitgrower
I was saying to move the args outside of filter so it is not redefined multiple times.
I might have misused the word global
DJ
@qualitymanifest
Mar 27 2016 05:00
@claredickerson to get remainders using modulo you do like 3 % 2 (which equals 1). here they want you to assign it to var remainder
bitgrower
@bitgrower
Mar 27 2016 05:01
LOL ... yeah, probably @brainyfarm ... had just had @scottmike0 move an args def from outside the destroyer function to INSIDE ... but then he moved it WAY inside ... into the filter callback ...
Miguel T Rivera
@mtrivera
Mar 27 2016 05:02
wiki where
CamperBot
@camperbot
Mar 27 2016 05:02

:point_right: algorithm where art thou [wiki]

Problem Explanation

Write an algorithm that will take an array for the first argument and return an array with all the objects that matches all the properties and values in the Object passed as second parameter.

:pencil: read more about algorithm where art thou on the FCC Wiki

Miguel T Rivera
@mtrivera
Mar 27 2016 05:02
wiki belong
CamperBot
@camperbot
Mar 27 2016 05:02

:point_right: algorithm where do i belong [wiki]

Explanation:

This can be a tricky problem to understand. You need to find where in the array a number should be inserted by order, and return the index where it should go.

:pencil: read more about algorithm where do i belong on the FCC Wiki

bitgrower
@bitgrower
Mar 27 2016 05:02
is that the right "where", @migueltrivera -- we have a couple of challenges which have "where" in them ...
scottmike0
@scottmike0
Mar 27 2016 05:03
@brainyfarm how does array.filter work, like does it create a new whole array or does it slice?
Ramana Venkata
@vramana
Mar 27 2016 05:03
@scottmike0 It creates a new array.
bitgrower
@bitgrower
Mar 27 2016 05:03
new array, @scottmike0 ...
Miguel T Rivera
@mtrivera
Mar 27 2016 05:03
@bitgrower i wanted the second one
bitgrower
@bitgrower
Mar 27 2016 05:03
okay ...
scottmike0
@scottmike0
Mar 27 2016 05:03
@brainyfarm oh
bitgrower
@bitgrower
Mar 27 2016 05:03
.hasOwnProperty, and deep indexing, are your friends ... :) @migueltrivera
scottmike0
@scottmike0
Mar 27 2016 05:04
how does the paramaters accept a function then?
is it simply function bob(function ?)
Ramana Venkata
@vramana
Mar 27 2016 05:05
@bitgrower I never use hasOwnProperty. Is it really needed??
@scottmike0 That is function declaration. You can call bob(function () {})
bitgrower
@bitgrower
Mar 27 2016 05:05
@vramana ... that was for "Where Art Thou" -- and if you get to "Where Art Thou" without using .hasOwnProperty, something's wrong
Ramana Venkata
@vramana
Mar 27 2016 05:06
Ah
DJ
@qualitymanifest
Mar 27 2016 05:06
@scottmike0 someArray.filter() works such that it removes pieces of an array that the filter function you use declares to be false, and keeps the ones that are true.
scottmike0
@scottmike0
Mar 27 2016 05:06
@vramana yeah i was refering to how to declare a function passing into a function
samamsam
@samsamam
Mar 27 2016 05:06
Hi Coders I am having trouble with this code it seems fine but cant find where is the error help would be appreciated thanks
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) {

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

  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
bitgrower
@bitgrower
Mar 27 2016 05:06
why wouldn't you want to use .hasOwnProperty -- it's a great function!!! It's like indexOf for Objects ...
Ramana Venkata
@vramana
Mar 27 2016 05:06
@scottmike0 Just pass it's name bob(myFunction)
bitgrower
@bitgrower
Mar 27 2016 05:07
@scottmike0 ... all your callback functions are examples of a function being passed a function as a parameter...
scottmike0
@scottmike0
Mar 27 2016 05:07
@vramana that is passing, I was refering to declaring a function that has a params as a function. Is there a specific way or how do you know the function's name
bitgrower
@bitgrower
Mar 27 2016 05:08

when you say array.filter (function (myVar) {

... that's passing a function as a parameter ... but it's also defining the function at the same time...

scottmike0
@scottmike0
Mar 27 2016 05:08
@bitgrower i know that
Ramana Venkata
@vramana
Mar 27 2016 05:09
@scottmike0 You just treat it as another variable.
bitgrower
@bitgrower
Mar 27 2016 05:09
k ... just trying to shore up related information to your question ...
scottmike0
@scottmike0
Mar 27 2016 05:09
@bitgrower am refering to how to set up a function that passes in another function
like
bitgrower
@bitgrower
Mar 27 2016 05:09
@scottmike0 -- there is at least one challenge where you see that done ...
Ramana Venkata
@vramana
Mar 27 2016 05:10
@bitgrower I guess I am addicted to Object.keys() So, I never use it.
bitgrower
@bitgrower
Mar 27 2016 05:10
...and, in fact, call the function that was passed in ...
scottmike0
@scottmike0
Mar 27 2016 05:10
function myfunction(randomfunction()){  };// is it like that
Ramana Venkata
@vramana
Mar 27 2016 05:10
@scottmike0 No. Let me write an example
bitgrower
@bitgrower
Mar 27 2016 05:10
function myfunction(randomfunction)
if you put parens there it will try to execute the function immediately
scottmike0
@scottmike0
Mar 27 2016 05:11
@bitgrower i see
Ramana Venkata
@vramana
Mar 27 2016 05:11
function executeFn(func) {

  return func();
}

executeFn(function () { return 2} );
scottmike0
@scottmike0
Mar 27 2016 05:12
@vramana in order for that to work, func() cannot be void?
DJ
@qualitymanifest
Mar 27 2016 05:13
This message was deleted
Ramana Venkata
@vramana
Mar 27 2016 05:13
@scottmike0 You can pass nothing in which case it will throw an error that's all. Also void is not term you want to use in JS. Do you mean to say called with no arguments??
samamsam
@samsamam
Mar 27 2016 05:13
Hi Coders
Ramana Venkata
@vramana
Mar 27 2016 05:14
@samsamam Hey Give me a sec. I'll go over your code.
samamsam
@samsamam
Mar 27 2016 05:14
@vramana thanks
CamperBot
@camperbot
Mar 27 2016 05:14
samsamam sends brownie points to @vramana :sparkles: :thumbsup: :sparkles:
:star: 220 | @vramana | http://www.freecodecamp.com/vramana
scottmike0
@scottmike0
Mar 27 2016 05:15
@vramana or Can a void function be written like this
function executeFn(func){
func();
}
executeFn(function()  {var b = 2;})
DJ
@qualitymanifest
Mar 27 2016 05:16
@scottmike0 whoops, made some corrections: https://repl.it/Bzp6/2
scottmike0
@scottmike0
Mar 27 2016 05:16
@qualitymanifest
DJ
@qualitymanifest
Mar 27 2016 05:16
@scottmike0 no ints in JS.... only vars
Ramana Venkata
@vramana
Mar 27 2016 05:16
@scottmike0 You mean return value is undefined Yes you can
scottmike0
@scottmike0
Mar 27 2016 05:16
am not focused on filter, was focused on that
@qualitymanifest i mean var
Chetna
@chetna-4
Mar 27 2016 05:17
plz explain me the working of filter method. I am not getting it clearly.
DJ
@qualitymanifest
Mar 27 2016 05:17
scottmike0
@scottmike0
Mar 27 2016 05:17
@vramana soo is that code possible?
DJ
@qualitymanifest
Mar 27 2016 05:17
@scottmike0 what are you trying to accomplish there
Coy Sanders
@coymeetsworld
Mar 27 2016 05:17
bitgrower
@bitgrower
Mar 27 2016 05:18
yay MDN
Ramana Venkata
@vramana
Mar 27 2016 05:18
@samsamam You have write collection[id] not collection.id Can you see why??
scottmike0
@scottmike0
Mar 27 2016 05:19
@qualitymanifest i am not sure what I was trying to accomplish besides testing if a function with no return can be used like that
Ramana Venkata
@vramana
Mar 27 2016 05:19
@qualitymanifest I think it better to show documentation as first resource. Because one needs to get used to reading documentation.
@scottmike0 Yes it is possible. I write functions like that all the time.
Chetna
@chetna-4
Mar 27 2016 05:19
@coymeetsworld yup i saw the documentation but it didnt become clear in my mind! now i get it ! thanx @qualitymanifest
CamperBot
@camperbot
Mar 27 2016 05:19
chetna-4 sends brownie points to @coymeetsworld and @qualitymanifest :sparkles: :thumbsup: :sparkles:
Chetna
@chetna-4
Mar 27 2016 05:19
:)
CamperBot
@camperbot
Mar 27 2016 05:19
:star: 400 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
:star: 1120 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Coy Sanders
@coymeetsworld
Mar 27 2016 05:21
ah ok @chetna-4 , its basically does as the name suggests, filter an array based on some criteria. The criteria being represented in an anonymous function
or rather any function, doesn't have to be anonymous
Paul Borawski
@iAmNawa
Mar 27 2016 05:23

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 = 0;
this.setGear= function(change){
gear += change;
};
this.getGear = function() {
return gear;
};

};

var myCar = new Car();

var myBike = new Bike();

can someone help me with this one?
Ramana Venkata
@vramana
Mar 27 2016 05:23
@iAmNawa Can you format your code??
samamsam
@samsamam
Mar 27 2016 05:23
@vramana tried this code but still doesnt work
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) {

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

  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
scottmike0
@scottmike0
Mar 27 2016 05:24
@iAmNawa whats the goal with the code
Paul Borawski
@iAmNawa
Mar 27 2016 05:24
myBike.getGear() should return 4 after calling myBike.setGear(4).
myBike.getGear() should return 3 after calling myBike.setGear(3).
myBike.getGear() should return 1 after calling myBike.setGear(1).
it’s weird becayse the first one is passing and the second two are not
Ramana Venkata
@vramana
Mar 27 2016 05:25
@samsamam It should be collection[id][prop] Do you understand how to read a property from an object??
samamsam
@samsamam
Mar 27 2016 05:25
object.property ? @vramana
Ramana Venkata
@vramana
Mar 27 2016 05:26
@iAmNawa Can you format your code or use something like gist?? Since your code is extremely long. It obstructs other messages.
Dylan Pagillo
@DylanNeil
Mar 27 2016 05:26
help nesting for loops
CamperBot
@camperbot
Mar 27 2016 05:26

:point_right: challenge nesting for loops [wiki]

Challenge: Nesting For Loops

If you have a multi-dimensional array, you can use the same logic as the prior Challenge to loop through both the array and any sub-arrays. Here is an example:

    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]);
      }
    }

This outputs each sub-element in arr one at a time. Note that for the inner loop, we are checking the .length of arr[i], since arr[i] is itself an array.
:pencil: read more about challenge nesting for loops on the FCC Wiki

Ramana Venkata
@vramana
Mar 27 2016 05:26
@samsamam Yes. or object['property']
Paul Borawski
@iAmNawa
Mar 27 2016 05:26
how do i post in black like that?
Ramana Venkata
@vramana
Mar 27 2016 05:26
help format
CamperBot
@camperbot
Mar 27 2016 05:26

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Ramana Venkata
@vramana
Mar 27 2016 05:27
@samsamam collection[[id][prop.value]] What do you think meaning of this is??
Paul Borawski
@iAmNawa
Mar 27 2016 05:28
fssd
samamsam
@samsamam
Mar 27 2016 05:28
@vramana it gets the id then goes into the property to get the value
Ramana Venkata
@vramana
Mar 27 2016 05:29
@samsamam Nope.
If you want to read property of object it is simply obj[prop] where prop is string. collection[id] returns an object. So when you want to read a property of that object you need to write collection[id][prop]
scottmike0
@scottmike0
Mar 27 2016 05:32
Why does array.sort not work
array.sort();
samamsam
@samsamam
Mar 27 2016 05:32
@vramana tried this
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) {

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

  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
Ramana Venkata
@vramana
Mar 27 2016 05:32
@scottmike0 JavaScript is crazy man.
@samsamam What is prop.value ??
samamsam
@samsamam
Mar 27 2016 05:33
@vramana wait up
Ramana Venkata
@vramana
Mar 27 2016 05:33
@scottmike0 You will get used to it.
scottmike0
@scottmike0
Mar 27 2016 05:33
@vramana why is arr.sort based on unicode...
Ramana Venkata
@vramana
Mar 27 2016 05:33
@samsamam Okay.
Dylan Pagillo
@DylanNeil
Mar 27 2016 05:33
Nesting For Loops, having a hard time figuring out this one. Could anyone nudge me in the right direction
Ramana Venkata
@vramana
Mar 27 2016 05:33
@scottmike0 I don't know man. I just got used to it.
scottmike0
@scottmike0
Mar 27 2016 05:34
@vramana i see, i will just have to convert it into a sorted array...
samamsam
@samsamam
Mar 27 2016 05:35
@vramana prop.value gets the value of the property ?
Ramana Venkata
@vramana
Mar 27 2016 05:35
@samsamam What is value of prop in you function call??
samamsam
@samsamam
Mar 27 2016 05:35
@vramana "artist"
Ramana Venkata
@vramana
Mar 27 2016 05:37
@samsamam yes. So prop = 'artist' Now prop is not an object so prop.value doesn't make sense.
@samsamam Can you rethink what you are writing? May be you have the idea. Try to rethink.
jorgon1022
@jorgon1022
Mar 27 2016 05:41
hi guys
Ramana Venkata
@vramana
Mar 27 2016 05:41
@jorgon1022 Hi
jorgon1022
@jorgon1022
Mar 27 2016 05:41
any of you available for some troubleshooting help?\
<body>
    <div style="width: 25%;margin:10% auto;">
        <form id="submitted">
            First Name: <input id="firstname">
            <br>
            Last Name: <input id="lastname">
            <br>
            Email Address: <input id="email">
            <br>
            Phone: <input id="phone">
            <br>
            Subject You need Help With:
            <br>
            Pre-Algebra<input type="radio" name="subject" value="Pre Algebra">
            <br>
            Algebra<input type="radio" name="subject" value="Algebra">
            <br>
            Trigonometry<input type="radio" name="subject" value="Trigonometry">


<button onclick="submit()">Submit</button>
<br>
<p id='demo'></p>
</form>
</div>
</body>
Ramana Venkata
@vramana
Mar 27 2016 05:42
We are here to help.
jorgon1022
@jorgon1022
Mar 27 2016 05:42
check out this code @vramana
what I am trying to do is use this javascript function to submit my work but for some reason its not working. what am I missing?
samamsam
@samsamam
Mar 27 2016 05:43
@vramana so if i use [] notation to dig to the value of the property it should work otherwise we cant access value just by comparing value with the condition
jorgon1022
@jorgon1022
Mar 27 2016 05:43
```

function submit(){
    var firstName=document.getElementById('demo').innerHTML;
}
Ramana Venkata
@vramana
Mar 27 2016 05:43
@jorgon1022 Which challenge is this??
jorgon1022
@jorgon1022
Mar 27 2016 05:44
@vramana its actually not a challenge
Ia m trying to build a simple web form
Ramana Venkata
@vramana
Mar 27 2016 05:44
@samsamam Can you rephrase your second half of the statement?? It's a bit confusing.
samamsam
@samsamam
Mar 27 2016 05:45
@vramana collection[id][prop][value] to get the value from the collection ?
Ramana Venkata
@vramana
Mar 27 2016 05:45
@jorgon1022 Okay. Do you know jQuery?? Just asking.
jorgon1022
@jorgon1022
Mar 27 2016 05:46
@vramana I dont. I am learning javascript little by little
Dylan Pagillo
@DylanNeil
Mar 27 2016 05:47

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0;i < product.length; i++){
for ( var j=0; j < product[i].length; product[j] *= product[j + 1]){
console.log(product[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]]);

Ramana Venkata
@vramana
Mar 27 2016 05:47
@jorgon1022 Then probably you have to read the basics a little more. I can help but I feel that you won't get much.
Dylan Pagillo
@DylanNeil
Mar 27 2016 05:47
This is what I have for Nesting For Loops
not working, any advice?
Ramana Venkata
@vramana
Mar 27 2016 05:47
@DylanNeil Can you format your code??
help format
CamperBot
@camperbot
Mar 27 2016 05:47

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Ramana Venkata
@vramana
Mar 27 2016 05:48
@DylanNeil Where are you incrementing the j variable??
Dylan Pagillo
@DylanNeil
Mar 27 2016 05:50
@vramana length; product[j] *= product[j + 1]
I tried replacing the increment with this
Ramana Venkata
@vramana
Mar 27 2016 05:50
@DylanNeil I don't think it works. You have to increment it like j = j + 1
@DylanNeil Then j will always be 0 it will never increment.
Dylan Pagillo
@DylanNeil
Mar 27 2016 05:51
right that makes sense
@vramana I kept coming up with with 1 for every answer
@vramana I'm also supposed to find the product of every number in each sub array
@vramana thats the part I'm having trouble figuring out
Ramana Venkata
@vramana
Mar 27 2016 05:52
@DylanNeil Which challenge is this.
Dylan Pagillo
@DylanNeil
Mar 27 2016 05:52
Nesting For Loops
@vramana Nesting For Loops
Ramana Venkata
@vramana
Mar 27 2016 05:53
@DylanNeil Give me a sec
Mariya
@mariyadiminsky
Mar 27 2016 05:56
Hey guys, my code is crashing. This code is freezing my page, I can't figure out where the error is, any advice? The goal is to find the roman numeral of the number given:
function romanNumeral(n) {
    var numConversion = {
        1000: "M",
        900 : "CM",
        500 : "D",
        400 : "CD",
        100 : "C",
        90 : "XC",
        50 : "L",
        40 : "XL",
        10 : "X",
        9 : "IX",
        5 : "V",
        4 : "IV",
        1 : "I",
    }

    var result = "";

    function recurse(thisNum) {
        for(var num in numConversion) {
            if(thisNum === 0) { // base case
                return result;
            }else if(thisNum >= num) { // if 1012 >= 1000 true
                result += numConversion[num]; // result="M"
                recurse(thisNum - num); // 1012 - 1000 = 12
            }
        }

    }

    recurse(n);

    return result;
}

console.log(romanNumeral(900)); // CM
console.log(romanNumeral(843)); // DCCCXLIII
console.log(romanNumeral(12)) // XII
console.log(romanNumeral(493)) // CDXCIII
Ramana Venkata
@vramana
Mar 27 2016 05:56
@DylanNeil Can you write a function that multiplies a array of numbers ??
I am breaking the problem down.
Leah H
@leah-h
Mar 27 2016 05:57
This message was deleted
samamsam
@samsamam
Mar 27 2016 05:58
@vramana okay i got this code now
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) {

if ((collection[id][prop] !== "") && (prop !== "tracks"))

  {
    collection.push[id][prop] = collection[id][prop];
  }
else if(collection[id][prop] === "")
  {
    delete collection[id][prop];
  }

  return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");
@vramana its accessing the property through this collection[id][prop]
Ramana Venkata
@vramana
Mar 27 2016 06:00
@samsamam Do you understand what it means to indent code??
samamsam
@samsamam
Mar 27 2016 06:01
@vramana make spaces
Leah H
@leah-h
Mar 27 2016 06:01
I need some help please!
function truncateString(str, num) {
  // Clear out that junk in your trunk
  var newString = 0;

  if (num <= 3){
    newStr = str.slice(0, num);
  return newStr + "...";
  }
 else {  newStr = str.slice(0, (num - 3));
return newStr + "...";
}
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Ramana Venkata
@vramana
Mar 27 2016 06:02
@samsamam In a sense yeah. Can you indent your code?? It makes it easy to spot mistakes.
Leah H
@leah-h
Mar 27 2016 06:03
I'm not sure how to solve (str.length + 2)
Coy Sanders
@coymeetsworld
Mar 27 2016 06:04
@leah-h you're not checking if the string is less than the number provided
samamsam
@samsamam
Mar 27 2016 06:04
@vramana is this better indent
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) 
{

if ( (collection[id][prop] !== "") && (prop !== "tracks") )

  {

    collection.push[id][prop] = collection[id][prop];

  }
else if(collection[id][prop] === "")

  {

    delete collection[id][prop];

  }

  return collection;

}

// Alter values below to test your code
update(5439, "artist", "ABBA");
Ramana Venkata
@vramana
Mar 27 2016 06:05
@samsamam Nope not really. Let me show you.
Coy Sanders
@coymeetsworld
Mar 27 2016 06:05
@leah-h which tests are failing?
oh also you're using an undefined variable
Ramana Venkata
@vramana
Mar 27 2016 06:06
function update(id, prop, value) {

    if ((collection[id][prop] !== "") && (prop !== "tracks")) {
        collection.push[id][prop] = collection[id][prop];
    } else if(collection[id][prop] === "") {
        delete collection[id][prop];
    }

  return collection;
}
Coy Sanders
@coymeetsworld
Mar 27 2016 06:06
you have newString declared(which should be initialized with '' not 0) but you're using newStr which is not defined
samamsam
@samsamam
Mar 27 2016 06:08
@vramana thats indented ?
Ramana Venkata
@vramana
Mar 27 2016 06:09
@samsamam yeah New line after every line of code isnot going make it eaier to read.
@samsamam It decreases readability.
samamsam
@samsamam
Mar 27 2016 06:12
@vramana okay
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) 
{if ( (collection[id][prop] !== "") && (prop !== "tracks") ){
    collection.push[id][prop] = collection[id][prop];
    }
else if(collection[id][prop] === ""){
    delete collection[id][prop];}
return collection;
}
// Alter values below to test your code
update(5439, "artist", "ABBA");
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:12
@vramana hello, thanks, sorry I had to step away from my computer for a minute
CamperBot
@camperbot
Mar 27 2016 06:12
dylanneil sends brownie points to @vramana :sparkles: :thumbsup: :sparkles:
:star: 221 | @vramana | http://www.freecodecamp.com/vramana
Ramana Venkata
@vramana
Mar 27 2016 06:12
@DylanNeil It's okay
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:12
@vramana hang on, let me work that out quick
Ramana Venkata
@vramana
Mar 27 2016 06:12
@DylanNeil Sure
samamsam
@samsamam
Mar 27 2016 06:12
@vramana is that better can u spot the error now
Ramana Venkata
@vramana
Mar 27 2016 06:13
@samsamam Can you explain what is the first if condition supposed to do??
samamsam
@samsamam
Mar 27 2016 06:14
@vramana
If value is non-blank (value !== "") and prop is not "tracks"
Ramana Venkata
@vramana
Mar 27 2016 06:15
@samsamam Which challenge is this ? I forgot sorry.
samamsam
@samsamam
Mar 27 2016 06:15
@vramana Record Collection
Jaymin
@JamesPatel37
Mar 27 2016 06:16
I am stuck on the same problem
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:16
@vramana num[i] *= num[i + 1];
something like that
@vramana something like that
Ramana Venkata
@vramana
Mar 27 2016 06:16
@DylanNeil Write a complete function. We need it.
@samsamam Okay. What are you trying to do in the next line?? collection.push[id][prop] = collection[id][prop];
Leah H
@leah-h
Mar 27 2016 06:17
@coymeetsworld these two are not working:
truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length) should return "A-tisket a-tasket A green and yellow basket".
truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2) should return "A-tisket a-tasket A green and yellow basket".
Coy Sanders
@coymeetsworld
Mar 27 2016 06:18
did you look at what I wrote before? @leah-h you're using different variable names
samamsam
@samsamam
Mar 27 2016 06:19
sorry my bad it should be

 collection[id][prop] = collection.push[id][prop];
    }
  if(collection[id][prop] === "")
@vramana
Ramana Venkata
@vramana
Mar 27 2016 06:19
@samsamam What is collection.push ??
samamsam
@samsamam
Mar 27 2016 06:19
it pushes a value into the array at the end of it
Ramana Venkata
@vramana
Mar 27 2016 06:20
@samsamam Can you read the question once more??
@samsamam What is the type of collection??
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:20
@vramana function multiplyAll(arr){
var product = 1;
for (var i=0; i <product.length; i++){
product[i] *= product[i+1];
}
}
Ramana Venkata
@vramana
Mar 27 2016 06:20
@DylanNeil Are you sure?? can you check it again??
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:20
@vramana Something like that, that's if we are not talking about nested arrays
Ramana Venkata
@vramana
Mar 27 2016 06:21
@DylanNeil Simple plain array with positive numbers
Can you run it with [1,2, 3, 4, 5] it should give 60.
@DylanNeil What is the type of product??
@DylanNeil Are you in hurry ??
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:23
@vramana nope not in a hurry
@vramana trying to figure this out lol
Ramana Venkata
@vramana
Mar 27 2016 06:24
No offence meant. I am not in hurry either. You can take your time to give a proper solution rather than giving some solution which you may think works. If you are struck, I can help you.
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:24
@vramana do you know of any testing environments browser based
Leah H
@leah-h
Mar 27 2016 06:25
@coymeetsworld sorry. now i see what you meant.
Ramana Venkata
@vramana
Mar 27 2016 06:25
@DylanNeil Testing environments Just call the function. with some input. Use repl.it
@DylanNeil What is the type of product ??
Coy Sanders
@coymeetsworld
Mar 27 2016 06:26
@leah-h np did you get it?
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:27
@product is the name of the array
Ramana Venkata
@vramana
Mar 27 2016 06:28
@DylanNeil Read your function once.
@DylanNeil Did you get what I am saying??
meghana
@meghanasarikonda
Mar 27 2016 06:30
<function diff(arr1, arr2) {
  var resArr=[];
  var newArr = arr1.concat(arr2);

  for(var i=0;i<newArr.length;i++){
   if(newArr[-1]===newArr[newArr.indexOf(newArr[i],i+1)]){
      resArr.push(newArr[i]);
      }

  }                                          // Same, same; but different. 


  return resArr;
}

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
>
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:30
@vramana no, I;m sorry
meghana
@meghanasarikonda
Mar 27 2016 06:30
what is wrong with my code
Ramana Venkata
@vramana
Mar 27 2016 06:31
@DylanNeil What is the argument of your function?
@meghanasarikonda Give me a sec to go over your code. Are you doing the symmetric difference challenge??
meghana
@meghanasarikonda
Mar 27 2016 06:32
@vramana yeah
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:32
@vramana product is the argument of the function
Ramana Venkata
@vramana
Mar 27 2016 06:32
@DylanNeil No need to say sorry. You are just learning.
@DylanNeil
function multiplyAll(arr){
    var product = 1;
    for (var i=0; i <product.length; i++){
       product[i] *= product[i+1];
   }
}
From this it doesn't seem so.
anthonyjl92
@anthonyjl92
Mar 27 2016 06:33
'''
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
CamperBot
@camperbot
Mar 27 2016 06:33
:bulb: to format code use backticks! ``` more info
Leah H
@leah-h
Mar 27 2016 06:34
@coymeetsworld thanks! you're right about on both points. thx!!!
CamperBot
@camperbot
Mar 27 2016 06:34
leah-h sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
Ramana Venkata
@vramana
Mar 27 2016 06:34
@DylanNeil Isn't arr the argument of your function??
CamperBot
@camperbot
Mar 27 2016 06:34
:star: 406 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Mar 27 2016 06:34
alright cool, gj @leah-h :thumbsup:
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:34
yes!
@vramana yes
Ramana Venkata
@vramana
Mar 27 2016 06:34
@meghanasarikonda Can you describe your algorithm in words??
anthonyjl92
@anthonyjl92
Mar 27 2016 06:34
'''
var obj=
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
'''
does obj.likes return the array?
CamperBot
@camperbot
Mar 27 2016 06:34
:bulb: to format code use backticks! ``` more info
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:35
@vramana vocabulary error, a function is called with in argument, in this case arr
Ramana Venkata
@vramana
Mar 27 2016 06:35
@DylanNeil Now read the function and tell me that is the type of product?
anthonyjl92
@anthonyjl92
Mar 27 2016 06:36
'''js
var obj= {
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
'''
does obj.likes return the whole array?
CamperBot
@camperbot
Mar 27 2016 06:36
:bulb: to format code use backticks! ``` more info
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:37
@vramana can you explain what you mean by "type" of product
Jaymin
@JamesPatel37
Mar 27 2016 06:38
@samsamam -

function update(id, prop, value) {

if (value !== "" && prop == "tracks") {
collection[id][prop].push(value);
}

if (value !== "" && prop != "tracks") {
collection[id][prop] = value;
}

if(value === "") {
delete collection[id][prop];
}

return collection;
}

Ramana Venkata
@vramana
Mar 27 2016 06:38
@DylanNeil Is it an array or an object or a number or a string??
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:38
got it, it is number
@vramana got it, it is a number
Ramana Venkata
@vramana
Mar 27 2016 06:39
@DylanNeil Now read the next line the for-loop.
Do you see anything wrong there??
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:40
for (var i=0; i <product.length; i++) @vramana
@vramana product is already initialized to 1, so the for loop stops at 1?
Ramana Venkata
@vramana
Mar 27 2016 06:41
What will be value of product.length??
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:41
@vramana 1
Ramana Venkata
@vramana
Mar 27 2016 06:41
@DylanNeil No.
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:41
@vramana 0
Ramana Venkata
@vramana
Mar 27 2016 06:41
product.length will be undefined.
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:41
@vramana because it is not an array?
Ramana Venkata
@vramana
Mar 27 2016 06:42
Yeah.
So what should be there instead of product ??
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:42
@vramana arr?
Ramana Venkata
@vramana
Mar 27 2016 06:42
Correct
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:43
@vramana also change product to arr on the next line? product[i] *= product[i+1];
@vramana wait no
leave it
Ramana Venkata
@vramana
Mar 27 2016 06:44
@DylanNeil yeah but that is not completely correct Think about it.
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:44
@vramana because I am multiplying numbers
@vramana nothing is being returned?
samamsam
@samsamam
Mar 27 2016 06:45
@JamesPatel37 thanks heaps
CamperBot
@camperbot
Mar 27 2016 06:45
samsamam sends brownie points to @jamespatel37 :sparkles: :thumbsup: :sparkles:
:star: 221 | @jamespatel37 | http://www.freecodecamp.com/jamespatel37
Ramana Venkata
@vramana
Mar 27 2016 06:47
@DylanNeil what is product[i] when product = 1 ??
It throws an error.
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:49
@vramana because product = 2 things? What about arr[i] *= arr[i+1];
@vramana with no variable product
Ramana Venkata
@vramana
Mar 27 2016 06:49
@DylanNeil What will that do ??
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:51
@vramana take element i in my array, and multiply it by the next element in the array, until I reach the end of the array
@vramana Or at least that's what I'm trying to achieve
Ramana Venkata
@vramana
Mar 27 2016 06:52
@DylanNeil This is not very good way.
@DylanNeil Let's do something more simple. Can you sum all numbers from 0 to 100 with a for-loop??
Dylan Pagillo
@DylanNeil
Mar 27 2016 06:54
@vramana okay hang on
Ramana Venkata
@vramana
Mar 27 2016 06:56
@DylanNeil Sure.
Jaymin
@JamesPatel37
Mar 27 2016 07:01
@samsamam you're welcome. :smile:
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:01
@vramana for(int i = 0; i <= 100; i++)
Ramana Venkata
@vramana
Mar 27 2016 07:02
@DylanNeil Is it all??
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:03

@vramana and then something like function sunOf(){
sum = 0
for(int i = 0; i <= 100; i++);
sum = sum += i;

return sum

}

Ramana Venkata
@vramana
Mar 27 2016 07:04
@DylanNeil Almost can you check the line inside for loop??
@DylanNeil Also format your code. It is harder to read it.
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:09
function sumOf(){
sum = 0
for(i = 0; i <= 100; i++){
sum = sum += i;
}
return sum
}
@vramana
@vramana sorry, I'm trying to figure out how to print my code in black in the chat box
SHUBHAM CHARAN PAHARI
@charan-pahari
Mar 27 2016 07:12

Remove all the backslashes ()
You should have two single quotes ' and four double quotes "
Only remove the backslashes \ used to escape quotes.

var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>"

i am not getting the output
hey someone help me
Ramana Venkata
@vramana
Mar 27 2016 07:15
@DylanNeil
help format
CamperBot
@camperbot
Mar 27 2016 07:15

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Dylan Pagillo
@DylanNeil
Mar 27 2016 07:16
function sumOf(){
    sum = 0
    for(i = 0; i <= 100; i++){
        sum = sum += i;
    }
    return sum
}
cool, thank you @vramana
CamperBot
@camperbot
Mar 27 2016 07:16
dylanneil sends brownie points to @vramana :sparkles: :thumbsup: :sparkles:
:star: 222 | @vramana | http://www.freecodecamp.com/vramana
SHUBHAM CHARAN PAHARI
@charan-pahari
Mar 27 2016 07:17
@camperbot
Sidharth Kriplani
@sidkrip
Mar 27 2016 07:17
wiki Sum All Odd Fibonacci Numbers
CamperBot
@camperbot
Mar 27 2016 07:17

:point_right: algorithm sum all odd fibonacci numbers [wiki]

Explanation:

You will need to gather all the Fibonacci numbers and then check for the odd ones. Once you get the odd ones then you will add them all. The last number should be the number given as a parameter if it actually happens to be an off Fibonacci number.

:pencil: read more about algorithm sum all odd fibonacci numbers on the FCC Wiki

SHUBHAM CHARAN PAHARI
@charan-pahari
Mar 27 2016 07:17
help me plz
CamperBot
@camperbot
Mar 27 2016 07:17
no wiki entry for: me plz
Ramana Venkata
@vramana
Mar 27 2016 07:17
@DylanNeil You need to declare var sum = 0;
Sidharth Kriplani
@sidkrip
Mar 27 2016 07:17
@camperbot lol it trolled you @camperbot
  • @charan-pahari
what do you need help with?
SHUBHAM CHARAN PAHARI
@charan-pahari
Mar 27 2016 07:18

Remove all the backslashes ()
You should have two single quotes ' and four double quotes "
Only remove the backslashes \ used to escape quotes.

var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link<

i am not getting outpu
output*
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:20
function sumOf(){
    var sum = 0;
    for(i = 0; i <= 100; i++){
        sum = sum += i;
    }
    return sum;
}
Ramana Venkata
@vramana
Mar 27 2016 07:20
@DylanNeil Inside for-loop. Do you understand how += operator works ??
Jiimms
@jiimms
Mar 27 2016 07:21
i finished all bonfire exercises and then wanted to see if there are any other solutions availlable on the net. I came across afreecodecamper's page and opened it, now all my solutions are overwritten :worried: . is there any way for me to get my code back?
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:21
function sumOf(){
    var sum = 0;
    for(i = 0; i <= 100; i++){
        sum = sum += i;
    }
    return sum;
}
sumOf();
Joseph
@revisualize
Mar 27 2016 07:21
@bitgrower You didn't give me a brownie point.
revisualize @revisualize wants to inform @bitgrower that when you say thanks via a /me @camperbot doesn't see it.
CamperBot
@camperbot
Mar 27 2016 07:22
revisualize sends brownie points to @bitgrower and @camperbot :sparkles: :thumbsup: :sparkles:
Sidharth Kriplani
@sidkrip
Mar 27 2016 07:22
@charan-pahari challenge name?
CamperBot
@camperbot
Mar 27 2016 07:22
:star: 1444 | @camperbot | http://www.freecodecamp.com/camperbot
:star: 933 | @bitgrower | http://www.freecodecamp.com/bitgrower
Joseph
@revisualize
Mar 27 2016 07:22
Or didn't.
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:22
@vramana yes, the += operator sets the value of the left to equal to itself plus the value on the right
Joseph
@revisualize
Mar 27 2016 07:22
That's messed up.
Anyhow, I lost my streak. It's all good.
Sidharth Kriplani
@sidkrip
Mar 27 2016 07:23
@jiimms they probably havent been overwritten. You are in their portfolio so you will be seeing their answers in all the challenges
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:24
@vramana so if sum = 0, then sum += i will cause sum to equal 1 after the first loop, 3 after the second loop, 6 after the third loop etc
Ramana Venkata
@vramana
Mar 27 2016 07:24
@DylanNeil What you wrote is bit unnecesary. sum += i; is enough. I prefer to avoid += and *= operators They bring more headache. Just simply write sum = sum + i simple and straightforward.
Jiimms
@jiimms
Mar 27 2016 07:25
no, i am back in my portfolio now. I finished all exercises 2 days back, then reset them all and did everything again in various ways and now back to square one or zero :worried: :worried:
Sidharth Kriplani
@sidkrip
Mar 27 2016 07:25
@jiimms I am sorry but I dont know what do for that
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:25
@vramana correct, thank you, after runnng it in repl.it I achieved the same result (5050)
CamperBot
@camperbot
Mar 27 2016 07:25
dylanneil sends brownie points to @vramana :sparkles: :thumbsup: :sparkles:
:warning: dylanneil already gave vramana points
Sidharth Kriplani
@sidkrip
Mar 27 2016 07:26
hasnt happened with me ever
Jiimms
@jiimms
Mar 27 2016 07:27
@sidkrip thanks anyways for the sympathy
CamperBot
@camperbot
Mar 27 2016 07:27
jiimms sends brownie points to @sidkrip :sparkles: :thumbsup: :sparkles:
:star: 378 | @sidkrip | http://www.freecodecamp.com/sidkrip
Ramana Venkata
@vramana
Mar 27 2016 07:27
@DylanNeil Yeah that is because of how assignment operators work But lets leave that for now. Instead of sum If I asked for product what would change ??
Nikhil Kumar
@nikhilkumar238
Mar 27 2016 07:28
help me solving this "You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative. The current count and the player's decision ("Bet" or "Hold") should be separated by a single space."
CamperBot
@camperbot
Mar 27 2016 07:28
no wiki entry for: me solving this you will write a card counting function it will receive a card parameter and increment or decrement the global count variable according to the cards value see table the function will then return a string with the current count and the string bet if the count is positive or hold if the count is zero or negative the current count and the players decision bet or hold should be separated by a single space
Joseph
@revisualize
Mar 27 2016 07:28
@nikhilkumar238 You need to read the instructions and follow the test cases.
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:29
@vramana I would replace the + operator with the * operator
Joseph
@revisualize
Mar 27 2016 07:29
@nikhilkumar238 If you follow the track that you're on. It is just a simple switch and an if else statment.
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:29
@vramana that can't be right, because my result is 0
Nikhil Kumar
@nikhilkumar238
Mar 27 2016 07:30
provide me the solution if you have
Ramana Venkata
@vramana
Mar 27 2016 07:30
@DylanNeil Exactly Now how would you change that if instead of 1 to 100 numbers it was an array of 100 elements
Joseph
@revisualize
Mar 27 2016 07:30
@nikhilkumar238
Count Change Cards
+1 | 2, 3, 4, 5, 6
0 | 7, 8, 9
-1 | 10, 'J', 'Q', 'K','A'
@nikhilkumar238 Have you done it?
Ramana Venkata
@vramana
Mar 27 2016 07:30
@DylanNeil Your i strats with 0 probably.
Joseph
@revisualize
Mar 27 2016 07:30
@nikhilkumar238 Give me your solution then I will give you mine.
I'm not going to give you the answer.
Give a man a fish and he eats for a day. Teach a man to fish....
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:31
@vramana It multiplied correctly when I changed the value of i from 0 to 1
Nikhil Kumar
@nikhilkumar238
Mar 27 2016 07:31

@revisualize var count = 0;
var m;
function cc(card) {
// Only change code below this line
if(card == 2 || 3 || 4|| 5 || 6){
count ++;

}
else if(card == 7|| 8 || 9){
count = count + 0;
}
else if(card == 10 || 'J' || 'Q' || 'K' || 'A'){
count --;
}}

// Only change code above this line

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Ramana Venkata
@vramana
Mar 27 2016 07:31
@DylanNeil How would you change it for an array of 100 elements
Nikhil Kumar
@nikhilkumar238
Mar 27 2016 07:32
@revisualize not able to print correct answer
Joseph
@revisualize
Mar 27 2016 07:32
@nikhilkumar238 You cannot do if statements like that.
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:32
@vramana in which case the program returned 9.33262154439441e+157
Ramana Venkata
@vramana
Mar 27 2016 07:32
@DylanNeil It's okay. That value doesn't matter.
Nikhil Kumar
@nikhilkumar238
Mar 27 2016 07:33
@revisualize Should I use switch case
Joseph
@revisualize
Mar 27 2016 07:33
@nikhilkumar238 If you want to use an IF statement like that you need to recheck the number against the variable over and over and over.
if(card == 2 || card == 3 || card == 4..........
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:33
@vramana so to do this same thing to each element in an array
Ramana Venkata
@vramana
Mar 27 2016 07:33
@DylanNeil Write code and show it.
Joseph
@revisualize
Mar 27 2016 07:33
@nikhilkumar238 It's in line with your current learning process. And I found it to be easier. But, you do you turbo.
Nikhil Kumar
@nikhilkumar238
Mar 27 2016 07:33
@revisualize k let me try it now again
Joseph
@revisualize
Mar 27 2016 07:34
@nikhilkumar238 Also, you're not returning anything.
Ramana Venkata
@vramana
Mar 27 2016 07:35
I like this famous quote by Linus Torvalds. "Talk is cheap. Show me the code."
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:36
function multiplyAll(arr){
    var product = 1;
    for(i = 1; i <arr.length; i++){
        product = product * i;
    }
    return product;
}
multiplyAll([2, 5, 4]);
Joseph
@revisualize
Mar 27 2016 07:36
Hehe.. It's funny that he put his mailing list on blast.
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:36
@vramana not working yet, but this is how I'm thinking about it so far
@vramana I also like that quote
Joseph
@revisualize
Mar 27 2016 07:38
The context is also funny. https://lkml.org/lkml/2000/8/25/132
Ramana Venkata
@vramana
Mar 27 2016 07:38
@DylanNeil shouldn't it be arr[i] ??
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:39
@vramana arr[i].length in the for loop?
@vramana wait I got it
Ramana Venkata
@vramana
Mar 27 2016 07:40
no. shouldn' it be product = product * arr[i] instead of `product = product * i
@DylanNeil Good
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:40
@vramana ```
Joseph
@revisualize
Mar 27 2016 07:40
@DylanNeil Which assessment is that?
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:41
function multiplyAll(arr){
    var product = 1;
    for(var i = 0; i <arr.length; i++){
        product = product * arr[i];
    }
    return product;
}
multiplyAll([2, 5, 4]);
@vramana this returns 40
Ramana Venkata
@vramana
Mar 27 2016 07:41
@DylanNeil Good. Step 1 solved.
Joseph
@revisualize
Mar 27 2016 07:41
2*5*4 = 40
Dylan Pagillo
@DylanNeil
Mar 27 2016 07:43
@vramana
function multiplyAll(arr) {
  var product = 1;