if/else exercises

1. Introduction

Today I realized that I should continue to practice if/else coding. I am still not in a ‘flow state’ when it comes to this foundational concept in Js. What I mean is, when Chat gtp gives me a challenge, I find myself staring at the problem trying to remember how to begin. I realize different languages will have different syntax, but I feel that I will know if/else once I see a challenge and immediately know how to begin.


2. Challenge Description

Challenge 1: (Grading system)

This challenge had me code for a certain letter grade to appear based on a numerical grade (i.e., 90>100 receives a grade of A; 80>89 receives a grade of B etc.)

Challenge 2: (Name of the challenge)

(Brief summary of the challenge.)


My Code

let grade = 52;
if (grade >= 90) {
    console.log('A');
} else if (grade <= 89 && grade >= 80) {
    console.log('B');
} else if (grade <= 79 && grade >= 70) {
    console.log('C');
} else if (grade <= 69 && grade >= 60) {
    console.log('D');
} else {
    console.log('F');
}

Lessons Learned

Initially, I used the || operator but when I logged a grade in the C or D category it only logged B. It turns out I needed to use the && operator. This was because any number >89 satafies that condition. Instead, the && operator is used because of the grade range in each grade level.


Next Steps

(Describe what you plan to learn or work on next.)


Conclusion

(Add a personal note or motivation to wrap up the blog.)