Skip to content

Commit

Permalink
戻り値のある関数
Browse files Browse the repository at this point in the history
  • Loading branch information
ura-hasam committed Jul 23, 2024
1 parent b1691a4 commit 2e8bd7a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
14 changes: 6 additions & 8 deletions js/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
"use strict";
function sum(...nums) {
let total = 0;
for (let num of nums) {
total += num;
}
console.log(`合計は${total}です`);
function getTriArea(base, height) {
let area = 0;
area = base * height / 2;
return area;
}
sum(1, 2, 3, 4);
sum(5, 10);
let menseki = getTriArea(4, 3);
console.log(`面積は${menseki}です`);
15 changes: 7 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
function sum(...nums:number[]):void{
let total =0;
for(let num of nums){
total +=num;
}
console.log(`合計は${total}です`);
function getTriArea(base:number,height:number)
:number{
let area:number=0;
area=base*height/2;
return area;
}
sum(1,2,3,4);
sum(5,10);
let menseki=getTriArea(4,3);
console.log(`面積は${menseki}です`);

0 comments on commit 2e8bd7a

Please sign in to comment.