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
// this function will return a table with data for all next years | |
const calculate = ({ principal, years, interest }) => { | |
const rate = interest / 100; | |
// the first entry is year 0—makes the logic simpler below | |
const table = [[0, principal, principal, 0]]; | |
for (let i = 1; i <= years; i++) { | |
table.push([ | |
i, // year number | |
table[i - 1][1] + principal * rate, // with simple interest |
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
// ©2020 Ilona Codes. All rights reserved. | |
// Playing with weight values changes results | |
const weights = { | |
'A': -2, | |
'B': -1, | |
'C': 1, | |
'D': 2, | |
}; |
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
// example comment | |
describe('greet(name)', () => { | |
it('some test example', () => { | |
expect('actual').toEqual('expected'); | |
}); | |
it('some test example', () => { | |
expect('actual').toEqual(true); | |
}); | |
}); |
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
const ImportFromFileBodyComponent = () => { | |
let fileReader; | |
const handleFileRead = (e) => { | |
const content = fileReader.result; | |
console.log(content) | |
// … do something with the 'content' … | |
}; | |
const handleFileChosen = (file) => { |
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
// index.js | Vue.js implementation | |
const app = new Vue({ | |
el: '#app', | |
data: { | |
dices: [ | |
{ dots: 1 }, | |
{ dots: 1 }, | |
] | |
}, |
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
<!-- index.html | Vue.js Implementation --> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Dice Rolling Simulator</title> | |
<link rel="stylesheet" href="./index.css"> | |
</head> | |
<body> |
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
// index.js | VanillaJS Implementation | |
const dices = window.document.querySelectorAll('.dice'); | |
const roll = () => { | |
dices.forEach(dice => { | |
const dots = Math.floor(Math.random() * 6) + 1; | |
dice.setAttribute("data-dots", dots); | |
}) | |
}; |
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
<!-- index.html | VanillaJS Implementation --> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Dice Rolling Simulator</title> | |
<link rel="stylesheet" href="index.css"> | |
</head> | |
<body> | |
<div id="app" onclick="roll()"> |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>With Vue</title> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> | |
<link rel="stylesheet" href="index.css"> | |
</head> | |
<body> | |
<div id="app"> |
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
const card = document.querySelector(".card"); | |
const hideLinkPreview = () => { | |
return card.style.display = 'none'; | |
}; | |
const showLinkPreview = event => { | |
const image = event.currentTarget.getAttribute("data-image"); | |
card.querySelector('img').setAttribute("src", image); |