An warware: bazuwar lamba 0 zuwa 3

Babban matsala tare da lambar bazuwar 0 zuwa 3 shine cewa ba da gaske ba ne. Wannan yana nufin cewa lambobin ba su da cikakkiyar tsinkaya, kuma wanda ya san tsarin zai iya yin annabta.

Math.floor(Math.random() * 4);

Wannan layin lambar yana samar da lambar bazuwar tsakanin 0 da 3.

Misalai tare da aikin bazuwar

var bazuwar = aiki () {komawa Math.random (); }; // Yana mayar da lamba tsakanin 0 da 1

Shafi posts:

Leave a Comment