Using LLMs for efficient learning
Write a function that returns true if a book ‘The fundamentals of JavaScript’ is applicable for a specific search string:
function isBookApplicable(searchString) {
// Your code here
}
true if the book title "The fundamentals of JavaScript" is applicable for the given search stringfalse otherwiseconsole.log(isBookApplicable("javascript"));
// Output: true
console.log(isBookApplicable("javascript "));
// Output: true
console.log(isBookApplicable("python"));
// Output: false
console.log(isBookApplicable("JavaScript"));
// Output: true
console.log(isBookApplicable("JAVASCRIPT"));
// Output: true
Write a function called parseDateString that takes a date string as input and returns an object containing the parsed date components.
function parseDateString(dateString) {
// Your code here
}
Input Format:
The input string will be in one of two formats:
MDY 10-21-1983 - Month-Day-Year formatDMY 21-10-1983 - Day-Month-Year formatThe format indicator (MDY or DMY) is always followed by a space, then the date values separated by hyphens.
Expected Output:
Your function should return an object with three properties:
day - the day as a numbermonth - the month as a numberyear - the year as a numberconsole.log(parseDateString("MDY 10-21-1983"));
// Output: { day: 21, month: 10, year: 1983 }
console.log(parseDateString("DMY 21-10-1983"));
// Output: { day: 21, month: 10, year: 1983 }
console.log(parseDateString("MDY 03-15-2024"));
// Output: { day: 15, month: 3, year: 2024 }
console.log(parseDateString("DMY 15-03-2024"));
// Output: { day: 15, month: 3, year: 2024 }
day, month, and year propertiesIn this task, you will create a reusable JavaScript module that provides date conversion functions. You'll practice creating modules, exporting functions, and using them in other files.
Scenario:
You have been given an example.js file that already uses various date conversion functions. Your job is to create a date.js module that implements these functions so that example.js works correctly.
<aside> ❗
Do not modify example.js
</aside>
Create a file called date.js that exports the following functions:
convertHoursToMinutes(hours) - converts hours to minutesconvertMinutesToHours(minutes) - converts minutes to hoursconvertDaysToHours(days) - converts days to hoursconvertHoursToDays(hours) - converts hours to daysconvertMinutesToSeconds(minutes) - converts minutes to secondsconvertSecondsToMinutes(seconds) - converts seconds to minutesdate.js in the same directory as example.jsexample.js file - it should work as-is once your date.js is completeIn this task, you will be given code that works correctly but violates the DRY (Don't Repeat Yourself) principle. Your job is to refactor the code by extracting repeated logic into separate functions.
Refactor this code by creating separate functions to eliminate repetition.
After refactoring, add weather reports for two more cities with different temperatures and wind speeds. Notice how much easier it is to generate new reports when following the DRY principle!
The assignment repository can be found in https://github.com/HackYourAssignment/ with the name cXX-core-week-## (Replace XX with your cohort number and ## with the week number)
Follow the Assignment submission guide to learn how to submit the assignment