diff --git a/Assignment/Assignment-2/p1.js b/Assignment/Assignment-2/p1.js index 7df2c13..d962a4f 100644 --- a/Assignment/Assignment-2/p1.js +++ b/Assignment/Assignment-2/p1.js @@ -22,5 +22,10 @@ Output: Even function evenOrOdd(num) { // Your code here + if (num % 2 == 0){ + return "Even"; + } else { + return "Odd"; + } } module.exports = evenOrOdd; \ No newline at end of file diff --git a/Assignment/Assignment-2/p2.js b/Assignment/Assignment-2/p2.js index 0d4e442..215321b 100644 --- a/Assignment/Assignment-2/p2.js +++ b/Assignment/Assignment-2/p2.js @@ -19,5 +19,6 @@ Output: "tneduts a ma I" function reverseString(str) { // Your code here + return str.split("").reverse().join(""); } module.exports = reverseString; \ No newline at end of file diff --git a/Assignment/Assignment-2/p3.js b/Assignment/Assignment-2/p3.js index 79ed397..0db0c2f 100644 --- a/Assignment/Assignment-2/p3.js +++ b/Assignment/Assignment-2/p3.js @@ -19,5 +19,7 @@ Output: ["Short", "Longer", "Longest"] function sortByLength(arr) { // Your code here + let sorted = arr.sort((a,b) => a.length - b.length); + return sorted; } module.exports = sortByLength; \ No newline at end of file