Basic Web Development Skills Test
Introduction​
Can you replicate the website below using HTML, CSS, and JavaScript? When you click the “zzz” button, the website should suggest six best times to wake up based on 6 sleep cycles from the current time.
SleepTimeApp​
Deployed version link: https://cs280spring.github.io/sleeptime-app/
Test Your Knowledge!​
What is the code behind the first sentence “If you go to bed...wake up at...”?
What is the code behind the last four sentences?
What is the code to generate a window alert window saying “buzz!” when “zzz” button is clicked?
What provides access to the browser’s debugging console?
How would you write a JavaScript function named handleOnClickEvent() and call it when button is clicked?
The text color is aliceblue and the background color is darkblue. What is the code to center the body text with specified text color and background color?
What is the purpose of a div tag in HTML?
What method returns the element that has the ID attribute with the specified value?
What method returns the first element of DOM that matches a specified CSS selector in the document?
What does DOM stand for?
How do you separate style from content?
If styling is in separate file, then what code should replace <style> on the index.html file?
If scripts are in separate file, then what code should replace <script> on the index.html file?
Date Object (Step 10)​
Step 10 Link: https://cs280spring.github.io/01-sleeptime/step_10.html
Date.now()​
returns the numeric value corresponding to the current time; the number of milliseconds elapsed since 1/1/1970 00:00:00 UTC, with leap seconds ignored.
Date.prototype.toLocaleTimeString()​
returns a string with a locality-sensitive representation of the time portion of this date, based on system settings.
Calculate sleep times (Step 11)​
Our goal is to write code that will implement the algorithm described below and add it after the first three lines in the handleOnClickEvent() function.
function handleOnClickEvent() {
let output = document.querySelector(".output");
output.style.display = "block";
let hours = document.getElementById('hours');
Algorithm​
- When the
zzz
button is clicked, we want to record the current time; - Allow 14 minutes to fall asleep;
- Create six cycles of 90 minutes each;
- Display the cycles as suggested wake-up times. Make sure to use the Date object and functions in your algorithm.