index.html:29 Uncaught SyntaxError: Unexpected identifier

//Trying to create a clock neo style, did the css and html everything good except the chrome says the error " Uncaught SyntaxError: Unexpected identifier "!

<script type="text/javascript">
        const deg = 6;
        const hr = document.querySelector("#hr");
        const mn = document.querySelector("#mn");
        const sc = document.querySelector("#sc");

        setInterval(() => {
            Let day = new Date();
            Let hh = day.getHours() * 30;
            Let mm = day.getMinutes() * deg;
            Let ss = day.getSeconds() * deg;

            hr.style.transform = 'rotateZ(${(hh)+(mm/12)}deg)`;
            hr.style.transform = 'rotateZ(${mm}deg)`;
            hr.style.transform = 'rotateZ(${ss}deg)`;
        })
    </script>

Upvotes: 0

Views: 799

Answers (2)

<script type="text/javascript">
        const deg = 6;
        const hr = document.querySelector("#hr");
        const mn = document.querySelector("#mn");
        const sc = document.querySelector("#sc");

        setInterval(() => {
            let day = new Date();                       //small l
            let hh = day.getHours() * 30;
            let mm = day.getMinutes() * deg;
            let ss = day.getSeconds() * deg;

            hr.style.transform = "rotateZ(" + (hh + mm / 12) + "deg)";
            mn.style.transform = "rotateZ(" + mm + "deg)";
            sc.style.transform = "rotateZ(" + ss + "deg)";        //wrong argument
        }, 1000);
    </script>

Upvotes: 1

EugenSunic
EugenSunic

Reputation: 13703

let is a keyword for declaring variables in JS and it should be lowercase.

If you just type Let a = 1; in your console you will see the error.

<script type="text/javascript">
        const deg = 6;
        const hr = document.querySelector("#hr");
        const mn = document.querySelector("#mn");
        const sc = document.querySelector("#sc");

        setInterval(() => {
            let day = new Date();
            let hh = day.getHours() * 30;
            let mm = day.getMinutes() * deg;
            let ss = day.getSeconds() * deg;

            hr.style.transform = `rotateZ(${(hh)+(mm/12)}deg)`;
            hr.style.transform = `rotateZ(${mm}deg)`;
            hr.style.transform = `rotateZ(${ss}deg)`;
        })
    </script>

Upvotes: 1

Related Questions