forked from gabischool/Week3_JS_Introduction
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasics.js
More file actions
112 lines (62 loc) · 3.8 KB
/
Copy pathbasics.js
File metadata and controls
112 lines (62 loc) · 3.8 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
/*
Task: Convert Strings to Numbers / String number ku badal
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 / Raadi Number Method wax la dhaho
*/
/*
Task: Mood Checker
Do the following:
1. Write a script that prompts the user for their current mood. / Code qor u soo saaraayo qof meeshuu ku qori lahaa siduu dareemaayo
2. If the user inputs happy, print 'Yay me too!' to the console, sad print 'Aw cheer up', / Haduu qofka galiyo 'happy', console log samee ah 'Yay me too', haduu 'sad' galiyo, 'Aw Cheer up' console ku qor.
3. Else just print 'So moody!' / Hadii kale 'So Moody!' soo saar.
*/
/*
Task: Odd or Even / kisi ama dhaban
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.
Adigoo 'if/else' isticmaalaayo hubi in nambar uu yahay 'kisi ama dhaban', kadi console log ku samee adigoo sheegaayo midkuu yahay
*/
var num = 16; // You can change this number! / Number-kaan ku bilow
// write your conditions here / Code-kaada halkaan ku qor
/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task: FIZZBUZZ 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
/*
You're about to do an assignment called "Fizz Buzz", which is one of the classic programming challenges.
"Fizz Buzz" waa xujo la siiyo markii dadka interview laga qaadaayo. Waa inuu programkaada soo saaro "Fizz", "Buzz" ama "FizzBuzz".
Write a program that prints the numbers from 1 to 100.
Code qor soo saaraayo inta u dhaxeysa 1 ilaa 100.
But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz".
Markii numberka lagu dhufan karo 3, waa inuu soo qoraa "Fizz", haduu numberka lagu dhufan karo 5, waa inuu soo qoraa "Buzz"
For numbers which are multiples of both three and five print "FizzBuzz".
Hadii labadaba (3 iyo 5) lagu dhufan karo, waa inuu soo qoraa "FizzBuzz".
The one hint you'll likely need is / Halka wax ood u baahantahay inaa ogaato:
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:
Waxaa jiro wax la yiraahdo "modulus" oo Javascript ku jiro, kaas oo uu kuu soo saaraayo haraaga labo number oo la isku dhuftay, sidaan ayuu u qoranyahay:
6 % 3
Equals zero. Because after dividing 6 by 3, there is zero leftover. Whereas:
Waa ebar, hadii lix loo qaybiyo sadex, waxbo ma soo haraayaan.
6 % 4
Equals 2. Because after dividing 6 by 4, there are 2 left over from the six.
Waa labo, haduu 6 loo qaybiyo 4, lao ayaa soo haraayo.
Knowing this should help you complete this assignment without any issue. Xarafkaa "%" wuxuu kaa cawinayaa inaa haraaga hesho, asaga u isticmaal inaa
ogaato in number ay isku qaybsamaan.
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*/
}