Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/isolate-duplicates/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
function isolateDuplicates(text) {}
function isolateDuplicates(text) {

if (typeof (text) !== "string") {
throw new Error('Please enter a valid string')
}

let finalStr = ''
let count = 0
let newText = text.toLowerCase()
for (let j = 0; j < text.length; j++) {
finalStr += text[j]

if (newText[j] === newText[j - 1] && newText[j] === newText[j + 1] && newText[j] !== newText[j - 2]) {
finalStr += '['
count += 0.5
}

if (newText[j] === newText[j - 1] && newText[j] !== newText[j + 1] && newText[j] === newText[j - 2]) {
finalStr += ']'
count += 0.5
}
}
return [finalStr, count]
}

module.exports = isolateDuplicates;
12 changes: 10 additions & 2 deletions src/morse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ const MORSE_CODE = {

Object.freeze(MORSE_CODE);

function morse(text) {}

function morse(text) {
if (typeof text != 'string') {
throw new Error('Please provide a morse string')
} else {
text = text.trim().split(' ');
let translatedCode;
translatedCode = text.map(a => a.split(' ').map(b => MORSE_CODE[b]).join('')).join(' ')
return translatedCode;
}
}
module.exports = morse;
27 changes: 26 additions & 1 deletion src/remove-dulplicates/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
function removeDuplicates(obj) {}
function removeDuplicates(obj) {
let arr = Object.entries(obj)
let newArr
let keysArr = []
let valuesArr = []
let c = []
let diff = (a, b) => [...new Set([...a].filter((x) => !b.includes(x)))];

for (let index = 0; index < arr.length; index++) {
keysArr.push(arr[index][0])
newArr = [...new Set(arr[index][1])]
valuesArr.push(newArr)
}
let finalArr = valuesArr.reverse().map((value) => {
const subCollector = c;
c = [...new Set([...c, ...value])];
return [...new Set(diff(value, subCollector))]
})
finalArr = finalArr.reverse()
const newObj = {}
keysArr.forEach((element, index) => {
let newElement = element
newObj[newElement] = finalArr[index]
})
return newObj
}

module.exports = removeDuplicates;
18 changes: 9 additions & 9 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Language and Environment */
"target": "es2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "es2020" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
Expand All @@ -25,7 +25,7 @@
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */

/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
"module": "commonjs" /* Specify what module code is generated. */,
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
Expand All @@ -39,19 +39,19 @@
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */

/* JavaScript Support */
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
"allowJs": true /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */,
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */

/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
"sourceMap": true /* Create source map files for emitted JavaScript files. */,
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
"noEmit": true, /* Disable emitting files from a compilation. */
"noEmit": true /* Disable emitting files from a compilation. */,
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
Expand All @@ -71,12 +71,12 @@
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,

/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
Expand All @@ -98,6 +98,6 @@

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}