Solucionado (ver solución)
Solucionado
(ver solución)
2
respuestas

tengo un problema al declarar el "else if"

Hola, estoy declarando el "else if' tal cual lo hace el instructor, pero me da un error esa nomenclatura y estoy atascado.

PS C:\Users\tdrei\downloads\1785-js-herencia-polimorfismo-ProyectoInicial\1785-js-herencia-polimorfismo-ProyectoInicial> node index.js file:///C:/Users/tdrei/downloads/1785-js-herencia-polimorfismo-ProyectoInicial/1785-js-herencia-polimorfismo-ProyectoInicial/Cuenta.js:31 else if (this.tipo == 'ahorro'); ^^^^

SyntaxError: Unexpected token 'else' ←[90m at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:119:18)←[39m ←[90m at ESMLoader.moduleProvider (node:internal/modules/esm/loader:483:14)←[39m

Node.js v18.6.0 PS C:\Users\tdrei\downloads\1785-js-herencia-polimorfismo-ProyectoInicial\1785-js-herencia-polimorfismo-ProyectoInicial>

/ retirarDeCuenta(valor){ if(this.tipo == 'Corriente'); valor = valor * 1.05; else if (this.tipo == 'ahorro'); valor == valor * 1.02; if(valor <= this.#saldo) this.#saldo -= valor; return this.#saldo }/

2 respuestas
solución!

Tienes el código fuente desordenado y con errores de sintaxis, debería quedar como algo similar a esto:

function retirarDeCuenta(valor){ 
    if(this.tipo == 'Corriente')
        valor = valor * 1.05; 
    else // this.tipo === 'ahorro'
        valor == valor * 1.02; 

    if(valor <= this.saldo) 
        this.saldo -= valor;

    return this.saldo;
}

Te lo agradezco muchísimo.

¡Pura vida!