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 ffdfd
• 5,550 points
551 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, 2019 in RPA by Abha
• 28,140 points
8,064 views
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 5, 2020 in RPA by Deny
1,263 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
• 58,020 points
5,703 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
1,306 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
2,015 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
1,883 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
1,608 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
601 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
4,680 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP