web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Adding two integers to...
Power Pages
Answered

Adding two integers together - surely it's not that hard!

(0) ShareShare
ReportReport
Posted on by 7

I need to add two integers together in JavaScript - no matter what I do, I just can't seem to get anything to work. I started with

var varC = $('#varA').val() + $('#varB').val();

This just concatenated them. I then found out that adding .val() returns a string so that would explain it.I tried removing the '.val()' but it didn't return anything. I've tried replacing the 'var' with 'let' but, again, no joy.

I've tried looking for some sort of function that would return what I want but I can't find anything. Can anyone please tell me how I can do this?

 
 
Categories:
I have the same question (0)
  • Verified answer
    Fubar Profile Picture
    8,505 Super User 2026 Season 1 on at

    If its returning a string you need to convert it to a number in JavaScript 

    var x = Number("1") + Number("2");

    Note: defining variables via "let" just affects the variable scope not its type.

  • JonEvans Profile Picture
    7 on at

    That's worked brilliantly, thank you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
11manish Profile Picture

11manish 50

#1
11manish Profile Picture

11manish 50

#3
Valantis Profile Picture

Valantis 26

Last 30 days Overall leaderboard