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

Challenge: Generating random cakes - ReasonML Tutorial

From the course: ReasonML: First Look

Start my 1-month free trial

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.…

Contents