리턴값이 있는 함수
return 문은 함수에서 결괏값을 반환할 때 사용합니다.
리턴값이 있는 함수
function(함수 이름){ //실행 코드 return 리턴값; } let 변수 = 함수명( ); //함수 호출
function func4(){
let str = "함수를 실행하였습니다.";
return str; //return은 결과
}
let value = func4();
document.write(value);매개변수 + 리턴값
function func5(num1, num2){
return num1 + num2;
}
let resulf = func5(100,200);
document.write(resulf); // 300리턴값이 있는 함수(결과)
function func5(){
let str = "함수가 출력되었습니다5.<br>";
return str;
}
let value = func5();
document.write(value);
// 함수가 출력되었습니다5.리턴값이 있는 함수(종)
평균 구하기
배열 + 함수 + 평균
이미지 슬라이드
Last updated
Was this helpful?