Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to convert a string to a mathematical expression programmatically javascript

function addbits(s) {
  var total = 0,
      s = s.match(/[+-]*(.d+|d+(.d+)?)/g) || [];
      
  while (s.length) {
    total += parseFloat(s.shift());
  }
  return total;
}

var string = '1+23+4+5-30';
console.log(
  addbits(string)
)
Comment

PREVIOUS NEXT
Code Example
Javascript :: propertyName nuxt auth 
Javascript :: url encoded body in node.js 
Javascript :: download pdf javascript 
Javascript :: javascript remove from array 
Javascript :: js detect all images errors 
Javascript :: buildpack for nodejs 
Javascript :: js create md5 hash 
Javascript :: how to read files in node 
Javascript :: js delete cookie by name 
Javascript :: how to change input value in javascript using class 
Javascript :: add multiple elements to set javascript 
Javascript :: remove javascript 
Javascript :: js sort int array 
Javascript :: how to send the mail using node with template 
Javascript :: get location from brwoser react 
Javascript :: how to import pdfmake/build/pdfmake.min in react 
Javascript :: for loop java script 
Javascript :: different uniqid usage 
Javascript :: comentário jsx 
Javascript :: how to check the number is palindrome or not 
Javascript :: delete element from array js 
Javascript :: node.js brotli 
Javascript :: if array ontains any item of another array js 
Javascript :: javascript json trypass 
Javascript :: ticking clock react js 
Javascript :: conditional onclick react 
Javascript :: ckeditor config 
Javascript :: distinguishing positive numbers in javascript 
Javascript :: mui react outlined input helperText 
Javascript :: express js sample project 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =