본문 바로가기

자바스크립트

[JavaScript] 36. Functions Calling Other Functions

A함수 내부에 B함수를 호출할 수 있다.

굳이 이렇게 포함시키는 이유는, 수정할 때 A, B 둘다 수정하지 않고 한 번에 A만 수정하면 되도록 하기 위함이다.

 

function cutFruitPieces(fruit){
	return fruit * 4;
}

function fruitProcessor(apples, oranges){
	const applePieces = cutFruitPieces(apples);
	const orangePieces = cutFruitPieces(oranges);
	
	const juice = `Juice with ${applePieces} piece of apple and ${orangePieces} pieces of orange.`;
	return juice;
}

www.udemy.com/course/the-complete-javascript-course/

 

Learn Modern Javascript (Build and Test Apps) - Full Course

The modern JavaScript course for everyone! Master JavaScript with projects, challenges and theory. Many courses in one!

www.udemy.com