18th
Jan 2018
Kent Saeteurn
@sansae
Jan 18 2018 00:34

Hello all. I'm currently working on "Map the Debris" under Advanced Algorithm Scripting.

Can anyone tell me how to correctly round the results? I think my code is correct (for finding the orbital period and returning it as a hash nested inside an array), however, rounding the orbital period is off. It seems freecodecamp is using different rounding techniques?

for example, for sputnik, the result is 86397.158, and they round it off to 86400 (I can write the code to round it off this way)
however, for iss, the result is 5557.034, and they round it off to 5557 (I can also write the code to round it off this way as well)
further, for hubble, the result is 5733.86, to which they round off to 5734.

I'm confused. How exactly should I round off the results here? The instructions says to round off to the nearest whole number. The nearest whole number for 86397.158 to me is 86397, but they rounded off to 86400.

Can anyone help?
TIA

Rajat Parajuli
@rjpj2016
Jan 18 2018 03:32
hey guys!
Need some help
How do I transition display: none to display: block
ehutchllew
@ehutchllew
Jan 18 2018 03:51
@rjpj2016 you can't transition a display
@rjpj2016 would have to be visibility
plus mess with the dimensions
Rajat Parajuli
@rjpj2016
Jan 18 2018 04:02
I transitioned max-height.
@ehutchllew Thanks !
CamperBot
@camperbot
Jan 18 2018 04:02
rjpj2016 sends brownie points to @ehutchllew :sparkles: :thumbsup: :sparkles:
Jan 18 2018 04:55
@sansae - I just used Math.round on the result of the calculation? I think that it worked just fine.
Jan 18 2018 05:06
@sansae - if you are still having problems, could you post your code? I just re-checked and my solution is returning the correct answers using only Math.round.
Kaz Baig
@kbaig
Jan 18 2018 06:33

Interesting JS snippet making the rounds:

const a = {};
a.abuseCoercion = 0;
a.valueOf = function() {
this.abuseCoercion++;
return this.abuseCoercion;
}

console.log(a == 1 && a == 2 && a == 3); // true

It was from an interview question asking, "Can (a == 1 && a == 2 && a == 3) ever evaluate to true?"

