markdown js_cc_02_practice_if_advanced

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown js_cc_02_practice_if_advanced相关的知识,希望对你有一定的参考价值。

    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).

以上是关于markdown js_cc_02_practice_if_advanced的主要内容,如果未能解决你的问题,请参考以下文章

markdown js_cc_02_practice_if_advanced

markdown js_cc_05_practice_func_elementary

markdown js_cc_04_practice_array_advanced

markdown js_cc_04_practice_array_intermediate

markdown js_cc_04_practice_array_elementary

markdown js_cc_01_practice_operator_intermediate