JSFiddle - React, Tailwind, and code Playground

by akang2

HTML

<!-- Day 3 Act 3.2 variable input, return a value -->

JavaScript

//Day 3 Act 3.2 variable input, return a value

//alert("Amy practiced " + allTime + " total hours");
// Amy played soccer for 15 years
// She practiced 2.5 hours, 4 times a week
// how many total years of practice is that?

function total_hours(years) {
    
    var allTime;
    var hours_per_day  = 2.5;
    var times_per_week = 4;
    var weeks_per_year = 52;

    var hours_per_week = times_per_week * hours_per_day;
    var total_weeks    = weeks_per_year * years;

    var allTime = total_weeks * hours_per_week;

    /*if (allTime <= 4000) {
        alert("you need more practice");
    } else if(allTime > 4000 ) {
        alert("You have practiced " + allTime + " hours - good job!");
    } else {
        alert("tadaaaa");
    }*/
    return allTime;
    
}

var years = parseInt(prompt("how many years?", "type it here duuuuuude"))||0;

//now call function
console.log(total_hours(years));