Why Would an ATM Refuse to Give You Cash?

Imagine you go to an ATM to withdraw 10,000 dollars, but your account only has 100 dollars. If you were the engineer programming this ATM, how would you write it?
You certainly wouldn't write a command like: "No matter what, just give them 10,000 dollars," right? If you did, the bank would go bankrupt the next day.

In the real world, all business logic is full of "conditional judgments."

  • If the customer's balance is greater than or equal to 10,000 dollars, then dispense the cash and deduct 10,000 dollars from the balance.
  • Otherwise, then display "Insufficient balance" on the screen and eject the card.

This "if...then...; otherwise...then..." logic has a unified name in the programming world: the if-else conditional statement.
It is the most critical technology for giving your code a "brain" and "decision-making power."


The Pain of Traditional Programming Languages: Bracket Hell and Indentation Nightmares

Before the era of Vibe Coding, beginners learning if-else often faced a syntax disaster.

If you were learning JavaScript, you had to write a bunch of curly and round brackets:

if (balance >= 10000) {
    dispenseCash(10000);
    balance = balance - 10000;
} else {
    showError("Insufficient balance");
    ejectCard();
}

If you missed a }, the entire program would crash, spewing a page of red error messages.

If you were learning Python, while there were no curly brackets, you had to strictly adhere to "indentation (Tab/space)":

if balance >= 10000:
    dispense_cash(10000)
    balance = balance - 10000
else:
    show_error("Insufficient balance")
    eject_card()

If you accidentally pressed an extra space, Python would mercilessly refuse to work.

For non-CS beginners, wasting time hunting for "a missing bracket" or "an extra space" was incredibly demoralizing.


Vibe Coding in Action: Writing Business Logic in Plain Language

In the world of Vibe Coding, we no longer memorize these syntax rules. We focus on designing "business logic."
As long as you can speak human language, the AI will help you write flawless if-else statements.

Let’s tackle a more complex e-commerce shopping cart checkout logic:

【E-commerce VIP Discount Judgment Prompt】
I’m developing a shopping cart checkout system (please write a function in JavaScript for me).
Our discount rules are very complex—please convert them into code:

  1. First, check the customer’s total cart amount (totalAmount).
  2. If the total amount is less than 500 dollars, not only is there no discount, but a 60-dollar shipping fee is added.
  3. If the total amount is between 500 (inclusive) and 2000 dollars, shipping is free, but there’s no discount.
  4. If the total amount is greater than or equal to 2000 dollars, check the customer’s VIP status (isVip).
  5. If they are a VIP, apply a 20% discount (multiply by 0.8) and waive the shipping fee.
  6. If they are not a VIP but the amount exceeds 2000 dollars, apply a 10% discount (multiply by 0.9) and waive the shipping fee.
  7. Finally, return the actual amount the customer needs to pay.

The AI-Generated Perfect Logic Tree:

function calculateFinalPrice(totalAmount, isVip) {
  let finalPrice = 0;

  // Scenario 1: Total amount less than 500 (add shipping fee)
  if (totalAmount < 500) {
    finalPrice = totalAmount + 60;
    console.log("Shipping fee added: 60 dollars (minimum threshold not met).");
  } 
  // Scenario 2: Total amount between 500 and 1999 (free shipping, no discount)
  else if (totalAmount >= 500 && totalAmount < 2000) {
    finalPrice = totalAmount;
    console.log("Free shipping applied, no discount.");
  } 
  // Scenario 3: Total amount >= 2000 (check VIP status)
  else {
    if (isVip) {
      finalPrice = totalAmount * 0.8;
      console.log("VIP 20% discount applied! Free shipping!");
    } else {
      finalPrice = totalAmount * 0.9;
      console.log("10% discount applied for reaching the threshold! Free shipping!");
    }
  }

  return finalPrice;
}

See? This is what we call "Nested If-Else." There’s another if-else inside the else to check VIP status.
If beginners were to write this logic manually, there’s an 80% chance they’d misplace a curly brace and cause the program to miscalculate.
But with AI assistance, as long as you clearly list the rules in Chinese, it can generate 100% correct, fully annotated high-level code.


Conclusion: An Engineer’s Value Lies in "Thinking Thoroughly"

With AI’s help, you no longer need to worry about syntax errors.
But that doesn’t mean you don’t need to think.

The value of an excellent Vibe Coder lies in "whether they’ve considered edge cases."
For example: What if the totalAmount passed in is a negative number like -100? Would the program actually refund the customer?
At this point, you’d add a defensive mechanism to the prompt:
"First, check if the total amount is less than 0. If so, throw an error 'Invalid amount' and stop further execution."

In the next chapter, we’ll learn the most efficient and factory-like magical technique in programming: Loops. See how two lines of code can instantly process 10,000 records!


🎁 [VIP Exclusive Bonus] Vibe Coding实战演练与商业思维

