Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Desafío: Calculadora de Comisiones | Declaraciones Condicionales
Introducción a TypeScript

bookDesafío: Calculadora de Comisiones

You are developing a program for a bank that needs to calculate commission based on the transaction type. Your task is to write a switch statement that will output the commission based on the type of incoming transaction.

Commission rates based on transaction type:

  • Payment: 0.5%
  • Transfer: 1.2%
  • Withdrawal: 2.0%
  • Deposit: 0.0% (no commission)

Replace ___ with the necessary code to compile it. Don't hesitate to check the hint and solution to better understand the task.

123456789101112131415161718192021
let transactionType: string = "Transfer"; // You can change the operation type let commission: number; switch (transactionType) { case ___: ___ = 0.5; break; case ___: ___ = ___; break; case ___: ___ = ___; break; case ___: ___ = ___; break; ___: ___ = -1; // Handle unknown transaction types } console.log(`Commission for ${transactionType}: ${commission}%`);
copy
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 7

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

Suggested prompts:

Can you explain how the switch statement works in this example?

What happens if the transaction type is not recognized?

Can you show me how to test this with a different transaction type?

Awesome!

Completion rate improved to 2.94

bookDesafío: Calculadora de Comisiones

Desliza para mostrar el menú

You are developing a program for a bank that needs to calculate commission based on the transaction type. Your task is to write a switch statement that will output the commission based on the type of incoming transaction.

Commission rates based on transaction type:

  • Payment: 0.5%
  • Transfer: 1.2%
  • Withdrawal: 2.0%
  • Deposit: 0.0% (no commission)

Replace ___ with the necessary code to compile it. Don't hesitate to check the hint and solution to better understand the task.

123456789101112131415161718192021
let transactionType: string = "Transfer"; // You can change the operation type let commission: number; switch (transactionType) { case ___: ___ = 0.5; break; case ___: ___ = ___; break; case ___: ___ = ___; break; case ___: ___ = ___; break; ___: ___ = -1; // Handle unknown transaction types } console.log(`Commission for ${transactionType}: ${commission}%`);
copy
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 7
some-alt