1.3 KiB
1.3 KiB
id, title, challengeType
id | title | challengeType |
---|---|---|
5d7925330918ae4a2f282e7e | Part 12 | 0 |
--description--
Use arrow function syntax to define a function infixEval
which takes str
and regex
as arguments and returns str.replace(regex, "")
.
--hints--
See description above for instructions.
assert(
/constinfixEval=\(str,regex\)=>str\.replace\(regex,['"]{2}\)/.test(
code.replace(/\s/g, '')
)
);
--seed--
--before-user-code--
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Spreadsheet</title>
<style>
#container {
display: grid;
grid-template-columns: 50px repeat(10, 200px);
grid-template-rows: repeat(11, 30px);
}
.label {
background-color: lightgray;
text-align: center;
vertical-align: middle;
line-height: 30px;
}
</style>
</head>
<body>
<div id="container">
<div></div>
</div>
--after-user-code--
</body>
</html>
--seed-contents--
<script>
const infixToFunction = {
"+": (x, y) => x + y,
"-": (x, y) => x - y,
"*": (x, y) => x * y,
"/": (x, y) => x / y
};
</script>
--solutions--
<script>
const infixToFunction = {
"+": (x, y) => x + y,
"-": (x, y) => x - y,
"*": (x, y) => x * y,
"/": (x, y) => x / y
};
const infixEval = (str, regex) => str.replace(regex, "");
</script>