0

Question about Math.random

How do you get a random number between -100 and +100?

5th May 2020, 3:31 PM
Robin Flickinger
Robin Flickinger - avatar
5 Antworten
+ 2
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 yea sure but i am still in the beginning of learning programming.. so i don't understand your answer with random import randint and stuff 😅😅😅
5th May 2020, 6:42 PM
Robin Flickinger
Robin Flickinger - avatar
+ 1
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 Martin Taylor And what about creating a second Math.random and subtract it with the first Math.random? Would it be a legit opportunity?
5th May 2020, 6:38 PM
Robin Flickinger
Robin Flickinger - avatar
+ 1
Because I had an exam today and the question was how do u get random numbers between -100 and +100 And my answer was that u could generate a second Math.random and subtract them
5th May 2020, 6:40 PM
Robin Flickinger
Robin Flickinger - avatar
+ 1
number = Math.random()*200 - 100;
6th May 2020, 5:46 PM
mr sha
+ 1
Ohhh ok now i understand, thank you very much, now i realize that my answer in the exam was wrong 😅 That makes perfectly sense And yea sorry i forgot to include the language, thanks for the advise 😉 Martin Taylor
6th May 2020, 7:56 PM
Robin Flickinger
Robin Flickinger - avatar