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
Binary file added .DS_Store
Binary file not shown.
Binary file added src/.DS_Store
Binary file not shown.
30 changes: 29 additions & 1 deletion src/isolate-duplicates/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
function isolateDuplicates(text) {}
function isolateDuplicates(text) {
function isolateDuplicates(text) {

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

let lowerText = text.toLowerCase()

let newString = ""
let count = 0

for (let i = 0; i < text.length; i++) {
newString += text[i]

if (lowerText[i] === lowerText[i - 1] && lowerText[i] === lowerText[i + 1] && lowerText[i] !== lowerText[i - 2]) {
newString += '['
count++
}

if (lowerText[i] === lowerText[i - 1] && lowerText[i] !== lowerText[i + 1] && lowerText[i] === lowerText[i - 2] ) {
newString += ']'
}
}
return [newString, count]
}

console.log(isolateDuplicates("aaAabbcdefffffffg"))
}

module.exports = isolateDuplicates;
16 changes: 15 additions & 1 deletion src/morse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,21 @@ const MORSE_CODE = {
};

Object.freeze(MORSE_CODE);

function morse(text) {
let _morseArr = text.trim().split(" ");
let _arrOfDecodedWords = _morseArr.map((item) => {
let getMorseCodeFromItem = item.split(" ");

function morse(text) {}
let getWordsFromItemArray = getMorseCodeFromItem.map((value) => {

let decodedLetter = MORSE_CODE[VALUE];
return decodedLetter;
})
return getWordsFromItemArray.join("")
})
return _arrOfDecodedWords.join (" ");
}

console.log(morse(",-"))
module.exports = morse;
15 changes: 14 additions & 1 deletion src/remove-dulplicates/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
function removeDuplicates(obj) {}
function removeDuplicates(obj) {
function removeDuplicates(obj) {
let n = [];

let rep = (a, b) => [...new Set([...a].filter( x => !b.includes(x)))];

return Object.entries(obj).reverse().map(element => {
const aux = n;
n = [...new Set([...n, ...element[1]])];

return [element[0], [...new Set(rep(element[1], aux))]];
}).reduce((arrays, array) => ((arrays[array[0]] = array[1]), arrays), {});
}
}

module.exports = removeDuplicates;