From db13e8a32ff36a2ae7d98bb323210752c23469a3 Mon Sep 17 00:00:00 2001 From: EbenAngeline Date: Thu, 21 May 2026 21:56:25 -0500 Subject: [PATCH] Add functions for attendee badge, event cost, and email validation --- sharing-task.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/sharing-task.js b/sharing-task.js index 3c7e23e..7912d8f 100644 --- a/sharing-task.js +++ b/sharing-task.js @@ -36,6 +36,12 @@ reusable functions that solve specific tasks. This activity encourages: // 3. Capitalize the role if needed. // 4. Return the result. +function attendeeBadge(name,role){ + + return `Name: ${name} , Role: ${role}`; + +} + console.log(attendeeBadge("Alice","Speaker")); // ============================================ // 🧩 Task 2: Calculate Event Cost @@ -51,6 +57,19 @@ reusable functions that solve specific tasks. This activity encourages: // 3. If so, apply a 10% discount. // 4. Return the final total. +function event(numberOfAttendee,costPerAttendee){ + + totalCost = numberOfAttendee * costPerAttendee; + + if (numberOfAttendee > 100) + { + totalCost *= 0.9; + + } + return totalCost; +} +console.log(event(101,50)); +console.log(event(50,40)); // ============================================ // 🧩 Task 3: Validate Email @@ -64,6 +83,20 @@ reusable functions that solve specific tasks. This activity encourages: // 1. Check if the string includes both "@" and ".". // 2. Return true or false accordingly. +function validEmail(email) +{ + return email.includes('@') && email.includes('.') ; +} +console.log(validEmail("mailid@gmail.com")); +console.log(validEmail("mailid@gmailcom")); + +//Goal: Create a personalized badge string. +//input: name (string).role (string). +//output: formated string "Name: Alice, Role: Speaker" + + + + // ============================================ // 🧠 Collaborative Steps @@ -89,3 +122,4 @@ reusable functions that solve specific tasks. This activity encourages: // - Explain how your team approached the design and testing process // ✅ Bonus: Can you extend any of the functions to be more flexible or reusable? +g