题解 | #文件扩展名#
文件扩展名
https://www.nowcoder.com/practice/01ca4c6aa14249c2911f89baba9dc023
思路:使用split()方法将filename以‘.’分割成数组,选取最后一个值(因为扩展名肯定在最后面),但是一定要记得加上'.'!!!
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> </head> <body> <script> const _getExFilename = (filename) => { // 补全代码 return "."+filename.split('.')[filename.split('.').length-1] } </script> </body> </html>