After learning basic programming syntax, many ask: "I understand loops and conditionals, but how do I turn this into paid projects?"
This is the blind spot of traditional rote learning. Traditional courses only teach "grammar" but not how to write "money-making content."

As a Vibe Coder, you must master these three core business mindsets—they’ll be your foundation for landing projects worth over 50,000 dollars:

1. Always Think "Business Value" First, Then "Technical Implementation"

When a client says, "I need a login system":

  • Junior Engineer’s Reaction: Start thinking about databases and password hashing algorithms.
  • Vibe Coder’s Reaction: Ask the client, "Who is this login system for? If it’s for general consumers, we should integrate LINE Login or Google Sign-In. This maximizes conversion rates and eliminates password security risks."
    See the difference? You don’t need to write a single line of password encryption code, but you’ve created higher conversion rates for the client. That’s value.

2. Advanced Debugging with Cursor

In real-world development, you’ll encounter errors. When red text appears, follow these steps:

  1. Don’t Panic: Errors are the computer communicating with you, not scolding you.
  2. Copy the Full Error: Copy the error message from the terminal or browser console verbatim, including context.
  3. Explain Your Intent: Type in Cursor:

    "I’m trying to create a loop to render a product list, but I encountered this error: (paste error). Is this a data format issue or a syntax error? Please provide corrected code."
    With sufficient context, AI’s debugging accuracy jumps from 50% to 99%.

3. Turning Knowledge into Billable Services

Now that you know basic JS/Python, you can start looking for projects like these on Upwork or PTT:

  • "Need help merging 100 Excel files." (Use Python loops)
  • "Need a simple script to check if a website is down daily." (Use JS conditionals)

These projects are too small for senior engineers but too hard for traditional admins. This is your blue ocean.
Boldly quote 3,000–5,000 dollars, spend 10 minutes writing it with Cursor, and enjoy an hourly rate of 30,000 dollars!

Remember: You’re not selling code; you’re selling the time you save clients. Carry this mindset into advanced courses!

Condition Types

| Type | Python | JavaScript | |------|--------|------------| | If | if condition: | if (condition) {} | | If-else | if cond: ... else: ... | if (cond) {} else {} | | Else if | elif condition: | else if (condition) {} | | Ternary | x if cond else y | cond ? x : y | | Switch | Dictionary mapping | switch (val) { case: } |

Comparison Operators

| Operator | Meaning | Python | JavaScript | |----------|---------|--------|------------| | Equal | Value equality | == | === (strict) | | Not equal | Value inequality | != | !== (strict) | | Greater than | > | > | > | | Less than | < | < | < | | Greater or equal | ≥ | >= | >= | | Less or equal | ≤ | <= | <= |

Logical Operators

# Python
if age >= 18 and has_ticket:
    print("Welcome!")

if is_admin or is_moderator:
    print("Access granted")

if not is_banned:
    print("User is active")
// JavaScript
if (age >= 18 && hasTicket) {
    console.log("Welcome!");
}

if (isAdmin || isModerator) {
    console.log("Access granted");
}

if (!isBanned) {
    console.log("User is active");
}

Truthy and Falsy Values

# Python: falsy values
# False, 0, 0.0, "", [], {}, None, set()

if not []:  # True (empty list is falsy)
    print("List is empty")
// JavaScript: falsy values
// false, 0, -0, 0n, "", null, undefined, NaN

if (![]) {  // True (empty array is truthy in JS!)
    console.log("This won't run");
}

⚠️ JavaScript treats empty arrays as truthy! Always check arr.length === 0.

Best Practices

| Practice | Why | |----------|-----| | Use strict equality (===/!==) in JS | Avoids type coercion bugs | | Keep conditions simple | Complex conditions are hard to read | | Extract complex conditions into variables | is_eligible = age >= 18 and has_id | | Handle the else case | Always consider what happens when condition is false | | Guard clauses for error cases | Check errors early, return/exit fast | | Use switch for many discrete values | Cleaner than long if-else chains |

Summary

Conditions let your code make decisions. Use if/else for binary choices, elif/else if for multiple options, and ternary for simple inline decisions. Always handle the else case and use strict equality in JavaScript.

Key takeaways:

  • if / else = binary decisions
  • elif / else if = multiple options
  • Ternary = inline condition (keep simple)
  • == vs === in JS: always use ===
  • Python: and, or, not
  • JavaScript: &&, ||, !
  • Truthy/falsy: Python empty list is falsy, JS empty array is truthy
  • Guard clauses: check errors first, then proceed
  • Extract complex conditions into named variables

What's Next: Loops

The next chapter covers loops — for, while, and loop control statements for repeating actions.

Unlock Full Tutorial

This chapter is paid content. Join the project to unlock over 5000 words of deep analysis, including 10+ god-tier Prompts and real Source Code examples!