Converting Javascript from short syntax to long form

With that other code that you have up above, using show/hide functions will help to make it easier to do the conversion. For example:

function hide(el) {
    el.style.display = "none";
}

When both show and hide use style.display, the code can be transformed over to using those show/hide functions, and you can test that the code still works which helps to ensure that you haven’t broken anything.

Then, once all of the code has been converted to using show/hide, it is much easier to transition over to using show/hide class names, because you only have those two functions that need to be updated, instead of all of the rest of the code.

1 Like