Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: made timeAgo function way shorter and viewCount shorter #54583

Merged
merged 6 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,185 +99,137 @@
"id": "643ee973c162ae017b3d30db",
"title": "Step 22"
},
{
"id": "6443b612a30b3601404c9b61",
"title": "Step 23"
},
{
"id": "6443c4d659395d0175cd121a",
"title": "Step 24"
},
{
"id": "6443c7e97bcc4401bc99d87b",
"title": "Step 25"
},
{
"id": "6443c98ac169e501eba36d04",
"title": "Step 26"
},
{
"id": "6443cc3ed4a11e02329c4c0e",
"title": "Step 27"
},
{
"id": "6443ce08c89b250267c4225a",
"title": "Step 28"
},
{
"id": "6443cf1cca1fbb02a8a6e46e",
"title": "Step 29"
},
{
"id": "6443d0428d7c2402e9d78709",
"title": "Step 30"
},
{
"id": "6443d6ab21742c031bea7778",
"title": "Step 31"
},
{
"id": "6443fbba1e9df4038f5af689",
"title": "Step 32"
"title": "Step 23"
},
{
"id": "6444062a33ab4c03d0c2e9f5",
"title": "Step 33"
"title": "Step 24"
},
{
"id": "64440a50d076c204051f2cc0",
"title": "Step 34"
},
{
"id": "6444ec416a1fe1017e517bd8",
"title": "Step 35"
},
{
"id": "6444ed90ff671201bf007af6",
"title": "Step 36"
},
{
"id": "6444f08fae25f201f10083a9",
"title": "Step 37"
"title": "Step 25"
},
{
"id": "6444f324c287170220eee013",
"title": "Step 38"
"title": "Step 26"
},
{
"id": "6576076879130f6cf7426e82",
"title": "Step 39"
"title": "Step 27"
},
{
"id": "65760954561c726e832a0cc8",
"title": "Step 40"
"title": "Step 28"
},
{
"id": "65760ce115eb06716baeb361",
"title": "Step 41"
"title": "Step 29"
},
{
"id": "65760de70283687288fe70cf",
"title": "Step 42"
"title": "Step 30"
},
{
"id": "6446d8f9fce0fa0172473964",
"title": "Step 43"
"title": "Step 31"
},
{
"id": "644b6d20eabd7e0149383254",
"title": "Step 44"
"title": "Step 32"
},
{
"id": "644b736c83c5250181633899",
"title": "Step 45"
"title": "Step 33"
},
{
"id": "644b97360868a301bf9ba463",
"title": "Step 46"
"title": "Step 34"
},
{
"id": "644ba3c43bb57f020ca57834",
"title": "Step 47"
"title": "Step 35"
},
{
"id": "644baae059c58402a31e815a",
"title": "Step 48"
"title": "Step 36"
},
{
"id": "644f360e888420013dbe705f",
"title": "Step 49"
"title": "Step 37"
},
{
"id": "644f4bcf1c2afd0211cd945e",
"title": "Step 50"
"title": "Step 38"
},
{
"id": "644f848af645ce012bd1a2bc",
"title": "Step 51"
"title": "Step 39"
},
{
"id": "644fa585a5f9970173ca3cff",
"title": "Step 52"
"title": "Step 40"
},
{
"id": "644fb1d7f0257702a0c935cf",
"title": "Step 53"
"title": "Step 41"
},
{
"id": "644fba64caf60303c9540d14",
"title": "Step 54"
"title": "Step 42"
},
{
"id": "645763874fd6d901c273db29",
"title": "Step 55"
"title": "Step 43"
},
{
"id": "645f06144bc0dc0143a5a3a2",
"title": "Step 56"
"title": "Step 44"
},
{
"id": "645f1cffc7f95e01db009f32",
"title": "Step 57"
"title": "Step 45"
},
{
"id": "645f34e7925b68021ce0bcaa",
"title": "Step 58"
"title": "Step 46"
},
{
"id": "645f7231271ab1012bc659b8",
"title": "Step 59"
"title": "Step 47"
},
{
"id": "645f764c37de33015ded1273",
"title": "Step 60"
"title": "Step 48"
},
{
"id": "645f7879ebbdb201892e55e1",
"title": "Step 61"
"title": "Step 49"
},
{
"id": "645f8615fa144d01c476b22c",
"title": "Step 62"
"title": "Step 50"
},
{
"id": "645f958584305d02bf48fe5b",
"title": "Step 63"
"title": "Step 51"
},
{
"id": "646474a88d0d4a016f895ba8",
"title": "Step 64"
"title": "Step 52"
},
{
"id": "64648c3254e52901e36e7703",
"title": "Step 65"
"title": "Step 53"
},
{
"id": "646494e11d0cab03caee204c",
"title": "Step 66"
"title": "Step 54"
},
{
"id": "64649b108df035051cb2ba2d",
"title": "Step 67"
"title": "Step 55"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,48 @@ dashedName: step-22

To display data in the `Activity` column, you need to use the `bumped_at` property of each topic, which is a timestamp in the ISO 8601 format. You need to process this data before you can show how much time has passed since a topic had any activity.

Create a new arrow function called `timeAgo` with a parameter called `time`.
Create a new `timeAgo` function with a `time` parameter.

Inside your `timeAgo` function, create two variables named `currentTime` and `lastPost` and set them to `new Date()` and `new Date(time)` respectively.

`lastPost` will be the date of the last activity on a topic, and`currentTime` represents the current date and time.

# --hints--

You should have an arrow function named `timeAgo`.
You should create a `timeAgo` function.

```js
assert.match(code, /\s*const\s+timeAgo\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/);
assert.isFunction(timeAgo);
```

`timeAgo` should be defined.
Your `timeAgo` function should have a `time` parameter.

```js
assert.isDefined(timeAgo);
assert.match(timeAgo.toString(), /\(time\)/);
```

`timeAgo` should be a function.
You should have a `currentTime` variable inside your `timeAgo` function.

```js
assert.isFunction(timeAgo);
assert.match(timeAgo.toString(), /currentTime\s*=\s*/);
```

You should set the `currentTime` variable to `new Date()`.

```js
assert.match(timeAgo.toString(), /currentTime\s*=\s*new\s*Date\(\)/);
```

`timeAgo` should be an empty function.
You should have a `lastPost` variable inside your `timeAgo` function.

```js
assert.match(code, /\s*const\s+timeAgo\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{\s*}/);
assert.match(timeAgo.toString(), /lastPost\s*=\s*/);
```

You should have a `time` parameter for the `timeAgo` function.
You should set the `lastPost` variable to `new Date(time)`.

```js
assert.match(code, /\s*const\s+timeAgo\s*=\s*(\(\s*time\s*\)|time)\s*=>\s*{\s*}/);
assert.match(timeAgo.toString(), /lastPost\s*=\s*new\s*Date\(\s*time\s*\)/);
```

# --seed--
Expand Down