An Interest In:
Web News this Week
- March 22, 2024
- March 21, 2024
- March 20, 2024
- March 19, 2024
- March 18, 2024
- March 17, 2024
- March 16, 2024
Daily Challenge 292 - ISBN-10 Identifiers
ISBN-10 identifiers are ten digits. The first nine digits are on the range 0 to 9. The last digit can be either on the range 0 to 9 or the letter 'X' used to indicate a value of 10.
For an ISBN-10 to be valid, the sum of the digits multiplied by their position has to equal zero modulo 11. For example, the ISBN-10: 1112223339 is valid because:(((1*1)+(1*2)+(1*3)+(2*4)+(2*5)+(2*6)+(3*7)+(3*8)+(3*9)+(9*10)) % 11) == 0
Create the function validISBN10()
to return true if and only if the input is a valid ISBN-10 Identifier.
Examples
validISBN10('1293000000'), true
validISBN10('048665088X'), true
validISBN10('1234512345'), false
validISBN10('1293') , false
Tests
validISBN10('1112223339')
validISBN10('X123456788')
validISBN10('1234512345')
Good luck!
This challenge comes from nklein on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email [email protected] with your suggestions!
Original Link: https://dev.to/thepracticaldev/daily-challenge-292-isbn-10-identifiers-293g
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To