Похожие чаты

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 ответов

12 просмотров

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');

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

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

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта