Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
6 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |