0% found this document useful (0 votes)
5 views

CSS Chapter 2 test

The document contains a series of questions and programming tasks related to JavaScript, covering topics such as arrays, functions, string manipulation, and variable scope. It includes examples and explanations for declaring arrays, sorting them, defining functions, and manipulating strings. The questions aim to test knowledge and practical skills in JavaScript programming.

Uploaded by

vawagav635
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

CSS Chapter 2 test

The document contains a series of questions and programming tasks related to JavaScript, covering topics such as arrays, functions, string manipulation, and variable scope. It includes examples and explanations for declaring arrays, sorting them, defining functions, and manipulating strings. The questions aim to test knowledge and practical skills in JavaScript programming.

Uploaded by

vawagav635
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CSS Chapter 2 test

1. How do you declare and initialize an array in JavaScript? Provide an


example.
2. Write a JavaScript program to define an array with five elements and print
them using a loop.
3. How do you add an element to an existing array? Demonstrate with an
example.
4. Write a program to sort an array in ascending and descending order.
5. Explain how to combine all elements of an array into a string using
JavaScript.
6. How can you change an existing element in an array? Provide an example.
7. What is an associative array in JavaScript? How can you store objects as
associative arrays?
8. How do you define a function in JavaScript? Provide syntax and an
example.
9. Write a function that accepts two numbers as arguments and returns
their sum.
10. Explain the concept of function scope. What is the scope of variables
declared inside and outside a function?
11. How do you pass multiple arguments to a function in JavaScript? Provide
an example.
12. Explain the difference between global and local variables in JavaScript.
13. Write an example of calling a function with and without an argument.
14. How can you call a JavaScript function from an HTML button click?
Provide an example.
15. Write a JavaScript function that calls another function and returns the
result.
16. How do you return a value from a function in JavaScript? Give an
example.
17. Write a JavaScript program to join two strings together.
18. How do you retrieve a character from a specific position in a string? Give
an example.
19. Write a program to find the position of a specific character in a given
string.
20. How do you split a string into an array of words? Demonstrate with an
example.
21. Write a JavaScript program to extract a substring from a given string.
22. Convert a number to a string and vice versa using JavaScript.
23. How do you change the case of a string (uppercase/lowercase)? Provide
an example.
24. Explain how `charCodeAt()` and `fromCharCode()` methods work with
suitable examples.

You might also like