Advanced Placement (AP), 13.03.2021 02:30 iikatreii
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-b irthday. 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: 1
Advanced Placement (AP), 22.06.2019 00:00
According to the article, what are some of the drawbacks of traditional intelligence tests, and what is being done to rectify these issues?
Answers: 3
Advanced Placement (AP), 23.06.2019 06:00
How does act ii, scene 3, when romeo goes to friar laurence’s cell at dawn, contrast with the action of the night before, when romeo and juliet declare their love? what do dawn and daytime signify to romeo and juliet’s relationship, and how does this scene tie into the light/darkness visual motif of the play? in the space below, analyze the scene’s importance in these respects. use specific details from the text to support your analysis.
Answers: 3
Advanced Placement (AP), 23.06.2019 12:00
Activity 1.3.2 standard and metric measuring pltw
Answers: 1
Advanced Placement (AP), 24.06.2019 05:00
Ronan has been working as domestic at a large mansion since a few months. recently, he has taken his employer’s seven-year-old boy by force and held him captive. he has demanded money from his employer in return of the boy. which crime has ronan committed? a. treason b. sedition c. assault and battery d. kidnapping
Answers: 2
Need help with APCSP coding (for and while loops)
It says that there are two codes that can be shor...
Mathematics, 25.01.2021 08:30
History, 25.01.2021 08:30
Mathematics, 25.01.2021 08:30
Mathematics, 25.01.2021 08:30
Mathematics, 25.01.2021 08:30
Mathematics, 25.01.2021 08:30
Mathematics, 25.01.2021 08:30
Mathematics, 25.01.2021 08:30
Mathematics, 25.01.2021 08:30
Mathematics, 25.01.2021 08:30
Mathematics, 25.01.2021 08:40
History, 25.01.2021 08:40
Chemistry, 25.01.2021 08:40