Skip to content
Permalink
Browse files

added week 6

  • Loading branch information
Alex Mueller
Alex Mueller committed Mar 1, 2020
1 parent 1202abe commit c915c2d9e01c5619be1d83f6ece520647832eab8
Showing with 92 additions and 0 deletions.
  1. +12 −0 week-6/index.html
  2. +17 −0 week-6/js/main.js
  3. +21 −0 week-6/js/reverse.js
  4. +20 −0 week-6/js/sum.js
  5. +11 −0 week-6/reverse.html
  6. +11 −0 week-6/sum.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>
@@ -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']);
@@ -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);
@@ -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
}
@@ -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>
@@ -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.
You can’t perform that action at this time.