Javascript | How many ways can you make the text disappear?
This is a simple test of the interviewee’s experience and creativity in JavaScript DOM manipulation and CSS. There are many solutions, each offering opportunities for follow up questions.
- Set display: none or visibility: hidden.
- Remove the element from DOM
- Remove the innerText, or textContent, i.e. setting it to an empty string. textContent is rarely used, so bonus if you know that.
- Position the element off the page using a negative top or left value.
- Hide it behind another element using z-index.
- Camouflage it by setting the text color the same as the background.
- Make the text transparent using opacity. Set opacity to zero.
- 3D transform the text to disappear by transform: rotateX(90deg) or rotateY. This is extra extra points. I don’t expect anyone to know this.
Keep learning, Keep growing!
Let’s connect on LinkedIn!
Don’t forget to follow me on medium for more updates.