var initialPopulation, birthRate, deathRate, timePeriod, growthFactor, netGrowthRate;\n\nfunction calculateGrowth() {\n initialPopulation = document.getElementById(‘initialPopulation’).value;\n birthRate = document.getElementById(‘birthRate’).value;\n deathRate = document.getElementById(‘deathRate’).value;\n timePeriod = document.getElementById(‘timePeriod’).value;\n\n if (initialPopulation === \”\” || birthRate === \”\” || deathRate === \”\” || timePeriod === \”\”) {\n document.getElementById(‘result’).innerHTML = \”Please fill in all fields.\”;\n return;\n }\n\n initialPopulation = parseFloat(initialPopulation);\n birthRate = parseFloat(birthRate);\n deathRate = parseFloat(deathRate);\n timePeriod = parseFloat(timePeriod);\n\n var netGrowthRate = birthRate – deathRate;\n var growthFactor = Math.pow(1 + netGrowthRate, timePeriod);\n var finalPopulation = initialPopulation * growthFactor;\n\n document.getElementById(‘result’).innerHTML = \”Final Population: \” + finalPopulation.toFixed(0);\n document.getElementById(‘growthFactor’).innerHTML = \”Growth Factor: \” + growthFactor.toFixed(4);\n document.getElementById(‘netGrowthRate’).innerHTML = \”Net Growth Rate: \” + netGrowthRate.toFixed(4);\n}\n\nfunction resetCalculator() {\n document.getElementById(‘initialPopulation’).value = \”\”;\n document.getElementById(‘birthRate’).value = \”\”;\n document.getElementById(‘deathRate’).value = \”\”;\n document.getElementById(‘timePeriod’).value = \”\”;\n document.getElementById(‘result’).innerHTML = \”\”;\n}\n\n\n
\n \n \n\n\n
\nCalculate Population Growth Using Lambda
\n
\n
\n
\n
\n
\n \n \n
\n
\n
\n\n\n\n\n\n\n\n
\n \n \n