mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(curriculum): slice range (#52712)
This commit is contained in:
+2
-2
@@ -34,13 +34,13 @@ assert.match(code, /<p\s*class=("|')bio\1>\$\{\s*bio\.length\s*>\s*50/)
|
||||
If the `bio` text is greater than `50` characters, you should extract the first 50 characters with `slice()` and replace the rest with `...`. Don't forget that indexes are zero-based.
|
||||
|
||||
```js
|
||||
assert.match(code, /<p\s*class=("|')bio\1>\$\{\s*bio\.length\s*>\s*50\s*\?\s*bio\.slice\(\s*0\,\s*49\s*\)\s*\+\s*("|')\.\.\.\2\s*\:/)
|
||||
assert.match(code, /<p\s*class=("|')bio\1>\$\{\s*bio\.length\s*>\s*50\s*\?\s*bio\.slice\(\s*0\,\s*50\s*\)\s*\+\s*("|')\.\.\.\2\s*\:/)
|
||||
```
|
||||
|
||||
If the `bio` text is less than 50 characters, use the `bio` text directly.
|
||||
|
||||
```js
|
||||
assert.match(code, /<p\s*class=("|')bio\1>\$\{\s*bio\.length\s*>\s*50\s*\?\s*bio\.slice\(\s*0\,\s*49\s*\)\s*\+\s*("|')\.\.\.\2\s*\:\s*bio\s*\}<\/p>/)
|
||||
assert.match(code, /<p\s*class=("|')bio\1>\$\{\s*bio\.length\s*>\s*50\s*\?\s*bio\.slice\(\s*0\,\s*50\s*\)\s*\+\s*("|')\.\.\.\2\s*\:\s*bio\s*\}<\/p>/)
|
||||
```
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -180,7 +180,7 @@ const displayAuthors = (authors) => {
|
||||
<h2 class="author-name">${author}</h2>
|
||||
<img class="user-img" src="${image}" alt="${author} avatar" />
|
||||
<div class="purple-divider"></div>
|
||||
<p class="bio">${bio.length > 50 ? bio.slice(0, 49) + '...' : bio}</p>
|
||||
<p class="bio">${bio.length > 50 ? bio.slice(0, 50) + '...' : bio}</p>
|
||||
<a class="author-link" href="${url}" target="_blank">${author} author page</a>
|
||||
</div>
|
||||
`;
|
||||
|
||||
+2
-2
@@ -174,7 +174,7 @@ const displayAuthors = (authors) => {
|
||||
<h2 class="author-name">${author}</h2>
|
||||
<img class="user-img" src="${image}" alt="${author} avatar">
|
||||
<div class="purple-divider"></div>
|
||||
<p class="bio">${bio.length > 50 ? bio.slice(0, 49) + '...' : bio}</p>
|
||||
<p class="bio">${bio.length > 50 ? bio.slice(0, 50) + '...' : bio}</p>
|
||||
<a class="author-link" href="${url}" target="_blank">${author} author page</a>
|
||||
</div>
|
||||
`;
|
||||
@@ -321,7 +321,7 @@ const displayAuthors = (authors) => {
|
||||
<h2 class="author-name">${author}</h2>
|
||||
<img class="user-img" src="${image}" alt="${author} avatar" />
|
||||
<div class="purple-divider"></div>
|
||||
<p class="bio">${bio.length > 50 ? bio.slice(0, 49) + '...' : bio}</p>
|
||||
<p class="bio">${bio.length > 50 ? bio.slice(0, 50) + '...' : bio}</p>
|
||||
<a class="author-link" href="${url}" target="_blank">${author} author page</a>
|
||||
</div>
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user