Created
June 4, 2018 20:21
-
-
Save UlvacMoscow/a0c78dc5385f458b854d0cf9cff38af8 to your computer and use it in GitHub Desktop.
ControlStructures created by Ulvac - https://repl.it/@Ulvac/ControlStructures
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
'use strict' | |
// 1 | |
var quantityInStock; | |
var quantityOfGoodsInTheOrder; | |
quantityInStock = 500; | |
quantityOfGoodsInTheOrder = 500; | |
if (quantityOfGoodsInTheOrder > quantityInStock) { | |
console.log('На складе нет такого количества товаров') | |
} | |
else if (quantityOfGoodsInTheOrder == quantityInStock) { | |
console.log('Вы забираете весь товар с нашего склада') | |
} | |
else { | |
console.log('Заказ оформлен') | |
} | |
// 2 | |
var place = prompt("Введите место доставки?") | |
switch(place) { | |
case 'луна': | |
console.log(`Цены на доставку ${place} 150 Q`) | |
break | |
case 'крабовидная туманность': | |
console.log(`Цены на доставку ${place} 250 Q`) | |
break | |
case 'галактика туманность андромеды': | |
console.log(`Цены на доставку ${place} 550 Q`) | |
break | |
case 'туманность ориона': | |
console.log(`Цены на доставку ${place} 600 Q`) | |
break | |
case 'звезда смерти': | |
console.log(`Цены на доставку договорная`) | |
break | |
default: | |
console.log(`В ваш квадрант доставка не осуществляется.`) | |
} | |
// 3 | |
var price = jhjhjh; | |
try { | |
if (typeof(price) !== 'number') { | |
throw `Вы допустили ошибку: ${price} не является числом`; | |
} | |
console.log('Цена товара введена корректно'); | |
} catch(err) { | |
console.log('произошла ошибка'); | |
} | |
// я что-то не понял с этим catch произошла ошибка что я не так делаю? Она не обрабатывается по сути, если число ввести то все ок. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
task 2