[backend][nodejs] Add decision maker with hardcoded decisions A,B,C
This commit is contained in:
23
backend/nodejs/random-decision.js
Normal file
23
backend/nodejs/random-decision.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const random = require('random');
|
||||
|
||||
class Choice {
|
||||
constructor(name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
const choices = [
|
||||
new Choice('A'),
|
||||
new Choice('B'),
|
||||
new Choice('C')
|
||||
];
|
||||
|
||||
exports.getRandomChoice = () => {
|
||||
return choices[random.int(0, choices.length - 1)];
|
||||
}
|
||||
|
||||
exports.choices = choices;
|
||||
Reference in New Issue
Block a user