Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

javascript-javascript1-week3/juan #107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
12 changes: 12 additions & 0 deletions javascript/javascript1/week3/NoteTakingApp/index.html
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>Document</title>
</head>
<body>
<script src="script.js"></script>

</body>
</html>
31 changes: 31 additions & 0 deletions javascript/javascript1/week3/NoteTakingApp/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
let notes = [];

function saveNote (content, id) {
// The saveNote function should push an object to the notes array with the keys content and id
notes.push({
content,
id
});
}

function getNote(id) {
for (let i = 0; i < notes.length; i++) {
if (notes[i].id === id) {
return notes[i];
}
}
return "Error";
}

function logOutNotesFormatted() {
for (let i = 0; i < notes.length; i++) {
console.log("The note with id: " + notes[i].id + ", has the following note text: " + notes[i].content);
}
}

saveNote("Pick up groceries", 1);
saveNote("Do laundry", 2);

logOutNotesFormatted();

console.log(notes);
13 changes: 13 additions & 0 deletions javascript/javascript1/week3/homework/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>

<script src="script.js"></script>

</body>
</html>
28 changes: 28 additions & 0 deletions javascript/javascript1/week3/homework/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const names = [
"Peter",
"Ahmad",
"Yana",
"kristina",
"Rasmus",
"Samuel",
"katrine",
"Tala",
];
const nameToRemove = "Ahmad";
const borrar = names.indexOf(nameToRemove);


// Write some code here

if (names.includes(nameToRemove)) {

names.splice(borrar, borrar);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Splice(param1, param2) removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
@param1 — The zero-based location in the array from which to start removing elements.
@Param2 — The number of elements to remove.

so if the name is "Yana"for example, the first and the second parameter in your code will be 2, and therefore you will get "Yana" and "kristina" removed

does is make sense?


}


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How ever if you want it to be fancy and return the same result, instead of if statement:

Suggested change
function nameToRemove(name) {
names.splice(names.indexOf(name), 1);
}

And you can also try this
it might be fun ;)

Suggested change
function nameToRemove(name) {
names.splice(names.indexOf(name), 1, "Simon");
}


// Code done


console.table(names); // ['Peter', 'Yana', 'kristina', 'Rasmus', 'Samuel', 'katrine', 'Tala']
13 changes: 13 additions & 0 deletions javascript/javascript1/week3/homework1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>

<script src="script.js"></script>

</body>
</html>
22 changes: 22 additions & 0 deletions javascript/javascript1/week3/homework1/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@


const travelInformation = {
speed: 50,
destinationDistance: 432,
};



let horas = travelInformation.destinationDistance / travelInformation.speed;

let horasCompletas = Math.floor(horas);

let minutos = Math.round((horas - horasCompletas) * 60);

console.log(horasCompletas + " hours and " + minutos + " minutes");






11 changes: 11 additions & 0 deletions javascript/javascript1/week3/homework2/index.html
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>Document</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
46 changes: 46 additions & 0 deletions javascript/javascript1/week3/homework2/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

// SERIE DURATION

const seriesDurations = [
{
title: "Breaking Bad",
days: 2,
hours: 3,
minutes: 40,
}
];

// CALCULATING TIME OF SERIES IN HOURS


const totalHoras = (seriesDurations[0].days * 24) + seriesDurations[0].hours + (seriesDurations[0].minutes / 60);

// CREATING ARRAY + OBJECT WITH MY INFO


const lifeTime = [ {
nombre: "Juan",
days: 8760,
},
];

// TRANSFORMING MY DAYS INTO HOURS

const lifeHours = (lifeTime[0].days * 24);


// CALCULATING PERCENTAGE OF SEEN SERIES

const percentage = (totalHoras / lifeHours).toFixed(5) * 100;



console.log("The total ammount of lived hours of " + lifeTime[0].nombre + " is " + lifeHours);
console.log("The total ammount of watched hours are: " + totalHoras);
console.log("The percentage of your life that you spend watching series is " + percentage + "%")


// I learn that ".toFixed(5)" limited the ammount of numbers of decimals that are shows
// I learn that ".toFixed(5)" limited the ammount of numbers of decimals that are shows
// I learn that ".toFixed(5)" limited the ammount of numbers of decimals that are shows
// I learn that ".toFixed(5)" limited the ammount of numbers of decimals that are shows