From c8c7aded937e184913eb548b0239b6aa85f611c9 Mon Sep 17 00:00:00 2001 From: Andazi Boboye <95321227+andazi@users.noreply.github.com> Date: Tue, 5 Jul 2022 01:25:26 +0100 Subject: [PATCH] Update assignment.md assignment on functions --- 2-js-basics/2-functions-methods/assignment.md | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/2-js-basics/2-functions-methods/assignment.md b/2-js-basics/2-functions-methods/assignment.md index 4fbe387d..1d1a48a9 100644 --- a/2-js-basics/2-functions-methods/assignment.md +++ b/2-js-basics/2-functions-methods/assignment.md @@ -4,10 +4,35 @@ Create different functions, both functions that return something and functions that don't return anything. +#1 returns random number 1 -100 +function randomNumber(){ + return Math.floor(Math.random() * 100) + 1; +} +randomNumber(); + +#2 does not return anything +function randomNumber(){ +} +randomNumber(); + See if you can create a function that has a mix of parameters and parameters with default values. +#1 +function greet(firstName, lastName){ + return `Hey there, ${firstName} ${lastName}`; +} +greet('Boboye', 'Andazi'); + +#2 +function greet(firstName, lastName = 'Ford'){ + return `Hey there, ${firstName} ${lastName}`; +} +greet('Boboye'); +greet('Boboye', 'Manny'); + + ## Rubric | Criteria | Exemplary | Adequate | Needs Improvement | | -------- | -------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | ----------------- | -| | Solution is offered with two or more well-performing functions with diverse parameters | Working solution is offered with one function and few parameters | Solution has bugs | \ No newline at end of file +| | Solution is offered with two or more well-performing functions with diverse parameters | Working solution is offered with one function and few parameters | Solution has bugs |