LoginSignup
1
0

More than 3 years have passed since last update.

JavaScript コンソール に 掛け算 割り算 あまりのみ を 出力する ~console.log(数値 符号 数値);~

Posted at

目的

  • JavaScript 掛け算/割り算結果をコンソールに出力する方法を知る。

押さえるポイント

  • 掛け算を行う時の符号は*
  • 割り算を行う時の符号は/
  • 割り算のあまりを出力するときの符号は%

書き方の例

  • 下記に計算の汎用的な処理を記したJavaScriptの内容を記載する。
# 計算結果をコンソールに出力する処理
console.log(数値 計算符号 数値);

より具体的な例(掛け算)

  • 下記に3×7の結果をコンソールに出力する処理を記したJavaScriptの内容を記載する。
console.log(3 * 7);

より具体的な例(割り算)

  • 下記に6÷3の結果をコンソールに出力する処理を記したJavaScriptの内容を記載する。
console.log(6 / 3);

より具体的な例(割り算のあまり)

  • 下記に9÷2の結果のあまりをコンソールに出力する処理を記したJavaScriptの内容を記載する。
console.log(9 % 2);
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0