From 88f64ac950e9d7250fa35296db91d670926085ef Mon Sep 17 00:00:00 2001 From: Henil Malaviya Date: Mon, 19 Aug 2024 16:38:48 +0530 Subject: [PATCH] feat: implement w2ascii function --- src/index.ts | 1 + src/w2ascii.ts | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 4dad8f3..b42889c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1,2 @@ export { not } from './not'; +export { w2ascii } from './w2ascii'; diff --git a/src/w2ascii.ts b/src/w2ascii.ts index 63ce678..69fe9cb 100644 --- a/src/w2ascii.ts +++ b/src/w2ascii.ts @@ -1 +1,7 @@ -// Waiting for henil0604 to implement this 😃! +export function w2ascii(str: string): number { + let sum = 0; + for (let i = 0; i < str.length && str[i] !== ' '; i++) { + sum += str.charCodeAt(i); + } + return sum; +}