This file contains hidden or 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
// task 1 | |
function createOrder(orderId){ | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
let rand = Math.random() > 0.3; | |
if(rand){ resolve(orderId); } | |
else(reject(`Order ${orderId} was not created`)); | |
console.log("Creating order:" + orderId); | |
}, 1000) |
This file contains hidden or 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
// task 1 | |
function onError(error){ | |
console.log(error) | |
} | |
function onSuccess(result){ | |
console.log(result) | |
} | |
function devider(a,b,onSuccess,onError){ | |
if (b === 0) { | |
onError("Zero division error") |
This file contains hidden or 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
<!doctype html> | |
<html class="no-js" lang=""> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title></title> | |
<link rel="stylesheet" href="css/style.css"> | |
<meta name="description" content=""> |
This file contains hidden or 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
<!doctype html> | |
<html class="no-js" lang=""> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title></title> | |
<link rel="stylesheet" href="css/style.css"> | |
<meta name="description" content=""> |
This file contains hidden or 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
// Task 1 | |
function randomNumber(){ | |
let div = document.createElement('div'); | |
let text = document.createElement('p'); | |
let h1 = document.createElement('h1'); | |
let btn = document.createElement('button'); | |
text.textContent = "Random number"; | |
h1.textContent = "Number"; |
This file contains hidden or 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
// Task 1 | |
function insertTable(){ | |
let table = document.createElement("table"); | |
table.style.border = "1px solid black"; | |
table.style.borderCollapse = "collapse"; | |
for(let i = 0; i < 10; i++) { | |
let tr = document.createElement("tr"); | |
tr.style.border = "1px solid black"; |
This file contains hidden or 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
class HtmlElement { | |
#tagOpen; | |
#tagClose; | |
constructor(name, paired = true) { | |
this.name = name; | |
this.paired = paired; | |
this.textContent = ""; | |
this.children = []; | |
this.attributes = []; |
This file contains hidden or 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
// Task PrintMachine | |
class PrintMachine{ | |
constructor(fontSize, fontColor, fontFamily, element = document.body) { | |
this.fontSize = fontSize; | |
this.fontColor = fontColor; | |
this.fontFamily = fontFamily; | |
this.element = element; | |
} |
This file contains hidden or 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
let rectangle = { | |
topLeft: {x:0, y:0}, | |
bottomRight: {x:0, y:0} | |
} | |
function width(rect){ | |
return rect.bottomRight.x - rect.topLeft.x; | |
} | |
function height(rect){ | |
return rect.topLeft.y - rect.bottom.y; |
This file contains hidden or 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
// Task 1 | |
const comparer = function (a, b){ | |
if(a > b) return 1; | |
else if(a < b) return -1; | |
else return 0; | |
} | |
console.log(comparer(1, 2)); | |
// Task 2 factorial |
NewerOlder