JavaScript: Column number that relates to a column title
JavaScript Math: Exercise-98 with Solution
Excel Column Number from Title
Write a JavaScript program to get the column number (integer value) related to a column title as it appears in an Excel sheet.
For example:
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
...
Visual Presentation:

Test Data:
("C") -> 3
("AD") -> 30
("ZX") -> 700
Sample Solution-1:
JavaScript Code:
Output:
Original text: C Excel column title related with the said column number: 3 Original text: AD Excel column title related with the said column number: 30 Original text: ZX Excel column title related with the said column number: 700
Flowchart:

Live Demo:
Sample Solution-2:
JavaScript Code:
Output:
Original text: C Excel column title related with the said column number: 3 Original text: AD Excel column title related with the said column number: 30 Original text: ZX Excel column title related with the said column number: 700
Flowchart:

Live Demo:
For more Practice: Solve these Related Problems:
- Write a JavaScript function that converts an Excel column title to its corresponding number by processing each letter's value.
- Write a JavaScript function that iterates through the characters of a column title and computes the numeric value using base-26 arithmetic.
- Write a JavaScript function that validates the input title and handles both uppercase and lowercase letters.
- Write a JavaScript function that returns the Excel column number and manages edge cases such as invalid characters.
Improve this sample solution and post your code through Disqus.
Previous: Excel column title related with a column number.
Next: Add digits until there is only one digit.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.