Advanced Placement (AP)
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;

}

answer
Answers: 1

Other questions on the subject: Advanced Placement (AP)

image
Advanced Placement (AP), 23.06.2019 00:00, kp2078
Which of the following credit scores will most likely get you the least expensive interest rate on a car loan
Answers: 1
image
Advanced Placement (AP), 23.06.2019 02:00, ColungaRosemary
Which of the following refers to treating all patients or first aid victims as a potential source of bloodborne pathogens by taking all precautions to prevent contamination?
Answers: 2
image
Advanced Placement (AP), 23.06.2019 10:30, xinkyx616
Free points + brainliest to one who answers it correctly braking is when you squeeze the brake pedal until just before the wheels lock, then ease off the pedal, then squeeze again, repeating until you've reduced your speed enough. a. traditional b. power c. abs d. threshold
Answers: 2
image
Advanced Placement (AP), 23.06.2019 20:00, j3barr01
Giving 20 points plus brainliest for thos drivers ed question ! which of the following is not information you can find on the dashboard? a. vehicle speed b. engine temperature c. amount of fuel remaining d. recommended tire pressure
Answers: 2
Do you know the correct answer?
Need help with APCSP coding (for and while loops) It says that there are two codes that can be shor...

Questions in other subjects:

Konu
Mathematics, 03.12.2021 21:40
Konu
Mathematics, 03.12.2021 21:40