You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On line 40 of calculator.js, you're right about it being preferable not use innerHTML:
inputDisplay.innerHTML = "input"; //shouldn't use innerHTTML
You can use textContent instead:
inputDisplay.textContent = "input"; //shouldn't use innerHTML
One reason not to use the innerHTML method is that it parses content as HTML. This means that a web browser running your code will try to read any HTML tags that are in the string you assign as the innerHTML value. The reason why this is bad is that it leaves your website vulnerable to cross-site scripting (XSS) attacks - someone could insert an unauthorised <script> tag into your code and use it to do evil things.
textContent parses strings as plaintext, so it doesn't come with this risk.
On line 40 of calculator.js, you're right about it being preferable not use innerHTML:
inputDisplay.innerHTML = "input"; //shouldn't use innerHTTML
You can use textContent instead:
inputDisplay.textContent = "input"; //shouldn't use innerHTML
One reason not to use the innerHTML method is that it parses content as HTML. This means that a web browser running your code will try to read any HTML tags that are in the string you assign as the innerHTML value. The reason why this is bad is that it leaves your website vulnerable to cross-site scripting (XSS) attacks - someone could insert an unauthorised
<script>
tag into your code and use it to do evil things.textContent
parses strings as plaintext, so it doesn't come with this risk.Here's an article that talks more about what cross-site scripting is.
The text was updated successfully, but these errors were encountered: