These are chat archives for FreeCodeCamp/HelpJavaScript

22nd
Apr 2017
Keon Samuel
@keonsam
Apr 22 2017 00:00
let me go back into beta for now understand this tic tac toe is hard.
Sergii
@Doomkrat
Apr 22 2017 00:03
@revisualize @Lumexralph
function phoneticLookup(val) {
  var result = "";

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

  lookup.val=result;

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

// Change this value to test
phoneticLookup("charlie");
Ogundele Olumide
@Lumexralph
Apr 22 2017 00:04
@Doomkrat you need to assign the value to result
@Doomkrat = it's right to left associativity , what's on the right is assigned to what's on left
Sergii
@Doomkrat
Apr 22 2017 00:05
function phoneticLookup(val) {
  var result = "";

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

  result=lookup.val;

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

// Change this value to test
phoneticLookup("charlie");
still not working
Ogundele Olumide
@Lumexralph
Apr 22 2017 00:06
@Doomkrat val is a parameter, just like a variable, dot notation will not work, use bracket notation
Sergii
@Doomkrat
Apr 22 2017 00:07
@Lumexralph thanks
CamperBot
@camperbot
Apr 22 2017 00:07
doomkrat sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1548 | @lumexralph |http://www.freecodecamp.com/lumexralph
Sergii
@Doomkrat
Apr 22 2017 00:08
I did it, cant believe :smile:
Kyle Janka
@KTJanka
Apr 22 2017 00:10
 var myVar = myVar++;
not sure what I am doing wrong here "Change the code to use the ++ operator on myVar."
Ogundele Olumide
@Lumexralph
Apr 22 2017 00:10
@Doomkrat cool
@EverythingEpi you need to simply do myVar++;
@EverythingEpi do you know why this `var myVar = myVar++; won't work ?
Kyle Janka
@KTJanka
Apr 22 2017 00:12
hmm I never would of guessed it literally meant just put that there
Diwaxa
@Diwaxa
Apr 22 2017 00:12

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

Joseph
@revisualize
Apr 22 2017 00:12
@Doomkrat Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
'
Diwaxa
@Diwaxa
Apr 22 2017 00:12
wat am i supposed to do there
Kyle Janka
@KTJanka
Apr 22 2017 00:12
I know ++ is meant to eliminate the = sign
Ogundele Olumide
@Lumexralph
Apr 22 2017 00:13
@EverythingEpi that's what it's meant for
Kyle Janka
@KTJanka
Apr 22 2017 00:13
but don't I need var to declare myVar?
Joseph
@revisualize
Apr 22 2017 00:13

@Diwaxa String concatenation with variables.
Gist by revisualize / FreeCodeCamp - Word_Blanks.js
The function declaration was set up as... function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) giving the function name as wordBlanks and with four parameter of myNoun, myAdjective, myVerb and myAdverb.
There is more that I could go into (if you want I can) but, I'll sum it up with:
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

...
Here's a brief example about how to use parameters:

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

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

Kyle Janka
@KTJanka
Apr 22 2017 00:13
That's confusing to me haha
Joseph
@revisualize
Apr 22 2017 00:14
@Diwaxa My sample example only has 2 parameters the function wordBlanks has four parameters.
Ogundele Olumide
@Lumexralph
Apr 22 2017 00:14
@Diwaxa you need to make a string by concatenating all the strings held by the 4 parameters of your function and assigning the string to result
Diwaxa
@Diwaxa
Apr 22 2017 00:14
hmmm..thnx for the help...let me try it out :)
Ogundele Olumide
@Lumexralph
Apr 22 2017 00:14
@EverythingEpi if it's already declared, yes
Pagnito
@Pagnito
Apr 22 2017 00:14
why is this giving me an infinite loop
for(var i=0; i<arr.length; i++)
Kyle Janka
@KTJanka
Apr 22 2017 00:14
Oh wait! @Lumexralph I see what you mean
Ogundele Olumide
@Lumexralph
Apr 22 2017 00:15
@Pagnito the information is not sufficient to be responded to
Kyle Janka
@KTJanka
Apr 22 2017 00:16
cause the declarations were up top with the assignments begin on the bottom? That's what I missed @Lumexralph
Pagnito
@Pagnito
Apr 22 2017 00:16
@Lumexralph i see, yea i ended puttin the length into a var and it seems fine, thank you
CamperBot
@camperbot
Apr 22 2017 00:16
pagnito sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1549 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Apr 22 2017 00:17
@EverythingEpi have you solved it now?
@Pagnito cool
Kyle Janka
@KTJanka
Apr 22 2017 00:17
@Lumexralph yes I did and that makes sense now. Thanks!
CamperBot
@camperbot
Apr 22 2017 00:17
everythingepi sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1550 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Apr 22 2017 00:17
@EverythingEpi :+1:
Kelechi Chinaka
@ke1echi
Apr 22 2017 00:19
greetings guys
Ogundele Olumide
@Lumexralph
Apr 22 2017 00:20
@kelechichinaka Hey Bro!
Kelechi Chinaka
@ke1echi
Apr 22 2017 00:22
hey man @Lumexralph
i salute u @Lumexralph
hw r u @Lumexralph
Ogundele Olumide
@Lumexralph
Apr 22 2017 00:23
@kelechichinaka i hail oo, i'm good, you?
CharlieAguilera090
@CharlieAguilera090
Apr 22 2017 00:24
can someone explain a javascript code to me?
Kelechi Chinaka
@ke1echi
Apr 22 2017 00:24
am ok @Lumexralph
Manish Giri
@Manish-Giri
Apr 22 2017 00:27
@Lumexralph :wave:
hekri-d
@hekri-d
Apr 22 2017 00:27
@teghmehta you have to substitute letters. Like you substitute A with Z or somehting. Read the description.
Ogundele Olumide
@Lumexralph
Apr 22 2017 00:27
@kelechichinaka how area?
@Manish-Giri Bro! :smile:
Kelechi Chinaka
@ke1echi
Apr 22 2017 00:28
area jus de o..hope u de alrit @Lumexralph
CharlieAguilera090
@CharlieAguilera090
Apr 22 2017 00:29
console.log(getSubTotal(orderCount));
Ogundele Olumide
@Lumexralph
Apr 22 2017 00:30
@kelechichinaka i gentle
Long Nguyen
@longnt80
Apr 22 2017 00:38
@CharlieAguilera090
console.log(getSubTotal(orderCount));
get the value from the function getSubTotal with parameter orderCount and print it on the console
Parker St. Pierre
@ParkerSTP
Apr 22 2017 00:42
i need help in "Stand in line" in the javascript course
here is my code

function nextInLine(arr, item) {
  // Your code here

  arr[5] = item;
  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Johnny
@JohnnyBizzel
Apr 22 2017 00:42
array-funcs-stand in line.png
@parkerSTP remember these?
Parker St. Pierre
@ParkerSTP
Apr 22 2017 00:43
it says to remove the first item but I do not know how
Ogundele Olumide
@Lumexralph
Apr 22 2017 00:43
@ParkerSTP you need 2 array methods, (1). to push item into arr, and the next to remove the first element in the arr, which has to be returned
Parker St. Pierre
@ParkerSTP
Apr 22 2017 00:44
@Lumexralph but how do i remove it?
Ogundele Olumide
@Lumexralph
Apr 22 2017 00:44
@ParkerSTP use shift()
CharlieAguilera090
@CharlieAguilera090
Apr 22 2017 00:44

@longnt80 var orderCount = 0;
function takeOrder(topping, crustType) {
orderCount = orderCount +1;

console.log('Order: ' + crustType + ' crust topped with ' + topping);
}
function getSubTotal(itemCount){
return itemCount * 7.5;

}

takeOrder('bacon', 'thin');
takeOrder('pepperoni', 'regular');
takeOrder('pesto', 'thin');
console.log(getSubTotal(orderCount)); i just want to understand getSubTotal/orderCount. why was ordeCount chosen

Parker St. Pierre
@ParkerSTP
Apr 22 2017 00:44
okay thanls
thanks*
Johnny
@JohnnyBizzel
Apr 22 2017 00:46
@ParkerSTP thanks for the question
CamperBot
@camperbot
Apr 22 2017 00:46
johnnybizzel sends brownie points to @parkerstp :sparkles: :thumbsup: :sparkles:
:cookie: 126 | @parkerstp |http://www.freecodecamp.com/parkerstp
Tegh
@teghmehta
Apr 22 2017 00:46
how do I check if a string contains only letters
Johnny
@JohnnyBizzel
Apr 22 2017 00:47
@teghmehta Try a regular expression test
https://www.w3schools.com/jsref/jsref_obj_regexp.asp
Parker St. Pierre
@ParkerSTP
Apr 22 2017 00:48

@JohnnyBizzel I added what you said:

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

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

but I still am missing " nextInLine([], 1) should return 1
"

Johnny
@JohnnyBizzel
Apr 22 2017 00:48
@ParkerSTP what did I say?
array-funcs-stand in line.png
@parkerSTP remember these?
Parker St. Pierre
@ParkerSTP
Apr 22 2017 00:48
oh yeah thanks
Johnny
@JohnnyBizzel
Apr 22 2017 00:48
@ParkerSTP I think you should re-do these challenges
Long Nguyen
@longnt80
Apr 22 2017 00:52
@CharlieAguilera090
orderCount is the number of Order
the function getSubTotal take the number of Order and times 7.5
CharlieAguilera090
@CharlieAguilera090
Apr 22 2017 00:56
@longnt80 thanks man
CamperBot
@camperbot
Apr 22 2017 00:56
charlieaguilera090 sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 158 | @longnt80 |http://www.freecodecamp.com/longnt80
Long Nguyen
@longnt80
Apr 22 2017 00:56
no problem
Gustavo Davis
@gusdavis
Apr 22 2017 00:56
Hey hows everyone. im stuck on the part of the comparison operator with greater than operator . it asks add the greater than operator to the indicated lines so that the return statements make sense. I tried to add this to each if:
If (val) {
Joseph
@revisualize
Apr 22 2017 00:57
Hey.
Long Nguyen
@longnt80
Apr 22 2017 00:58
@gusdavis please copy the full code
Gustavo Davis
@gusdavis
Apr 22 2017 00:59
@longnt80 Im so sorry but how do you copy the full code?
Long Nguyen
@longnt80
Apr 22 2017 00:59
select everything and paste it here
(delete this) your copied code should be here
Gustavo Davis
@gusdavis
Apr 22 2017 01:00

Oh I sorry I thought you meant to send this as a pic. But anyways here it is:
function testGreaterThan(val) {
if (val) {
val= 0>10;
return "Over 100";
}

if (val) { val= 0>10;
return "Over 10";
}
val= 0>10;
return "10 or Under";
}

CharlieAguilera090
@CharlieAguilera090
Apr 22 2017 01:01
@gusdavis are you suppose to use if else/ else statements?
Gustavo Davis
@gusdavis
Apr 22 2017 01:02
this is the task of add the greater than operator to the indicated lines so that the return statements make sense
Long Nguyen
@longnt80
Apr 22 2017 01:03
@gusdavis
you shouldn't make a variable val= 0>10;
CharlieAguilera090
@CharlieAguilera090
Apr 22 2017 01:03
@gusdavis val 0<10; return under 10
Gustavo Davis
@gusdavis
Apr 22 2017 01:04
@CharlieAguilera090 I see. let me try that now and see if that works.
Tegh
@teghmehta
Apr 22 2017 01:04
@JohnnyBizzel entry == /[a-z]/g I wanna check if its a letter
Long Nguyen
@longnt80
Apr 22 2017 01:04
@gusdavis
the first if should be like this
function testGreaterThan(val) {
 if (val > 100) {
 return "Over 100";
 }
}
@gusdavis
and remember to use else if
Gustavo Davis
@gusdavis
Apr 22 2017 01:06
@longnt80 oh I see. what you mean. I thought that I had to make a variable that was greater than 10. I'll use those points you mentioned right now.
@longnt80 thank you so much. that did the trick. I really do appreicate your help sir.
CamperBot
@camperbot
Apr 22 2017 01:08
gusdavis sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 159 | @longnt80 |http://www.freecodecamp.com/longnt80
Long Nguyen
@longnt80
Apr 22 2017 01:09
@gusdavis
no problem man
CharlieAguilera090
@CharlieAguilera090
Apr 22 2017 01:09
@gusdavis dang, sorry i didnt even see that but hopefully i helped someway
Long Nguyen
@longnt80
Apr 22 2017 01:10
@CharlieAguilera090
don't worry, you just need more practice
Tegh
@teghmehta
Apr 22 2017 01:10
@longnt80 how do i check if a string is a letter
Gustavo Davis
@gusdavis
Apr 22 2017 01:11
@CharlieAguilera090 yes you did. you helped me out just by being available and ready to help me out with this. Ive been stuck on this issue for the 30 mins or so just trying to wrap my head around what it was really asking me to do. I hate that feeling off is there anyone out that willing to help me out without me feeling bad just for asking.
hekri-d
@hekri-d
Apr 22 2017 01:14
@gusdavis you don't have to feel bad for asking.
@gusdavis if people can help they will if. That's what the chat's for.
Gustavo Davis
@gusdavis
Apr 22 2017 01:14
thank you @hekri-d I appreicate that very much
CamperBot
@camperbot
Apr 22 2017 01:14
gusdavis sends brownie points to @hekri-d :sparkles: :thumbsup: :sparkles:
:cookie: 294 | @hekri-d |http://www.freecodecamp.com/hekri-d
hekri-d
@hekri-d
Apr 22 2017 01:15
@gusdavis you're welcome.
Long Nguyen
@longnt80
Apr 22 2017 01:19
@teghmehta
Please see this

@gusdavis

yes you did. you helped me out just by being available and ready to help me out with this. Ive been stuck on this issue for the 30 mins or so just trying to wrap my head around what it was really asking me to do. I hate that feeling off is there anyone out that willing to help me out without me feeling bad just for asking.

But don't ask too soon though, you'll learn much more by figure it out by your self

Manish Giri
@Manish-Giri
Apr 22 2017 01:24
any react people here?
João Novaes Barreiros
@Jon-Nova
Apr 22 2017 01:29
Hi people, im having trouble with operations involving float number
Jason Luboff
@JLuboff
Apr 22 2017 01:37
@Manish-Giri no
Mohamed Derhalli
@derhallim
Apr 22 2017 01:48
@Jon-Nova use math js
Stephen James
@sjames1958gm
Apr 22 2017 01:49
Storm sirens going off
João Novaes Barreiros
@Jon-Nova
Apr 22 2017 01:50
@derhallim i will look, thx
CamperBot
@camperbot
Apr 22 2017 01:50
jon-nova sends brownie points to @derhallim :sparkles: :thumbsup: :sparkles:
:cookie: 249 | @derhallim |http://www.freecodecamp.com/derhallim
Mohamed Derhalli
@derhallim
Apr 22 2017 01:50
wow
web storm?
or a real storm?
Stephen James
@sjames1958gm
Apr 22 2017 01:51
Rain storm - hail and tornado watch
Mohamed Derhalli
@derhallim
Apr 22 2017 01:51
tornado :worried:
Keon Samuel
@keonsam
Apr 22 2017 01:51
lots of bugs in the beta.
hurricane.
everyone sleeping?
Mohamed Derhalli
@derhallim
Apr 22 2017 01:53
hushhh @keonsam
DrKlahn33
@DrKlahn33
Apr 22 2017 01:55

function confirmEnding(str, target) {
 var endLength = target.length;
  var modString =str.length;
  var i=1;
  var result;
  for (i;i<endLength;i++){
    if (str[str.length-i] === target[target.length-i]){
      result = true; 
    }
    else{
      result = false;
    }
      }
return result;
}

confirmEnding("Bastian", "f");
hey guys. does anyone know why this code does not work for when the target is only one charafcter long?
tejavarma-twl
@tejavarma-twl
Apr 22 2017 01:58
because i is 1 and the length of str would be 1
Stephen James
@sjames1958gm
Apr 22 2017 01:59
@keonsam ONly 9pm
Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 01:59
Hello everyone!
@Manish-Giri you looking for react people?
tejavarma-twl
@tejavarma-twl
Apr 22 2017 02:00
i<endlength will fail here
Stephen James
@sjames1958gm
Apr 22 2017 02:01
@DrKlahn33 If i = 1 , i < 1 it wont loop
DrKlahn33
@DrKlahn33
Apr 22 2017 02:01
@tejavarma-twl Would not 1-1=0 and [0] should be the first character of a string?
Manish Giri
@Manish-Giri
Apr 22 2017 02:01
@kuriakinzeng yup
DrKlahn33
@DrKlahn33
Apr 22 2017 02:01
@sjames1958gm ahhhhhhhh
Peter Miles
@petermiles
Apr 22 2017 02:01

Hey y'all. Trying to declare JavaScript Variables and having some trouble.

How do I use the 'var' keyword to create a vraiable called myName?

Stephen James
@sjames1958gm
Apr 22 2017 02:02
which is what @tejavarma-twl was saying
Gulsvi
@gulsvi
Apr 22 2017 02:02
@poolsocks what does your code look like now?
Stephen James
@sjames1958gm
Apr 22 2017 02:02
@poolsocks What does the sample code look like?
tejavarma-twl
@tejavarma-twl
Apr 22 2017 02:02
It first should pass into the loop to execute the remaining
Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 02:02
@Manish-Giri I know a little
Wassup?
Peter Miles
@petermiles
Apr 22 2017 02:02
var ourName = myName;

// Example
var ourName;

// Define myName below this line

var ourName = myName;

Stephen James
@sjames1958gm
Apr 22 2017 02:03
@DrKlahn33 you need i = 1; i <= endlength
Peter Miles
@petermiles
Apr 22 2017 02:03
I clearly am way off.
Stephen James
@sjames1958gm
Apr 22 2017 02:03
@poolsocks Just match the example with a different variable name
DrKlahn33
@DrKlahn33
Apr 22 2017 02:04
@sjames1958gm Thanks
@tejavarma-twl Thanks
CamperBot
@camperbot
Apr 22 2017 02:04
drklahn33 sends brownie points to @tejavarma-twl :sparkles: :thumbsup: :sparkles:
:cookie: 265 | @tejavarma-twl |http://www.freecodecamp.com/tejavarma-twl
Peter Miles
@petermiles
Apr 22 2017 02:04
You ever get a disappointed with yourself because of how easy a question is? :)
got it, thank you @sjames1958gm
CamperBot
@camperbot
Apr 22 2017 02:04
poolsocks sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6873 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Manish Giri
@Manish-Giri
Apr 22 2017 02:04
@kuriakinzeng do you know how to traverse the DOM in react?
Stephen James
@sjames1958gm
Apr 22 2017 02:05
@Manish-Giri You can use refs in elements to access the DOM
https://facebook.github.io/react/docs/refs-and-the-dom.html
Manish Giri
@Manish-Giri
Apr 22 2017 02:06
@sjames1958gm I'm on that link for a while now, still not clear enough..let me do it again.
Stephen James
@sjames1958gm
Apr 22 2017 02:08
@Manish-Giri I find React docs challenging to pull basic info out of
Manish Giri
@Manish-Giri
Apr 22 2017 02:08
@sjames1958gm yeah same here
Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 02:08
@Manish-Giri any specific thing you wanna do?
Manish Giri
@Manish-Giri
Apr 22 2017 02:09

@kuriakinzeng okay here

<div>
<h1></h1>
<span></span>
<a></a>
</div>

When this a is clicked, I need to know what the content of the h1 is

Keon Samuel
@keonsam
Apr 22 2017 02:15
beta is super buggy.
Khoa Le
@Zacele
Apr 22 2017 02:16
hello guys
could you explain this code abit
math.max(...array)
what are the "..." for ?
cannot google this code
Manish Giri
@Manish-Giri
Apr 22 2017 02:17
@Zacele it spreads out the array into a list, which Math.max expects
it's called the spread operator.
Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 02:22
@Manish-Giri can you do onClick?
Manish Giri
@Manish-Giri
Apr 22 2017 02:22
@kuriakinzeng yup
Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 02:23
sure. then you declare a function within your react component
class Example extends Component {
  clickThis() {
    console.log('clicked')
  }
  render(){
<div>
<h1></h1>
<span></span>
<a onClick={() => this.clickThis.bind(this) }></a>
</div>
  }
Manish Giri
@Manish-Giri
Apr 22 2017 02:25
um
okay
and?
Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 02:26
when a is clicked, clickThis is called
Manish Giri
@Manish-Giri
Apr 22 2017 02:26
okay
Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 02:26
you might have to do preventDefault
Manish Giri
@Manish-Giri
Apr 22 2017 02:26
then?
Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 02:26
since your <a> probably has href
prevent default and do whatever you want before you push route to react router
i don't know your use case :joy:
Manish Giri
@Manish-Giri
Apr 22 2017 02:28
lol
I just need to get the content in the h1 tags when the a is clicked
Chetan Vashistth
@chetanhere
Apr 22 2017 02:30

function nextInLine(arr, item) {
// Your code here
arr = arr.push(item);
return arr.shift();
//console.log(arr);

//return arr.shift();
}

above code is showing error arr.shift is not a function

Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 02:31
@Manish-Giri ok so your h1 should have a ref tag so that you can refer to it from the clickThis function
Chetan Vashistth
@chetanhere
Apr 22 2017 02:32
@chetanhere arr is an array here, above code is from our exercise itself
Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 02:32
it's just like react version of getElementById
@chetanhere arr.push(item) is enough, don't assign it back to arr
Chetan Vashistth
@chetanhere
Apr 22 2017 02:34
@kuriakinzeng Thanks friend. It is working now. Would you please explain a bit about the issue when I assigned it. It would help me in future
CamperBot
@camperbot
Apr 22 2017 02:34
chetanhere sends brownie points to @kuriakinzeng :sparkles: :thumbsup: :sparkles:
:cookie: 381 | @kuriakinzeng |http://www.freecodecamp.com/kuriakinzeng
Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 02:34
@manish-giri
render: function() {
  return <input placeholder='Email' ref='email' onFocus={this.onEmailFocus} />;
},

-----

onEmailFocus: function() {
  this.refs.email.blur();
},
@chetanhere arr.push returns the length of the new array
so it becomes a number
and you try to shift it
javascript is quirky
;)
Chetan Vashistth
@chetanhere
Apr 22 2017 02:35
@kuriakinzeng okay, got it. Thanks a lot friend
CamperBot
@camperbot
Apr 22 2017 02:35
chetanhere sends brownie points to @kuriakinzeng :sparkles: :thumbsup: :sparkles:
:warning: chetanhere already gave kuriakinzeng points
DistinctWolf
@DistinctWolf
Apr 22 2017 02:36
var img=[];
img[0]=new Image(100,100);
img[0].src="https://www.nature.org/cs/groups/webcontent/@web/@northcarolina/documents/media/nc-mountain-sunset.jpg";
img[1]=new Image(100,100);
img[1].src="https://static.pexels.com/photos/20974/pexels-photo.jpg";
function show(){
for(var i=0;i<img.length;i++){
  if(img.indexOf(img[i])<2){
     document.body.appendChild(img[i]);
  }
}
}
setInterval(show,2000);
I can't get one image to appear after specified seconds. Both images is shown at the same time
CatherineKa
@CatherineKa
Apr 22 2017 02:36
Hi everyone! I am here again, so lucky to learn with you
Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 02:37
@CatherineKa Welcome
CatherineKa
@CatherineKa
Apr 22 2017 02:37
anyone knows how to replace the punction, spaces and symbols with String.replace( )?
Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 02:38
You could do multiple times
CatherineKa
@CatherineKa
Apr 22 2017 02:38
function palindrome(str) {
  // Good luck!
  lowerCase=str.toLowerCase();
  str1=lowerCase.replace(,"");
  return true;
}
Danny Welstad
@GoonTwo
Apr 22 2017 02:38
anybody willing to take a look at my pomodoro clock and take it for spin and give error feedback? would really appreciate it
http://codepen.io/DWelstad/pen/PmZxEr?editors=1011
Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 02:38
lowerCase.replace(",","");
@CatherineKa
oh wait you want to replace all punctuations?
you need to use Regex
You should have learned it before this challenge
Stephen James
@sjames1958gm
Apr 22 2017 02:39
@CatherineKa You can use regex with character sets or character classes
Sets are things like \w for word characters or \W for non word characters.
classes are like [a-z] for matching letters or [^a-z] for matching all but letters.
/[a-z]/g would be the full regex syntax for example.
Manish Giri
@Manish-Giri
Apr 22 2017 02:41
@kuriakinzeng all right I'll try something, thx
CamperBot
@camperbot
Apr 22 2017 02:41
manish-giri sends brownie points to @kuriakinzeng :sparkles: :thumbsup: :sparkles:
Luke
@luke818h
Apr 22 2017 02:42
Looking for help with Generate Random whole number (0-9)
I generate the correct result in my own IDE. But FCC is telling me that I don't have it correct.

function randomWholeNum() {

  // Only change code below this line.

  return Math.floor(Math.random() * 10);
}
Stephen James
@sjames1958gm
Apr 22 2017 02:42

@FlashHero

function show(index) {
   document.body.appendChild(img[index]);
}
show(0);
setTimeout(function() { show(1) }, 2000);

this is a really basic way for showing two images

CamperBot
@camperbot
Apr 22 2017 02:42
api offline
Stephen James
@sjames1958gm
Apr 22 2017 02:44
@luke818h Which tests fail?
CatherineKa
@CatherineKa
Apr 22 2017 02:45
Thanks both of you
I 'll learn it and try
Luke
@luke818h
Apr 22 2017 02:46
You should be using Math.random to generate a random number.
You should use Math.floor to remove the decimal part of the number.
those two tests fail
Long Nguyen
@longnt80
Apr 22 2017 02:48
@luke818h
It should be correct. Maybe refresh freecodecamp and paste your answer in it again
Luke
@luke818h
Apr 22 2017 02:48
@longnt80 I will give that a try
@longnt80 That did not work
Danny Welstad
@GoonTwo
Apr 22 2017 02:51
I'm about to dive into the tic-tac-toe game. any suggestions? The example seems to be smart... Does mine have to be functionally similar in that way as well? It seems like that apect would add quite a bit extra work
Long Nguyen
@longnt80
Apr 22 2017 02:52
@luke818h
hmm, your code's working fine. There's nothing wrong.
@luke818h
what did FCC say?
Luke
@luke818h
Apr 22 2017 02:53
@longnt80 Still the same thing. I will get out of FCC altogether and try again.
Stephen James
@sjames1958gm
Apr 22 2017 02:54
@luke818h Try reset - and don't remove the top line
@GoonTwo There is no requirement for the computer to be intelligent
Luke
@luke818h
Apr 22 2017 02:55
@sjames1958gm @longnt80 That worked! thanks alot
CamperBot
@camperbot
Apr 22 2017 02:55
luke818h sends brownie points to @sjames1958gm and @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 162 | @longnt80 |http://www.freecodecamp.com/longnt80
:star2: 6874 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Danny Welstad
@GoonTwo
Apr 22 2017 02:56
@sjames1958gm ok i didn't think so. Thanks!
CamperBot
@camperbot
Apr 22 2017 02:56
goontwo sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6875 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Mohamed Derhalli
@derhallim
Apr 22 2017 02:57
Wololo
Stephen James
@sjames1958gm
Apr 22 2017 02:59
@luke818h The tests are looking for two each of Math.floor and Math.random
Joseph
@revisualize
Apr 22 2017 03:02
Hey hey.
Daniel Molina
@Molina92
Apr 22 2017 03:04
Hello good night! i need some help please in this exercise i don't understand the task
Joseph
@revisualize
Apr 22 2017 03:06
@Molina92 What are you supposed to do?
CatherineKa
@CatherineKa
Apr 22 2017 03:07
function palindrome(str) {
  // Good luck!
  lowerCase=str.toLowerCase();
  str1=lowerCase.replace(/\s/g,"");
  str2=str1.replace(/\W/g,"");
  str3=str2.split("");
  str4=str3.reverse();
  str5=str4.join("");
  if(str===str5){
  return true;}
}
Joseph
@revisualize
Apr 22 2017 03:08
@CatherineKa You're not returning false?
@CatherineKa You're not changing str
@CatherineKa You need to modify both sides of the comparison.
CatherineKa
@CatherineKa
Apr 22 2017 03:10
but what I need is to make a comparison with the original string and current string, so I think I need to maintain the value of str
Joseph
@revisualize
Apr 22 2017 03:10
@CatherineKa No.
@CatherineKa You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything lower case in order to check for palindromes.
Daniel Molina
@Molina92
Apr 22 2017 03:10
at this moment i understand that the parameters of the function have to be passed when i call it or executed the name of the function. But the Instruccions say that define arr, item inside the function i dont get that part, i doed this and doesn't work. @revisualize
function nextInLine(arr, item) {
// Your code here
arr=[6,7,8,9];
return item=7; // Change this line
}
Joseph
@revisualize
Apr 22 2017 03:10
@CatherineKa A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.
@Molina92 You're supposed to:
Write a function nextInLine which has two parameters
an array (arr) and a number (item).
That part has been done for you here:
function nextInLine(arr, item) { }
zacharydylan
@zacharydylan
Apr 22 2017 03:11
@Molina92 They are trying to get you to manipulate the array in different ways. Here are some links: shift, push.
The instructions say that your input is arr.
Joseph
@revisualize
Apr 22 2017 03:12
@Molina92 Add a number (item) to the end of an array (arr)
CatherineKa
@CatherineKa
Apr 22 2017 03:12
So what I need to do is make a new string which backforward from str, and make a comparison?
Joseph
@revisualize
Apr 22 2017 03:12
@Molina92 remove the first element from an array (arr) and you need to return the element that was removed.
@CatherineKa Yes. But, you need to remove all punctuation, case, and spacing from both sides of the comparison.
CatherineKa
@CatherineKa
Apr 22 2017 03:13
Oh I see
Thanks. I'll try again
Joseph
@revisualize
Apr 22 2017 03:15
@Molina92 So.
@Molina92 So, How do you add a number (item) to the end of an array (arr)?
intcreate
@intcreate
Apr 22 2017 03:15
can any1 help me with this one
Joseph
@revisualize
Apr 22 2017 03:15
@Molina92 How do you remove the first element from an array (arr)?
intcreate
@intcreate
Apr 22 2017 03:16

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

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

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

CatherineKa
@CatherineKa
Apr 22 2017 03:16
So function palindrome(str) { // Good luck! lowerCase=str.toLowerCase(); str1=lowerCase.replace(/\s/g,""); str2=str1.replace(/\W/g,""); str3=str2.split(""); str4=str3.reverse(); str5=str4.join(""); if(str2===str5){ return true;} }
intcreate
@intcreate
Apr 22 2017 03:16
golfScore(4, 1) should return "Hole-in-one!"
golfScore(4, 2) should return "Eagle"
golfScore(5, 2) should return "Eagle"
golfScore(4, 3) should return "Birdie"
golfScore(4, 4) should return "Par"
golfScore(1, 1) should return "Hole-in-one!"
golfScore(5, 5) should return "Par"
golfScore(4, 5) should return "Bogey"
golfScore(4, 6) should return "Double Bogey"
golfScore(4, 7) should return "Go Home!"
golfScore(5, 9) should return "Go Home!"
i dont understand this because you can only have one return but it asks for a lot of returns
Joseph
@revisualize
Apr 22 2017 03:16
@CatherineKa Your function is only returning true or undefined
@CatherineKa Question.
@CatherineKa What does \W leave you with?
Vikram
@vikramnr
Apr 22 2017 03:17
hi all.. what's difference between reverseStr=trueStr.split(" "); and reverseStr=trueStr.split("");??
Joseph
@revisualize
Apr 22 2017 03:17
@vikramnr A space
CatherineKa
@CatherineKa
Apr 22 2017 03:18
the code here means I replace all the Non-word with ""
anything wrong?
Joseph
@revisualize
Apr 22 2017 03:18
@CatherineKa What is a word character?
@vikramnr
"hello world".split('');
// => [ 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd' ]

//     vs 

"hello world".split(' ');
// => [ 'hello', 'world' ]
Vikram
@vikramnr
Apr 22 2017 03:19
@revisualize :smile: While using these two difference statements in palindrome two different conditions passes ... @CatherineKa Thanks
CamperBot
@camperbot
Apr 22 2017 03:19
vikramnr sends brownie points to @revisualize and @catherineka :sparkles: :thumbsup: :sparkles:
:cookie: 240 | @catherineka |http://www.freecodecamp.com/catherineka
:star2: 3813 | @revisualize |http://www.freecodecamp.com/revisualize
Vikram
@vikramnr
Apr 22 2017 03:20
@revisualize @CatherineKa which should i use for palindrome to pass all testcase??
Joseph
@revisualize
Apr 22 2017 03:20
@vikramnr Well.. What is the .reverse() of an array [ 'hello', 'world' ]?
@vikramnr It's [ 'world', 'hello' ]
EK Azubuike
@ekazubuike
Apr 22 2017 03:21
Sorted Union challenge keeps throwing me a TypeError: "Cannot read property 'length' of undefined." I think the values for the arguments object are undefined, but I don't understand why this is the case. Here's my code:

function uniteUnique(arr) {
  for (var i = 0; i <= arguments.length; i++) {
    for (var j = 0; j <= arguments[i].length; j++) {
      arguments[i].reduce(function (acc, curr){
        if (acc.indexOf(arguments[i][j] === -1)) {
            return acc.concat(arguments[i][j]);
            }
      }, []);
    }
  }
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
Daniel Molina
@Molina92
Apr 22 2017 03:21
@revisualize let me think about this revisiting the past classes cause' still doesn't see
Joseph
@revisualize
Apr 22 2017 03:21
@Molina92 You don't see what?
Daniel Molina
@Molina92
Apr 22 2017 03:21
What you try to say.
Vikram
@vikramnr
Apr 22 2017 03:21
@revisualize Yes You are correct So should i put if clause for that??
Joseph
@revisualize
Apr 22 2017 03:21
@Molina92 You don't see how you add a number (item) to the end of an array (arr)?
@vikramnr Do words have spaces in between letters?
@vikramnr .split('') is what you want for that lesson. Words do not have spaces between characters.
Daniel Molina
@Molina92
Apr 22 2017 03:24
@revisualize with push()?
Joseph
@revisualize
Apr 22 2017 03:24
@Molina92 yes.
Daniel Molina
@Molina92
Apr 22 2017 03:25
so what i have to do is use push to item variable?
Joseph
@revisualize
Apr 22 2017 03:26
@Molina92 You don't push anything to item .. The parameter item isn't an array.
@Molina92 the parameter item is a number.
@Molina92 Write a function nextInLine which has two parameters
an array (arr) and a number (item).
CatherineKa
@CatherineKa
Apr 22 2017 03:26
@intcreate You can try 'if' 'else if' to return different results.
Vikram
@vikramnr
Apr 22 2017 03:26
@revisualize I'm not understanding what is it you are trying to say
observelife
@observelife
Apr 22 2017 03:26
arr[].push(what you want to push)
Joseph
@revisualize
Apr 22 2017 03:26
@observelife That's incorrect.
@vikramnr What do you mean you don't understand?
@vikramnr Is race car a palindrome?
Vikram
@vikramnr
Apr 22 2017 03:29
@revisualize Here is what it is confusing it is palindrome if space is removed but no when it's not
CatherineKa
@CatherineKa
Apr 22 2017 03:29
@revisualize word character means [A-Za-z0-9_], right?
Joseph
@revisualize
Apr 22 2017 03:29
@vikramnr
"race car".split(' ');
// => [ 'race', 'car' ]
"race car".split(' ').reverse();
// => [ 'car', 'race' ]
@CatherineKa Is a _ a non-alphanumeric character?
Vikram
@vikramnr
Apr 22 2017 03:30
@revisualize So it not a palindrome??
Joseph
@revisualize
Apr 22 2017 03:30
@vikramnr No. race car is a palindrome.
CatherineKa
@CatherineKa
Apr 22 2017 03:30
I think it is
Joseph
@revisualize
Apr 22 2017 03:30
A palindrome is a word or sentence that's spelled the same way both forward and backward,
--> ignoring punctuation, case, and spacing. <--- Important part.
observelife
@observelife
Apr 22 2017 03:31
you are right.I have a problem wtih describe. @revisualize
Vikram
@vikramnr
Apr 22 2017 03:31
@revisualize @CatherineKa Okay :smile:
image.png
Joseph
@revisualize
Apr 22 2017 03:33
@vikramnr Why are you still splitting on the space?
@vikramnr You are supposed to IGNORE spacing.
@vikramnr In fact.. your .replace() removes all spacing.
Vikram
@vikramnr
Apr 22 2017 03:34
@revisualize @CatherineKa Yeah got it thanks finally :clap:
CamperBot
@camperbot
Apr 22 2017 03:34
vikramnr sends brownie points to @revisualize and @catherineka :sparkles: :thumbsup: :sparkles:
:warning: vikramnr already gave revisualize points
:warning: vikramnr already gave catherineka points
Vikram
@vikramnr
Apr 22 2017 03:36
@revisualize I shouldn't have considered spacing in both split and join
intcreate
@intcreate
Apr 22 2017 03:36

``
function caseInSwitch(val) {
var answer = "";
// Only change code below this line
case 1:
console.log('alpha');
break;

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

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

caseInSwitch(1) should have a value of "alpha"
caseInSwitch(2) should have a value of "beta"
caseInSwitch(3) should have a value of "gamma"
Joseph
@revisualize
Apr 22 2017 03:36
@intcreate You don't have a switch. You just have a single case statement.
CatherineKa
@CatherineKa
Apr 22 2017 03:37
@revisualize Could you tell me the difference between /\W/g and /[\W_]/g?
intcreate
@intcreate
Apr 22 2017 03:37
so just
finish the others then ill be ok>?>
Joseph
@revisualize
Apr 22 2017 03:37
@CatherineKa _
@CatherineKa Look \W is shorthand for [^A-Za-z0-9_]
@CatherineKa If you do [\W_] You're saying [^A-Za-z0-9_] & [_]
Ergo: [^A-Za-z0-9]
CatherineKa
@CatherineKa
Apr 22 2017 03:39
Dose _neither belong to \W nor \w?
Joseph
@revisualize
Apr 22 2017 03:40

@CatherineKa
\w
Matches any alphanumeric character from the basic Latin alphabet, including the underscore. Equivalent to [A-Za-z0-9_].
For example, /\w/ matches "a" in "apple", "5" in "$5.28", and "3" in "3D".

...

\W
Matches any character that is not a word character from the basic Latin alphabet. Equivalent to [^A-Za-z0-9_].
For example, /\W/or /[^A-Za-z0-9_]/ matches "%" in "50%".

CatherineKa
@CatherineKa
Apr 22 2017 03:42
@revisualize OK thanks. let me digest it for a while
CamperBot
@camperbot
Apr 22 2017 03:42
catherineka sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3814 | @revisualize |http://www.freecodecamp.com/revisualize
intcreate
@intcreate
Apr 22 2017 03:44
function caseInSwitch(val) { var answer = "";
// Only change code below this line var change = caseInSwitch(switch() {
case 1: console.log('alpha');
break; case 2:
console.log('beta'); break;
case 3: console.log('gamma');
break; case 4:
console.log('delta'); });
caseInSwitch(1) should have a value of "alpha"
caseInSwitch(2) should have a value of "beta"
caseInSwitch(3) should have a value of "gamma"
caseInSwitch(4) should have a value of "delta"
CatherineKa
@CatherineKa
Apr 22 2017 03:44
@revisualize aha I get it. Thanks
CamperBot
@camperbot
Apr 22 2017 03:44
catherineka sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: catherineka already gave revisualize points
CatherineKa
@CatherineKa
Apr 22 2017 03:46
@intcreate No, you need set up a switch in a new line
intcreate
@intcreate
Apr 22 2017 03:47

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

}

it doesnt work
CatherineKa
@CatherineKa
Apr 22 2017 03:48
@intcreate why do you declare change?
intcreate
@intcreate
Apr 22 2017 03:50
i think that is a good thing to do
intcreate
@intcreate
Apr 22 2017 03:50
okay i removed it switch() {
case 1:
console.log('alpha');
break;
case 2:
console.log('beta');
break;
case 3:
console.log('gamma');
break;
case 4:
console.log('delta');
}
CatherineKa
@CatherineKa
Apr 22 2017 03:52
you need to add expression in the bracket after switch
intcreate
@intcreate
Apr 22 2017 03:53

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

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

CatherineKa
@CatherineKa
Apr 22 2017 03:55
Nope. I think you just need to add valin the bracket. caseInSwitch is the function, no need to put it in the bracket
intcreate
@intcreate
Apr 22 2017 03:56
still doesnt work
DistinctWolf
@DistinctWolf
Apr 22 2017 03:57
@intcreate instead of console.log you need to set the values to the variable answer
CatherineKa
@CatherineKa
Apr 22 2017 03:57
yeah, that's another problem
to assign the value to the variable answer
sudip chhetri
@SudipChhetri
Apr 22 2017 04:11
Hey is there any one to help me , I am stuck in tic tac toe game
Todd Abraham
@toddabraham
Apr 22 2017 04:11
Baseic JavaScript - Profile Lookup exercise. I found this exercise to be very difficult and was not able to get through it without the help of RealToughCandy’s YouTube video. My question is, did anyone else find this difficult? How are you going about making sure you’re grasping the concepts being taught along the way through this course?
Manish Giri
@Manish-Giri
Apr 22 2017 04:12
@toddabraham I'd recommend doing codeacademy's js lessons too.
Joseph
@revisualize
Apr 22 2017 04:12
@toddabraham I didn't find it too difficult.
@toddabraham It was a bit challenging. I just read the instructions over and over.
sudip chhetri
@SudipChhetri
Apr 22 2017 04:12
@Manish-Giri plz help me
Manish Giri
@Manish-Giri
Apr 22 2017 04:13
@SudipChhetri lol tictactoe is difficult
I'm in the midst of debugging my recipebox
what's the problem?
Todd Abraham
@toddabraham
Apr 22 2017 04:13
@Manish-Giri What’s the rationale for doing codeacademy’s js lessons as well? Does it spin the topic in a different way that helps with learning, or?
sudip chhetri
@SudipChhetri
Apr 22 2017 04:13
my javascript is not working
Joseph
@revisualize
Apr 22 2017 04:14
@toddabraham After I read the instructions a few times I did this:
// A lookUpProfile function that takes
// firstName and a property (prop)
// as parameters has been pre-written for you.
function lookUpProfile(firstName, prop){
   // The function should check if firstName is an actual contact's firstName
   // and the given property (prop) is a property key of that contact.

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

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


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

}
Manish Giri
@Manish-Giri
Apr 22 2017 04:14
@toddabraham it goes over a lot of the simple things in detail, which fcc doesn't.
Joseph
@revisualize
Apr 22 2017 04:14
@toddabraham From there I was able to just fill in the blanks.
Manish Giri
@Manish-Giri
Apr 22 2017 04:15
@SudipChhetri document.getElementsById("x");
should be Element
sudip chhetri
@SudipChhetri
Apr 22 2017 04:15
@Manish-Giri just once you see my code onclick function is not working
@Manish-Giri still not working
Todd Abraham
@toddabraham
Apr 22 2017 04:17
@revisualize Nice approach, thank you.
CamperBot
@camperbot
Apr 22 2017 04:17
toddabraham sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3815 | @revisualize |http://www.freecodecamp.com/revisualize
CatherineKa
@CatherineKa
Apr 22 2017 04:17
Anyone knows how to sort an array based on the length of words in it?
Todd Abraham
@toddabraham
Apr 22 2017 04:17
@Manish-Giri Thanks for the tip, I’ll try.
CamperBot
@camperbot
Apr 22 2017 04:17
toddabraham sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5252 | @manish-giri |http://www.freecodecamp.com/manish-giri
CatherineKa
@CatherineKa
Apr 22 2017 04:19
I know the .sort property, but I just dont know how to write in the function to sort based on the length of words in an array
Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 04:19

I am doing the voting app. I'm thinking of the following schema for poll:

pollSchema = new Schema({
  _creator: { type: Schema.Types.ObjectId, ref: 'User'},
  name: String,
  options: [{ type: Schema.Types.ObjectId, ref: 'Option'}]
});

where option has a schema like:

const optionSchema = new Schema({
  _poll: { type: Schema.Types.ObjectId, ref: 'Poll'},
  name: String,
  voters: [{ type: Schema.Types.ObjectId, ref: 'User'}]
});

Question:
My api route "polls/create" receives three objects: email, name (of poll) and an array of options
What's the recommended way of inserting poll and options into the database?

I plan to use:

  1. Find the _creator using User.findOne({email})
  2. Then either do Option.insertMany(options,...) or do async.map(options,...).
  3. If I use Option.insertMany, how do I populate Poll with the newly created options
@CatherineKa you need to pass in a compare function
something like function(a,b) { return a-b }
if compareFunction(a, b) is less than 0, sort a to a lower index than b, i.e. a comes first.
@Manish-Giri can you help with mongodb?
@sjames1958gm help?
Kendrick Chung
@kenchung1996
Apr 22 2017 04:36

Hi everyone, I'm stuck on this exercise.
// Setup
function phoneticLookup(val) {
var result = "";

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

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

Instructions
Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable.
Peter Nguyen
@iampeternguyen
Apr 22 2017 04:41
hey can someone tell me why this while function doesn't work? i thought it would keep going if until it ran into a vowel?
function translatePigLatin(str) {
  var consonants = [];
  var regex = /[aeiou]/gi;

  str = str.split('');
  if (regex.test(str[0])){
    str = str.join('') + "way";
  }
  else {

  //while 0-x index != vowel push to var. add var to end of str. add ay and join
    regex = /[b-df-hj-np-tv-z]/gi;
    while (regex.test(str[0])){
      consonants = str.shift();  
    }
    //str = str.join('') + consonants + "ay";
  }

  return str;
}

translatePigLatin("glove");
nevermiind
figured it out =D
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:03
@kenchung1996 convert the switch statement into an object
@iampeternguyen there's while loop in JS and not function, you must always look for a way to end your loop, in while it's making the test condition come out false in the body of the loop, else it'll be an infinite loop
Mathew Gellner-Garcia
@Rafewey
Apr 22 2017 05:06

// Declarations
var studlyCapVar;
var properCamelCase;
var titleCaseOver;

// Assignments
studlyCapVar = 10;
properCamelCase = "A String";
titleCaseOver = 9000;

what is the solution to this?
I am supposed to put this into proper camelCase.
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:07
@iampeternguyen
while (regex.test(str[0])){  //this will return a boolean, what will make it return false for the next iteration of your loop in the body?
      consonants = str.shift();  
    }
Mathew Gellner-Garcia
@Rafewey
Apr 22 2017 05:07
studlyCapVar <--- this is obviously wrong.
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:08
@Rafewey why is it wrong?
seems camelCase format to me, but it depends on your instructions
Mathew Gellner-Garcia
@Rafewey
Apr 22 2017 05:09
I mean its camelCased, but its not the proper answer for the challenge.
I'm on "Understanding Case Sensitivity in Variables" under "Basic Javascript".
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:11
@Rafewey can you write the instructions?
Naveen Raju Mudhunuri
@naveenrajum
Apr 22 2017 05:12

function titleCase(str) {
return str.toLowerCase().split(" ").map(function(word){
return word[0].toUpperCase();
}).join(" ");
}

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

Mathew Gellner-Garcia
@Rafewey
Apr 22 2017 05:12
Modify the existing declarations and assignments so their names use camelCase.
Do not create any new variables.
Naveen Raju Mudhunuri
@naveenrajum
Apr 22 2017 05:12
function titleCase(str) {
   return str.toLowerCase().split(" ").map(function(word){
     return word[0].toUpperCase();
   }).join(" ");
}

titleCase("I'm a little tea pYt");
Aizaz Shahid
@aizazshahid
Apr 22 2017 05:12
@Rafewey in camelCase the first word should be in lowercase and after first word eaach word first letter should be in uppercase
Naveen Raju Mudhunuri
@naveenrajum
Apr 22 2017 05:12
could someone helpme!
Mathew Gellner-Garcia
@Rafewey
Apr 22 2017 05:12
@forwebtech Yes, I know that.
Aizaz Shahid
@aizazshahid
Apr 22 2017 05:12
@Rafewey they are already declared for you, just need to change their cases in camelCase
Mathew Gellner-Garcia
@Rafewey
Apr 22 2017 05:13

// Declarations
var studlyCapVar;
var properCamelCase;
var titleCaseOver;

// Assignments
studlyCapVar = 10;
properCamelCase = "A String";
titleCaseOver = 9000;

I have @forwebtech
pkzero2039
@pkzero2039
Apr 22 2017 05:13
Hey anyone still doing the javascript portion of the training? I am stuck on #141 and it refuses to accept what I typed in
Mathew Gellner-Garcia
@Rafewey
Apr 22 2017 05:13
It says it is wrong.
It looks completely fine to me
Aizaz Shahid
@aizazshahid
Apr 22 2017 05:13
@Rafewey copy your code and then reset it, and then check
yes sometimes browser issue :exclamation:
Naveen Raju Mudhunuri
@naveenrajum
Apr 22 2017 05:14

```
function titleCase(str) {
return str.toLowerCase().split(" ").map(function(word){
return word[0].toUpperCase();
}).join(" ");
}

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

```

Mathew Gellner-Garcia
@Rafewey
Apr 22 2017 05:14
wow...
that actually worked...
Aizaz Shahid
@aizazshahid
Apr 22 2017 05:14
:+1:
Joseph
@revisualize
Apr 22 2017 05:15
@pkzero2039 Challenges don't have numbers.
Aizaz Shahid
@aizazshahid
Apr 22 2017 05:15
@9aveen please do step by step atleast write a code that can be commented as for instructions ! !
Joseph
@revisualize
Apr 22 2017 05:15
@pkzero2039 What is the name of the challenge?
iso
@iso1048
Apr 22 2017 05:15
@9aveen you cannot change letters in a string with word[0] i think. Try using splice method.
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:16
@9aveen return word[0].toUpperCase(); you're only returning the uppercase first element of each word character which is a string, you need to returned the processed string
Aizaz Shahid
@aizazshahid
Apr 22 2017 05:16
@9aveen try to console.log(word[0]).toUpperCase() then you will understand
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:18
@9aveen you can use slice substring from the character after the first character in the map, something like word[0].toUpperCase() + substring or sliced string after the first character;
jhobotuck
@jhobotuck
Apr 22 2017 05:19
I'm struggling on the factorial challenge.
function factorialize(num) {

  var factorialOfNum = 1;

  for (var i = 1; i > num; i++) {
    factorialOfNum *= i;
  }

return factorialOfNum;
}


factorialize(5);
Returns 1. Not sure if it is looping properly.
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:19
@jhobotuck why doing this in your loop conditioni > num ?
Aizaz Shahid
@aizazshahid
Apr 22 2017 05:19
@jhobotuck in loop do i < num
because whatever the number it will always greater than your iterator
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:20
@jhobotuck because 1 > 5, will return a boolean false, your loop never runs
Aizaz Shahid
@aizazshahid
Apr 22 2017 05:20
except when user pass factorialize(0) or factorialize(1)
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:20
@jhobotuck the suggestion @forwebtech gave will help
Kendrick Chung
@kenchung1996
Apr 22 2017 05:22

@Lumexralph Thanks for the tip. However, I'm still not sure what to do after that. Here is my code:

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

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

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

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

CamperBot
@camperbot
Apr 22 2017 05:22
kenchung1996 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1551 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:23
@kenchung1996 i'll suggest you give your object a separate name other than val which is the name of your parameter
jhobotuck
@jhobotuck
Apr 22 2017 05:23
@Lumexralph and @forwebtech - Thanks guys
CamperBot
@camperbot
Apr 22 2017 05:23
jhobotuck sends brownie points to @lumexralph and @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 295 | @forwebtech |http://www.freecodecamp.com/forwebtech
:star2: 1552 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:23
@kenchung1996 i'll also suggest that your object keys be in string and not variable name
Naveen Raju Mudhunuri
@naveenrajum
Apr 22 2017 05:23
@Lumexralph Yeah
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:23
@jhobotuck :smile:
@9aveen done it?
Naveen Raju Mudhunuri
@naveenrajum
Apr 22 2017 05:24
How to return the processed array?
I am stuck at there from the last 2 hours @Lumexralph
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:25
@9aveen this is one way return word[0].toUpperCase() + word.slice(1);
you can't mutate a string but you can return the processed version
@9aveen another way return word[0].toUpperCase() + word.substr(1);
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 05:27
@Lumexralph mornin
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:27
@9aveen another way return word[0].toUpperCase() + word.substring(1);
@HeebieGeeBee Bro! morning
Kendrick Chung
@kenchung1996
Apr 22 2017 05:27
I'm running my code, its returning every single property, how do I make it return 1 value based on argument. Here is my code:

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

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

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

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

Naveen Raju Mudhunuri
@naveenrajum
Apr 22 2017 05:28
@Lumexralph
It worked bro!
Kendrick Chung
@kenchung1996
Apr 22 2017 05:28

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

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

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

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

kerafyrm02
@kerafyrm02
Apr 22 2017 05:28
who is stuck?
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:28
@kenchung1996 use another name other than than result for your object
Kendrick Chung
@kenchung1996
Apr 22 2017 05:29
declare a new variable?
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:29
@9aveen cool
Kendrick Chung
@kenchung1996
Apr 22 2017 05:29
var values = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank",
"": undefined,
};
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:29
@kenchung1996 yes, a new variable name for your object
@kenchung1996 that's okay
Kendrick Chung
@kenchung1996
Apr 22 2017 05:30
Nothing's working now, how do I make it return 1 value based on user input
How do I make it work like a switch statement, without using a switch statement.
alpox
@alpox
Apr 22 2017 05:31
@kenchung1996 object lookup with bracket notation
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:32
@kenchung1996 your val parameter will be holding the name of the property arguments passed, so use the val parameter to access the object to return the respective values
Kendrick Chung
@kenchung1996
Apr 22 2017 05:36
This is difficult.
I think I know.
Dan Couper
@DanCouper
Apr 22 2017 05:37
@kenchung1996 also, remove the undefined line; the function will return undefined anyway if you give it something that doesn't match
Kendrick Chung
@kenchung1996
Apr 22 2017 05:37
@DanCouper Thank you for pointing that out, I will do that :)
CamperBot
@camperbot
Apr 22 2017 05:37
kenchung1996 sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 650 | @dancouper |http://www.freecodecamp.com/dancouper
Joseph
@revisualize
Apr 22 2017 05:41
@kenchung1996 The function declaration was set up as... function phoneticLookup(val) { } you have a function declaration with a function name of phoneticLookup and a parameter val.
When you make the function call: phoneticLookup("charlie"); You are calling the function by name and passing the argument of "charlie" to the function parameter of val as a value.
Parameters are variable-like value that represent the values that get passed into your function from the function call (arguments). (You basically treat them like variables.)
You need to assign the value of the object property to the variable result.
How do you modify the variable result?
How do you access an object property value?
You need to re-assign the variable result the the object property value of the object that you created lookup. (As per the instructions)
Kendrick Chung
@kenchung1996
Apr 22 2017 05:50

"You need to assign the value of the object property to the variable result."

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

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

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

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

This only works for "charlie": "chicago"
Joseph
@revisualize
Apr 22 2017 05:51
@kenchung1996 because you're hard coding the value var result = "Chicago";
Kendrick Chung
@kenchung1996
Apr 22 2017 05:51
I thought so, how do I make it more dynamic?
Joseph
@revisualize
Apr 22 2017 05:51
@kenchung1996 You're not modifying result
@kenchung1996 How do you access an object property value?
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:52
@kenchung1996 result = values[val];
Kendrick Chung
@kenchung1996
Apr 22 2017 05:52
objectName.propertyName
Joseph
@revisualize
Apr 22 2017 05:52
Or someone can just give you the answer.
@kenchung1996 Dot Notation is converting the value to a string (string literal). Example: myObj.name; is the same as myObj["name"]; and as we all know quotes define strings. If you want to use a variable for accessing the value of object properties you cannot use Dot Notation. You have to use Bracket Notation. Example: var num = 42; myObj[num];
@kenchung1996 The instructions state to name the object lookup
@kenchung1996
So, when you do value[val]; you're accessing the value with the parameter val that has a value of "charlie" and to get the object property value of "Chicago".
With result = value[val]; You're assigning that object property value to the variable result. Then you're returning result.
Vikram
@vikramnr
Apr 22 2017 05:56
can i fetch next value of array in for loop?? like thisfor(var i=0;i<length.stringArr;i++){ longest=length.stringArr[i]; if(longest>lenght.stringArr[i+1]){
Ogundele Olumide
@Lumexralph
Apr 22 2017 05:58
@vikramnr what are you trying to do here if(longest>lenght.stringArr[i+1]){?
Vikram
@vikramnr
Apr 22 2017 06:00
@Lumexralph if the longest is less than current one then i'm assign it to next val else current one
Joseph
@revisualize
Apr 22 2017 06:01
@vikramnr you misspelled length
Ogundele Olumide
@Lumexralph
Apr 22 2017 06:01
@vikramnr how do you get the length of a string?
Joseph
@revisualize
Apr 22 2017 06:01
@vikramnr You're also not accessing the .length property of a string correctly.
Vikram
@vikramnr
Apr 22 2017 06:06
@Lumexralph @revisualize Why is that so??
Kendrick Chung
@kenchung1996
Apr 22 2017 06:08
result = values[val]; is the answer, I understand what it does. But coming up with it by myself would
give me many headaches
I really appreciate your help everyone.
The problem with me is that I have trouble coming up with a solution by myself. I understand exactly what the code does, I understand the order, but coming up with a solution to solve a problem all by yourself is what troubles me. Does this take time to practice or am i retarded?
Ogundele Olumide
@Lumexralph
Apr 22 2017 06:11
@kenchung1996 you're welcome, you're not in anyway retarded
@kenchung1996 i struggled at the early stages so it's not unusual, I still struggle now as I grow...... one thing I know now, is don't get caught up in the FCC challenge race
Kendrick Chung
@kenchung1996
Apr 22 2017 06:12
Thanks for sharing that, I'm glad I'm not the only one.
result = values[val]; was such a simple answer, I don't get how I couldn't think of this.
Ogundele Olumide
@Lumexralph
Apr 22 2017 06:13
@kenchung1996 if you don't know something or think you're lacking in an aspect, i'll suggest you do more research and study on that aspect and concept and when you're comfortable with it, you move to the next
Vikram
@vikramnr
Apr 22 2017 06:14
.lenght will only return array length not individual elements.. @Lumexralph Am i right
Ogundele Olumide
@Lumexralph
Apr 22 2017 06:15
@kenchung1996 it's all about taking time to understand the instructions and algorithms, I start my solution, by thinking through, writing the possible steps to the solution using pseudocode then I use the programming language to present the solution from my pseudocode
@vikramnr it'll return the length of the array, meaning the number of elelemnts in the arrray
Vikram
@vikramnr
Apr 22 2017 06:18
@Lumexralph thanks
CamperBot
@camperbot
Apr 22 2017 06:18
vikramnr sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1553 | @lumexralph |http://www.freecodecamp.com/lumexralph
Vikram
@vikramnr
Apr 22 2017 06:35
Can i get next string from the array through a for loop. I'm using arr[i+1] but it's not working
What should i use??
observelife
@observelife
Apr 22 2017 06:47

function checkObj(checkProp) {
// Your Code Here

if(myObj.hasOwnProperty("checkProp")){
return myObj.checkProp;
}
else{
return "Not Found!";
}
}
hey guys,help.Check what's wrong with it?

Aizaz Shahid
@aizazshahid
Apr 22 2017 06:48
@observelife you define your argument as a string !
@observelife checkPropis not a string !
in your function, precisely . as there
if(myObj.hasOwnProperty("checkProp")){
observelife
@observelife
Apr 22 2017 06:49
I will try it now
observelife
@observelife
Apr 22 2017 06:54
Thanks a lot. @forwebtech
CamperBot
@camperbot
Apr 22 2017 06:54
observelife sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 296 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
Apr 22 2017 06:55
:+1:
Syam Sasidharan
@syam00
Apr 22 2017 07:00
Hello All,
alpox
@alpox
Apr 22 2017 07:00
@vikramnr it should work. Go sure to check the array boundaries right
Aizaz Shahid
@aizazshahid
Apr 22 2017 07:01
@syam00 Welcome !
Syam Sasidharan
@syam00
Apr 22 2017 07:04

I am having an issue with one of the tasks in which I have to count based on card counting in black jack ..I was wondering whats happening but couldn't get it through after my several tries. so if anyone can light me up on this will greatly appreciated.

here is the code

var count = 0;

function cc(card) {
  // Only change code below this line
  var result = "Invalid";

  switch(card){
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      ++count;
      console.log(count);
      result = count + ' Bet';
      break;
    case 7:
    case 8:
    case 9:
      //dont do anything
      console.log(count);
      result = '0 Hold';
      break;
    case 10:
    case 'J':
    case 'K':
    case 'Q':
    case 'A':
      --count;
      console.log(count);
      result = "-" + count + ' Hold';
      break;
    default:
      result = "Invalid";
      break;
  }

  return result;
  // 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');
cc(10); cc(1);

but the decrement function is not working for some reason. Meaning if I send cc('K'); cc('A');
cc(10); to this function it won't decrement the count variable.

does anybody have an idea ?

sorry for making it bit long :)

it works fine with following calls cc(2); cc(3); cc(7);
Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 07:06
@syam00 can you do count += 1, and count -= 1 instead of that
Syam Sasidharan
@syam00
Apr 22 2017 07:06
okay let me try that as well..thanks @kuriakinzeng
CamperBot
@camperbot
Apr 22 2017 07:06
syam00 sends brownie points to @kuriakinzeng :sparkles: :thumbsup: :sparkles:
:cookie: 385 | @kuriakinzeng |http://www.freecodecamp.com/kuriakinzeng
Aizaz Shahid
@aizazshahid
Apr 22 2017 07:07
@kuriakinzeng what's wrong with count++ or count--
Syam Sasidharan
@syam00
Apr 22 2017 07:08
@kuriakinzeng It's same result..I have even tried the count = count + 1 & count = count - 1
Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 07:08
@syam00 i see
somehow it looks ok to me
Aizaz Shahid
@aizazshahid
Apr 22 2017 07:08
@syam00 actually you misundertood the instruction !
Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 07:08
@forwebtech maybe has other ideas?
Syam Sasidharan
@syam00
Apr 22 2017 07:09
@forwebtech : ohh :$
Aizaz Shahid
@aizazshahid
Apr 22 2017 07:09
@syam00 actually you have to return count with bet / hold, by checking whether count is positive or not !
Syam Sasidharan
@syam00
Apr 22 2017 07:10
@forwebtech ahh my bad ;(
Kuriakin Zeng
@kuriakinzeng
Apr 22 2017 07:10
@syam00 what do you get at console.log though
Aizaz Shahid
@aizazshahid
Apr 22 2017 07:11
and it should be just by one line in your return statement, like:
return  count > 0 :     count + " bet"   ?   count + " hold";
Syam Sasidharan
@syam00
Apr 22 2017 07:11
@kuriakinzeng I am getting Invalid..
@forwebtech I got it ..completely misunderstood ..
Aizaz Shahid
@aizazshahid
Apr 22 2017 07:11
@syam00 and in your switch statement just increment / decrement !
iamjoshuacolon
@iamjoshuacolon
Apr 22 2017 07:16

Hey! These are my instructions: Assign the value 7 to variable a.

Assign the contents of a to variable b.

This is my code: var a = 7;
var b = 7;
What am I missing?
Aizaz Shahid
@aizazshahid
Apr 22 2017 07:17
@iamjoshuacolon did you know what is assigning ?
@iamjoshuacolon = that is assignment operator
Abhishek Ghosh
@abhishekghosh97
Apr 22 2017 07:18
yo can someone help me
Aizaz Shahid
@aizazshahid
Apr 22 2017 07:19
at first they are saying to you that just , assign value 7 to var a and then assign a to b, and for assignment you can say that the thing which came up on right is called assigning value !
@abhishekghosh97 yes !
Abhishek Ghosh
@abhishekghosh97
Apr 22 2017 07:20
this is the q
Quoting Strings with Single Quotes
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
Aizaz Shahid
@aizazshahid
Apr 22 2017 07:21
@abhishekghosh97 whatever comes in those quotes " text " is called string. so just change double quotes to single ones , " "
sajad
@sajadk16
Apr 22 2017 07:21
@abhishekghosh97 ok , whts going on?
Syam Sasidharan
@syam00
Apr 22 2017 07:21
@forwebtech @kuriakinzeng Thanks a lot guys..really appreciated :)
CamperBot
@camperbot
Apr 22 2017 07:21
syam00 sends brownie points to @forwebtech and @kuriakinzeng :sparkles: :thumbsup: :sparkles:
:warning: syam00 already gave kuriakinzeng points
:cookie: 297 | @forwebtech |http://www.freecodecamp.com/forwebtech
Abhishek Ghosh
@abhishekghosh97
Apr 22 2017 07:22
Change the provided string from double to single quotes and remove the escaping.
Aizaz Shahid
@aizazshahid
Apr 22 2017 07:23
yes
but you have to do with the outer one only " <a....... " to ' <a .... `
sajad
@sajadk16
Apr 22 2017 07:23
hey guys someone help me

function nextInLine(arr, item) {
// Your code here
test=testArr[0];
testArr[0]=testArr[1];
testArr[1]=testArr[2];
testArr[2]=testArr[3];
testArr[3]=testArr[4];
testArr[4]=item;
return test; // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

Abhishek Ghosh
@abhishekghosh97
Apr 22 2017 07:24
@forwebtech thanks
CamperBot
@camperbot
Apr 22 2017 07:24
abhishekghosh97 sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 298 | @forwebtech |http://www.freecodecamp.com/forwebtech
sajad
@sajadk16
Apr 22 2017 07:24
i try it and give an right ans..
but Camp say another things...
Daniel Romero
@Ranacode
Apr 22 2017 07:30
@Ranacode
Hi guys, any tips on the steamroller challenge? im trying to write an small algorithm that check if the contents of the array is an another array and break the loop when it return false on this and push the element into the new array
I'm using the .isArray function
Aizaz Shahid
@aizazshahid
Apr 22 2017 07:30

@abhishekghosh97 an example of usage for quotes:

var  variable1  =  "some string";

// if doubles quotes require to use in that so you should to escape it like:

variable = "some \"string\" ";

same goes to single one, wants to use single quotes within same quotes, like:

variable = 'some \'string\' ';

but different quotes can be used without escaping it:

variable = " some 'string'";
variable = ' some "string"';
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:31
@Ranacode share your code
gheorghiank
@gheorghiank
Apr 22 2017 07:34
hi! need help with "convert Celsius to Fahrenheit" !!!!
sajad
@sajadk16
Apr 22 2017 07:35
whts going on?
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:36
@gheorghiank what do you need help with?
gheorghiank
@gheorghiank
Apr 22 2017 07:36

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit = 0 9/5 + 32;
fahrenheit = -30
9/5 + 32;
fahrenheit = -10 9/5 + 32;
fahrenheit = 20
9/5 + 32;
fahrenheit = 30 * 9/5 + 32;

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

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

HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:36
what have you tried?
@gheorghiank right youre meant to use the formula
youre not mean to hardcode the values like that
gheorghiank
@gheorghiank
Apr 22 2017 07:37
@HeebieGeeBee it's not working...what do I do wrong?
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:37
do you see what the formula is?
gheorghiank
@gheorghiank
Apr 22 2017 07:38
@HeebieGeeBee no
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:38
@gheorghiank its in the instructions youre kind of using it
its celsius * 9/5 + 32
and becuase the function has a parameter of celsius that means whenever someone makes the function call they can pass in an argument
that will be a temperature in celsius
so when writing the function we use parameters to represent a value
in this case we're using celsius to represent a value that someone will call the function with
@gheorghiank so how would you assign the formula celsius*9/5+32 to the fahrenheit variable?
gheorghiank
@gheorghiank
Apr 22 2017 07:41

@HeebieGeeBee
function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit = celsius * 9/5 + 32;

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

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

HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:41
@gheorghiank yes
gheorghiank
@gheorghiank
Apr 22 2017 07:41
@HeebieGeeBee like this
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:41
so do you understand whats happening here?
its kind of fundamental to how functions work
gheorghiank
@gheorghiank
Apr 22 2017 07:42
@HeebieGeeBee thank you
CamperBot
@camperbot
Apr 22 2017 07:42
gheorghiank sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1413 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
gheorghiank
@gheorghiank
Apr 22 2017 07:42
@HeebieGeeBee not quite...but i am trying
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:42
@gheorghiank its importand to understand why youre writing each element of the function
@gheorghiank want to go through it it?
gheorghiank
@gheorghiank
Apr 22 2017 07:43
@HeebieGeeBee yes
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:43
ok the first line function convertToF(celsius) {
what do you think this is doing?
first of why would we write function
gheorghiank
@gheorghiank
Apr 22 2017 07:44
@HeebieGeeBee :( have no idea
tell the programme that it has to execute something
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:45
not quite
its a declaration of a function
gheorghiank
@gheorghiank
Apr 22 2017 07:45
ok
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:45
so just like when we declare a variable with var
gheorghiank
@gheorghiank
Apr 22 2017 07:45
go on pls
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:46
this is a declaration of a function
gheorghiank
@gheorghiank
Apr 22 2017 07:46
ok
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:46
and then convertToF
this is the functions name
gheorghiank
@gheorghiank
Apr 22 2017 07:46
aha
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:47
so in the future when we want to call this function we refer to it using its name
then the part in the parenthesis
gheorghiank
@gheorghiank
Apr 22 2017 07:47
ok...now it makes more sense
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:47
(celsius) these are the functions parameters
similar to variables
gheorghiank
@gheorghiank
Apr 22 2017 07:47
aha
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:48
that we can use when writing the algorithm or the function
they will represent values that will get passed in as arguments when the function gets called
Peter Nguyen
@iampeternguyen
Apr 22 2017 07:48
hey would anyone mind giving me feedback on this code? it works, but i used arguments instead of arr and i feel like maybe i shouldn't have done it that way?

function uniteUnique(arr) {
  var i = 0;
  var j = 0;
  var newArray = [];
  while (i < arguments.length){
    while (j < arguments[i].length){
      if (newArray.indexOf(arguments[i][j]) < 0 ) {
        newArray.push(arguments[i][j]);
        }
      j++;
    }
    i++;
    j=0;
  }

  return newArray;
}

uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
i'm supposed to create a new array of all unique numbers
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:49
so when you see something like convertToF(30); this is a function call of the convertToF function with the value of 30 being passed in as an argument @gheorghiank
gheorghiank
@gheorghiank
Apr 22 2017 07:49
@HeebieGeeBee following you :)
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:49
so when we write celsius * 9/5 + 32 inside the function
when the function gets called convertToF(30) that then becomes 30 * 9/5 + 32
because celsius is representing the value of the argument
so if we call the function with convertToF(5) it then becomes 5* 9/5 + 32 and so on
gheorghiank
@gheorghiank
Apr 22 2017 07:52
because we assign the value of 5 or whatever to the celsius argument
right?
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:52
@gheorghiank yes when we call the function
gheorghiank
@gheorghiank
Apr 22 2017 07:52
ok...the terms are killing me :(
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:53
@gheorghiank it gets better the more you use them
gheorghiank
@gheorghiank
Apr 22 2017 07:53
@HeebieGeeBee but now I've got it...at least the process behind it
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:53
one last thing do you understand what return in a function does?
gheorghiank
@gheorghiank
Apr 22 2017 07:54
yes...it gives the result
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:54
@iampeternguyen you have to use arguments, as the fucntion on has one parameter
@gheorghiank sort of
micojay020
@micojay020
Apr 22 2017 07:54
can someone help me
gheorghiank
@gheorghiank
Apr 22 2017 07:54
@HeebieGeeBee tell me pls
micojay020
@micojay020
Apr 22 2017 07:54
so whats wrong with my code
// 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
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:55
first off @gheorghiank a return in side the fucntion will stop all processes of the function
micojay020
@micojay020
Apr 22 2017 07:55
its saying the i should use the variable player number in my bracket notation
heroiczero
@heroiczero
Apr 22 2017 07:55
@micojay020 you have to use playerNumber inside your bracket i think
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:55
you can just write return inside a function when you wont it to stop running all its processes
micojay020
@micojay020
Apr 22 2017 07:55
i dont get it
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:56
but if you add a value to be returned when you make a return
micojay020
@micojay020
Apr 22 2017 07:56
what do you mean by that @heroiczero
gheorghiank
@gheorghiank
Apr 22 2017 07:56
@HeebieGeeBee you ve lost me
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:56
it will also give you that value you
micojay020
@micojay020
Apr 22 2017 07:56
i dont get it
heroiczero
@heroiczero
Apr 22 2017 07:57

@micojay020 the purpose of the exercise is to access the testObj with the use of a variable so

var player = testObj["16"];

gotta use a variable instead of "16"

devpaaji
@devpaaji
Apr 22 2017 07:58
@gheorghiank a function is a like a machine which takes ingredients and generates the end product
end product = return some value
gheorghiank
@gheorghiank
Apr 22 2017 07:59
@devpaaji ok. this means I have to have return and a value, right?
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 07:59
function example(num) {
     console.log(num);
      return;
}

example(5) // this call doesnt return any value but it will console.log(5)

function example2(num) {
        return num + 5
}

example2(5) // this call will return a value of 10
devpaaji
@devpaaji
Apr 22 2017 07:59
function addMe(a, b){

return a + b;
}
so here addMe is a machine
a, b are ingredients
return a + b is the end product
a function must return smething
gheorghiank
@gheorghiank
Apr 22 2017 08:00
@devpaaji got that
devpaaji
@devpaaji
Apr 22 2017 08:00
just like a machine is created for that purpose to produce something
however if it does not
gheorghiank
@gheorghiank
Apr 22 2017 08:00
@HeebieGeeBee i don't get the first part...what's the use again?
devpaaji
@devpaaji
Apr 22 2017 08:00
that gives us undefined
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 08:01
@gheorghiank its just an example, you can make functions do operations, without having a value returned
@micojay020 you're meant to use the playerNumber variable to lookfor a value in the test object
gheorghiank
@gheorghiank
Apr 22 2017 08:03
@HeebieGeeBee ok. i understand that. but when and why do i use such a function that doe not return value?
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 08:03
@gheorghiank you will come accross them in the future its just best for now, you understand what a return does
Matthew Hoth
@kingofthecross
Apr 22 2017 08:04

Hey guys, what am I missing here? trying to pop off a variable and then assign it:

var removedFromMyArray = myArray[1];
myArray.pop(1);

gheorghiank
@gheorghiank
Apr 22 2017 08:04
@devpaaji @HeebieGeeBee thank you for making it a bit clearer :)
CamperBot
@camperbot
Apr 22 2017 08:04
gheorghiank sends brownie points to @devpaaji and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:warning: gheorghiank already gave heebiegeebee points
:cookie: 234 | @devpaaji |http://www.freecodecamp.com/devpaaji
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 08:04
the most important thing to know about them is that the will stop all the functions operation when they are hit, and they will return a value if theyre assigned a value to return
@gheorghiank
@gheorghiank so in the temp function you write return fahrenheit so that means youre ending the functions operation and you want the value of the fahrenheit variable returned when it does
devpaaji
@devpaaji
Apr 22 2017 08:05
@gheorghiank when you call return the machine stops
as it has done its job of giving you the end product
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 08:06
@kingofthecross just assign the pop to the variable
gheorghiank
@gheorghiank
Apr 22 2017 08:07
so the return ends the function? no matter if you ask for a return value or not, right?
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 08:07
@gheorghiank yes
gheorghiank
@gheorghiank
Apr 22 2017 08:07
@devpaaji @HeebieGeeBee now i got it
devpaaji
@devpaaji
Apr 22 2017 08:07
understand the story
it will be with you forever
when you connect programming with real life scenarios....everything seems a lot easy
gheorghiank
@gheorghiank
Apr 22 2017 08:08
@HeebieGeeBee @devpaaji question: return is always inside the function?
devpaaji
@devpaaji
Apr 22 2017 08:09
i ask you a question
what you think
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 08:09
@gheorghiank yes
devpaaji
@devpaaji
Apr 22 2017 08:09
when will a return work
gheorghiank
@gheorghiank
Apr 22 2017 08:09
@HeebieGeeBee ok
devpaaji
@devpaaji
Apr 22 2017 08:09
when you give some ingredients
isnt 't
gheorghiank
@gheorghiank
Apr 22 2017 08:10
@devpaaji i didn't quite understand your question :(
devpaaji
@devpaaji
Apr 22 2017 08:11
no worries
I will as again
gheorghiank
@gheorghiank
Apr 22 2017 08:11
@devpaaji ok
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 08:11
@gheorghiank things will be better, if you understand why every line is written in code, rather than just trying to race through challenges
devpaaji
@devpaaji
Apr 22 2017 08:12
according to the story where should return be?
return = end product = give me something
gheorghiank
@gheorghiank
Apr 22 2017 08:12
@HeebieGeeBee i understood everything up to this java :( this is hard for me...hope it will get better
devpaaji
@devpaaji
Apr 22 2017 08:12
machine => ingredients = > return
@gheorghiank
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 08:13
@gheorghiank it will , and just for future reference java and javscript are different
gheorghiank
@gheorghiank
Apr 22 2017 08:13
@devpaaji yes...i got that
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 08:13
so you might see things online about java that wont work in javascript
gheorghiank
@gheorghiank
Apr 22 2017 08:13
@HeebieGeeBee sorry...i meant java scripy
@devpaaji i need to call the function
i need to give it a name
i need to assign a value...
and then ask for the return
devpaaji
@devpaaji
Apr 22 2017 08:15
yep
perfect
@gheorghiank
gheorghiank
@gheorghiank
Apr 22 2017 08:15
@devpaaji tks
@devpaaji @HeebieGeeBee but i will still need help with this...i will 'bother' you again
devpaaji
@devpaaji
Apr 22 2017 08:17
@gheorghiank sure check the links I share on PM
gheorghiank
@gheorghiank
Apr 22 2017 08:18
@devpaaji ???
Mushtaq
@mahalepoto
Apr 22 2017 08:32

Hi good people..........Accessing Objects Properties with Variables
Another use of bracket notation on objects is to use a variable to access a property. This can be very useful for iterating through lists of the object properties or for doing the lookup.

Here is an example of using a variable to access a property:

var someProp = "propName";
var myObj = {
propName: "Some Value"
}
myObj[someProp]; // "Some Value"
Here is one more:

var myDog = "Hunter";
var dogs = {
Fido: "Mutt",
Hunter: "Doberman",
Snoopie: "Beagle"
}
var breed = dogs[myDog];
console.log(breed);// "Doberman"
Note that we do not use quotes around the variable name when using it to access the property because we are using the "value of the variable, not the name???".

Can some body help me with this????
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 08:33
@gheorghiank no problem, there are lots of very smart ppl in the chat always willing to help
Mushtaq
@mahalepoto
Apr 22 2017 08:33
as far as my understanding is they are using variable name not its value ?????
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 08:35
@mahalepoto the variables value is being used to access the value of the property in the object
Mushtaq
@mahalepoto
Apr 22 2017 08:36
ahhhh........through variable's name ?
@HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 08:37
well yes, the variable just holds a value
but to use the variable you need to refer to it using its name
Mushtaq
@mahalepoto
Apr 22 2017 08:37
hummm not directly........Thanks @HeebieGeeBee
CamperBot
@camperbot
Apr 22 2017 08:37
mahalepoto sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1414 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 08:38
@mahalepoto what do you mean not directly?
Mushtaq
@mahalepoto
Apr 22 2017 08:40
@HeebieGeeBee never mind ....cheers though
Peter Nguyen
@iampeternguyen
Apr 22 2017 08:57
hey all i'm working on the convert html entities challenge and I got it to work but I want to create a var map instead. so when i do the string replace, it looks at the mapped function and returns the proper html value, but i can't figure out how to structure the variable to get it to work.
function convertHTML(str) {
  // &colon;&rpar;
  var map = {
    /&/: "&amp;"
  };

  str = str.replace(/&/g, "&amp;"); 
  str = str.replace(/</g, "&lt;");
  str = str.replace(/>/g, "&gt;");
  str = str.replace(/"/g, "&quot;");
  str = str.replace(/'/g, "&apos;");
  return str;
}

convertHTML('Stuff in "quotation marks"');
Harshil Bhagat
@Harshil-bhagat
Apr 22 2017 09:01

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = myNoun+myAdjective+myVerb+myAdverb;
// Your code below this line

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog","big","ran","quickly");

some body help me in this madlibs
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:03
 var map = {
    &: "&amp;"
  };

  str = str.replace(/&/g, map.&);
@iampeternguyen is that what you want to do?
@Harshil-bhagat you need to make a sentenece using the function parameters along with special characters such as spaces and other words, and have it assigned to the result variable so it gets returned in the function
@iampeternguyen i dont really see what benefit that lookup object would have though
Peter Nguyen
@iampeternguyen
Apr 22 2017 09:06
@HeebieGeeBee kind of, but i plan on having all the characters in there. like ' " < > &
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:06
@iampeternguyen yes i just used the and for an example
obviously you need to add the rest
Peter Nguyen
@iampeternguyen
Apr 22 2017 09:07
but i feel like when i get to the ' " won't i have some issues?
var str = "I have a cat, a dog, and a goat.";
var mapObj = {
   cat:"dog",
   dog:"goat",
   goat:"cat"
};
str = str.replace(/cat|dog|goat/gi, function(matched){
  return mapObj[matched];
});
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:08
@iampeternguyen ok
well try it and see
Sandbagger
@Sandbagger
Apr 22 2017 09:10
Why is the .length in the statement of the for loop considered undefined? ``` var nums = [];
for(i = 0; i <= arr.length; i++) {
nums.push(arr[i].length);
} ````
well that didn't come out like I wanted
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:11
@Sandbagger what is arr?
Sandbagger
@Sandbagger
Apr 22 2017 09:11
sorrry, it is an array of strings
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:11
and it probably should be i < arr.length
other wise the last index might be undefined
Sandbagger
@Sandbagger
Apr 22 2017 09:14
@HeebieGeeBee Thank you! Some progress
CamperBot
@camperbot
Apr 22 2017 09:14
sandbagger sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1415 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Rionangelfire
@Rionangelfire
Apr 22 2017 09:14
hellow world
Rionangelfire
@Rionangelfire
Apr 22 2017 09:20

// Setup
var a;
var b = 2;

// Only change code below this line
var a = 7;
b= 7;

a should be assigned to b with =
Rionangelfire
@Rionangelfire
Apr 22 2017 09:26

// Setup
var a;
var b = 2;

// Only change code below this line
a = b = 7;

devpaaji
@devpaaji
Apr 22 2017 09:29
@HeebieGeeBee
var foo = function foo() {
    console.log(foo === foo);  
};
foo();
Baderfahad
@Baderfahad
Apr 22 2017 09:30
hey guys !
bunnybae
@bunnybae
Apr 22 2017 09:30
myVar = 1 + myVar++;
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:30
@Rionangelfire assigning a to b is b = a
Baderfahad
@Baderfahad
Apr 22 2017 09:30
I am confused with gold excercise haha!
golf
bunnybae
@bunnybae
Apr 22 2017 09:30
myVar = myVar should be changed
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:30
@devpaaji ??
what do am i meanto to do with that?
@bunnybae myVar = myVar +1 is the same as myVar++
@Baderfahad whats confusing you about it?
devpaaji
@devpaaji
Apr 22 2017 09:32
why it is true
bunnybae
@bunnybae
Apr 22 2017 09:32
What does this mean "myVar = myVar should be changed" how can i change the myVar?
devpaaji
@devpaaji
Apr 22 2017 09:32
@HeebieGeeBee
there is a var foo that holds a function
and then there is a function foo
bunnybae
@bunnybae
Apr 22 2017 09:32
@HeebieGeeBee How can i write it differently
devpaaji
@devpaaji
Apr 22 2017 09:33
after the code we are calling foo();
bunnybae
@bunnybae
Apr 22 2017 09:33
because it says the myVar = myVar should be changed
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:33
@devpaaji no idea
Baderfahad
@Baderfahad
Apr 22 2017 09:33
@HeebieGeeBee how should I start :P !
Pieter Stokkink
@forkerino
Apr 22 2017 09:33
@devpaaji everything compared to itself is true, with the exception in JS of NaN
meurning!
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:34
@forkerino moarrneeng
devpaaji
@devpaaji
Apr 22 2017 09:34
@forkerino
var foo = function foo() {
    console.log(typeof foo);  // function
    console.log(foo === foo);  
};
foo();
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:35
@bunnybae thought i just said
Pieter Stokkink
@forkerino
Apr 22 2017 09:35
@devpaaji yeah a function is a function
devpaaji
@devpaaji
Apr 22 2017 09:35
is this var foo diff from function foo() ?
then how they are equal
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:36
looks like a variable foo is holding a function called foo
Pieter Stokkink
@forkerino
Apr 22 2017 09:37
foo holds a reference to the function foo(). So when you type foo === foo, JS checks to see if they refer to the same thing. Obviously they do.
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:37
@forkerino still in germany?
Pieter Stokkink
@forkerino
Apr 22 2017 09:37
@HeebieGeeBee Amsterdam!
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:37
oh nice
how is it?
Pieter Stokkink
@forkerino
Apr 22 2017 09:37
visiting the fam
cold and wet
I'm hiding inside
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:37
brutal
Pieter Stokkink
@forkerino
Apr 22 2017 09:38
indeed.
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:38
though i do kinda lke amsterdam when its cold and wet
Pieter Stokkink
@forkerino
Apr 22 2017 09:38
I'm here by myself, so enjoying the freedom
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:38
lol nice
Pieter Stokkink
@forkerino
Apr 22 2017 09:38
left gf and daughter at her mother for a bit
Deepan Udaiyar
@CodeToOvercome
Apr 22 2017 09:39
Hey guys, i am stuck in Basic Algorithm challenge "Factorialize a number"
Pieter Stokkink
@forkerino
Apr 22 2017 09:40
I like Amsterdam even when it is stormy and raining buckets.
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:41
yeah plus less ppl on the streets so you can enjoy it more
Rionangelfire
@Rionangelfire
Apr 22 2017 09:41
thank you @HeebieGeeBee
CamperBot
@camperbot
Apr 22 2017 09:41
rionangelfire sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1416 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:41
lik ewalking around like im in a 70's avant garde french film
Baderfahad
@Baderfahad
Apr 22 2017 09:42
ok guys a got it !!
lol
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:43
@CodeToOvercome need to elaborate a bit more, what you having a problem with, what have you tried?
Deepan Udaiyar
@CodeToOvercome
Apr 22 2017 09:49
@HeebieGeeBee i forgot basic concepts that i learned..I know the logic to get it working but forgot the methods ..
devpaaji
@devpaaji
Apr 22 2017 09:49
@forkerino
alert("1" - - "1");
gives 2
randprs101
@randprs101
Apr 22 2017 09:49
Hey everyone! Could someone please help me with using objects for lookups? I understand what objects are and how to make them but I don't really understand this challenge very well.
devpaaji
@devpaaji
Apr 22 2017 09:49
when we use arithmetic operators
how are they getting converted
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:50
@CodeToOvercome can always go back and review previous challenges
randprs101
@randprs101
Apr 22 2017 09:51
Anyone?
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:51
@devpaaji 1 - -1 is 2
devpaaji
@devpaaji
Apr 22 2017 09:51
@randprs101 yes please
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:51
just generally in maths
Deepan Udaiyar
@CodeToOvercome
Apr 22 2017 09:51
@HeebieGeeBee yup that's what am doing now..
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:52
@randprs101 it wants you to return the value from the lookup object that you create
Pieter Stokkink
@forkerino
Apr 22 2017 09:52
@devpaaji the - operator coerces the values to a number if possible, if not, it will give NaN, I think (test it!)
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:52
thats in the val key
randprs101
@randprs101
Apr 22 2017 09:54
@HeebieGeeBee Okay but what value should be going in the case? For e.g., the name of the case is "alpha" but the result is "Adams"
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:55
the val parameter
wait what you having problem with?
randprs101
@randprs101
Apr 22 2017 09:56
Making the list of cases with values
I did mention val already
But I don't understand why it's var alpha in the given example
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 09:56
the object should be converted from the swithc statments so thats its alpha: "Adams"
randprs101
@randprs101
Apr 22 2017 09:57
Okay I'll try that
@HeebieGeeBee
randprs101
@randprs101
Apr 22 2017 10:04
Thanks
gheorghiank
@gheorghiank
Apr 22 2017 10:05
@HeebieGeeBee how do I paste in here the code as a picture?
Pieter Stokkink
@forkerino
Apr 22 2017 10:09
@gheorghiank ''' check more info below. You will have to find the ` backtick key on your keyboard....
CamperBot
@camperbot
Apr 22 2017 10:09
:bulb: to format code use backticks! ``` more info
gheorghiank
@gheorghiank
Apr 22 2017 10:13
@forkerino thank you
CamperBot
@camperbot
Apr 22 2017 10:13
gheorghiank sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1839 | @forkerino |http://www.freecodecamp.com/forkerino
Ankur sharma
@ankur1163
Apr 22 2017 10:21
that is cool
@HeebieGeeBee
gheorghiank
@gheorghiank
Apr 22 2017 10:22
@HeebieGeeBee thank you again
CamperBot
@camperbot
Apr 22 2017 10:22
gheorghiank sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1417 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Peter Nguyen
@iampeternguyen
Apr 22 2017 10:25
is there a regexp code to avoid the first character of a string?
or ignore rather
devpaaji
@devpaaji
Apr 22 2017 10:27
var bar = 1,
    foo = {};

foo: {
    bar: 2;
    baz: ++bar;
};
foo.baz + foo.bar + bar;
@HeebieGeeBee
why is this NaN
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 10:28
@devpaaji no idea
devpaaji
@devpaaji
Apr 22 2017 10:28
ok
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 10:28
tag @forkerino and ask him
Mathew Gellner-Garcia
@Rafewey
Apr 22 2017 10:29
How do i post my code into the chat?
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 10:29
@Rafewey scroll up theres a gif about it
Mathew Gellner-Garcia
@Rafewey
Apr 22 2017 10:30
function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line
  fahrenheit = (fahrenheit * (9/5)) + 32;
  // Only change code above this line
  return fahrenheit;
}

// Change the inputs below to test your code
convertToF(30);
can someone tell me why this doesnt work?
Andrew
@AndrewKTai
Apr 22 2017 10:31
@Rafewey your not using celsius in your fahrenheit equation
Mathew Gellner-Garcia
@Rafewey
Apr 22 2017 10:32
@AndrewKTai oh shoot
@AndrewKTai i feel so dumb...
Andrew
@AndrewKTai
Apr 22 2017 10:33
@Rafewey we all have those moments haha
gheorghiank
@gheorghiank
Apr 22 2017 10:34
@Rafewey fahrenheit = celsius *9/5 +32;
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 10:36
@gheorghiank a space
gheorghiank
@gheorghiank
Apr 22 2017 10:36
what am I missing?
where?
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 10:37
where do spaces usually come when writing multiple sentences
gheorghiank
@gheorghiank
Apr 22 2017 10:37
got it
at the end of the first one :)
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 10:38
yup
bilaal-s
@bilaal-s
Apr 22 2017 10:38
Good morning gitter! Asuming I have element with the class "tablecell--disabled" and all table cells have the class tablecell inside my html, why does the following code not work?
  const tabletd = document.getElementsByClassName('table__cell');

  //We can also replace Jquery's hasClass with our own class verifcation function.
  function isClass(element, cn){
    let classes = element.classList;
    for(let j = 0; j < classes.length; j++){
        if(classes[j] == cn){
            return true;
        } 
    }
  }

  for (let i = 0; i < tabletd.length; i++) {
    if (isClass(tabletd[i],'table__cell--disabled') === true) {
      console.log("Success!")
    }
  }
Daria
@Dashikin
Apr 22 2017 10:39
hey! Can't find how to make work task "Generate Random Fractions with JavaScript". Anyone can help?
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 10:39
@Dashikin need to use Math.random()
Daria
@Dashikin
Apr 22 2017 10:40
@HeebieGeeBee I've read the task =D
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 10:40
@Dashikin what have you tried?
Pieter Stokkink
@forkerino
Apr 22 2017 10:42
@bilaal-s .classList doesn't return an array, I think.
Daria
@Dashikin
Apr 22 2017 10:42
@HeebieGeeBee i did it. I tried to find harder solution that it was needed
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 10:43
@Dashikin i mean can you paste your code to show what you have tried
Moisés Man
@moigithub
Apr 22 2017 10:43
@bilaal-s cuz u selectin non disbbled class only
bilaal-s
@bilaal-s
Apr 22 2017 10:43
@forkerino Aha, I will have a look into that!
Daria
@Dashikin
Apr 22 2017 10:44
Solution:

function randomFraction() {
return Math.random()
// Only change code below this line.

return 0;

// Only change code above this line.
}

bilaal-s
@bilaal-s
Apr 22 2017 10:44
@moigithub what do you mean my friend? the --disabled portion?
Moisés Man
@moigithub
Apr 22 2017 10:44
@bilaal-s use a css start with selector ^
Parvesh garg
@parveshgarg24
Apr 22 2017 10:44
how that a array contain a another array or not??
Moisés Man
@moigithub
Apr 22 2017 10:45
Yes @bilaal-s
bilaal-s
@bilaal-s
Apr 22 2017 10:45
@moigithub will try that one moment! :)
Pieter Stokkink
@forkerino
Apr 22 2017 10:45
@parveshgarg24 do you mean to ask how you can know if an array contains another array?
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 10:45
@Dashikin that doesnt work?
Daria
@Dashikin
Apr 22 2017 10:45
@HeebieGeeBee work
Parvesh garg
@parveshgarg24
Apr 22 2017 10:46
@forkerino yeah
HeebieGeeBee
@HeebieGeeBee
Apr 22 2017 10:46
@Dashikin delete the return 0 too
@Dashikin i dont understand what the problem youre having though that should work fine
rugano
@rugano
Apr 22 2017 10:47
Hello campers
Parvesh garg
@parveshgarg24
Apr 22 2017 10:47
hello
Pieter Stokkink
@forkerino
Apr 22 2017 10:47
@parveshgarg24 you can use the Array.isArray() method to check each element.
say i have arr = [1,[2,3],4,5], the second element is the subarray [2,3]. Array.isArray(arr[1]) will return true
Parvesh garg
@parveshgarg24
Apr 22 2017 10:48
@forkerino ty
CamperBot
@camperbot
Apr 22 2017 10:48
parveshgarg24 sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1840 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Apr 22 2017 10:48
:+1:
rugano
@rugano
Apr 22 2017 10:50
What is wrong with my interpretation of the Profile Lookup challenge?I have only highlighted the first object.
Pieter Stokkink
@forkerino
Apr 22 2017 10:50
@rugano show your function (not the contacts array).
rugano
@rugano
Apr 22 2017 10:51
@forkerino ok,
Aizaz Shahid
@aizazshahid
Apr 22 2017 10:59

Challenge: Truncate a string

function sliceWithDots(str, endIndex) {
  return str.slice(0, endIndex).concat("...");
}

function truncateString(str, num) {

  if(str.length > num)   
    return num > 3 ? sliceWithDots(str, num-3) : sliceWithDots(str, num);
  else
    return str;

}

any better way ?

Pieter Stokkink
@forkerino
Apr 22 2017 11:01

I like the simple one I wrote:

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

I also have a oneliner, but I know you don't like those ;)

Aizaz Shahid
@aizazshahid
Apr 22 2017 11:02
show me ?
rugano
@rugano
Apr 22 2017 11:02
function lookUpProfile(firstName,prop){
//Only change code below this line
lookUpProfile.hasOwnProperty();

if("firstName" === "0543236543"){
output = "Laine";
}else{
output = "No such contact";
}if("prop" === "0543236543"){
output = ["Pizza","Coding","Brownie Points"];
}else{
output = "No such property";
}

return output;
//only change code above this line
}

//Change these values to test your function
lookUpProfile("Akira", "likes");
Aizaz Shahid
@aizazshahid
Apr 22 2017 11:04
@rugano your function hasn't that property , lookUpProfile.hasOwnProperty(); so just remove it !
Pieter Stokkink
@forkerino
Apr 22 2017 11:04

@forwebtech

const truncateString = (str, num) => num >= str.length ? str : num<=3 ? str.slice(0,num)+"..." : str.slice(0, num-3) + "...";

It is probably the least readable oneliner for the basic algos

Aizaz Shahid
@aizazshahid
Apr 22 2017 11:04
that is your function name !
@rugano
@forkerino can you tell me the procedure how you write code in one-line ?
CatherineKa
@CatherineKa
Apr 22 2017 11:05
Anyone knows how to sort an array by the length of the words in it?
Moisés Man
@moigithub
Apr 22 2017 11:06
U can move ternary inside slice @forkerino
Pieter Stokkink
@forkerino
Apr 22 2017 11:06
@moigithub !!! hadn't thought of that! Thanks!
CamperBot
@camperbot
Apr 22 2017 11:06
forkerino sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3149 | @moigithub |http://www.freecodecamp.com/moigithub
Aizaz Shahid
@aizazshahid
Apr 22 2017 11:07
@forkerino but that one is ES6 version
Keon Samuel
@keonsam
Apr 22 2017 11:07
no ES6 oo.
no english
rugano
@rugano
Apr 22 2017 11:07
@forwebtech yes,
Keon Samuel
@keonsam
Apr 22 2017 11:07
lol tic tac toe is sending me crazy.
Aizaz Shahid
@aizazshahid
Apr 22 2017 11:08
@forkerino can you tell the procedure ??
Pieter Stokkink
@forkerino
Apr 22 2017 11:08
@forwebtech ES6 syntax helps a lot, yes, but when writing oneliners, it is about being concise: cutting out intermediate variables (not always a good idea, often two lines are better than one, such as this case), removing everything unnecessary
Keon Samuel
@keonsam
Apr 22 2017 11:09
give me the tic tac toe AI.
Aizaz Shahid
@aizazshahid
Apr 22 2017 11:09
@forkerino so what i did is alright then ??
@forkerino more readable !
devpaaji
@devpaaji
Apr 22 2017 11:10
function foo(a, b) {
    arguments[1] = 2;
    alert(b); // undefined, I worked out to be 2
}
foo(1);
arguments[1] = 2; is value of b
Pieter Stokkink
@forkerino
Apr 22 2017 11:10
@forwebtech sure. I don't know if I would create a separate function for adding three dots to a slice. I don't think your version is more readable than the first one I posted, though, mostly because of that separate function.
Aizaz Shahid
@aizazshahid
Apr 22 2017 11:10
@devpaaji what are you doing ??
devpaaji
@devpaaji
Apr 22 2017 11:11
@forwebtech
i thik this is incorrect
Aizaz Shahid
@aizazshahid
Apr 22 2017 11:11
@forkerino i just thought of refactoring !
devpaaji
@devpaaji
Apr 22 2017 11:11
for args o work
it needs parameters
Aizaz Shahid
@aizazshahid
Apr 22 2017 11:11
@devpaaji then my mistake, don't know about that.
Keon Samuel
@keonsam
Apr 22 2017 11:12
can you call a function way otherside a function?
devpaaji
@devpaaji
Apr 22 2017 11:12
@forkerino
this works
Keon Samuel
@keonsam
Apr 22 2017 11:12
like far otherside.
devpaaji
@devpaaji
Apr 22 2017 11:12
function foo(a, b) {
    arguments[1] = 2;
    alert(b); //  2
}
foo(1, 2);
@forwebtech no thats fine
no worries mate
Keon Samuel
@keonsam
Apr 22 2017 11:13
like a function within a function calling a function outside of that function that is within in another function ?
Kim Ford
@kimfucious
Apr 22 2017 11:15
In some of the JS challenges dot notation doesn't work, while brackets notation does.
I'm not sure if there's a reason or just me.
For example in [Testing Objects for Properties] :(https://www.freecodecamp.com/challenges/testing-objects-for-properties)
return myObj[checkProp]; will work, but return myObj.checkprop; will not.
Dan Couper
@DanCouper
Apr 22 2017 11:16
The second one, you're trying to look for a property literally called ch
eckProp
Tyler
@TychoCRD
Apr 22 2017 11:16
@kimfucious is checkProp a variable? Variables can only be used in brackets
Aizaz Shahid
@aizazshahid
Apr 22 2017 11:17
@kimfucious because you are passing an argument !
Keon Samuel
@keonsam
Apr 22 2017 11:17
I only need the ai to finish the tic tac toe
Dan Couper
@DanCouper
Apr 22 2017 11:17
Ah, the easy bit ;)
Aizaz Shahid
@aizazshahid
Apr 22 2017 11:18
@kimfucious that means if you do like that

function checkObj(checkProp) {
  // Your Code Here

  return ((myObj.hasOwnProperty(checkProp)) ? myObj.checkProp  : "Not Found");

}
Pieter Stokkink
@forkerino
Apr 22 2017 11:18
@devpaaji in the case where you pass in only one argument to the function, arguments[1] does not refer to b, as it is undefined (arguments.length = 1, you see). So assigning to arguments[1], does not alter b.
Aizaz Shahid
@aizazshahid
Apr 22 2017 11:18
now as you told it didn't work, because of the passing an argument !
Moisés Man
@moigithub
Apr 22 2017 11:19
NO dot notation with variables like checkprop @forwebtech
Aizaz Shahid
@aizazshahid
Apr 22 2017 11:19
@moigithub i know that !
Pieter Stokkink
@forkerino
Apr 22 2017 11:19
@keonsam dude, you are asking someone else to do most of the heavy lifting. Look up some algorithm online or figure it out on your own. We can only help if you have some code to show.
Aizaz Shahid
@aizazshahid
Apr 22 2017 11:20
:point_up: April 22, 2017 4:15 PM he already define his problem ! @forkerino
he passed it fine but pointing some sort of issue !
Dan Couper
@DanCouper
Apr 22 2017 11:24
@kimfucious dot notation is used to access a property you know the name of already: var myObj = { foo: 1 }. So myObj.foo gets you 1. Or myArr.length gets the length property from an array, myArr.shift() applies the shift function to an array. Bracket notation if you need to access dynamically (like you have a variable, and you want to query the object with whatever the value of that variable is)
ErezT
@ErezT
Apr 22 2017 11:25
289 exact change, can anyone whos done it can take a look and help out?
https://codepen.io/oldmanwithbeer/pen/WpdWBW
Keon Samuel
@keonsam
Apr 22 2017 11:26
or use a array
Kim Ford
@kimfucious
Apr 22 2017 11:27
@forwebtech @DanCouper @TychoCRD : yep, checkprop is an argument. Thanks, gents.
CamperBot
@camperbot
Apr 22 2017 11:27
kimfucious sends brownie points to @forwebtech and @dancouper and @tychocrd :sparkles: :thumbsup: :sparkles:
:cookie: 303 | @forwebtech |http://www.freecodecamp.com/forwebtech
:cookie: 324 | @tychocrd |http://www.freecodecamp.com/tychocrd
:cookie: 651 | @dancouper |http://www.freecodecamp.com/dancouper
Keon Samuel
@keonsam
Apr 22 2017 11:27
function checkCashRegister(price, cash, cid) {
  var money =[["ONE HUNDRED", 100.00],["TWENTY", 20.00],["TEN",10.00],["FIVE",5.00],["ONE",1.00],["QUARTER",0.25],["DIME",0.10],["NICKEL",0.05],["PENNY",0.01]];
  cid.reverse();
  var change= cash-price;
  var cidTotal= cid.reduce(function(a,b){
    return a+b[1];
  },0.00);
  if(change > cidTotal) {
    return "Insufficient Funds";
  }
  if (change === cidTotal) {
    return "Closed";
  }
  var finalArr = money.reduce(function (a,b,v){
    if(change >= b[1]){
      var returnChange = 0.00;
       while(change >= b[1] && cid[v][1] >= b[1]) {
        change -= b[1];
         change =Math.round(change *100) /100;
        returnChange += b[1];
         cid[v][1] -= b[1];
      }
      a.push([b[0],returnChange]);
      return a;
    }else {
    return a;
    }
  },[]);

  // Here is your change, ma'am.
  return finalArr.length > 0 && change === 0 ? finalArr: "Insufficient Funds";
}

// Example cash-in-drawer array:
// [["PENNY", 1.01],
// ["NICKEL", 2.05],
// ["DIME", 3.10],
// ["QUARTER", 4.25],
// ["ONE", 90.00],
// ["FIVE", 55.00],
// ["TEN", 20.00],
// ["TWENTY", 60.00],
// ["ONE HUNDRED", 100.00]]

checkCashRegister(19.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
Pieter Stokkink
@forkerino
Apr 22 2017 11:27
@ErezT with such an amount of code you need to be more specific about what goes wrong.
Dan Couper
@DanCouper
Apr 22 2017 11:28
@kimfucious You can use bracket notation for everything, buuuut everything you can apply methods to is an object, so if it was enforced you'd have to do stuff like myArr['shift']() or myString['toLowerCase']() which is pretty awful (note that those will all work fine written like that though)
Keon Samuel
@keonsam
Apr 22 2017 11:29
don't copy my algorithm.
Aizaz Shahid
@aizazshahid
Apr 22 2017 11:32
@forkerino is Mozilla updated JS to EC6 ??
as i have checked FCC using old version !
Pieter Stokkink
@forkerino
Apr 22 2017 11:34
@forwebtech https://kangax.github.io/compat-table/es6/ latest FireFox supports almost all of the syntax. I haven't run into problems using ES6 in it. But for production, you want to be compatible with older browsers, so you can use a transpiler like Babel
Dan Couper
@DanCouper
Apr 22 2017 11:34
All browsers have most stuff, it's not a case of "update to ES6" though
They did most of it 2-3 years ago
Keon Samuel
@keonsam
Apr 22 2017 11:35
software teacher vs software engineer?
Parvesh garg
@parveshgarg24
Apr 22 2017 11:35
var arr=[];
function uniteUnique() {
for(var i=0;i<arguments.length;i++){
if(Array.isArray(arguments[i])===true){
for(var j=0;j<arguments[i].length;j++){uniteUnique(arguments[i][j]);}
}
else if(arr.indexOf(arguments[i])<0){
arr.push(arguments[i]);
}
}
return arr;
}
uniteUnique([1, 2, 3], [5, 2, 1]);
please find the bug in it
Keon Samuel
@keonsam
Apr 22 2017 11:35
lol lots of bugs
rugano
@rugano
Apr 22 2017 11:36
What other changes do i need to make in my profile lookup challenge? I already removed the lookUpProfile.hasOwnProperty() function and it is not passing
Keon Samuel
@keonsam
Apr 22 2017 11:36
post your code.
Dan Couper
@DanCouper
Apr 22 2017 11:37
@parveshgarg24 dont use global variables, are should be inside the function otherwise it'll just keep getting more stuff pushed into it every test
Parvesh garg
@parveshgarg24
Apr 22 2017 11:37
how i post my code
Dan Couper
@DanCouper
Apr 22 2017 11:37
You did, keon is referring a different person
Stephen James
@sjames1958gm
Apr 22 2017 11:37
@parveshgarg24 https://forum.freecodecamp.com/t/markdown-code-formatting/18391
To format your code correctly
@parveshgarg24 When doing recursion without globals you have to capture the return value from the recursive call
Stephen James
@sjames1958gm
Apr 22 2017 11:44
@ErezT You need to account for the bad floating point values Math.round(x *100) /100; this is a ways to resolved.
But your while loop is checking (change - valueOfDen) >= 0
a27-suryansh
@a27-suryansh
Apr 22 2017 11:46
Hi
Need help with Js
Push the odd numbers from 9 through 1 to myArray using a for loop.
// Only change code below this line.
for (var me=9; me<=1; me-=2) {
  myArray.push(me);
}
what am i doing wrong?
Bharat Sharma
@itsmebharat
Apr 22 2017 11:47
Related to cordova based app - I am facing a issue on Android version 4.2.2, whenever i try to run my app, at some point of app, i get this error "Resource interpreted as Script but transferred with MIME type text/plain". I am developing app using Backbone and building with cordova. App is working fine with debug version but not with release version, however release app is working fine on above 4.2.2, can anyone help me?
Weird thing is, other section of app is working so seems like js is working fine.
and debug version has same source code otherthan signing details, which is working fine on same device.
Pieter Stokkink
@forkerino
Apr 22 2017 11:48
@a27-suryansh me <= 1 is never true when me is 9, so your loop won't run
a27-suryansh
@a27-suryansh
Apr 22 2017 11:48
@forkerino ok Thans :+1:
Parvesh garg
@parveshgarg24
Apr 22 2017 11:52

here my code

var arr=[];
function uniteUnique() {
  for(var i=0;i<arguments.length;i++){
    if(Array.isArray(arguments[i])===true){
      for(var j=0;j<arguments[i].length;j++){uniteUnique(arguments[i][j]);}
    }
    else if(arr.indexOf(arguments[i])<0){
      arr.push(arguments[i]);
    }
  }
    return arr;
}
uniteUnique([1, 2, 3], [5, 2, 1]);

how i can make my arr empty for each first time function call

Moisés Man
@moigithub
Apr 22 2017 11:54
move it INSIDE the function
Parvesh garg
@parveshgarg24
Apr 22 2017 11:55
after each call arr will be empty
Moisés Man
@moigithub
Apr 22 2017 11:55
and conctenate with ur recursive function call
probably u dnt need a 2nd loop in there
Jefferson
@jeffersonnnn
Apr 22 2017 11:59
Hi guys , i am stuck in the Manipulating Complex Objects challenge and here is my code. What am i doing wrong


var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }

  {
    "artist": "LFC",
    "title": "Young Forever",
    "release_year": 2017,
    "formats": [
      "CS",
      "Casstte",
      "Tudor"],
  }
];
Pieter Stokkink
@forkerino
Apr 22 2017 11:59
@jeffersonnnn elements in an array are separated by ... ?
Jefferson
@jeffersonnnn
Apr 22 2017 12:00
@forkerino commas?
Pieter Stokkink
@forkerino
Apr 22 2017 12:01
bingo!
you have an array with two objects, insert a comma between them
Jefferson
@jeffersonnnn
Apr 22 2017 12:02
@forkerino are you referring to the formats array?
Pieter Stokkink
@forkerino
Apr 22 2017 12:02
@jeffersonnnn no the myMusic array
@jeffersonnnn you have an array, containing two objects (albums). Each album contains several key value pairs, where in both cases one of the values is an array itself. This exercise shows that you can nest objects in arrays and vice versa.
Jefferson
@jeffersonnnn
Apr 22 2017 12:04
@forkerino thank sir!
CamperBot
@camperbot
Apr 22 2017 12:04
jeffersonnnn sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1844 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Apr 22 2017 12:04
got it to work, then?
:+1:
a27-suryansh
@a27-suryansh
Apr 22 2017 12:13
Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
@forkerino can you please explain me this question?
Pieter Stokkink
@forkerino
Apr 22 2017 12:14
@a27-suryansh no need to paste the exercise if you didn't write any code... :)
You need to create a nested for-loop, I believe there is an example in the instructions. Then inside the inner loop multiply product with the current value.
a27-suryansh
@a27-suryansh
Apr 22 2017 12:15
What is the purpose of nesting the loops in this question @forkerino ?
I am not understanding nested loops
Luv Suneja
@chiz
Apr 22 2017 12:17
@a27-suryansh It is a 2D array. So you need to nest
Pieter Stokkink
@forkerino
Apr 22 2017 12:17
@a27-suryansh your array has arrays inside it, so the first loop goes through all these subarrays, and the next loop goes through each element of these subarrays.
a27-suryansh
@a27-suryansh
Apr 22 2017 12:18
@forkerino you mean [5,6,7] is the sub array of [3,4] and [3,4] is the sub array of [1,2] ???
Pieter Stokkink
@forkerino
Apr 22 2017 12:19
@a27-suryansh no, they are all subarrays of the whole thing: [[1,2],[3,4],[5,6,7]] note the extra set of brackets surrounding everything
a27-suryansh
@a27-suryansh
Apr 22 2017 12:19
ok
Pieter Stokkink
@forkerino
Apr 22 2017 12:19
@a27-suryansh so the first loop will get [1,2], then [3,4] then [5,6,7]
the second will have to go through each of them
a27-suryansh
@a27-suryansh
Apr 22 2017 12:20
I think i got this :) let me try @forkerino
yofri
@yofriadi
Apr 22 2017 12:20
hi guys, how to remove all non-alphanumeric from strings with .replace() ?
CatherineKa
@CatherineKa
Apr 22 2017 12:21
Use Regex @Yofri
GaganSinghwa
@GaganSinghwa
Apr 22 2017 12:21
so i am trying to use reduce to get the items in the object and getting the first item to be the key and the last item to be the value idk if some one can help me with that
a27-suryansh
@a27-suryansh
Apr 22 2017 12:21
what is the length of an empty array, is it 0 @forkerino ?