JSFiddle - React, Tailwind, and code Playground

JavaScript

var s = '999';
var total = '';
var carryTheOne = true;

for(var i = s.length-1; i >= 0; i--)
{
	var intValue = s.charAt(i);
	if(carryTheOne)
	{
		intValue++;
	}
	carryTheOne = intValue == 10;
	if(carryTheOne)
	{
		intValue = 0;
	}
	total = intValue + total;
}

if(carryTheOne) total = '1' + total;

alert(total);