Pārlūkot izejas kodu

part of homework 2

serg155alternate 2 gadi atpakaļ
vecāks
revīzija
06f391cd7e
3 mainītis faili ar 139 papildinājumiem un 0 dzēšanām
  1. 30 0
      HW2/index.html
  2. 53 0
      HW2/script.js
  3. 56 0
      HW2/style.css

+ 30 - 0
HW2/index.html

@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>HW2</title>
+    <link rel="stylesheet" href="style.css">
+</head>
+
+<body>
+    <div class="container">
+        <div class="calc__wrapper">
+            <h3>Калькулятор</h3>
+            <div class="calc__item">
+                <span>Первое число</span>
+                <input type="number"  class="num1">
+            </div>
+            <div class="calc__item">
+                <span>Второе число</span>
+                <input type="number" class="num2">
+            </div>
+            <button class="btn"> Calculate </button>
+            <div class="outer"> </div>
+    </div>
+    <script src="script.js"></script>
+</body>
+
+</html>

+ 53 - 0
HW2/script.js

@@ -0,0 +1,53 @@
+let a = 5;
+let b, c;
+console.log(b)
+b = a * 5;
+console.log(b)
+b = c = b / 2;
+console.log(b, c)
+
+//semicolon: error
+
+// b = a * c  console.log(b) 
+
+//semicolon: mistake
+
+//Number: age
+
+let age ,
+      date = new Date().getFullYear();
+    
+do {
+    age = prompt('Enter your age', '');
+    if (age !== '' && age ) {
+      
+        alert(`Год рождения:  ${date - age}`);
+    } 
+} while (age == '' || age == null);
+
+
+//Number: temperature
+
+let tempCels  = prompt('Enter tempereture', ''),
+    tempFar = tempCels * 1.8 + 32;
+alert(`In fahrenheit: ${tempFar} `);
+
+//Number: divide
+
+let num1Input = document.querySelector('.num1'),
+    num2Input = document.querySelector('.num2'),
+    calculateBtn = document.querySelector('.btn'),
+    outer = document.querySelector('.outer');
+
+
+calculateBtn.addEventListener('click', () => {
+    let arg1 = +num1Input.value,
+        arg2 = +num2Input.value;
+
+    if (arg1 && arg2) {
+        let res = arg1 / arg2;
+        outer.textContent = `${Math.floor(res)}`;
+    } else {
+        outer.textContent = `Enter correct number`;
+    }
+})

+ 56 - 0
HW2/style.css

@@ -0,0 +1,56 @@
+*, html {
+    margin: 0;
+    padding: 0;
+}
+.container {
+    position: relative;
+    max-width: 1140px;
+    margin: 0 auto;
+    padding: 50px;
+}
+.calc__wrapper {
+    width: 280px;
+    height: 180px;
+    padding: 20px;
+    margin: 0 auto;
+    border: 2px solid grey;
+    background-color: ivory;
+    box-shadow: 12px 12px 2px 1px rgba(93, 93, 95, 0.2);
+    border-radius: 25px;
+    text-align: center;
+  
+}
+h3 {
+    margin-bottom: 20px;
+}
+
+input {
+    width: 60px;
+    margin-left: 10px;
+    padding: 2px;
+}
+
+.calc__item {
+    padding: 10px;
+    text-align: left;
+} 
+
+.outer {
+    margin-top: 5px;
+    margin-bottom: 10px;
+    font-size: 24px;
+    font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
+    color: rgb(19, 16, 207);
+}
+
+.btn {
+    margin: 0 auto;
+    padding: 5px;
+    border-radius: 10px;
+    background-color:linen;
+    color: rgb(92, 44, 44);
+    box-shadow: 3px 3px 2px 1px rgba(95, 93, 94, 0.2);
+    align-self: end;
+}
+
+