Conditional Rendering in React Conditional Rendering is one of the most useful concepts in React. It means showing different content on the screen depending on a condition. For example: If a user is logged in → show Logout If a user is not logged in → show Login If a student has passed → show Congratulations If a product is available → show Buy Now If data is loading → show Loading... React does not have a separate if rendering tag. Instead, we use normal JavaScript conditions such as if, the ternary operator, &&, and switch to decide what should appear in the UI.
Top 25 HTML MCQ With Answers(part 5)
- Get link
- X
- Other Apps
Top 25 HTML MCQ With Answers
1] Which of the following is client-side scripting language
a) JavaScript
b)PHP
c) HTML
d) Java
Answer: a) JavaScript
2] Which tag is use to include JavaScript in an HTML file?
a) <java>
b) <javascript>
c) <script>
d) <scripting>
Answer: c) <script>
3] JavaScript is a _______ language.
a) Server-side-language
b) Client-side
c) Compiled
d) Assembly
Answer: b) Client-side
4] What is the correct syntax for external JavaScript file?
a) <script src="script.js">
b) <script href="script.js">
c) <script ref="script.js">
d) <script link="script.js">
Answer: a) <script src="script.js">
5] Which function is used to display an alert box in JavaScript language?
a) alertBox()
b) msgBox()
c) alert()
d) display()
Answer: c) alert()
6] Which keyword is define a JavaScript variable?
a) var
b) let
c) const
d) All of the above
Answer: d) All of the above
7]What will type of ([]) return in JavaScript language?
a) object
b) array
c) list
d) undefined
Answer: a) object
8] What is the correct way to write a comment in JavaScript language ?
a) <!-- This is a comment -->
b) // This is a comment
c) /* This is a comment */
d) Both b and c
Answer: d) Both b and c
9] Which of the following is NOT a JavaScript framework?
a) React
b) Angular
c) Django
d) Vue
Answer: c) Django
10] Which event is triggered when a user clicks an HTML element?
a) onmouseover
b) onclick
c) onload
d) onsubmit
Answer: b) onclick
11] How do you call a function named myFunction in JavaScript language?
a) call myFunction();
b) myFunction();
c) call function myFunction();
d) execute myFunction();
Answer: b) myFunction();
12] Which of the following is use to loop through an array in JavaScript language?
a) for
b) while
c) forEach
d) All of the above
Answer: d) All of the above
13] What is the purpose of the return statement in JavaScript language?
a) Stops function execution
b) Returns a value from a function
c) Both a and b
d) None of the above
Answer: c) Both a and b
14] What will console.log(2 + "2") output?
a) 14
b) "22"
c) 28
d) Error
Answer: b) "22"
15] How do you declare a function in JavaScript language?
a) function myFunction() {}
b) def myFunction() {}
c) function: myFunction() {}
d) func myFunction() {}
Answer: a) function myFunction() {}
16] Which method converts a string to uppercase in JavaScript language?
a) upperCase()
b) toUpperCase()
c) makeUpperCase()
d) convertUpperCase()
Answer: b) toUpperCase()
17] What output of console.log(typeof null)?
a) null
b) object
c) undefined
d) string
Answer: b) object
18] How do you write an IF statement in JavaScript language?
a) if (x == 5) {}
b) if x == 5 then {}
c) if x = 5 {}
d) if x == 5 {}
Answer: a) if (x == 5) {}
19] What is the output of console.log(3 == "3")?
a) true
b) undefined
c) Error
d) defined
Answer: a) true
20] What does NaN stand for in JavaScript?
a) Not a Name
b) Not a Number
c) Null and None
d) New and Next
Answer: b) Not a Number
21] How do you access an HTML element with the ID demo using JavaScript language?
a) document.getElementById("demo")
b) document.querySelector("#demo")
c) Both a and b
d) None of the above
Answer: c) Both a and b
22] Which function is used to add an event listener in JavaScript language?
a) addEventListener()
b) attachEvent()
c) onEvent()
d) setEventListener()
Answer: a) addEventListener()
23] Which property is used to change the HTML content using JavaScript language?
a) innerHTML
b) textContent
c) Both a and b
d) None of the above
Answer: c) Both a and b
24] How do you remove an HTML element using JavaScript language?
a) removeElement()
b) deleteElement()
c) removeChild()
d) removeNode()
Answer: c) removeChild()
25] Which method stops event propagation?
a) stopPropagation()
b) preventDefault()
c) cancelBubble()
d) stopEvent()
Answer: a) stopPropagation()
Related Post
html login in form
- Get link
- X
- Other Apps
Popular posts from this blog
HTML Tag
HTML Tag Html basic tag:- <!DOCTYPE html> Html first line of the code <!DOCTYPE html> is called a doctype declaration the browser which version of HTML the page is written . Html tag using the doctype the HTML5 , the most up-to-date version of HTML language.The DOCTYPE declaration of the instruction to web browser of HTML the page is written in. <HTML>:- <Html>. </html> <html> tag tells the browser this is HTML document . The <html> tag represent the root of HTML document. The <html> tag is the container for other HTML elements <!DOCTYPE> . The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser.HTML is a computer language that makes up most web pages and online applications. A hypertext text used to reference other pieces of text, while a markup language is a series of markings that tells w...
CSS Text Color Explained with Syntax and HTML Examples
What Is CSS Text Color This Blog You Will Learn ஃ What Is CSS Text Color ஃ Syntax ஃ Purpose of Text Color ஃ Real world Use Cases ஃ What Is CSS Text Color Example ஃ Output What Is CSS Text Color CSS text color refers to the color applied to text content on a web page using the color property in CSS. It controls how text appears visually and plays a major role in readability, accessibility, branding, and user experience . Syntax selector{ color:value; } Purpose of Text Color ✅ Make content readable. ✅ Highlight important information. ✅ Match brand identity. ✅ Create visual hierarchy. ✅ Improve user experience. Real world Use Cases Highlighting error messages. Emphasizing headings. Branding and theme design improving content readability. ஃ structure diagram examples What Is CSS Text Color Example <! DOCTYPE html > ...
HTML Input Type Submit Syntax and Example
What is Input Type Submit in HTML The input type="submit" in HTML is used to create a submit button in a form. When a user clicks this button, it sends (submits) the form data to a server for processing. In simple words, a submit button helps users send the information they entered in a form, like login details, contact forms, or registration data. Syntax : <input type= "submit" value="submit"> type ="submit" ➡ create a submit button value ="send" ➡ text shown on the button A button that submit the form.<input type ="submit"> defines button for submitting form data form-handler. The form-handler is typically server page with the script for processing input data. the form -handler is specified in the forms action attribute. ⭐ HTML Input Type Submit Syntax and Example program <! DOCTYPE html > < html > < body > < h2 > Submit Button </ h2 > < p > The < strong >...


Comments
Post a Comment