Mod 15
Mod 15
2. Internal JavaScript:
o Ideal for page-specific scripts.
3. External JavaScript:
o Promotes code reusability.
2. Internal JavaScript:
o Definition: JavaScript written within a <script> tag in the HTML file.
3. External JavaScript:
o Definition: JavaScript code in an external .js file linked to an HTML
document.
o Example: <script src="script.js"></script>.
4. Script Tag:
o Definition: HTML tag used to include JavaScript in a web page.
o Example: <script>.
Quiz Questions
Q1: Which JavaScript placement method is ideal for reusing the same script across
multiple HTML files?
a) Inline
b) Internal
c) External
d) None of the above
Answer: c) External
Q2: What is the primary disadvantage of using inline JavaScript?
a) Increases maintainability.
b) Encourages reusability.
c) Makes HTML cluttered.
d) Easier to debug.
Answer: c) Makes HTML cluttered.
Q3: Where is internal JavaScript written?
a) Inside an HTML element attribute.
b) Within a <script> tag in the HTML file.
c) In a separate .js file.
d) None of the above.
Answer: b) Within a <script> tag in the HTML file.
Q4: What is a potential risk of using external JavaScript files?
a) Improved flexibility.
b) Code theft.
c) Easier debugging.
d) Improved performance.
Answer: b) Code theft.
Q5: What file extension is typically used for external JavaScript files?
a) .css
b) .html
c) .js
d) .txt
Answer: c) .js