var rand1 = Math.floor(Math.random() * 3);
var rand2 = Math.floor(Math.random() * 3);
var rand3 = Math.floor(Math.random() * 3);
var max = Math.max(rand1, rand2, rand3);
document.write('<p>rand1: ' + rand1 + '</p>');
document.write('<p>rand2: ' + rand2 + '</p>');
document.write('<p>rand3: ' + rand3 + '</p>');
if (rand1 === rand2 && rand1 === rand3 ) {
document.write('<p>3つは同じ値です</p>');
} else {
if (max === rand1 && rand1 === rand2) {
document.write('<p>一番値が大きいのはrand1とrand2です</p>');
} if (max === rand1 && rand1 === rand3) {
document.write('<p>一番値が大きいのはrand1とrand3です</p>');
} if (max === rand2 && rand2 === rand3) {
document.write('<p>一番値が大きいのはrand2とrand3です</p>');
} else {
if (max === rand1 && max != rand2 && max != rand3) {
document.write('一番値が大きいのはrand1です');
} else if (max === rand2 && max != rand1 && max != rand3) {
document.write('一番値が大きいのはrand2です');
} else if (max === rand3 && max != rand1 && max != rand2) {
document.write('一番値が大きいのはrand3です');
}
}
}
js_cc_02_practice_if_advanced
-----------------------------
A [Pen](https://codepen.io/m-shinkawa/pen/yEYKKQ) by [m-shinkawa](https://codepen.io/m-shinkawa) on [CodePen](https://codepen.io).
[License](https://codepen.io/m-shinkawa/pen/yEYKKQ/license).