These are chat archives for FreeCodeCamp/HelpJavaScript

22nd
Nov 2016
REAPERkato
@REAPERkato
Nov 22 2016 00:00
how do you paste your wrapped code..
Joe Narvaez
@wordyallen
Nov 22 2016 00:00
This message was deleted
Stephen James
@sjames1958gm
Nov 22 2016 00:01
@REAPERkato THere is an extra ';' as the end of your if statement (this creates an empty statement so that the next line return Not Equal runs every time
@barb1643 Show your code?
REAPERkato
@REAPERkato
Nov 22 2016 00:02
thank you.. @sjames1958gm
CamperBot
@camperbot
Nov 22 2016 00:02
reaperkato sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4469 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
REAPERkato
@REAPERkato
Nov 22 2016 00:02
how did that give me that big of a problem
wow
Stephen James
@sjames1958gm
Nov 22 2016 00:03
@steffanek I don't see you appending any elements to the existing HTML.
@REAPERkato Basically that ';' made your if statement impotent
steffanek
@steffanek
Nov 22 2016 00:03
@sjames1958gm haha yes Thats what exacly what I was thinking of, I forgot to add body.append...
Stephen James
@sjames1958gm
Nov 22 2016 00:04
@steffanek Append to the ul?
steffanek
@steffanek
Nov 22 2016 00:04
@sjames1958gm ye I mean to the ul which already exist
REAPERkato
@REAPERkato
Nov 22 2016 00:04
@sjames1958gm when i wrap my code how do i paste it?..
Daniel Tweedy
@DanielTweedy
Nov 22 2016 00:05
@steffanek I'm not familiar with all the functions you're using, I generally use JQuery to handle this. Was it working before you added some of the functionality?
Stephen James
@sjames1958gm
Nov 22 2016 00:05
You mean paste to chat?
REAPERkato
@REAPERkato
Nov 22 2016 00:05
yes
so i dont gotta copy and paste it
Stephen James
@sjames1958gm
Nov 22 2016 00:05
I copy and paste it but I put three ` then shift-enter then paste then shift-enter then three ` then enter to get the black background
REAPERkato
@REAPERkato
Nov 22 2016 00:07
function testEqual(val) {
  if (val == 12)  { // Change this line
    return "Equal";
  }
  return "Not Equal";
}

// Change this value to test
testEqual(12);
ahh
ok
Daniel Tweedy
@DanielTweedy
Nov 22 2016 00:07
I usually keep it in compose mode which uses ctrl + enter to post and you can easily make new lines by pressing enter.
REAPERkato
@REAPERkato
Nov 22 2016 00:07
cool
Barbara
@barb1643
Nov 22 2016 00:08

function nextInLine(arr, item) {
// Your code here
testArr.push(item);

return arr.shift(); // Change this line
}

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

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

Stephen James
@sjames1958gm
Nov 22 2016 00:08
@REAPERkato :+1:
Barbara
@barb1643
Nov 22 2016 00:08
@sjames1958gm sorry, i thought i did
Stephen James
@sjames1958gm
Nov 22 2016 00:09
@barb1643 only use arr in the function (it will contain the array to change)
@barb1643 I came on late maybe missed it
steffanek
@steffanek
Nov 22 2016 00:09
@sjames1958gm lets say my ul have an id of catList so I did this : document.getElementById('catList').appendChild(newCat);
but still nothing
I have an error I cannot use appendChild i guess in that case I will try to create a var
Barbara
@barb1643
Nov 22 2016 00:11

@sjames1958gm function nextInLine(arr, item) {
// Your code here
testArr.push(item);

return testArr.shift(); // Change this line
}

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

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

Stephen James
@sjames1958gm
Nov 22 2016 00:11
@steffanek maybe the function is a different name - that code should have worked
@barb1643 use arr.push not testArr.push
Barbara
@barb1643
Nov 22 2016 00:11
@sjames1958gm still won't work
Stephen James
@sjames1958gm
Nov 22 2016 00:11
@barb1643 No change the other way only use arr in the function not testArr (arr is the parameter to use.
steffanek
@steffanek
Nov 22 2016 00:11
@sjames1958gm "Uncaught TypeError: Cannot read property 'appendChild' of null(…)
Stephen James
@sjames1958gm
Nov 22 2016 00:11
gotta go all good luck
@steffanek hmm, gotta go, that seems like it should work, sorry
steffanek
@steffanek
Nov 22 2016 00:12
ok ;/
Daniel Tweedy
@DanielTweedy
Nov 22 2016 00:14
So I'm having a bit of trouble with rounding error in Exact Change in the Advanced Algorithms and I'm not sure what I should change in my code or how I should change the numbers I'm using to prevent this.
function checkCashRegister(price, cash, cid) {
  var change = [];
  // Here is your change, ma'am.
  // Total amount in the register
  var total = cid.reduce(function(acc, item) { return acc + item[1]; }, 0);

  // How much I need to pay back in number form, to be converted to currency
  var rawChange = cash - price;

  if(total < rawChange) { return "Insufficient Funds"; }
  else if(total == rawChange) { return "Closed"; }

  var currencyValue = [["PENNY", 0.01], ["NICKEL", 0.05], ["DIME", 0.10], ["QUARTER", 0.25], ["ONE", 1.00], ["FIVE", 5.00], ["TEN", 10.00], ["TWENTY", 20.00], ["ONE HUNDRED", 100.00]];

  for(var i = currencyValue.length - 1; i >= 0 && rawChange > 0; i--) {
    // imediate currency in the register and in the currency values array
    var imedCurVal = currencyValue[i][1],
        imedRegVal = cid[i][1],
        pusher = [cid[i][0], 0]; // item that will be pushed to the front of change
    //console.log(rawChange - currencyValue[i][1]);
    while(rawChange - currencyValue[i][1] >= 0 && imedRegVal > 0) {
      pusher[1] += imedCurVal;
      imedRegVal -= imedCurVal;
      rawChange -= imedCurVal;
    }
    if(pusher[1] > 0) {
      change.unshift(pusher);
    }
  }

  if(rawChange !== 0) {
    return "Insufficient Funds";
  }

  return change;
}
checkCashRegister(3.26, 100.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]]);
Moisés Man
@moigithub
Nov 22 2016 00:20
@MelBrooksKA yea.. js floating point give lot of headaches :)
u can try to use toFixed method <-- return a string
and probably parseFloat
Daniel Tweedy
@DanielTweedy
Nov 22 2016 00:27
Was that what you used, when I tried it, it didn't seem to work, but I might not have implemented it well. Plus it's not really JS's fault, just Floating point in general, which is why I usually try to stick to integers.
@moigithub
Moisés Man
@moigithub
Nov 22 2016 00:42
i dont remember what i used.. did long time ago :)
or probably i converted to integer ? @MelBrooksKA
shuttlzworth
@shuttlzworth
Nov 22 2016 00:46

