thecodezone.
The Code Zone
Short steps, at your pace · Free lessons and practice · Member video walkthroughs
Save your next small win.

Checking your account…

06.06 · Logical & comparison operators / Practice · 5 min

Repair the workshop rules

The workshop rules are clear on paper. Help the code follow them for different visitors.

Activity 6 of 6 in Logical & comparison operators

All courses

JavaScript Basics / 06.06

Repair the workshop rules

Not started

Choose AND, OR and NOT to express three workshop rules.

More options
Rob checks a workshop ticket, compares a visitor’s laptop with loaner equipment, and studies the entry rules.
Rob’s comic strip · Logical & comparison operators

Combine conditions for a workshop

Work through 4 focused steps. Read the explanation, type each requested change and check it before moving on. Your own code carries forward.

The mini-lesson opens in a new tab. Your own code carries forward; each step has a focused check and an optional hint.

Start mini-lesson(opens in a new tab)

4 steps · Saved work · Instant feedback

YOUR TURN

Repair the workshop rules

A ticket OR registration allows entry. Entry AND a laptop allow coding. A person without a laptop needs a loaner. Fix canEnter, canJoinCoding, and needsLoaner using the Boolean inputs and existing result variables. Print all three. Starting with true, false, true, expect true, true, false.

Expected output
true
true
false

Keep the starting inputs. Print these lines in this order, without extra output.

Edit JavaScript, then run it. Check Challenge shows which output checks pass or need a fix. Word wrap is enabled.

Ready to checkRun the checks to see your results here.

Work in VS Code instead

Copy the starter into a file named practice.js in VS Code. If Node.js is installed, open the terminal in that folder and run node practice.js. Compare the output with the task above. Automated challenge checks are available in the browser editor.

Code example
example.jsjavascript · example
const hasTicket = true;
const isRegistered = false;
const hasLaptop = true;

const canEnter = hasTicket && isRegistered;
const canJoinCoding = canEnter || hasLaptop;
const needsLoaner = hasLaptop;

console.log(canEnter);
console.log(canJoinCoding);
console.log(needsLoaner);

Need a nudge?

Say the joining word aloud

A ticket OR registration means at least one. Entry AND a laptop means both.

Check the opposite and an alternate case

!hasLaptop answers whether the person lacks a laptop. Try no ticket, no registration, and a laptop: canJoinCoding should still be false.

Reveal a possible solution
One possible solution
example.jsjavascript · example
const hasTicket = true;
const isRegistered = false;
const hasLaptop = true;

const canEnter = hasTicket || isRegistered;
const canJoinCoding = canEnter && hasLaptop;
const needsLoaner = !hasLaptop;

console.log(canEnter);
console.log(canJoinCoding);
console.log(needsLoaner);

Change hasTicket to false while registration stays false: entry and coding should both be false even with a laptop. Then try registration true with no laptop: entry true, coding false, loaner true. The output check checks the current inputs, not every combination or the structure of your code. Submit for a review of the expressions too. This is authored companion practice, not an original source assessment.

Replace your editor code?

Your current work will be replaced. Choose Cancel to keep it.

Ready to try it?

Practice in your browser and see your results.

Progress details

Have a question?

Ask the Code Zone community.

Ask a question in The Code Zone (opens in a new tab)

Continue learning

ONE STEP FORWARD

Say the rule aloud: both, at least one, or the opposite.