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",function () {

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);

}


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;


}

Answers

Answer 1

Answer:

maybe 12 is the answer? im not sure dont take my word for it


Related Questions

Other Questions
A man walks a distance of 2 m every second.aj What speed is he travelling at?b) How far wil he have walked in:5 s 50 s 2 min 2 hr Please help :(. PLS HELP AND HURRYAfter how many hours is the price the same in both companies? Explain how you found the answer. Fill the blanks using Product formula. Please help as quickly as possible, this is Algebra 1! SOMEONE HELP ME PLZZZ!!!!!!!!! The following can be decomposed in ???? Long chains of amino acids are sugars. proteins. lipids. carbohydrates. What is the lanthanide with least mass, periodic table? 10. What are the only types of passes allowed in floor hockey? Which term refers to the way an artist arranges the elements in an artwork?A) resourceB) guideC) compositionD) style Help me with this pls 1. Which statement is NOT true about chemical and physical changes?A. Chemical and physical changes could produce precipitates.B. Chemical changes produce new substances, but physical changes do not.C. Physical changes use energy transferred as heat, but chemical changes do not.D. Physical and chemical changes could require days for their effects to be noticeable. The term used for an event in which large number of losses occur to life and property is called _____________.toxicvulnerabledisaster Jenny and Anne wanted to see who could throw a ball the hardest. They decided to each throw a ball against a wall as hard as they could and measure how far the ball rolled away from the wall Which of the following will most likely result in an increase in deficit spending The following are the ages (years) of 5 people in a room:17, 21, 15, 15, 25A person enters the room.The mean age of the 6 people is now 25.What is the age of the person who entered the room? distribute, opposition, rescue, present, social worker, toiletries and segregation in a sentence Write the recursive formula for this sequence: 3, 1, -1, ... * NEED HELP ON THIS NOW PLEASE In a survey of 3,200 people who owned a certain type of car, 1,920 said they wouldbuy that type of car again. What percent of the people surveyed were satisfied with the car?% of the people surveyed were satisfied with the car