Created
July 1, 2015 11:52
-
-
Save sinslav/c42d928321adcfd30924 to your computer and use it in GitHub Desktop.
exchange
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var valuta, sum, uah_kurs, usd_kurs, eur_kurs; | |
uah_kurs=1; | |
usd_kurs=1/28; | |
eur_kurs=1/32; | |
valuta=prompt('Какую валюту вы хотите обменять? \(usd\, uah или eur\)'); | |
// if (valuta !== 'usd' || 'USD' || 'uah' || 'UAH' || 'EUR' ||'eur') {alert('Введите валюту в формате USD, UAH или EUR')}; | |
sum=+prompt('Сколько у вас валюты?'); | |
switch(valuta) { | |
case 'usd'||'USD': {alert('Ваши ' + sum + ' ' + valuta + ' равны ' + sum/usd_kurs + ' uah ' + ' или ' + sum/usd_kurs * eur_kurs + ' eur'); break;} | |
case 'uah'||'UAH': {alert('Ваши ' + sum + ' ' + valuta + ' равны ' + sum*usd_kurs + ' usd ' + ' или ' + sum*eur_kurs + ' eur' ); break;} | |
case 'eur'||'EUR': {alert('Ваши ' + sum + ' ' + valuta + ' равны ' + sum/eur_kurs*usd_kurs + ' usd ' + ' или ' + sum/eur_kurs + ' uah' );} | |
default: {alert('Не вверно введена сумма денег')} } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment