AI Frontend · Exercise 1 of 5Next
Intermediate
Pick the Back End
Five pretend devices are listed. Each button picks one and shows the back end your code chooses in #backend. Finish pickBackend(env) so it returns "webgpu", "wasm" or "server".
WebGPU needs env.gpu and an adapter from await env.gpu.requestAdapter(); that call can return null or throw. Use WebAssembly when env.wasm is true. Otherwise use the server.
What Check tests
- A desktop with a GPU adapter gets
webgpu - A device whose adapter is
nullgetswasm - A device whose GPU call throws gets
wasm, not an error - A device with no WebGPU gets
wasm - A device with nothing gets
server
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.