From 131439e115f37d61c284d6765bc44993a99f0207 Mon Sep 17 00:00:00 2001 From: AbdisalanYusuf Date: Mon, 23 Dec 2024 18:45:00 -0600 Subject: [PATCH] first task --- index.js | 56 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/index.js b/index.js index 3524ab6..ef3ed12 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,13 @@ // 2. Write a conditional that returns true if `votingAge` is 18 or older; otherwise, return false. // 3. Log the result to the console. -let votingAge = /* Your code here */; + let votingAge = 16 + if (votingAge >= 18) { + console.log("You Can Vote") + } else { + console.log("You Can Not Vote") + + } /*🏋️‍♂️ Task 2: Variable Value Swap 🔄 */ @@ -15,8 +21,8 @@ let votingAge = /* Your code here */; // 2. Write a conditional that changes the value of the first variable if a certain condition with the second variable is met. // 3. Log the new value of the first variable to the console. -let variableOne = /* Your code here */; -let variableTwo = /* Your code here */; +// let variableOne = /* Your code here */; +// let variableTwo = /* Your code here */; /*🏋️‍♂️ Task 3: Favorite Number Checker 🔢 */ @@ -25,7 +31,7 @@ let variableTwo = /* Your code here */; // 2. Write a conditional to check if `favoriteNumber` is greater than, less than, or equal to 10. // 3. Log the result with a message, e.g., "My favorite number is greater than 10." -let favoriteNumber = /* Your code here */; +// let favoriteNumber = /* Your code here */; /*🏋️‍♂️ Task 4: Mood Checker 😊😢 */ @@ -45,7 +51,7 @@ let mood = prompt("How are you feeling today?"); // 2. Write a conditional to check if the number is odd or even. // 3. Log whether the number is odd or even, along with the number, to the console. -let num = /* Your code here */; +// let num = /* Your code here */; /*🚀 FIZZBUZZ 🚀 */ @@ -56,9 +62,9 @@ let num = /* Your code here */; // 4. For multiples of both 3 and 5, print "FizzBuzz". // 5. Add a check for prime numbers and print "Prime" for those. -for (let i = 1; i <= 100; i++) { +// for (let i = 1; i <= 100; i++) { // Your FizzBuzz logic here -} +// } // Bonus: Create a helper function to check if a number is prime. @@ -69,9 +75,9 @@ for (let i = 1; i <= 100; i++) { // Count and return the number of vowels in the string, handling both uppercase and lowercase vowels. // Hint: You may need to use the `.includes()` method. -function vowelCounter(/* Add parameter here */) { - // Your code here -} +// function vowelCounter(/* Add parameter here */) { +// // Your code here +// } // Test the `vowelCounter` function by calling it with different strings. @@ -83,9 +89,9 @@ function vowelCounter(/* Add parameter here */) { // Log the result to the console. // Include error handling for cases where the operator is invalid. -function simpleCalculator(/* Add parameters here */) { - // Your code here -} +// function simpleCalculator(/* Add parameters here */) { +// // Your code here +// } /*💪 Stretch 3: Temperature Converter 💪 */ @@ -96,13 +102,13 @@ function simpleCalculator(/* Add parameters here */) { // - Celsius to Fahrenheit: (C * 9/5) + 32 // - Fahrenheit to Celsius: (F - 32) * 5/9 -function toCelsius(/* Add parameter here */) { - // Your code here -} +// function toCelsius(/* Add parameter here */) { +// // Your code here +// } -function toFahrenheit(/* Add parameter here */) { - // Your code here -} +// function toFahrenheit(/* Add parameter here */) { +// // Your code here +// } // Test the temperature converter functions by calling them with different temperatures. @@ -113,9 +119,9 @@ function toFahrenheit(/* Add parameter here */) { // Use a loop to calculate the factorial. // Factorial of 0 is 1, and factorial of any positive number n is the product of all positive integers less than or equal to n. -function factorial(/* Add parameter here */) { - // Your code here -} +// function factorial(/* Add parameter here */) { +// // Your code here +// } // Test the factorial function by calling it with different numbers. @@ -126,8 +132,8 @@ function factorial(/* Add parameter here */) { // Ignore spaces, punctuation, and case when checking if the string is a palindrome. // Return true if the string is a palindrome, otherwise return false. -function isPalindrome(/* Add parameter here */) { - // Your code here -} +// function isPalindrome(/* Add parameter here */) { +// // Your code here +// } // Test the isPalindrome function by calling it with different strings.