Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drip
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
backup
Drip
Commits
9d3c3324
Commit
9d3c3324
authored
4 years ago
by
Sofiya Tepikin
Browse files
Options
Downloads
Patches
Plain Diff
Fix getOrdinalSuffix and add a formatting function
parent
e5418c32
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
components/helpers/home.js
+19
-9
19 additions, 9 deletions
components/helpers/home.js
with
19 additions
and
9 deletions
components/helpers/home.js
+
19
−
9
View file @
9d3c3324
...
...
@@ -64,14 +64,24 @@ export function getBleedingPredictionRange(prediction) {
}
export
function
getOrdinalSuffix
(
num
)
{
const
suffixes
=
{
1
:
'
st
'
,
2
:
'
nd
'
,
3
:
'
rd
'
,
default
:
'
th
'
const
j
=
num
%
10
const
k
=
num
%
100
if
(
j
===
1
&&
k
!==
11
)
{
return
'
st
'
}
if
(
j
===
2
&&
k
!==
12
)
{
return
'
nd
'
}
if
(
j
===
3
&&
k
!==
13
)
{
return
'
rd
'
}
const
numAsString
=
num
.
toString
()
const
lastNumber
=
numAsString
[
numAsString
.
length
-
1
]
return
suffixes
[
lastNumber
]
||
suffixes
.
default
}
\ No newline at end of file
return
'
th
'
}
export
function
formatWithOrdinalSuffix
(
num
)
{
return
num
+
getOrdinalSuffix
(
num
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment