Advanced Placement (AP), 13.03.2021 02:30, MayFlowers
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;
}
Answers: 3
Advanced Placement (AP), 22.06.2019 03:30, sharpeyennifer
What does collaboration mean? ? and what is your favorite food? ?
Answers: 2
Advanced Placement (AP), 22.06.2019 09:00, kingjustin0825
What are 3 traits scientist can know about an organism based on a complete fossil
Answers: 2
Advanced Placement (AP), 26.06.2019 08:00, alexandergoetz4857
Which of these is a disadvantage of hydrogen fuel cells? a. engines that use hydrogen fuel are more efficient than gasoline-powered engines. b. the only emission produced by hydrogen fuel cells is water. c. hydrogen fuel is continually available and useful for heating. d. hydrogen fuel is often purified in a process that emits lots of greenhouse gases.
Answers: 1
Advanced Placement (AP), 27.06.2019 13:00, alyssahomeworkneeds
The arctic is a cold deset biome, which one of the answers is not correct? a) animals in cold deserts burrow to get out of the harsh climates. b) vegetation in cold deserts is normally shallow rooted small shrubs. c) animals in cold deserts hibernate most of the year to get out of the cold. d) soils are very heavy and course. e) the region receives less than 10 inches of precipitation annually.
Answers: 1
Need help with APCSP coding (for and while loops)
It says that there are two codes that can be shor...
Mathematics, 02.12.2020 03:00
History, 02.12.2020 03:00
Mathematics, 02.12.2020 03:00
Mathematics, 02.12.2020 03:00
History, 02.12.2020 03:00
Mathematics, 02.12.2020 03:00