How to do Division in Office Scripts

Karthik Mahendrakumar 1 Reputation point
2021-10-26T14:37:21.413+00:00

Hello Guys. I want to do division in the Office Scripts.

Eg: salary_nl = ( fixed_salary ) / 12

But I am getting error at line 24 as you see in the below image. How to resolve this ?

143780-capture.png

Microsoft Office Online Server
Microsoft Office Online Server
Microsoft on-premises server product that runs Office Online. Previously known as Office Web Apps Server.
690 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,364 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. kinuasa 371 Reputation points
    2021-10-27T07:24:37.44+00:00

    Hi,
    You need to convert it to a number using the parseInt or parseFloat functions, or simply use the Unary plus(+) operator.

    1 person found this answer helpful.
    0 comments No comments

  2. Nancy Wang 116 Reputation points Microsoft Employee
    2021-11-19T21:01:21.683+00:00

    @kinuasa 's suggestion sounds right - another way you may be able to fix this error is by modifying line 23 to read "let fixed_salary = tablevalues[i][11] as number;". This lets the code know to expect a number value for your variable, fixed_salary, so that you can divide it in the next line to calculate salary_nl. I hope this helps!

    Nancy

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.