UNPKG

d.ibrohim

Version:

test uchun

38 lines (30 loc) 978 B
import { log } from 'console'; import { readFile, writeFile } from 'fs/promises'; const data = await readFile( new URL('data.txt', import.meta.url), 'utf-8' ).catch(e => { console.log('meni errorim :' + e); }); let harflar = ''; let sonlar = ''; for (let char of data) { if(!isNaN(char)) { sonlar += char; } else { harflar += char; } } await writeFile(new URL('harflar.txt',import.meta.url), harflar); await writeFile(new URL('raqamlar.txt',import.meta.url), sonlar); template = template.replace('{title}', 'Qiziqishlarim'); template = template.replace('{body}', 'Football,War Thunder'); await writeFile(new URL('yangi.html',import.meta.url), template); let text = await readFile(new URL('data.txt', import.meta.url), 'utf-8'); let sum = 0; for (let char of text) { if(!isNaN(char)){ sum += Number(char); } } await writeFile(new URL('result.txt',import.meta.url), String(sum));