Browse Source

Some fixes + blue task added

pocu46 4 years ago
parent
commit
dc1169d547
2 changed files with 61 additions and 3 deletions
  1. 28 3
      03/script.js
  2. 33 0
      Select/index.html

+ 28 - 3
03/script.js

@@ -102,7 +102,7 @@ const euroEURtoBuy = 33.25;
 const euroEURforSale = 33.35;
 let currency = (prompt("Enter currency", "USD or EUR").toUpperCase());
 let forChange = +prompt("Enter number HRN for change");
-let buyOrSale = confirm("To you want to buy?")
+let buyOrSale = confirm("Do you want to buy?")
 
 if (currency === "USD" && buyOrSale === true) {
     alert(dollarUSDtoBuy * forChange);
@@ -120,10 +120,10 @@ if (currency === "USD" && buyOrSale === true) {
 
 let userChoise = prompt("Enter your choise", "rock, paper, scissors"); 
 let computerChoise = Math.random();
-if (computerChoise < 0.33) {
+if (computerChoise <= 0.33) {
     computerChoise = "rock"
     alert("rock");
-} else if (computerChoise > 0.33 && computerChoise < 0.66) {
+} else if (computerChoise > 0.33 && computerChoise <= 0.66) {
     computerChoise = "paper"
     alert("paper");
 } else {
@@ -145,4 +145,29 @@ if (userChoise === "rock" && computerChoise === "scissors" ) {
     alert("Nobody wins");
 } else {
     alert("Computer wins");
+}
+
+// ------------------scissors ------------------------------------
+
+let exchangeRates = {
+    dollarUSDtoBuy: 28.25,
+    dollarUSDforSale: 28.37,
+    euroEURtoBuy: 33.25,
+    euroEURforSale: 33.35,
+}
+
+let currency = (prompt("Enter currency", "USD or EUR").toUpperCase());
+let forChange = +prompt("Enter number HRN for change");
+let buyOrSale = confirm("Do you want to buy?")
+
+if (currency === "USD" && buyOrSale === true) {
+    alert(exchangeRates.dollarUSDtoBuy * forChange);
+} else if (currency === "USD" && buyOrSale === false) {
+    alert(exchangeRates.dollarUSDforSale * forChange);
+} else if (currency === "EUR" && buyOrSale === true) {
+    alert(exchangeRates.euroEURtoBuy * forChange);
+} else if (currency === "EUR" && buyOrSale === false) {
+    alert(exchangeRates.euroEURforSale * forChange);
+} else {
+    alert("Wrong data were entered");
 }

+ 33 - 0
Select/index.html

@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+<body>
+    <select id='rates'>
+
+    </select>
+    <input type = 'number' id = 'amount'>
+    <script>
+        fetch('https://api.exchangeratesapi.io/latest')
+    .then(res => res.json())
+    .then(d => {
+        console.log(d) 
+        let str =''
+        for(let currency in d.rates){
+            console.log(currency, d.rates[currency])
+            str += `<Option value=''>${currency}</Option>`        }
+
+            rates.innerHTML = str
+        // тут у нас есть данные
+        //и ниже с ними можно работать
+        //нигде кроме этой функции (этих фигурных скобок) переменной d нет
+    })
+    rates.onchange = amount.oninput = () => {
+        console.log(amount.value, rates.value)
+    }
+    </script>
+</body>
+</html>