Complete the code to print 'Hello from Deno!' in the console.
console.[1]('Hello from Deno!');
The console.log function prints messages to the console in Deno.
Complete the code to import the standard HTTP server module in Deno.
import { serve } from '[1]';
Deno uses URLs to import modules. The standard HTTP server is imported from https://deno.land/std/http/server.ts.
Fix the error in the code to run a simple HTTP server in Deno.
import { serve } from 'https://deno.land/std/http/server.ts'; const server = serve({ port: [1] }); for await (const req of server) { req.respond({ body: 'Hello Deno!' }); }
The port number must be a number, not a string. So use 8080 without quotes.
Fill in the blank to create a Deno script that reads a file and prints its content.
const data = await Deno.[1]('hello.txt'); console.log(new TextDecoder().decode(data));
Deno.readFile reads a file as bytes, and readTextFile reads as text. Here, readFile is correct because the code decodes bytes manually.
Fill all three blanks to create a Deno script that fetches JSON data from a URL and logs a property.
const response = await fetch('[1]'); const data = await response.[2](); console.log(data.[3]);
The fetch function gets data from the URL. The json() method parses the response as JSON. Then we log the name property from the data.
