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 4 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 @@ -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

This file was deleted.