From 26c348d4be5ceb01e963aa21ba41f6184dfb2bd4 Mon Sep 17 00:00:00 2001 From: Jawad Al Bdiwi Date: Wed, 28 Jan 2026 19:41:51 +0100 Subject: [PATCH 1/5] Final commit --- task-1/book.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/task-1/book.js b/task-1/book.js index 8b49ecc..e185a68 100644 --- a/task-1/book.js +++ b/task-1/book.js @@ -1,3 +1,16 @@ -function isBookApplicable(searchString) { - // Your code here +import PromptSync from "prompt-sync"; +const prompt = PromptSync(); + +const queryUser = prompt(`Please enter your search query: `); +const searchString = queryUser.toLowerCase().trim(); +const bookTitle = `The fundamentals of JavaScript`.toLowerCase(); + +function isBookApplicable() { + if (searchString === bookTitle || bookTitle.includes(searchString)) { + return true; + } else { + return false; } +} + +console.log(isBookApplicable()); \ No newline at end of file From 6971caa9b4061a15663b408627fdcd05024880ae Mon Sep 17 00:00:00 2001 From: Jawad Al Bdiwi Date: Wed, 28 Jan 2026 19:42:39 +0100 Subject: [PATCH 2/5] Final commit --- task-2/parse-date.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/task-2/parse-date.js b/task-2/parse-date.js index 877a3aa..fe8b458 100644 --- a/task-2/parse-date.js +++ b/task-2/parse-date.js @@ -1 +1,18 @@ -// Your code here +function parseDateString(dateString) { + let parts = dateString.split(" "); + let format = parts[0]; + let date = parts[1]; + let splitDate = date.split("-"); + + let firstDate = Number(splitDate[0]); + let secondDate = Number(splitDate[1]); + let thirdDate = Number(splitDate[2]); + + if (format === "MDY") { + return {day: secondDate, month: firstDate, year: thirdDate} + } else if (format === "DMY") { + return {day: secondDate, month: firstDate, year: thirdDate} + } else { + return `Error! Please enter a valid date format.`; + } +} \ No newline at end of file From 80d0a5dd21e1c322e15b517beb036be93de975eb Mon Sep 17 00:00:00 2001 From: Jawad Al Bdiwi Date: Wed, 28 Jan 2026 19:47:56 +0100 Subject: [PATCH 3/5] Final commit --- task-3/date.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 task-3/date.js diff --git a/task-3/date.js b/task-3/date.js new file mode 100644 index 0000000..f55c2cc --- /dev/null +++ b/task-3/date.js @@ -0,0 +1,23 @@ +export function convertHoursToMinutes(hours) { + return hours * 60; +} + +export function convertMinutesToHours(minutes) { + return minutes / 60; +} + +export function convertDaysToHours(days) { + return days * 24; +} + +export function convertHoursToDays(hours) { + return hours / 24; +} + +export function convertMinutesToSeconds(minutes) { + return minutes * 60; +} + +export function convertSecondsToMinutes(seconds) { + return seconds / 60; +} \ No newline at end of file From f9c9d7f335ba11a82c40c7ec1bfea08df314b050 Mon Sep 17 00:00:00 2001 From: Jawad Al Bdiwi Date: Wed, 28 Jan 2026 20:17:37 +0100 Subject: [PATCH 4/5] Final commit --- task-4/cleanup.js | 109 ++++++++++++++++------------------------------ 1 file changed, 37 insertions(+), 72 deletions(-) diff --git a/task-4/cleanup.js b/task-4/cleanup.js index 207523a..d729cc6 100644 --- a/task-4/cleanup.js +++ b/task-4/cleanup.js @@ -1,80 +1,45 @@ -// Temperature conversion and weather report for City 1 -let cityName1 = "Amsterdam"; -let tempCelsius1 = 22; -let tempFahrenheit1 = (tempCelsius1 * 9 / 5) + 32; -let tempKelvin1 = tempCelsius1 + 273.15; -console.log("Weather Report for " + cityName1); -console.log("Temperature: " + tempCelsius1 + "°C"); -console.log("Temperature: " + tempFahrenheit1 + "°F"); -console.log("Temperature: " + tempKelvin1 + "K"); -if (tempCelsius1 < 0) { - console.log("Status: Freezing"); -} else if (tempCelsius1 >= 0 && tempCelsius1 < 10) { - console.log("Status: Cold"); -} else if (tempCelsius1 >= 10 && tempCelsius1 < 20) { - console.log("Status: Mild"); -} else if (tempCelsius1 >= 20 && tempCelsius1 < 30) { - console.log("Status: Warm"); -} else { - console.log("Status: Hot"); +const cities = [ + { city: "Amsterdam", temp: 22, windSpeed: 15 }, + { city: "Berlin", temp: 15, windSpeed: 20 }, + { city: "Copenhagen",temp: -5, windSpeed: 25 } +]; + +convertToFahrenheit(temp) { + return temp * 9 / 5 + 32; } -console.log("---"); -// Temperature conversion and weather report for City 2 -let cityName2 = "Berlin"; -let tempCelsius2 = 15; -let tempFahrenheit2 = (tempCelsius2 * 9 / 5) + 32; -let tempKelvin2 = tempCelsius2 + 273.15; -console.log("Weather Report for " + cityName2); -console.log("Temperature: " + tempCelsius2 + "°C"); -console.log("Temperature: " + tempFahrenheit2 + "°F"); -console.log("Temperature: " + tempKelvin2 + "K"); -if (tempCelsius2 < 0) { - console.log("Status: Freezing"); -} else if (tempCelsius2 >= 0 && tempCelsius2 < 10) { - console.log("Status: Cold"); -} else if (tempCelsius2 >= 10 && tempCelsius2 < 20) { - console.log("Status: Mild"); -} else if (tempCelsius2 >= 20 && tempCelsius2 < 30) { - console.log("Status: Warm"); -} else { - console.log("Status: Hot"); +convertToKelvin(temp) { + return temp + 273.15; } -console.log("---"); -// Temperature conversion and weather report for City 3 -let cityName3 = "Copenhagen"; -let tempCelsius3 = -5; -let tempFahrenheit3 = (tempCelsius3 * 9 / 5) + 32; -let tempKelvin3 = tempCelsius3 + 273.15; -console.log("Weather Report for " + cityName3); -console.log("Temperature: " + tempCelsius3 + "°C"); -console.log("Temperature: " + tempFahrenheit3 + "°F"); -console.log("Temperature: " + tempKelvin3 + "K"); -if (tempCelsius3 < 0) { - console.log("Status: Freezing"); -} else if (tempCelsius3 >= 0 && tempCelsius3 < 10) { - console.log("Status: Cold"); -} else if (tempCelsius3 >= 10 && tempCelsius3 < 20) { - console.log("Status: Mild"); -} else if (tempCelsius3 >= 20 && tempCelsius3 < 30) { - console.log("Status: Warm"); -} else { - console.log("Status: Hot"); +function calcWindChill(temp, windSpeed) { + return 13.12 + 0.6215 * temp - 11.37 * Math.pow(windSpeed, 0.16) + 0.3965 * temp * Math.pow(windSpeed, 0.16); } -console.log("---"); -// Wind chill calculation for City 1 -let windSpeed1 = 15; -let windChill1 = 13.12 + 0.6215 * tempCelsius1 - 11.37 * Math.pow(windSpeed1, 0.16) + 0.3965 * tempCelsius1 * Math.pow(windSpeed1, 0.16); -console.log("Wind chill in " + cityName1 + ": " + windChill1.toFixed(2) + "°C"); +function tempStatus(temp) { + if (temp < 0) { + return `Freezing`; + } else if (temp < 10) { + return `Cold`; + } else if (temp < 20) { + return `Mild`; + } else if (temp < 30) { + return `Warm`; + } else { + return `Hot`; +} +} -// Wind chill calculation for City 2 -let windSpeed2 = 20; -let windChill2 = 13.12 + 0.6215 * tempCelsius2 - 11.37 * Math.pow(windSpeed2, 0.16) + 0.3965 * tempCelsius2 * Math.pow(windSpeed2, 0.16); -console.log("Wind chill in " + cityName2 + ": " + windChill2.toFixed(2) + "°C"); +function printWeather(city, temp, windSpeed) { + const tempF = convertToFahrenheit(temp).toFixed(2); + const tempK = convertToKelvin(temp).toFixed(2); + const status = tempStatus(temp) + const windChill = calcWindChill(temp, windSpeed).toFixed(2); -// Wind chill calculation for City 3 -let windSpeed3 = 25; -let windChill3 = 13.12 + 0.6215 * tempCelsius3 - 11.37 * Math.pow(windSpeed3, 0.16) + 0.3965 * tempCelsius3 * Math.pow(windSpeed3, 0.16); -console.log("Wind chill in " + cityName3 + ": " + windChill3.toFixed(2) + "°C"); \ No newline at end of file + console.log(`Weather Report for ${city}`); + console.log(`Temperature: ${temp} °C`); + console.log(`Temperature: ${tempF} °F`); + console.log(`Temperature: ${tempK} K`); + console.log(`Status: ${status}`); + console.log(`Wind chill in ${city}: ${windChill} °C`) +} \ No newline at end of file From 2b1674cc4cd83a6e1b1fa4f916b1a2af76d020dc Mon Sep 17 00:00:00 2001 From: Jawad Al Bdiwi Date: Thu, 29 Jan 2026 11:05:04 +0100 Subject: [PATCH 5/5] Added comment regarding script functionality --- task-4/cleanup.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/task-4/cleanup.js b/task-4/cleanup.js index d729cc6..0eccc28 100644 --- a/task-4/cleanup.js +++ b/task-4/cleanup.js @@ -1,14 +1,18 @@ +/* I could not figure out how to properly create arrays +and call the function using them as input for the printWeather function +*/ + const cities = [ { city: "Amsterdam", temp: 22, windSpeed: 15 }, { city: "Berlin", temp: 15, windSpeed: 20 }, { city: "Copenhagen",temp: -5, windSpeed: 25 } ]; -convertToFahrenheit(temp) { +function convertToFahrenheit(temp) { return temp * 9 / 5 + 32; } -convertToKelvin(temp) { +function convertToKelvin(temp) { return temp + 273.15; } @@ -42,4 +46,4 @@ function printWeather(city, temp, windSpeed) { console.log(`Temperature: ${tempK} K`); console.log(`Status: ${status}`); console.log(`Wind chill in ${city}: ${windChill} °C`) -} \ No newline at end of file +}