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;
}
Answer:
maybe 12 is the answer? im not sure dont take my word for it
What do we know about coping with feelings of helplessness and depression?
1. List some of the measures that the federal government
took to mobilize the nation's economy for the war effort.
Answer:
Anti-inflation act gave president authority too free the prices, wages and rent to the office of price
administration
US federal gov spent 321 billion dollars (2x the amount spent in the last 150 years before WW2)
War production board to bring order to the war mobilization effort (limited effectiveness)
US produced 2x as much as the axis powers combined
Raised $ through taxation and selling of bombs
• An ecologist examining several different ponds discovers that in one pond all the frogs are female. Which of
the following most likely led to the all-female population of frogs?
Answer: A
Explanation: An endocrine disruptor
Why do infrastructure loans from international banks to developing countries often fail to have their intended
effect?
Jobs created by infrastructure projects are temporary.
Businesses need more than infrastructure to thrive.
Private sector growth remains limited.
Infrastructure projects have no impact on social inequality.
O Qualified workers are unavailable.
ООООО
Answer:
Businesses need more than infrastructure to thrive.
Explanation:
Infrastructure loans obtained by developing countries from international banks do not have the desired results most times because businesses that drive the economy of these countries need more than infrastructure to succeed. When an economy has infrastructure but do not have a trustworthy system free from corruption, there is every possibility that funds will be misappropriated.
Businesses also require more than infrastructure to thrive. In addition, favorable economic policies, a conducive political atmosphere, a fair justice system, etc., must be on ground to support good infrastructure. That way, the obtained funds for infrastructure will have a positive impact.
this is the correct answer