Exercise 2 of chapter 2, using let function