1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【JavaScript】文字を整数に変える合言葉

Last updated at Posted at 2023-03-02

その名も…parseInt()

Saasのプログラム書いているスキマにスキルを身につけようとpaizaラーニングを始めました。
初心にかえり、基礎からやっていますが独学でやっていたツケが回ってきたのか、初めて知ることも多く勉強になります:pray_tone1:
リンク ➡ https://paiza.jp/

中でもスキルチェックにお熱で…ついさっきまで詰んでいたのが、
入力された配列の足し算!
簡単そうに見えて意外と沼でした:fearful:

paizaでの入力値って縦表記なうえに文字列:scream_cat:
1
2
3
こんな感じ。

いくら足し算してもNanであしらわれます。。。

めっちゃ探しに探した結果、parseInt(数値にしたいヤツ) これだけ;;

これだけでやりたいこと全て叶っちゃいました:hugging::sparkles:

何ならfor文で出力した値も計算できるっ!完璧:clap:

1
0
5

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?