Где ошибка помогите

var a, b, c, d, x, y, z;
console.log("Введіть a:");
a = Number(prompt());
console.log("Введіть b:");
b = Number(prompt());
console.log("Введіть c:");
c = Number(prompt());
console.log("Введіть d:");
d = Number(prompt());
console.log("Введіть x:");
x = Number(prompt());

if (Math.abs(x) < d) {
  z = Math.sqrt(a * x + 1) + d
} else {
  if (Math.abs(x) == d) {
    z = Math.sin(b * x + 1)
  }
} else {
  if (Math.abs(x) > d) {
    z = Math.pow(b, 3) * Math.cos(c * x + 1)
  }
}

y = Math.cos(z) + Math.log(z * a / x)
console.log('y=', y, 'z=', z)


Ответы (1 шт):

Автор решения: Zhihar

если немного аккуратненько поставить отступы, то

if (Math.abs(x) < d) 
{
    z = Math.sqrt(a * x + 1) + d
} 
else 
{
    if (Math.abs(x) == d) 
    {
        z = Math.sin(b * x + 1)
    }
} 
else // <- см. сюда
{
    if (Math.abs(x) > d) 
    {
        z = Math.pow(b, 3) * Math.cos(c * x + 1)
    }
}

чувствуете подвох?

→ Ссылка