How do i rename a file in JavaScript

So I’m trying to make something where you can edit text files. The problem is sometimes I’m having problems in the user uploads a js file.

So lets say this is my file,

const myFile = new File([':)'], 'my-file.js');

Notice how the file I just made is a JavaScript file. I want to rename it so the exact same file is my-file.txt. Please help!