문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top