-
Notifications
You must be signed in to change notification settings - Fork 388
/
index.html
96 lines (91 loc) · 1.92 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<title>Practice Problems</title>
<script type="text/javascript">
//Bigger words
var output = null;
function wordCompare (string_one, array_of_strings){
var output = [];
for (var i = 0; i < array_of_strings.length; i++){
if (array_of_strings[i].length > string_one.length){
output.push(array_of_strings[i]);
}
}
return output;
}
//Total Reverse
var output = null;
function total_reverse(my_array){
var output = [];
var array_reversed = [];
for(var i = my_array.length-1; i >=0; i--){
array_reversed.push(my_array[i]);
}
output = array_reversed;
return output;
}
//One to Multi
var output = null;
function sort_array(my_array){
var swap = true;
while(swap == true){
swap = false;
for (var i = 0; i < my_array.length; i++){
if ( my_array[i] > my_array[i+1]){
var temp = my_array[i];
my_array[i] = my_array[i+1]
my_array[i+1] = temp;
swap = true;
}
}
}
output = my_array;
return output;
}
//Fizz Buzz
function fizz_buzz(){
for (var i = 1; i < 101; i++){
if (i % 3 == 0 && i % 5 == 0){
console.log('FizzBuzz');
}
else if(i % 3 == 0){
console.log('Fizz');
}
else if (i % 5 == 0){
console.log('Buzz');
}
else {
console.log(i);
}
}
}
//Spirals
function fib_sequence(fib_index){
var f = [0, 1];
for ( var i = 1; i < fib_index; i++){
f.push(f[i-1]+[f[i])
}
return f.join('');
}
//Pig Latin
var hello = "hello there";
function piggy(a_string){
var array_of_strings = null;
var pig_latin_array = [];
array_of_strings = (a_string.split(" "));
for (var i = 0; i < array_of_strings.length; i++){
var word = array_of_strings[i];
var head_chop = word.substr(0,1);
var root = word.substr(1);
word = root + head_chop + 'ay';
pig_latin_array.push(word);
}
var phrase = pig_latin_array.join(" ");
return phrase;
}
</script>
</head>
<body>
</body>
</html>