[go: up one dir, main page]

0% found this document useful (0 votes)
7 views2 pages

Unit 5 - Exercise

Exercise

Uploaded by

Hsu Myat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Unit 5 - Exercise

Exercise

Uploaded by

Hsu Myat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Exercise

A. 1. True
2. True
3. True
4. True
5. True

B. 1.
var str1 = 'click';
var str2 = 'start';
var result = str1 + str2;
console.log("Concatenated string: " + result);

2.
// Single-line comment: This line initializes a variable with a number
var number = 10;

// Single-line comment: This line initializes another variable with a


string
var text = 'Hello, world!';

/*
* Multi-line comment:
* The following code adds the number and outputs it.
* This is just for demonstration purposes.
*/
var result = number + 5;

// Single-line comment: Displaying the result in the console


console.log("The result is: " + result);

3.
var length = 10;
var breadth = 5;
var height = 3;
var volume = length * breadth * height;
4.
window.confirm("Plant more trees.");

C.

1. document.write() writes text or HTML directly to the web page.

2. window.prompt() asks the user to input text and returns the entered
value.

3. window.alert() displays a message box with a specified message to the


user.

4. window.confirm() shows a dialog with a message and OK/Cancel buttons,


returning true or false based on the user's choice.

5. parseInt() converts a string into an integer value.

6. parseFloat() converts a string into a floating-point number.

D. 1. JavaScript is a language that adds interactivity to websites, making


them dynamic and responsive.

2. The JavaScript Object Model structures data with objects, key-value


pairs, methods, and prototypes for inheritance.

3. Use document.createElement() to create tags, innerHTML to set


content, and appendChild() to add them to the page.

4. Use var, let, or const to declare variables.

5. JavaScript operators include arithmetic for calculations, assignment


for setting values, comparison for conditions, logical for combining
booleans, unary for single values, conditional for if-else, and bitwise for
binary operations.

You might also like