---
# System prepended metadata

title: Untitled

---



calc("1+1") == 2
calc("2-1+5") == 6
calc("0-2-3-5") == -10
calc("1+10") == 11
calc("5-1") == 4

function calc(str: string) {
    let final = 0;
    
    numberArray = string[];
    operatorArray = string[];
    const numberString = '';
    
    
    
    str.map((c: string) => {
       if (c === '+') {
       } (c === '-') {
       } else {
           numberString = `;`
      }
   });
   if (operator === '+') {
       final = numberBefore + numberAfter;
   } if (operator === '-') {
       final = numberBefore - numberAfter;
   } 
   return final;
} 

calc("2-1+5") == 6

    numberArray = ('2','1','5')
    operatorArray = ('-','+');
    
    final = numberArray[0] operatorArray[0] numberArray[1] operatorArray[1] numberArray[2]
    
    2 - 1 + 5

