Add Binary is an example of string problems. In this post we will see how we can solve it in Javascript.

Problem Description

Given two binary strings, return their sum (also a binary string). The input strings are both non-empty and contains only characters 1 or 0.

Example 1:

Input: s1 = "11", s2 = "1"
Output: "100"

Example 2:

Input: s1 = "1010", s2 = "1011"
Output: "10101"

Solution: Please check the main.js snippet for the solution. If you have different approach in mind or have any suggestion for this implementation feel free to share in the comment below. Thanks!

Originally posted at: