Question

Edited for clarification:

function Num(str) { 
  return str;
}

which returns when the input is 2^15

13

I want to know how I can keep it from evaluating str and just return 2^15 instead of returning 13.

Was it helpful?

Solution

var string = "2^15"; // wrap in double quotes to treat it as a string

As a sidenote, avoid calling your variables 'string', since it is a reserved keyword in a lot of languages and reduces readability.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top