subject

Need help with APCSP coding (for and while loops) It says that there are two codes that can be shortened into for/while loops. Please hurry, I have to pass it at 11:59 tonight (PST). I'll give brainliest if you answer.

Here's the code:

var monthName="January";

var month=1;

var day=1;

var year=2020;

var birthDate = "";

onEvent("input1","input",function () {

monthName = getText("input1");

month = convertToNumber(monthName. toLowerCase());

updateScreen();

});

onEvent("input2","input",function () {

day = getNumber("input2");

updateScreen();

});

onEvent("input3","input",function () {

year = getNumber("input3");

updateScreen();

});

onEvent("checkButton","click",fun ction () {

var d = new Date();

var todayMonthNum = d. getMonth()+1;

var todayDay = d. getDay();

var todayYear = d. getFullYear();

if (todayMonthNum == month &&

todayDay == day &&

todayYear == year)

{

hideElement("input1");

hideElement("input2");

hideElement("input3");

playSound("EJGreenberg---birthday -birthday. mp3");

}

});

function updateScreen ()

{

birthDate =month + "/" + day + "/" + year;

setText("dateOutput",birthDate);< br />
}

function convertToNumber (name)

{

var names=["january", "february", "march", "april",

"may", "june", "july", "august",

"september", "october", "november", "december"];

var foundIndex = -1;

if (names[0]==name) foundIndex = 0;

if (names[1]==name) foundIndex = 1;

if (names[2]==name) foundIndex = 2;

if (names[3]==name) foundIndex = 3;

if (names[4]==name) foundIndex = 4;

if (names[5]==name) foundIndex = 5;

if (names[6]==name) foundIndex = 6;

if (names[7]==name) foundIndex = 7;

if (names[8]==name) foundIndex = 8;

if (names[9]==name) foundIndex = 9;

if (names[10]==name) foundIndex = 10;

if (names[11]==name) foundIndex = 11;

if (foundIndex==-1) return "??";

else return foundIndex + 1;

}

ansver
Answers: 3

Another question on Advanced Placement (AP)

question
Advanced Placement (AP), 23.06.2019 08:20
Free 20 points + brainliest to whoever answers right! in the event of a crash, personal injury protection (pip) coverage pays toward the medical costs for a. any injuries you cause to others b. any injuries that are not your fault c. your injuries if you are not at fault d. your injuries, regardless of who's at fault
Answers: 2
question
Advanced Placement (AP), 23.06.2019 21:30
According to binet, mental age relates to chronological age because a. they are the same thing b. mental age involves calculating the chronological age at which a person functions c. chronological age involves calculating how a person is mentally functioning d. they are opposites 38
Answers: 1
question
Advanced Placement (AP), 24.06.2019 17:00
According to the nebular theory, the planets formed from a process called . after our protosun formed, remaining dust and gas from the nebula collided, combined, and gravitated together to form the planets.
Answers: 1
question
Advanced Placement (AP), 26.06.2019 07:30
What type of commercial speech is not protected by the 1st amendment?
Answers: 1
You know the right answer?
Need help with APCSP coding (for and while loops) It says that there are two codes that can be shor...
Questions
question
Mathematics, 30.06.2019 13:30
question
Social Studies, 30.06.2019 13:30
question
Social Studies, 30.06.2019 13:30
question
Mathematics, 30.06.2019 13:30
Questions on the website: 13722360