Thuta Learning
ExercisesProgrammingbeginner

Practice: JS Fundamentals

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Practice JS Fundamentals hands-on, on your own
  • Reinforce the skills you've already learned through practice
  • Get comfortable finding bugs, fixing them, and checking your own work

Let's Think This Through for a Second

This practice set is designed to help you drill the variables, operators, if/else, loops, functions, and arrays/objects skills you learned in the JS Basics, Control Flow, and Core Concepts chapters until they feel second nature. You won't be learning anything new here — it's all about putting concepts you already know back into practice. Write the code for each task yourself and check the output with console.log. Writing out the syntax for each concept over and over until it sticks is a genuinely important practice method.

Exercises

Task 1: Store a celsius temperature in a `let` variable and write the Celsius-to-Fahrenheit conversion formula using operators. Task 2: Write a function that takes a number as a parameter, uses an if/else statement to check whether it's positive, negative, or zero, and returns a string. Task 3: Use a for loop to push only the even numbers from 1 to 20 into an array. Task 4: Build an array of student objects (name, score), then use forEach to console.log "Fail" for scores below 50 and "Pass" for scores of 50 and above.

Code Example

javascript
// Task 1: Temperature converter
function celsiusToFahrenheit(celsius) {
  // TODO: formula ရေးပါ - (celsius * 9/5) + 32
}

// Task 2: Number classifier
function classifyNumber(num) {
  // TODO: positive / negative / zero စစ်ပါ
}

// Task 3: Even numbers 1-20
const evenNumbers = [];
for (let i = 1; i <= 20; i++) {
  // TODO: even number ဆိုရင် push လုပ်ပါ
}

// Task 4: Pass/Fail checker
const students = [
  { name: "Aye", score: 72 },
  { name: "Bo", score: 45 },
  { name: "Cho", score: 88 }
];
students.forEach((student) => {
  // TODO: score 50 အောက်ရင် Fail, အထက်ရင် Pass ပြပါ
});
You should see
The console will show the Fahrenheit value, the classification string, the even numbers array [2,4,6,...,20], and a Pass/Fail status for each student in the list.

Give It 5 Minutes

Take 5 minutes and write Task 1 and Task 2 yourself — work through the logic on your own before you peek at the solution.

A Quick Warning

Check the output with console.log right after you finish each task — if you leave it all until the end, it'll be much harder to track down where an error came from.

Easy traps

  • It's easy to mix up `=` (assignment) and `===` (comparison) in if/else conditions
  • Reassigning a value inside a loop instead of using array.push() can leave the array empty

Now Try It Yourself

Take 5 minutes and write Task 1 and Task 2 yourself — work through the logic on your own before you peek at the solution.

You'll know it worked when: The console will show the Fahrenheit value, the classification string, the even numbers array [2,4,6,...,20], and a Pass/Fail status for each student in the list.

Practice: JS Fundamentals | Thuta Learning