function switchOfStuff(val) {
var answer = "";
// Only change code below this line
switch (val) {
case a:
answer = ("apple");
break;
case b:
answer = ("bird");
break;
case c:
answer = ("cat");
break;
default:
answer = ("stuff");
}

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

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

I keep getting the error of can't find variable a. If i change my cases to be 1,2,3 it works fine. How do I make a case respond to a letter instead of a number?

Jason Luboff
@JLuboff
Nov 22 2016 00:49
@shuttlzworth place a in quotes
@shuttlzworth And, also there shouldn't be a need for parenthesis around your answer, just the quotes
shuttlzworth
@shuttlzworth
Nov 22 2016 00:50
i had to change the bottom value to be in quotes also! thanks!!
it passed with parenthesis around the answer but I removed them and it passes also so I will do that going forward, thank you!
Joe Narvaez
@wordyallen
Nov 22 2016 00:53
This message was deleted
Ken Cherry
@kenCherry
Nov 22 2016 01:00

if I pass (10,15) shouldn't it return true?
function isLess(a, b) {
// Fix this code
return a === b;
}

// Change these values to test
isLess(10, 15);

Joe Narvaez
@wordyallen
Nov 22 2016 01:02
=== <= >=
maths
Simon Cordova
@gbsimon87
Nov 22 2016 01:04
@kenCherry if you replace a with 10 and b with 10, this would return false because 10 is not strictly equal to 15
Tomas Mattia
@tomasmattia
Nov 22 2016 01:04
```
// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  if (prop!=="tracks" && value!==""){ // ITS OK 
    collection[id][prop]=value;
  }
  else if (prop==="tracks" && !collection[id].hasOwnProperty("tracks")){
    collection[id].create([prop,""]);
  }
  else if (prop==="tracks" && value!==""){
    collection[id].prop(value);
  }
  else if (value===""){ // ITS OK  
    delete collection[id][prop];
  }


}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
```
Simon Cordova
@gbsimon87
Nov 22 2016 01:04
be with 15**
@kenCherry
Tomas Mattia
@tomasmattia
Nov 22 2016 01:04
this is my code of record collection
those 2 if else in the middle are not working like i expected
and idk how to make it
Ken Cherry
@kenCherry
Nov 22 2016 01:08
@gbsimon87 Ahhh.... I should have written: return a < b; for a return of true. Thank you!
CamperBot
@camperbot
Nov 22 2016 01:08
:cookie: 362 | @gbsimon87 |http://www.freecodecamp.com/gbsimon87
kencherry sends brownie points to @gbsimon87 :sparkles: :thumbsup: :sparkles:
Daniel Tweedy
@DanielTweedy
Nov 22 2016 01:10
@tomasmattia One moment while I look at your code and mine
Tomas Mattia
@tomasmattia
Nov 22 2016 01:11
@MelBrooksKA i dont want the direct code, if u can give some hint like what method u use its fine
Daniel Tweedy
@DanielTweedy
Nov 22 2016 01:11
I know, I just don't remember how to do the code and need to look at my own
Simon Cordova
@gbsimon87
Nov 22 2016 01:11
@kenCherry no worries
Daniel Tweedy
@DanielTweedy
Nov 22 2016 01:11
I think one problem is that you're not testing for the empty string every else if statement
lalith77
@lalith77
Nov 22 2016 01:13
anyone know how to replace non alphanumeric characters with their html counterparts?
steffanek
@steffanek
Nov 22 2016 01:14
anybody here knowing well how to use IFFE?
Daniel Tweedy
@DanielTweedy
Nov 22 2016 01:15
@tomasmattia I think you want to change collection[id][prop] = value in
else if (prop==="tracks" && value!==""){
    collection[id].prop(value);
  }
Moisés Man
@moigithub
Nov 22 2016 01:17

IIFE
declare a function

( function ( params ){ 
 statements 
} )

then add another set of parenthesis at the end.. to CALL the function

( function ( params ){ 
 statements 
} )()

@steffanek

Tomas Mattia
@tomasmattia
Nov 22 2016 01:17
@MelBrooksKA with your code i still can not get the new tracks on the array
Moisés Man
@moigithub
Nov 22 2016 01:19
to create a new property.. u only assign a new value to it.. ie
var myObj = {} // no props
myObj.newProp = value
u only need to think what kind of "value" u need.. strings(quote), numbers, arrays(brackets), another object(curly brackets)
Daniel Tweedy
@DanielTweedy
Nov 22 2016 01:19

@lalith77 I don't think there's a function for it but you could do something like this

"Hello, I want some milk.".replace(/./, <value of period>).replace(/,/, <value of comma>)

There's probably a better way, but if you can't find it that might work

Moisés Man
@moigithub
Nov 22 2016 01:21
"my&str".replace(/&/g, '&amp;') with regex and global flag
Tomas Mattia
@tomasmattia
Nov 22 2016 01:22
@moigithub i try that way but i still dont getting the new array "tracks":"",
lalith77
@lalith77
Nov 22 2016 01:22
str= str.replace(str.charAt(5), '&#38;'); this doesnt seem to work
__mifflin__
@cdrainxv
Nov 22 2016 01:23
@moigithub: Shouldn’t it be like this:
(function (params) { 
 //statements 
}());
Moisés Man
@moigithub
Nov 22 2016 01:23
that works too... @cdrainxv
__mifflin__
@cdrainxv
Nov 22 2016 01:24
Can () be outside the function?
Okay… it works...
Thanks for that @moigithub :smile:
CamperBot
@camperbot
Nov 22 2016 01:25
cdrainxv sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2216 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Nov 22 2016 01:25
:D
steffanek
@steffanek
Nov 22 2016 01:27
@moigithub I sent u a priv ;)
lalith77
@lalith77
Nov 22 2016 01:28
@moigithub for the challange "Convert HTML Entities" do i need to write a separate str.replace statement for all of the 32 non alphanumeric characters?
or is there better way to do this?
__mifflin__
@cdrainxv
Nov 22 2016 01:30
@lalith77: You only need to replace the 5 or 6 they asked for: <,>,&,', ", and one more I believe?
lalith77
@lalith77
Nov 22 2016 01:31
i thought that would be cheating my way out. ok then.
thanks @cdrainxv @moigithub @MelBrooksKA
CamperBot
@camperbot
Nov 22 2016 01:32
lalith77 sends brownie points to @cdrainxv and @moigithub and @melbrookska :sparkles: :thumbsup: :sparkles:
:cookie: 332 | @melbrookska |http://www.freecodecamp.com/melbrookska
:star2: 2217 | @moigithub |http://www.freecodecamp.com/moigithub
:star2: 1050 | @cdrainxv |http://www.freecodecamp.com/cdrainxv
Abhishek Kumar
@Mr-Kumar-Abhishek
Nov 22 2016 01:33
@lalith77 there is a better way however
Daniel Tweedy
@DanielTweedy
Nov 22 2016 01:35
@tomasmattia I'm not sure what's going on, I'm trying to modify your code and it seems to be updating everything correctly in some cases, but it keeps telling me the case hasn't been corrected
lalith77
@lalith77
Nov 22 2016 01:36
@Mr-Kumar-Abhishek there is?
siaxiong
@siaxiong
Nov 22 2016 01:37
how do people screen shoot their code?
on freecodecamp
Abhishek Kumar
@Mr-Kumar-Abhishek
Nov 22 2016 01:37
@lalith77 yes, you want to convert something to apha chars correct ?
Aaron Bell
@awb715
Nov 22 2016 01:37
text here
```
Moisés Man
@moigithub
Nov 22 2016 01:38
@siaxiong read the more info link '''
CamperBot
@camperbot
Nov 22 2016 01:38
:bulb: to format code use backticks! ``` more info
Aaron Bell
@awb715
Nov 22 2016 01:38
@siaxiong type ``` and press enter then enter code beween
siaxiong
@siaxiong
Nov 22 2016 01:38
thank you i'll try

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

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

} else { 
return "Not Found";} }

// Test your code by modifying these values
checkObj("gift");
I need help
it asking me to Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found"
Abhishek Kumar
@Mr-Kumar-Abhishek
Nov 22 2016 01:42
@lalith77 uh.... from your challenge you could use regex to recognise the chars and replace them with with html entities
siaxiong
@siaxiong
Nov 22 2016 01:43
? i think that too advance for me right now. im still learning the basics from freeCodeCamp
siaxiong
@siaxiong
Nov 22 2016 01:44
ooops
Moisés Man
@moigithub
Nov 22 2016 01:47
@steffanek to add event listener u no need IIFE..
u creating dynamic content/elements u need to use "event delegation" if u wanna add click events
lalith77
@lalith77
Nov 22 2016 01:48
@Mr-Kumar-Abhishek i want to convert to html characters. So % should be &percent
Abhishek Kumar
@Mr-Kumar-Abhishek
Nov 22 2016 01:51
@lalith77 shouldn't it be &percnt ?
Florian Mettetal
@Falieson
Nov 22 2016 01:52
console.log('generating decks...');
  const cardNumbers = [...Array(11).keys()];
  cardNumbers.shift();
  cardNumbers.shift();
  cardNumbers.push(...['J', 'Q', 'K', 'A']);

  console.log('cardNumbers> ', cardNumbers); //[2, 3, 4, 5, 6, 7, 8, 9, 10, "J", "Q", "K", "A"]

  const cardTypes = [['S', 'Black'], ['C', 'Black'], ['H', 'Red'], ['D', 'Red']];

  const cards = _.each(cardNumbers, number => _.each(cardTypes, type => ({
    code: number + type[0],
    number,
    type: type[0],
    color: type[1],
  })));
  console.log('CARDS> ', cards); //[2, 3, 4, 5, 6, 7, 8, 9, 10, "J", "Q", "K", "A”]
Abhishek Kumar
@Mr-Kumar-Abhishek
Nov 22 2016 01:53
@lalith77 or.... &#37;
lalith77
@lalith77
Nov 22 2016 01:53
@Mr-Kumar-Abhishek it is &percnt sorry
Florian Mettetal
@Falieson
Nov 22 2016 01:53
anyone see why my cards var is ouptutting cardNumbers rather than array of objs?
__mifflin__
@cdrainxv
Nov 22 2016 01:54
@siaxiong: The error is here:
return myObj.checkProp;
checkProp is a variable so you need to use [] notation.
Abhishek Kumar
@Mr-Kumar-Abhishek
Nov 22 2016 01:54
@lalith77 yes don't forget the ; at the end too it will cause bugs ~
KR62
@KR62
Nov 22 2016 01:56
what's the difference between using JS on the Khan Academy vs. using it on Codepen? My code isn't working on Codepen.
lalith77
@lalith77
Nov 22 2016 01:58
@Mr-Kumar-Abhishek thank you
CamperBot
@camperbot
Nov 22 2016 01:58
lalith77 sends brownie points to @mr-kumar-abhishek :sparkles: :thumbsup: :sparkles:
:cookie: 405 | @mr-kumar-abhishek |http://www.freecodecamp.com/mr-kumar-abhishek
Moisés Man
@moigithub
Nov 22 2016 02:01
if u post ur codepen link..probably helps... @KR62
Danilo Geronimo
@danilogeronimo
Nov 22 2016 02:09
Hello guys! When an exercise gives me the helpful links, am I supposed to be able to solve the exercise only using those links? or i need to know more stuff?
in the "Diff Two Arrays" algorithm, the helpful links are: Comparison Operators, slice, filter, indexOf and concat. It is possible to solve the exercise only with these topics?
Rachel Riley
@ParadiseArtist
Nov 22 2016 02:12
Hello I wonder if anyone could help me understand the Global Scope and Functions excersize
Here are the instructions:

Using var, declare a global variable myGlobal outside of any function. Initialize it with a value of 10.

Inside function fun1, assign 5 to oopsGlobal without using the var keyword.

Manish Giri
@Manish-Giri
Nov 22 2016 02:15
@ParadiseArtist did you have a question
Rachel Riley
@ParadiseArtist
Nov 22 2016 02:17
@Manish-Giri I'm really not sure where to start with this one.

// Declare your variable here
var myGlobal = 10;

function fun1() {
// Assign 5 to oopsGlobal Here
}

// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}

Manish Giri
@Manish-Giri
Nov 22 2016 02:17
@ParadiseArtist okay, were you understand the concept of global vs local scope
Aaron Bell
@awb715
Nov 22 2016 02:17
so just set it myGlobal=5
Manish Giri
@Manish-Giri
Nov 22 2016 02:18

@ParadiseArtist you need another variable inside the function fun1, but without the var keyword, that makes it global

Inside function fun1, assign 5 to oopsGlobal without using the var keyword.

@ParadiseArtist your step 1 is already done

var myGlobal = 10;

Rachel Riley
@ParadiseArtist
Nov 22 2016 02:19
so something like fun1(oopsGlobal=5)
Manish Giri
@Manish-Giri
Nov 22 2016 02:19
yes, but inside the {}, not ()
the body of a function is the code between the {}
Rachel Riley
@ParadiseArtist
Nov 22 2016 02:20
Ok! that makes sense. is it to show what not to do? or?
Manish Giri
@Manish-Giri
Nov 22 2016 02:20
?
Rachel Riley
@ParadiseArtist
Nov 22 2016 02:21
It just says in the instructions to always use var for variables.
I guess oopsGlobal is not supposed to be a variable thats what makes it global?
I'll keep working through and see if it starts to come together.
Manish Giri
@Manish-Giri
Nov 22 2016 02:22
yes, it's an instance of not following the best practice
Rachel Riley
@ParadiseArtist
Nov 22 2016 02:23
Yeay I'm not as lost as I thought I was. Cool Thanks @Manish-Giri !
CamperBot
@camperbot
Nov 22 2016 02:23
paradiseartist sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 2385 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Nov 22 2016 02:23
@ParadiseArtist welcome
Tomas Mattia
@tomasmattia
Nov 22 2016 02:26
i need help with record collection
with this part of code
  else if (prop==="tracks" && !collection[id].hasOwnProperty("tracks")){
    collection[id].tracks=value;
  }
If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.
that is the exercise
i still cant creating a new array called tracks
Gniewoszu
@Gniewoszu
Nov 22 2016 02:31
@tomasmattia
  else if (prop==="tracks" && !collection[id].hasOwnProperty(prop)){
    collection[id][prop] = [];
  }
j3dimaster
@j3dimaster
Nov 22 2016 02:33
you need to return myObj[checkProp]
siaxong
function checkObj(checkProp) {
return myObj.hasOwnProperty(checkProp) ? myObj[checkProp] : 'Not Found'
}
using the syntax : object[property]
Gniewoszu
@Gniewoszu
Nov 22 2016 02:35
@tomasmattia and then you can collection[id][prop].push(value);
j3dimaster
@j3dimaster
Nov 22 2016 02:37
function checkObj(checkProp) {
return checkProp in myObj ? myObj[checkProp] : 'Not Found';
} you can also use the in operator for check in an object
Tomas Mattia
@tomasmattia
Nov 22 2016 02:43
@Gniewoszu
// Only change code below this line
function updateRecords(id, prop, value) {
  if (prop!=="tracks" && value!==""){
    collection[id][prop]=value;
  }
  else if (prop==="tracks" && !collection[id].hasOwnProperty("tracks")){
    collection[id][prop] = [value];
    collection[id][prop].push(value);
  }

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


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
sorry i delete value between []
but i still got one not working
After updateRecords(1245, "tracks", "Addicted to Love"), tracks should have "Addicted to Love" as the last element.
that one not work
Moisés Man
@moigithub
Nov 22 2016 02:47
what hapen when prop is tracks.. and album DO HAVE tracks property ?? @tomasmattia
Mel DeJesus
@edgewood1
Nov 22 2016 02:48
I'm trying to write a switch statement which tests val and sets answer for the following conditions: 1 - "alpha" 2- "beta", etc. Any suggestions? function caseInSwitch(val) {
var answer = "";
case 1:
answer="alpha";
break;
}
caseInSwitch(1);
Moisés Man
@moigithub
Nov 22 2016 02:48
return answer missing ? @edgewood1
also switch statement
Walid Ashri
@walidashri
Nov 22 2016 02:49
@edgewood1 where is switch declaration
Tomas Mattia
@tomasmattia
Nov 22 2016 02:49
@moigithub thanks man!
CamperBot
@camperbot
Nov 22 2016 02:49
tomasmattia sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2218 | @moigithub |http://www.freecodecamp.com/moigithub
Tomas Mattia
@tomasmattia
Nov 22 2016 02:49
i forgot that
Submitted!
Barbara
@barb1643
Nov 22 2016 02:51
Can someone please look at this and tell me what is wrong? I have 2 out of four right and don't know what I am doing wrong with it. It is the Stand in LIne exercise.

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

arr.push(item);
arr.shift(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, 1)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

Mel DeJesus
@edgewood1
Nov 22 2016 02:51
@walidashri thanks - i assumed the switch statement was what was present in the function - yet the function and switch statements are different things!
CamperBot
@camperbot
Nov 22 2016 02:51
edgewood1 sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 670 | @walidashri |http://www.freecodecamp.com/walidashri
Moisés Man
@moigithub
Nov 22 2016 02:53
@barb1643 shift dont require any parameter... and it returns a value (check the documentation )
u need to do something with the returned value
Walid Ashri
@walidashri
Nov 22 2016 02:53
@barb1643 Array.shift() takes no param
Barbara
@barb1643
Nov 22 2016 02:55
Thanks @moigithub Thanks@walidashri I changed it and I still have the same 2 wrong..
Before: [1,2,3,4,5]
1
After: [2,3,4,5,1]
CamperBot
@camperbot
Nov 22 2016 02:55
barb1643 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2219 | @moigithub |http://www.freecodecamp.com/moigithub
Barbara
@barb1643
Nov 22 2016 02:55
nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10),
Walid Ashri
@walidashri
Nov 22 2016 02:56
@barb1643 as @moigithub saidu need to do something with the returned value
Barbara
@barb1643
Nov 22 2016 02:56
the 1st and 4th are correct, can't get the 2nd and 3rd
Walid Ashri
@walidashri
Nov 22 2016 02:57
@barb1643 the arr.shift() returns the shifted element
Barbara
@barb1643
Nov 22 2016 02:59
@walidashri and then what, I don't get it
do what with the shifted element?
Walid Ashri
@walidashri
Nov 22 2016 03:00
@barb1643 if u return the arr.shift call you are done :)
Moisés Man
@moigithub
Nov 22 2016 03:01
instructions says.. add item to the end of the array.. and remove and return the first element @barb1643
Steve Brockley
@stevebrockley
Nov 22 2016 03:02
What am I doing wrong with adding another album?
var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
   {
   "artist": "Gary Clark Jr.",
   "title": "Black and Blu",
   "release_year": 2012,
   "formats": [
     "CD",
     "LP"]
  }
  // Add record here
];
Joseph
@revisualize
Nov 22 2016 03:03
@moigithub I sent you one of those PM things.
@stevebrockley You're missing a ,
[ { ... } , { ... } ]
See the , ?
Barbara
@barb1643
Nov 22 2016 03:04
@moigithub It says remove the first element not remove and return. At least that is how I interpret it....Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
Steve Brockley
@stevebrockley
Nov 22 2016 03:04
ohhhh thanks @revisualize
CamperBot
@camperbot
Nov 22 2016 03:04
stevebrockley sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2396 | @revisualize |http://www.freecodecamp.com/revisualize
Moisés Man
@moigithub
Nov 22 2016 03:05
@barb1643 then remove the first element of array. The nextInLine function should
then return the element that was removed.
@revisualize :O thanks :)
CamperBot
@camperbot
Nov 22 2016 03:06
moigithub sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2397 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Nov 22 2016 03:06
:)
KR62
@KR62
Nov 22 2016 03:11
I'm not sure what I'm missing in my JS on Codepen, it's not working. I have no problem on the Khan Academy, it's very straightforward and easy to use. What's the difference between the two? Here's one of my pens. Thanks for the help. http://codepen.io/KR62/pen/VmpGgW
Gniewoszu
@Gniewoszu
Nov 22 2016 03:14
@KR62 ReferenceError: fill is not defined
Jason Savage
@SavageDevInteractive
Nov 22 2016 03:16
Anyone fluent enough with the counting cards challenge that would be willing to speak with 1 on 1 about it?
KR62
@KR62
Nov 22 2016 03:17
What does that mean? I ran the Analyze JS and it said No Errors. Can the fill be defined in RGB code?
Gniewoszu
@Gniewoszu
Nov 22 2016 03:18
@KR62
file() and rect() probably are functions form p5.js library
@KR62 go to your pen and check console for errors
KR62
@KR62
Nov 22 2016 03:25
Yea, Console is clear, I don't see anything.
Moisés Man
@moigithub
Nov 22 2016 03:26
https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.4/p5.min.js
add that library to ur codepen JS settings
Gniewoszu
@Gniewoszu
Nov 22 2016 03:26
@KR62 strange because this function are from p5.js and your pen do not have this library
http://codepen.io/Magiczny/pen/QGpZBb
Moisés Man
@moigithub
Nov 22 2016 03:27
put all ur code inside a
function draw(){
  //all ur code here
}
Gniewoszu
@Gniewoszu
Nov 22 2016 03:28
@KR62 or simply fork my pen :) @moigithub :+1:
KR62
@KR62
Nov 22 2016 03:32
@moigithub I tried that, didn't work.
santoshrajendra10
@santoshrajendra10
Nov 22 2016 03:32

@santoshrajendra10
function Person(name){
this.name = name;
}

Person.prototype.greet = function(otherName){
return "Hi " + otherName + ", my name is " + name;
}
how do i display the name in Person fucntion
to the greet function

Moisés Man
@moigithub
Nov 22 2016 03:33
@KR62 u didnt add the library to ur JS settings...
click on the cogwheels
https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.4/p5.min.js
n copy paste that
Mo Zargham
@Mozar10
Nov 22 2016 03:38
@santoshrajendra10 the Person function is just the constructor, you need to instantiate an object from it
KR62
@KR62
Nov 22 2016 03:38
@moigithub hey, I got something, a tiny bit of the design. Now I just have to define the space at 400x400.
Mo Zargham
@Mozar10
Nov 22 2016 03:38
function Person(name){
this.name = name;
}

Person.prototype.greet = function(){alert("hi " + obj.name)
}
var obj =  new Person("joe");
obj.greet()
KR62
@KR62
Nov 22 2016 03:41
@moigithub what is the command I use for that? something like define canvas?
Moisés Man
@moigithub
Nov 22 2016 03:43
http://p5js.org/get-started/
probably this
function setup() {
  createCanvas(640, 480);
}
Gniewoszu
@Gniewoszu
Nov 22 2016 03:46
@KR62 check out [codingrainbow](
haider
@candh
Nov 22 2016 03:46
oh cool the UI changed
hello guys
Gniewoszu
@Gniewoszu
Nov 22 2016 03:47
@KR62 this for p5.js best tutirials codingrainbow
MCess
@MCess
Nov 22 2016 03:48
Hi all, I'm working on creating this in Javascript - For a given number, call it "x", write a program that returns the sum of all odd numbers less than x
For example, function if we call the function OddSumNum, then OddSumNum(8) should return a value of 16, which is 7+5+3+1. So far I have this
function OddSumNum(x) {
  var newArr = [];
for (i = 1; i < x; i += 2)
return newArr;
  var sum = newArr.reduce(function(a, b) {return a + b;}, 0);
  return sum;
}


OddSumNum(8);
Could anyone help me figure out what I'm doing wrong? Also where can I test this out other than in FCC's challenge boxes?
KR62
@KR62
Nov 22 2016 03:50
@moigithub thank you so much, the library code helped and solved the problem. My pens are showing! thank you.
CamperBot
@camperbot
Nov 22 2016 03:50
kr62 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2220 | @moigithub |http://www.freecodecamp.com/moigithub
stevebarakat
@stevebarakat
Nov 22 2016 03:52

Hi. I’m having trouble with the “Profile Lookup” exercise. Can anyone see what I’m doing wrong? Here’s the code:
‘’'

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

function lookUpProfile(firstName, prop){
// Only change code below this line
var response = "";
for(var i = 0; i < contacts.length ; i++){
if(contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)){
response = contacts[i][prop];
}

if(contacts[i].firstName !== firstName){
  response = "No such contact";
}

if(contacts[i][prop] === undefined){
  response = "No such property";
}

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

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

‘''

Gniewoszu
@Gniewoszu
Nov 22 2016 03:53
@MCess you can test it on jsfidle
@MCess edit [jsfiddle](http://jsfiddle.net]
CamperBot
@camperbot
Nov 22 2016 03:55
:bulb: to format code use backticks! ``` more info
stevebarakat
@stevebarakat
Nov 22 2016 03:56
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line 
  var response = "";
  for(var i = 0; i < contacts.length ; i++){
    if(contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)){
      response = contacts[i][prop];
    }

    if(contacts[i].firstName !== firstName){
      response = "No such contact";
    }

    if(contacts[i][prop] === undefined){
      response = "No such property";
    }
  }
  return response;
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Sherlock", "likes");
haider
@candh
Nov 22 2016 03:56
@MCess thats how i'd do it
function OddSumNum(x){
  var sum = 0;
  for(var i = 0; i < x; i++){
      if(i % 2 != 0) {
         sum += i;
      }
   }
  return sum;
}
KR62
@KR62
Nov 22 2016 03:56
@Gniewoszu thank you for the tutorial suggestion, I will look into it. My pens are working now, yay!
CamperBot
@camperbot
Nov 22 2016 03:56
kr62 sends brownie points to @gniewoszu :sparkles: :thumbsup: :sparkles:
:cookie: 210 | @gniewoszu |http://www.freecodecamp.com/gniewoszu
KR62
@KR62
Nov 22 2016 03:58
@camperbot Yes, many brownie points...they helped me. I can see my Pens!
Brennan Glynn
@BrennanGlynn
Nov 22 2016 03:58
function gcd(a, b) {
    return !b ? a : gcd(b, a % b);
  }
