mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-22 03:26:02 -05:00
82 lines
1.7 KiB
Markdown
82 lines
1.7 KiB
Markdown
---
|
|
id: 642df32c0c2db433d8b46d46
|
|
title: Step 5
|
|
challengeType: 0
|
|
dashedName: step-5
|
|
---
|
|
|
|
# --description--
|
|
|
|
Finally, use the `.appendChild()` method to add your `label` element to the `container` element.
|
|
|
|
# --hints--
|
|
|
|
You should access the `.appendChild()` method of the `container` element.
|
|
|
|
```js
|
|
assert.match(code, /container\.appendChild\(/);
|
|
```
|
|
|
|
You should pass your `label` element to the `.appendChild()` method.
|
|
|
|
```js
|
|
assert.match(code, /container\.appendChild\(\s*label\s*\)/);
|
|
```
|
|
|
|
You should append `label` after setting the attributes.
|
|
|
|
```js
|
|
assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\)\s*;?\s*label\.className\s*=\s*('|"|`)label\2\s*;?\s*label\.textContent\s*=\s*name\s*;?\s*container\.appendChild\(\s*label\s*\)/);
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```html
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<link rel="stylesheet" href="./styles.css" />
|
|
<title>Functional Programming Spreadsheet</title>
|
|
</head>
|
|
<body>
|
|
<div id="container">
|
|
<div></div>
|
|
</div>
|
|
<script src="./script.js"></script>
|
|
</body>
|
|
</html>
|
|
```
|
|
|
|
```css
|
|
#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;
|
|
}
|
|
```
|
|
|
|
```js
|
|
--fcc-editable-region--
|
|
window.onload = () => {
|
|
const container = document.getElementById("container");
|
|
const createLabel = (name) => {
|
|
const label = document.createElement("div");
|
|
label.className = "label";
|
|
label.textContent = name;
|
|
|
|
}
|
|
}
|
|
--fcc-editable-region--
|
|
```
|