-
Notifications
You must be signed in to change notification settings - Fork 0
/
ls.html
118 lines (97 loc) · 3.52 KB
/
ls.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script>
class Worker {
constructor(name, surname, days, rate) {
this.name = name;
this.surname = surname;
this.days = days;
this.rate = rate;
}
setName(name){
this.name = name;
}
getName(){
return this.name;
}
setSurname(surname){
this.surname = surname;
}
getSurname(){
return this.surname;
}
setDays(days){
this.days = days;
}
getDays(){
return this.days;
}
setRate(rate){
this.rate = rate;
}
getRate(){
return this.rate;
}
getSalary(){
return this.days * this.rate;
}
}
var worker = new Worker ('Иван', 'Иванов', 31, 10);
console.log(worker.getName());
console.log(worker.getSurname());
console.log(worker.getDays());
console.log(worker.getSalary());
//=====================&===========================
class MyString {
constructor(str){
this.str = str;
}
revers(str){
return str.split('').reverse().join(' ');
}
usFirst(str) {
let newstr = str[0].toUpperCase() + str.slice(1);
return newstr;
}
usWords(str) {
let splitStr = str.split(' ');
for (var i = 0; i < splitStr.length; i++) {
splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].slice(1); //* substring(1) можно использовать
}
return splitStr.join(' ');
}
}
var str = new MyString();
console.log(str.usWords('abcd abcd abcd'));
console.log(str.revers('abcd'));
console.log(str.usFirst('abcd'));
//=====================&===========================
class Validator {
constructor(email, domain, data, phone) {
this.email = email;
this.domain = domain;
this.data = data;
this.phone = phone;
}
isMail(email) {
if(email){
var valid = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
return valid.test(String(email).toLowerCase());
}
}
isDomain(domain) {
}
isData(data) {
}
isPhone(phone) {
}
}
var valid = new Validator();
console.log(valid.isMail('[email protected]'));
</script>
</head>
<body>
</body>
</html>