Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,193,776 members, 7,952,187 topics. Date: Wednesday, 18 September 2024 at 12:01 PM

Try This,programmers - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Try This,programmers (353 Views)

I'm Leaving Nairaland But Not Without A Gift For ALL Programmers! / See Money Making Programmers In Nairalans / Benefits Of The Improvements Made On Forum4africa - Programmers (2) (3) (4)

(1) (Reply) (Go Down)

Try This,programmers by NDSMELODY(m): 2:21pm On Jul 31, 2021
Write a program that would roll a dice using any programming language
Re: Try This,programmers by Karleb(m): 6:58pm On Jul 31, 2021
Store 1 to 6 in an array and shuffle it. Pop out any index then repeat.


let numbers = [1, 2, 3, 4, 5, 6];

function shuffle(numbers) {
return numbers.sort(() => Math.random() - 0.5);
}
alert(shuffle(numbers).pop());

I had a little help. wink
Re: Try This,programmers by NDSMELODY(m): 8:53pm On Jul 31, 2021
Karleb:
Store 1 to 6 in an array and shuffle it. Pop out any index then repeat.


let numbers = [1, 2, 3, 4, 5, 6];

function shuffle(numbers) {
return numbers.sort(() => Math.random() - 0.5);
}
alert(shuffle(numbers).pop());

I had a little help. wink
I guess you used python pl,but for I used java pl

Re: Try This,programmers by spartan117(m): 11:14pm On Jul 31, 2021
JavaScript

const randomNumber = () => Math.floor(Math.random()*6 +1)

(1) (Reply)

How To Manage Burnout And Depression As A Developer / Instagram Sorry For Blocking User Named Metaverse / Android Development Tutorial For Learning java

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.