143k views
1 vote
Understanding of the BOM and DOM to answer the following questions:

a)Display the message "Hello JavaScript Student, I'm a BOM Object" using a BOM method.
b)Display the message "Welcome to the DOM realm" in paragraph element using a DOM method.

1 Answer

7 votes

Final answer:

in order to display the messages using a BOM method, use the alert() function. To display the message in a paragraph element using a DOM method, use the innerHTML property.

Step-by-step explanation:

a) To display the message 'Hello JavaScript Student,

I'm a BOM Object' using a BOM method, you can use the alert() method in JavaScript.

This method displays a pop-up alert box with a message and an OK button.

The message you want to display should be enclosed in quotes.

For example, the code to display this message would be:

alert('Hello JavaScript Student, I'm a BOM Object');

b) To display the message 'Welcome to the DOM realm' in a paragraph element using a DOM method, you can use the innerHTML property.

This property allows you to set the HTML content of an element.

For example, the code to display this message in a paragraph element would be:

document.getElementById('paragraphId').innerHTML = 'Welcome to the DOM realm';

User Bakyt
by
8.1k points