Basic Knowledge - Exercise 1

Question 1: Convert Seconds to Minutes and Seconds

Return an array containing the whole minutes and remaining seconds for a non-negative integer number of seconds.

Expected output: [2,15] (print this with console.log)

javascript

function splitElapsedSeconds(seconds) {
  // Write your solution here
}

console.log(splitElapsedSeconds(135));

Question 2: Calculate a Rectangle Perimeter

Return the perimeter of a rectangle from its width and height.

Expected output: 22 (print this with console.log)

javascript

function rectanglePerimeter(width, height) {
  // Write your solution here
}

console.log(rectanglePerimeter(4, 7));

Question 3: Convert Kilometers to Meters

Return the number of meters in the supplied distance in kilometers.

Expected output: 2500 (print this with console.log)

javascript

function kilometersToMeters(kilometers) {
  // Write your solution here
}

console.log(kilometersToMeters(2.5));

Question 4: Calculate Change for Two Items

Return the change after paying for both item prices with the given amount.

Expected output: 7 (print this with console.log)

javascript

function calculateCashChange(paid, firstPrice, secondPrice) {
  // Write your solution here
}

console.log(calculateCashChange(20, 5, 8));

Question 5: Convert Celsius to Fahrenheit

Convert the supplied Celsius temperature to Fahrenheit and return it.

Expected output: 68 (print this with console.log)

javascript

function celsiusToFahrenheit(celsius) {
  // Write your solution here
}

console.log(celsiusToFahrenheit(20));

Question 6: Count Complete Boxes

Return the number of full boxes when items are packed into boxes of the given positive capacity.

Expected output: 4 (print this with console.log)

javascript

function countFullBoxes(items, capacity) {
  // Write your solution here
}

console.log(countFullBoxes(23, 5));

Question 7: Calculate a Trip's Total Distance

Return the round-trip distance when the one-way distance is traveled a given number of times in each direction.

Expected output: 72 (print this with console.log)

javascript

function roundTripDistance(distance, trips) {
  // Write your solution here
}

console.log(roundTripDistance(12, 3));

Question 8: Round Up Meeting Hours

Return the minimum number of whole hours needed for the supplied non-negative number of minutes.

Expected output: 3 (print this with console.log)

javascript

function roundUpMeetingHours(minutes) {
  // Write your solution here
}

console.log(roundUpMeetingHours(130));

Question 9: Calculate an Average Speed

Return the distance divided by travel time. The time is greater than zero.

Expected output: 50 (print this with console.log)

javascript

function averageTravelSpeed(distance, hours) {
  // Write your solution here
}

console.log(averageTravelSpeed(150, 3));

Question 10: Find the Larger Reading

Return the larger of two numeric readings. If they are equal, return either value.

Expected output: 24 (print this with console.log)

javascript

function largerSensorReading(first, second) {
  // Write your solution here
}

console.log(largerSensorReading(17, 24));