what is happening in this line of code?
Heliocrat
@heliocrat
Nov 22 2016 03:59

function destroyer(arr) {
return arr;
}

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

'''
function destroyer(arr) {
return arr;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
'''
CamperBot
@camperbot
Nov 22 2016 04:01
:bulb: to format code use backticks! ``` more info
Heliocrat
@heliocrat
Nov 22 2016 04:02
function destroyer(arr) {
return arr;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
The above returns the array [1,2,3,1,2,3]... but arr1 or arr[2] notation does not access the 2 or the 3 not in arrays. How would I access the 2 or the 3?
Gniewoszu
@Gniewoszu
Nov 22 2016 04:04
@BrennanGlynn it is ternary operation
Brennan Glynn
@BrennanGlynn
Nov 22 2016 04:06
@Gniewoszu I know that
MCess
@MCess
Nov 22 2016 04:07
Cool Thanks @candh !
CamperBot
@camperbot
Nov 22 2016 04:07
mcess sends brownie points to @candh :sparkles: :thumbsup: :sparkles:
:cookie: 34 | @candh |http://www.freecodecamp.com/candh
Gniewoszu
@Gniewoszu
Nov 22 2016 04:09
@heliocrat `arr =Array.from(arguments)'
Mo Zargham
@Mozar10
Nov 22 2016 04:09
@heliocrat the 2 and 3 are the arguments of the function you can access them by accessing the arguments property of functions
__mifflin__
@cdrainxv
Nov 22 2016 04:10
@heliocrat: Refer to the links provided.
Heliocrat
@heliocrat
Nov 22 2016 04:10
@Gniewoszu thanks! I also see that return arguments gives me everything indexed in a psuedo array, so I can work with that. :)
CamperBot
@camperbot
Nov 22 2016 04:10
:cookie: 211 | @gniewoszu |http://www.freecodecamp.com/gniewoszu
heliocrat sends brownie points to @gniewoszu :sparkles: :thumbsup: :sparkles:
Edson Mendieta
@edsonmendieta
Nov 22 2016 04:11

I'm working on "Map the Debris" in the advanced algorithm scripting in the front-end development track.

Here a GM value of earth is provided as

 var GM = 398600.4418;

Would it be okay to just use what's found here https://en.wikipedia.org/wiki/Earth_mass

5.98 * 10^24

If not, would I have to multiply the provided mass value by 1000 since it's in kilometers?

