Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Module_5/Challenge1.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

let names = ['Westly Snipes', 'Nicholas Cage', 'Nasir Jones', 'Sean Carter', 'Sean Combs', 'Michael Jordan', 'Patrick Ewing'];
let names = [['Westly'], ['Snipes'], ['Nicholas'],['Cage'], ['Nasir'], ['Jones'], ['Sean'], ['Carter'], ['Sean'], ['Combs'], ['Michael'],['Jordan'], ['Patrick'], ['Ewing']];

let firstName = [];

let lastName = [];

let i;

for (i=0; i <= names.length; i++) {

for (let i=0; i <= names.length; i++) {
if (names[i] % 2 == 0) {
firstName.push(names[i]);
}else{
lastName.push(names[i]);
}
}
console.log(firstName)

console.log("firstName:");

console.log("lastName:");
console.log(lastName)
14 changes: 9 additions & 5 deletions Module_5/Challenge3.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
const lyrics = [`I messed up tonight, I lost another fight, I messed up but I'll just start again, I keep falling down I keep on hitting the ground, I always get up now to see what's next. Birds don't just fly, they fall down and get up. Nobody learns without getting it wrong! I won't give up, no I won't give in, till I reach the end and then I'll start again. No I won't leave, I wanna try everything, I wanna try even though I could fail!`];
let lyrics = [`I messed up tonight, I lost anothEr fight, I messed up but I'll just start again, I keep falling down I keep on hitting the ground, I always get up now to see what's next. Birds don't just fly, thEy fall down and get up. Nobody learns without getting it wrong! I won't give up, no I won't give in, till I reach the end and then I'll start again. No I won't leave, I wanna try everything, I wanna try even though I could fail!`];
let words = lyrics.split(" ")
for (let i=0; i < lyrics.length; i++) {
if (words[i] == "e" && words[i] == 'E') {
let newLyrics = words[i].replace(/e/ig, "$");
}
}
let newLyrics = newString.join(" ");

const words = lyrics.split(" ").join();
console.log(newLyrics);

array.splice("s", '$');

console.log(lyrics);


23 changes: 23 additions & 0 deletions Module_6/Object_Animal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*Create an Animal*/

let animal = {
name: "furballs",
color: "white",
breed: "bear",
softness: "sinkably soft",
makes_noise: function(){
console.log ("meow");
return true
},

get name( ) {
return this.animalName;
},
set breed(breed) {
this.breed = animalBreed;
}
};

animal.name
animal.breed
animal.makes_noise
23 changes: 23 additions & 0 deletions Module_6/Object_Sports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*Creat a sports team*/

let sport = {
name: "Bangles",
color: "Fuchsia",
country: "USA",
game: "panty brigade",
ball_hitting: function(){
console.log ("crack");
return true
},

get color( ) {
return this.sportColor;
},
set country(country) {
this.country = sportCountry;
}
};

sport.color()
sport.country
sport.ball_hitting
22 changes: 22 additions & 0 deletions Module_6/Objects_Cars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Create a car */
let car = {
name: "Lamborghini",
color: "red",
country: "Italy",
Speed: "220 mph",
makes_noise: function(){
console.log ("vroom vroom");
return true
},

get color( ) {
return this.carColor;
},
set speed(speed) {
this.speed = carSpeed;
}
};

car.color
car.speed
car.makes_noise
43 changes: 43 additions & 0 deletions Module_6/Projects/Tip Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content = "width = device-width, initial-scale=1.0">
<meta http-equiv ="X-UA-Compatible" content = "ie = edge">
<title>Tip Calculator</title>
<link href= "styles.css" rel = "stylesheet">
<script src ="script.js" defer></script>
</head>

<body>
<div class="calculator-grid">
<div class="output">
<div data-previous-operand class="previous-operand"></div>
<div data-current-operand class="current-operand"></div>
</div>
<button data-all-clear class="span-two">AC</button>
<button data-delete>DEL</button>
<button data-operation>/</button>
<button data-number>1</button>
<button data-number>2</button>
<button data-number>3</button>
<button data-operation>*</button>
<button data-number>4</button>
<button data-number>5</button>
<button data-number>6</button>
<button data-operation>+</button>
<button data-number>7</button>
<button data-number>8</button>
<button data-number>9</button>
<button data-operation>-</button>
<button data-number>.</button>
<button data-number>0</button>
<button data-equals class="span-two">=</button>
</div>





</body>
</html>
132 changes: 132 additions & 0 deletions Module_6/Projects/Tip Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
class Calculator {
constructor (previousOperandTextElement, currentOperandandTextElement) {
this.previousOperandTextElement = previousOperandTextElement
this.currentOperandandTextElement = currentOperandandTextElement
this.clear()
}
clear() {
this.currentOperand = ''
this.previousOperand = ''
this.operation = undefined
}

delete() {
this.currentOperand = this.currentOperand.toString().slice(0, -1)
}

appendNumber(number) {
if (number === '.' && this.currentOperand.includes ('.')) return
this.currentOperand = this.currentOperand.toString() + number.toString()
}

chooseOperation(operation) {
if (this.currentOperand === '') return
if (this.previousOperand !== '') {
this.compute()
}
this.operation = operation
this.previousOperand = this.currentOperand
this.currentOperand = ''
}

compute() {
let computation
const prev = parseFloat(this.previousOperand)
const current = parseFloat(this.currentOperand)
if (isNaN(prev) || isNaN(current)) return
switch (this.operation) {
case '+':
computation = prev + current
break

case '+':
computation = prev + current
break

case '-':
computation = prev - current
break

case '*':
computation = prev * current
break

case '/':
computation = prev / current
break
default:
return
}
this.currentOperand = computation
this.operation = undefined
this.previousOperand = ''
}

getDisplayNumber(number) {
const stringNumber = number.toString()
const integerDigits = parseFloat(stringNumber.split('.')[0])
const decimalDigits = stringNumber.split('.')[1]
let integerDisplay
if (isNaN(integerDigits)) {
integerDisplay = ''
}else {
integerDisplay = integerDigits.toLocaleString('en', {maximumFractionDigits: 0})
}
if (decimalDigits != null) {
return `${integerDisplay}.${decimalDigits}`
}else {
return integerDisplay
}
}

updateDisplay() {
this.currentOperandandTextElement.innerText = this.getDisplayNumber(this.currentOperand)
if (this.operation != null) {
this.previousOperandTextElement.innerText =
`${this.getDisplayNumber (this.previousOperand)} ${this.operation}`
}else {
this.previousOperandTextElement.innerText = ''
}
}
}



const numberButtons = document.querySelectorAll('[data-number]')
const operationButtons = document.querySelectorAll('[data-operation]')
const equalsButton = document.querySelector('button[data-equals]')
const deleteButton =document.querySelector('[data-delete]')
const allClearButton = document.querySelector('[data-all-clear]')
const previousOperandTextElement = document.querySelector('[data-previous-operand]')
const currentOperandandTextElement = document.querySelector('[data-current-operand]')

const calculator = new Calculator(previousOperandTextElement, currentOperandandTextElement)

numberButtons.forEach(button => {
button.addEventListener('click', () => {
calculator.appendNumber(button.innerText)
calculator.updateDisplay()
})
})

operationButtons.forEach(button => {
button.addEventListener('click', () => {
calculator.chooseOperation(button.innerText)
calculator.updateDisplay()
})
})

equalsButton.addEventListener('click', button => {
calculator.compute()
calculator.updateDisplay()
})

allClearButton.addEventListener('click', button => {
calculator.clear()
calculator.updateDisplay()
})

deleteButton.addEventListener('click', button => {
calculator.delete()
calculator.updateDisplay()
})
58 changes: 58 additions & 0 deletions Module_6/Projects/Tip Calculator/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
*, *::before, *::after {
box-sizing: border-box;
font-family: Arial, sans-serif;
font-weight: normal;
}

body {
padding: 0;
margin: 0;
background: linear-gradient(to right, #00AAFF, #00FF6C);
}

.calculator-grid {
display: grid;
justify-content: center;
align-content: center;
min-height: 100vh;
grid-template-columns: repeat(4, 100px);
grid-template-rows: minmax(120px, auto) repeat(5, 100px);
}

.calculator-grid > button {
cursor: pointer;
font-size: 2rem;
border: 1px solid white;
outline: none;
background-color: rgba(255, 255, 255, .75);
}

.calculator-grid > button:hover {
background-color: rgba(255, 255, 255, .9);
}

.span-two {
grid-column: span 2;
}

.output {
grid-column: 1 / -1;
background-color: rgba(0, 0, 0, .75);
display: flex;
align-items: flex-end;
justify-content: space-around;
flex-direction: column;
padding: 10px;
word-wrap: break-word;
word-break: break-all;
}

.output .previous-operand {
color: rgba(255, 255, 255, .75);
font-size: 1.5rem;
}

.output .current-operand {
color: white;
font-size: 2.5rem;
}
26 changes: 26 additions & 0 deletions Module_6/Projects/To do list/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<script src="https://kit.fontawesome.com/d29d219c19.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href = "path/to/font-awesome/css/font-awesome.min.css">
<title>Vacation To Do List</title>
<link rel='stylesheet' type='text/css' href='main.css'>
<link href="https://fonts.googleapis.com/css?family=Hind&display=swap" rel="stylesheet">
</head>

<body>
<h1><span class="styling">Vacation To Do List</span></h1>
<div class="input_div">
<input class="input" type="text" placeholder="What Do You Want to Do...">
<button class="addButton"><i class="fas fa-plus"></i></button>
</div>
<div class="container">
<div class="item">
<input type="text" class="item_input" disabled>
<button class="editButton">EDIT</button>
<button class="removeButton">REMOVE</button>
</div>
</div>
<script type = "text/javascript" src='main.js'></script>
</body>
</html>
Loading