Skip to content

Commit

Permalink
chore(i18n,learn): processed translations
Browse files Browse the repository at this point in the history
  • Loading branch information
camperbot committed Oct 2, 2024
1 parent 5090694 commit b85ce6f
Show file tree
Hide file tree
Showing 207 changed files with 7,641 additions and 392 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Modify your regex pattern to use a negative lookbehind so that the character `1`

# --hints--

You should modify the pattern passed as the first argument to the `re.sub()` call using a negative lookbehind. TODO: add details/improve wording
You should modify the pattern passed as the first argument to the `re.sub()` call using a negative lookbehind.

```js
({ test: () => assert(runPython(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ const target = meta?.find(m => m?.getAttribute('name')?.toLowerCase()?.replace(/
assert.exists(target);
```
Your new `meta` element should be inside the `head` element.
Your two `meta` elements should be inside the `head` element.
```js
const metaElementRegex = /<head\s*>(?:.|\r|\n)*?<meta\s+name\s*=\s*('|"|`)\s*viewport\s*\1\s+content\s*=\s*\1\s*width\s*=\s*device-width\s*,\s*initial-scale\s*=\s*1(?:\.0)?\s*\1(?:.|\r|\n)*?<\/head\s*>/i;
assert.match(code, metaElementRegex);
const headContentRegex = /(?<=<head\s*>)[\S|\s]*(?=<\/head\s*>)/;
const headElementContent = code.match(headContentRegex);

