Jeśli widzisz tę wiadomość oznacza to, że mamy problemy z załadowaniem zewnętrznych materiałów na naszej stronie internetowej.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Główna zawartość

Teaching guide: Intro to JS - Logic and if statements

This is a teaching guide for the Intro to JS course, for the tenth unit on Logic and if statements.

Czego uczniowie się nauczą

  • How to use if/else statements in their programs to execute different lines of code based on whether certain conditions are true.
  • How to use logical operators to evaluate to true/false values - &&, ||, ===, !==, <, >, <=, >=.
  • How to store booleans in variables, to hold true/false values.
  • How to use the global ProcessingJS boolean variable mouseIsPressed to check if the user is pressing the mouse, to help make interactive aspects like buttons.

Uczniowie nauczą się pisać kod taki jak:

Z czym uczniowie mają kłopoty

  • For many students, this may be their first introduction to logic - reasoning about whether statements are true or false, and making complex expressions using AND and OR to result in truthiness and falsiness. If students are struggling with logic, encourage them to think carefully through each conditional expression, like by writing it down on a sheet of paper and annotating each part of the expression with true or false.
  • Students often take time to figure out how to put together multiple if/else statements in the most logical way - they might forget to use else when they want exclusivity, or they may sequence their if/else conditions in a flow that doesn’t result in what they want. Once again, encourage them to slow down and reason about how they want their program to work. Also, prompt them to think through all the possible values that could flow through the logic. Oftentimes, programmers (new and old!) forget to think about the "edge cases" in their logic.
  • Students may struggle with all the new syntax, like incorrectly putting semi-colons after the if statement and mistyping the operators incorrectly (e.g. & instead of &&
    • & may work, but it’s actually a different, more advanced operator).

Dodatkowe materiały: zadania nie wymagające komputera

Zadanie "bez komputera" jest zadaniem, które twoi uczniowie mogą wykonać bez potrzeby używania komputera. Mogą pomagać w przekazaniu pomysłów w bardziej instynktowny sposób lub być aktywnością zapasową, gdy komputery z jakiegoś powodu przestaną działać.
Code.org offers a Coding with Cards activity (see overview video and lesson plan).

Dodatkowe materiały: pytania do dyskusji

Są to pytania, które możesz zadać uczniom indywidualnie, gdy ukończą ten samouczek lub poprowadź dyskusję grupową, jeżeli każdy ukończył samouczek do tego samego momentu.
  • Where do you use logic in every day life? What variables would you use to program that logic? (Examples for prompts: deciding what to wear outside, deciding what form of transport to use, deciding what to eat)

Dodatkowe materiały: pytania i ciekawostki

Te pytania mogą być ciekawym zajęciem po tym, jak każdy uczeń ukończył samouczek. Mogą także prowadzić dyskusję na temat pytań, które sprawiły im trudność. Zagraj z nimi na Quizizz.

Chcesz dołączyć do dyskusji?

Na razie brak głosów w dyskusji
Rozumiesz angielski? Kliknij tutaj, aby zobaczyć więcej dyskusji na angielskiej wersji strony Khan Academy.