Parcourir la source

Second task is done

pocu46 il y a 4 ans
Parent
commit
6379577663
4 fichiers modifiés avec 128 ajouts et 0 suppressions
  1. 11 0
      02/index.html
  2. 90 0
      02/script.js
  3. 11 0
      03/index.html
  4. 16 0
      03/script.js

+ 11 - 0
02/index.html

@@ -0,0 +1,11 @@
+<!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>
+    <script src="./script.js"></script>
+</body>
+</html>

+ 90 - 0
02/script.js

@@ -0,0 +1,90 @@
+// ------------------Number: age  task----------------------------------
+
+let userAge = +prompt("Enter your age", "");
+let userYearOfBirth = 2020 - userAge;
+alert(userYearOfBirth);
+
+// ------------------Number: temperature --------------------------------
+
+let temperatureCelsius = +prompt("Enter number degrees Celsius", "");
+let celsiusToFahrenheit = x => x * 1.8 + 32;
+alert(celsiusToFahrenheit(temperatureCelsius));
+
+// ------------------Number: divide ----------------------------------
+
+let num1 = +prompt("Enter number1");
+let num2 = +prompt("Enter number2");
+
+function divideNum(x, y) {
+    const divN = x / y;
+    return Math.round(divN);
+}
+
+alert(divideNum(num1, num2)); 
+
+// ------------------Number: odd ----------------------------------
+
+// debugger
+let enterNum = +prompt("Enter number");
+if (enterNum == typeof(Number)) {
+    if (enterNum % 2 === 0) {
+        alert("Even number");
+    } else {
+        alert("Odd number");
+    }
+} else {
+    alert("You need to enter number");    //  NEED TO FIX
+}
+
+// ------------------Number: greeting ----------------------------------
+
+let name = prompt("Enter your name", "");
+alert(`Hello ${name}! How are you?`);
+
+// ------------------Number: lexics ------------------------------------
+
+let someText = prompt("Enter some text");
+if (someText.includes("PHP")) {
+    alert("You've got $ only in variables");
+} else {
+    alert("You are not PHP developer");
+}
+
+// ------------------Number: lexics ------------------------------------
+
+let checkSex = confirm("Are you a man?");
+if (checkSex === true) {
+    alert("Sex - male");
+} else {
+    alert("Sex - feemale");
+}
+
+// ------------------Array: real ------------------------------------
+
+let racers = [
+    {
+        name: "Valentino",
+        surname: "Rossi",
+        number: 46,
+        team: "Yamaha"
+    },
+    {
+        name: "Andrea",
+        surname: "Dovisioso",
+        number: 04,
+        team: "Ducati"
+    },
+]
+
+// ------------------Number: flats ------------------------------------
+
+let flatNumber = +prompt("Enter number of flat in house");
+let maxFloorNumber = +prompt("Enter number of floors in house");
+let flatsPerFloor = +prompt("Enter total flats number in house");
+let entrance;
+let floor;
+
+    entrance = Math.trunc((flatNumber - 1) / (maxFloorNumber * flatsPerFloor)) + 1;
+    floor = Math.trunc(((flatNumber - 1) % (maxFloorNumber * flatsPerFloor)) / flatsPerFloor) + 1;
+
+alert(`Floor: ${floor}, entrance: ${entrance}`);

+ 11 - 0
03/index.html

@@ -0,0 +1,11 @@
+<!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>
+    <script src="./script.js"></script>
+</body>
+</html>

+ 16 - 0
03/script.js

@@ -0,0 +1,16 @@
+// ------------------switch: if ------------------------------------
+
+let color = prompt("Enter text","");
+if (color === "red") {
+    document.write("<div style='background-color: red;'>red</div>");
+    document.write("<div style='background-color: black; color: white;'>black</div>");
+} else if (color === "black") {
+    document.write("<div style='background-color: black; color: white;'>black</div>");
+} else if (color === "blue") {
+    document.write("<div style='background-color: blue;'>blue</div>");
+    document.write("<div style='background-color: green;'>green</div>");
+} else if (color === "green") {
+    document.write("<div style='background-color: green;'>green</div>");
+} else {
+    document.write("<div style='background-color: gray;'>I can't understand</div>");
+}