const headElement = document.createElement("head");
headElement.innerHTML = headElementContent;
assert.strictEqual(headElement.querySelectorAll('meta').length, 2);
```
# --seed--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,21 @@ console.log( counter++ ); // 0

## --text--

What is the difference in the result of the two console log statements in the JavaScript code below?
What are the outputs of the two `console.log` statements in the JavaScript code below?

```js
let counter = 1;
console.log(2 * ++counter); // Statement A
```

```js
let counter = 1;
console.log(2 * counter++); // Statement B
```

## --answers--

There is no difference; both alert statements will show the same result.
There is no difference; both `console.log` statements will show the same result.

---

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
---
id: 587d825d367417b2b2512c96
title: Implement the Depth-First Search Algorithm
challengeType: 14
dashedName: implement-the-depth-first-search-algorithm
---

# --description--

<dfn>Depth-first search</dfn> (DFS) is an algorithm used to search through data structures such as trees or graphs. Starting from a root node, the search first goes down a path of edges as far as it can. Once it reaches one end of a path, the search will backtrack to the last node with an unvisited edge path and continue searching down the unvisited edge path.

**Objective:** Fulfill the user stories below and get all the tests to pass to complete the lab.

**User Stories:**

1. You should write a function `dfs()` that implements the <dfn>depth-first search</dfn> algorithm on a graph.
1. The function should keep track of the visited nodes.
1. The function should use a stack, an array where the last element added is the first to be removed, to make sure to visit the neighbors of the most recently added node.
1. The function should take an undirected, adjacency matrix `graph` and a node label `root` as parameters. The node label is the numeric value of the node between `0` and `n - 1`, where `n` is the total number of nodes in the graph.
1. The function should output an array of all nodes reachable from `root`.

# --hints--

The input graph `[[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 0]]` with a start node of `1` should return an array with `0`, `1`, `2`, and `3`.

```js
assert.sameMembers(
(function () {
var graph = [
[0, 1, 0, 0],
[1, 0, 1, 0],
[0, 1, 0, 1],
[0, 0, 1, 0]
];
return dfs(graph, 1);
})(),
[0, 1, 2, 3]
);
```

The input graph `[[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 0]]` with a start node of `3` should return an array with `3`, `2`, `1`, and `0`.

```js
assert.sameMembers(
(function () {
var graph = [
[0, 1, 0, 0],
[1, 0, 1, 0],
[0, 1, 0, 1],
[0, 0, 1, 0]
];
return dfs(graph, 3);
})(),
[3, 2, 1, 0]
);
```

The input graph `[[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 0]]` with a start node of `1` should return an array with four elements.

```js
assert(
(function () {
var graph = [
[0, 1, 0, 0],
[1, 0, 1, 0],
[0, 1, 0, 1],
[0, 0, 1, 0]
];
return dfs(graph, 1);
})().length === 4
);
```

The input graph `[[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 0]]` with a start node of `3` should return an array with `3`.

```js
assert.sameMembers(
(function () {
var graph = [
[0, 1, 0, 0],
[1, 0, 1, 0],
[0, 1, 0, 0],
[0, 0, 0, 0]
];
return dfs(graph, 3);
})(),
[3]
);
```

The input graph `[[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 0]]` with a start node of `3` should return an array with one element.

```js
assert(
(function () {
var graph = [
[0, 1, 0, 0],
[1, 0, 1, 0],
[0, 1, 0, 0],
[0, 0, 0, 0]
];
return dfs(graph, 3);
})().length === 1
);
```

The input graph `[[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]` with a start node of `3` should return an array with `2` and `3`.

```js
assert.sameMembers(
(function () {
var graph = [
[0, 1, 0, 0],
[1, 0, 0, 0],
[0, 0, 0, 1],
[0, 0, 1, 0]
];
return dfs(graph, 3);
})(),
[2, 3]
);
```

The input graph `[[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]` with a start node of `3` should return an array with two elements.

```js
assert(
(function () {
var graph = [
[0, 1, 0, 0],
[1, 0, 0, 0],
[0, 0, 0, 1],
[0, 0, 1, 0]
];
return dfs(graph, 3);
})().length === 2
);
```

The input graph `[[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]` with a start node of `0` should return an array with `0` and `1`.

```js
assert.sameMembers(
(function () {
var graph = [
[0, 1, 0, 0],
[1, 0, 0, 0],
[0, 0, 0, 1],
[0, 0, 1, 0]
];
return dfs(graph, 0);
})(),
[0, 1]
);
```

The input graph `[[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]` with a start node of `0` should return an array with two elements.

```js
assert(
(function () {
var graph = [
[0, 1, 0, 0],
[1, 0, 0, 0],
[0, 0, 0, 1],
[0, 0, 1, 0]
];
return dfs(graph, 0);
})().length === 2
);
```

# --seed--

## --seed-contents--

```js

```

# --solutions--

```js
function dfs(graph, root) {
const stack = [];
let tempV;
const visited = [];
let tempVNeighbors = [];
stack.push(root);
while (stack.length > 0) {
tempV = stack.pop();
if (visited.indexOf(tempV) == -1) {
visited.push(tempV);
tempVNeighbors = graph[tempV];
for (let i = 0; i < tempVNeighbors.length; i++) {
if (tempVNeighbors[i] == 1) {
stack.push(i);
}
}
}
}
return visited;
}

const exDFSGraph = [
[0, 1, 0, 0],
[1, 0, 1, 0],
[0, 1, 0, 1],
[0, 0, 1, 0]
];
console.log(dfs(exDFSGraph, 0));
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
id: bd7158d8c443edefaeb5bd0f
title: File Metadata Microservice
challengeType: 4
dashedName: file-metadata-microservice
---

# --description--

Build a full stack JavaScript app that is functionally similar to this: <a href="https://file-metadata-microservice.freecodecamp.rocks" target="_blank" rel="noopener noreferrer nofollow">https://file-metadata-microservice.freecodecamp.rocks</a>. Working on this lab will involve you writing your code using one of the following methods:

- Clone <a href="https://github.com/freeCodeCamp/boilerplate-project-filemetadata/" target="_blank" rel="noopener noreferrer nofollow">this GitHub repo</a> and complete your project locally.
- Use <a href="https://gitpod.io/?autostart=true#https://github.com/freeCodeCamp/boilerplate-project-filemetadata/" target="_blank" rel="noopener noreferrer nofollow">our Gitpod starter project</a> to complete your project.
- Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.

# --instructions--

**HINT:** You can use the `multer` npm package to handle file uploading.

# --hints--

You should provide your own project, not the example URL.

```js
(getUserInput) => {
assert(
!/.*\/file-metadata-microservice\.freecodecamp\.rocks/.test(
getUserInput('url')
)
);
};
```

You can submit a form that includes a file upload.

```js
async (getUserInput) => {
const site = await fetch(getUserInput('url'));
const data = await site.text();
const doc = new DOMParser().parseFromString(data, 'text/html');
assert(doc.querySelector('input[type="file"]'));
};
```

The form file input field has the `name` attribute set to `upfile`.

```js
async (getUserInput) => {
const site = await fetch(getUserInput('url'));
const data = await site.text();
const doc = new DOMParser().parseFromString(data, 'text/html');
assert(doc.querySelector('input[name="upfile"]'));
};
```

When you submit a file, you receive the file `name`, `type`, and `size` in bytes within the JSON response.

```js
async (getUserInput) => {
const formData = new FormData();
const fileData = await fetch(
'https://cdn.freecodecamp.org/weather-icons/01d.png'
);
const file = await fileData.blob();
formData.append('upfile', file, 'icon');
const data = await fetch(getUserInput('url') + '/api/fileanalyse', {
method: 'POST',
body: formData
});
const parsed = await data.json();
assert.property(parsed, 'size');
assert.equal(parsed.name, 'icon');
assert.equal(parsed.type, 'image/png');
};
```

Loading

0 comments on commit b85ce6f

Please sign in to comment.