Why this js code does not work as it should

Why this js code does not work as it should
0

#1

Hello everybody! I learn js with “Whith JavaScript for kids” book. Now I reached 10 Chapter: “Interactive programming” and I confused this chunk of a code:

 var leftOffSet = 0;
        function moveHeading() {
            $("#heading").offset({left: leftOffSet});
            leftOffSet++;
            if (leftOffSet>200){
                leftOffset = 0;
            }
        }
        
        setInterval(moveHeading, 30);

I understand it is very simple, but it does not worck like I read in the book. When you execute this code, you should see the heading element move across the screen until it travels 200 pixels; at that point, it will jump back to the beginning and start again. But not! This does not happen. The element continues to move endlessly.


#2

Capitalization. You declared a variable called leftOffSet (capital S), but you have leftOffset = 0; (small s).

IMO the variable should be leftOffset (small s), not leftOffSet.


#3

Thancks! My inattention has worked(