generated from HackYourFuture-CPH/hyf-homework-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
PAINj9
wants to merge
1
commit into
main
Choose a base branch
from
javascript-javascript1-week3/juan
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>Document</title> | ||
</head> | ||
<body> | ||
<script src="script.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,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); |
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,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> |
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,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); | ||||||||||||||||||
|
||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
And you can also try this
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
// Code done | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
console.table(names); // ['Peter', 'Yana', 'kristina', 'Rasmus', 'Samuel', 'katrine', 'Tala'] |
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,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> |
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,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"); | ||
|
||
|
||
|
||
|
||
|
||
|
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>Document</title> | ||
</head> | ||
<body> | ||
<script src="script.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,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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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"
removeddoes is make sense?