Skip to content

Commit c8c8f6e

Browse files
authored
fix: ensure dice calculation never becomes zero (sveltejs#180)
1 parent 95109d6 commit c8c8f6e

File tree

2 files changed

+3
-3
lines changed
  • content/tutorial/02-sveltekit/05-api-routes/01-get-handlers

2 files changed

+3
-3
lines changed

content/tutorial/02-sveltekit/05-api-routes/01-get-handlers/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This app fetches data from a `/roll` API route when you click the button. Create
99
```js
1010
/// file: src/routes/roll/+server.js
1111
export function GET() {
12-
const number = Math.ceil(Math.random() * 6);
12+
const number = Math.floor(Math.random() * 6) + 1;
1313

1414
return new Response(number, {
1515
headers: {
@@ -28,7 +28,7 @@ Request handlers must return a [Response](https://developer.mozilla.org/en-US/do
2828
+++import { json } from '@sveltejs/kit';+++
2929

3030
export function GET() {
31-
const number = Math.ceil(Math.random() * 6);
31+
const number = Math.floor(Math.random() * 6) + 1;
3232

3333
--- return new Response(number, {
3434
headers: {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { json } from '@sveltejs/kit';
22

33
export function GET() {
4-
const number = Math.ceil(Math.random() * 6);
4+
const number = Math.floor(Math.random() * 6) + 1;
55

66
return json(number);
77
}

0 commit comments

Comments
 (0)