generated from HackYourFuture/core-assignment-week-3
-
Notifications
You must be signed in to change notification settings - Fork 18
Yana P #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
YanaP1312
wants to merge
5
commits into
HackYourAssignment:main
Choose a base branch
from
YanaP1312:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Yana P #2
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4bf431a
Add function for searching a string
YanaP1312 fc13393
Add function for parse date
YanaP1312 2aedf41
Add date.js file and functions for convert time
YanaP1312 90ae191
Refactor code, split it into 6 separate functions, add two new cities…
YanaP1312 e4c6580
use split(-) in task-2 and change some variables name for more descr…
YanaP1312 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,17 @@ | ||
| function isBookApplicable(searchString) { | ||
| // Your code here | ||
| const bookName = "The fundamentals of JavaScript".toLowerCase(); | ||
| const pureString = searchString.trim().toLowerCase(); | ||
|
|
||
| if(!pureString) return false; | ||
|
|
||
| return bookName.includes(pureString); | ||
| } | ||
|
|
||
| // console.log(isBookApplicable("javascript")); | ||
| // console.log(isBookApplicable("j2vascript ")); | ||
| // console.log(isBookApplicable("python")); | ||
| // console.log(isBookApplicable("JavaScript")); | ||
| // console.log(isBookApplicable("JAVASCRIPT")); | ||
| // console.log(isBookApplicable("fundamentals")); | ||
| // console.log(isBookApplicable("fundamentals of1 JavaScript")); | ||
| // console.log(isBookApplicable(" ")); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,25 @@ | ||
| // Your code here | ||
| function parseDateString(dateString) { | ||
| const indexOfSpace = dateString.indexOf(" "); | ||
| const format = dateString.substring(0, indexOfSpace); | ||
| const date = dateString.substring(indexOfSpace); | ||
|
|
||
| const [day, month, year] = date.split("-"); | ||
|
|
||
| if (isNaN(day) || isNaN(month) || isNaN(year)) { | ||
| return "Invalid date!"; | ||
| } | ||
|
|
||
| if (format === "DMY") { | ||
| return { day, month, year }; | ||
| } else if (format === "MDY") { | ||
| return { day: month, month: day, year }; | ||
| } else { | ||
| return "Invalid format!"; | ||
| } | ||
| } | ||
|
|
||
| // console.log(parseDateString("MDY 10-21-1983")); | ||
| // console.log(parseDateString("DMY 21-10-1983")); | ||
| // console.log(parseDateString("DM 21-10-1983")); | ||
| // console.log(parseDateString(" ")); | ||
| // console.log(parseDateString("DMY 21fsdfksdv;jf-10-1983")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| export const convertHoursToMinutes = hours => hours * 60; | ||
|
|
||
| export const convertMinutesToHours = minutes => minutes / 60; | ||
|
|
||
| export const convertDaysToHours = days => days * 24; | ||
|
|
||
| export const convertHoursToDays = hours => hours / 24; | ||
|
|
||
| export const convertMinutesToSeconds = minutes => minutes * 60; | ||
|
|
||
| export const convertSecondsToMinutes = seconds => seconds / 60; | ||
|
Comment on lines
+1
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice use of arrow functions 👍 |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,80 +1,66 @@ | ||
| // 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"); | ||
| function fullWeatherReport(city, celsius, speed) { | ||
| const reportWeather = weatherReport(city, celsius); | ||
| const reportWind = windChillCalculation(city, celsius, speed); | ||
|
|
||
| return `${reportWeather}\n${reportWind}`; | ||
| } | ||
|
|
||
| function weatherReport(city, celsius) { | ||
| const fahrenheit = toFahrenheit(celsius); | ||
| const kelvin = toKelvin(celsius); | ||
| const status = weatherStatus(celsius); | ||
|
|
||
| return `Weather Report for ${city} \nTemperature: ${celsius}°C \nTemperature: ${fahrenheit}°F \nTemperature: ${kelvin}K \n${status} \n---`; | ||
| } | ||
|
|
||
| function toFahrenheit(celsius) { | ||
| return (celsius * 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"); | ||
| function toKelvin(celsius) { | ||
| return celsius + 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 weatherStatus(celsius) { | ||
| if (celsius < 0) { | ||
| return "Status: Freezing"; | ||
| } else if (celsius >= 0 && celsius < 10) { | ||
| return "Status: Cold"; | ||
| } else if (celsius >= 10 && celsius < 20) { | ||
| return "Status: Mild"; | ||
| } else if (celsius >= 20 && celsius < 30) { | ||
| return "Status: Warm"; | ||
| } else { | ||
| return "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"); | ||
| function windChillCalculation(city, celsius, speed) { | ||
| const windChill = ( | ||
| 13.12 + | ||
| 0.6215 * celsius - | ||
| 11.37 * Math.pow(speed, 0.16) + | ||
| 0.3965 * celsius * Math.pow(speed, 0.16) | ||
| ).toFixed(2); | ||
|
|
||
| return `Wind chill in ${city}: ${windChill}°C`; | ||
| } | ||
|
|
||
| // console.log(weatherReport("Amsterdam", 22)); | ||
| // console.log(windChillCalculation("Amsterdam", 22, 15)); | ||
| // console.log(weatherReport("Berlin", 15)); | ||
| // console.log(windChillCalculation("Berlin", 15, 20)); | ||
| // console.log(weatherReport("Copenhagen", -5)); | ||
| // console.log(windChillCalculation("Copenhagen", -5, 25)); | ||
|
|
||
| // console.log(fullWeatherReport("Amsterdam", 22, 15)); | ||
| // console.log(fullWeatherReport("Berlin", 15, 20)); | ||
| // console.log(fullWeatherReport("Copenhagen", -5, 25)); | ||
|
|
||
| // 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"); | ||
| // console.log(weatherReport("Odesa", -8)); | ||
| // console.log(windChillCalculation("Odesa", -8, 13)); | ||
| // console.log(weatherReport("Antwerpen", 3)); | ||
| // console.log(windChillCalculation("Antwerpen", 3, 36)); | ||
|
|
||
| // 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"); | ||
| // console.log(fullWeatherReport("Odesa", -8, 13)); | ||
| // console.log(fullWeatherReport("Antwerpen", 3, 36)); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice that you're checking this!