S
S
Sergey Sisharpof2021-06-26 22:55:47
JavaScript
Sergey Sisharpof, 2021-06-26 22:55:47

2 conditions are set, but only one is displayed, what did I do wrong?

let nickname = "TestName";
let balance = 7000;

if (nickname === "admin") {
  console.log("Администратор");
} else if(nickname === "") {
  console.log("Гость");
} else if (balance > 1000) {
  console.log("Постоянный покупатель");
} else if (balance > 5000) {
  console.log("ВИП-клиент");
}


When you enter a variable greater than 5000, it still says "Regular customer".

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lillipup, 2021-06-26
@d3c0dik

Probably it needs to

let nickname = "TestName";
let balance = 7000;

if (nickname === "admin") {
  console.log("Администратор");
} else if(nickname === "") {
  console.log("Гость");
} else if (balance >= 1000 && balance < 5000) {
  console.log("Постоянный покупатель");
} else if (balance >= 5000) {
  console.log("ВИП-клиент");
}

S
Sergey Sokolov, 2021-06-26
@sergiks

who first got up - that and slippers
The condition "more than 1000" is fulfilled, and does not go further, there else (otherwise)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question