From bf524fed18881fb42cce4807dd0b36f74f222a84 Mon Sep 17 00:00:00 2001 From: Murali Date: Sun, 28 Apr 2024 10:26:40 +0530 Subject: [PATCH 1/2] Added the anagram.js --- 01-js/easy/anagram.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/01-js/easy/anagram.js b/01-js/easy/anagram.js index fff61427..3469ff10 100644 --- a/01-js/easy/anagram.js +++ b/01-js/easy/anagram.js @@ -8,7 +8,20 @@ */ function isAnagram(str1, str2) { + var str_1 = str1.split("").sort().join(""); + var str_2 = str2.split("").sort().join(""); + + if(str_1 == str_2) + { + return true; + } + else{ + return false; + } + } +var res = isAnagram("hello","olleh"); +console.log(res); -module.exports = isAnagram; +// module.exports = isAnagram; From b0a382857cdb704d3db21dcdfe0286091038d177 Mon Sep 17 00:00:00 2001 From: Murali Date: Sun, 28 Apr 2024 10:30:18 +0530 Subject: [PATCH 2/2] Added package.json for Anagram scripts and updated the logic of anagram.js --- 01-js/easy/anagram.js | 4 ++-- package.json | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 package.json diff --git a/01-js/easy/anagram.js b/01-js/easy/anagram.js index 3469ff10..222155f2 100644 --- a/01-js/easy/anagram.js +++ b/01-js/easy/anagram.js @@ -21,7 +21,7 @@ function isAnagram(str1, str2) { } -var res = isAnagram("hello","olleh"); -console.log(res); +var result = isAnagram("hello","olleh"); +console.log(result); // module.exports = isAnagram; diff --git a/package.json b/package.json new file mode 100644 index 00000000..17b8c172 --- /dev/null +++ b/package.json @@ -0,0 +1,17 @@ +{ + "name": "week-1-assignment", + "version": "1.0.0", + "description": "- The project contains easy, medium and hard assigments for week 1.\r - 01-js contains assignments related to JavaScript, things that were covered in the first class.\r - 02-async-js contains assignments related to asynchronous JavaScript, things that were covered in the second class.\r - If you have any query then ping us on the Discord server.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "anagram": "node 01-js/easy/anagram.js" + }, + + "keywords": [], + "author": "", + "license": "ISC" +} + + + \ No newline at end of file