question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Corrections to the article "10 JavaScript Hacks Every Web Developer Should Know"

See original GitHub issue

several corrections to the article at https://www.freecodecamp.org/news/javascript-hacks/

x-post from FCC forum, as per support-reply

1.

math.round(math.random*50)

Uncaught ReferenceError: math is not defined

the keyword is Math, first letter is upper-cased and its method is .random(), with brackets at the end

2.

equating Math.round to ~~

// instead of
math.round(math.random*50)
// use
~~(math.random*50)

~~ acts the same as Math.floor, since its “~” twice – bitwise inversion two times, decimal part just falls off, as it can only be apllied to integer numbers, and floats are converted on first inversion

3.

You can also use filter() together with Boolean to return all null or undefined values from your array.

no, its literally the opposite. only truthy elements will be returned.

37e0b8d1818dc81862515c9ae0ea6d7dd62bc058

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
AbbeyRenncommented, Jan 26, 2021

Thank you @dym-sh @RandellDawson @scissorsneedfoodtoo I’ve emailed the author so he can make the remaining corrections 👍

0reactions
scissorsneedfoodtoocommented, Jan 27, 2021

The author made some updates and I worked on some additional formatting and wording issues.

Thanks for reporting this @dym-sh. Please let us know if you notice anything else in this or other articles.

Read more comments on GitHub >

github_iconTop Results From Across the Web

10 JavaScript Hacks Every Web Developer Should Know
1. How to Use Shortcuts for Conditionals. JavaScript allows you to use certain shortcuts to make your code easier on the eyes. ·...
Read more >
10 JavaScript hacks that developers should know - Medium
In this article, I will share some JavaScript hacks that can be very useful for you, whether you are starting out as a...
Read more >
10 HTML5 Hacks Every Web Developer Should Know - DZone
In this article, we discuss 10 HTML5 every web developer should know in order to optimize basic elements of their pages more effectively....
Read more >
10 JavaScript Tricks Front End Developers Should Know in ...
1. ?? · 2. ?. · 3. On-demand loading using dynamic import () (optimizing static import) · 4. Simplifying async functions with top-level...
Read more >
Hacks Every Web Developer Should Know in 2022 - YouTube
... know ⚡ Get in touch: https://twitter.com/ZaurbekStark▭▭▭▭▭ RECOMMENDED VIDEOS ▭▭▭▭▭➜ 8 Years of Coding in 10 Minutes: htt...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found