Self-Paced Work: Funktional Functions Updates
Follow these instructions to update the Funktional Functions website.
New Cycle Speed
Currently, when the color cycle is running, it changes colors once every 250 milliseconds. Update this to make it a little less hectic - try 500 milliseconds instead.
New Colors
Currently, there are only six colors for the filter. Add a few more colors to randomly cycle.
Note: to make the filter stronger or weaker, check the
.filterruleset in the style.css file, and update theopacityvalue.
Play/Pause Button
Currently, the button text for the "🎸 ⏯" button is always the same. However, to make it more dynamic, update the code so that it changes the button text based on whether or not the music is playing. If the music is playing, it should display ⏸. If the music is not playing, it should display ▶.
- Open the script.js file for editing
 - Find the 
playBassfunction - In the body of the 
if, underbassAudio.play(), make a new line - There, set 
playPauseBassButton.textContentto"🎸 ⏸" - In the body of the 
else, underbassAudio.pause(), make a new line - There, set 
playPauseBassButton.textContentto"🎸 ▶" 
Run the program, click the button, and make sure the play and pause symbols show up appropriately!
Display Current Filter Color
As of now, the filter color changes, but a visitor to the site might not know what the current color actually is. Add a piece of code to display the current color of the background filter.
HTML: A New Paragraph
Start by adding a new <p> element in the HTML.
- Open the index.html file for editing
 - Make a new line under the 
<h1></h1> - There, add a new 
<p></p>element - Set the 
idof the<p>to be"filter-color" 
JS: Setting the Paragraph Text
Next, update the <p> element text every time the filter color changes.
- Open the script.js file for editing
 - Make a new line under the 
backgroundFilterDivvariable initialization - There, create a new variable named 
filterColorParagraph - Set 
filterColorParagraphto a call todocument.querySelector - Pass in 
"#filter-color"to store the proper<p>element in the variable - Make a new line at the bottom of the 
randomBgFilterfunction - There, set 
filterColorParagraph.textContentto berandomColor 
Run the program, start the cycle, and verify that the current filter color appears on the page!
Easter Egg: Header Click
Add a secret way to change the background image - when a site visitor clicks the "FUNKTIONAL FUNCTIONS" header, a new picture should appear!
- Open the script.js file for editing
 - Make a new line at the bottom of the file
 - There, Define a new function named 
slyBackgroundfunctionkeyword- Function name (
slyBackground) - Parentheses (
()) - Curly brackets (
{}) 
 - Make a new line in the body of the function (between 
{and}) - There, set 
document.body.style.backgroundImageto"url('https://github.com/hytechclub/web-103/raw/main/Assets/sly.jpg')"- This will change the background image of the page
 
 - Make a new line under the function definition (after 
}) - There, create a new variable named 
header - Set 
headerto select the"h1"usingdocument.querySelector - Under that, call 
header.addEventListener - Pass in 
"click"andslyBackgroundto theaddEventListenercall 
Run the program, click the header, and verify that the background changes!
Header Click Music
In addition to changing the background image, start playing a different piece of music when the header is clicked.
- Make a new line above the 
slyBackgroundfunction definition - There, create a new variable named 
danceToTheMusic- Set 
danceToTheMusicto be anew Audioobject - Set the audio file to be 
"https://github.com/hytechclub/web-103/raw/main/Assets/dancetothemusic.mp3" 
 - Set 
 - Make a new line in the body of the 
slyBackgroundfunction - There, reate an 
if/elsestructureifkeyword- Parentheses (
()) - Curly brackets (
{}) elsekeyword- Curly brackets (
{}) 
 - For the 
ifcondition, check ifdanceToTheMusic.paused - In the body of the 
if, call thedanceToTheMusic.playfunction - In the body of the 
else, call thedanceToTheMusic.pausefunction 
Run the program, click the header again, and verify that the new music can start and stop playing!