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

Please break the program in to functions (make it modullar) function testMagicDa

ID: 3598653 • Letter: P

Question

Please break the program in to functions (make it modullar)

function testMagicDate()

{

//declear month value

var month=prompt("Enter month value ");

  

//declear day value

var day=prompt("Enter day of month ");

  

//declear year value

var year=prompt("Enter year ");

  

//check if the input data values are not null

if (month!=null && day!=null && year!=null)

{

if(month*day==year)

<!--show if the date is magic date-->

alert(month+"/"+day+"/"+year+" : Magic Date");

else

<!--show if the date is not magic date-->

alert(month+"/"+day+"/"+year+" Not magic Date");

}

}

//call the testMagicDate

testMagicDate()

Explanation / Answer

function getMonth() {

//declear month value

var month=prompt("Enter month value ");

return month;

}

function getDay() {

//declear day value

var day=prompt("Enter day of month ");

return day;

}

function getYear() {

//declear year value

var year=prompt("Enter year ");

return year;

}

function isMagic(day, month, year) {

if(month*day==year)

return true

else

return false

}

function testMagicDate()

{

//declear month value

var month=getMonth();

  

//declear day value

var day=getDay();

  

//declear year value

var year=getYear();

  

//check if the input data values are not null

if (month!=null && day!=null && year!=null)

{

if(isMagic(day, month, year))

<!--show if the date is magic date-->

alert(month+"/"+day+"/"+year+" : Magic Date");

else

<!--show if the date is not magic date-->

alert(month+"/"+day+"/"+year+" Not magic Date");

}

}

//call the testMagicDate

testMagicDate()