-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathindex.js
More file actions
133 lines (84 loc) Β· 4.61 KB
/
index.js
File metadata and controls
133 lines (84 loc) Β· 4.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// JavaScript Basics Assignment
/*ποΈββοΈ Task 1: Voting Age Check π³οΈ */
// 1. Create a variable called `votingAge` and set it to any age.
// 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 */;
/*ποΈββοΈ Task 2: Variable Value Swap π */
// 1. Declare two variables and assign them initial values of your choice.
// 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 */;
/*ποΈββοΈ Task 3: Favorite Number Checker π’ */
// 1. Declare a variable named `favoriteNumber` and assign it your favorite number.
// 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 */;
/*ποΈββοΈ Task 4: Mood Checker ππ’ */
// 1. Prompt the user to enter their mood.
// 2. Write a conditional that logs the following responses based on the user input:
// - "Yay me too!" if the mood is "happy"
// - "Aw, cheer up" if the mood is "sad"
// - "So moody!" for any other input
// let mood = prompt("How are you feeling today?");
/*ποΈββοΈ Task 5: Odd or Even Checker π */
// 1. Choose a hardcoded number and store it in a variable.
// 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 */;
/*π FIZZBUZZ π */
// 1. Write a program that prints numbers from 1 to 100.
// 2. For multiples of 3, print "Fizz" instead of the number.
// 3. For multiples of 5, print "Buzz".
// 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++) {
// // Your FizzBuzz logic here
// }
// Bonus: Create a helper function to check if a number is prime.
/*πͺ Stretch 1: Vowel Counter πͺ */
// Write a `vowelCounter` function that takes a string as a parameter.
// 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
// }
// Test the `vowelCounter` function by calling it with different strings.
/*πͺ Stretch 2: Simple Calculator πͺ */
// Write a `simpleCalculator` function that accepts two numbers and an operator ("+", "-", "*", "/") as parameters.
// Based on the operator, perform the appropriate mathematical operation and return the result.
// Log the result to the console.
// Include error handling for cases where the operator is invalid.
// function simpleCalculator(/* Add parameters here */) {
// // Your code here
// }
/*πͺ Stretch 3: Temperature Converter πͺ */
// Write a `toCelsius` function that takes a Fahrenheit temperature and returns the equivalent Celsius temperature.
// Write a `toFahrenheit` function that takes a Celsius temperature and returns the equivalent Fahrenheit temperature.
// Formula:
// - Celsius to Fahrenheit: (C * 9/5) + 32
// - Fahrenheit to Celsius: (F - 32) * 5/9
// function toCelsius(/* 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.
/*πͺ Stretch 4: Factorial Calculation πͺ */
// Write a `factorial` function that takes a number as a parameter and returns the factorial of that number.
// 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
// }
// Test the factorial function by calling it with different numbers.
/*πͺ Stretch 5: Palindrome Checker πͺ */
// Write a `isPalindrome` function that checks if a given string is a palindrome (reads the same forwards and backwards).
// 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
// }
// Test the isPalindrome function by calling it with different strings.