Advertisement
kstoyanov

03. Extract File

Jul 17th, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(str) {
  2.   const words = str.split('\\');
  3.   const fileStr = words.pop();
  4.  
  5.   const name = fileStr.substr(0, fileStr.lastIndexOf('.'));
  6.   const extension = fileStr.slice(fileStr.lastIndexOf('.') + 1);
  7.  
  8.   console.log(`File name: ${name}`);
  9.   console.log(`File extension: ${extension}`);
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement