I think the test is fine and the problem is Math.round(), because it rounds each share separately and then the sum no longer adds up.
NativelyTranslated from CatalanConfidence: Medium
Four things Natively does today, step by step, in the language you pick.
A bug reported in Slack becomes an English Linear issue, and the fix comes back to the thread.
Step 1 of 4Noa reports a bug in Slack and mentions @Natively.
Noa’s Slack · she writes in her own language
split-bill
Noa10:42
Al repartir con propina, la app cobra un céntimo de más
Con splitWithTip(1000, 3, 10) las partes suman 1101 y el total con propina es 1100. @Natively
When an error crosses its threshold, one okay files the issue and then posts it to the team.
Step 1 of 4An error in Sentry reaches its alert threshold.
The team’s Sentry · in English
Issues · split-bill
RangeErrorpeople must be a whole number, 1 or more
splitWithTip (src/split-bill.js)
Events 14Users 6
Alert: users affected > 5
Comments in any language, and a failing check, read in your language.
Step 1 of 3Ari and Kai each wrote in their own language. You read both in yours.
The pull request, as you read it
src/split-bill.jsreturn Array.from({ length: people }, () => Math.round(withTip / people));I think the test is fine and the problem is Math.round(), because it rounds each share separately and then the sum no longer adds up.
NativelyTranslated from CatalanConfidence: Medium
If each person's share is rounded with Math.round() here, the total may no longer match the original amount. Please check it with splitWithTip(1000, 3, 10).
NativelyTranslated from JapaneseConfidence: Medium
Write in your own language and see the English that would be posted.
Step 1 of 3Noa writes her reply in her own language.
Noa’s comment box · in her own language
WritePreview
NativelyEscribe en español
Tu respuesta, en español
Tienes razón. Redondearé hacia abajo con Math.floor() y daré los céntimos que sobren a las primeras partes.
Natively never posts on GitHub for you.