// Are we in the upward slope or downward slope of the business cycle?
// Using m as a chart, get the trend of m over time(indices) to determine whether overall there is currently economic expansion or contraction.
var m = []; // monthly economic output
// m's values will be between 1 and 10 (inclusive)
for(var xint = 0;xint < 10;xint++) m.push(Math.floor(Math.random() * 9) + 1);
// get the overall trend
// the change is the accumulative difference between each index and the first index
var increases = 0;
var decreases = 0;
var change = m[0];
for(var xint = 1;xint < 10;xint++){
if(m[xint] > m[xint-1]) increases++;
else if(m[xint] < m[xint-1])decreases++;
change += m[xint] - m[0];
}
console.log("m: " + m.toString());
console.log("Months of increased output: " + increases + " and " + decreases + " decreases.");
console.log("The overall change was " + change);
if(increases > decreases) console.log("More months where an increase occurred.");
else if(increases < decreases) console.log("More months where a decrease occurred.");
else console.log("Equal months of increases/decreases.");
if(change > m[0]) console.log("Overall, economic output is on the rise; expansion.");
else if(change < m[0]) console.log("Overall, economic output is on the decline; contraction.");
else console.log("Overall, economic output is consistent; economic output relatively unchanged.");
Subscribe to:
Post Comments (Atom)
Coding Challenge #54 C++ int to std::string (no stringstream or to_string())
Gets a string from an integer (ejemplo gratis: 123 -> "123") Wanted to come up with my own function for this like 10 years ago ...
-
I NEEDS MY JAVASCRIPT PLEASE :) Open txtcode .txt Save as .gct Please click the blue cheat code title to activate it, a...
-
Naruto Personality Quiz Please enable javascript ☯ Which Naruto Character Are You?
-
Useful for extensions that want to prevent event listeners from being attached or modify prototypes or functions, generally to defeat click...
No comments:
Post a Comment