Short version: Yes, yes you can.
You don’t need str2. You can assign the changes to your str variable (str = str.slice(0,i) + "-" +str.slice(i)). Since your str variable will get longer when that happens, and since you need to make sure you skip your newly created -, you’ll want to increase your iterator variable (i) by 1 if you add a dash. Then you can just return str.