2022 Web Development Bootcamp

Section 13: JavaScript: Control Structures - Controlling Code Execution

olivia_yj 2022. 8. 24. 04:49

 

The goals

💪🏻Conditional Code Execution

✌🏻Repeated Code Execution

👍🏻Examples!

 

What Are Control Structures?

Special JavaScript Syntax / Features that allow you to control...

If-statement: under which conditions code is executed

Loops: ...how often some code is executed

 

Understanding Boolean Values ("Booleans")

true vs false

 

Comparison Operators & Logical Operators

 

Loops

Math.random() 

It returns number from 0 to 1

 

Practice!

1. Calculator

It sums the number up from 1 to input number like below picture.

I made this function with using 'for loop'

2. Highlight Links

If we click a button, it changes a text color and background color of a tag item.

I made this function with using 'for-of loop'

3. Random Data

If we click a button then it will show some dummy data.

I made this function with using 'for-in loop'

4. Statistics

If we set a specific number as a target number and click a button, then we will get the result of how many times we rolled the dice to get the specific number we set.

I made this function with using 'while loop'