سؤال

How do I use arc4random in JavaScript? I tried to use var randomNumber = (arc4random() % 83) + 1; but I got UncaughtReferenceError: arc4random is not defined. I am not sure which libs to include to use arc4random.

هل كانت مفيدة؟

المحلول

I do not believe it possible, given all research points to the fact that arc4random is not a js function, but one built in to objective-c, or ios. I'm beginning to believe you did little research into the matter. Even the tag wiki entry on SO says as much.

نصائح أخرى

arc4random() is not defined in JavaScaript. To generate random numbers in JavaScript you can use Math.random(). But I think you can easy emulate arc4random() as:

function arc4random(){
  return Math.random()*4294967296;
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top