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), 25.06.2019 12:00
Halppppppppppppppp there will be more
Answers: 2
question
Advanced Placement (AP), 25.06.2019 14:10
Among the following environmental factors, which does not have a long-term impact on the composition of a region's soil? a. kinds of crops grown b. types of fungi present c. topography of the landscape d. variety of species of mammals e. number of freezes occurring annually
Answers: 1
question
Advanced Placement (AP), 25.06.2019 19:30
Typically, passing a dual enrollment course in english would earn a student: a. weighted credit on college transcripts. b. both high school and college english credit. c. high school social studies credit. d. credit for two high school english classes
Answers: 1
question
Advanced Placement (AP), 25.06.2019 20:00
Along with removing drugs from the body, the kidneys also a. balance ph levels b. release hormones that regulate blood pressure c. release hormones into the stomach d. a and b
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, 29.08.2019 08:30
question
History, 29.08.2019 08:30
question
Mathematics, 29.08.2019 08:30
Questions on the website: 13722367