LoginSignup
0
0

More than 3 years have passed since last update.

javascript 問題集 No.12数値検査(Number型の禁止)

Posted at

コマンド引数の3桁の数字の中に0~9以外のものが含まれていたらfalseする問を解きました。

初めはコマンド引数をfor文で回して0~9ならture
間違えていたらfalseにしようと考えていました。
けどコードが長くなり不満。。。

そこで考えたのは、初めからtureと定義して、もし0~9でなければfalseという考え方。

このやり方なら、for文とif文一つずつで解くことができます。

0
0
1

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