LoginSignup
0
0

More than 3 years have passed since last update.

javascri 問題集No.15 0埋め~年月日を20000707の形にする。~

Posted at

const number =(' ')
↑この中に入れてstringに変えていきます。

const number =(${year}${month}${day})

この年月日を変えていきます。

const number =(${0000+year.slice(4)}${month}${day})

このような形ですね。

.slice(-length)-をする意味は 00+2 の時 002となり、必要な部分を抜き取るためです。
002.slice(-2)は 02 になります。

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