diff --git a/append-array.js b/append-array.js new file mode 100644 index 0000000..ce77fbd --- /dev/null +++ b/append-array.js @@ -0,0 +1,12 @@ +// Append array of strings on value + +const appendValues = (value, appends) => { + if (appends.length === 0) { + return value + } + return value + appends.join('') +}; + +text = appendValues('A', ['m', 'azi', 'ng']); + +console.log(text); // Amazing diff --git a/sort-peoples.js b/sort-peoples.js new file mode 100644 index 0000000..38a7894 --- /dev/null +++ b/sort-peoples.js @@ -0,0 +1,18 @@ +const peoples = [ + { name: 'Paulo', age: 19 }, + { name: 'Hannah', age: 26 }, + { name: 'Lucio', age: 32 }, + { name: 'Waldo', age: 73 }, + { name: 'Larissa', age: 22 }, + { name: 'Brucer', age: 15 } +]; + +const sortNames = peoples.sort((a, b) => { + const firstName = a.name.toLowerCase(); + const secondName = b.name.toLowerCase(); + if (firstName < secondName) return -1 + if (firstName > secondName) return 1 + return 0 +}) + +console.log(sortNames);