Skip to content

Instantly share code, notes, and snippets.

@mathenls
Created April 7, 2022 14:36
Show Gist options
  • Save mathenls/b35b5e3bdf1d4a7a84d13d976d716c4d to your computer and use it in GitHub Desktop.
Save mathenls/b35b5e3bdf1d4a7a84d13d976d716c4d to your computer and use it in GitHub Desktop.
/*
You are given 2 numbers as strings, and you need to sum them assuming that you can't simply parse them as integers
cause the numbers may be too big to be stored as an integer
Return the sum as a string
*/
function sumStrings(str1, str2) {
// Your code here
}
function test(str1, str2, solution) {
const res = sumStrings(str1, str2)
const isCorrect = res === solution ? "Correct" : "Incorrect"
console.log(`${str1} + ${str2} = ${res} \t=>\t${isCorrect}, expected ${solution}`)
}
test('1', '1', '2')
test('9', '1', '10')
test('999', '2', '1001')
test('10001', '1', '10002')
test('1', '10001', '10002')
test('10009', '10001', '20010')
test('299', '12', '311')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment