求助js 问题
javascript吧
全部回复
仅看楼主
level 4
求助js 问题
2020年05月11日 12点05分 1
level 4
有木有人
2020年05月11日 15点05分 2
level 4
大神有木有
2020年05月11日 15点05分 3
level 4
求带
2020年05月11日 15点05分 4
level 7
[乖]循环遍历对象
2020年05月12日 03点05分 5
唔,我做了第二题,能输入,但是输入过后,输出就成空格!总感觉我自己写的不靠谱!太难了
2020年05月12日 03点05分
有没有console输进去格式怎么样的?是json那种么?
2020年05月12日 03点05分
@欣儿哥哥 唔,是js那种,最后我发现是document定义错了
2020年05月12日 16点05分
@nice今非昔比z 嗷嗷,好的
2020年05月13日 05点05分
level 5
工作划水,私我带带你
2020年05月12日 03点05分 6
level 2
构造函数stu里面定义语文,数学,平均,总和。然后在一个新的数组里new 五个 stu ,语文数学为函数入参[你懂的]
2020年05月12日 09点05分 7
???
2020年05月12日 16点05分
level 12
你试试看 [吐舌]
学号:<input class="student" type="text" oninput="oStudent.sid=this.value" value="" /><br />
姓名:<input class="student" type="text" oninput="oStudent.name=this.value" value="" /><br />
年龄:<input class="student" type="text" oninput="oStudent.age=this.value" value="" /><br />
<input type="button" onclick="fnStudent(document.getElementById('demo'))" value="输出" />
<p id="demo"></p>
<p id="stu-data"></p>
<script>
// 2
let oStudent = {};
const fnStudent = o => {
if (!([...document.querySelectorAll('.student')].every(e => e.value && e.value.trim()))) return (o.innerHTML = '', alert('其中有空白!!!'));
o.innerHTML = Object.values(oStudent).join('<br />');
};
// 3
class ClStudent {
constructor(sid, name, _class,
chinese, mathematics, totalScore) {
this.sid = sid;
this.name = name;
this._class = _class;
this.chinese = chinese;
this.mathematics = mathematics;
this.totalScore = totalScore;
}
}
let aStuData = [new ClStudent(10, '小明', '一年一斑', 60, 50, 110), new ClStudent(20, '小芳', '二年二班', 70, 60, 130), new ClStudent(30, '张三', '三年三班', 50, 50, 100), new ClStudent(40, '李四', '一年四班', 70, 70, 140), new ClStudent(50, '王五', '二年一班', 20, 90, 110)],
oIdStu = document.getElementById('stu-data');
oIdStu.innerHTML = aStuData.map(c => `学号: ${c.sid}, 姓名: ${c.name}, 班级: ${c._class}, 语文: ${c.chinese}, 数学: ${c.mathematics}, 总分: ${c.totalScore}`).join('<br />') + `<br />
语文平均分: ${aStuData.reduce((p, n) => p + n.chinese, 0) / aStuData.length}<br />
数学平均分: ${aStuData.reduce((p, n) => p + n.mathematics, 0) / aStuData.length}`;
</script>
2020年05月13日 01点05分 10
1