EasyFunctionsNot started

Shipping fee function

A bookshop courier charges 35 base units, plus 6 per whole kilogram and 3 per kilometre. Read weight and distance, define a function named shippingFee, and print the calculated charge.

Input

One line containing two integers: weight and distance.

Output

One integer: the complete shipping charge.

Example 1

Input

4 10

Output

89

35 + (4 × 6) + (10 × 3) equals 89.

Constraints

  • 1 <= weight <= 100
  • 1 <= distance <= 1000

Hints

Hint 1 of 3

A function gives a result back with return.

Hint 2 of 3

Multiply each rate by its matching input.

Hint 3 of 3

Return 35 + weight * 6 + distance * 3.

Solution

Show a reference solution and explanation
 JavaScript · reference solution
function shippingFee(weight, distance) {
  return 35 + weight * 6 + distance * 3;
}
const [weight, distance] = readline().split(' ').map(Number);
console.log(shippingFee(weight, distance));

Why it works

The function contains one pricing rule and can be reused with any valid inputs. Returning the result keeps calculation separate from the console output performed by the caller.

Lesson for this exercise: JavaScript Functions: Declarations, Arrows and Return Values

Your program
function shippingFee(weight, distance) {
  // return the calculated charge
}
const [weight, distance] = readline().split(' ').map(Number);
console.log(shippingFee(weight, distance));

Tests: 3 cases including the examples. Passing every test marks the exercise solved in this browser.

How this page was checked. Every program on it was run with Node.js 22 at build time; runs in your browser in an isolated Web Worker by the publishing checks, and the output shown is what it printed. The Run buttons execute the same code on your device; nothing you type is sent anywhere.