Advertisement
Talilo

Calculo fatorial.js

Dec 26th, 2022 (edited)
808
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var numero = prompt("Digite o numero fatorial: ")
  2. fatorial = numero
  3. for (var i = 1; i < numero; i++){
  4.   fatorial = fatorial * i  
  5.  
  6. }
  7. console.log(`seu numero é ${fatorial}`)
  8.  
  9.  
  10. var numero = 10
  11. fatorial = numero
  12. for (var i = 1; i < numero; i++){
  13.   fatorial = fatorial * i  
  14.  
  15. }
  16. console.log('seu numero é' + fatorial)
  17.  
  18. // uso de switch no javascrip
  19. const expr = prompt()
  20. switch (expr) {
  21.   case 'Oranges':
  22.     console.log('Oranges are $0.59 a pound.');
  23.     break;
  24.   case 'Mangoes':
  25.   case 'Papayas':
  26.     console.log('Mangoes and papayas are $2.79 a pound.');
  27.     // expected output: "Mangoes and papayas are $2.79 a pound."
  28.     break;
  29.   default:
  30.     console.log(`Sorry, we are out of ${expr}.`);
  31. }
  32.  
  33. //https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Statements/switch
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement