function convertIsbn10ToIsbn13(isbn10) {
  if (!isValidIsbn(isbn10)) {
    return null;
  }

  if (isbn10.length === 13) {
    return isbn10;
  }

  const newIsbn = `978${isbn10.slice(0, -1)}`;
  const checkSum = newIsbn
    .split('')
    .map((d, i) => ((i + 1) % 2 === 0 ? 3 : 1) * parseInt(d, 10))
    .reduce((sum, parcel) => sum + parcel, 0);
  const lastDigit = checkSum % 10;

  return newIsbn + (lastDigit !== 0 ? 10 - lastDigit : 0);
}
Convert a valid ISBN-10 string to a current ISBN-13.

@param {string} isbn10 The ISBN-10 representation.
@returns The ISBN-13 representation.