3.Fruit
Здравейте,
Джъдж ми дава само 40/100 и не мога да разбера защо. Ето условие на задачата и код:
1.Fruit
Write a JS function that calculates how much money you need to buy a fruit. You will receive a string for the type of fruit you want to buy, a number for weight in grams and another number for a price per kilogram.
Print the following text on the console: 'I need {money} leva to buy {weight} kilograms {fruit}.' . Print the weight and the money rounded to two decimal places.
The input comes as three arguments passed to your function.
The output should be printed to the console.
Example
| Input | Output | 
| 'orange', 2500, 1.80 | I need 4.50 leva to buy 2.50 kilograms orange. | 
| Input | Output | 
| 'apple', 1563, 2.35 | I need 3.67 leva to buy 1.56 kilograms apple. | 
Ето и код:
function calculateKg(type,weight,pricePerkg) {
let weightInKg = (weight/1000).toFixed(2);
let money = (weightInKg*pricePerkg).toFixed(2);
console.log(`I need ${money} leva to buy ${weightInKg} kilograms ${type}.`)
}