You'll write four short JavaScript functions and push your work to GitHub. The functions are tiny on purpose — the real win this week is getting comfortable with defining functions, returning values, and the Git workflow.
- Fork this repo to your own GitHub account (button top-right).
- Clone your fork to your computer:
git clone https://github.com/YOUR-USERNAME/Week4_Functions.git cd Week4_Functions - Open the folder in your code editor.
- Open
index.htmlin your browser. Open the browser console (F12 → Console). - Edit
challenges.js. Refresh the page to see new output.
Write a function greetUser(name) that returns a greeting string.
greetUser("Fatuma"); // → "Hello, Fatuma!"
greetUser("Asha"); // → "Hello, Asha!"📝 The function should return the string, not log it. The test code at the bottom of the file will log the result.
Write a function calculateTip(bill, tipPercent) that returns the tip amount.
calculateTip(50, 20); // → 10
calculateTip(80, 15); // → 12Formula: bill * (tipPercent / 100)
Write a function celsiusToFahrenheit(c) that returns the temperature in °F.
celsiusToFahrenheit(0); // → 32
celsiusToFahrenheit(100); // → 212
celsiusToFahrenheit(25); // → 77Formula: (c * 9) / 5 + 32
Write a function isAdult(age) that returns true if the age is 18 or older, otherwise false.
isAdult(20); // → true
isAdult(15); // → false
isAdult(18); // → true💡 Try writing this one as an arrow function:
const isAdult = (age) => ...
- All 4 functions exist with the exact names listed above
- Each function uses
return(not justconsole.log) - Running
index.htmlin the browser shows the right values in the console
git add .
git commit -m "Complete Week 4 functions assignment"
git pushThen submit the link to your repo (something like https://github.com/your-name/Week4_Functions).
Add one more function: getInitials(firstName, lastName) → returns the initials, like "Fatuma", "Ali" → "F.A."