From e631272de1a72751693a54bcd9624c6b7388a83e Mon Sep 17 00:00:00 2001 From: gaireprakash20-ops Date: Mon, 5 Oct 2026 19:33:37 +0100 Subject: [PATCH 1/8] Remove the redundant code --- dead-code/exercise-1.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index 4d09f15fa9..5116eee6ad 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -1,13 +1,26 @@ // Find the instances of unreachable and redundant code - remove them! // The sayHello function should continue to work for any reasonable input it's given. +// let testName = "Jerry"; +// const greeting = "hello"; + +// function sayHello(greeting, name) { +// // const greetingStr = greeting + ", " + name + "!"; +// return `${greeting}, ${name}!`; +// // console.log(greetingStr); +// } + +// testName = "Aman"; + +// const greetingMessage = sayHello(greeting, testName); + +// console.log(greetingMessage); // 'hello, Aman!' + let testName = "Jerry"; const greeting = "hello"; function sayHello(greeting, name) { - const greetingStr = greeting + ", " + name + "!"; return `${greeting}, ${name}!`; - console.log(greetingStr); } testName = "Aman"; From 96b65cf674b1742a51e5475b36bf773bdddb7210 Mon Sep 17 00:00:00 2001 From: gaireprakash20-ops Date: Mon, 5 Oct 2026 20:08:28 +0100 Subject: [PATCH 2/8] Formate change as per pre section instructions --- format-clock-edge-cases/timeConverter.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 310c07bd9c..c6eb509ef0 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,11 +1,14 @@ function formatAs12HourClock(time) { - const hours = Number(time.slice(0, 2)); + if (time === "00:00") { + return `12:00 am`; + } + if (hours > 12) { return `${hours - 12}:00 pm`; } return `${time} am`; } -export {formatAs12HourClock}; +export { formatAs12HourClock }; From 3ae7c4f0c760570239f2df4ec2ff0381055db183 Mon Sep 17 00:00:00 2001 From: gaireprakash20-ops Date: Mon, 5 Oct 2026 21:44:12 +0100 Subject: [PATCH 3/8] make a function which run all the test cases --- format-clock-edge-cases/timeConverter.js | 28 ++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index c6eb509ef0..c1c1b688f1 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,12 +1,32 @@ +// This code only work when there is only hours not whenn there is minutes. +// function formatAs12HourClock(time) { +// const hours = Number(time.slice(0, 2)); + +// if (time === "00:00") { +// return `12:00 am`; +// } + +// if (hours > 12) { +// return `${hours - 12}:00 pm`; +// } +// return `${time} am`; +// } + +// export { formatAs12HourClock }; + +// The code which run all the run cases is. function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); + const minutes = time.slice(-3); - if (time === "00:00") { - return `12:00 am`; + if (hours === 0) { + return `12${minutes} am`; + } + if (hours === 12) { + return `${time} pm`; } - if (hours > 12) { - return `${hours - 12}:00 pm`; + return `${String(hours - 12).padStart(2, "0")}${minutes} pm`; } return `${time} am`; } From a980d4f8e46460a7bc7772ea4f583f414f6cb38c Mon Sep 17 00:00:00 2001 From: gaireprakash20-ops Date: Mon, 5 Oct 2026 21:44:37 +0100 Subject: [PATCH 4/8] make a edge cases . --- format-clock-edge-cases/timeConverter.test.js | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 88f2af0948..581d400d3b 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -1,11 +1,39 @@ -import {formatAs12HourClock} from "./timeConverter.js"; +import { formatAs12HourClock } from "./timeConverter.js"; import assert from "node:assert"; import test from "node:test"; -test("correctly convert time after 12:00", function(){ - assert.equal(formatAs12HourClock("23:00"), "11:00 pm"); +test("correctly convert time after 12:00", function () { + assert.equal(formatAs12HourClock("23:00"), "11:00 pm"); }); -test("can correctly convert morning time", function() { - assert.equal(formatAs12HourClock("08:00"), "08:00 am"); +test("can correctly convert morning time", function () { + assert.equal(formatAs12HourClock("08:00"), "08:00 am"); }); + +test("can correctly convert midnight with double digit minutes", function () { + assert.equal(formatAs12HourClock("00:25"), "12:25 am"); +}); + +test("can correctly convert noon with the double digits minutes ", function () { + assert.equal(formatAs12HourClock("12:20"), "12:20 pm"); +}); + +test("can correctly convert evening with single-digit minutes", function () { + assert.equal(formatAs12HourClock("23:05"), "11:05 pm"); +}); + +test("can correctly convert one minute before noon", function () { + assert.equal(formatAs12HourClock("11:59"), "11:59 am"); +}); + +test("can correctly convert one hour after noon", function () { + assert.equal(formatAs12HourClock("13:00"), "01:00 pm"); +}); +// It's a failing case also we need to complete it +// test("does not need to convert a string.", function () { +// assert.equal(formatAs12HourClock("Hello"), "NAN"); +// }); + +// test("throws an error for hours above 23", function () { +// assert.equal(formatAs12HourClock("25:00"), " Out of time"); +// }); From a4931983fa2f3da741722ac6094ac5833ef973ac Mon Sep 17 00:00:00 2001 From: gaireprakash20-ops Date: Mon, 5 Oct 2026 21:51:05 +0100 Subject: [PATCH 5/8] 1.js --- dead-code/exercise-1.js | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index 5116eee6ad..4d09f15fa9 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -1,26 +1,13 @@ // Find the instances of unreachable and redundant code - remove them! // The sayHello function should continue to work for any reasonable input it's given. -// let testName = "Jerry"; -// const greeting = "hello"; - -// function sayHello(greeting, name) { -// // const greetingStr = greeting + ", " + name + "!"; -// return `${greeting}, ${name}!`; -// // console.log(greetingStr); -// } - -// testName = "Aman"; - -// const greetingMessage = sayHello(greeting, testName); - -// console.log(greetingMessage); // 'hello, Aman!' - let testName = "Jerry"; const greeting = "hello"; function sayHello(greeting, name) { + const greetingStr = greeting + ", " + name + "!"; return `${greeting}, ${name}!`; + console.log(greetingStr); } testName = "Aman"; From c2984392e67f8f96c66611f0c312f62fdde24c7b Mon Sep 17 00:00:00 2001 From: gaireprakash20-ops Date: Tue, 6 Oct 2026 18:39:52 +0100 Subject: [PATCH 6/8] Remove the unnecessary code --- format-clock-edge-cases/timeConverter.test.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 581d400d3b..c4e448be82 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -29,11 +29,3 @@ test("can correctly convert one minute before noon", function () { test("can correctly convert one hour after noon", function () { assert.equal(formatAs12HourClock("13:00"), "01:00 pm"); }); -// It's a failing case also we need to complete it -// test("does not need to convert a string.", function () { -// assert.equal(formatAs12HourClock("Hello"), "NAN"); -// }); - -// test("throws an error for hours above 23", function () { -// assert.equal(formatAs12HourClock("25:00"), " Out of time"); -// }); From 0aa80bd9e0df5ea0e8bbe0c308741c6e40f4c3dd Mon Sep 17 00:00:00 2001 From: gaireprakash20-ops Date: Tue, 6 Oct 2026 18:42:18 +0100 Subject: [PATCH 7/8] Delete unused line --- format-clock-edge-cases/timeConverter.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index c1c1b688f1..91ff248b91 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,20 +1,3 @@ -// This code only work when there is only hours not whenn there is minutes. -// function formatAs12HourClock(time) { -// const hours = Number(time.slice(0, 2)); - -// if (time === "00:00") { -// return `12:00 am`; -// } - -// if (hours > 12) { -// return `${hours - 12}:00 pm`; -// } -// return `${time} am`; -// } - -// export { formatAs12HourClock }; - -// The code which run all the run cases is. function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); const minutes = time.slice(-3); From 8d02c00fd34d227596ab1129cbcfad9cb104c647 Mon Sep 17 00:00:00 2001 From: gaireprakash20-ops Date: Tue, 6 Oct 2026 18:49:38 +0100 Subject: [PATCH 8/8] test noon midnight and last minutes --- format-clock-edge-cases/timeConverter.test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index c4e448be82..8a5ee9d166 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -29,3 +29,15 @@ test("can correctly convert one minute before noon", function () { test("can correctly convert one hour after noon", function () { assert.equal(formatAs12HourClock("13:00"), "01:00 pm"); }); + +test("can correctly convert midnight", function () { + assert.equal(formatAs12HourClock("00:00"), "12:00 am"); +}); + +test("can correctly convert Noon", function () { + assert.equal(formatAs12HourClock("12:00"), "12:00 pm"); +}); + +test("can correctly convert last minutes of the day", function () { + assert.equal(formatAs12HourClock("23:59"), "11:59 pm"); +});