GM value of earth is 398600.4418 km3s-2
Edson Mendieta
@edsonmendieta
Nov 22 2016 04:16
Hello?
Mo Zargham
@Mozar10
Nov 22 2016 04:18
@edsonmendieta this should work 6367.4447 for earth radius and GM is given .. I'm not sure I understand your question
Edson Mendieta
@edsonmendieta
Nov 22 2016 04:21
@Mozar10 Alright, I'll go ahead and try it out with the given mass and check back in if I run into any problems.
zack
@acting2332
Nov 22 2016 04:23
javascript is killing me :(
Mo Zargham
@Mozar10
Nov 22 2016 04:24
Yea.. It likes doing that from time to time
Yang Lu
@ylu01
Nov 22 2016 04:25
return main()-1;
JackVizl
@JackVizl
Nov 22 2016 04:25

function sepArgs(firstArg){
  secArg=0;



  if(typeof secArg==='number'){

 //how do i get the second argument?




 // return firstArg+secArg;

  }

  else{return undefined;}


}



function addTogether() {


if(arguments.length<2){


  sepArgs(arguments[0]);

}
  else if((typeof arguments[0]!=='number')||(typeof arguments[1]!=='number')){
    return undefined;

  }
  else{return arguments[0]+arguments[1];}



}

addTogether(2);
halp
zack
@acting2332
Nov 22 2016 04:26
not giving up but man oh man thought i was really getting the hang of stuff than javascript reminded me i know nothing haha
Mo Zargham
@Mozar10
Nov 22 2016 04:26
@acting2332 lol get used to that man, it seems to be a pretty common pattern
just keep at it
Yang Lu
@ylu01
Nov 22 2016 04:27
https://codepen.io/Ylu01/full/jVMWVE
have some fun and relax
Mo Zargham
@Mozar10
Nov 22 2016 04:30
@JackVizl where are you stuck?
JackVizl
@JackVizl
Nov 22 2016 04:30
@Mozar10 how do i get input for the second arg?
Mo Zargham
@Mozar10
Nov 22 2016 04:34
@JackVizl There is no second argument though
JackVizl
@JackVizl
Nov 22 2016 04:35
@Mozar10 whats the challenge asking me to do then
Mo Zargham
@Mozar10
Nov 22 2016 04:37
@JackVizl if only one argument is given then you should return a function which gets the second argument
JackVizl
@JackVizl
Nov 22 2016 04:37
@Mozar10 right, 'gets' the second argument so i need some kind of input right?
Mo Zargham
@Mozar10
Nov 22 2016 04:39
@JackVizl if arguments are greater than 1 return a function(input) and input is second argument
JackVizl
@JackVizl
Nov 22 2016 04:39
how do i input?
like
how do i get the second argument in that function
Mo Zargham
@Mozar10
Nov 22 2016 04:40
you give it the second input
JackVizl
@JackVizl
Nov 22 2016 04:41
im confused how to write that
Mo Zargham
@Mozar10
Nov 22 2016 04:42
look if you have 1 argument only you return a function which "takes" a second argument and uses the first argument to return the sum
@JackVizl your first function should return the inner function
JackVizl
@JackVizl
Nov 22 2016 04:45
confused as
Mo Zargham
@Mozar10
Nov 22 2016 04:46
@JackVizl its a tricky one, closures are pretty tricky to grasp
Henry Cabello
@hacu9
Nov 22 2016 04:47

Hey! Can anyone give feedback and help me on my Simon proyect? https://codepen.io/cabello986/pen/rrgdpV?editors=1010

i have a problem with the play function cuz it pushes the plays twice

Mo Zargham
@Mozar10
Nov 22 2016 04:47
if(outerArgs.length ===1){
    if(typeof outerArgs[0] === "number"){
        return function(number){
          if(typeof number === "number"){
            return outerArgs[0] + number
            }
        }
    }
}
JackVizl
@JackVizl
Nov 22 2016 04:48
@Mozar10 yeah i dont completely even understand what it wants me to do haha
Rex Smith Jr.
@rsmith731
Nov 22 2016 04:48
i have 2 huge icons on my page and i wanted them to slide up when they are clicked….what is the easiest way to achieve this?
Darth Skywalker
@adityaparab
Nov 22 2016 04:48
function add(){
  if(arguments.length === 0 ) return;
  return arguments.length > 1 ? arguments[0]+arguments[1] : function(x){
    return arguments[0]+x;
  }
}
Mo Zargham
@Mozar10
Nov 22 2016 04:50
@rsmith731 add an eventListener which alters their position on click event
Darth Skywalker
@adityaparab
Nov 22 2016 04:50
function add(){
  let args = Array.from(arguments).filter(isNaN);
  if(args.length > 0 ) return;
  return arguments.length > 1 ? arguments[0]+arguments[1] : function(x){
    return arguments[0]+x;
  }
}
JackVizl
@JackVizl
Nov 22 2016 04:50
@Mozar10 thank you
CamperBot
@camperbot
Nov 22 2016 04:50
jackvizl sends brownie points to @mozar10 :sparkles: :thumbsup: :sparkles:
:cookie: 313 | @mozar10 |http://www.freecodecamp.com/mozar10
Rex Smith Jr.
@rsmith731
Nov 22 2016 04:50
@Mozar10 ok thanks
CamperBot
@camperbot
Nov 22 2016 04:50
rsmith731 sends brownie points to @mozar10 :sparkles: :thumbsup: :sparkles:
:cookie: 314 | @mozar10 |http://www.freecodecamp.com/mozar10
JackVizl
@JackVizl
Nov 22 2016 04:51
@Mozar10 what are outer args tho?
Mo Zargham
@Mozar10
Nov 22 2016 04:51
@JackVizl I just named a variable outerArgs = arguments
Darth Skywalker
@adityaparab
Nov 22 2016 04:51
function add(){
  let args = Array.from(arguments).filter(isNaN);
  if(args.length > 0 || arguments.length === 0) return;
  return arguments.length > 1 ? arguments[0]+arguments[1] : function(x){
    return arguments[0]+x;
  }
}
JackVizl
@JackVizl
Nov 22 2016 04:51
ok right
Mo Zargham
@Mozar10
Nov 22 2016 04:52
@JackVizl to make it easier to understand for myself
Darth Skywalker
@adityaparab
Nov 22 2016 04:52
Now this looks satisfying
JackVizl
@JackVizl
Nov 22 2016 04:52
@adityaparab is that a solution?
Mo Zargham
@Mozar10
Nov 22 2016 04:52
@adityaparab lol I need to refactor all my algos
Darth Skywalker
@adityaparab
Nov 22 2016 04:52
@Mozar10 haha.. why?
Mo Zargham
@Mozar10
Nov 22 2016 04:52
@adityaparab cause the first time going through them I just want to get it done ! lol i want them to look beautiful like that
Darth Skywalker
@adityaparab
Nov 22 2016 04:52

@JackVizl

@adityaparab is that a solution?

It could be. I'm not sure of all the boundary conditions. I implemented that reading your conversation

JackVizl
@JackVizl
Nov 22 2016 04:53
@adityaparab oh thanks man
CamperBot
@camperbot
Nov 22 2016 04:53
:cookie: 718 | @adityaparab |http://www.freecodecamp.com/adityaparab
jackvizl sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
Darth Skywalker
@adityaparab
Nov 22 2016 04:53
@Mozar10 : Don't worry about it mate. Focus on understanding what is going on. You don't go to the gym and start posing on the first day, do you? ;)
Gniewoszu
@Gniewoszu
Nov 22 2016 04:53
@rsmith731 add class with slide up animation on event click
JackVizl
@JackVizl
Nov 22 2016 04:54
Personally, i did but your message is clear, thank you @adityaparab
CamperBot
@camperbot
Nov 22 2016 04:54
jackvizl sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:warning: jackvizl already gave adityaparab points
JackVizl
@JackVizl
Nov 22 2016 04:54
i better learn what let and from mean haha
edwinwarner
@edwinwarner
Nov 22 2016 04:54
I need help solving the "Stand In Line" challenge
Mo Zargham
@Mozar10
Nov 22 2016 04:54
@adityaparab lool unfrotunately i do, Im that guy
Darth Skywalker
@adityaparab
Nov 22 2016 04:54
By posing, I mean, posing in a way that will really impress people :P. You can pose whenever you want but don't expect being impressive if you've never worked out before :P
Mo Zargham
@Mozar10
Nov 22 2016 04:54
@adityaparab lol jk, yea I try to just solve them first time around
Henry Cabello
@hacu9
Nov 22 2016 04:54
Anyone willing to help me? >:c
JackVizl
@JackVizl
Nov 22 2016 04:54
@hacu9 whats up
Darth Skywalker
@adityaparab
Nov 22 2016 04:55
@hacu9 : If you ask, then I'm sure you'll get help.
Henry Cabello
@hacu9
Nov 22 2016 04:55

Hey! Can anyone give feedback and help me on my Simon proyect? https://codepen.io/cabello986/pen/rrgdpV?editors=1010

i have a problem with the play function cuz it pushes the plays twice

Mo Zargham
@Mozar10
Nov 22 2016 04:55
@adityaparab but I find through refactoring I understand them even better, when I try to make it look elegant
Darth Skywalker
@adityaparab
Nov 22 2016 04:55
@hacu9 : Just a side note, if you have a question, ask the fucking question :D
Henry Cabello
@hacu9
Nov 22 2016 04:55
I did like 10mins ago xD
Darth Skywalker
@adityaparab
Nov 22 2016 04:55
@Mozar10 : Yes! Keep on improving :D
JackVizl
@JackVizl
Nov 22 2016 04:56
@adityaparab dude chill XD
Darth Skywalker
@adityaparab
Nov 22 2016 04:56
@hacu9 : Holy shit! You're showing your latin roots by spelling project as proyect :P
Henry Cabello
@hacu9
Nov 22 2016 04:57
lul
Darth Skywalker
@adityaparab
Nov 22 2016 04:57

@hacu9 :

Sweet you're following industry standard for naming jQuery variables :)

  var $1 = $("#1");
  var $2 = $("#2");
  var $3 = $("#3");
  var $4 = $("#4");
Rex Smith Jr.
@rsmith731
Nov 22 2016 04:57
@Gniewoszu i think that will be the easiest way. thanks
CamperBot
@camperbot
Nov 22 2016 04:57
rsmith731 sends brownie points to @gniewoszu :sparkles: :thumbsup: :sparkles:
:cookie: 212 | @gniewoszu |http://www.freecodecamp.com/gniewoszu
JackVizl
@JackVizl
Nov 22 2016 05:00
````

function addTogether() {

if(arguments.length ===1){
if(typeof arguments[0] === "number"){
return function(number){
if(typeof number === "number"){
return arguments[0] + number;
}
};
}
}

else if((typeof arguments[0]!=='number')||(typeof arguments1!=='number')){
return undefined;

}
else{return arguments[0]+arguments1;}

}

addTogether(2)(3);

why dis return 0
6*

function addTogether() {

if(arguments.length ===1){
    if(typeof arguments[0] === "number"){
        return function(number){
          if(typeof number === "number"){
            return arguments[0] + number;
            }
        };
    }
}

  else if((typeof arguments[0]!=='number')||(typeof arguments[1]!=='number')){
    return undefined;

  }
  else{return arguments[0]+arguments[1];}



}

