Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

function Surprise(){ var number = document.favorites.number.value; var color = d

ID: 3634175 • Letter: F

Question

function Surprise(){

var number = document.favorites.number.value;

var color = document.favorites.color.value;

var count = 1; //intializationwhile(count<=number){//condition

if( ((color=="Red") || (color=="RED") || (color=="red"));

document.write("<img src="rose.jpg" alt='rose'>");

else if((color == "Blue") || (color =="BLUE") || (color == "blue") );

document.write("<img src="iris.jpg" alt='iris'>");

else if((color =="Purple") || (color == "PURPLE" || (color == "purple") );

document.write("<img src="clematis.jpg" alt='clematis'>");

else if((color == "Yellow") || (color == "YELLOW") || (color =="yellow") );

document.write("<img src="sunflower.jpg" alt='sun'>")

count = count +1;

//update

if(number<1);document.write(number + color + " flowers!");

if else(number==1)document.write(number + color + " flower!");

if else(number>1 || <=10)document.write(number + color + " flowers!");

}

//end of while

Explanation / Answer

Instead of writing all of these if/else statements, set ! = to a common variable that can be used throughout the entire code. I would set it equal to one of the statements below. document.write(""); else if((color == "Blue") || (color =="BLUE") || (color == "blue") ); document.write(""); else if((color =="Purple") || (color == "PURPLE" || (color == "purple") ); document.write(""); else if((color == "Yellow") || (color == "YELLOW") || (color =="yellow") );