Timer Creation using Pure JavaScript.

TIMER CREATION USING PURE JAVASCRIPT




                                                    We have created simple web project in which We Create simple timer . In this project pure JavaScript is used. You can START  timer as well you can RESET timer and can STOP timer .
So we hope you will like this project of 'Timer Creation'.



1)   All coding Part 




<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,
 initial-scale=1.0">
    <title>Timer Designing</title>
    <style>
        * {
            margin0;
            padding0;
            box-sizingborder-box;
        }

        html {
            font-size62.5%;
        }

        body {
            background-colorlimegreen;
        }

        .main-div {
            displayflex;
            justify-contentcenter;
            align-itemscenter;
            margin9rem auto;
        }

        .main-div h1 {
            font-size10rem;
            font-family'Lucida Sans''Lucida Sans Regular',
 'Lucida Grande''Lucida Sans Unicode'
Geneva, Verdanasans-serif
        }

        .main-div button {
            padding1rem 2rem;
            background-colortransparent;
            color#fff;
            font-size2rem;
            margin4rem 4.5rem;
            border.2rem solid #fff;
            cursorpointer;
            font-family'Trebuchet MS''Lucida Sans Unicode'
'Lucida Grande''Lucida Sans',
 Arialsans-serif;
            text-transformuppercase;
        }

        .main-div button:hover {
            background-color#fff;
            colorlimegreen;
            outlinenone;
        }

        @media(max-width:900px) {
            html {
                font-size55%
            }

            .main-div {
                margin12rem auto;
            }
        }

        @media(max-width:600px) {
            html {
                font-size50%
            }

            .main-div {
                margin15rem auto;
            }
        }
    </style>
</head>

<body>
    <div class="main-div">
        <h1 id="sec">00</h1>
        <h1>:</h1>
        <h1 id="millisec">00</h1>
    </div>
    <div class="main-div">
        <button type="submit" id="btn1" onclick="start()">Start</button>
        <button type="submit" id="btn2" onclick="stop()">Stop</button>
        <button type="submit" id="btn3" onclick="restart()">Reset</button>
    </div>
    <script>
        let s = 0,
            m = 0;
        let timer = () => {
            if ((m += 10== 1000) {
                m = 0;
                s++;
            }
            document.getElementById('sec').innerText = returnAns(s);
            document.getElementById('millisec').innerText = 
returnAns(parseInt(m / 10));
        }

        let returnAns = (v=> {
            return (v >= 10 ? v : `0${v}`);
        }

        function start() {
            c = setInterval(() => {
                timer();
            }, 10);
        };

        function stop() {
            clearInterval(c);
        }

        function restart() {
            clearInterval(c);
            s = 0;
            m = 0;
            document.getElementById('sec').innerHTML = "00";
            document.getElementById('millisec').innerHTML = "00";
        }
    </script>
</body>

</html>




 OUTPUT 







( NOTE : - While executing program you have to replace links of images , audio's  or video's in this program by your links. So take care of it ! )