addTogether(2)(3);
Rex Smith Jr.
@rsmith731
Nov 22 2016 05:01
@Gniewoszu so i should use $('.active').slideUp('fast', function() { $(this).removeClass('active').addClass('completed'); });
__SharifTarver__
@Sharifdesigns22
Nov 22 2016 05:01
''var myStr ='"<a href=http//:www.example.com" "target=_blank>Link</a>"';'' hi i'm trying to see if i'm removing the escapes properly? thanks
@JackVizl how did you paste your code that way?
Art
@maceo32
Nov 22 2016 05:02
Can someone please help me with this lesson please. I have been held up on it for hours, and I'm driving myself crazy.
JackVizl
@JackVizl
Nov 22 2016 05:02
@Sharifdesigns22 use ```
Art
@maceo32
Nov 22 2016 05:02
Can someone please help me with this lesson please. I have been held up on it for hours, and I'm driving myself crazy.
JackVizl
@JackVizl
Nov 22 2016 05:03
your code here
/```
your code
/```
Art
@maceo32
Nov 22 2016 05:03
var myStr = '\"FirstLine\n '\ SecondLine '\'\r nThirdLine/"'; // Change this line
__SharifTarver__
@Sharifdesigns22
Nov 22 2016 05:03
so /' ' ' after your code?
Art
@maceo32
Nov 22 2016 05:03

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

FirstLine
\SecondLine\
ThirdLine
You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

@Sharifdesigns22 before and after
JackVizl
@JackVizl
Nov 22 2016 05:04
@maceo32 send me link to challenge
Mo Zargham
@Mozar10
Nov 22 2016 05:05
@JackVizl set arguments[0] to a variable
JackVizl
@JackVizl
Nov 22 2016 05:05
oh
__SharifTarver__
@Sharifdesigns22
Nov 22 2016 05:05
ok sweet thanks @JackVizl
CamperBot
@camperbot
Nov 22 2016 05:05
sharifdesigns22 sends brownie points to @jackvizl :sparkles: :thumbsup: :sparkles:
:cookie: 328 | @jackvizl |http://www.freecodecamp.com/jackvizl
Mo Zargham
@Mozar10
Nov 22 2016 05:05
@JackVizl when you dont arguemtns[0] becomes 3 inside the second function because its the ony argument of that function
__SharifTarver__
@Sharifdesigns22
Nov 22 2016 05:05
thanks @maceo32
CamperBot
@camperbot
Nov 22 2016 05:05
sharifdesigns22 sends brownie points to @maceo32 :sparkles: :thumbsup: :sparkles:
:cookie: 153 | @maceo32 |http://www.freecodecamp.com/maceo32
JackVizl
@JackVizl
Nov 22 2016 05:05
@maceo32 just slap /charactrer here/
slap da / on each side
Cal-culator
@Cal-culator
Nov 22 2016 05:05
hi guys
JackVizl
@JackVizl
Nov 22 2016 05:05
@Mozar10 ok
@Cal-culator sup fam
Cal-culator
@Cal-culator
Nov 22 2016 05:06
Can anyone help me with the weather app? I don't know what's wrong with it.
Art
@maceo32
Nov 22 2016 05:06
@JackVizl I dont understand what you mean.
JackVizl
@JackVizl
Nov 22 2016 05:06
@Mozar10 of i have to likes tore it or something?
store*
Cal-culator
@Cal-culator
Nov 22 2016 05:06
@JackVizl stuck on weather app
Mo Zargham
@Mozar10
Nov 22 2016 05:07
@JackVizl yea store the argument from the first function to a variable, so in the second one you can say arguments[0] + whatever Var
Cal-culator
@Cal-culator
Nov 22 2016 05:08
Is anyone done with the weather app on code pen?
Will
@Will-is-Coding
Nov 22 2016 05:08
What's your current issue @Cal-culator ?
Cal-culator
@Cal-culator
Nov 22 2016 05:09
@Will-is-Coding The issue right now is that the status is 404 even though the url exists.
Mo Zargham
@Mozar10
Nov 22 2016 05:09
@Cal-culator use http
__SharifTarver__
@Sharifdesigns22
Nov 22 2016 05:09
@maceo32 so like this? var myStr = "<a href=http//:www.example.com" \"target=_blank>Link</a> \";
** /' ' ' var myStr = "<a href=http//:www.example.com" \"target=_blank>Link</a> \"; /' ' '
Cal-culator
@Cal-culator
Nov 22 2016 05:10
@Mozar10 can you elaborate please?
Gniewoszu
@Gniewoszu
Nov 22 2016 05:10
@rsmith731 eh maybe like this $('.active').on('click', function(){$(this). slideUp('fast')});
Mo Zargham
@Mozar10
Nov 22 2016 05:11
@Cal-culator in your url, use http://
Henry Cabello
@hacu9
Nov 22 2016 05:12
Go ahead and open the dev tools console,press start and notice how when its clicked more than 1 time it pushes a bunch of things into the playerplays array https://codepen.io/cabello986/pen/rrgdpV?editors=1010
How can i fix that?
Art
@maceo32
Nov 22 2016 05:12
@Sharifdesigns22 it the backtic key, just left of the #1 key on standard keyboard. it should have 3 in a row then place your code then 3 at the end of the code
Cal-culator
@Cal-culator
Nov 22 2016 05:12
@Mozar10 wow THANKS SO MUCH! Been stuck for about two months now haha
CamperBot
@camperbot
Nov 22 2016 05:12
cal-culator sends brownie points to @mozar10 :sparkles: :thumbsup: :sparkles:
:cookie: 315 | @mozar10 |http://www.freecodecamp.com/mozar10
Mo Zargham
@Mozar10
Nov 22 2016 05:12
@Cal-culator :thumbsup:
__SharifTarver__
@Sharifdesigns22
Nov 22 2016 05:14
/var myStr = "<a href=http//:www.example.com" \"target=_blank>Link</a> \"; /
JackVizl
@JackVizl
Nov 22 2016 05:14
var myStr="FirstLine\n\SecondLine\\rThirdLine";
@maceo32 var myStr="FirstLine\n\\SecondLine\\\rThirdLine";
Art
@maceo32
Nov 22 2016 05:15
@JackVizl thats not working/
@JackVizl not really sure if its a bug
JackVizl
@JackVizl
Nov 22 2016 05:15
might be
worked for me
did you copy paste?

var myStr="FirstLine\n\\SecondLine\\\rThirdLine";
Art
@maceo32
Nov 22 2016 05:15
yes
JackVizl
@JackVizl
Nov 22 2016 05:15
must be bug
reload browser or something, maybe delete local storage for the challenge
Art
@maceo32
Nov 22 2016 05:16
@JackVizl thanks now it works
CamperBot
@camperbot
Nov 22 2016 05:16
maceo32 sends brownie points to @jackvizl :sparkles: :thumbsup: :sparkles:
:cookie: 329 | @jackvizl |http://www.freecodecamp.com/jackvizl
JackVizl
@JackVizl
Nov 22 2016 05:16
@maceo32 glad i could help, sorry i took so long
Art
@maceo32
Nov 22 2016 05:16
@Sharifdesigns22 yup it looks good now
@JackVizl better late than never :)
Rex Smith Jr.
@rsmith731
Nov 22 2016 05:19
@Gniewoszu so if the image is in a class called .image_frame i would just replace that where .active is?
JackVizl
@JackVizl
Nov 22 2016 05:19
@Mozar10

function addTogether() {

if(arguments.length ===1){
   var number=arguments[0];
    if(typeof arguments[0] === "number"){

        return function(number){
          if(typeof number === "number"){
            return arguments[0] + number;
            }
        };
    }
}

  else if((typeof arguments[0]!=='number')||(typeof arguments[1]!=='number')){
    return undefined;

  }
  else{return arguments[0]+arguments[1];}



}

addTogether(2)(3);
still cant make it work
sorry im so trash bro
__SharifTarver__
@Sharifdesigns22
Nov 22 2016 05:20
So like this? /var myStr = "<a href=http//:www.example.com"\n\"target=_blank>Link</a>"\\\; / I'm confused @JackVizl @maceo32
No I'm really sorry I'm so trash bros
JackVizl
@JackVizl
Nov 22 2016 05:21
@Sharifdesigns22 bro
send me link to challenge
i got u
Mo Zargham
@Mozar10
Nov 22 2016 05:22
@JackVizl its your param name and var name man
@JackVizl just change first var to number2 or something
Mo Zargham
@Mozar10
Nov 22 2016 05:22
don't beat yourself up man closures are so tricky i regularly have to read up on them
JackVizl
@JackVizl
Nov 22 2016 05:23
@Mozar10 im usually not this confused on these
Rex Smith Jr.
@rsmith731
Nov 22 2016 05:23
@Gniewoszu getting an error in the console when i do that
JackVizl
@JackVizl
Nov 22 2016 05:24
@Sharifdesigns22
var myStr = '<a href="http://www.example.com" target="_blank">Link</a>';
backslashes and apostrophes/quotations have the same effect
so its just saying swap the backslashes for '' instead
Mo Zargham
@Mozar10
Nov 22 2016 05:26
@JackVizl change first var name to something different than the parameter name in the second function, then return arguments[0] + firstVar in the second function
Gaurav Deopa
@talk2g
Nov 22 2016 05:27
need some help in record collection challenge
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  if(id=='2538')
{
  if(prop!='tracks'&&value!=='')
    {
      collection[0].prop=value;
    }
  else if(prop==='tracks'&&value!=='')
    {
      collection[0].push(value);
    }
  else if(value===0)
    delete collection[0].prop;
}  

    if(id=='2468')
{
  if(prop!='tracks'&&value!=='')
    {
      collection[1].prop=value;
    }
  else if(prop==='tracks'&&value!=='')
    {
      collection[1].push(value);
    }
  else if(value===0)
    delete collection[1].prop;
}  
  if(id=='1245')
{
  if(prop!='tracks'&&value!=='')
    {
      collection[2].prop=value;
    }
  else if(prop==='tracks'&&value!=='')
    {
      collection[2].push(value);
    }
  else if(value===0)
    delete collection[2].prop;
}  

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

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
JackVizl
@JackVizl
Nov 22 2016 05:27
@Mozar10 ok i gotitworking
@Mozar10 thanks so much man
CamperBot
@camperbot
Nov 22 2016 05:27
jackvizl sends brownie points to @mozar10 :sparkles: :thumbsup: :sparkles:
:warning: jackvizl already gave mozar10 points
Mo Zargham
@Mozar10
Nov 22 2016 05:27
@JackVizl :thumbsup:
JackVizl
@JackVizl
Nov 22 2016 05:27
im gonna look over it and see if i cant get a hold on whats going on
Mo Zargham
@Mozar10
Nov 22 2016 05:27
@JackVizl read up on closures... its tricky but definitely worth spending time on
JackVizl
@JackVizl
Nov 22 2016 05:29
 return function(number){
          if(typeof number === "number"){
            return arguments[0] + number2;
            }
        };
this is the bit that confuses me
i dont see any direct reference to the second parameter
like just by calling it a function, it know to get the next () ?
Mo Zargham
@Mozar10
Nov 22 2016 05:30
see the second parameter is arguments[0] in the second function
there is actually no second argument
first function returns a second function and arguments[0] is the only argument of the second function
so there is really 2 seperate arguments[0]s if you will, there is no second parameter, there is parameter 1 of function 1 and parameter 1 of function 2
Ogundele Olumide
@Lumexralph
Nov 22 2016 05:31
@talk2g why don't you loop through the contacts array before using you branches for comaparing
Tom
@moT01
Nov 22 2016 05:31
@talk2g im not sure testing for the id first is the right way to go
i suppose it would work
Gaurav Deopa
@talk2g
Nov 22 2016 05:32
any hints
Ogundele Olumide
@Lumexralph
Nov 22 2016 05:32
@talk2g the manual picking the elements of the array might be too much work in my opinion
JackVizl
@JackVizl
Nov 22 2016 05:32
@Mozar10 hmm ok, so the addTogether(2)(3), is that like the same as addTogether(2); addTogether(3);?
Gaurav Deopa
@talk2g
Nov 22 2016 05:32
so should i go for looping
JackVizl
@JackVizl
Nov 22 2016 05:32
ive never seen the ()() before
Gaurav Deopa
@talk2g
Nov 22 2016 05:32
@Lumexralph
Ogundele Olumide
@Lumexralph
Nov 22 2016 05:33
first loop through the contatcs array, a for loop will be just fine
yes
Gaurav Deopa
@talk2g
Nov 22 2016 05:33
sure
leeme try
Mo Zargham
@Mozar10
Nov 22 2016 05:33
@JackVizl very close, its the same as addTogether(2) which returns a function with (3) as the parameter...
JackVizl
@JackVizl
Nov 22 2016 05:34
wtf
how does it know about the 3 thooooo
Ogundele Olumide
@Lumexralph
Nov 22 2016 05:34
@talk2g make use of the parameters of your function, don't assign another value to them in your function, they are already holding values from the arguments giving to your function
Mo Zargham
@Mozar10
Nov 22 2016 05:34
@JackVizl so its addTogether(2) , and whatever function is the return value of addTogether(2) with the parameter(3)
@JackVizl the second function is returning 3
its like this
Gaurav Deopa
@talk2g
Nov 22 2016 05:35
thanks @ @Lumexralph
CamperBot
@camperbot
Nov 22 2016 05:35
talk2g sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 478 | @lumexralph |http://www.freecodecamp.com/lumexralph
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 05:35
Hello world
CamperBot
@camperbot
Nov 22 2016 05:35

welcome to FreeCodeCamp @JeffGreenlee42!

JackVizl
@JackVizl
Nov 22 2016 05:35
OHHHH
no dude
i get it now
ima f*ing idiot
@Mozar10 i get it 100% now dude
Mo Zargham
@Mozar10
Nov 22 2016 05:35
@JackVizl if you store the return value of function 1 to a variable myVar, and then say myVar(3) you will get 5 in this example
JackVizl
@JackVizl
Nov 22 2016 05:35
nah man i get it
Ogundele Olumide
@Lumexralph
Nov 22 2016 05:35
@JackVizl there's a funny thing going on in closure, there a function and the ability or the mechanism to remember or have access to the environment it was declared
JackVizl
@JackVizl
Nov 22 2016 05:35
i feel so stupid
Mo Zargham
@Mozar10
Nov 22 2016 05:36
@JackVizl lol its tricky fam , closure is arguably the hardest concept to grasp
Ogundele Olumide
@Lumexralph
Nov 22 2016 05:36
@JeffGreenlee42 hey
@Mozar10 lol, true
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 05:36
I got a question: I just did the "bounce Falsy" challenge.. I made it work... but is this the correct way to do it? :

function isNotFalsy(val) {
  return val;
}

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var filteredArr = arr.filter(isNotFalsy);
  return filteredArr;
}

//debugger;
bouncer([7, "ate", "", false, 9]);
JackVizl
@JackVizl
Nov 22 2016 05:37
ur just telling the function to store the first return, then set a new variable to what would be returned 'if' it called itself with the other parameter?
Ogundele Olumide
@Lumexralph
Nov 22 2016 05:38
@JeffGreenlee42 let your callback function isNotfalsy be in your bouncer scope, i mean in your function
JackVizl
@JackVizl
Nov 22 2016 05:38
@JeffGreenlee42 if it works, its right dude haha
Ogundele Olumide
@Lumexralph
Nov 22 2016 05:39
@JeffGreenlee42 just thinking it's not doing anything in the outer scope of your bouncer function and it'll be accessible in the the bouncer function still, in my opinion
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 05:39
@Lumexralph That's the part I'm confused about! The page for the filter() command seems to indicate the requirement that a function must be called as a first argument. I wish the FCC process covered using callback functions more... they confuse me!
Shantanu1395
@Shantanu1395
Nov 22 2016 05:40
double quotes for string not working in tutorial 144 please help
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 05:40
@Lumexralph so how would I use a callback in this situation?
Mo Zargham
@Mozar10
Nov 22 2016 05:40

@JackVizl ```
function add(number1){
function hasClosureOverAdd(number2){
console.log(number1 + number2);
}
return hasClosureOverAdd
}

add(2)(3)

Ogundele Olumide
@Lumexralph
Nov 22 2016 05:40
@JeffGreenlee42 but your callback function is not checking for falsy value, it should return a boolean, if true filter keeps it, if false filter removes it
Mo Zargham
@Mozar10
Nov 22 2016 05:40
function add(number1){
function hasClosureOverAdd(number2){
console.log(number1 + number2);
}
return hasClosureOverAdd
}
add(2)(3)
JackVizl
@JackVizl
Nov 22 2016 05:41
i see
so calling a function from within a function
the iside
knows about the outside
Mo Zargham
@Mozar10
Nov 22 2016 05:41
@JackVizl exactly
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 05:41
@Lumexralph sure I understand that.. but the descrption of the function clearly requires that you call a function!
JackVizl
@JackVizl
Nov 22 2016 05:42
so
Ogundele Olumide
@Lumexralph
Nov 22 2016 05:42
@JeffGreenlee42 you have already created your callback function and that's cool, just put it in your bouncer function scope
JackVizl
@JackVizl
Nov 22 2016 05:43
im still a little confused about how it knows i want 3 as the next param, is that just the way ()() works? like they all fall into the functions within the outer function ?
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 05:43
@Lumexralph That's where I am having a disconnect.. What do you mean by "put it in your bouncer function scope"?
Ogundele Olumide
@Lumexralph
Nov 22 2016 05:43
@JeffGreenlee42 one thing left to do is a way to make your callback isNotFalsy function to return a boolean checking for truthy or falsy value
JackVizl
@JackVizl
Nov 22 2016 05:43
like funcOut(a)(b)(c) is like funcOut(a), funcFirstInside(b), funcSecondInside(c)?
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 05:45
@Lumexralph The Boolean syntax description states this: "Description
The value passed as the first parameter is converted to a boolean value, if necessary. If value is omitted or is 0, -0, null, false, NaN, undefined, or the empty string (""), the object has an initial value of false. All other values, including any object or the string "false", create an object with an initial value of true."
Mo Zargham
@Mozar10
Nov 22 2016 05:45
@JackVizl dont let the second param confuse you its just a second function call
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 05:45
So from that description I understand that all I have to do is return value.. if its NOT a falsy.. it will return true.. which it does.
Mo Zargham
@Mozar10
Nov 22 2016 05:46
function times(number1){
    function hasClosureOverAdd(){
        console.log(number1 * 2);
    }
    return hasClosureOverAdd 
}

