-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstar.html
57 lines (52 loc) · 1.46 KB
/
star.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
<!DOCTYPE html>
<html>
<head>
<title>star</title>
<meta charset="UTF-8">
<style>
/* .top, .bottom{
width: 200px;
height: 50px;
position: absolute;
}
.top {
background-color: rgba(0,0,0,0.5);
z-index: 2;
}
.bottom {
background-color: pink;
z-index: 1;
}
.top-star {
width: 30px;
height: 30px;
} */
</style>
</head>
<!-- <div class="top">
<span></span>
</div>
<div class="bottom"></div> -->
<body>
<script>
const starFunc = (point) => {
const starArr = ['null', 'null', 'null', 'null', 'null'];
const score = Number(point) - 1;
for (let i = 0; i < starArr.length; i++){
if (score >= i){
starArr[i] = 'full';
}else if (score < i && Math.ceil(score) === i){
starArr[i] = 'half';
}else {
starArr[i] = 'null';
}
}
return starArr;
}
const starArr = starFunc(8);
console.log(starArr);
// const score = 4.5;
// console.log(Math.ceil(score))
</script>
</body>
</html>