javascript - Using replace() on decoded URI hex codes with native division operator -


building calculator.

var process = "6÷6";  // need replace division sign 1 javascript can evaluate process = encodeuri(process); process.replace(/%c3%b7/gi,'/'); // replacement step doesn't work - %c3%b7 shows hex divison sign in chrome debugger, not sure why process = decodeuri(process); result = eval(process); 

the third line of code wrong. have assign return value of replace function variable. easiest way assign itself:

process = process.replace(/%c3%b7/gi,'/'); 

so whole script code this:

var process = "6÷6";  // need replace division sign 1 javascript can evaluate process = encodeuri(process); process = process.replace(/%c3%b7/gi,'/'); // replacement step works process = decodeuri(process); result = eval(process); 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -