16th
Aug 2018
Jason Luboff
@JLuboff
Aug 16 2018 00:02
A lot of companies ;)
Fikry82
@Fikry82
Aug 16 2018 00:08
``````const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
const squareList = (arr) => {
"use strict";
// change code below this line
var myPositiveArray=[];
for(var i = 0; i<=realNumberArray.length; i++){
if(realNumberArray[i].isInteger){
myPositiveArray.push(realNumberArray[i]*2);
}
}
const squaredIntegers =myPositiveArray;
// change code above this line
return squaredIntegers;
};
const squaredIntegers = squareList(realNumberArray);
console.log(squaredIntegers);``````
why realNumberArray[i] undefined
Aug 16 2018 00:09
use `arr` not realNumberArray, since its a global and could not exist
especially during testing
Fikry82
@Fikry82
Aug 16 2018 00:13
arr[i] undefined
Moisés Man
@moigithub
Aug 16 2018 00:13
probably u wanna check isInteger documentation /syntax /examples
mdn.io/number.isInteger
JJ Megma
Aug 16 2018 00:14
@Fikry82 isInteger is a function
You are using it like a variable
isInteger(2) //true
isInteger //undefined
Fikry82
@Fikry82
Aug 16 2018 00:16
ohh
JJ Megma
Aug 16 2018 00:17
if u want u can do `if(Number.isInteger(realNumberArray[i]))`
or `typeof realNumberArray[i] === 'number'`
and @bradtaniguchi is right, you want to use arr
not the global arr ur passing into the function anyways
Aug 16 2018 00:19
You sure arr[i] isn't undefined due to being off by 1?
JJ Megma
Aug 16 2018 00:19
other wise there is no point
off by 1?
@Fikry82 it sorta defeats the purpose of passing that arg
Aug 16 2018 00:20
change `<=` to `<` in the for condition, I think that would work, since if length = 5, that means arr[5] doesn't exist, since the arr indexes start at 0, not 1
JJ Megma
Aug 16 2018 00:20
oh
yea I didn't look that far into the code lol
I think he left
Aug 16 2018 00:21
@Fikry82 ^^
Fikry82
@Fikry82
Aug 16 2018 00:21
no i am here
JJ Megma
Aug 16 2018 00:22
:)
Fikry82
@Fikry82
Aug 16 2018 00:22
lol
i should't use loop
JJ Megma
Aug 16 2018 00:23
ur loop is fine to use, just make small changes pointed out
@Fikry82 ur passing an array to that function u created
the problem is
ur not using it, ur taking from the global array
now ur function won't work anywhere else
except on that one array with that variable name
make sense?
Fikry82
@Fikry82
Aug 16 2018 00:27
``````const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
const squareList = (arr) => {
"use strict";
// change code below this line
const myPositiveArray=[];
for(let i = 0; i<arr.length; i++){
if(Number.isInteger(arr[i])){
myPositiveArray.push(arr[i]*2);
}
}
const squaredIntegers =myPositiveArray;
const squaredIntegers = arr;
// change code above this line
return squaredIntegers;
};
const squaredIntegers = squareList(realNumberArray);
console.log(squaredIntegers);``````
Moisés Man
@moigithub
Aug 16 2018 00:29
whats the value of `arr`
and what this code will do ? `const squaredIntegers = arr;`
on the other hand.. const(ants) cant be redefined/reassigned
Fikry82
@Fikry82
Aug 16 2018 00:30
arr = realNumberArray
``````const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
const squareList = (arr) => {
"use strict";
// change code below this line
const myPositiveArray=[];
for(let i = 0; i<arr.length; i++){
if(Number.isInteger(arr[i])){
myPositiveArray.push(arr[i]*2);
}
}
arr =myPositiveArray;
const squaredIntegers = arr;
// change code above this line
return squaredIntegers;
};
const squaredIntegers = squareList(realNumberArray);
console.log(squaredIntegers);``````
Aug 16 2018 00:32
these lines dont do anything of importance
``````arr =myPositiveArray;
const squaredIntegers = arr;``````
my question is where did squaredIntegers go, don't they give you that? or you create it yourself?
Fikry82
@Fikry82
Aug 16 2018 00:33
const squaredIntegers = arr; is already there
Aug 16 2018 00:35
id throw out that line, and rename your `myPositiveArray` to `squaredIntegers`, since that's the answer you want to give, no need to beat around the bush with interm variables
JJ Megma
Aug 16 2018 00:39
what is the objective here? just square each num in the passed in array?
@Fikry82
Fikry82
@Fikry82
Aug 16 2018 00:39
only positive one
i think test don't wanna me to use loop
JJ Megma
Aug 16 2018 00:40
where are u testing if its a positive or negative?
Fikry82
@Fikry82
Aug 16 2018 00:40
wanna me use filter or map
JJ Megma
Aug 16 2018 00:40
ur checking if its an integer
but ur not checking if its a positive number
Fikry82
@Fikry82
Aug 16 2018 00:40
number.isInteger(arr[i)
JJ Megma
Aug 16 2018 00:40
right
Aug 16 2018 00:40
yea, optimally you'd use reduce, or filter+map
Fikry82
@Fikry82
Aug 16 2018 00:41
okay i will search them
JJ Megma
Aug 16 2018 00:41
u need to change ur if
do u know how to check if a number is negative or positive using javascript? @Fikry82
Fikry82
@Fikry82
Aug 16 2018 00:41
sure its easy
negative <0
positive>0
this number.isInteger() true only when the number is not float
test dont wanna float numbers to be squared
Aug 16 2018 01:09
time to try my docker setup once again, give myself half an hour to figure this out :sunglasses:
Christopher McCormack
@cmccormack
Aug 16 2018 01:10
@bradtaniguchi you have 14 minutes... Go!
JJ Megma
Aug 16 2018 01:12
@Fikry82 yea so u need to check that in ur if
Aug 16 2018 01:26
hehe I complained about docker in the wrong room :P
Aug 16 2018 01:52
ouch, running into issues with a private github repo...
Simon Cordova
@gbsimon87
Aug 16 2018 08:33
morning...
coderlyn
@ailyntang
Aug 16 2018 08:40
Hi all - I'm having trouble running tests for this one JS curriculum lesson. Anyone else able to run the tests? Other lessons are working fine, not sure if it's a bug or just me. TIA!
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/record-collection/
@ezioda004
Aug 16 2018 08:44
@ailyntang Can you show your code?
coderlyn
@ailyntang
Aug 16 2018 08:47
@ezioda004 D'oh, as I typed in some code to show you, thought I would try it again just one more time. And this time the tests ran! Bah, no idea what I was doing wrong before (not hitting command enter hard enough clearly!). Thanks for checking Aditya! All good now
@ezioda004
Aug 16 2018 08:48
Great :thumbsup:
Supra01
@Supra01
Aug 16 2018 12:11
Hello I hope everyone is doing well!
I'm trying to make an accordion with vanilla JavaScript by toggling a CSS class but I cannot seem to get it to work and I was wondering if anyone might know why.
https://codepen.io/Supra_01/pen/BPgZWM?editors=0110
``````var accordions = document.querySelectorAll('.accordion');
var content = document.querySelector('.accordion-content');

()=> content.toggle('isOpen')))``````
Simon Cordova
@gbsimon87
Aug 16 2018 12:17
@Supra01 I don't believe .toggle is vanilla JS
You could try something like
content.classList.toggle("isOpen");
Supra01
@Supra01
Aug 16 2018 12:18
@gbsimon87 I'll give it a try
@ezioda004
Aug 16 2018 12:19
@Supra01 As pointed above you'll need to access the `classList` property first. Also `.querySelectorAll()` returns a nodeList which is not an array so no `.map()` on it, however you can convert it.
`[...accordions].map(//rest of the code)`
Simon Cordova
@gbsimon87
Aug 16 2018 12:33
To add to @ezioda004 's point, you can you also use a forEach or for-of loop for this case
but I don't believe all browsers support both, go with what's more appropriate, check MDN for that
@ezioda004
Aug 16 2018 12:35
Yeah, `.forEach()` is available on nodeList, that seems better for this task.
Supra01
@Supra01
Aug 16 2018 12:52

@ezioda004 Thank you! I'm almost there.

``````var accordions = document.querySelectorAll('.accordion');
var content = document.querySelector('.accordion-content');
[...accordions].map(
()=> content.classList.toggle('isOpen')))``````

All of the buttons work now. But they all only open one of the accordions' contents. Is this because I used a querySelector for content?

@ezioda004
Aug 16 2018 12:55
@Supra01 Correct, if all the content have `.accordion-content` then you should use `.querySelectorAll()` instead. You'll need to modify the map method and add another argument `i` which is the index and help you loop through the `content`.
Something like this
``````var content = document.querySelectorAll('.accordion-content');
[...accordions].map(
()=> content[i].classList.toggle('isOpen')))``````
Supra01
@Supra01
Aug 16 2018 13:01
@ezioda004 Thank you again! That was tripping me up.
Jason Luboff
@JLuboff
Aug 16 2018 15:05
Morning :wave:
Tom
@moT01
Aug 16 2018 15:20
:poodle:
Jason Luboff
@JLuboff
Aug 16 2018 15:21
What up
Tom
@moT01
Aug 16 2018 15:21
gettin my butt kicked
Jason Luboff
@JLuboff
Aug 16 2018 15:21
Tom
@moT01
Aug 16 2018 15:22
seems like it shouldnt be too tough - just can't quite get it workin
Jason Luboff
@JLuboff
Aug 16 2018 15:23
Ah
Christopher McCormack
@cmccormack
Aug 16 2018 16:13
@moT01 I just implemented one of those a few days ago
also :wave:
Simon Cordova
@gbsimon87
Aug 16 2018 16:14
HEEEEY YO!
whats up whats up!
PLEASE someone tell me they're good with CSS animations
Christopher McCormack
@cmccormack
Aug 16 2018 16:15
@gbsimon87 Someone is!
Simon Cordova
@gbsimon87
Aug 16 2018 16:16
Oh man, just the man I need!
lolol
I'm going to write up a quick pen and explain my dilemma maybe you can help me figure it out
I truly think I'm overcomplicating it but whatevs...
Jason Luboff
@JLuboff
Aug 16 2018 16:17
What up guys
Chris
@crokita
Aug 16 2018 16:19
good afternoon
Simon Cordova
@gbsimon87
Aug 16 2018 16:19
whats up @JLuboff
and @crokita
Christopher McCormack
@cmccormack
Aug 16 2018 16:19
@gbsimon87 I hope you didn't imply that i did
I just said Someone is
Simon Cordova
@gbsimon87
Aug 16 2018 16:19
lololol
damn
lol
Jason Luboff
@JLuboff
Aug 16 2018 16:19
@gbsimon87 just working my man
Christopher McCormack
@cmccormack
Aug 16 2018 16:20
i've only done a couple and barely remember the sytnax haha
something to do with keyframes and percentages
Chris
@crokita
Aug 16 2018 16:20
adding a bunch of config environment options to this project
Simon Cordova
@gbsimon87
Aug 16 2018 16:21
Same I'm working away atm
This client wants some animation and I'm almost there but no cigar
Jason Luboff
@JLuboff
Aug 16 2018 16:22
Simon Cordova
@gbsimon87
Aug 16 2018 16:25
so was my ex but they didn't stop the kid
lol
Simon Cordova
@gbsimon87
Aug 16 2018 16:32
BTW I touch nothing but VS Code from yesterday on
Jason Luboff
@JLuboff
Aug 16 2018 16:32
Look at this rebel
Christopher McCormack
@cmccormack
Aug 16 2018 16:32
What did you used to use?
Simon Cordova
@gbsimon87
Aug 16 2018 16:37
Rebel with no cause!
I used to be all Sublime, but switched santeria and now VS Code is What I got
Yes, I should rest, omg
Good news is I finish work in 20 mins :)
Although I must admit I like it here, people are very nice and easy
Christopher McCormack
@cmccormack
Aug 16 2018 16:39
@gbsimon87 oh I get it it's a Sublime band pun :p
took me a minute haha
@gbsimon87 that's great man, can't ask for better
Jason Luboff
@JLuboff
Aug 16 2018 16:40
With puns that bad...you'll be giving your future kids a life full of embaressment
Simon Cordova
@gbsimon87
Aug 16 2018 16:41
HELL YEAH! I love em dad jokes
Ozarion
@Ozarion
Aug 16 2018 16:44
I think FCC's 4th Project in Apis and Microservices is broken. The "Excersice Tracker" one.
Christopher McCormack
@cmccormack
Aug 16 2018 16:44
@Ozarion the example?
it's not a very good example in our opinion
Jason Luboff
@JLuboff
Aug 16 2018 16:44
Ya the example blows lol
But I know an example that works great!
README.md says nothing and it has errors. :/
@JLuboff It's cool. Is it what I am supposed to create in the aforementioned project?
Jason Luboff
@JLuboff
Aug 16 2018 16:49
@Ozarion You don't need the third form necessarily, but otherwise, ya. Allow a user to create an username and then be able to add exercises and look them up later
Christopher McCormack
@cmccormack
Aug 16 2018 16:49
@JLuboff that's a nice one!
especially that awesome favicon
Jason Luboff
@JLuboff
Aug 16 2018 16:49
@cmccormack I thought so. Heard three amigo's built it
Ozarion
@Ozarion
Aug 16 2018 16:49
Yeah that favicon is dope. Took me 4 seconds to realize its not a blue bra.
Jason Luboff
@JLuboff
Aug 16 2018 16:51
The favicon looks like someone spent way too much time in Paint..
:P
Tom
@moT01
Aug 16 2018 16:51
wow, that's a good example @JLuboff
Ozarion
@Ozarion
Aug 16 2018 16:52

