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.

Math.random() not working in Chrome

See original GitHub issue

Challenge Generate Random Fractions with JavaScript has an issue. User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36. Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

function myFunction() {

  // Only change code below this line.

  return Math.random();

  // Only change code above this line.
}

not working in Google Chrome but worked fine in Safari

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vlory73commented, Apr 2, 2016

it just seemed that Math.random() wasn’t doing anything.

i was writing “return Math.random();” and nothing happened. Went to Safari and I was able to finish the exercise.

On 02 Apr 2016, at 19:42, Eric Leung notifications@github.com wrote:

@vlory73 https://github.com/vlory73 can you give more details on what kind of errors are you getting? Or like how did you find out it was not working on Chrome?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/FreeCodeCamp/FreeCodeCamp/issues/7859#issuecomment-204764646

0reactions
vlory73commented, May 19, 2017

@vekatobias maybe the code is wrong. I probably would do it differently today. But today I have substantial more experience than back then. Also, the intended solution of the exercise was this. In the end, it boils down to Safari working, whereas Chrome did not. I don’t mind that this is not addressed. In fact, I’m happy that raising it already helped a couple of people .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is Google Chrome's Math.random number generator not ...
Apparently Math.random() in V8 only works with 32 bit values (and didn't even correctly randomize all of those in the past). And with...
Read more >
Google Chrome functions finally return actual random numbers
Math.random() was broken for years, but Google has finally fixed it.
Read more >
r/javascript - Math.random() is broken in V8/Chrome/Node
I don't understand the problem. The most likely outcome of a short "Math.random() is broken for me, plz fix" bug report is a...
Read more >
Math.random() - JavaScript - MDN Web Docs
The Math.random() function returns a floating-point, pseudo-random number that's greater than or equal to 0 and less than 1, with approximately uniform ...
Read more >
Overwrite Standard Math.random() Function - Google Groups
The problem is that it isn't overwriting * the function prior to its initial execution. */ function main () { // ... Math.random...
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