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.

Similar code written in different style gives error!!

See original GitHub issue

Challenge [Generate Random Whole Numbers with JavaScript](https://www.freecodecamp.com/challenges/generate-random-whole-numbers-with-javascript User Agent is: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36. Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:


var randomNumberBetween0and19 = Math.floor(Math.rando

m() * 20);

function randomWholeNum() {

  // Only change code below this line.
  var rand = Math.random() * 10;
  return Math.floor(rand);
 // return Math.floor(Math.random() * 10); //works fine
//but above doesn't work
}

screen

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
ranaparthcommented, May 13, 2016

@raisedadead Yes, I have tested the code many times.

1reaction
raisedadeadcommented, May 12, 2016

@ranaamritparth Just to confirm you have tested this :

var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {
  // Only change code below this line.
  var rand = Math.random() * 10;
  return Math.floor(rand);
}

The original description has some code that can give a false positive.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The 7 Most Common Types of Errors in Programming and ...
Runtime Errors​​ Runtime errors happen as a user is executing your program. The code might work correctly on your machine, but on the...
Read more >
The code formatting problem, and how to solve it - Medium
The solution to the code formatting problem is this: every programming language should have one, and only one, valid way to format code....
Read more >
Types of Errors in Java with Examples - GeeksforGeeks
Syntax errors are grammatical errors whereas, logical errors are errors arising out of an incorrect meaning. For example, if a programmer ...
Read more >
Fix the top 10 most common compile time errors in Java
Example of an 'unreachable code' error, one of several common Java compile errors. 1. Class and source file mismatch. The name of the...
Read more >
Java Software Errors: How to Avoid 50 Code Issues in Java
We've rounded up 50 of the most common Java software errors, complete with code examples and tutorials to help you work around common...
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