JavaScript Coding for Teens: A Beginner's Guide to Developing Websites and Games by Yueh Andrew
Author:Yueh, Andrew
Language: eng
Format: epub, pdf
Publisher: Rockridge Press
Published: 2021-12-28T00:00:00+00:00
Debugging
This code has a ton of problems! The function playerAboveSkillAndAge should be returning an array that includes the players who are above the specified skill and age.
var players = [
{ player: 'super', skill: 1, age: 20 },
{ player: 'smurf', skill: 8, age: 24 },
{ player: 'ANS', skill: 6, age: 27 },
{ player: 'faker', skill: 10, age: 17 },
{ player: 'shroud', skill: 9, age: 26 }
];
function playersAboveSkill(players, skill) {
var skilledPlayers = players;
for (var i = 0; i < players.length; i++) {
var objectKey = 'skill';
if (players[i].objectKey < skill) {
skilledPlayers.push(players);
}
}
return skilledPlayers;
}
function playersAboveAge(players, age) {
var agedPlayers = players;
for (var i = 1; i < players.length; i++) {
var objectKey = 'age';
if (players[i].objectKey < age) {
agedPlayers.push(players);
}
}
return agedPlayers;
}
function playerAboveSkillAndAge(players, skill, age) {
var skilledPlayers = playersAboveSkill(players, skill);
var skilledAndAgedPlayers = playersAboveAge(skilledPlayers, age);
return skilledAndAgedPlayers;
}
console.log(playerAboveSkillAndAge(players, 6, 19));
// expected
[
{ player: 'smurf', skill: 8, age: 24 },
{ player: 'shroud', skill: 9, age: 26 }
];
console.log(playerAboveSkillAndAge(players, 2, 16));
// expected
[
{ player: 'smurf', skill: 8, age: 24 },
{ player: 'ANS', skill: 6, age: 27 },
{ player: 'faker', skill: 10, age: 17 },
{ player: 'shroud', skill: 9, age: 26 }
];
Download
JavaScript Coding for Teens: A Beginner's Guide to Developing Websites and Games by Yueh Andrew.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Basics of Organic Chemistry by Clowes Martin;(312)
The Science of Philip Pullman's His Dark Materials by Mary Gribbin(307)
Harry Potter and the Sorcerer's Stone: SparkNotes Literature Guide by SparkNotes(266)
Flowers in the Gutter by K. R. Gaddy(241)
Summary of the Selfish Gene by Readtrepreneur Publishing(231)
Fake News and Propaganda by Fiona Young-Brown(230)
Braiding Sweetgrass for Young Adults by Robin Wall Kimmerer(227)
Super Simple Chemistry by D.K. Publishing(227)
Exam Success in Geography for IGCSE & O Level by Unknown(227)
JavaScript Coding for Teens: A Beginner's Guide to Developing Websites and Games by Yueh Andrew(213)
The Python Audio Cookbook;Recipes for Audio Scripting with Python by Alexandros Drymonitis(208)
Analysis and Linear Algebra for Finance: Part II by Bookboon.com(207)
Key Immigration Laws by Kathryn Ohnaka(203)
Dark days in Salem: the witchcraft trials by Deborah Kent(196)
Cracking the AP Economics Macro & Micro Exams, 2017 Edition by Princeton Review(194)
The Science of Fashion by Julie Danneberg;(184)
Solutions for a Cleaner, Greener Planet: Environmental Chemistry by Marc Zimmer(181)
Cracking the AP Psychology Exam, 2017 Edition by Princeton Review(170)
The Basics of Biochemistry by Kyle Kirkland(169)
