@@ -11,12 +11,12 @@ function chemEval(formula) {
1111 const element = / [ A - Z ] [ a - z ] { 0 , 2 } /
1212 const numberAfterElement = / \d + $ /
1313 let molec = { }
14- chemArray = formula . match ( / [ A - Z ] [ a - z ] * \d * / g)
14+ const chemArray = formula . match ( / [ A - Z ] [ a - z ] * \d * / g)
1515 chemArray . forEach ( x => {
16- ele = x . match ( element ) [ 0 ]
17- elemNumMatch = x . match ( numberAfterElement )
18- atoms = elemNumMatch ? parseInt ( elemNumMatch [ 0 ] ) : 1
19- elem = { }
16+ const ele = x . match ( element ) [ 0 ]
17+ const elemNumMatch = x . match ( numberAfterElement )
18+ const atoms = elemNumMatch ? parseInt ( elemNumMatch [ 0 ] ) : 1
19+ const elem = { }
2020 elem [ ele ] = atoms
2121 molec = addMolecules ( molec , elem , 1 )
2222 } )
@@ -44,7 +44,7 @@ function MM(formula) {
4444 let total = null
4545 let numMatch = null
4646
47- formula = formula . replace ( / \s / g, '' ) ;
47+ const formula = formula . replace ( / \s / g, '' ) ;
4848 chemArray . forEach ( x => {
4949 if ( simpleFormula . test ( x ) ) {
5050 elmass [ level ] = addMolecules ( elmass [ level ] , chemEval ( x ) , 1 )
@@ -67,12 +67,12 @@ function MM(formula) {
6767
6868 let molecularMass = { }
6969
70- for ( [ ele , atoms ] of Object . entries ( elmass [ 0 ] ) ) {
70+ for ( let [ ele , atoms ] of Object . entries ( elmass [ 0 ] ) ) {
7171 molecularMass [ ele ] = math . unit ( atom [ ele ] * atoms , 'g/mol' )
7272 total = total ? math . add ( total , molecularMass [ ele ] ) : molecularMass [ ele ]
7373 }
7474 let fraction = { }
75- for ( [ ele , atoms ] of Object . entries ( elmass [ 0 ] ) ) {
75+ for ( let [ ele , atoms ] of Object . entries ( elmass [ 0 ] ) ) {
7676 fraction [ ele ] = math . divide ( molecularMass [ ele ] , total )
7777 }
7878
0 commit comments