₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,429 members, 8,421,920 topics. Date: Sunday, 07 June 2026 at 10:25 AM

Toggle theme

Try This,programmers - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingTry This,programmers (403 Views)

1 Reply (Go Down)

Try This,programmers by NDSMELODY(op): 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(op): 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

Python Programmers Lets Meet Here!!!Programmers, Please Recommend A Good Laptop For Me.Please Is There A Place In Benin City Where Programmers Meet Everyday?234

You Would Have Made N14M naira Today For Free If You Had 1 Bitcoin Last WeekHow To Screen Record On Ios 11 And LaterCredits And Thrifts App