From 7bcc255160b32914858afbd302b6058d6b2ca42e Mon Sep 17 00:00:00 2001 From: Hamed Razizadeh Date: Wed, 28 Jan 2026 19:32:58 +0100 Subject: [PATCH 1/4] book searching --- task-1/book.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/task-1/book.js b/task-1/book.js index 8b49ecc..3e57ced 100644 --- a/task-1/book.js +++ b/task-1/book.js @@ -1,3 +1,17 @@ function isBookApplicable(searchString) { - // Your code here + const BookTitles = "The fundamentals of JavaScript"; + const normalizedBookTitles = BookTitles.toLowerCase(); + const normalizedSearchString = searchString.trim().toLowerCase(); + return normalizedBookTitles.includes(normalizedSearchString); } +// Sample tests +console.log(isBookApplicable("javascript")); +console.log(isBookApplicable("javascript ")); +console.log(isBookApplicable("python")); +console.log(isBookApplicable("JavaScript")); +console.log(isBookApplicable("JAVASCRIPT")); +console.log(isBookApplicable(" JavaScript ")); +console.log(isBookApplicable("fundamentals")); +console.log(isBookApplicable("Fundamentals of JavaScript")); +console.log(isBookApplicable("The fundamentals of JavaScript")); +console.log(isBookApplicable("The fundamentals of JavaScript!")); From 0cdd6c25bec907490307dba0cfbada80c8b5444d Mon Sep 17 00:00:00 2001 From: Hamed Razizadeh Date: Wed, 28 Jan 2026 19:35:16 +0100 Subject: [PATCH 2/4] renew parse date --- task-2/parse-date.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/task-2/parse-date.js b/task-2/parse-date.js index 877a3aa..6b7175d 100644 --- a/task-2/parse-date.js +++ b/task-2/parse-date.js @@ -1 +1,27 @@ -// Your code here +function parseDateString(dateString) { + const [format, datePart] = dateString.trim().split(" "); + const [first, second, year] = datePart.split("-").map(Number); + + if (format === "MDY") { + return { + day: second, + month: first, + year: year, + }; + } + + if (format === "DMY") { + return { + day: first, + month: second, + year: year, + }; + } +} + +// Sample tests +console.log(parseDateString("MDY 10-21-2026")); +console.log(parseDateString("DMY 21-10-2026")); +console.log(parseDateString("MDY 03-15-1897")); +console.log(parseDateString("DMY 15-03-1897")); + From 01cec223f67bade93aaa18ae2b54b3a4e969bf80 Mon Sep 17 00:00:00 2001 From: Hamed Razizadeh Date: Wed, 28 Jan 2026 19:37:21 +0100 Subject: [PATCH 3/4] convertor --- task-3/date.js | 19 +++++++++++++++++++ 1 file changed, 19 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..a2e3f1f --- /dev/null +++ b/task-3/date.js @@ -0,0 +1,19 @@ +const convertor = { + HoursToMinutes: (hours) => (hours * 60), + MinutesToHours: (minutes) => (minutes / 60), + DaysToHours: (days) => (days * 24), + HoursToDays: (hours) => (hours / 24), + MinutesToSeconds: (minutes) => (minutes * 60), + SecondsToMinutes: (seconds) => (seconds / 60), +} + +// sample tests + +console.log(convertor.HoursToMinutes(72)); +console.log(convertor.MinutesToHours(480)); +console.log(convertor.DaysToHours(92)); +console.log(convertor.HoursToDays(180)); +console.log(convertor.MinutesToSeconds(5)); +console.log(convertor.SecondsToMinutes(360)); + + \ No newline at end of file From e2af7db9fb18002e72fd9c669bdb91b62540467d Mon Sep 17 00:00:00 2001 From: Hamed Razizadeh Date: Wed, 28 Jan 2026 19:39:01 +0100 Subject: [PATCH 4/4] renew cleanup --- task-4/cleanup.js | 121 ++++++++++++++++------------------------------ 1 file changed, 41 insertions(+), 80 deletions(-) diff --git a/task-4/cleanup.js b/task-4/cleanup.js index 207523a..c51e49a 100644 --- a/task-4/cleanup.js +++ b/task-4/cleanup.js @@ -1,80 +1,41 @@ -// 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"); -} -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"); -} -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"); -} -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"); - -// 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"); - -// 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 +const celsiusToFahrenheit = (celsius) => (celsius * 9) / 5 + 32; +const celsiusToKelvin = (celsius) => celsius + 273.15; +const getTemperatureStatus = (celsius) => + celsius < 0 + ? "Freezing" + : celsius < 10 + ? "Cold" + : celsius < 20 + ? "Mild" + : celsius < 30 + ? "Warm" + : "Hot"; +const calculateWindChill = (celsius, windSpeed) => + 13.12 + + 0.6215 * celsius - + 11.37 * Math.pow(windSpeed, 0.16) + + 0.3965 * celsius * Math.pow(windSpeed, 0.16); +const printWeatherReport = ({ cityName, tempCelsius, windSpeed }) => { + console.log(`Weather Report for ${cityName}`); + console.log(`Temperature: ${tempCelsius}°C`); + console.log(`Temperature: ${celsiusToFahrenheit(tempCelsius).toFixed(2)}°F`); + console.log(`Temperature: ${celsiusToKelvin(tempCelsius).toFixed(2)}K`); + console.log(`Status: ${getTemperatureStatus(tempCelsius)}`); + console.log("---"); + console.log( + `Wind chill in ${cityName}: ${calculateWindChill(tempCelsius, windSpeed).toFixed(2)}°C\n`, + ); +}; +const printallWeatherReports = ({ cityName, tempCelsius, windSpeed }) => { + for (const city of cities) { + printWeatherReport(city); + } +}; +const cities = [ + { cityName: "Amsterdam", tempCelsius: 22, windSpeed: 15 }, + { cityName: "Berlin", tempCelsius: 15, windSpeed: 20 }, + { cityName: "Copenhagen", tempCelsius: -5, windSpeed: 25 }, + { cityName: "Utrecht", tempCelsius: 28, windSpeed: 10 }, + { cityName: "Tehran", tempCelsius: 5, windSpeed: 8 }, +]; +printallWeatherReports(cities);