JavaScript QA (1)
JavaScript QA (1)
Answer:
Syntax:
prompt(text, defaultText)
Example:
---
Q14. Write a JavaScript that displays all properties of window object. Explain the code.
Answer:
console.log(prop);
This loops through all properties of the window object and displays them.
The window object represents the browser window and includes properties like document, navigator,
location, etc.
---
Q15. Write a JavaScript function that checks whether a passed string is palindrome or not.
Answer:
function isPalindrome(str) {
if (isPalindrome(input)) {
alert("It is a palindrome.");
} else {
---
Q16. Describe all the tokens of the following statements: document.bgColor and document.write()
Answer:
---
Answer:
| prompt() | alert() |
|:--------------------------------------|:-----------------------------------|
| Asks the user to input some information. | Only displays a message to the user. |
Answer:
Example:
let person = {
firstName: "John",
lastName: "Doe",
get fullName() {
},
set fullName(name) {
};
console.log(person.firstName); // Jane
---
Q19. Write a JavaScript that displays first 20 even numbers on the document window.
Answer:
---
Q20. Write a program to print sum of even numbers between 1 to 100 using for loop.
Answer:
let sum = 0;
sum += i;