forked from The-Marcy-Lab-School/git-js-pairing-lab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
146 lines (128 loc) · 3.19 KB
/
index.js
File metadata and controls
146 lines (128 loc) · 3.19 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
134
135
136
137
138
139
140
141
142
143
144
145
146
function fiveToOneHundred(){
for(let i = 5; i <=100; i++){
console.log(i);
}
}
// console.log("---Q1---")
// fiveToOneHundred();
function multiplesOfThree(){
for(let i = 3; i <=100; i+=3){
console.log(i);
}
}
// console.log("---Q2---")
// multiplesOfThree();
function multiplesOfThreeOrFive(){
for(let i = 0; i <= 100; i++){
if(i % 3 === 0 || i % 5 === 0){
console.log(i);
}
}
}
// console.log("---Q3---")
// multiplesOfThreeOrFive();
function untilNum(num){
for(let i = 1; i <= num; i++){
console.log(i);
}
}
// console.log("---Q4---")
// untilNum(15);
function multiply(num1, num2){
return num1 * num2;
}
// console.log("---Q5---");
// console.log(multiply(2,5));
function add(num1, num2) {
if (num1 === num2){
return (num1 + num2)*3;
}else{
return num1 + num2;
}
}
// console.log("---Q6---")
// console.log(add(2, 2));
// console.log(add(2, 3));
function isNegative(num){
if(num < 0){
return true;
}else{
return false;
}
}
// console.log("---Q7---");
// console.log(isNegative(3));
// console.log(isNegative(-3));
// console.log(isNegative(0));
function triangleArea(base,height){
return (base * height)*.5;
}
// console.log("---Q8---")
// console.log(triangleArea(5,10));
function betweenTwentyAndFourty(num){
if(num > 20 && num < 100){
return true;
}else{
return false;
}
}
// console.log("---Q9---")
// console.log(betweenTwentyAndFourty(19));
// console.log(betweenTwentyAndFourty(44));
function largest(num1,num2,num3){
return Math.max(num1,num2,num3);
}
// console.log("---Q10---")
// console.log(largest(2,4,6));
function printTime(){
let currentDate = new Date()
let currentTime = currentDate.getHours()+":"+currentDate.getMinutes()+":"+currentDate.getSeconds()
return currentTime
}
// console.log("---Q11---")
// console.log(printTime())
function isLeapYear(year){
return (year % 100 === 0) ? (year % 400 === 0) : (year % 4 === 0);
}
// console.log("---Q12---")
// console.log(isLeapYear(1756));
// console.log(isLeapYear(1900));
// console.log(isLeapYear(2020));
// console.log(isLeapYear(1999));
function getExtention(filename){
let extension = filename.split(".").pop()
return "."+ extension
}
// console.log("---Q13---")
// console.log(getExtention("hello.txt"));
function absoluteNineteen(num){
let difference = Math.abs(num) - 19
if (num > 19){
return difference * 3;
}
}
// console.log("---Q14---")
// console.log(absoluteNineteen(21));
function switchLetters(str){
let emptyStr = "";
for(let i = 0; i < str.length; i++){
if(i != 0 && i!= str.length-1){
emptyStr += str[i]
console.log(i)
}
}
return str[str.length-1] + emptyStr + str[0];
}
// console.log("---Q15---")
// console.log(switchLetters("anne"))
function changeString(str){
let newStr = '';
for (let i = 0; i < str.length; i++) {
if (96 < str.charCodeAt(i) && str.charCodeAt(i) < 123) {
newStr += String.fromCharCode(str.charCodeAt(i) + 1);
}
}
return newStr;
}
// console.log("---Q16---")
// console.log(changeString('javascript'));