<Script>
"use strict";
//dollorsign iin hexa = "\u0024"
function extractCurrencyValue (str){
let target = "\u0024";
let pos = -1;
while ( (pos = str.indexOf(target, pos + 1)) != -1 ){
// alert(pos);
if(pos == 0){
return (+str.slice(1));
}
else {
return (+str.substring(str.length - 1, 0) );
}
}
}
alert(extractCurrencyValue('120$') === 120);
</Script>
"use strict";
//dollorsign iin hexa = "\u0024"
function extractCurrencyValue (str){
let target = "\u0024";
let pos = -1;
while ( (pos = str.indexOf(target, pos + 1)) != -1 ){
// alert(pos);
if(pos == 0){
return (+str.slice(1));
}
else {
return (+str.substring(str.length - 1, 0) );
}
}
}
alert(extractCurrencyValue('120$') === 120);
</Script>
댓글
댓글 쓰기