``````# Exercise Tracker REST API

#### A microservice project, part of Free Code Camp's curriculum``````

And I was like well, that's a lot of instructions.. XD

Christopher McCormack
@cmccormack
Aug 16 2018 16:52

That

Create Query to get Exercise Info

section is quite creative!

@Ozarion you can probably just look at the form and get a good enough idea what you need
There are no user stories or tests, just make a cool exercise tracker
Tom
@moT01
Aug 16 2018 16:52
definitely the best part @cmccormack
Ozarion
@Ozarion
Aug 16 2018 16:52
Yep. Gonna do that now.
That favicon is back from the times when alpha channel was not invented.
Christopher McCormack
@cmccormack
Aug 16 2018 16:53
but at least it's mobile ready!
@Ozarion (myself @JLuboff and @moT01 made that tracker ) :)
don't be too mean
Ozarion
@Ozarion
Aug 16 2018 16:54
Hell yeah. It's Responsive AF.
@cmccormack It's dope. :)
Jason Luboff
@JLuboff
Aug 16 2018 16:54
Responsiveness is credit to @cmccormack I believe
Christopher McCormack
@cmccormack
Aug 16 2018 16:55
yes and media query trickery!
Tom
@moT01
Aug 16 2018 16:55
just got an error from a `limit=0` query
Christopher McCormack
@cmccormack
Aug 16 2018 16:57
nits
@moT01 as Steve Jobs might say - you're holding it wrong
Jason Luboff
@JLuboff
Aug 16 2018 16:57
Hmmm...who would use 0 ;)
Christopher McCormack
@cmccormack
Aug 16 2018 16:58
quick pull request!
Jason Luboff
@JLuboff
Aug 16 2018 16:58
Interestingly...if you use a negative number... the validator gives an invalid date warning :joy:
Simon Cordova
@gbsimon87
Aug 16 2018 17:01
Home sweet home time
I'll catch you guys in half an hour
Christopher McCormack
@cmccormack
Aug 16 2018 17:03
@gbsimon87 later
Aug 16 2018 17:53
man how am I suppose to do audits that compare the new value with the old value.... Do I return the old value from the when updating? Or do I load it again? So many questions ug
Jason Luboff
@JLuboff
Aug 16 2018 18:02
Aug 16 2018 18:11
Yea, so in mongo I need it to return the old value (that was already in the database) when updating something, so when I "update it" I can compare the value I put in, with what was there, and make an audit
but, if I want to return the "newest" value I can't, unless I return the value I was passed
but I guess that should be fine
Jason Luboff
@JLuboff
Aug 16 2018 18:20
Ya.. sounds like you got it..
Aug 16 2018 18:37
I guess, I was told to just not return anything, since its not really needed
Jason Luboff
@JLuboff
Aug 16 2018 18:39
There you go
Christopher McCormack
@cmccormack
Aug 16 2018 19:10
@bradtaniguchi the value you were passed?
did you use `new: true`?
Aug 16 2018 19:12
I don't now since I need the old version, but I was thinking it would be nice to return the "new" version back to the client, right now I'm just passing something else (a message the update worked)
Diego Mayer
@Chrono79
Aug 16 2018 20:01
How I hate Google Analytics and non standar implementations
Fikry82
@Fikry82
Aug 16 2018 20:34
hi
i need help with filter()
Diego Mayer
@Chrono79
Aug 16 2018 20:43
Fikry82
@Fikry82
Aug 16 2018 20:52
i have an array arr i wanna filter it to get numbers > 0
Diego Mayer
@Chrono79
Aug 16 2018 20:53
Fikry82
@Fikry82
Aug 16 2018 20:54
``````const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
const squareList = (arr) => {
"use strict";
// change code below this line
const myArr;

const squaredIntegers = arr;
// change code above this line
return squaredIntegers;
};``````
i want all number >0 and not float
i cant use loop
Diego Mayer
@Chrono79
Aug 16 2018 20:56
Are you sure that's what you have to do there? The var names suggest you have to square all numbers there
Fikry82
@Fikry82
Aug 16 2018 20:56
Use arrow function syntax to compute the square of only the positive integers (fractions are not integers) in the array realNumberArray and store the new array in the variable squaredIntegers.
Diego Mayer
@Chrono79
Aug 16 2018 20:57
Ok, but filter only won't do it
You'll have to use map too
Fikry82
@Fikry82
Aug 16 2018 20:58
okay but i wanna know first how to use it
Moisés Man
@moigithub
Aug 16 2018 20:58
again ?? didnt u finished that yesterday ?
Fikry82
@Fikry82
Aug 16 2018 20:59
no i went to sleep ;)
Diego Mayer
@Chrono79
Aug 16 2018 20:59
``arr.filter(n => evaluate n here, if it's true, it's kept)``
Moisés Man
@moigithub
Aug 16 2018 20:59
Fikry82
@Fikry82
Aug 16 2018 21:01
n is argument ?
can i use array
Diego Mayer
@Chrono79
Aug 16 2018 21:01
yes, it's every element of the array
Fikry82
@Fikry82
Aug 16 2018 21:01
ohhh
so that filter go through all array element without need for loop
Diego Mayer
@Chrono79
Aug 16 2018 21:02
exactly, have you read mdn fliter doc?
Fikry82
@Fikry82
Aug 16 2018 21:03
yes but my bad English :)
so
Diego Mayer
@Chrono79
Aug 16 2018 21:03
you can change languages, maybe yours isn't there
Fikry82
@Fikry82
Aug 16 2018 21:04
var myArr = arr.filter(arr=> arr>0);
is that will give me new array with all >0 numbers ??
Diego Mayer
@Chrono79
Aug 16 2018 21:06
I would use n, num or a better var name inside filter
Fikry82
@Fikry82
Aug 16 2018 21:07
what's wrong ?
Diego Mayer
@Chrono79
Aug 16 2018 21:07
you have an array of numbers, why call the elements of the array arr too?
you'll only confuse yourself that way, and others that read your code too
It'll work, but it is a bad practice
It'll also shadow the arr var inside the filter
Fikry82
@Fikry82
Aug 16 2018 21:11
umm
allot of times i feel that i will not go any where with this
i am lost hahah
thx any way
Diego Mayer
@Chrono79
Aug 16 2018 21:14
It's easy, you don't call the people and pets in your house with the same name (if you do, well, I'm sure that'll be a nightmare), so when naming vars, use meaningfull names
When another coder or you in the future read your code will know what it does easily
Aug 16 2018 21:20

I remember helping someone who had a function that looked like this

``````function someFunc(a,b,d) {
//.. some basic code here
}``````

the code was like 5 lines of basic logic, but me AND HIM had no idea what the hell was going on.He said he kept the vars single and simple so he didn't have to type as much, but the amount of time just figuring out what was going on what totally went over the amount of time it would take to type out a meaningful name

Fikry82
@Fikry82
Aug 16 2018 21:24
most of times i think that i am too stupid to understand this >>> but i don't know why i don't give up and i keep coming back :)
``  const squaredIntegers = arr.filter(positive => positive > 0);``
is that look better
Aug 16 2018 21:27
Id consider grit to be one of the best attributes for a programmer. There shouldn't be a day where you go "Oh I understand EVERYTHING", cuse your either forgetting something, missing something, or arrogant :P.
most day's your going to be going "wtf is going on", regardless of what level you are XD
Fikry82
@Fikry82
Aug 16 2018 21:30
:)
``````const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
const squareList = (arr) => {
"use strict";
// change code below this line
const squaredIntegers = arr.filter(positive => positive > 0 && Number.isInteger(positive));
// change code above this line
return squaredIntegers;
};``````
can i have now array with integers > 0
Aug 16 2018 21:32
now you need to square the integers, as right now the squaredIntegers variable will contain just positive integers (they aren't squared)
Fikry82
@Fikry82
Aug 16 2018 21:32
so is that right :)
Diego Mayer
@Chrono79
Aug 16 2018 21:32
it's your naming, but I would go with number instead of positive (it could be negative and having a negative number in a var named positive is a little weird)
Aug 16 2018 21:34
yea I agree
Diego Mayer
@Chrono79
Aug 16 2018 21:35
``const positiveIntegers = arr.filter(number => number > 0 && Number.isInteger(number));``
Fikry82
@Fikry82
Aug 16 2018 21:35
okay
now how i will square that array without loop ?
Diego Mayer
@Chrono79
Aug 16 2018 21:36
with map
Fikry82
@Fikry82
Aug 16 2018 21:36
okay i will search it
thx @Chrono79 you are so cool :)
Diego Mayer
@Chrono79
Aug 16 2018 21:37
instead of using a truthy value, the returned value of the callback function "replaces" the current value
No problem :+1:
Jason Luboff
@JLuboff
Aug 16 2018 22:09
oh man...nothing like going into a meeting and having your manager walk out :joy:
Aug 16 2018 22:10
damn, sounds fun :D
Jason Luboff
@JLuboff
Aug 16 2018 22:11
Lol It's a project he was proposing for me that our boss wanted to discuss also and the scope blew up and my manager wasn't happy
Aug 16 2018 22:14
ah I see haha
Aug 16 2018 22:19
features features features, as always :P
Fikry82
@Fikry82
Aug 16 2018 22:21
``````const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
const squareList = (arr) => {
"use strict";
// change code below this line
const squaredIntegers = arr.filter(num => (num > 0 && Number.isInteger(num)));
squaredIntegers = squaredIntegers.map(sqr => sqr * 2);
// change code above this line
return squaredIntegers;
};``````
Jason Luboff
@JLuboff
Aug 16 2018 22:22
Shouldn't that be throwing an error?
You can't reassign a `const`
Fikry82
@Fikry82
Aug 16 2018 22:23
ohh yea
``````const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
const squareList = (arr) => {
"use strict";
// change code below this line
const squaredIntegers = arr.filter(num => (num > 0 && Number.isInteger(num)));
squaredIntegers.map(sqr => sqr * 2);
// change code above this line
return squaredIntegers;
};``````
Jason Luboff
@JLuboff
Aug 16 2018 22:25
your map function isn't being assigned to anything.
if anything, return that
Aug 16 2018 22:25
either use chaining, or a new variable
and the `const squaredIntegers = arr.filter` line is lying, they are just wholeIntegers, not squared ones right now
Jason Luboff
@JLuboff
Aug 16 2018 22:29
Good point, unless its chained then its not lying..as much
Fikry82
@Fikry82
Aug 16 2018 22:29
i dont know how to chain them >>> that new arrow thing
Jason Luboff
@JLuboff
Aug 16 2018 22:30
``````const squareList = (arr) => {
// change code below this line
return arr.filter(num => (num > 0 && Number.isInteger(num))).map(sqr => sqr * 2);
};``````
Fikry82
@Fikry82
Aug 16 2018 22:31
lol
just like that
Jason Luboff
@JLuboff
Aug 16 2018 22:31
I guess they don't want you to return that directly...but you could instead of returning there assign it to the variable
Fikry82
@Fikry82
Aug 16 2018 22:35
yes but still not working ??? !
``````const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
const squareList = (arr) => {
"use strict";
// change code below this line
const squaredIntegers = arr.filter(num => (num > 0 && Number.isInteger(num))).map(sqr => sqr * 2);

// change code above this line
return squaredIntegers;
};``````
Jason Luboff
@JLuboff
Aug 16 2018 22:35
What challenge is this?
Fikry82
@Fikry82
Aug 16 2018 22:36
Use arrow function syntax to compute the square of only the positive integers (fractions are not integers) in the array realNumberArray and store the new array in the variable squaredIntegers.
Jason Luboff
@JLuboff
Aug 16 2018 22:38
Oh...its becuase you aren't squaring anything
Fikry82
@Fikry82
Aug 16 2018 22:38
how ? what about map() ??
Jason Luboff
@JLuboff
Aug 16 2018 22:38
a sqaure is a number multipled by itself, not multipled by 2
Fikry82
@Fikry82
Aug 16 2018 22:38
zzzzzz
hahahahha
done
``const squaredIntegers = arr.filter(num => (num > 0 && Number.isInteger(num))).map(sqr => sqr * sqr);``
Jason Luboff
@JLuboff
Aug 16 2018 22:39
Yup
Fikry82
@Fikry82
Aug 16 2018 22:39
that new arrow thing is so great all that logic in one line wow
Aug 16 2018 22:40
I dislike variable naming in the map, your not squaring squares
Fikry82
@Fikry82
Aug 16 2018 22:40
Aug 16 2018 22:40
There is 1 cavet of this code too, performance wise you could go over all the numbers in the array twice in a worst case.
Fikry82
@Fikry82
Aug 16 2018 22:40
thanks @JLuboff
Jason Luboff
@JLuboff
Aug 16 2018 22:41
@bradtaniguchi Curious...do you normally use a name that makes sense for the element in map/filter/etc? I have a tendency to use `e` but will occasionally use something more discriptive
Aug 16 2018 22:42
I always usually name it what it is, but then my array names are also descriptive:
`const carModelNames = cars.map(car => car.model);`
I never use some small variable name, even if its a super simple case (like the line above)
but then I'm the OCD code quality nazi of my team XD
Jason Luboff
@JLuboff
Aug 16 2018 22:47
Fair enough
Aug 16 2018 22:50
There was one time when I was refactoring some code, and searched the whole project for a variable name, and It got most things, but not the elements in the method (I was using el), so things were broken and I had to hunt them down again
Jason Luboff
@JLuboff
Aug 16 2018 22:53
I do always worry when I chagne a class/id/variable name throughout my document lol
Whoo! I'm now officially "Systems Developer"
Aug 16 2018 22:58
nice :+1: and yea I worry about it a lot. The OCD in me would like to refactor my code all the time making sure there's no regressions
Jason Luboff
@JLuboff
Aug 16 2018 23:00
Ya...as much as I want to say I'm done with this current project...I'm sure I'm going to constantly want to change things..
Like.. I made all my routes use async/await..but my queries are still promises.. so I could switch those..
Aug 16 2018 23:48
defiantly nice to have testing in at that point, start making things elegant AF :P
Jason Luboff
@JLuboff
Aug 16 2018 23:59
I need to learn how to setup tests :worried: