Page:
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Big Data Addition</title></Head><Body><H3style= "margin-left:800px;margin-top:200px;">I'm the big Data add</H3></Body></HTML>
Js:
' Use strict '; import Base from'./base.js ';varFS = require (' FS '); Exportdefaultclass extends Base {/** * Index action * @return {Promise} []*/Async indexaction () {//Let RootPath = think. Root_path + "\\www\\"; Let Num1= await Fs.readfilesync (rootpath + "3.txt");//synchronized version of Fs.readfile () fs.readfilesync (filename, [encoding]) filename--> file pathLet num2 = await Fs.readfilesync (rootpath + "4.txt"); Let Sum=MySum (NUM1, num2); //Write FileFs.writefile (RootPath + "Sum.txt", Sum, ' UTF8 ', (err) = = { if(ERR)Throwerr; Console.log (' The calculation results are saved successfully! ‘); }); return This. display (); }}/** * Sum method * @param num1 * @param num2 * @returns {string}*/functionMySum (NUM1, num2) {Let sum= ' '; Let Jin= 0; for(Let i = num1.length-1; I >= 0; i--) {Let stmp= (Num1[i] + num2[i]-96); if(i==0) {sum= (Stmp + Jin) +sum; } Else{sum= ((Stmp + Jin)% 10) +sum; } Jin= parseint (STMP/10); } returnsum;}
Big Data Addition