Skip to content

Commit

Permalink
First exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
remarcmij committed Nov 28, 2024
1 parent 32c40e3 commit a5f6c86
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions 1-JavaScript/Week2/assignment/ex1-giveCompliment.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,40 @@ Full description at: https://github.com/HackYourFuture/Assignments/tree/main/1-J
Use `console.log` each time to display the return value of the
`giveCompliment` function to the console.
-----------------------------------------------------------------------------*/
export function giveCompliment(/* TODO parameter(s) go here */) {
// TODO complete this function
export function giveCompliment(name) {
//Array of compliments names
const compliments = [
'amazing',
'awesome',
'brilliant',
'clever',
'wonderful',
'excelent',
'fantastic',
'funny',
'smart',
];
// Randomly select a compliment
const randomIndex = Math.floor(Math.random() * compliments.length);
const compliment = compliments[randomIndex];

// Return the compliment string
return `You are ${compliment}, ${name}!`;
}

function main() {
// TODO substitute your own name for "HackYourFuture"
const myName = 'HackYourFuture';
const myName = 'Hossein';

// Call the function three times with myName
console.log(giveCompliment(myName));
console.log(giveCompliment(myName));
console.log(giveCompliment(myName));

const yourName = 'Amsterdam';

// Another example with a different name
const yourName = 'Kelisa';

// Call the function three times with yourName
console.log(giveCompliment(yourName));
console.log(giveCompliment(yourName));
console.log(giveCompliment(yourName));
Expand All @@ -39,4 +59,4 @@ function main() {
// ! Do not change or remove the code below
if (process.env.NODE_ENV !== 'test') {
main();
}
}

0 comments on commit a5f6c86

Please sign in to comment.