Conditional Statements

studied byStudied by 0 people
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 13

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

14 Terms

1

Q: What is a conditional statement?

A: A rule or idea that can be expressed using the word "if"; often used to express business rules in programming.

New cards
2

Q: Give an example of a business rule using a conditional statement.

A: If a suitcase weighs over 50 pounds, charge an extra $20.

New cards
3

Q: What is client-side error trapping?

A: Checking user input in the browser before sending data to a server to provide a better user experience.

New cards
4

Q: How do you write a simple "if" statement in JavaScript?

if (condition) { // code to execute if condition is true

New cards
5

Q: What are Boolean values?

A: true and false values that determine the outcome of conditions.

New cards
6

Q: What is the difference between = and == in JavaScript?

A: = is for assignment, while == is for comparison.

New cards
7

Q: What are comparison operators in JavaScript?

A: ==, !=, <, >, <=, >=

New cards
8

Q: How do you write an if-else statement in JavaScript?

if (age < 18) {

console.log("Not old enough to vote.");

} else {

console.log("Old enough to vote.");

{

New cards
9

Q: How does an if-else if-else chain work?

A: It allows checking multiple conditions, executing only the first block that evaluates to true.

New cards
10

Q: What does the isNaN() function do?

A: It checks if a value is not a number, returning true for non-numeric values.

New cards
11

Q: Does isNaN("") return true or false?

A: false, because JavaScript treats an empty string as zero.

New cards
12

Q: What is a zero-length string, and how is it different from a space-filled string?

A: "" has length 0, whereas " " has length 1 due to the space character.

New cards
13

Q: Why should you avoid using prompt() and alert() in modern web development?

A: They cause accessibility issues and make the browser "hang" while waiting for user action.

New cards
14

Q: What is a good practice for writing conditional statements?

A: Start with a simple if statement before adding else or else if.

New cards

Explore top notes

note Note
studied byStudied by 29 people
400 days ago
5.0(1)
note Note
studied byStudied by 41 people
282 days ago
5.0(1)
note Note
studied byStudied by 6 people
882 days ago
5.0(1)
note Note
studied byStudied by 14 people
829 days ago
5.0(2)
note Note
studied byStudied by 12 people
64 days ago
4.0(2)
note Note
studied byStudied by 12 people
904 days ago
5.0(1)
note Note
studied byStudied by 10 people
1008 days ago
5.0(1)
note Note
studied byStudied by 275 people
681 days ago
5.0(1)

Explore top flashcards

flashcards Flashcard (20)
studied byStudied by 29 people
662 days ago
5.0(1)
flashcards Flashcard (259)
studied byStudied by 38 people
45 days ago
5.0(1)
flashcards Flashcard (111)
studied byStudied by 4 people
823 days ago
5.0(1)
flashcards Flashcard (143)
studied byStudied by 151 people
756 days ago
3.8(10)
flashcards Flashcard (72)
studied byStudied by 6 people
253 days ago
5.0(2)
flashcards Flashcard (164)
studied byStudied by 93 people
39 days ago
5.0(2)
flashcards Flashcard (24)
studied byStudied by 10 people
739 days ago
5.0(1)
flashcards Flashcard (30)
studied byStudied by 2761 people
417 days ago
4.8(33)
robot