LoginSignup
0
1

More than 3 years have passed since last update.

概要

日付と税込み価格をアラートで表示

日付を取得

index.js
function date (){
        const dd =  new Date;
        const year = dd.getFullYear();
        const month = dd.getMonth() +1;
        const d = dd.getDate();
        const mon = [year,month,d];
        console.log(mon);
        return mon;

      }

①ddに現在日時を保存
②現在日時をそれぞれyear,month,d,にメソッドで変更します。
 *Monthは海外では文字列(sundeyとか)ですが、日本では1~12月で表されます。その都合で、0始まりになっています。なので、呼び出すときは、+1をします。1を足し忘れると−1月で表示されました。
③それらデータをまとめてリターンするので、配列にします。

アラートで表示

index.js
    const m = date();
      const sub = totalTax();

      const win =[m,sub];

      window.alert(win);

そして今回の目的は、taxと日時をアラートで出したいので、配列にします。

配列

データを一列に並べたものです。
配列として1つの定数に保存することで、大量のデータを扱うことができます。

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