Answers for "how to get a random num within a range in java"

3

how to return a random number from a list in dart

import "dart:math";

void main() {
 var list = ['a','b','c','d'];
    var element = getRandomElement(list);
    print(element);  
}


T getRandomElement<T>(List<T> list) {
    final random = new Random();
    var i = random.nextInt(list.length);
    return list[i];
}
Posted by: Guest on May-21-2020
37

javascript get random number in range

function getRandomNumberBetween(min,max){
    return Math.floor(Math.random()*(max-min+1)+min);
}

//usage example: getRandomNumberBetween(20,400);
Posted by: Guest on July-23-2019

Code answers related to "how to get a random num within a range in java"

Code answers related to "Javascript"

Browse Popular Code Answers by Language