0
0

More than 3 years have passed since last update.

progate java L1基本まとめ cosole.log,変数と定数の違い、if文

Posted at

console.log

console.log();と使う
コンソール上に()内を表示させる
注意点として文字列を表示させたい場合はconsole.log("")のように文字列を""で囲む

○ console.log("あいうえお") ⇨ あいうえお と表示される
× console.log(あいうえお) ⇨ referenceエラーになる

値の宣言 変数letと定数const

値を宣言する場合、letまたはconstで宣言する

let numberA = 1;
const numberB = 2;

この2つには違いがあり、letは更新できるがconstは更新できない

値の更新

変数は値を更新することができる
let numberA = 1;
この時点ではnumberAは1だが、

numberA = 10;
これでnumberAはではなく10になる

if文

if(条件){処理}←セミコロンは付けない
(条件)を満たした場合に{処理}が実行される

条件の例
a>=b aは以上
a<b aはbより下

さらに条件を追加するときはelse ifを使う
else if(条件){処理}←セミコロンは付けない

条件を満たさない場合に処理を行う場合はelseを使う
ifやelseifの条件に全て当てはまらない場合、elseの処理が実行される
else{処理}

0
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
0
0