Title: #415 - Add Strings - LeetCode JavaScript Solutions
Open Graph Title: #415 - Add Strings - LeetCode JavaScript Solutions
X Title: #415 - Add Strings - LeetCode JavaScript Solutions
Description: Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string. You must solve the proble...
Open Graph Description: Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string. You must solve the proble...
X Description: Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string. You must solve the proble...
Keywords:
Opengraph URL: https://leetcodejavascript.com/solutions/add-strings
Domain: leetcodejavascript.com
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/add-strings","name":"#415 - Add Strings - LeetCode JavaScript Solutions","description":"Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string. You must solve the proble...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {string} num1\n * @param {string} num2\n * @return {string}\n */\nvar addStrings = function(num1, num2) {\n let result = '';\n\n for (let i = num1.length - 1, j = num2.length - 1, carry = 0; i > -1 || j > -1 || carry === 1;) {\n if (i > -1) {\n carry += num1.charCodeAt(i--) - 48;\n }\n if (j > -1) {\n carry += num2.charCodeAt(j--) - 48;\n }\n result = (carry % 10) + result;\n carry = Math.floor(carry / 10);\n }\n\n return result;\n};","keywords":"LeetCode 415, #415 - Add Strings, Easy, JavaScript solution","learningResourceType":"Code","isAccessibleForFree":true,"educationalLevel":"intermediate","interactivityType":"mixed"}
| author | LeetCodeJavascript.com |
| og:type | article |
| og:image | https://leetcodejavascript.com/og-image.jpg |
| og:site_name | LeetCode JavaScript Solutions |
| twitter:card | summary_large_image |
| twitter:url | https://leetcodejavascript.com/solutions/add-strings |
| twitter:image | https://leetcodejavascript.com/og-image.jpg |
| twitter:creator | @joshcrozier |
| theme-color | #1f2937 |
Links:
| LeetCodeJavascript.com | https://leetcodejavascript.com/ |
| Star on GitHub | https://github.com/JoshCrozier/leetcode-javascript |
| Back to all solutions | https://leetcodejavascript.com |
| View on LeetCode | https://leetcode.com/problems/add-strings/ |
| View on GitHub | https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/0415-add-strings.js |
| String | https://leetcodejavascript.com/tags/string |
| Math | https://leetcodejavascript.com/tags/math |
| Simulation | https://leetcodejavascript.com/tags/simulation |
| Josh Crozier | https://joshcrozier.com |
Viewport: width=device-width,initial-scale=1
Robots: index, follow