1
0

More than 1 year has passed since last update.

Javascript_関数を作る

Last updated at Posted at 2022-05-01

はじめに

このページは初学者のメモ書きです。

参考

Progate JavascriptⅢ

内容

関数を作る時の書き方①
const 定数名 = function(引数){
  関数の中身を書く;
}
関数を作る時の書き方②
const 定数名 = (引数) =>{
  関数の中身を書く;
}
関数で処理した値を返す
const 定数名 = () =>{
  return ;
}
戻り値をつかう例
const half = (number) => {
  return number / 2;
};

const result = half(130);

console.log(`130の半分は${result}です`);

half関数に入れた数字の半分を出力した。

引数は複数設定することもできる

引数複数
const half = (number1,number2) => {
  return number1 / number2;
};

const result = half(130,20);

console.log(`${result}です`);

簡単な関数を作れるようになった。

1
0
2

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