From the course: ReasonML: First Look
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Challenge: Generating random cakes - ReasonML Tutorial
From the course: ReasonML: First Look
Challenge: Generating random cakes
- [Instructor] Now it's time for you to try your hand at this by writing code that generates a random cake. One thing we're missing in the cake record module is a function that converts a cake record to a printable string. The first part of your challenge is to write a function to do exactly that. You're going to complete this two string function that you see here. The second part of the challenge is, in the cakeexamples.re file, to write a function named createRandomCake that takes no arguments and returns a random cake record. To generate a random cake, you need to generate random numbers. Here's some code that might give you some hints. Here I've created a type that could be used in a rock, scissors, paper game. And I've created an array of choices. This code uses the Js.Math.random_int function to generate a random integer in the range starting from the first number up to, but not including, the second number.…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Creating your own data types5m 10s
-
(Locked)
Say goodbye to null and undefined4m 39s
-
(Locked)
Creating modules for reusable code2m 35s
-
(Locked)
Using collection types6m 41s
-
(Locked)
Creating record types6m 47s
-
(Locked)
Challenge: Generating random cakes2m 1s
-
(Locked)
Solution: Generating random cakes2m 57s
-
(Locked)
-
-