JSFiddle - React, Tailwind, and code Playground

JavaScript

var str = ['(','C','1','2','3','4','*',')']; // Your Input
var temp = [],count = 0;

for(var i=0;i<str.length;i++)
{
   if(i<str.indexOf('C') + 2)
   {
      temp[count] = str[i];
      count++;
   }
   else
   {
      if(isNaN(str[i]) == true)
      {
        temp[count] = str[i];
        count++;
      }      
   }
 }
str = temp;
alert(str);