amoraptor91
@amoraptor91
Jan 18 2018 06:34
const are block-scoped
and i think might it will give an error like a is not defined
Kaz Baig
@kbaig
Jan 18 2018 06:35
How is block scoping relevant here?
amoraptor91
@amoraptor91
Jan 18 2018 06:35
can someone look it for????
Kaz Baig
@kbaig
Jan 18 2018 06:35
This is all happening within the same block
I'm saying the above is an example condition where the logged statement evals to true
Muhammed Hafiz
@zifahm
Jan 18 2018 06:42
@kbaig how does it work?
aRtoo
@artoodeeto
Jan 18 2018 06:46
why is it i cant use transform:translateX if i use transform:translateY
check codepen https://codepen.io/artoo/pen/opQZWy
im trying to copy this img
https://lh4.ggpht.com/ojUTDJE8KGMLBGfsejho_vhZW-a2RCSz_3mclXbZOWUBtz5tfD7UELr4pn2A4NN0cQw=w300
Linus
@nusli
Jan 18 2018 06:52
@zifahm When an object is used in comparison with a number the JS engine first calls the object‘s „valueOf“ method. In this case it first returns „1“ and on the second comparison is called again, returning „2“
Markus Kiili
@Masd925
Jan 18 2018 07:03
@zifahm Abstract equality algorithm uses an internal ToPrimitive function on the object on the left side which coerces the object into a primitive value. It calls the valueOf method it is exists and toString method if valueOf doesn't exist. Here it uses valueOf like @nusli said.
Sorin Ruse
@sorinr
Jan 18 2018 07:15
@artoodeeto you may use in css #center :
margin: 0 50% 50%;
transform: translate(-25px, -25px);
aRtoo
@artoodeeto
Jan 18 2018 07:23
@sorinr let me try bro thanks
CamperBot
@camperbot
Jan 18 2018 07:23
artoodeeto sends brownie points to @sorinr :sparkles: :thumbsup: :sparkles:
:star2: 1392 | @sorinr |http://www.freecodecamp.org/sorinr
aRtoo
@artoodeeto
Jan 18 2018 07:24
@sorinr bro it worked!! the fuck!! how tho?
Sorin Ruse
@sorinr
Jan 18 2018 07:27
@artoodeeto so, you needed to push the center from the margins by 50% and translate it x and y by half of height and width (50px) and thats it -25px. ofc if you make the center lets say 100px you would need to chage the -25px into -50px
aRtoo
@artoodeeto
Jan 18 2018 07:29
@sorinr for the margin i tried 0% 50%`` too and doing the adjustment for thetranslateX and translateY``` but its canceling out. but htanks bro
Sorin Ruse
@sorinr
Jan 18 2018 07:32
@artoodeeto here how should look in css your#center:
#center{
background: black;
height: 50px;
width: 50px;
position: absolute;
z-index: 100;
margin: 0 50% 50%;
transform: translate(-25px, -25px);
}
VaseJS
@VaseJS
Jan 18 2018 07:37
display: flexbox. justify-content: center. boom
Sorin Ruse
@sorinr
Jan 18 2018 07:38
@VaseJS yes i know but i usually don't modify the code. only trying to suggest a solution based on what already have
VaseJS
@VaseJS
Jan 18 2018 07:39
i have no idea whats going on. i just saw code :P
jimmy · YIN
@jimmyYSY
Jan 18 2018 10:03
hi
shafiiprince
@shafiiprince
Jan 18 2018 12:18
hi all
I am new here!
I want to know about Java script references for API's
Markus Kiili
@Masd925
Jan 18 2018 12:19
@shafiiprince Wellcome!
shafiiprince
@shafiiprince
Jan 18 2018 12:19
hey markus! how r u?
Markus Kiili
@Masd925
Jan 18 2018 12:19
What API's are you talking about?
Fine, thanks.
shafiiprince
@shafiiprince
Jan 18 2018 12:20
I have a project to create random qoutes machine
Markus Kiili
@Masd925
Jan 18 2018 12:21
@shafiiprince You learn the most by finding an quote api and making an ajax request from the JS to get the quote(s).
Kaz Baig
@kbaig
Jan 18 2018 15:15
@zifahm As the abuseCoercion property name suggests, you're basically using a hack to make it so that every time you check the "value" of a, it goes up. Using == instead of === is also vital here because, as you can see, a is actually an object, not a number
co083121
@co083121
Jan 18 2018 19:44
hello all, does freecodecamp have any graphic designers involved? i need some graphic design help
Alan M.
@Am3ra
Jan 18 2018 19:54
Hey all, anyone up for "No repeats please"?
G-4-R-Y
@G-4-R-Y
Jan 18 2018 21:11
hey guys, can someone give me a little hand with "Wherefore art thou"? Im kinda stuck for a while now and I tried to just make an "exercise specific" code to solve the problem, but it also didn't work.
here's the code:
for (var i = 0; i < collection.length; i++) {
if (collection[i].last == source.last) {
arr.push(collection[i]);
}
else if (collection[i].a == source.a && collection[i].b == source.b) {
arr.push(collection[i]);
}
else {
arr.push(collection[i]);
}
}
Markus Kiili
@Masd925
Jan 18 2018 21:14
@G-4-R-Y You need a second nested loop or iteration over source's property keys. Then you need logic that keeps those objects that have matching property values with source for all the source's keys.
G-4-R-Y
@G-4-R-Y
Jan 18 2018 21:16
but im getting the source's properties that I need with dot notation
like, it isn't necessary to iterate through them
Markus Kiili
@Masd925
Jan 18 2018 21:17
@G-4-R-Y Those keys change from test case to test case.
Kaz Baig
@kbaig
Jan 18 2018 21:17
@G-4-R-Y The way you're doing it now is looking at the tests to build the solution. You need to make it in a more generic way, where I could pass in anything valid
Markus Kiili
@Masd925
Jan 18 2018 21:18
@G-4-R-Y Yeah, the description doesn't say anything about what the keys are.
i.e the solution needs to work with any source keys.
G-4-R-Y
@G-4-R-Y
Jan 18 2018 22:04
I know that and wrote that down when asking for help lol
but ill try it out with some more generic ways again
aka the correct way
hensn5250
@hensn5250
Jan 18 2018 22:13
@G-4-R-Y still need help?
Petru Alin Gheorghe
@palingheorghe
Jan 18 2018 23:32
Hi guys!
Idowu Wasiu
@Hoxtygen
Jan 18 2018 23:40
@palingheorghe hello
it's kinda calm in here
Petru Alin Gheorghe
@palingheorghe
Jan 18 2018 23:44
uys.. How long should take me to learn some basic react?
Idowu Wasiu
@Hoxtygen
Jan 18 2018 23:46
@palingheorghe not sure anyone can put a standard timeline to that, we all learn at a different rate. what takes you 5 mins to learn may take someone else a whole day
Petru Alin Gheorghe
@palingheorghe
Jan 18 2018 23:49
yeah, i know, but I.m curious about the average time
Peh Hui Shi
@pehhuishi
Jan 18 2018 23:49
Good Morning, I’m a new to web development. I love to learn React. But my Javascript is not strong yet. Any advice I can learn React n Javascript at the same time?
Petru Alin Gheorghe
@palingheorghe
Jan 18 2018 23:49
someone needs to learn react
Idowu Wasiu
@Hoxtygen
Jan 18 2018 23:50
@palingheorghe can't help there as i havent gone into react myself
@pehhuishi you wanna learn crawl and walk at the same time?
@pehhuishi web development is a marathon not a sprint, you take one step at a time, slow and steady.
Peh Hui Shi
@pehhuishi
Jan 18 2018 23:52
@Hoxtygen 😅
Is there any site you all know where to start basic React?
Which you all had tried before. 😬😬
alpox
@alpox
Jan 18 2018 23:53
@pehhuishi I strongly suggest to get fluent in basic javascript before going react. Otherwise it aint gonna work.
Idowu Wasiu
@Hoxtygen
Jan 18 2018 23:53
Petru Alin Gheorghe
@palingheorghe
Jan 18 2018 23:53
what are u using ?
alpox
@alpox
Jan 18 2018 23:54
@pehhuishi You will not be able to understand whats going on in react unless you know javascript well enough
Peh Hui Shi
@pehhuishi
Jan 18 2018 23:54
@alpox okay I will brush up on my basic Javascript. Thank you for advice
CamperBot
@camperbot
Jan 18 2018 23:54
pehhuishi sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1522 | @alpox |http://www.freecodecamp.org/alpox
Peh Hui Shi
@pehhuishi
Jan 18 2018 23:56
@Hoxtygen okay. Thank you. I will brush up my Javascript before dive in React.
CamperBot
@camperbot
Jan 18 2018 23:56
pehhuishi sends brownie points to @hoxtygen :sparkles: :thumbsup: :sparkles: