JS basic logic applied
Added HTML and JS to better demonstrate logic on screen.