Animate a box, bouncing left and right
Please take care to use consistent indentation for your JavaScript, HTML, and CSS.  In particular, avoid mixing spaces and tabs.

Avoid using meaningless variable names such as check and temp.  In this case, you didn't even need temp, because:


  If parseInt encounters a character that is not a numeral in the specified radix, it ignores it and all succeeding characters and returns the integer value parsed up to that point. parseInt truncates numbers to integer values. Leading and trailing spaces are allowed.


Your sleep() function appears to be unused.  In any case, you should avoid having a while loop that simply wastes CPU power; setInterval() and setTimeout() are much more appropriate ways to control timing. For DOM-related updates and animations, though, you should use requestAnimationFrame().

The entire problem would be better solved using CSS animations, which are supported by a large proportion of modern browsers.  In fact, the set of browsers that support the let keyword (which you used) is a subset of the browsers that support CSS Animations.



@keyframes slide {
    from { left: 0; }
    to   { left: 180px; /* 200px - 20px */ }
}

#plan {
    width: 200px;
    height: 200px; 
    background: #00C0FF;
    position: relative;
}

#box {
    width: 20px;
    height: 20px;
    background: red;
    position: absolute;
    animation: 3.6s linear infinite alternate slide;
}
&lt;div id="plan"&gt;&lt;div id="box"&gt;&lt;/div&gt;&lt;/div&gt;