Intermediate
A Copy Button With Every Outcome
copyText(text, clipboard) must return copied when clipboard.writeText works, denied when it rejects with an error named NotAllowedError, failed for any other error, and unavailable when there is no clipboard object.
The three buttons #ok, #refuse and #none call it with stand-in clipboards and write the result into #result.
What Check tests
- A working clipboard gives
copied - A refused permission gives
denied - No clipboard gives
unavailable(and does not crash)
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Your page
Press Run to see the page.
Console
Nothing logged yet.