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
28 changes: 26 additions & 2 deletions src/isolate-duplicates/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
function isolateDuplicates(text) {}
// function isolateDuplicates(text) {
// let count = {}

module.exports = isolateDuplicates;
// text.forEach(isolate)

// function isolate(item){
// console.log(item)
// }

// }


// console.log("aaaabbcdefffffffg")
// module.exports = isolateDuplicates;


//switch between two variables without using a third

let x = 10
let y = 20

x = x + y
y = x - y
x = x - y

console.log(x)
console.log(y)
14 changes: 13 additions & 1 deletion src/morse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ 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");

if (text == "") return "";
let word = "";
let firstWord = "";
text = text.trim();

if (text.includes(" ")) {
text = text.replace(/ /g, "[[]]");
text = text

}

module.exports = morse;
14 changes: 13 additions & 1 deletion src/remove-dulplicates/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
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;