Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,22 @@ $(document).ready(function(){
else if((idx = (txt.toLowerCase()).lastIndexOf("change background".toLowerCase())) !==-1)
{
Speech("Change backgroud");
// Code to change body backgroud color
// HINT: use simple DOM commands for this.
// EASY: 3

var makeArray = txt.split(' ');
var bColor = makeArray.splice(-3);

//for example if user says 'change background color to crimson red'
//then this process will select crimson red

if (bColor[0] === 'to') {
document.body.style.backgroundColor = bColor[1] + bColor[2];
} else if (bColor[1] === 'to') {
document.body.style.backgroundColor = bColor[2];
} else {
document.body.style.backgroundColor = bColor[0] + bColor[1] + bColor[2];
}


}
else if((idx = (txt.toLowerCase()).indexOf("let us".toLowerCase())) !==-1){
Speech("enjoy tetris");
Expand Down