Вопрос

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