[Programming basics] - World Swimming Record- Javascript
здравейте, това е кодът ми
function worldSwimmingRecord (input) {
let recordSec = Number(input.shift());
let distanceInM = Number(input.shift());
let timeInSecForM = Number(input.shift());
let time = (distanceInM * timeInSecForM);
let additionaltime = Math.floor(distanceInM / 15 * 12.5);
let totalTime = time + additionaltime;
if(totalTime < recordSec) {
console.log(`Yes, he succeeded! The new world record is ${totalTime.toFixed(2)} seconds.`);
}else {
console.log(`No, he failed! He was ${(totalTime - recordSec).toFixed(2)} seconds slower.`)
}}
моля за малко помощ.
И аз за това мислех. Може би така:
let additionaltime = (distanceInM / 15) * 12.5;
let totalTime = time + Math.floor(additionaltime);
mersi
много благодаря