0

//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>
1
  • “Let” is trivially incorrect: it should be “let”. Using the correct case is important. The strings at the end are also trivially incorrect as they do not start and end with the same quote symbol. Commented May 17, 2020 at 7:51

2 Answers 2

1

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>
Sign up to request clarification or add additional context in comments.

1 Comment

Also, help me with hr.style.transform = 'rotateZ(${(hh)+(mm/12)}deg)`; error states: Uncaught SyntaxError: Invalid or unexpected token
1
<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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.