times(2)()
() ---> means execution of a function, just the name of the function is a "reference" to the function
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 05:47
@Lumexralph It appears that the filter() function simply treats anything that is NOT false as true.
Ogundele Olumide
@Lumexralph
Nov 22 2016 05:48
@JeffGreenlee42 e.g if(value) {return true}, all truthy values will passed the test, you can put that in your isNotFalsy call back function
Mo Zargham
@Mozar10
Nov 22 2016 05:48
so you're saying execute times(2), and times(2) returns a reference to hasClosureOverAdd, and the() executes has closureOverAdd
JackVizl
@JackVizl
Nov 22 2016 05:49
@Mozar10 a second function call, so i could have (a)(b)(c)(d)..... and it would just call over and over again?
Ogundele Olumide
@Lumexralph
Nov 22 2016 05:51
@JeffGreenlee42 it should work then, so that means the return value of a filter method is converted to a boolean if it's not right?
Mo Zargham
@Mozar10
Nov 22 2016 05:51
@JackVizl if you keep using closures then yea
function times(number1){
    function hasClosureOverAdd(number2){
        function someFunction(number3){
            console.log(number1*number2*number3)
        }
        return someFunction
    }
    return hasClosureOverAdd 
}

times(2)(2)(2)
JackVizl
@JackVizl
Nov 22 2016 05:52
@Mozar10 i see, thanks so much for all the help man
CamperBot
@camperbot
Nov 22 2016 05:52
jackvizl sends brownie points to @mozar10 :sparkles: :thumbsup: :sparkles:
:cookie: 316 | @mozar10 |http://www.freecodecamp.com/mozar10
JackVizl
@JackVizl
Nov 22 2016 05:52
ok just like i thought, the ()()() just fall into the functions in order
ok, i ge tit now
Mo Zargham
@Mozar10
Nov 22 2016 05:52
:thumbsup: np keep going over it man, i still do all the time
JackVizl
@JackVizl
Nov 22 2016 05:52
im just so used to having to be very specific with referencing data
Mo Zargham
@Mozar10
Nov 22 2016 05:53
@JackVizl yea its an advance concept
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 05:53
@Lumexralph yes.. I guess I just struggle over the question of efficiency... It seems silly to have to call a function.... from a function...... if you are just passing a value that is either true or false. I'm kind of wondering why the filter function doesn't handle that implicitly!
JackVizl
@JackVizl
Nov 22 2016 05:53
@Mozar10 thanks for clearing it up for me :thumbsup:
CamperBot
@camperbot
Nov 22 2016 05:53
jackvizl sends brownie points to @mozar10 :sparkles: :thumbsup: :sparkles:
:warning: jackvizl already gave mozar10 points
Edson Mendieta
@edsonmendieta
Nov 22 2016 05:54

So, in "Map the Debris": is this

avgAlt : 35873.5553

in kilometers or meters?

Ogundele Olumide
@Lumexralph
Nov 22 2016 05:54
@JeffGreenlee42 i only suggested creating your callback in your bouncer function since that's where you need it, but if it gets passed on fcc, it's okay....it passed all the tests, right?
@JeffGreenlee42 then you try something else
Burak
@BurakAy
Nov 22 2016 05:55
Profile Lookup has me stumped. I'm able to pass 2 challenges where you get a return value of "no such contact" and "no such property" but am unable to return anything from the first 'if' statement.

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


function lookUpProfile(firstName, prop) {

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

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

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

    } else if (prop !== contacts[i]) {
      return "No such property";
    } 
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");
Ogundele Olumide
@Lumexralph
Nov 22 2016 05:56
@JeffGreenlee42 use an if to check for truthy value then remove any that's not
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 05:56
@Lumexralph Yes.. however so far this series of JavaScript tutorial challenges.. just really has NOT spent much time on What exactly "call back function" is and how it works!!!! So I confess I am not sure how to do it!
Ogundele Olumide
@Lumexralph
Nov 22 2016 05:57
while looping through
@JeffGreenlee42 think of callback as a function that responds to an event
__SharifTarver__
@Sharifdesigns22
Nov 22 2016 05:58
thank you @JackVizl much appreciated
CamperBot
@camperbot
Nov 22 2016 05:58
sharifdesigns22 sends brownie points to @jackvizl :sparkles: :thumbsup: :sparkles:
:warning: sharifdesigns22 already gave jackvizl points
Richie
@Richie2
Nov 22 2016 05:58
Hello all
JackVizl
@JackVizl
Nov 22 2016 05:58
@Sharifdesigns22 :thumbsup:
@Richie2 sup
Ogundele Olumide
@Lumexralph
Nov 22 2016 05:59
it's triggered by an action or event, remember ajax request, a function callback is used when the data is ready, click event etc they all use a function when they occur, that's what i simply understand as callback
Sultan
@Sultan2790
Nov 22 2016 05:59
Hello people, I need some thoughts of Writing a method named menu that displays the menu of selections. This method should
not accept any arguments.
 The program should continue to display the menu until the user enters 4 to quit the
program.
 The program should not accept negative numbers for the distance in meters.
 If the user selects an invalid choice from the menu, the program should display an error
message.
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 05:59
@Lumexralph Ok.. understood.. but what are the mechanics? How do you implement a call back function?
Edson Mendieta
@edsonmendieta
Nov 22 2016 06:00

So, in "Map the Debris": is this

avgAlt : 35873.5553

in kilometers or meters?

