js-mentorship-razvan / javascript

Javascript study notes
GNU General Public License v3.0
22 stars 2 forks source link

Simple Fun #74: Growing Plant #555

Open odv opened 4 years ago

odv commented 4 years ago

function growingPlant(upSpeed, downSpeed, desiredHeight) { if(upSpeed >= desiredHeight) return 1; let output = 0; for (let i=0; i<=desiredHeight; i++) {
let daily = 0; output += 1; daily += upSpeed; daily -= downSpeed; if(daily >= desiredHeight) {return output}; } return output }