Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updatad the logic of Anagram.js #330

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
15 changes: 14 additions & 1 deletion 01-js/easy/anagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 result = isAnagram("hello","olleh");
console.log(result);

module.exports = isAnagram;
// module.exports = isAnagram;
17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}