Richie
@Richie2
Nov 22 2016 06:01
Just a quick question about Bonfire solutions.
Sometimes when checking my solutions, they can be very different to the Wiki. What is the best way to approach this? Are the wikisolutions to be studied as model examples?
Ogundele Olumide
@Lumexralph
Nov 22 2016 06:02
@jeffGreenlee42 filter loops through the array by picking each element, the action that occurs is when the element is picked makes the filter to pass the isNotFalsy function you created to the element, that's the callback, i think when the engine sees the name of the function isNotFalsy it's more like a reference to where isNotFalsy was declared it looks for it and use it
@Richie2 no. so far it passes the test
Richie
@Richie2
Nov 22 2016 06:04
thanks, I just wondered if the algorithms should @Lumexralph
CamperBot
@camperbot
Nov 22 2016 06:04
richie2 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:cookie: 479 | @lumexralph |http://www.freecodecamp.com/lumexralph
Richie
@Richie2
Nov 22 2016 06:05
I just wondered if the algorithms should be memorised as set pieces...
Ogundele Olumide
@Lumexralph
Nov 22 2016 06:05
@Richie2 create your own algorithm so far it get's the work done, the wiki just helps to get started
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 06:06
@Lumexralph Ok... so I did some searching in the forums on this topic: Is this a "callback" function?
```
function bouncer(arr) {
return arr.filter(function(i){return i;});
}
Richie
@Richie2
Nov 22 2016 06:06
cheers…. I can sleep better at night :smile:
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 06:06
ah nuts!
function bouncer(arr) {
  return arr.filter(function(i){return i;});
}
Ogundele Olumide
@Lumexralph
Nov 22 2016 06:07
@JeffGreenlee42 yes
Edson Mendieta
@edsonmendieta
Nov 22 2016 06:07

In "Map the Debris": is the provided argument:

avgAlt : 35873.5553

in kilometers or meters?

Ogundele Olumide
@Lumexralph
Nov 22 2016 06:08
@JeffGreenlee42 because the only way that function will be called or used is if it get's the element from filter method when it passes element i to it
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 06:08
That was my quesion... I don't understand WHY the Javascript tutorials do not cover this more explicitly! I think it is really important concept for those learning Javascript (like me!) to understand!
Ogundele Olumide
@Lumexralph
Nov 22 2016 06:11
@JeffGreenlee42 use mdn mozilla developers network.....do you mind taking a lil time out with this https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
Richie
@Richie2
Nov 22 2016 06:11
@JeffGreenlee42 you are right it is important, maybe you should check out some tutorials on youtube about callback functions or check a beginners book like Head First JavaScript Programming. alot of methods require callbacks to work, such as .filter() and .sort()
Darth Skywalker
@adityaparab
Nov 22 2016 06:11

@JeffGreenlee42 :smile:

Now try

const bouncer = (arr) => arr.filter(Boolean);

;)

Ogundele Olumide
@Lumexralph
Nov 22 2016 06:12
@adityaparab ES6 right? lol
Darth Skywalker
@adityaparab
Nov 22 2016 06:13

@Lumexralph : Not exactly,

I wanted to point out

arr.filter(Boolean)

vs

arr.filter(function(i){return i;});
Ogundele Olumide
@Lumexralph
Nov 22 2016 06:13
i love the simplicity just bringing myself to code in the new mechanism an syntax it offers everyday
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 06:13
@Richie2 Yes.. I am going to go one step further and suggest in the forums that this topic get more coverage in the initial challenges.
Markus Kiili
@Masd925
Nov 22 2016 06:13
@adityaparab To me, passing Boolean seems like doing extra work, because filter has automatic coercion to type Boolean.
Darth Skywalker
@adityaparab
Nov 22 2016 06:14
@Masd925 : That depends on a "point of view" through which one evaluates "extra work" :)
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 06:14
@Masd925 Yes! that was my original thought..
Ogundele Olumide
@Lumexralph
Nov 22 2016 06:14
@JeffGreenlee42 FCC always put read, ask, research in their challenges, they know their platform is not enough to learn it all
@JeffGreenlee42 that's the extra work we have to put
Varoonn
@varoonn
Nov 22 2016 06:14
hello
i am stuck
in string escape sequence

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

FirstLine
\SecondLine\
ThirdLine
You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

what to do in this
Ogundele Olumide
@Lumexralph
Nov 22 2016 06:15
@Masd925 hey man, gotten a girl for me yet
Varoonn
@varoonn
Nov 22 2016 06:15
????????
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 06:15
@Lumexralph Maybe... but I think I am probably not alone in not being even aware that I should have researched it by now!!!! How many ppl are coding in JS who still don't quite get the concept?
Darth Skywalker
@adityaparab
Nov 22 2016 06:16

@Lumexralph

@Masd925 hey man, gotten a girl for me yet

You're black. You don't (shouldn't) need help in that department. You just have to be "there" ;)

Varoonn
@varoonn
Nov 22 2016 06:16
@adityaparab
@Lumexralph
Darth Skywalker
@adityaparab
Nov 22 2016 06:16
Crap, I forgot you're striving to be a programmer :P
Varoonn
@varoonn
Nov 22 2016 06:16
@JeffGreenlee42
Ogundele Olumide
@Lumexralph
Nov 22 2016 06:16
@Masd925 i learnt a big lesson about javascript when creating the exact change algorithm
Varoonn
@varoonn
Nov 22 2016 06:16
anyone
??
Markus Kiili
@Masd925
Nov 22 2016 06:17
@Lumexralph What lesson was that you learned?
Darth Skywalker
@adityaparab
Nov 22 2016 06:17

@varoonn

@adityaparab

yes?

Varoonn
@varoonn
Nov 22 2016 06:17
tell
plz
?

@varoonn
hello
i am stuck
in string escape sequence
Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine
\SecondLine\
ThirdLine
You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
what to do in this

Darth Skywalker
@adityaparab
Nov 22 2016 06:18
@varoonn
var str = 'FirstLine\n\\SecondLine\\\nThirdLine';
Ogundele Olumide
@Lumexralph
Nov 22 2016 06:18
@Masd925 is colour an advantage in getting a rich girlfriend.......when i was doing my calculations i experienced so many misbehaviour, the result of some was returning string another number when i tested for their type....
Varoonn
@varoonn
Nov 22 2016 06:19
ok
Darth Skywalker
@adityaparab
Nov 22 2016 06:19
@Lumexralph : What's surprising to me is you're taking advice in this department from programmers!
Markus Kiili
@Masd925
Nov 22 2016 06:19
@adityaparab It makes no practical difference to pass x=>x or Boolean, but the latter feels like holding tweezers with another tweezers.
Ogundele Olumide
@Lumexralph
Nov 22 2016 06:20
@Masd925 i had to explicitly make them all numbers, i had been a lil frustrated before i realised that
@adityaparab lol
Markus Kiili
@Masd925
Nov 22 2016 06:20
@Lumexralph The robust way is to use pennie amounts that are safe integers.
Ogundele Olumide
@Lumexralph
Nov 22 2016 06:20
@adityaparab any suggestion for a fellow programmer...? :wink:
@Masd925 mind expatiating on that?
Markus Kiili
@Masd925
Nov 22 2016 06:21
@Lumexralph It doesn't matter if you are black or white dumdididum.... because when you go rubbing elderly ladies shoulders on the bingo hall, they don't see or hear that well.
Ogundele Olumide
@Lumexralph
Nov 22 2016 06:22
@Masd925 lol
Darth Skywalker
@adityaparab
Nov 22 2016 06:24

@Lumexralph : Many! ;)

1) It has got nothing to do about you. It's about how you make them "feel". (of course that goes on without saying, be hygienic). All ladies are about "I, me and myself"
2) Sense of humor. (doesn't mean you need to be funny. But if the jokes on you, you gotta take it in sporting spirit)
3) The faster you quicker you make your intentions clear, the better for EVERYONE.

Let's focus on these 3 fundamentals first. And get back to programming :D
Markus Kiili
@Masd925
Nov 22 2016 06:24
@Lumexralph Integers -9007199254740991< x < 9007199254740991 have an exact representation as floats. So if you calculate with integers (pennies) you don't have any rounding problems.
Darth Skywalker
@adityaparab
Nov 22 2016 06:25
For ridiculosly huge number, consider http://mathjs.org/
Markus Kiili
@Masd925
Nov 22 2016 06:26
@Lumexralph And remember that it is not going to last forever. I can hold my breath for five minutes and you can please a granny until you get your degree.
Darth Skywalker
@adityaparab
Nov 22 2016 06:26
^ that was a really bad joke @Masd925 :worried:
Markus Kiili
@Masd925
Nov 22 2016 06:27
@adityaparab What joke?
Darth Skywalker
@adityaparab
Nov 22 2016 06:27
Exactly!
Ogundele Olumide
@Lumexralph
Nov 22 2016 06:28
@adityaparab an what are you again? you ain't a progrommer.... yeah i kow, it was a funny talk @Masd925 and I had some time ago and it's now stuffs we joke about seldomly
Darth Skywalker
@adityaparab
Nov 22 2016 06:28
Programming is just one of the things I do for the sake of doing it. :D
Markus Kiili
@Masd925
Nov 22 2016 06:29
@adityaparab Yes, we are not serious. Just talk about whether or not to get a degree or to study on your own.
Darth Skywalker
@adityaparab
Nov 22 2016 06:30
That's why I said! Bad joke! :D
Markus Kiili
@Masd925
Nov 22 2016 06:30
@Lumexralph But stay away from a graveyard. Funerals are a huntingground though.
Darth Skywalker
@adityaparab
Nov 22 2016 06:30
You had to explain that :P
Ogundele Olumide
@Lumexralph
Nov 22 2016 06:30
@Masd925 and how do i do that when i do calculations like that using what you showed
Darth Skywalker
@adityaparab
Nov 22 2016 06:31
The only use I have seen for my degree so far is, for some reason, people take me more seriously because of degree
No need to "prove" anything.
Markus Kiili
@Masd925
Nov 22 2016 06:31
@Lumexralph What do you mean?
Ogundele Olumide
@Lumexralph
Nov 22 2016 06:31
@Masd925 don't worry about that am a cool guy
lol
x as safe integer
phurlakemi
@folagiwa
Nov 22 2016 06:31
hello everyone!
Richie
@Richie2
Nov 22 2016 06:32
my mum plays bingo...
Burak
@BurakAy
Nov 22 2016 06:32
can anybody help me out with this? am not able to get a return value from the first 'if' statement.
Markus Kiili
@Masd925
Nov 22 2016 06:32
@Lumexralph safe integer === exact representation as a float
Darth Skywalker
@adityaparab
Nov 22 2016 06:32
Finally! A woman showed up to soothe this box like space!
welcome @folagiwa
Burak
@BurakAy
Nov 22 2016 06:32

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


function lookUpProfile(firstName, prop) {

// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
    var returnVal = "";

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

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

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

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

// Change these values to test your function
lookUpProfile("Kristian", "lastName");
phurlakemi
@folagiwa
Nov 22 2016 06:33
Can anyone help tutor me in front end development. i have basic knowledge
thank you @adityaparab
CamperBot
@camperbot
Nov 22 2016 06:33
folagiwa sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 719 | @adityaparab |http://www.freecodecamp.com/adityaparab
Darth Skywalker
@adityaparab
Nov 22 2016 06:34

@BurakAy : You should take this part

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

out of your loop

@folagiwa : Post your questions!
Ogundele Olumide
@Lumexralph
Nov 22 2016 06:34
@folagiwa try stuffs on your own when you need help good people are here to help
phurlakemi
@folagiwa
Nov 22 2016 06:35
ok @Lumexralph
Ogundele Olumide
@Lumexralph
Nov 22 2016 06:35
@Masd925 I'll get to you on that when i get to work....
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 06:35
Ok.. So I just posted something on the forum... sort of suggesting that more coverage on the use of call back functions might be added to the ... errr.. curriculum! :P
Darth Skywalker
@adityaparab
Nov 22 2016 06:35
@BurakAy you also need to change that condition to
if (returnVal  == "") {
  return "No such contact";
@JeffGreenlee42 : It should be an entirely new course called "getting funky with the syntax"
or something like "complete idiots guide to be fancy with syntax"
Markus Kiili
@Masd925
Nov 22 2016 06:36
@BurakAy You can use a result variable but just returning when you know the return value is a bit more elegant.
phurlakemi
@folagiwa
Nov 22 2016 06:36
Is this platform strictly for javascript cos i might be asking question on PHP@lumexralph
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 06:37
@adityaparab hmmm.. yeah.. I don't know.. it seems like callback functions are kind of more than just "getting funky" with syntax .. doesn't it?
Darth Skywalker
@adityaparab
Nov 22 2016 06:37
@folagiwa Yes. This is for JS.
Greg Duncan
@GregatGit
Nov 22 2016 06:37
@BurakAy they way you have written it - it will loop through every contact , even after is has matched the contact, it will check the next one
Darth Skywalker
@adityaparab
Nov 22 2016 06:37

@folagiwa : You might find answers to your PHP questions in

https://gitter.im/FreeCodeCamp/HelpBackEnd

Markus Kiili
@Masd925
Nov 22 2016 06:38
help rooms
CamperBot
@camperbot
Nov 22 2016 06:38
no wiki entry for: rooms
Coy Sanders
@coymeetsworld
Nov 22 2016 06:38
wiki is dead :/
CamperBot
@camperbot
Nov 22 2016 06:38
no wiki entry for: is dead
Coy Sanders
@coymeetsworld
Nov 22 2016 06:38
wiki anything
CamperBot
@camperbot
Nov 22 2016 06:38
no wiki entry for: anything
Darth Skywalker
@adityaparab
Nov 22 2016 06:38

@camperbot

no wiki entry for: is dead

Camper bot is really American. Taking everything literally!

Coy Sanders
@coymeetsworld
Nov 22 2016 06:38
I guess/
?
Richie
@Richie2
Nov 22 2016 06:39
lol
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 06:39
I mean.. as I was doing the challenge I was really aware of how "Ugly" my solution (which did work!) was! seems like a concerted effort to change 10 lines of code to just one is a worthy endeavor!
Burak
@BurakAy
Nov 22 2016 06:39
@adityaparab @GregatGit @Masd925 Thanks for your help!
CamperBot
@camperbot
Nov 22 2016 06:39
burakay sends brownie points to @adityaparab and @gregatgit and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 720 | @adityaparab |http://www.freecodecamp.com/adityaparab
:cookie: 788 | @gregatgit |http://www.freecodecamp.com/gregatgit
:star2: 2972 | @masd925 |http://www.freecodecamp.com/masd925
Richie
@Richie2
Nov 22 2016 06:39
@JeffGreenlee42 ugly is good if it works
your code will get cleaner the more you do it….. at least I hope
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 06:40
@Richie2 Not necessarily if you have to read someone's ugly code after the fact!
Markus Kiili
@Masd925
Nov 22 2016 06:40
@JeffGreenlee42 I have a gist of my FCC one-liners. You can look at it after doing the algorithm challenges if you like.
c0d0er
@c0d0er
Nov 22 2016 06:40
does anybody know how to make margin between the green red yellow and blue boxes? http://codepen.io/c0d0er/pen/ENWyyp?editors=1100
Darth Skywalker
@adityaparab
Nov 22 2016 06:41

Ugly code is subjective.

To me, not being explicit in the code is ugly.
Lot of people think shorter and implied code is beautiful. That's really ugly to me

Richie
@Richie2
Nov 22 2016 06:41
@JeffGreenlee42 yes, but you are just beginning, so just take your time and read code read code read code…. and repeat
@adityaparab agreed, I read somewhere that we should write code that other people can understand
Darth Skywalker
@adityaparab
Nov 22 2016 06:42
Correct
Sultan
@Sultan2790
Nov 22 2016 06:43
Can you call function inside a function to display output ?
Markus Kiili
@Masd925
Nov 22 2016 06:43
@Sultan2790 Yes.
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 06:43
@adityaparab maybe.. but the callback solution.. just seems like its a lot more efficient ? rather than calling a function .. which calls another function then returns to the function... yada yada.. am I wrong?
Coy Sanders
@coymeetsworld
Nov 22 2016 06:43
@Richie2 try to make something as simple as possible but not simpler
Sultan
@Sultan2790
Nov 22 2016 06:44
@Masd925 Thanks
CamperBot
@camperbot
Nov 22 2016 06:44
sultan2790 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2973 | @masd925 |http://www.freecodecamp.com/masd925
shawn wang
@sw-yx
Nov 22 2016 06:44
hi guys, i am doing no-repeats-please, and facing a problem because my permutation function is recursive and needs a global variable.
any advice?
Markus Kiili
@Masd925
Nov 22 2016 06:44
@sw-yx You can always make a wrapper function around it.
shawn wang
@sw-yx
Nov 22 2016 06:44
ohh
c0d0er
@c0d0er
Nov 22 2016 06:45
@coymeetsworld thanks, i know the pic you sent to me, but any way to make margin between four boxes?
CamperBot
@camperbot
Nov 22 2016 06:45
c0d0er sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1560 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 06:45
@sw-yx Might want to display your code .. so pple can see it...
Darth Skywalker
@adityaparab
Nov 22 2016 06:45
@JeffGreenlee42 : Let's leave elegance aside for a while. How else do you propose async functions be written?
Coy Sanders
@coymeetsworld
Nov 22 2016 06:46
I'm not sure I understand @c0d0er
shawn wang
@sw-yx
Nov 22 2016 06:46
blob
@JeffGreenlee42 @Masd925
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 06:46
@adityaparab your getting way ahead of me... "async" hasn't been introduced as a topic yet.. from my perspective.
Joseph
@revisualize
Nov 22 2016 06:46
@JeffGreenlee42 I sent you a PM.
Coy Sanders
@coymeetsworld
Nov 22 2016 06:47
you can specify where you want the margins by using margin-top/margin-bottom/margin-left/margin-right
shawn wang
@sw-yx
Nov 22 2016 06:47
i dont think i grok how to mak e a wrapper funciton to simulate a global variable for a recursive function
Joseph
@revisualize
Nov 22 2016 06:47
@coymeetsworld I also sent you a pm.
Coy Sanders
@coymeetsworld
Nov 22 2016 06:47
yes I saw thanks @revisualize
CamperBot
@camperbot
Nov 22 2016 06:47
coymeetsworld sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2399 | @revisualize |http://www.freecodecamp.com/revisualize
c0d0er
@c0d0er
Nov 22 2016 06:47
@coymeetsworld i tried using margin-right then it will ruin the 2 floating boxes
Markus Kiili
@Masd925
Nov 22 2016 06:48
@sw-yx All code inside the wrapper function.
shawn wang
@sw-yx
Nov 22 2016 06:48
all code?
ahh
im an idiot
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 06:48
@sw-yx Oh my! have you tried stepping through that with a debugger? what happens?
:) is that a form of recursion?
shawn wang
@sw-yx
Nov 22 2016 06:50
@JeffGreenlee42 @Masd925 thanks for your help you get karma
CamperBot
@camperbot
Nov 22 2016 06:50
sw-yx sends brownie points to @jeffgreenlee42 and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 266 | @jeffgreenlee42 |http://www.freecodecamp.com/jeffgreenlee42
:star2: 2974 | @masd925 |http://www.freecodecamp.com/masd925
shawn wang
@sw-yx
Nov 22 2016 06:50
and brownies
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 06:50
Reminds me of an old blues Lyric: "I was looking back to see if she was looking back to see if I was looking back at her!"
shawn wang
@sw-yx
Nov 22 2016 06:50
can i just say as a python guy
i hate js
haha
ONLY reason i am putting myself thru this is to do frontend myself
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 06:51
Yeah!!!! I hear you @sw-yx !!! ha ha!
Henry Cabello
@hacu9
Nov 22 2016 06:52
Someone take a look at my pen D: https://codepen.io/cabello986/pen/rrgdpV go ahead and open dev tools console,click ON and try to play,it keeps pushing massive elements into the playerplays array
also,isnt it cute? :c
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 06:53
@sw-yx I think there is more structure in formally typed languages... Python definitely beats JS on that!
besides that.. its just easier to read! :)
Abhisek Pattnaik
@abhisekp
Nov 22 2016 07:09
I :heartpulse: JS
Sultan
@Sultan2790
Nov 22 2016 07:10
How to break out of the loop do-while loop ? for example, if user enter 4, I want to quit
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 07:10
@abhisekp I HOPE there will come a day when I say the same.. .. errr.. I'm just not there yet!
Sultan
@Sultan2790
Nov 22 2016 07:10
@abhisekp me too even it is hard just like it
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 07:11
@Sultan2790 break;
Sultan
@Sultan2790
Nov 22 2016 07:11
@JeffGreenlee42 what about a condition ?
Abhisek Pattnaik
@abhisekp
Nov 22 2016 07:11

How to break out of the loop do-while loop ? for example, if user enter 4, I want to quit

@Sultan2790 add a check in the while condition

Markus Kiili
@Masd925
Nov 22 2016 07:11
@Sultan2790 You can also have a variable that you test on the while condition.
Abhisek Pattnaik
@abhisekp
Nov 22 2016 07:11
lol
yeah! silence for a minute. Shh..
Sultan
@Sultan2790
Nov 22 2016 07:13
blob
Abhisek Pattnaik
@abhisekp
Nov 22 2016 07:13
where are all the indentations?
Sultan
@Sultan2790
Nov 22 2016 07:14
see the last function, I had quitprogram as var but it program will still run the functions even the user enter number 4, i want it to quit when the user enter 4
@abhisekp Thanks buddy
CamperBot
@camperbot
Nov 22 2016 07:14
sultan2790 sends brownie points to @abhisekp :sparkles: :thumbsup: :sparkles:
:star2: 3179 | @abhisekp |http://www.freecodecamp.com/abhisekp
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 07:15
Sultan
@Sultan2790
Nov 22 2016 07:17
@JeffGreenlee42 I think it is good idea not to use break bc it messes with the program performance. I think a condition to break out of the loop would be better for performance. What u think ?
Ogundele Olumide
@Lumexralph
Nov 22 2016 07:17
@Sultan2790 it depends on what you're doing
break and continue can come in handy, you never know
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 07:18
@Sultan2790 I'm definitely NOT an expert on the subject.. I think it's used most often in While loops and Switch statements...
Ogundele Olumide
@Lumexralph
Nov 22 2016 07:18
@JeffGreenlee42 break is a keyword to stop a loop
Sultan
@Sultan2790
Nov 22 2016 07:19
Yes true they used on while loop and switch but I have read it messes with the performance of the program bc it breaks and go find other statement to execute
@Lumexralph yes they are helpful sometimes I agree
Ogundele Olumide
@Lumexralph
Nov 22 2016 07:20
@Sultan2790 i don't know about that
Markus Kiili
@Masd925
Nov 22 2016 07:20
@Sultan2790 I think breaking from loops usually makes the code harder to read and understand.
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 07:20
@Lumexralph yes I know... @Sultan2790 I think what you might want to watch and becareful of is when and if something is calling and it does not get a return value it might expect...
Mateusz Kadlubowski
@xeho91
Nov 22 2016 07:21

Hi, can anyone explain me why my code so far returns an empty array?


function sym() {

  var args = Array.from(arguments);

  function findSymetricDifferences(array1, array2) {

    var symetricDifferences = [];

    array1.forEach(function(value) {

      if (array1.indexOf(value) === -1 && symetricDifferences.indexOf(value) === -1) {
        symetricDifferences.push(value);
      }
    });

    return symetricDifferences;
  }

  return args.reduce(findSymetricDifferences);
}

// test here
sym([1, 2, 3], [5, 2, 1, 4]);

and what's the difference between calling function like this (without parentheses) findSymetricDifferences and with parentheses findSymetricDifferences()?

Sultan
@Sultan2790
Nov 22 2016 07:21
@Lumexralph @JeffGreenlee42 I would practice on how to break out of the loop by creating a condition to cut the loop and let the program run normally
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 07:21
but sometimes a clean break is the clean and quickest way out!
Markus Kiili
@Masd925
Nov 22 2016 07:21
@JeffGreenlee42 I can be used in a clear way sometimes.
Sultan
@Sultan2790
Nov 22 2016 07:21
@JeffGreenlee42 Yes clean break
blob
Can someone look at the last function, I want the program say bye when the user enter number 4 ...
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 07:23
I think JS is probably a bit more robust then some of the older typed languages.. I remember situations using C where a break could leave you in a BAD place if it was used improperly..
Mateusz Kadlubowski
@xeho91
Nov 22 2016 07:23
@Sultan2790 Sorry for off-topic, but have you considered using code editors like Atom or Sublime?
Sultan
@Sultan2790
Nov 22 2016 07:24
@xeho91 not really ? what are those ?
Markus Kiili
@Masd925
Nov 22 2016 07:24
@xeho91 array1.indexOf(value) === -1 is always false?
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 07:24
@Sultan2790 They are really AWESOME code editors! with lots of bells and whistles!
Markus Kiili
@Masd925
Nov 22 2016 07:25
@xeho91 Maybe you meant to use array2 here.
Ogundele Olumide
@Lumexralph
Nov 22 2016 07:25
@JeffGreenlee42 lol
Sultan
@Sultan2790
Nov 22 2016 07:25
@JeffGreenlee42 I am tryin it now
Mateusz Kadlubowski
@xeho91
Nov 22 2016 07:25
@Masd925 Damn, thank you!
CamperBot
@camperbot
Nov 22 2016 07:25
xeho91 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2975 | @masd925 |http://www.freecodecamp.com/masd925
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 07:25
Sublime is great too.. but it does cost some $$$
Ashirwad Joshi
@aashu1829
Nov 22 2016 07:25
Hi All
can someone
please help me with this
lydie88
@lydie88
Nov 22 2016 07:26
@BurakAy I and you have the same problem,can I refer to your code?
Markus Kiili
@Masd925
Nov 22 2016 07:26
@aashu1829 It is better if you copy paste the code here formatted (if you have made some code).
Burak
@BurakAy
Nov 22 2016 07:27
hey @lydie88 check out the detailed explanation in the forum, it's really helpful! https://forum.freecodecamp.com/t/profile-lookup-spoilers-solved/1827/3
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 07:27
@aashu1829 yeah.. click the litle "M" on the right of the chat to see how to paste code.
Mateusz Kadlubowski
@xeho91
Nov 22 2016 07:28
@Masd925 Can you explain also logic between calling defined function with parentheses and without?
findSymetricDifferences() and findSymetricDifferences?
I thought that's exact same, but for some reason both are different
Markus Kiili
@Masd925
Nov 22 2016 07:28
@xeho91 The second is a function and the first its return value then called without any arguments.
Ashirwad Joshi
@aashu1829
Nov 22 2016 07:28
alt%20%7B%0A%20%20%2F%2F%20Your%20code%20here%0A%20%20%0A%20%20return%20item%3B%20%20%2F%2F%20Change%20this%20line%0A%7D%0A%0A%2F%2F%20Test%20Setup%0Avar%20testArr%20%3D%20%5B1%2C2%2C3%2C4%2C5%5D%3B%0A%0A%2F%2F%20Display%20Code%0Aconsole.log(%22Before%3A%20%22%20%2B%20JSON.stringify(testArr))%3B%0Aconsole.log(nextInLine(testArr%5B2%5D%2C1))%3B%20%2F%2F%20Modify%20this%20line%20to%20test%0Aconsole.log(%22After%3A%20%22%20%2B%20JSON.stringify(testArr))%3B%0A)
lydie88
@lydie88
Nov 22 2016 07:29
ok,thanks @BurakAy
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 07:29
@xeho91 I think it depends...
Ashirwad Joshi
@aashu1829
Nov 22 2016 07:29
Sorry I did something wrong
Markus Kiili
@Masd925
Nov 22 2016 07:29
@xeho91 In JS functions are objects that can be stored in variables and passed into and returned from functions, like all other values.
Mateusz Kadlubowski
@xeho91
Nov 22 2016 07:30
@Masd925 so you mean I can store functions as variables?
Markus Kiili
@Masd925
Nov 22 2016 07:30
@xeho91 You can store a function in a variable.
Mateusz Kadlubowski
@xeho91
Nov 22 2016 07:31
Wow... it wasn't mentioned in any lesson earlier or I must have missed this part
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 07:31
@Masd925 yeah.. I was thinking.. isn't "string.length" an example of that?
Markus Kiili
@Masd925
Nov 22 2016 07:31
Another way is to declare a function, but those two have very little difference in any language with higher order functions.
@JeffGreenlee42 Strings are primitive values so it is a bit different. The engine automatically wraps the string into a String object and calls its method.
Jeff Greenlee
@JeffGreenlee42
Nov 22 2016 07:33
right.. but in the end.. it IS a method.... right? even though you don't have to use () on it?
Markus Kiili
@Masd925
Nov 22 2016 07:33
But yes, a function is assigned into a property of String.prototype
Mateusz Kadlubowski
@xeho91
Nov 22 2016 07:33

Okay, I finally completed this challenge "Symetric Difference"


function sym() {

  var args = Array.from(arguments);

  function findSymetricDifferences(array1, array2) {

    var symetricDifferences = [];

    array1.forEach(function(value) {

      if (array2.indexOf(value) === -1 && symetricDifferences.indexOf(value) === -1) {
        symetricDifferences.push(value);
      }
    });

    array2.forEach(function(value) {

      if (array1.indexOf(value) === -1 && symetricDifferences.indexOf(value) === -1) {
        symetricDifferences.push(value);
      }
    });

    return symetricDifferences;
  }

  return args.reduce(findSymetricDifferences);
}

// test here
sym([1, 2, 3], [5, 2, 1, 4]);

But of course I would love to know if it could be shorter using more advanced JS

Markus Kiili
@Masd925
Nov 22 2016 07:36
@xeho91 I see some repeating code with those forEach calls. You could make a function that you call twice.
@xeho91 Filter could so the same as your forEach without the result variable.
Mateusz Kadlubowski
@xeho91
Nov 22 2016 07:38
Hmmm absolutely no idea for now how I could pass each array as parameter inside this function
Markus Kiili
@Masd925
Nov 22 2016 07:40
@xeho91 This is one good way to make it a bit clearer:
function sym(args) {
  args=Array.prototype.slice.call(arguments);
  return args.reduce(function(acc, curr){
    return removeDoubles(acc.concat(removeMultiples(curr))); 
  }, []);
}

function removeDoubles (arr) {  // Removes non-singles (doesn't leave on of each)
  return arr.filter(function(val){
      return arr.indexOf(val)===arr.lastIndexOf(val);
  });  
}

function removeMultiples (arr) {  // Leaves one of each
  return arr.filter(function(val, index){
    return arr.indexOf(val)===index;
  });
}
Mateusz Kadlubowski
@xeho91
Nov 22 2016 07:41
args=Array.prototype.slice.call(arguments); will be same as args = Array.from(arguments)?
Markus Kiili
@Masd925
Nov 22 2016 07:41
@xeho91 Yes, from is ES6 method.
For example that Array.from has no IE support, so for most front end production code, you still have to transpile your ES6 JS into ES5, so it works on clients browsers.
Mateusz Kadlubowski
@xeho91
Nov 22 2016 07:43
Really? Every version of IE?
Markus Kiili
@Masd925
Nov 22 2016 07:45
@xeho91 It should work on Edge, but many people use old browsers.
initzer0
@initzer0
Nov 22 2016 07:45
hi, I'm having trouble with the Profile Lookup challenge, if anyone could lead me the right direction.

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


function lookUpProfile(firstName, prop){
// Only change code below this line
  for(var i=0; i<contacts.length; i++){
    if(firstName == contacts[i].firstName && contacts[i][prop]){
     return contacts[i][prop];
    }else if (firstName !== contacts[i].firstName){
      return "No such contact";
    } else {
    return "No such property";
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Kristian", "lastName");
Mateusz Kadlubowski
@xeho91
Nov 22 2016 07:45
Well then, I'll stand against those stubborn people to change browser. If they want to take a look at my futurish-awesome-site, then they will have to change to anything but IE. Period :/
Markus Kiili
@Masd925
Nov 22 2016 07:45
@initzer0 contacts[i][prop] is not a property existence test.
initzer0
@initzer0
Nov 22 2016 07:46
the first if statement seemed to work fine, so I'm guessing my problem is on the if/else statements because after adding them , the lookup does not work.
@Masd925 I tried it with .hasOwnProperty as well and I still had the same problem
Markus Kiili
@Masd925
Nov 22 2016 07:46
@xeho91 You can do that, but if you do code for Coca-Cola, that is not a good way.
Many people think that the screen is the computer and they have no idea what a browser is.
Mateusz Kadlubowski
@xeho91
Nov 22 2016 07:48
@Masd925 Thanks for the tip, I will now skip Coca-Cola offers in future to avoid working and losing nerves :D
CamperBot
@camperbot
Nov 22 2016 07:48
xeho91 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: xeho91 already gave masd925 points
Markus Kiili
@Masd925
Nov 22 2016 07:48
@xeho91 ES6 code can easily be transpiled into ES5, so that is not a problem.
Mateusz Kadlubowski
@xeho91
Nov 22 2016 07:49
@Masd925 How? Some tools?
@Masd925 I can imagine that probably Gulp has some package to transform from ES6 to ES5
Burak
@BurakAy
Nov 22 2016 07:51
@initzer0 check out the discussion about it on the forum here https://forum.freecodecamp.com/t/profile-lookup-spoilers-solved/1827/3
Ji Baik
@JiBaik
Nov 22 2016 07:51
webpack
Darth Skywalker
@adityaparab
Nov 22 2016 07:52
webpack doesn't transpile on it's own
Ji Baik
@JiBaik
Nov 22 2016 07:52
well u use babel
Darth Skywalker
@adityaparab
Nov 22 2016 07:52
You'll need babel-loader to transform ES6 to ES5
Ji Baik
@JiBaik
Nov 22 2016 07:52
but webpack is the standard these days
Darth Skywalker
@adityaparab
Nov 22 2016 07:52
yes
initzer0
@initzer0
Nov 22 2016 07:52
@BurakAy sweet, will do. Thanks for taking time for finding it and linking!
CamperBot
@camperbot
Nov 22 2016 07:52
initzer0 sends brownie points to @burakay :sparkles: :thumbsup: :sparkles:
:cookie: 226 |