Skip to content

Instantly share code, notes, and snippets.

// 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
// ©2020 Ilona Codes. All rights reserved.
// Playing with weight values changes results
const weights = {
'A': -2,
'B': -1,
'C': 1,
'D': 2,
};
// example comment
describe('greet(name)', () => {
it('some test example', () => {
expect('actual').toEqual('expected');
});
it('some test example', () => {
expect('actual').toEqual(true);
});
});
const ImportFromFileBodyComponent = () => {
let fileReader;
const handleFileRead = (e) => {
const content = fileReader.result;
console.log(content)
// … do something with the 'content' …
};
const handleFileChosen = (file) => {
@ilonacodes
ilonacodes / index.js
Created April 20, 2020 07:26
index.js | Vue.js implementation
// index.js | Vue.js implementation
const app = new Vue({
el: '#app',
data: {
dices: [
{ dots: 1 },
{ dots: 1 },
]
},
@ilonacodes
ilonacodes / index.html
Last active April 20, 2020 07:25
index.html | Vue.js Implementation
<!-- 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>
@ilonacodes
ilonacodes / index.js
Created April 20, 2020 07:22
index.js | VanillaJS Implementation
// 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);
})
};
@ilonacodes
ilonacodes / index.html
Created April 20, 2020 07:16
index.html | VanillaJS Implementation
<!-- 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()">
@ilonacodes
ilonacodes / index.html
Created April 15, 2020 15:59
Vue.js — index.html
<!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">
@ilonacodes
ilonacodes / index.js
Created April 15, 2020 12:17
VanillaJS — index.js
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);