JSFiddle - React, Tailwind, and code Playground

HTML

<form>
  <input type="text" id="addItems" value="" placeholder="separate with commas">
  <input type="submit" value="Add">
</form>

JavaScript

function addItem(e) {	
		e.preventDefault();                         // Prevent form being submitted
		var text = $('input:text').val();           // Get value of text input
		var itemArr = text.split(',');																
		var lngth = itemArr.length					
		
		for(i = 0; i < lngth; i++)					
			{
				$list.append('<li>' + itemArr[i] + '</li>'); 	// Add item to end of the list
				updateCount();									// Update the count
			} // End loop
	
		$('#addItems').val('');                    		// Empty the text input
		return false;
	}
	
	$('#addItems').keypress(function(e) {
		if(e.which == 13) {
        	addItem();
    	}
    	return false;
	});