3rd
May 2017
Samuel Culpepper
@qzdl
May 03 2017 00:01
@cmccormack thanks man, it was stressing me for the longest time, glad to have some eyes on it
CamperBot
@camperbot
May 03 2017 00:01
qzdl sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
Christopher McCormack
@cmccormack
May 03 2017 00:01
@etisdew I don't see any javascript so I don't think you have any click events :)
Mohamed Derhalli
@derhaIIim
May 03 2017 00:10
wassup
:v:
Chris
@MrChristofferson
May 03 2017 00:12
@derhaIIim Ayeeee
Mohamed Derhalli
@derhaIIim
May 03 2017 00:17
@MrChristofferson heyzzzzzzz
wassup
Randall S.
@reylas81
May 03 2017 00:19

Here is my code:

``````function findLongestWord(str) {
var a = str.split(" "); //array for each word in str
var b = a.length - 1; //number of cells in array a
var c = 0; //counter for number of itterations
var d = []; //array to hold the numberic length of each word per cell
var e ; //compares cells and returns highest numberic value
for ( ; c <= b; c++) { //while c is less than b run code and add 1 to c
d.push([a[c]].length) ; //should push the value of the length of a[c] into d[]
return d[];
}
e = d.Math.max();//should return the larges value in d[]
return ;
}

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

WTF am I doing wrong... currently with this code it returns with [1], if I remove the [] around [a[c]] so it is a[c] it will return with [3]

Chris
@MrChristofferson
May 03 2017 00:31
@reylas81, don't forget that `return` statements inside functions will return the immediate value they get and exit the function
You're on the right track though, `3` is the index of the longest word ;)
Nathan Vu
@NathanVu
May 03 2017 00:32
``````
// Example
var ourDog = {
"name": "Camper",
"legs": 4,
"tails": 1,
"friends": ["everything!"]
};

// Only change code below this line.

var myDog = {
"name": "name",
"legs": 4,
"tails": 3,
"friends": ["everyting!"],

};``````
Hey guys does this syntax looks like a json to you? It looks really familar
Gabe Rotberg
@grotberg
May 03 2017 00:32
@reylas81 the index of the longest s actually 4, though. Your for loop is never making it past the first loop since you have a `return` statement in there. I think the 3 being returned is the length of the 0 index, since that is far as it gets.
Chris
@MrChristofferson
May 03 2017 00:33
Ah, @grotberg is right :clap:
Gabe Rotberg
@grotberg
May 03 2017 00:34
@reylas81 basically, there's quite a few issues. First, in the look you want to remove those square braces around the a[c] - those aren't doing anything good for you. Then delete that return statement in the for loop, it is breaking your logic. (when in doubt, follow the logic through by hand to try and figure out where things are going wrong)
@reylas81 at that point, you should wind up finishing the for loop with d correctly being an array of the length of each word in the original string.
FlashHero
@FlashHero
May 03 2017 00:35
@NathanVu It is formatted as json
Nathan Vu
@NathanVu
May 03 2017 00:36
@FlashHero Okay that's what I thought. They did not mention anything about json in this tutorial
Chris
@MrChristofferson
May 03 2017 00:36
@NathanVu Try to avoid trailing commas in JSON, check the `friends` property of `myDog`
Gabe Rotberg
@grotberg
May 03 2017 00:36
@reylas81 that said, I don't believe `d.Math.max()` works that way, so you'll have to get the longest one some other way
Roxroy
@roxroy
May 03 2017 00:37
@NathanVu , you are righ. it is JSON, JavaScript Object Notation
Conor Murphy
@cmurphy580
May 03 2017 00:37
can anyone explain to me how this function works?
``const findOdd = (xs) => xs.reduce((a, b) => a ^ b);``
Anthony Henry
@Ahenry80
May 03 2017 00:38
``````
function steamrollArray(arr) {
// I'm a steamroller, baby
var ans = [];
if(Array.isArray(arr) === true){
for(var i = 0; i < arr.length; i++){
for(var j = 0; j < arr.length; j++){
arr.push(arr[i][j]);
}
}
}

return ans;
}

steamrollArray([1, [2], [3, [[4]]]]);``````
It keeps on saying that it will end in an infinite what I am supposed to do to access the numbers inside of the nested arrays
Gabe Rotberg
@grotberg
May 03 2017 00:38
@Ahenry80 it will be infinite because you're looping using arr.length as a conditional but pushing new values to arr
Chris
@MrChristofferson
May 03 2017 00:38
@cmurphy580 Think of it like this instead:
``````var findOdd = function findOdd(xs) {
return xs.reduce(function (a, b) {
return a ^ b;
});
};``````
Gabe Rotberg
@grotberg
May 03 2017 00:38
@Ahenry80 so arr keeps getting longer...
FlashHero
@FlashHero
May 03 2017 00:39
challenge help
Anthony Henry
@Ahenry80
May 03 2017 00:40
@grotberg I understand now but how do I access the numbers in the nested arrays
Conor Murphy
@cmurphy580
May 03 2017 00:41
@MrChristofferson Sweet! thank you! But i'm not sure how the bitwise operator works
CamperBot
@camperbot
May 03 2017 00:41
cmurphy580 sends brownie points to @mrchristofferson :sparkles: :thumbsup: :sparkles:
Gabe Rotberg
@grotberg
May 03 2017 00:41
@Ahenry80 might try pushing them to the ans array instead of arr? that won't be the solution (you have to deal with the deeply nested arrays somehow as well), but it won't result in an error
@FlashHero for me, I found it easiest to start by creating a translation table object (ie, what is the value of each "numeral") and then figuring out how I could use that to calculate the answer.
Vamp
@the-vampiire
May 03 2017 00:43
@forkerino thanks thats what I thought yo meant. it produces the same result unfortunately :/
``````function checkCashRegister(price, cash, cid){
var change = (cash - price)*100, changed_used = [], total = 0;

for(var i in cid){
total += cid[i][1];
}

// console.log(change);
// console.log(total.toFixed(2));

if(total.toFixed(2) === change.toFixed(2)){
return 'Closed';
}

// coin and bill values array
var values = [0.01, 0.05, 0.10, 0.25, 1.00, 5.00, 10.00, 20.00, 100.00];

// push into cid array for easy access during forEach
// cid = [name[0], value[1], available amount[2]]
for(var i in cid){
cid[i] = [cid[i][0], values[i], cid[i][1]];
}

cid.reverse();

// iterate through each element and decrement both the change needed and available amount of each coin / bill
cid.forEach(function(element){

var available = element[2]*100,
val = element[1]*100;

// console.log('\n');
// console.log('called: ', element[0], 'val: ', val);
// console.log('changed remaining: ', change);
// console.log('change / val: ', change / val, '>1: ', change/val > 1);
// console.log('\n');

// checking change / val > 1
// determines whether it is possible to make change using that bill or coin
if((change / val) > 1){
while(change  - val>= 0){
if(available !==0){
console.log('available: ', available, 'change: ', change);
available -= val;
change -= val;
}
else{
return 'unavailable';
}
}
}

// if the change used is not 0, push it to the change_used array
var returned = element[2]*100 - available;

if(element[2] - available !== 0){
// divide by 1 to make it an integer as toFixed returns a string
changed_used.push([element[0], returned/100]);
}

return change;

});

// console.log('\n');
//
// console.log(changed_used);

if(changed_used.length > 0){
return changed_used;
}

return 'Insufficient Funds';
}``````
CamperBot
@camperbot
May 03 2017 00:43
the-vampiire sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2097 | @forkerino |http://www.freecodecamp.com/forkerino
Vamp
@the-vampiire
May 03 2017 00:44
``````[ [ 'ONE HUNDRED', 0 ],
[ 'FIVE', 15 ],
[ 'ONE', 1 ],
[ 'QUARTER', 0.5 ],
[ 'DIME', 0.2 ],
[ 'NICKEL', 0 ],
[ 'PENNY', 0.04 ] ]``````
I need 0.5 and 0.2 to be 0.50 and 0.20
May 03 2017 00:45
So I could be reading the documentation wrong but calling .length on an argument object should give you the number of objects correct?
*arguments not objects but yeah
Gabe Rotberg
@grotberg
May 03 2017 00:46
@Adia-A the arguments object is weird, and kinda acts like an array, but not exactly. I usually start off by assigning it like this whenever I need it: `var args = [].slice.call(arguments);`
@Adia-A behaves a lot more predictably that way
FlashHero
@FlashHero
May 03 2017 00:47
@grotberg how would i count the parameter passed and interpret
May 03 2017 00:47
@grotberg Oh yeah I tried that and it only returns the first argument (which is an array)
Gabe Rotberg
@grotberg
May 03 2017 00:49
@FlashHero Well, that's the puzzle. But you're going to need a loop. Think about how you'd do it manually and try applying the same logic.
FlashHero
@FlashHero
May 03 2017 00:50
@grotberg ok thanks
CamperBot
@camperbot
May 03 2017 00:50
flashhero sends brownie points to @grotberg :sparkles: :thumbsup: :sparkles:
Gabe Rotberg
@grotberg
May 03 2017 00:50
@Adia-A and that's weird. It should give you all the arguments passed
May 03 2017 00:50
@grotberg Yeah that's what weird. When I console log out the exact code you give me it only returns the first argument.....
Michael Grienauer
@mgrienauer
May 03 2017 00:51
hey is there a way with js or html to play an audio file when i click a button?
Gabe Rotberg
@grotberg
May 03 2017 00:52
@Adia-A Well, as you say, it should have the length attribute anyway (just none of the other array functions)
May 03 2017 00:52
Yeah and the length attribute returns 6 (which is the length of the first argument array) instead of 3 which is the number of arguments passed
Vamp
@the-vampiire
May 03 2017 00:52

how can I round 0.5 to 0.50 as an integer?

toFixed fails (returns string)
parseInt fails
parseFloat fails
mod 2 fails
100 / 100 fails
Math.round(num \
100)/100 fails

May 03 2017 00:53
@grotberg So very confused right now
Gabe Rotberg
@grotberg
May 03 2017 00:53
Chris
@MrChristofferson
May 03 2017 00:53
@the-vampiire do you have code examples?
Michael Grienauer
@mgrienauer
May 03 2017 00:53
@grotberg awesome thanks
CamperBot
@camperbot
May 03 2017 00:53
mike93og93 sends brownie points to @grotberg :sparkles: :thumbsup: :sparkles:
Vamp
@the-vampiire
May 03 2017 00:53
``````function checkCashRegister(price, cash, cid){
var change = (cash - price), changed_used = [], total = 0;

for(var i in cid){
total += cid[i][1];
}

// console.log(change);
// console.log(total.toFixed(2));

if(total.toFixed(2) === change.toFixed(2)){
return 'Closed';
}

// coin and bill values array
var values = [0.01, 0.05, 0.10, 0.25, 1.00, 5.00, 10.00, 20.00, 100.00];

// push into cid array for easy access during forEach
// cid = [name[0], value[1], available amount[2]]
for(var i in cid){
cid[i] = [cid[i][0], values[i], cid[i][1]];
}

cid.reverse();

// iterate through each element and decrement both the change needed and available amount of each coin / bill
cid.forEach(function(element){

var available = element[2],
val = element[1];

// console.log('\n');
// console.log('called: ', element[0], 'val: ', val);
// console.log('changed remaining: ', change);
// console.log('change / val: ', change / val, '>1: ', change/val > 1);
// console.log('\n');

// checking change / val > 1
// determines whether it is possible to make change using that bill or coin
if((change / val) > 1){
while(change  - val>= 0){
if(available !==0){
console.log('available: ', available, 'change: ', change);
available -= val;
change -= val;
}
else{
return 'unavailable';
}
}
}

// if the change used is not 0, push it to the change_used array
var returned = Math.round((element[2] - available)*10)/10;

if(element[2] - available !== 0){
// divide by 1 to make it an integer as toFixed returns a string
changed_used.push([element[0], returned ]);
}

return change;

});

// console.log('\n');
//
// console.log(changed_used);

if(changed_used.length > 0){
return changed_used;
}

return 'Insufficient Funds';
}``````
Gabe Rotberg
@grotberg
May 03 2017 00:53
@the-vampiire may I ask why you need it to be 0.50? 0.5 should be equivalent
Vamp
@the-vampiire
May 03 2017 00:54
relevant
``````cid.forEach(function(element){

var available = element[2],
val = element[1];

// console.log('\n');
// console.log('called: ', element[0], 'val: ', val);
// console.log('changed remaining: ', change);
// console.log('change / val: ', change / val, '>1: ', change/val > 1);
// console.log('\n');

// checking change / val > 1
// determines whether it is possible to make change using that bill or coin
if((change / val) > 1){
while(change  - val>= 0){
if(available !==0){
console.log('available: ', available, 'change: ', change);
available -= val;
change -= val;
}
else{
return 'unavailable';
}
}
}

// if the change used is not 0, push it to the change_used array
var returned = Math.round((element[2] - available)*10)/10;

if(element[2] - available !== 0){
// divide by 1 to make it an integer as toFixed returns a string
changed_used.push([element[0], returned ]);
}

return change;

});``````
it is not passing their test
May 03 2017 00:54
Sure I'm on Seek and Destroy and let me see how you post a code snippet.....
Vamp
@the-vampiire
May 03 2017 00:55
this is the dumbest thing ever. spent this time producing the algorithm and it gets hung up on a trailing 0 that is completely irrelevant
May 03 2017 00:55
``````function destroyer(arr) {
// Remove all the values
console.log([].slice.call(arr));
console.log(arr.length);
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);``````
Gabe Rotberg
@grotberg
May 03 2017 00:56
@the-vampiire Ah, the problem isn't the 0.5, the problem is that you're returning things with a 0 value
May 03 2017 00:56
@grotberg
Vamp
@the-vampiire
May 03 2017 00:56
this is the fucked up code from trying to fix 0.5 to 0.50
it was working before
Gabe Rotberg
@grotberg
May 03 2017 00:56
@the-vampiire `should return [["TWENTY", 60.00], ["TEN", 20.00], ["FIVE", 15.00], ["ONE", 1.00], ["QUARTER", 0.50], ["DIME", 0.20], ["PENNY", 0.04]]`
@the-vampiire the 0.50 isn't a problem. the test works with 0.5. the problem is you're returning it with [ 'ONE HUNDRED', 0 ], but items with 0 value shouldn't be part of the returned array
Vamp
@the-vampiire
May 03 2017 00:58
i know the snippeti just posted is wrong
i made changes to fix the 0.5
let me post the correct code so you can see
Gabe Rotberg
@grotberg
May 03 2017 00:58
@the-vampiire post the output that is failing, and lets take a look at that
@Adia-A ah, i see the problem. you actually need to call that expression on `arguments` even if your input variable is `arr` or whatever
May 03 2017 00:59
@grotberg
OOOOOOOOOOOOOOOHHHHHHHHHHHHHHH ugh I thought that was just a placeholder
Thanks!
Gabe Rotberg
@grotberg
May 03 2017 01:00
Vamp
@the-vampiire
May 03 2017 01:02
@grotberg
``````function checkCashRegister(price, cash, cid){
var change = cash - price, changed_used = [], total = 0;

for(var i in cid){
total += cid[i][1];
}

console.log(change);
console.log(total.toFixed(2));

if(total.toFixed(2) === change.toFixed(2)){
return 'Closed';
}

// coin and bill values array
var values = [0.01, 0.05, 0.10, 0.25, 1.00, 5.00, 10.00, 20.00, 100.00];

// push into cid array for easy access during forEach
// cid = [name[0], value[1], available amount[2]]
for(var i in cid){
cid[i] = [cid[i][0], values[i], cid[i][1]];
}

cid.reverse();

// iterate through each element and decrement both the change needed and available amount of each coin / bill
cid.forEach(function(element){

var available = element[2],
val = element[1];

// console.log('\n');
// console.log('called: ', element[0], 'val: ', val);
// console.log('changed remaining: ', change);
// console.log('change / val: ', change / val, '>1: ', change/val > 1);
// console.log('\n');

// checking change / val > 1
// determines whether it is possible to make change using that bill or coin
if((change / val) > 1){
while(change  - val>= 0){
if(available !==0){
console.log('available: ', available, 'change: ', change);
available -= val;
change -= val;
}
else{
break;
}
}
}

// if the change used is not 0, push it to the change_used array
var returned = element[2] - available;

if(element[2] - available !== 0){
// divide by 1 to make it an integer as toFixed returns a string
changed_used.push([element[0], (returned.toFixed(2))/1]);
}

return change;

});

// console.log('\n');
//
// console.log(changed_used);

if(changed_used.length > 0){
return changed_used;
}

return 'Insufficient Funds';
}``````
output:
``````[ [ 'TWENTY', 60 ],
[ 'TEN', 20 ],
[ 'FIVE', 15 ],
[ 'ONE', 1 ],
[ 'QUARTER', 0.5 ],
[ 'DIME', 0.2 ],
[ 'PENNY', 0.03 ] ]``````
passes every case except this one
``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]]) should return [["TWENTY", 60.00], ["TEN", 20.00], ["FIVE", 15.00], ["ONE", 1.00], ["QUARTER", 0.50], ["DIME", 0.20], ["PENNY", 0.04]]``
Gabe Rotberg
@grotberg
May 03 2017 01:04
@the-vampiire I believe you're one penny short
@the-vampiire which means you probably have an ugly rounding error in there somewhere
Vamp
@the-vampiire
May 03 2017 01:05
god damn it
and I’ve fucked with it so many times over this stupid 0.5 to 0.50 shit that I lost it
ugh
Gabe Rotberg
@grotberg
May 03 2017 01:06
@the-vampiire i'd add copious logging to your code to try and figure out where, but that's going to be a bit nasty :-/ sorry
Vamp
@the-vampiire
May 03 2017 01:06
so frustrated
Gabe Rotberg
@grotberg
May 03 2017 01:07
yeah, this is definitely a hard one. the 0.5/0.50 won't make it fail though, so at least you don't need to worry about that. You can do it!
Vamp
@the-vampiire
May 03 2017 01:07
it did fail gabe
i wouldnt be bothering with it if it didnt
this is the log I had saved earlier
``````called:  ONE HUNDRED val:  100
changed remaining:  81.84
change / val:  0.8184 >1:  false

called:  TWENTY val:  20
changed remaining:  81.84
change / val:  4.0920000000000005 >1:  true

available:  60 change:  81.84
available:  40 change:  61.84
available:  20 change:  41.84

called:  TEN val:  10
changed remaining:  21.840000000000003
change / val:  2.184 >1:  true

available:  30 change:  21.840000000000003
available:  20 change:  11.840000000000003

called:  FIVE val:  5
changed remaining:  1.8400000000000034
change / val:  0.36800000000000066 >1:  false

called:  ONE val:  1
changed remaining:  1.8400000000000034
change / val:  1.8400000000000034 >1:  true

available:  20 change:  1.8400000000000034

called:  QUARTER val:  0.25
changed remaining:  0.8400000000000034
change / val:  3.3600000000000136 >1:  true

available:  3 change:  0.8400000000000034
available:  2.75 change:  0.5900000000000034
available:  2.5 change:  0.3400000000000034

called:  DIME val:  0.1
changed remaining:  0.09000000000000341
change / val:  0.9000000000000341 >1:  false

called:  NICKEL val:  0.05
changed remaining:  0.09000000000000341
change / val:  1.8000000000000682 >1:  true

available:  0.45 change:  0.09000000000000341

called:  PENNY val:  0.01
changed remaining:  0.04000000000000341
change / val:  4.000000000000341 >1:  true

available:  0.52 change:  0.04000000000000341
available:  0.51 change:  0.030000000000003406
available:  0.5 change:  0.020000000000003404
available:  0.49 change:  0.010000000000003404

[ [ 'TWENTY', '60.00' ],
[ 'TEN', '20.00' ],
[ 'ONE', '1.00' ],
[ 'QUARTER', '0.75' ],
[ 'NICKEL', '0.05' ],
[ 'PENNY', '0.04' ] ]``````
when it was a stupid string because of toFixed
same console logs
Gabe Rotberg
@grotberg
May 03 2017 01:09
Yeah, those 000000000xxxx are where you need to deal with the rounding errors, but you probably figured that already
this is the line I used to deal with that exact problem: `changeleft = Math.round(changeleft*100)/100; // this is to fix some weird floating point problems`
Russell Goldman
@russellgoldman
May 03 2017 01:10
/help
oops
Anthony Henry
@Ahenry80
May 03 2017 01:10
``````function steamrollArray(arr) {
// I'm a steamroller, baby
var ans = [];
for(var i =0; i < arr.length; i++){
if(Array.isArray(arr[i]) === true){
for(var j = 0; j < arr[i].length; j++){
ans.push(arr[i][j]);
}

}
else{
ans.push(arr[i]);
}
}

return ans;
}

steamrollArray([1, [2], [3, [[4]]]]);``````
The 4 that is nested is the only part that I need to get out of the array can someone please help
Russell Goldman
@russellgoldman
May 03 2017 01:12

