Typescript Code is not returning any output but is running

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.

May 24, 2018 in RPA by Atul
• 5,550 points
90 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 May 24, 2018 by wrecker
• 3,110 points

Related Questions In RPA

0 votes
1 answer

I want to automate pdf but selectors are not working properly is there any other way to automate?

UiPath cannot identify the object inside pdf! Try ...READ MORE

answered Nov 4, 2020 in RPA by Deny
91 views
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, 2019 in RPA by Abha
• 28,000 points
4,241 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
512 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
716 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
855 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
742 views
0 votes
1 answer

Typescript Code is not returning any output

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

answered Jun 27, 2018 in RPA by wrecker
• 3,110 points
75 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
2,338 views