0

Help me to correct my code

function timeFour (hour1, min1, sec1) { if (hour1 > 0 && min1 > 0) { let sec4 = hour1 * 3600; let sec5 = min1 * 60; let sec6 = sec4 + sec5; console.log(`${sec6 + sec1} second`) } else if (hour1 > 0) { let sec2 = hour1 * 3600; console.log(`${sec2 + sec1} second`) } else if (min1 > 0) { let sec3 = min1 * 60; console.log(`${sec3 + sec1} second`) } else { console.log(`${sec1}`) } } timeFour(12,1,0) function timeFive (hourTwo, minTwo, secTwo) { if (hourTwo > 0 && 0 < minTwo) { let secFive = hourTwo * 3600; let secSix = minTwo * 60; let secSeven = secFive + secSix; console.log(`${secSeven + secTwo} second`) } else if (hourTwo > 0) { let secThree = hourTwo * 3600; console.log(`${secThree + secTwo} second`) } else if (minTwo > 0) { let secFour = minTwo * 60; console.log(`${secFour + secTwo} second`) } else { console.log(`${secTwo}`) } } timeFive(14,1,0) function timeSix(time1, time2) { let timeSeven = time2 - time1; console.log(timeSeven) } timeSix(time1 = timeFour(), time2 = timeFive()) function time(timeSeven) { if (timeSeven >= 3600) { let hour = Math.floor( timeSeven / 3600); let sec1 = timeSeven % 3600; if (sec1 > 60) { let min = Math.floor(sec1 / 60); let sec2 = sec1 % 60; console.log(`${hour}:${min}:${sec2}`) } else { console.log(`${hour}:0:${sec1}`) } } else if (timeSeven >= 60 && timeSeven < 3600) { let min = Math.floor( timeSeven / 60); let sec3 = timeSeven % 60; console.log(`0:${min}:${sec3}`) } else { console.log(`0:0:${timeSeven}`) } } time(t = timeSix())

28th Apr 2021, 11:50 AM
Тимур Завьялов
Тимур Завьялов - avatar
6 Antworten
+ 2
Тимур Завьялов What are you doing here? Что ты здесь делаешь?
28th Apr 2021, 11:58 AM
A͢J
A͢J - avatar
0
Тимур Завьялов What is the problem in the code?
28th Apr 2021, 12:26 PM
Matias
Matias - avatar
0
I need to write a function that counts the difference between dates. The function takes 6 parameters that describe 2 dates, and returns the result as a string " hh:mm: ss". When completing a task, use the functions from the previous 2 tasks: first, convert both dates to seconds, find out the difference in seconds, and then translate the difference back to " hh:mm: ss".
28th Apr 2021, 12:31 PM
Тимур Завьялов
Тимур Завьялов - avatar
0
Matiyas, I can't subtract the first function from the second function and convert this function to hh: mm:ss
28th Apr 2021, 12:34 PM
Тимур Завьялов
Тимур Завьялов - avatar
0
Ok let me try to solve
28th Apr 2021, 12:35 PM
Matias
Matias - avatar
0
Matiyas, thank you)
28th Apr 2021, 1:13 PM
Тимур Завьялов
Тимур Завьялов - avatar