'''
function nextInLine(arr, item) {
arr.push(item);
item = arr.unshift();
return item; // Change this line
}

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

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

CamperBot
@camperbot
May 03 2017 01:12
Russell Goldman
@russellgoldman
May 03 2017 01:12
anyone know what im doing wrong here
Vamp
@the-vampiire
May 03 2017 01:12
@grotberg can it round differently on repeated calls?
wtf
I put the exact code I used earlier to gt that log
and I sitll get 0.03
and the console log values dont match
Russell Goldman
@russellgoldman
May 03 2017 01:12
Vamp
@the-vampiire
May 03 2017 01:13
``````called:  PENNY val:  0.01
changed remaining:  0.03999999999999487
change / val:  3.999999999999487 >1:  true

available:  1.01 change:  0.03999999999999487
available:  1 change:  0.02999999999999487
available:  0.99 change:  0.01999999999999487

// compared to earlier, functioning, call:

called:  PENNY val:  0.01
changed remaining:  0.04000000000000341
change / val:  4.000000000000341 >1:  true

available:  0.52 change:  0.04000000000000341
available:  0.51 change:  0.030000000000003406
available:  0.5 change:  0.020000000000003404
available:  0.49 change:  0.010000000000003404``````
Gabe Rotberg
@grotberg
May 03 2017 01:13
@Ahenry80 best advice i can offer is to think about using recursion. you're already writing a function to flatten an array, if you need to, you can call it again inside itself to flatten multiple 'layers'
Vamp
@the-vampiire
May 03 2017 01:13
its the exact same code..
Gabe Rotberg
@grotberg
May 03 2017 01:15
@the-vampiire yeah, javascript doesn't seem to deal with floating points well. if I remember right, the problems seemed to crop up when multiplying floats, so if you deal with them right away (rounding or however), it might help.
Vamp
@the-vampiire
May 03 2017 01:15
im just subtracting
nothing is multiplied
those logs are before any fuckery has taken place to get them down to 2 decimals. raw values
ugh nevermind
those calls were not being passed the same cid
one is for 3.26, 100 the other is for 18.16, 100
either way there is a rounding error thats throwing this off
Jeff
@etisdew
May 03 2017 01:26
do you need to use a math lib to fix floats in your language? @the-vampiire
Vamp
@the-vampiire
May 03 2017 01:27
i dont even know anymore man
im so goddamn frustrated
I know this code was working earlier
I should have saved it somewhere isntead of fucking with it. now god knows how ill ever get back to it
spent the entire day working on this. finally got it working and then broke it like an idiot.
Jeff
@etisdew
May 03 2017 01:28
Been there done that
can you ctrl z back to the working version?
I still don't make copies, but I'm learning to duplicate everything
worst case ctrl y it all back
Vamp
@the-vampiire
May 03 2017 01:29
it wont go back that far
I literally spent over 2 hours fuckin with this stupid code
because of it
Michael Grienauer
@mgrienauer
May 03 2017 01:34
@grotberg i read the w3 link you posted but still a little lost. I want to have a different sound play each time a buttons is clicked on my tic tac toe game. Should I add all the audio elements to my html and then use getElementById to access them on click?
Gabe Rotberg
@grotberg
May 03 2017 01:36
@mike93og93 hm, in a case like that you probably don't want to use the audio tag anyway. Might check out this question on stack overflow to see if that helps? http://stackoverflow.com/questions/32913026/click-a-button-to-play-sound-on-javascript Sorry I can't offer more specific advice.
Christopher McCormack
@cmccormack
May 03 2017 01:39
@mike93og93 that's pretty much it
Mostafa Hesham
@mhesham32
May 03 2017 01:39

hey can you help me pls

``````\$.ajax({
type:"GET",
url:'https://www.mostafahesham.ml/quotes.json',
success: function(data){
console.log(data.author);
}
});``````

nothing is logged into the console why?

Christopher McCormack
@cmccormack
May 03 2017 01:39
@mhesham32 possible your call is failing
Gabe Rotberg
@grotberg
May 03 2017 01:39
@mhesham32 probably because the call is failing
Christopher McCormack
@cmccormack
May 03 2017 01:40
check the browser console
Michael Grienauer
@mgrienauer
May 03 2017 01:40
@grotberg @cmccormack alright thanks homies
CamperBot
@camperbot
May 03 2017 01:40
mike93og93 sends brownie points to @grotberg and @cmccormack :sparkles: :thumbsup: :sparkles:
:warning: mike93og93 already gave grotberg points
Csaba Balogh
@JasonCorp84
May 03 2017 01:42
Hello everyone
how many ways do you know to solve the factorialize assignment ?
Mostafa Hesham
@mhesham32
May 03 2017 01:43
@cmccormack @grotberg the link is not secure why?
Vamp
@the-vampiire
May 03 2017 01:43
fuck
bout to pour up a real tall glass of whiskey
Csaba Balogh
@JasonCorp84
May 03 2017 01:44
@the-vampiire nice. But do not destroy all that you built :D
Christopher McCormack
@cmccormack
May 03 2017 01:44
@mhesham32 you doing it from codepen?
@GoonTwo
May 03 2017 01:45
anyone have any idea when the beta is gonna go live?
Jeff
@etisdew
May 03 2017 01:45
@the-vampiire WOOT!
Michael Grienauer
@mgrienauer
May 03 2017 01:45
@the-vampiire congratz
Vamp
@the-vampiire
May 03 2017 01:46
goodd damn it
``````function checkCashRegister(price, cash, cid){

// to solve the floating point issue all values are multiplied by 100 and then
// divided by 100 before being pushed to the 'change_used' array for function return

var change = (cash - price), changed_used = [], total = 0;

for(var i in cid){
total += cid[i][1];
}

if(total.toFixed(2) === change.toFixed(2)){
return 'Closed';
}

// coin and bill values array
var values = [0.01, 0.05, 0.10, 0.25, 1.00, 5.00, 10.00, 20.00, 100.00];

// push into cid array for easy access during forEach
// cid = [name[0], value[1], available amount[2]]
for(var i in cid){
cid[i] = [cid[i][0], values[i], cid[i][1]];
}

cid.reverse();
change = (cash - price)*100;

// iterate through each element and decrement both the change needed and available amount of each coin / bill
cid.forEach(function(element){

var available = element[2]*100,
val = element[1]*100;

console.log('\n');
console.log('called: ', element[0], 'val: ', val);
console.log('changed remaining: ', change);
console.log('change / val: ', change / val, '>1: ', change/val > 1);
console.log('\n');

// checking change / val > 1
// determines whether it is possible to make change using that bill or coin
if((change / val) > 1){
while(change  - val >= 0){
if(available !==0){
console.log('available: ', available, 'change: ', change);
available -= val;
change -= val;
}
else{
break;
}
}
}

// if the change used is not 0, push it to the change_used array
var returned = element[2]*100 - available;

if(returned / 100 !== 0){
changed_used.push([element[0], returned/100 ]);
}

return change;

});

if(changed_used.length > 0 && change === 0){
return changed_used;
}

return 'Insufficient Funds';
}``````
Jeff
@etisdew
May 03 2017 01:46
what beta is happening?
Mostafa Hesham
@mhesham32
May 03 2017 01:47
@cmccormack no it is offline
FlashHero
@FlashHero
May 03 2017 01:48
``````
function convertToRoman(num) {
var roman={
I:1,
II:2,
III:3,
V:5,
X:10,
L:50,
C:100,
D:500,
M:1000

};
for(var prop in roman){
if(roman[prop]==num){
return prop;
}
}
}

convertToRoman(11);``````
I need help on this exercise
Chris Jokinen
@ChrisJokinen
May 03 2017 01:56
can someone explain the rules of the "Smallest Common Multiple" problem. They give an example of 1 and 5 which should be 5 as the SCM but the question expect a result of 60....I must be missing something, so any help?
Christopher McCormack
@cmccormack
May 03 2017 01:57
@FlashHero need to think about it programmatically - practice some larger numbers manually and see how the string gets built. one hint is that your special cases will be 4, 9, 40, 90, etc...
May 03 2017 01:57
khanvuthy88
@khanvuthy88
May 03 2017 01:58

``````// Example
function ourRandomRange(ourMin, ourMax) {

return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
}

ourRandomRange(1, 9);

// Only change code below this line.

function randomRange(myMin, myMax) {

return Math.random(); // Change this line

}

// Change these values to test your function
var myRandom = randomRange(5, 15);``````

because I'm not clear with random method.

Johnny
@jtan3
May 03 2017 01:58
@ChrisJokinen they want you to find the SCM of the range of 1,5.
May 03 2017 01:58
i need help to Crystallization problem
Christopher McCormack
@cmccormack
May 03 2017 01:58
Stephen James
@sjames1958gm
May 03 2017 01:59
@khanvuthy88 Math.random() returns a number between 0 inclusive and and 1 not inclusive
@WSCQSDADADAD myStr[0] = "H"; is an error that causes failure of the test. - remove this line
@khanvuthy88 Basically copy the line above with different variables
khanvuthy88
@khanvuthy88
May 03 2017 02:02
@sjames1958gm , thanks for your advice, but i don't know how to use if condition within random() method.
CamperBot
@camperbot
May 03 2017 02:02
khanvuthy88 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7092 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Chris Jokinen
@ChrisJokinen
May 03 2017 02:02
@jtan3 thank
CamperBot
@camperbot
May 03 2017 02:02
chrisjokinen sends brownie points to @jtan3 :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
May 03 2017 02:03
@khanvuthy88 This is a math problem no if is needed.
`return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;`
just do this but exchange myMin and myMax
khanvuthy88
@khanvuthy88
May 03 2017 02:07
@sjames1958gm , yes actually it's work, but I am still not understand what this statement mean.
``return Math.floor(Math.random() * (ourMax - ourMin +1 )) + ourMin``
Stephen James
@sjames1958gm
May 03 2017 02:09
@khanvuthy88 So Math.random() returns [0, 1) - which means 0 to almost 1.
Then you multiply by the range + 1 so [0, range +1).
then Math.floor makes it [0, range] then + ourMin is [ourMin, ourMax]
Long Nguyen
@longnt80
May 03 2017 02:09
hey guys, I'm working on the Build a wikipedia viewer challenge. Right now, I'm trying to get the JSON from Wiki using `.ajax` method. However, I can't make the codepen console to print out the JSON. Here's the codepen:
https://codepen.io/longnt80/pen/zwZMYa
Aizaz Shahid
@aizazshahid
May 03 2017 02:10
``````window.addEventListener("event", foo);          // works fine

window.addEventListener("event", foo() );          // not works``````
wondering, why the second one not works ?
Stephen James
@sjames1958gm
May 03 2017 02:11
@longnt80 because you have a form - when you submit it tries to submit the form to the back end - do this:
``````\$('button').on('click', function(e){
e.preventDefault();``````
@forwebtech because the function expects a function reference which foo is - but foo() is calling the function -
Aizaz Shahid
@aizazshahid
May 03 2017 02:12
@sjames1958gm what ?? :D
Long Nguyen
@longnt80
May 03 2017 02:12
@sjames1958gm so is the `form` neccessary?
Stephen James
@sjames1958gm
May 03 2017 02:12
@longnt80 No it is not.
Long Nguyen
@longnt80
May 03 2017 02:13
@sjames1958gm ok let me try that, thank you!
CamperBot
@camperbot
May 03 2017 02:13
longnt80 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7093 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 03 2017 02:13
@forwebtech foo() calls the function so the return from this function is what is passed to addEventListener - but it expects a function refernce
Aizaz Shahid
@aizazshahid
May 03 2017 02:14
@sjames1958gm by default functions return some value ??
Stephen James
@sjames1958gm
May 03 2017 02:14

@forwebtech

``````window.addEventListener("event", function (e) {
// do stuff;
});``````

this is also a function reference

@forwebtech Unless foo() returns a function reference it won't work.
Aizaz Shahid
@aizazshahid
May 03 2017 02:14
@sjames1958gm so it is `listener` ??
Stephen James
@sjames1958gm
May 03 2017 02:15
@forwebtech huh?
Aizaz Shahid
@aizazshahid
May 03 2017 02:15

@sjames1958gm

Stephen James
@sjames1958gm
May 03 2017 02:15
@forwebtech listener means a function reference
Aizaz Shahid
@aizazshahid
May 03 2017 02:16
what is a function reference ?
``````var a = 7;
var b = a;

// here we can say b is reference to a but how functions can be a reference !``````
Stephen James
@sjames1958gm
May 03 2017 02:17
@forwebtech var a = function() {}
here a is a reference to a function
function a() {}
here a is a reference to a function
@forwebtech b is not a reference to a
Aizaz Shahid
@aizazshahid
May 03 2017 02:18
something goes into my brain :stuck_out_tongue:
sorry !
a is reference to b ??
khanvuthy88
@khanvuthy88
May 03 2017 02:19
@sjames1958gm, thanks for explanation
Stephen James
@sjames1958gm
May 03 2017 02:19
@forwebtech Neither - because 7 is a value - a and b contain the value 7
var arr = [1, 2, 3]
var arrb = arr;
arr is a reference to [1, 2, 3]
and arrb is the same reference
A function is an object in js and so
var foo = function () {}
foo is a function reference
Aizaz Shahid
@aizazshahid
May 03 2017 02:21
@sjames1958gm oh got it reference are used for object like things ?
Stephen James
@sjames1958gm
May 03 2017 02:21
yes
Aizaz Shahid
@aizazshahid
May 03 2017 02:22
and if we use `()` that means return something or execution of that function !
Dbakk
@Dbakk
May 03 2017 02:22
need some help on Assignment with a Returned Value
Stephen James
@sjames1958gm
May 03 2017 02:22
Yes, foo() means whatever the function returns - which could be a function.
``````var foo = function() {
return function(e) {
//handle event
}
}``````
Aizaz Shahid
@aizazshahid
May 03 2017 02:23
and that's why `window.addEventListener( event , foo() )` don't accept it :clap: thanks @sjames1958gm
CamperBot
@camperbot
May 03 2017 02:23
forwebtech sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7094 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
May 03 2017 02:23
:) -
@forwebtech I am reading this - it is a challenging read - but it has good info
Aizaz Shahid
@aizazshahid
May 03 2017 02:25
something like walk through !
J Tang
@jf4nathan
May 03 2017 02:25
@cusbus nope I gave up last night and now I'm going to take another stab at it
Aizaz Shahid
@aizazshahid
May 03 2017 02:26
@sjames1958gm did you want to shut my mouth :D
Dbakk
@Dbakk
May 03 2017 02:27
@sjames1958gm
// Only change code below this line
function processArg(processed) {
return (processed - 7);
}
var processArg = 2;
var processed = processArg;
i think I am way off lol
Aizaz Shahid
@aizazshahid
May 03 2017 02:27
@Dbakk you need to pass the parameter !
Stephen James
@sjames1958gm
May 03 2017 02:28
Don't redefine the function. Just call the function.
the pattern you need to follow is changed = change(10)
Dbakk
@Dbakk
May 03 2017 02:29
i tried that before but kept getting a yellow caution
Ill try again and send over
Stephen James
@sjames1958gm
May 03 2017 02:29
@Dbakk Remember that to call a function you need () and to pass a value put it in the ()
Chuck Hoffman
@rhoffman219
May 03 2017 02:31
Really need help
I have been stuck on this for a while now!
It wants me to assign a function "oopsGlobal" without using the "var" keyword
Aizaz Shahid
@aizazshahid
May 03 2017 02:32
@rhoffman219 yes ?
Chuck Hoffman
@rhoffman219
May 03 2017 02:32
i can't get it to work
heres my code'

var myGlobal = 10;

function fun1 () {
// Assign 5 to oopsGlobal Here
console.log(5);
}

// Only change code above this l

Aizaz Shahid
@aizazshahid
May 03 2017 02:33
@rhoffman219 so just initialize myGlobal = 5 into your function !
Chuck Hoffman
@rhoffman219
May 03 2017 02:33
how do i do that?
Aizaz Shahid
@aizazshahid
May 03 2017 02:33
`myGlobal = 5`
Stephen James
@sjames1958gm
May 03 2017 02:33
@rhoffman219 the variable is oopsGlobal.
Chuck Hoffman
@rhoffman219
May 03 2017 02:34
here are the instructions:
Aizaz Shahid
@aizazshahid
May 03 2017 02:34
:D but it's not declared ?
Chuck Hoffman
@rhoffman219
May 03 2017 02:34

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.

Aizaz Shahid
@aizazshahid
May 03 2017 02:34
@rhoffman219 `oopsGlobal = 5` don't know why this will works but try it !
Stephen James
@sjames1958gm
May 03 2017 02:35
@rhoffman219 Inside the function - don't use `var` which makes the variable accidentally global
which is why it is called oopsGlobal.
Nguyen Hoang
@honnhien12h
May 03 2017 02:35

Help me challenge Stand in Line in JVscript, i don't his understand :
function nextInLine(arr, item) {

return item; // Change this line
}

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

Aizaz Shahid
@aizazshahid
May 03 2017 02:35
@honnhien12h use `.push()` and `.shift()`
Chuck Hoffman
@rhoffman219
May 03 2017 02:35
@forwebtech that worked but i have no idea why
Stephen James
@sjames1958gm
May 03 2017 02:35
@rhoffman219 It is trying to show you that if you forget the `var` inside a function then
the variable will become global
Aizaz Shahid
@aizazshahid
May 03 2017 02:36
@rhoffman219 yes, he is right :point_up: May 3, 2017 7:35 AM
Stephen James
@sjames1958gm
May 03 2017 02:36
@honnhien12h `nextInLine(arr, item) {` this is your function definition where arr is the array and item is the value.
to simulate a queue you need to add item to the end of arr and then remove and return the first value of arr
Nguyen Hoang
@honnhien12h
May 03 2017 02:36
@forwebtech I tried it
J Tang
@jf4nathan
May 03 2017 02:37
I posted this last night to get some feedback so I know what I'm missing, I just don't know how to implement it. My loop is returning too early right? So it's not actually checking after the first set of arrays. Can anyone guide me in the right direction?
``````
function lookUpProfile(firstName, prop){
// Only change code below this line

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

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

else return "No such property";
}
else return "No such contact";
}

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "number");``````
Stephen James
@sjames1958gm
May 03 2017 02:37
Csaba Balogh
@JasonCorp84
May 03 2017 02:38
@jf4nathan I have been there for a while..
Aizaz Shahid
@aizazshahid
May 03 2017 02:38
@jf4nathan first `no such contact` should be out of loop!
Stephen James
@sjames1958gm
May 03 2017 02:38
@jf4nathan So .prop will not use the variable prop this was shown in a previous challenge with playerNumber and checkProp
you have to use []
If you don't match the first name with the first contact you quit with no such contact.
Patrick Koidal
@Koitis
May 03 2017 02:38
hey, i have a question regarding updating var and object names
Aizaz Shahid
@aizazshahid
May 03 2017 02:38
@Koitis yes ?
Stephen James
@sjames1958gm
May 03 2017 02:38
@Koitis :wave: hello from McKinney
Patrick Koidal
@Koitis
May 03 2017 02:39
is the reason we do this simply for version control? wouldn't it be simpler to update the original code with the new name?
diegoxro
@diegoxro
May 03 2017 02:39
???
Aizaz Shahid
@aizazshahid
May 03 2017 02:39
@Koitis copy and pasting hahaha :) not a good approach !
Patrick Koidal
@Koitis
May 03 2017 02:39
ex. `myName.name = "Patrick";`
wouldn't it be simpler to just edit the original var?
J Tang
@jf4nathan
May 03 2017 02:40
@sjames1958gm sweet. I fixed that first part
Aizaz Shahid
@aizazshahid
May 03 2017 02:40
@Koitis actually it's a property of object `myName`
Patrick Koidal
@Koitis
May 03 2017 02:40
but it changes the name, no?
Stephen James
@sjames1958gm
May 03 2017 02:40
@Koitis there is a difference between editing and running code.
Patrick Koidal
@Koitis
May 03 2017 02:40
sorry if this is a silly question
Aizaz Shahid
@aizazshahid
May 03 2017 02:40
@Koitis you can directly change it ? but your question didn't get ?
J Tang
@jf4nathan
May 03 2017 02:40
So a return statement stops a 'for' loop, correct?
Stephen James
@sjames1958gm
May 03 2017 02:41
@jf4nathan YEs
@jf4nathan Stops the entire function.
Patrick Koidal
@Koitis
May 03 2017 02:41
@sjames1958gm i guess this is where i run into confusion, because i haven't used it practically yet
Aizaz Shahid
@aizazshahid
May 03 2017 02:41
@Koitis you should make some test !
did you have any code ?
Patrick Koidal
@Koitis
May 03 2017 02:42
but if i needed to change the value of `myName`, why would i use dot notation to change it with another line of code?
Jason Lafrance
@SgtRaziel
May 03 2017 02:42
need someone to tell me what i'm missing in my `\$.getJSON()` request
``````\$(".quote-button").on('click', function(){
\$.getJSON (
"https://crossorigin.me/http://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en",
function(data) {console.log(data);}
)
})``````
diegoxro
@diegoxro
May 03 2017 02:42
@Koitis version control is another topic
Patrick Koidal
@Koitis
May 03 2017 02:42
not exactly, i just finished a challenge and kinda scratched my head on why we would use it
Aizaz Shahid
@aizazshahid
May 03 2017 02:42
@Koitis are you talking about the `myName` ??
Stephen James
@sjames1958gm
May 03 2017 02:42
@Koitis An object like myName is only a container, with properties.
it might be the case where you want to set the name on the object.
It might be in a function which sets the value.
Dbakk
@Dbakk
May 03 2017 02:42
stillstuck.....
why is this so frustrating to figure out
Stephen James
@sjames1958gm
May 03 2017 02:43
@Dbakk Did you move the return no such contact outside the for loop?
Aizaz Shahid
@aizazshahid
May 03 2017 02:43
@Koitis because `myName` is your object which has a property named `name`
Csaba Balogh
@JasonCorp84
May 03 2017 02:43
@jf4nathan first you need to use a bracket notation.
Chuck Hoffman
@rhoffman219
May 03 2017 02:43
i HATE JavaScript! i just don't understand it. Im stuck again. Tried researching it and i just don't understand what its asking me to do. I have tried numerous things and i can't figure it out
Instructions:
J Tang
@jf4nathan
May 03 2017 02:43
@JasonCorp84 yup i got that part down
Chuck Hoffman
@rhoffman219
May 03 2017 02:43
Declare a local variable myVar inside myLocalScope. Run the tests and then follow the instructions commented out in the editor.
Aizaz Shahid
@aizazshahid
May 03 2017 02:43
@Koitis which is associated with `myName`
Chuck Hoffman
@rhoffman219
May 03 2017 02:43
CODE:
Csaba Balogh
@JasonCorp84
May 03 2017 02:43
ok, then the next thing: is it in the right order ?
Dbakk
@Dbakk
May 03 2017 02:44

function processArg(processed) {
return (processed - 7);
}

processArg = processed(2);

Csaba Balogh
@JasonCorp84
May 03 2017 02:44
I mean those that you want to return
diegoxro
@diegoxro
May 03 2017 02:44
use ``` @rhoffman219
Stephen James
@sjames1958gm
May 03 2017 02:44
@rhoffman219 So declaring a variable is using var and the variable name
for example:
var myVar = 0;
Chuck Hoffman
@rhoffman219
May 03 2017 02:44

function myLocalScope() {
'use strict';

console.log(myVar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);

// Now remove the console log line to pass the

Aizaz Shahid
@aizazshahid
May 03 2017 02:44
@Koitis like:
``````var  myName = { name: "some Name" };

myName.name = "some other Name";``````
Patrick Koidal
@Koitis
May 03 2017 02:44
so the example in the challenge is this:
```var myDog = { "name": "Coder" } and then it has you add the following:```myDog.name = "Happy Coder"`
Chuck Hoffman
@rhoffman219
May 03 2017 02:44
right i know that but how do i know where to put the "var" and what to declare it as?
Patrick Koidal
@Koitis
May 03 2017 02:44
woops lol
but why wouldn't we just change the original var to a different name?
Stephen James
@sjames1958gm
May 03 2017 02:45
@Dbakk All you needed was the one line
`processed = processArg(7);`
this calls the function processArg with the value of 7 and assigns the result to processed
Chuck Hoffman
@rhoffman219
May 03 2017 02:45
what does it equal? the instructions don't give any information. Maybe im overthinking it? i just can't figure it out
Aizaz Shahid
@aizazshahid
May 03 2017 02:45
@Koitis you are changing the value of the property !
Stephen James
@sjames1958gm
May 03 2017 02:45
@rhoffman219 The value is not relevant.
you put it inside the function.
Patrick Koidal
@Koitis
May 03 2017 02:45
i guess i don't understand the difference between that and changing the original code lol
Aizaz Shahid
@aizazshahid
May 03 2017 02:45
@Koitis actually `myDog.name` is showing that the variable `name` is inside the `myDog` object
Stephen James
@sjames1958gm
May 03 2017 02:45
@rhoffman219 You are overthinking the value part
Jason Lafrance
@SgtRaziel
May 03 2017 02:45
@rhoffman219 what challenge is this for?
Dbakk
@Dbakk
May 03 2017 02:46
so i was doing it backwards... lol
Chuck Hoffman
@rhoffman219
May 03 2017 02:46
thats whats confusing me? "putting it IN the funtion" is really confusing me
Dbakk
@Dbakk
May 03 2017 02:46
fml
Patrick Koidal
@Koitis
May 03 2017 02:46
we assign a value to `"name"` in the orignal var statement
right?
Aizaz Shahid
@aizazshahid
May 03 2017 02:46
@Koitis oh, are you talking that why we can't just change the property value directly !
??
Stephen James
@sjames1958gm
May 03 2017 02:46
@rhoffman219
``````function myFunction() {
'use strict';

var myVar;

console.log(myVar);
}``````
Aizaz Shahid
@aizazshahid
May 03 2017 02:46
@Koitis well suppose if you have 500 lines of code ! , then what will you do ?
Stephen James
@sjames1958gm
May 03 2017 02:47
@rhoffman219 Between the { and } after the function declaration is inside the function.
Chuck Hoffman
@rhoffman219
May 03 2017 02:47
@sjames1958gm that didn't work
Patrick Koidal
@Koitis
May 03 2017 02:47
so it's just a QoL thing?
Nguyen Hoang
@honnhien12h
May 03 2017 02:47
@sjames1958gm i trad it and will show again
Stephen James
@sjames1958gm
May 03 2017 02:47
@rhoffman219 well did you do all the instructions?
Patrick Koidal
@Koitis
May 03 2017 02:47
i think i am overthinking it lol
Jason Lafrance
@SgtRaziel
May 03 2017 02:47
@rhoffman219 what is the name of the challenge your stuck on?
Stephen James
@sjames1958gm
May 03 2017 02:47
@rhoffman219 `// now remove the console log line to pass the test`
Chuck Hoffman
@rhoffman219
May 03 2017 02:47
name of the challenge is "local Scope and Functions"
Jason G
May 03 2017 02:47
i need help with some logic. i can't figure out how to do a lesson. here's what i have so far
Chuck Hoffman
@rhoffman219
May 03 2017 02:48
the instructions are incredibly vague
Jason G
May 03 2017 02:48
Stephen James
@sjames1958gm
May 03 2017 02:48
@rhoffman219 If you have removed the second console.log() and it still fails refresh the page.
Aizaz Shahid
@aizazshahid
May 03 2017 02:48
@Koitis it's a way to change the value from object, but when you have lots of code then you need these practices to change the values !
Jason Lafrance
@SgtRaziel
May 03 2017 02:48
@rhoffman219 let me look
Patrick Koidal
@Koitis
May 03 2017 02:48
ok, makes sense
thanks @forwebtech
CamperBot
@camperbot
May 03 2017 02:48
koitis sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
Chuck Hoffman
@rhoffman219
May 03 2017 02:48
removing it work
Aizaz Shahid
@aizazshahid
May 03 2017 02:48
@Koitis suppose you are extracting an object from other source , so in actual you don't see it, then how you will change the value ???
J Tang
@jf4nathan
May 03 2017 02:49
Still can't figure out how to get it to loop back again
do I have to nest another for loop?
Patrick Koidal
@Koitis
May 03 2017 02:49
gotcha, i was thinking a much smaller scope but i see the value now :)
Aizaz Shahid
@aizazshahid
May 03 2017 02:49
like that: `var obj = obj.fromother..source;`
Stephen James
@sjames1958gm
May 03 2017 02:49
@jf4nathan What does your code look like now
Chuck Hoffman
@rhoffman219
May 03 2017 02:49
i just don't understand why though. Im worried if i just keep moving through these like this I won't even be able to use JavaScript. I don't understand this at all! lol I got the HTML and CSS pretty well but this is killing me. Does anyone use any other resources to help them understand this?
Aizaz Shahid
@aizazshahid
May 03 2017 02:49
@Koitis and you just know the structure of that, then you can easily edit its values as, `obj.propName = value`
Jason Lafrance
@SgtRaziel
May 03 2017 02:50
@rhoffman219 the challenge is demonstrating scope
Patrick Koidal
@Koitis
May 03 2017 02:50
thank goodness for dot notation! XD
Aizaz Shahid
@aizazshahid
May 03 2017 02:50
@Koitis believe me, your question is very good :+1:
if all new comers raise these types of question, they will learn also concepts !
Patrick Koidal
@Koitis
May 03 2017 02:51
that is my goal!
feeling a little overwhelmed with javascript so glad you folks are around to teach dummies like me
Stephen James
@sjames1958gm
May 03 2017 02:51
@rhoffman219 Some of these challenges are showing some esoteric concepts.
these scope challenges are trying to show where a variable is defined depending on how you declare it
whether with var or not, inside a function or not
J Tang
@jf4nathan
May 03 2017 02:52
@sjames1958gm
``````function lookUpProfile(firstName, prop){
// Only change code below this line

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

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

else return "No such property";
}
else return "No such contact";
}

// Only change code above this line
}``````
Jason Lafrance
@SgtRaziel
May 03 2017 02:52

@rhoffman219 ```
function example(argeument){
var functionScopedVariable = "something"

console.log(functionScopedVariable)
}
example();
```

Stephen James
@sjames1958gm
May 03 2017 02:52
@rhoffman219 Learn code academy on you tube has good videos
Aizaz Shahid
@aizazshahid
May 03 2017 02:52
@Koitis and one more tip, if you are accessing object property from an argument like:
``````function foo ( val ) {
myObj.val;   // will not work

myObj[val];   // will work !
}``````
J Tang
@jf4nathan
May 03 2017 02:52
I fixed the dot notation to use index instead
Stephen James
@sjames1958gm
May 03 2017 02:53
@jf4nathan YOu cannot return no such contact inside the loop or it wont go past first contact.
J Tang
@jf4nathan
May 03 2017 02:53
right i know that, but what should go in its place?
Aizaz Shahid
@aizazshahid
May 03 2017 02:53
there are two types of notations to access the object property one is `.` dot and the other one is `[ ]` bracket !
Jason Lafrance
@SgtRaziel
May 03 2017 02:53

oops

``````function example(argeument){
var functionScopedVariable = "something"
console.log(functionScopedVariable)
}
example();``````

@rhoffman219

J Tang
@jf4nathan
May 03 2017 02:53
do i need to put anything there to make it go to the next iteration?
Patrick Koidal
@Koitis
May 03 2017 02:53
so if i understand correctly, dot notation is for properties and values, where bracket notation is used for variables?
Stephen James
@sjames1958gm
May 03 2017 02:53
@jf4nathan If inside the loop - you match first name you return property value or no such property
you can know that if the loop ends (without return) that the contact is not found.
Aizaz Shahid
@aizazshahid
May 03 2017 02:54
@Koitis no both used to get values !
Jason Lafrance
@SgtRaziel
May 03 2017 02:54
@rhoffman219 the `functionScoperVariable` is only accesable inside the {} of the function example
Stephen James
@sjames1958gm
May 03 2017 02:54
@Koitis bracket notation is also for property names where there are spaces or they start with numbers.
myObj["glove box"]
Patrick Koidal
@Koitis
May 03 2017 02:54
so why can you only use bracket for `val` in that example?
J Tang
@jf4nathan
May 03 2017 02:55
@sjames1958gm could you rephrase that?
Aizaz Shahid
@aizazshahid
May 03 2017 02:55
:+1: :point_up: May 3, 2017 7:54 AM
@Koitis
Jason Lafrance
@SgtRaziel
May 03 2017 02:56
@rhoffman219 you get a result due to the fact that the `console.log();` is displaying the value held by the variable.
Aizaz Shahid
@aizazshahid
May 03 2017 02:56
@Koitis and i used bracket for val because that is a argument which is string, it will make something like this, if used,:
`myObj."val.."` so that's why we use bracket notation
`myObj["propName"]` can work with strings !
Stephen James
@sjames1958gm
May 03 2017 02:57
@jf4nathan move return "No such contact" after the loop
Patrick Koidal
@Koitis
May 03 2017 02:57
@forwebtech ah, so bracket is a string rather than a value
if i understand correctly lol
J Tang
@jf4nathan
May 03 2017 02:57
I've got that down
``````function lookUpProfile(firstName, prop){
// Only change code below this line

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

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

else return "No such property";
}

}
return "No such contact";

// Only change code above this line
}``````
Aizaz Shahid
@aizazshahid
May 03 2017 02:58
@Koitis no you can pass strings to the bracket notation but it used to get the object property value also !
Jason G
May 03 2017 02:58

here's the challenge https://www.freecodecamp.com/challenges/sorted-union

``````//my code so far...
function uniteUnique(arr) {
var array = Array.from(arguments);
var bigArray = array.reduce(function(a,c){
return a.concat(c);
});

console.log(bigArray);
}``````

uniteUnique([1, 3, 2], [1, [5]], [2, [4]]) should return [1, 3, 2, [5], [4]]. <--example
any help would be great. i have no idea how they are solving this one

Aizaz Shahid
@aizazshahid
May 03 2017 02:59
``````var myObj = {
val1:   123,
val2:   "text"
}

myObj.val1;          //returns   123
myObj["val1"]     // also returns 123``````
@Koitis
but:
``myObj."val1" ;     // will not run``
Jason Lafrance
@SgtRaziel
May 03 2017 02:59
@rhoffman219 if you delete the line ``console.log("sonething);``` you remove the logging of the variable. Since you can only access the variable from within the function, the callback of the function is a null.
@rhoffman219 make sense?
Mostafa Hesham
@mhesham32
May 03 2017 03:01
why my json data didn't console into the log
https://codepen.io/mhesham32/project/editor/ZEBeQX/#0
J Tang
@jf4nathan
May 03 2017 03:01
@sjames1958gm how come my code is not returning the right prop?
or it can't find it
even for the first contact first prop
CamperBot
@camperbot
May 03 2017 03:02
Jason Lafrance
@SgtRaziel
May 03 2017 03:02
@mhesham32 preach brother
colegottdank
@colegottdank
May 03 2017 03:02
``/^[^a-zA-z]+\$/i``
This should check for all non-alphabetical characters. right?
Aizaz Shahid
@aizazshahid
May 03 2017 03:03
@colegottdank try here, http://regexr.com/
@colegottdank `\$` => that is used to ensure that the string or character is at the end !
Mostafa Hesham
@mhesham32
May 03 2017 03:04
@SgtRaziel sorry i don't understand you
colegottdank
@colegottdank
May 03 2017 03:04
what @forwebtech
Jason Lafrance
@SgtRaziel
May 03 2017 03:04
@mhesham32 having same issue
Aizaz Shahid
@aizazshahid
May 03 2017 03:05
@colegottdank just use
``/\W+/gi``
to check for all non-alphabetical characters.
Mostafa Hesham
@mhesham32
May 03 2017 03:05
@SgtRaziel ohh :smile:
Coy Sanders
@coymeetsworld
May 03 2017 03:05
@colegottdank its not just alphabetical, its alphanumeric, need to include numbers
\W wont work btw
so don't use that
colegottdank
@colegottdank
May 03 2017 03:06
@coymeetsworld ah, but is the syntax correct otherwize?
otherwise*
Coy Sanders
@coymeetsworld
May 03 2017 03:06
no it needs some work
you have 2 nots, im not sure why
Aizaz Shahid
@aizazshahid
May 03 2017 03:07
@colegottdank no !
Jason Lafrance
@SgtRaziel
May 03 2017 03:07
@mhesham32 \$.ajax \$.getJSON nothing works
Coy Sanders
@coymeetsworld
May 03 2017 03:07
dont necessarily need the + either
Aizaz Shahid
@aizazshahid
May 03 2017 03:07
if you put ^ [ .. ] that means you want to search from the start and if you used [ ... ] \$ with that sign, so it search at the end !
@colegottdank
colegottdank
@colegottdank
May 03 2017 03:08
@coymeetsworld The first ^ is a not? isnt it for settings the first?
Mostafa Hesham
@mhesham32
May 03 2017 03:08
@SgtRaziel i cant find working API and can't use my json file
Coy Sanders
@coymeetsworld
May 03 2017 03:08
oh the first is an anchor
you don't need that if you're using the global flag
colegottdank
@colegottdank
May 03 2017 03:08
ok cool
Aizaz Shahid
@aizazshahid
May 03 2017 03:08
@colegottdank if you put that `^` into bracket `[ ^ ]`, then it beomes not !
colegottdank
@colegottdank
May 03 2017 03:09
and then no \$ if I am using g?
Coy Sanders
@coymeetsworld
May 03 2017 03:09
right
colegottdank
@colegottdank
May 03 2017 03:09
/[^a-zA-z0-9]+/gi
Coy Sanders
@coymeetsworld
May 03 2017 03:09
your regex can check character by character, thats why you don't need the plus either
colegottdank
@colegottdank
May 03 2017 03:09
Still wrong?
Coy Sanders
@coymeetsworld
May 03 2017 03:09
A-z
you can either fix or remove that
Aizaz Shahid
@aizazshahid
May 03 2017 03:09
@colegottdank `\$` => Matches the end of the string
Coy Sanders
@coymeetsworld
May 03 2017 03:09
since you're specifying the i flag
case will be ignored
colegottdank
@colegottdank
May 03 2017 03:10
ok cool
Jason Lafrance
@SgtRaziel
May 03 2017 03:10
@mhesham32 found a simple API but can't get codepen to run the request
Aizaz Shahid
@aizazshahid
May 03 2017 03:10
@colegottdank `g` => global , `i` => ignore case !
colegottdank
@colegottdank
May 03 2017 03:10
@coymeetsworld why isn't the + needed?
Jason G
May 03 2017 03:10

here's the challenge https://www.freecodecamp.com/challenges/sorted-union

``````//my code so far...
function uniteUnique(arr) {
var array = Array.from(arguments);
var bigArray = array.reduce(function(a,c){
return a.concat(c);
});

console.log(bigArray);
}``````

uniteUnique([1, 3, 2], [1, [5]], [2, [4]]) should return [1, 3, 2, [5], [4]]. <--example
any help would be great. i have no idea how they are solving this one

colegottdank
@colegottdank
May 03 2017 03:10
@coymeetsworld because I am using g flag?
Coy Sanders
@coymeetsworld
May 03 2017 03:11
since you're just removing the characters it doesn't really matter
colegottdank
@colegottdank
May 03 2017 03:11
ok
Coy Sanders
@coymeetsworld
May 03 2017 03:11
plus matches one or more
all you're doing is removing anything that matches, so it doesn't matter if you replace a b and c individually or all at once
if the str is `abc`
colegottdank
@colegottdank
May 03 2017 03:12
var checker = /[^a-z0-9]/gi;
Coy Sanders
@coymeetsworld
May 03 2017 03:12
you can keep it in I just don't think it matters
colegottdank
@colegottdank
May 03 2017 03:12
If I use this, and use str.replace(checker, "");
Coy Sanders
@coymeetsworld
May 03 2017 03:12
try
Aizaz Shahid
@aizazshahid
May 03 2017 03:13
@coymeetsworld tell him to test his expressions there, http://regexr.com/
colegottdank
@colegottdank
May 03 2017 03:13
aizaz, I can read you :P
Aizaz Shahid
@aizazshahid
May 03 2017 03:13
hahaha, seems not !
colegottdank
@colegottdank
May 03 2017 03:13
sorry
Aizaz Shahid
@aizazshahid
May 03 2017 03:13
it's ok :+1:
Coy Sanders
@coymeetsworld
May 03 2017 03:13
that is a good place to test and provides nice reference
i do use it whenever i need to work w/ regex
colegottdank
@colegottdank
May 03 2017 03:14
``if(str == (str.split('').reverse().join('')))``
Mostafa Hesham
@mhesham32
May 03 2017 03:14
@SgtRaziel my project was offline all the APIs didn't work it gave me this error
``Refused to execute script from 'http://api.forismatic.com/api/1.0/?method=getQuote&format=jsonp&lang=en&jsonp=jQuery1120072795922933769_1493705752150&_=1493705752151' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.``
colegottdank
@colegottdank
May 03 2017 03:14
I then check if they are the same, but it isn't working...
Aizaz Shahid
@aizazshahid
May 03 2017 03:14
colegottdank
@colegottdank
May 03 2017 03:14
check for palindrome
Coy Sanders
@coymeetsworld
May 03 2017 03:14
can you show your whole code?
colegottdank
@colegottdank
May 03 2017 03:15
``````
function palindrome(str) {
// Good luck
var checker = /[^a-z0-9]/gi;

//Removes all whitespace
str.toLowerCase();
str.replace(checker, "");

if(str == (str.split('').reverse().join('')))
{
return true;
}

return false;
}

palindrome("eye");``````
Coy Sanders
@coymeetsworld
May 03 2017 03:15
the string functions don't modify the original string
colegottdank
@colegottdank
May 03 2017 03:15
^the comments old. i removed it
Aizaz Shahid
@aizazshahid
May 03 2017 03:15
oh in that you have to remove all non-alphanumeric characters from your string.
colegottdank
@colegottdank
May 03 2017 03:15
oh, they dont?
Coy Sanders
@coymeetsworld
May 03 2017 03:15
both return a new modified string
colegottdank
@colegottdank
May 03 2017 03:16
ah!
Coy Sanders
@coymeetsworld
May 03 2017 03:16
also another thing, you don't need that if/else statement or return true/false
you can just return the result of the == call
Aizaz Shahid
@aizazshahid
May 03 2017 03:16
@colegottdank use that `/[^a-z^A-Z]/g`
Coy Sanders
@coymeetsworld
May 03 2017 03:17
@forwebtech thats not correct, also don't give out answers like that
colegottdank
@colegottdank
May 03 2017 03:17
@coymeetsworld Your the best. Set the replace and to lowercase to str and it worked.
Coy Sanders
@coymeetsworld
May 03 2017 03:17
np @colegottdank
Aizaz Shahid
@aizazshahid
May 03 2017 03:17
@coymeetsworld hmm that is working one !
@coymeetsworld try it your self ?
colegottdank
@colegottdank
May 03 2017 03:17
also, you mean this coy?: return str==str.split('').reverse().join('');
Coy Sanders
@coymeetsworld
May 03 2017 03:17
its not, but regardless don't provide answers like that
yep @colegottdank
Aizaz Shahid
@aizazshahid
May 03 2017 03:18
@coymeetsworld Sir, go and check !
colegottdank
@colegottdank
May 03 2017 03:18
cool, thanks. Javascript has some cool features.
thanks @forwebtech @coymeetsworld
CamperBot
@camperbot
May 03 2017 03:18
colegottdank sends brownie points to @forwebtech and @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2511 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
May 03 2017 03:18
yeah, just a faster way
or rather less code
colegottdank
@colegottdank
May 03 2017 03:18
and optimized code makes me feel good lol
Coy Sanders
@coymeetsworld
May 03 2017 03:18
nice to use less code when possible, my solution uses 2 lines
Nguyen Hoang
@honnhien12h
May 03 2017 03:18
@sjames1958gm I can not finish this challenge, you can for me a example?
Coy Sanders
@coymeetsworld
May 03 2017 03:18
could put it in one but it would look ugly
Pagnito
@Pagnito
May 03 2017 03:19
so i thought regex ? meant optional but im reading that it means something else as well. like matching the proceeding character? how is that possible?
Vamp
@the-vampiire
May 03 2017 03:19
@colegottdank one correction
``return str === str.split(‘’).reverse().join(‘’);``
@colegottdank this case won’t matter thei are both strings by their nature but good to get in the habit of strict checking
colegottdank
@colegottdank
May 03 2017 03:20
@coymeetsworld changed it :
``````
function palindrome(str) {
// Good luck
var checker = /[^a-z0-9]/gi;
return str.replace(checker, "").toLowerCase() == str.replace(checker, "").split('').reverse().join('').toLowerCase();
}

palindrome("eye");``````
yeah @the-vampiire , you're right.
Coy Sanders
@coymeetsworld
May 03 2017 03:21
the line does look long @colegottdank
the main thing isn't so much about getting the code in less lines as possible, but making sure its readable
colegottdank
@colegottdank
May 03 2017 03:21
or one line:
return str.replace(/[^a-z0-9]/gi, "").toLowerCase() == str.replace(/[^a-z0-9]/gi, "").split('').reverse().join('').toLowerCase();
@coymeetsworld you're right, I just wanted to see lol
Coy Sanders
@coymeetsworld
May 03 2017 03:21
to paraphrase Einstein I think make something as simple as possible but not simpler than that
Mauro
@mauronml
May 03 2017 03:22
lol. I went the total opposite way with that challenge. I did a recursive solution. lots more code.
Vamp
@the-vampiire
May 03 2017 03:22
@colegottdank you can set str = str.replace(…).toLowerCase(); then return the comparison. reduce your repitition
Coy Sanders
@coymeetsworld
May 03 2017 03:22
and you don't need to set the regex to a variable, can just put it directly in the replace function
Vamp
@the-vampiire
May 03 2017 03:22
@colegottdank another habit to get in. don’t repeat code if you can avoid it
Coy Sanders
@coymeetsworld
May 03 2017 03:23
but these are just details, you got the soln right we're splitting hairs at this point
Vamp
@the-vampiire
May 03 2017 03:23
absolutely splitting hairs, you got it right for sur
just passing on some lessons along the way, good job.
colegottdank
@colegottdank
May 03 2017 03:23
@the-vampiire I know, I code in other languages a lot :P
new to js
thank you though @the-vampiire , you are right.
CamperBot
@camperbot
May 03 2017 03:24
colegottdank sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
Aizaz Shahid
@aizazshahid
May 03 2017 03:24
@colegottdank don't be one liner :) remember code readability and efficiency are important !
Vamp
@the-vampiire
May 03 2017 03:25
ya one liners are elegant and good if youre in a time crunch but overall I always prefer to spell out the code and comment it out. helps a lot when you want to reuse parts of it later and dont want to spend time digging through it wondering wtf you were doing lol
Aizaz Shahid
@aizazshahid
May 03 2017 03:25
and for production you can use some tools for that !
@the-vampiire well i don't put all code in one line unless that could be readable !
umedjon
@umedjon
May 03 2017 03:26
````````````````````
The thirdLetterOfLastName variable should have the value of v.
`````````````````````````````````````````````````
help me
Vamp
@the-vampiire
May 03 2017 03:27
its all preference, I just prefer to build habits early so it becomes second nature
Coy Sanders
@coymeetsworld
May 03 2017 03:27
sounds like you just need to assign a value to a variable
umedjon
@umedjon
May 03 2017 03:27
``````````````````````````````

// Example
var secondLetterOfFirstName = firstName[1];

// Setup
var lastName = "Lovelace";

// Only change code below this line.
var thirdLetterOfLastName = lastName;

``````````````````````````````````````````````````````
Dalton Escoe
@Alenero129
May 03 2017 03:27
Hello
Vamp
@the-vampiire
May 03 2017 03:28
@umedjon use ``` the letter above your esc key
Coy Sanders
@coymeetsworld
May 03 2017 03:28
only use 3
Aizaz Shahid
@aizazshahid
May 03 2017 03:28
@the-vampiire so what paradigm you prefer ?
Coy Sanders
@coymeetsworld
May 03 2017 03:28
@umedjon you need to change the last line
Vamp
@the-vampiire
May 03 2017 03:28
```js
new line
paste code here
new line
```
Victoria Zambrano
@vzambrano98
May 03 2017 03:28
can anyone just give me a hint as to what I might be doing wrong?
``````function telephoneCheck(str) {
var arrNum=str.replace(/[\D ]/g, "").split("");

if (arrNum.length===9){
var reg10=/[(]?\d{3}[)]?[-. ]?\d{3}[-. ]?\d{4}\b/g;
return reg10.test(str);
} else if (arrNum.length===10){
var reg11=/\b[+]?[1][. \-]?[(]?\d{3}[)]?[-. ]?\d{3}[-. ]?\d{4}\b/g;
return reg11.test(str);
}  else {return false;}
}
telephoneCheck("1 555 555 5555");``````
Coy Sanders
@coymeetsworld
May 03 2017 03:28
you don't want to set it to lastName, but a character inside lastName
look at the example for firstName
Mauro
@mauronml
May 03 2017 03:28
‘''
Aizaz Shahid
@aizazshahid
May 03 2017 03:28

More details..

Dalton Escoe
@Alenero129
May 03 2017 03:28
I wrote some javascript for the weather app. It works in Atom but doesn't work on codepen. Anyone knows why?
Mauro
@mauronml
May 03 2017 03:28
``````function palindrome(str) {
// get the length of the string
var length = str.length;
//base case for recursion
if (length <= 1)
{
return true;
}
else
{
//obtain first and last characters and convert to lower case
var firstChar = str.charAt(0).toLowerCase();
var lastChar = str.charAt(length - 1).toLowerCase();

if (isLetter(firstChar) && isLetter(lastChar)){
//both are letters
if (firstChar == lastChar){
//both first and last char are equal
console.log("first " + firstChar + " last " + lastChar );
var shorterString = str.substring(1, length - 1);
return palindrome(shorterString);
}else{
//they are not equal
return false;
}
}
else if (!isLetter(lastChar))
{
var noLast = str.substr(0, length - 1); //"remove" only the last char
return palindrome(noLast);
}
else if (!isLetter(firstChar))
{
var noFirst = str.substring(1); //"remove" the first char
return palindrome(noFirst);
}

}

}

function isLetter(str) {
var match = str.match(/[a-z0-9]/i);
return match;
}``````
Vamp
@the-vampiire
May 03 2017 03:29
you can replace js with whatever language you are pasting (html, css, etc)
Coy Sanders
@coymeetsworld
May 03 2017 03:29
the second letter of the first name is firstName[1]
Mauro
@mauronml
May 03 2017 03:29
that’s what i did. idk why i decided to go with a recursive solution. lol
Coy Sanders
@coymeetsworld
May 03 2017 03:29
need to do something similar with lastName
@mauronml you would've been better off using regex
you dont need such a complicated solution for this
Aizaz Shahid
@aizazshahid
May 03 2017 03:30
@mauronml you just need three lines to do that :)
Pagnito
@Pagnito
May 03 2017 03:30
is there a way to only match positive integers with regex?
Aizaz Shahid
@aizazshahid
May 03 2017 03:30
precisely !
colegottdank
@colegottdank
May 03 2017 03:30
``````
function findLongestWord(str) {
var splitter = str.split(" ");
var largestLength = 0;

for(var i = 0; i < splitter.length; i++)
{
if(splitter[i].length > largestLength)
{
largestLength = splitter[i].length;
}
}

return largestLength;
}

findLongestWord("The quick brown fox jumped over the lazy dog");``````
Challenge is to find longest word. It passed. @coymeetsworld do you see anything that I can improve on here?
Mauro
@mauronml
May 03 2017 03:30
@coymeetsworld yep. I figured there would be after I started, but I wanted to see if it could be done recursively anyways
Coy Sanders
@coymeetsworld
May 03 2017 03:31
looks fine to me
could make it shorter using a map function
Aizaz Shahid
@aizazshahid
May 03 2017 03:31
you can look at that !
colegottdank
@colegottdank
May 03 2017 03:31
couldn't you just do split(\ \g);
Coy Sanders
@coymeetsworld
May 03 2017 03:31
but its fine
you don't need a regex for that you can just separate by spaces
Aizaz Shahid
@aizazshahid
May 03 2017 03:32
@coymeetsworld yes !
colegottdank
@colegottdank
May 03 2017 03:32
ok, so all that weird looking shit is called regex. ok good to know :P
Coy Sanders
@coymeetsworld
May 03 2017 03:32
whered you get that solution from @forwebtech ?
Aizaz Shahid
@aizazshahid
May 03 2017 03:33
@coymeetsworld mine one !
Dalton Escoe
@Alenero129
May 03 2017 03:33
@the-vampiire What do you mean?
Aizaz Shahid
@aizazshahid
May 03 2017 03:33
``````function findLongestWord(str) {

// changing string into array
var array = str.split(" ");

// Creating new array having values of length of the above array elements
var lenArr = array.map( (val) => val.length );

// Getting max value and returning it
return Math.max.apply(null, lenArr);

}``````
edited !
Vamp
@the-vampiire
May 03 2017 03:34
@Alenero129 what is the question
Aizaz Shahid
@aizazshahid
May 03 2017 03:35
@coymeetsworld something wrong with it ??
Dalton Escoe
@Alenero129
May 03 2017 03:35
@the-vampiire I have some working code in Atom and transferred it to codepen but it seems like codepen isn't loading some of the javascript. Trying to figure out why.
Coy Sanders
@coymeetsworld
May 03 2017 03:35
nope
Vamp
@the-vampiire
May 03 2017 03:36
@Alenero129 I am very confused
Aizaz Shahid
@aizazshahid
May 03 2017 03:36
thanks for your comment for that `split()` ! @coymeetsworld
CamperBot
@camperbot
May 03 2017 03:36
forwebtech sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 2512 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Vamp
@the-vampiire
May 03 2017 03:36
you asked me what I meant
Coy Sanders
@coymeetsworld
May 03 2017 03:36
no problem
Vamp
@the-vampiire
May 03 2017 03:36
but I never said anything to you
Dalton Escoe
@Alenero129
May 03 2017 03:36
@the-vampiire I thought you were responding to me. Sorry, man.
Vamp
@the-vampiire
May 03 2017 03:36
no problem
post the codepen
likely you didnt include your libraries
Dalton Escoe
@Alenero129
May 03 2017 03:36
Vamp
@the-vampiire
May 03 2017 03:37
what is not working in particular
colegottdank
@colegottdank
May 03 2017 03:37
@Alenero129 I like the background image btw :P
Victoria Zambrano
@vzambrano98
May 03 2017 03:38
hey guys, I'm working on the telephone number algo and for some reason I have some if statements that aren't working. the statements are true but in python tutor I'm just watching it skip right over it....does anyone have a sec to let me know why on earth it's not working? much appreciated
``````function telephoneCheck(str) {
var arrNum=str.replace(/[\D ]/g, "").split("");

if (arrNum.length===9){
var reg10=/[(]?\d{3}[)]?[-. ]?\d{3}[-. ]?\d{4}\b/g;
return reg10.test(str);
} else if (arrNum.length===10){
var reg11=/\b[+]?[1][. \-]?[(]?\d{3}[)]?[-. ]?\d{3}[-. ]?\d{4}\b/g;
return reg11.test(str);
}  else {return false;}
}
telephoneCheck("1 555 555 5555");``````
Dalton Escoe
@Alenero129
May 03 2017 03:39
@the-vampiire Everything from the `xhttp.onreadystatechange = function...` line
Aizaz Shahid
@aizazshahid
May 03 2017 03:40
looks like regex competition :D
Dalton Escoe
@Alenero129
May 03 2017 03:40
@the-vampiire From line 30.
Aizaz Shahid
@aizazshahid
May 03 2017 03:40
@vzambrano98 may be you can make one regex to check all numbers !
Dalton Escoe
@Alenero129
May 03 2017 03:41
Where it adds the location, temperature and current weather icon to the dom
Vamp
@the-vampiire
May 03 2017 03:41
ya
so you are running into a common issue
Aizaz Shahid
@aizazshahid
May 03 2017 03:41
@vzambrano98 try your regex there, http://regexr.com/
Vamp
@the-vampiire
May 03 2017 03:41
I am going to share a link with you in exchange for you giving the author credit, give a thanks to @SkyCoder01
http://codepen.io/skycoder/post/apisandlocation
CamperBot
@camperbot
May 03 2017 03:41
the-vampiire sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:star2: 1255 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Nguyen Hoang
@honnhien12h
May 03 2017 03:42

Who can suggest for me this challenge Stand in line of JavaScript:
function nextInLine(arr, item) {
testArr.push(6);
testArr.shift();
return item; // Change this line
}

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

Vamp
@the-vampiire
May 03 2017 03:42
give thanks and I will give you a tldr
but i still suggest reading it through. good info to have. i keep it bookmarked
Aizaz Shahid
@aizazshahid
May 03 2017 03:42
@honnhien12h you need to return the array element which is cut it from array
Vamp
@the-vampiire
May 03 2017 03:42
@honnhien12h first of you need to review how functions and function parameters are used
Pagnito
@Pagnito
May 03 2017 03:42
``("1 555)555-5555")``
i made the first three numbers optional, but i dont know how to make them only capture the phone number if both the paranthesis are threr
Aizaz Shahid
@aizazshahid
May 03 2017 03:43
`return testArr.shift()` @honnhien12h
Vamp
@the-vampiire
May 03 2017 03:43
you have a function but inside it you are using static code (passing the number 6). you shold be using the parameters so the code becomes dynamic. meaning any values of arr and item can be passed in producing the expected results
Aizaz Shahid
@aizazshahid
May 03 2017 03:43
@honnhien12h sorry :) you need to use the argument !
Vamp
@the-vampiire
May 03 2017 03:43
@forwebtech that is incorrect
and you need to stop giving answers pleas
it does not help anyone
Aizaz Shahid
@aizazshahid
May 03 2017 03:43
@the-vampiire yes my bad i didn't look at it
Vamp
@the-vampiire
May 03 2017 03:44
even if it were correct the idea behind giving someone an answer is not something I stand by
they learn nothing, a monkey can copy and paste.
Aizaz Shahid
@aizazshahid
May 03 2017 03:44
yes right !
hahahah why are you calling them monkey !
Vamp
@the-vampiire
May 03 2017 03:44
never called anyone a monkey
Nguyen Hoang
@honnhien12h
May 03 2017 03:44
@forwebtech Thank you i will try it
CamperBot
@camperbot
May 03 2017 03:44
honnhien12h sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
Vamp
@the-vampiire
May 03 2017 03:45
the point is dont give people answers man. guide them to producing the answer themselves by providing resources or written explanations.
Aizaz Shahid
@aizazshahid
May 03 2017 03:45
@honnhien12h use your argument `arr.push(..)` and `arr.shift()`
@the-vampiire do you think i did that intentionally ??
Vamp
@the-vampiire
May 03 2017 03:45
@Alenero129 waiting for the thanks to @SkyCoder01
CamperBot
@camperbot
May 03 2017 03:45
the-vampiire sends brownie points to @alenero129 and @skycoder01 :sparkles: :thumbsup: :sparkles:
:warning: the-vampiire already gave skycoder01 points
Vamp
@the-vampiire
May 03 2017 03:46
yes I do, you have done it twice in the span of the last 15 minutes. and on other days I have also asked you not to do that. be mindful.
Aizaz Shahid
@aizazshahid
May 03 2017 03:47
@the-vampiire but i haven't seen you enough i don't know about other days hahaha
Vamp
@the-vampiire
May 03 2017 03:47
i dont control this chat room or you. i am just asking you to respect the process of learning. nobody is impressed you can spit out answers to beginner questions. the point of this chat is to help people learn not give them answers to copy and paste
Pagnito
@Pagnito
May 03 2017 03:47
@the-vampiire yo man guide me to finding a way to use a regex that will only accept (333) and not 333)
Gulsvi
@gulsvi
May 03 2017 03:48
I'm happy to help with that doc - no need for cookies :) but thank you
Vamp
@the-vampiire
May 03 2017 03:48
alright. well I have been here every single day since I started 40 days ago
Pagnito
@Pagnito
May 03 2017 03:48
@SkyCoder01 skyy!!
Aizaz Shahid
@aizazshahid
May 03 2017 03:48
@the-vampiire but didn't seen you enough !
Gulsvi
@gulsvi
May 03 2017 03:48
@Pagnito Hey Pag!
:)
Dalton Escoe
@Alenero129
May 03 2017 03:48
@the-vampiire Thanks. I don't understand the Thanks system.
CamperBot
@camperbot
May 03 2017 03:48
alenero129 sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles:
Vamp
@the-vampiire
May 03 2017 03:48
my point remains the same whether you have seen me or not
Pagnito
@Pagnito
May 03 2017 03:48
@SkyCoder01 hows it going man, what u workin on
Vamp
@the-vampiire
May 03 2017 03:48
@Alenero129 just write "@SkyCoder01 thank you for the great guide"
CamperBot
@camperbot
May 03 2017 03:48
the-vampiire sends brownie points to @alenero129 and @skycoder01 :sparkles: :thumbsup: :sparkles:
:warning: the-vampiire already gave alenero129 points
:warning: the-vampiire already gave skycoder01 points
Aizaz Shahid
@aizazshahid
May 03 2017 03:48
@the-vampiire ok keep arguing ! :+1:
Gulsvi
@gulsvi
May 03 2017 03:49
Random algorithms, trying to take a list of words in a document and see which ones are anagrams
Vamp
@the-vampiire
May 03 2017 03:49
I am not arguing. I am asking for you to respect the learning process. if you want to continue to boast with easy solutions go ahead
Pagnito
@Pagnito
May 03 2017 03:49
@SkyCoder01 what are anagrams?
Vamp
@the-vampiire
May 03 2017 03:49
nobody will stop you
least of all myself
Coy Sanders
@coymeetsworld
May 03 2017 03:49
@the-vampiire is right though @forwebtech, you shouldn't be providing answers like that
Aizaz Shahid
@aizazshahid
May 03 2017 03:50
@coymeetsworld like what ??
Vamp
@the-vampiire
May 03 2017 03:50
I wont ask again, no worries
Coy Sanders
@coymeetsworld
May 03 2017 03:50
and even worse if they are not correct which some of yours werent
Gulsvi
@gulsvi
May 03 2017 03:50
@Pagnito Like 'god' 'dog' - words that have the same letters
`act` `cat`
Tyler Wright
@samoasao
May 03 2017 03:50
hello
Coy Sanders
@coymeetsworld
May 03 2017 03:50
just giving the solution, i.e. giving them something they can just copy and paste
Aizaz Shahid
@aizazshahid
May 03 2017 03:50
@coymeetsworld well i gave solutions after they pass the challenge !
Pagnito
@Pagnito
May 03 2017 03:50
@SkyCoder01 oooh
Dalton Escoe
@Alenero129
May 03 2017 03:50
@the-vampiire I can't figure out the issue :/
It's all within the same function and it worked if I open it on the computer. It's odd. And I didn't use any libraries. No jquery.
Coy Sanders
@coymeetsworld
May 03 2017 03:50
@forwebtech not always
Vamp
@the-vampiire
May 03 2017 03:50
@Alenero129 did you read the guide?
Dalton Escoe
@Alenero129
May 03 2017 03:51
@the-vampiire lol hold up. I didn't see a guide. Let me scroll up to check.
Vamp
@the-vampiire
May 03 2017 03:51
lol
did you think I was demanding you to give some random person brownie points for free?
Mauro
@mauronml
May 03 2017 03:51
I think my laptop’s gpu is dying :(
Vamp
@the-vampiire
May 03 2017 03:51
here @Alenero129
Aizaz Shahid
@aizazshahid
May 03 2017 03:51
@coymeetsworld well next time, will take care of it, but thanks @the-vampiire , @coymeetsworld and vampire was just kidding with you !
CamperBot
@camperbot
May 03 2017 03:51
forwebtech sends brownie points to @coymeetsworld and @the-vampiire :sparkles: :thumbsup: :sparkles:
:warning: forwebtech already gave coymeetsworld points
Vamp
@the-vampiire
May 03 2017 03:52
the guy you were thanking is the author of that guide
Coy Sanders
@coymeetsworld
May 03 2017 03:52
ok np @forwebtech
Aizaz Shahid
@aizazshahid
May 03 2017 03:52
@the-vampiire i think he got serious :)
Gulsvi
@gulsvi
May 03 2017 03:52
lol :)
Pagnito
@Pagnito
May 03 2017 03:53
@SkyCoder01 dude argument optional was a biiiiiiitch so solve
Gulsvi
@gulsvi
May 03 2017 03:54
That one was hard
Vamp
@the-vampiire
May 03 2017 03:54

@Alenero129 tldr (but the article is worth reading for your own sake):
you are using a location method called navigator that requires https (secured connection)
your other API calls for weather details are not secure and dont offer a secure endpoint
this gets blocked by chrome

and I think it worked on your localhost site preview because everything was local sothe restrictions are lifted? cant remember

someone else can clean up what I’ve said if its wrong or partial

Dalton Escoe
@Alenero129
May 03 2017 03:54
@the-vampiire Yeah. Thanks. I'm going over it now.
@SkyCoder01
CamperBot
@camperbot
May 03 2017 03:54
alenero129 sends brownie points to @the-vampiire and @skycoder01 :sparkles: :thumbsup: :sparkles:
:warning: alenero129 already gave the-vampiire points
:star2: 1256 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Gulsvi
@gulsvi
May 03 2017 03:55
I did one on codewars that was kind of like it where you could have any number of params: `addTogether(2)(3)(5)(8)(9)etc...`
Vamp
@the-vampiire
May 03 2017 03:55
oh jesus
Aizaz Shahid
@aizazshahid
May 03 2017 03:55
@SkyCoder01 codewars ??
have seen one link of it, is it like FCC ?
Gulsvi
@gulsvi
May 03 2017 03:55
It isn't as fun as it sounds :)
Coy Sanders
@coymeetsworld
May 03 2017 03:55
currying
Vamp
@the-vampiire
May 03 2017 03:55
@Pagnito arguments optional was not bad until you realized ther was some trickery required to get around the undefined requirement
Gulsvi
@gulsvi
May 03 2017 03:56
A way to do more JS problems, build off of what you learn here.
Yeah, currying @coymeetsworld
Coy Sanders
@coymeetsworld
May 03 2017 03:57
codewars kind of gets annoying for me, sometimes some challenges aren't tested for all languages incl JS
i think i was doing kyu 4s or maybe 3s and got annoyed when people complained about the challenges
Pagnito
@Pagnito
May 03 2017 03:57
@the-vampiire yea, thats the point....nothin is hard once u figure it out...
Vamp
@the-vampiire
May 03 2017 03:57
so close I can taste it
Coy Sanders
@coymeetsworld
May 03 2017 03:57
think Hacker Rank is a little better
Gulsvi
@gulsvi
May 03 2017 03:57
They could use some more quality control...and I don't like that I have to bookmark a problem to go back to it. Would like to pick up where I left off
I've heard good things about Hacker Rank
Dalton Escoe
@Alenero129
May 03 2017 03:58
@the-vampiire I see. I'm going over it. And here I thought I had it all.
Vamp
@the-vampiire
May 03 2017 03:58
@Pagnito well what I mean is the base shell / underlying concept of the problem was easy to put together and understand
Aizaz Shahid
@aizazshahid
May 03 2017 03:58
looks like its older than this site !
Coy Sanders
@coymeetsworld
May 03 2017 03:58
they are challenging, trying the coding interview ones and they aren't easy
andventuree
@andventuree
May 03 2017 03:58
hi guys, first time here so i kindly ask you guys excuse me if im breaking any rules haha
Vamp
@the-vampiire
May 03 2017 03:58
there are no rules
this is anarchy
Aizaz Shahid
@aizazshahid
May 03 2017 03:58
@andventuree Welcome ! no worries !
there are rules by @the-vampiire hahahah
Vamp
@the-vampiire
May 03 2017 03:59
where?
Aizaz Shahid
@aizazshahid
May 03 2017 03:59
so just be careful with him !
Pagnito
@Pagnito
May 03 2017 03:59
@the-vampiire yea i suppose for you, i had a struggle with it, and i know many others did, we all think diffirent
Coy Sanders
@coymeetsworld
May 03 2017 03:59
dont spam, dont be vile, dont post answers @andventuree
pretty simple :)
Vamp
@the-vampiire
May 03 2017 03:59
@Pagnito I am not saying it to brag man I think you read my tone wrong. I am saying spend some time thinking about the undefined return that is the real issue
I meant to give you a hint
sorry if it came across otherwise
Pagnito
@Pagnito
May 03 2017 04:00
@the-vampiire its np appreciate ur concern, i did read it wrong lol
Vamp
@the-vampiire
May 03 2017 04:01
waht part are you stuck on
building the shell?
Pagnito
@Pagnito
May 03 2017 04:01
@the-vampiire no im not stuck on it anymore, i alrdy solved, i was saying tht it was hard when i was trying to figure out closure and recursion
@the-vampiire but u can help me with sometihng elseee
@the-vampiire im trying to find out how to pass a regex
@the-vampiire (333) but not 333)
Vamp
@the-vampiire
May 03 2017 04:02
Pagnito
@Pagnito
May 03 2017 04:02
@the-vampiire yea
Vamp
@the-vampiire
May 03 2017 04:02
hey im on that one too lol
Pagnito
@Pagnito
May 03 2017 04:02
@the-vampiire haha
Vamp
@the-vampiire
May 03 2017 04:03
no fuckin idea man I just got to it
I skipped around a bit
Pagnito
@Pagnito
May 03 2017 04:03
@the-vampiire yea it was unexpectedly more than i thought
Vamp
@the-vampiire
May 03 2017 04:03
regex scares me so I did some other ones first
Pagnito
@Pagnito
May 03 2017 04:03
i feel u
Coy Sanders
@coymeetsworld
May 03 2017 04:03
have to use some adv regex to do that
Vamp
@the-vampiire
May 03 2017 04:03
I some some savage on the facebook group post a one liner solution to it...
Coy Sanders
@coymeetsworld
May 03 2017 04:03
learn lookups
Pagnito
@Pagnito
May 03 2017 04:03
@the-vampiire yea regex looks like the retarded cousin of code
Vamp
@the-vampiire
May 03 2017 04:03
it was covered by the Complete box but I could see a bit behind it
Coy Sanders
@coymeetsworld
May 03 2017 04:03
Pagnito
@Pagnito
May 03 2017 04:04
@coymeetsworld were u tellin me? about lookups?
Coy Sanders
@coymeetsworld
May 03 2017 04:04
doubt it
Pagnito
@Pagnito
May 03 2017 04:04
oh
doubt it? lol
Coy Sanders
@coymeetsworld
May 03 2017 04:04
i don't remember talking about lookups recently
Pagnito
@Pagnito
May 03 2017 04:04
u asid learn look ups at 00:03
Coy Sanders
@coymeetsworld
May 03 2017 04:05
oh you mean just now? yeah
Pagnito
@Pagnito
May 03 2017 04:05
yea
oh so it was towards me?
Vamp
@the-vampiire
May 03 2017 04:05
crazy
Coy Sanders
@coymeetsworld
May 03 2017 04:05
i guess, just a general statement
Vamp
@the-vampiire
May 03 2017 04:05
may not be one line actually
Coy Sanders
@coymeetsworld
May 03 2017 04:05
i needed lookups to solve it
Vamp
@the-vampiire
May 03 2017 04:05
lot covered on the left
Joseph
@revisualize
May 03 2017 04:05
@the-vampiire Grats.
Vamp
@the-vampiire
May 03 2017 04:05
oh thats not me
i was sharing the “one line” solution to telephone numbers I saw on fb
Pagnito
@Pagnito
May 03 2017 04:06
@the-vampiire oh dude u solved it!!?
Vamp
@the-vampiire
May 03 2017 04:06
no
shit
Gulsvi
@gulsvi
May 03 2017 04:06
nice work!
that was a pain...
Vamp
@the-vampiire
May 03 2017 04:06
coy said “doubt it” thought he meant he douvted it was solved in one line so I found the pic on facebook. tht is NOT my solution
i havent done the problem
-_-
Pagnito
@Pagnito
May 03 2017 04:07
oh
gulsvi @SkyCoder01 takes back the "nice work" comment
Gulsvi
@gulsvi
May 03 2017 04:07
:)
Pagnito
@Pagnito
May 03 2017 04:07
lol
Aizaz Shahid
@aizazshahid
May 03 2017 04:07
what is the task name ??
telephone directory one ?
Gulsvi
@gulsvi
May 03 2017 04:08
Aizaz Shahid
@aizazshahid
May 03 2017 04:08
well let me try it !
Gulsvi
@gulsvi
May 03 2017 04:12
Does free code camp teach binary search trees, linked lists, and other data structures after the front-end course?
Or things like bubble sort, merge sort, and insertion sort?
Francisco Franco
@frenktico
May 03 2017 04:13
Hey y'all
Hope y'all are doing great
I need help on the Word Blanks challenge
Gulsvi
@gulsvi
May 03 2017 04:13
Hello @frenktico
Francisco Franco
@frenktico
May 03 2017 04:14
Gulsvi
@gulsvi
May 03 2017 04:14
lol, me too :)
What does your word blanks code look like? Or what question do you have?
Francisco Franco
@frenktico
May 03 2017 04:15
Actually I do not even know where to start :|
Even with the explanation of the exercise I did not get how to break that into few parts and start doing the code.
Gulsvi
@gulsvi
May 03 2017 04:16
Start with a sentence you want to say that includes "dog", "big" "ran" and "quickly"
Francisco Franco
@frenktico
May 03 2017 04:18
yes but my "solution" wasn't a solution actually. Check it out
``````function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result += "I was eating a " + wordBlanks[0] + "while having a " + wordBlanks[1] + "So I " + wordBlanks[2] + "and it was very " + wordBlanks[3];
// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");``````
The line in the middle did not work at all
There might be a reason for that
Gulsvi
@gulsvi
May 03 2017 04:19
Yeah, `wordBlanks[0]` is for getting something form an array
Francisco Franco
@frenktico
May 03 2017 04:19
I knew that but I thought that it would be a good way to go all the way from the function as well
Gulsvi
@gulsvi
May 03 2017 04:19
You have a function here with arguments, so instead of `wordBlanks[0]` use `myNoun`
Francisco Franco
@frenktico
May 03 2017 04:20
:O
Gulsvi
@gulsvi
May 03 2017 04:20
`myNoun` = `dog` in that function
`myAdjective` = `big`
`myVerb` = `ran`
etc..
Francisco Franco
@frenktico
May 03 2017 04:20
yay
That worked
Thank you @SkyCoder01
CamperBot
@camperbot
May 03 2017 04:21
frenktico sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:star2: 1257 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Gulsvi
@gulsvi
May 03 2017 04:21
Good job :+1:
May 03 2017 04:21
Hello everyone, Can someone help with javascript Challenge(Shopping List)
``````var myList = ["Gogeries", 60,"yusuf",87,"yusadolat",64,"tert",44,"intret",22];

myList.slice(0,1);``````
Gulsvi
@gulsvi
May 03 2017 04:22
@Yusadolat Each item in your shopping list should be in its own sub array: `[item, quantity],`
Khoa Le
@Zacele
May 03 2017 04:23
`` `
Gulsvi
@gulsvi
May 03 2017 04:23
Like the example: `["Chocolate Bar", 15]`
May 03 2017 04:23
Ohh Now I get thanks
Khoa Le
@Zacele
May 03 2017 04:23
``````function pairElement(str) {
var splittedStr=str.split('');
var Arr = [];
splittedStr.forEach(function(i){
var subArr = [];
if(i == "A"){
subArr.push("A","T");
Arr.push(subArr);
} else if(i== "T"){
subArr.push("T","A");
Arr.push(subArr);
} else if(i== "C"){
subArr.push("C","G");
Arr.push(subArr);
} else if(i== "G"){
subArr.push("G","C");
Arr.push(subArr);
}
});
return Arr;
}``````
here is my code for the DNA Pairing challenge
is there anyway I could do differently to refactor my code :(
is it way to long and DRY
Gulsvi
@gulsvi
May 03 2017 04:25
@Zacele I made a map for mine:
``````  var pairMap = {
"G": "C",
"C": "G",
"A": "T",
"T": "A"
};``````
Then I looped through `str` to get each letter and did `pairMap[letter]`
Francisco Franco
@frenktico
May 03 2017 04:29
OMG I love the chat we have here!
<3
Just wanted to say thanks to you all! <3
Mauro
@mauronml
May 03 2017 04:29
:)
Mauro
@mauronml
May 03 2017 04:41
``````function largestOfFour(arr) {
var newArr = arr.map(function(a){return a.reduce(function(a,b){return b > a ? b : a;});});
return newArr;
}``````
Aizaz Shahid
@aizazshahid
May 03 2017 04:45
@mauronml nice one !
also you could use `Math.max.apply(null, numArray)`
Mauro
@mauronml
May 03 2017 04:47
Thanks. I’ll look into that method
Khoa Le
@Zacele
May 03 2017 04:48
@SkyCoder01 hey man, I'm quite confuse about how to use that method you just show me, could you a little bit more specific about how to apply method .map() this challenge
Coy Sanders
@coymeetsworld
May 03 2017 04:52
you should learn how functional programming works so you can judge on your own
@mauronml
Mauro
@mauronml
May 03 2017 04:54
@coymeetsworld yeah, i will look into that as well :)
Lexi
@lexluther2125
May 03 2017 04:55
Hi guys. I'm stuck in Javascript on the section about finding a remainder. The example is: 5 % 2 = 1 because
Math.floor(5 / 2) = 2 (Quotient)
2 * 2 = 4
5 - 4 = 1 (Remainder)
Mauro
@mauronml
May 03 2017 04:55
@coymeetsworld is there a “best practice” book/site for JS functional programming? Kinda like Effective Java
Lexi
@lexluther2125
May 03 2017 04:56
They're asking us to find 11 divided by 3 using the remainder % operator.
I have no clue how to format this. Can anyone help out?
Aizaz Shahid
@aizazshahid
May 03 2017 04:56
@lexluther2125 yes use that modulus operator , actually it divides both numbers , but returns the remainder !
try to do `console.log( 10 % 3 )`
to test what is actually returning !
Coy Sanders
@coymeetsworld
May 03 2017 04:58
@mauronml not that I'm particularly aware of, haven't used any books to learn JS yet
Aizaz Shahid
@aizazshahid
May 03 2017 04:58
@mauronml Java or JavaScript are both different languages !
Mauro
@mauronml
May 03 2017 04:59
@coymeetsworld I see. I’m googling some now.
Coy Sanders
@coymeetsworld
May 03 2017 04:59
Lexi
@lexluther2125
May 03 2017 04:59
Aizaz, how do I input for console.log when testing within freecodecamp? I know I can try it within Sublime and then inspect the page using Chrome, but when I input it in Freecodecamp's example, it returns an error.
Aizaz Shahid
@aizazshahid
May 03 2017 05:00
@lexluther2125 well you should to open your console for that !
but actually, `10 % 3` returns 1
because 3 * 3 = 9 & 10 - 9 = 1
@lexluther2125 by same method you should use that `11 % 3`
Coy Sanders
@coymeetsworld
May 03 2017 05:02
@lexluther2125 the mod operator (%) finds out what the remainder is of a division
like `10 % 3` returns the remainder of `10 / 3`
Aizaz Shahid
@aizazshahid
May 03 2017 05:02
@lexluther2125 this operator is used widely you should to learn its usage ! by testing !
Coy Sanders
@coymeetsworld
May 03 2017 05:02
which would be 1, because 10 goes into 3, 3 times
Vamp
@the-vampiire
May 03 2017 05:03
which would be 1, because 3 goes into 10, 3 times
Coy Sanders
@coymeetsworld
May 03 2017 05:03
meh
Aizaz Shahid
@aizazshahid
May 03 2017 05:03
@lexluther2125 you can do test by making a file into your pc so you will understand much !
make a `index.html` and put your JS code between `<script> .... code </script>` so you can easily test whatever you want !
@lexluther2125 and i think for chrome, `ctrl+shift+j` will open you console area !
Markus Kiili
@Masd925
May 03 2017 05:10
@HeebieGeeBee It allows the constructor to have private data and not pollute the global scope with variables.
@coymeetsworld @forwebtech Morning.
Aizaz Shahid
@aizazshahid
May 03 2017 05:10
@Masd925 Good Morning ! :+1:
Coy Sanders
@coymeetsworld
May 03 2017 05:10
gm @Masd925, well night for me
Aizaz Shahid
@aizazshahid
May 03 2017 05:11
@Masd925 what time there ? 7 ?
Markus Kiili
@Masd925
May 03 2017 05:11
@forwebtech 8.11
Aizaz Shahid
@aizazshahid
May 03 2017 05:11
alright ! 2 hours late from us !
i think you are from any European country ?
Markus Kiili
@Masd925
May 03 2017 05:15
@forwebtech Finland.
Aizaz Shahid
@aizazshahid
May 03 2017 05:16
alright !
Markus Kiili
@Masd925
May 03 2017 05:25
@revisualize The JS engine parses the code (lexical analysis) and turns it into bytecode that the compiler can then execute (JIT processes). Some engines (V8) also compile JS source code into machine code.
Damien
@DubbDevs
May 03 2017 05:29
can I have some help with JSON and manipulating objects
``````var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}

myMusic.push([
"artist": "Outkast",
"title": "Atliens",
"release_year": 1996,
"formats": [
"CD",
"LP",
"Cassett"],
"gold": true
];``````
Mario A. Carlos
@MarioC3
May 03 2017 05:29
Hello Guys, I hope you guys can help me!
Damien
@DubbDevs
May 03 2017 05:30
i thought I could simply push data to the end of the array...seems that's incorrect
Mario A. Carlos
@MarioC3
May 03 2017 05:30
This is my code:
``````
var oldArray = [1,2,3,4,5];

var plusThree = oldArray.map(function (val){
return val + 3;
});

// Only change code below this line.

var newArray = oldArray;``````
Any idea what I might be doing wrong?
Markus Kiili
@Masd925
May 03 2017 05:33
@DubbDevs You could, but you are pushing inside the array literal there.