validstring-asmit33 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/isValidString.js +40 -0
  2. package/package.json +11 -0
@@ -0,0 +1,40 @@
1
+ function processData(data) {
2
+ const validCodes = [];
3
+ let invalidCount = 0;
4
+
5
+ for (const code of data) {
6
+ if (isValidCode(code)) {
7
+ validCodes.push(code);
8
+ } else {
9
+ invalidCount++;
10
+ }
11
+ }
12
+
13
+ function isValidCode(code) {
14
+ if (code.length !== 7) return false;
15
+
16
+ for (let i = 0; i < 3; i++) {
17
+ const char = code[i];
18
+ if (char < "A" || char > "Z") return false;
19
+ }
20
+
21
+ for (let i = 3; i < 7; i++) {
22
+ const char = code[i];
23
+ if (char < "0" || char > "9") return false;
24
+ }
25
+
26
+ return true;
27
+ }
28
+
29
+ // Sort valid codes alphabetically
30
+ validCodes.sort();
31
+
32
+ return {
33
+ totalCodes: data.length,
34
+ validCodes: validCodes.length,
35
+ invalidCodes: invalidCount,
36
+ normalizedValidCodes: validCodes,
37
+ };
38
+ }
39
+
40
+ module.exports = { processData };
package/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "validstring-asmit33",
3
+ "version": "1.0.0",
4
+ "main": "isValidString.js",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1"
7
+ },
8
+ "author": "",
9
+ "license": "ISC",
10
+ "description": ""
11
+ }