Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added week 6
  • Loading branch information
Alex Mueller committed Mar 1, 2020
1 parent 1202abe commit c915c2d
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 0 deletions.
12 changes: 12 additions & 0 deletions week-6/index.html
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MDN Object Tutoral</title>
</head>
<body>
<p>look in the console thanks</p>
<script src="js/main.js"></script>
</body>
</html>
17 changes: 17 additions & 0 deletions week-6/js/main.js
@@ -0,0 +1,17 @@
function Person(first, last, age, gender, interests) {
this.name = {
first : first,
last : last
};
this.age = age;
this.gender = gender;
this.interests = interests;
this.bio = function() {
alert(this.name.first + ' ' + this.name.last + ' is ' + this.age + ' years old. He likes ' + this.interests[0] + ' and ' + this.interests[1] + '.');
};
this.greeting = function() {
alert('Hi! I\'m ' + this.name.first + '.');
};
}

let person1 = new Person('Bob', 'Smith', 32, 'male', ['music', 'skiing']);
21 changes: 21 additions & 0 deletions week-6/js/reverse.js
@@ -0,0 +1,21 @@
function reverseArray(array) {
let arrayNew = []
for (let index = array.length- 1; index >=0 ; index--) {
const element = array[index];
arrayNew.push(element);
}
return arrayNew
}

function reverseArrayInPlace(array) {
let lastIndex = array.length - 1
for (let index = 0; index < (lastIndex / 2); index++) {
const element = array[index];
array[index] = array[lastIndex-index]
array[lastIndex-index] = element;
}
}
console.log(reverseArray(["A", "B", "C"]));
let arrayValue = [1, 2, 3, 4, 5];
reverseArrayInPlace(arrayValue);
console.log(arrayValue);
20 changes: 20 additions & 0 deletions week-6/js/sum.js
@@ -0,0 +1,20 @@
function range(start, end, step) {
let arr = []
if (step > 0){
for (let index = start; index <= end; index += step) {
arr.push(index)
}
} else if (step < 0)
for (let index = start; index >= end; index += step) {
arr.push(index)
} else return "Err"
return arr
}

function sum(array) {
let sum = 0;
array.forEach(item => {
sum += item
});
return sum
}
11 changes: 11 additions & 0 deletions week-6/reverse.html
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reversing an array</title>
</head>
<body>
<script src="js/reverse.js"></script>
</body>
</html>
11 changes: 11 additions & 0 deletions week-6/sum.html
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sum of a Range</title>
</head>
<body>
<script src="js/sum.js"></script>
</body>
</html>

0 comments on commit c915c2d

Please sign in to comment.