원문보기

Don't Repeat Yourself (D.R.Y)
여러분 스스로 반복하지 마십시오.

The D.R.Y. principle is really important in programming. No repeating!
프로그래밍에서 스스로 반복하지 않는 것은 매우 중요합니다.

Any time you find yourself typing the same thing, but modifying only one small part, you can probably use a function.
어느때나 당신스스로 같은 것을 입력하기를 찾지만 당신이 아마도 사용할 수 있는 함수에서 수정할 부분은 단지 작은 영역이다.

The 'small part' that you find yourself modifying will be the parameter. And the part that you keep repeating will be the code in the reusable block - the code inside { }.
당신이 찾을 수 있는 수정 사항 작은 부분은 매개변수가 될 겁니다. 그리고 당신이 재반복 되도록 하는 부분은 재사용되는 블락안의 코드가 될 겁니다.

Instructions
지침

You are a creature of habit. Every week you buy 5 oranges. But orange prices keep changing!
당신은 습관에 지배 받습니다. 매주 5개의 오렌지를 삽니다만 오랜지 가격은 계속 바뀌고 있습니다.

01    You want to declare a function that calculates the cost of buying 5 oranges.
01    당신은 5개 오렌지를 사는 비용 계산하는 함수를 선언하길 원합니다.
 
02    You then want to calculate the cost of the 5 all together.
02    당신은 그러고나서 5개 전부 비용을 계산하길 원합니다.

03    Write a function that does this called orangeCost().
03    orangeCost()라고 불리는 함수를 작성하세요.

04    It should take a parameter that is the cost of an orange, and multiply it by 5.
04   오렌지 비용 매개변수를 사용하여 5를 곱해야 합니다.

05    It should log the result of the multiplication to the console.
05   곱한 결과는 콘솔사용하여 기록해야합니다.

06    Call the function where oranges each cost 5 dollars.
06   오렌지들 각 5달러 비용이 드는 것으로 함수를 호출하세요.


Hint
힌트

What is the one bit of input that changes each time? It would be the price. So give your parameter the name price. And when you call your function, put in a number for the price to see how much 5 oranges cost!
각각의 때마다 변경되어 입력되는 한 비트는 무엇입니까? 그것은 가격이 될 겁니다. 따라서 당신의 매개변수에 이름 가격을 제공합니다. 그리고 당신의 함수를 호출할 때, 5개의 오렌지의 비용이 얼마인지 볼수 있도록 가격의 숫자를 입력하세요.


var orangeCost = function (price) {
console.log(5 * price);
}
orangeCost(5);


Posted by 뭔가느낌이
,