Typescript Code is not returning any output

0 votes

I am trying to get a string with a number where, if there is a match between the former and later number add it to a sum total, so 55412 will be 5 and 112332 will be 1 + 3 so 4. This is coded in typescript, the problem is my code doesn't output anything.

function uipath(e, arg)
{
  let stringToInt = new StringToInt("5514133");
  stringToInt.charCompareAndSum();
  stringToInt.stringSplit();
  alert (stringToInt.getSumList.toString);
}

class StringToInt
{
  private argumentString : string ;
  private numberArr : Array<string>;
  private sumList : number;

  constructor( arg: string)
  {
    this.argumentString = arg ;
  }

  stringSplit()
  {
    this.numberArr = this.argumentString.split(/(?=.)/u);
  }

  charCompareAndSum()
  {
    for(var i = 0; i < this.numberArr.length -1; i++ )
    {
      if (this.numberArr[i] == this.numberArr[i+1])
      {
        this.sumList = this.sumList + +this.numberArr[i];
      }
    }    
  }

  get getSumList():number
  {
    return this.sumList;
  }
}

The output should be 8.

Jun 27, 2018 in RPA by Atul
• 5,530 points
21 views

1 answer to this question.

0 votes

you need to call your functions:

stringToInt.getSumList.toString

Should be

stringToInt.getSumList().toString()

I'm guessing this prints nothing because

stringToInt.getSumList

Evaluates to the getSumList function itself, then

getSumList.toString

Evaluates to undefined since the function doesn't have a toString property.

answered Jun 27, 2018 by wrecker
• 3,110 points

Related Questions In RPA

0 votes
1 answer

Is there any way to check whether a file exists or not using UiPath?

Hi @Raj, performing this check in UiPath ...READ MORE

answered Mar 20 in RPA by Abha
• 27,180 points
774 views
0 votes
1 answer

What is code segment in Blueprism and how to implement it?

Blue Prism - Code Stage The code stage ...READ MORE

answered Sep 28, 2018 in RPA by Priyaj
• 56,900 points
1,805 views
0 votes
1 answer

Control Tower is not starting in my Work Fusion RPA Express

Even I've faced that issue, you need ...READ MORE

answered Oct 8, 2018 in RPA by Priyaj
• 56,900 points
487 views
0 votes
1 answer

UiPath - Citirx Automation

best way to do that is to ...READ MORE

answered Apr 13, 2018 in RPA by wrecker
• 3,110 points
235 views
0 votes
1 answer

UiPath - Web Scraping

Multiple solutions are listed below: Check your Selector Use ...READ MORE

answered Apr 13, 2018 in RPA by wrecker
• 3,110 points
270 views
0 votes
1 answer

Robot Manager in UiPath

the robot.exe file is located in: C:\Users\USER_ACCOUNT\AppData\Local\UiPath\app-17.1.6523\Ui-Robot.exe Hope it ...READ MORE

answered Apr 17, 2018 in RPA by wrecker
• 3,110 points
455 views
0 votes
1 answer

Automation in Uipath

you can use the Database package for connecting  ...READ MORE

answered Apr 17, 2018 in RPA by wrecker
• 3,110 points
362 views
0 votes
1 answer

Typescript Code is not returning any output, but is running

you need to call your functions: stringToInt.getSumList.toString Should be stringToInt.getSumList().toString() I'm ...READ MORE

answered May 24, 2018 in RPA by wrecker
• 3,110 points
23 views
+3 votes
5 answers

Is there any open source tools for RPA?

Not quite open source, but free nonetheless. ...READ MORE

answered Aug 28, 2018 in RPA by wrecker
• 3,110 points
1,629 views