Похожие чаты

Is this considered a completely function based program ? function

CreateAccount(name, accountNumber, password) {
this.name = name;
this.accountNumber = accountNumber;
this.balance = 0;
this.password = password;
}

CreateAccount.prototype.deposit = function(pass, amount) {
if (this.password === pass) {
this.balance += amount;
} else throw new Error("Wrong password");
};

function display(objorclass, element, balance) {
const elem = document.querySelector(`${objorclass}${element}`);
elem.innerHTML = `${balance}`;
}

function check() {
document.querySelector("#deposit").addEventListener("click", () => {
const pass = document.querySelector("#pass").value;
const amount = document.querySelector("#am").value;
const fixedAmmount = Number(amount);
account1.deposit(pass, fixedAmmount);
display("#", "amount", `${account1.balance} <br>${account1.name}`);
});
}

const account1 = new CreateAccount("simon", "01", "password");
check();

7 ответов

5 просмотров

It looks like you posted long piece of code, consider editing it out and putting it on hastebin.com and pasting link to it instead. Alternatively, send your code in a file.

for the id selectors you can use getElementById

0x01- Автор вопроса

^

0x01- Автор вопроса

can i stick this in one function and use curry to apply them all ?

Seems pretty class based

const thr = msg => { throw new Error(msg); }; const Account = (name, accountNubmer, password) => ({ name, accountNumber, balance: 0, password }); const deposit = (account, amount, pass) => account.password === pass ? ({ ...account, balance: balance + amount }) : thr('Wrong password');

Похожие вопросы

Обсуждают сегодня

Есть какой-нибудь для Delphi/FPC T*Compression(Decompression)Stream на базе LZ4/Zstd/любой другой быстрый(и хорошо сжимающий) алгоритм А ещё лучше в pure pascal А ещё лучше од...
notme
32
А чем вам питонисты не угодили?😂
.
79
Hey guys, did you see the new announcement about $Fun? 🔥
Filip Murphy
55
Язык Си можно выучить за день? По книжке ANSI C на 230 страниц
Vincent Vegan
29
Привет, запускаю werf в dind в k8s, получаю ошибку на этапе build/beforeSetup: /.werf/stapel/embedded/bin/bash: /.werf/scripts/5898bdfe5214357d3706b879cc8d3d78460fb379607cbd...
florius0
7
Всем привет, написал код ниже, но он выдает сегфолт, в чем причина? #include <stdio.h> #include <stdlib.h> #include <string.h> struct product { char *name; float price; };...
buzz базз
75
пацаны, как-нибудь можно панель задач заблюрить, что она была похожа на kde или винду 7, 11?
В
16
or do they all have 240?
Ilnur Zaripov
9
HI. Just reviewd Planck website which looks undercooked and some menu is not leading to correct section of site. Also, the vesting is shown to be for 20 months starting next y...
Neo517
4
Дорогие любители Прекрасной Джулии! Есть кто-то имеющий практический опыт построения ML для Систем Управления? Нам нужно сделать нейросеть для автоматической подстройки пара...
Roman Timo
4
Карта сайта