일단 해보는 코딩/Java Script
[JavaScript] 인수와 매개변수, 함수 종료 (간단 정리)
eun_zoey2
2023. 4. 30. 19:24
728x90
■ 인수와 매개변수 - 함수 사용할 때마다 조금씩 다르게 동작
function hello(name) {
const message = 'hello ' + name + '!'
console.log(message)
}
hello('world')
hello('Jaeeun')
hello('Jen')
■ 함수 종료 - 원하는 부분에서 함수의 동작을 종료
function hello(name) {
if(name.length > 5){
return
}
const message = 'hello ' + name + '!'
console.log(message)
}
hello('world')
hello('Jaeeun')
hello('Swon')