JSFiddle - React, Tailwind, and code Playground
by huston007
JavaScript
(function(rnd, userChoice){
var choices = ["б","к","н"],
compareResult = rnd - choices.indexOf(userChoice);
Math.abs(compareResult) == 2 && (compareResult = -compareResult);
alert(choices[rnd] + userChoice +":"+ compareResult);
})(~~(Math.random()*3), prompt("б,к,н"))