forked from gabischool/Introduction-to-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
121 lines (71 loc) · 3.58 KB
/
index.js
File metadata and controls
121 lines (71 loc) · 3.58 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
/*🏋️♂️🏋️♂️🏋️♂️🏋️♂️🏋️♂️🏋️♂️🏋️♂️🏋️♂️🏋️♂️ Task 1: Warm-up!🏋️♂️🏋️♂️🏋️♂️🏋️♂️🏋️♂️🏋️♂️🏋️♂️🏋️♂️*/
/*
Task 1 - Voting Age
Do the following:
1. Make a variable called votingAge and give it a value
2. Return true if age is 18 or higher
*/
/*
Task 2 - Values
Do the following:
1. Declare two variables and assign them values
2. Use a conditional to change the value of the 1st variable based on the value assigned to the 2nd variable
3. Return the new value of the 1st variable
*/
/*
Task 3 - Convert Strings to Numbers
Do the following:
1. Declare a string type variable with the value of "1999"
2. Convert the string value of "1999" to a integer value of 1999
3. Return the result
HINT: look up the Number method
*/
/*
Task 4 - Mood Checker
Do the following:
1. Write a script that prompts the user for their current mood.
2. If the user inputs happy, print 'Yay me too!' to the console, sad print 'Aw cheer up',
3. Else just print 'So moody!'
*/
/*
Task 5 - Odd or Even
Use conditionals to check if a hardcoded number is odd or even, and then console.log the number is odd or even with the numbers value.
*/
var num; // write a number here
// write your conditions here
/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 FIZZBUZZ 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
/*
You're about to do an assignment called "Fizz Buzz", which is one of the classic programming challenges.
It is a favorite for interviewers, and a shocking number of job-applicants can't get it right.
But you won't be one of those people. Here are the rules for the assignment:
Write a program that prints the numbers from 1 to 100.
But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz".
For numbers which are multiples of both three and five print "FizzBuzz".
The one hint you'll likely need is:
There is a Javascript operator called "remainder" but often referred to as "modulus" or "modulo".
It is represented by the percentage sign (%) and it gives you the remainder left over after division. So for example:
6 % 3
Equals zero. Because after dividing 6 by 3, there is zero leftover. Whereas:
6 % 4
Equals 2. Because after dividing 6 by 4, there are 2 left over from the six.
If that was confusing, don't worry. It will make more sense as you use it.
The point is: the remainder operator is useful for finding out if X is a multiple of Y. If it is, then X % Y will yield zero.
Knowing this should help you complete this assignment without any issue.
Extra Credit:
Instead of only printing "fizz", "buzz", and "fizzbuzz", add a fourth print statement: "prime".
You should print this whenever you encounter a number that is prime (divisible only by itself and one).
As you implement this, don't worry about the efficiency of the algorithm you use to check for primes.
It's okay for it to be slow.
*/
/*💪💪💪💪💪💪💪💪💪💪 Stretch 💪💪💪💪💪💪💪💪💪💪*/
//Vowel Counter - How many vowels are there?
/*
Using the vowelCounter function below do the following:
1. Receive a string as a parameter
2. Count and return the number of vowels within that string. It should handle both capitalized and uncapitalized vowels.
HINT - you may need to study next week's content on arrays
HINT - try looking up the .includes() method
*/
function vowelCounter(/*add your code here*/) {
/*add your code here*/
}