1 Star 0 Fork 40

林梅株/12月24日作业

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
jjs.html 1.66 KB
一键复制 编辑 原始数据 按行查看 历史
林梅株 提交于 2022-10-15 03:28 . 111
<!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>Document</title>
</head>
<body>
</body>
<script>
// ### 1. 字符串"要考试了,要好好复习,不要挂科",取满里面5个不同的字符,逗号能一个字符
var str = "要考试了,要好好复习,不要挂科";
var han = {
handle: function (arr = []) {
var shuzu = str[Math.floor(Math.random() * (str.length))];
if (arr.length < 5) {
if (arr.indexOf(shuzu) == -1) {
arr.push(shuzu);
}
this.handle(arr);
}
}
}
var arr = [];
han.handle(arr);
console.log(arr);
// 取出student,按date 进行升序排列;
var stu = {
"data": {
'list': [{
'student': [
{ date: '2022 10/1', 'name': '张三', 'pid': 0 },
{ date: 1665648330145, 'name': '张三三', 'pid': 1 },
{ date: 1655648330145,name: '李四', 'pid': 2 },
{ date: '2022 10/3', 'name': '李四四', 'pid': 3 },
{ date: '2020 10/3', 'name': '王五', 'pid': 3 },
]
}]
}
}
var student = stu.data.list[0].student
console.log(student);
student.sort(function (a, b) {
var date1 = new Date(a.date);
var date2 = new Date(b.date);
return date1 - date2
});
console.log(student);
</script>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lin-meizhu/operation-on-december-24.git
git@gitee.com:lin-meizhu/operation-on-december-24.git
lin-meizhu
operation-on-december-24
12月24日作业
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385