Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(str) {
- const words = str.split('\\');
- const fileStr = words.pop();
- const name = fileStr.substr(0, fileStr.lastIndexOf('.'));
- const extension = fileStr.slice(fileStr.lastIndexOf('.') + 1);
- console.log(`File name: ${name}`);
- console.log(`File extension: ${extension}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement