This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var defangIPaddr = function(address) { | |
let addressArray = address.split(''); | |
return addressArray.map((i)=>i=='.'?'[.]':i).join('') | |
}; | |
var defangIPaddr = function(address) { | |
let newAdd = ""; | |
for(let i = 0; i<address.length; i++){ | |
if(address[i]==='.'){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SOLUTION 1 | |
var runningSum = function(nums) { | |
//this line checks to make sure we're not working with an empty array and returns if nums is empty | |
if(nums.length==0) return []; | |
//we then create an array to hold our output. I called mine sumArray | |
const sumArray = []; | |
//We start by getting the first item in our array since we're sure the array is not empty. | |
let currentSum = nums[0]; | |
//The first item will always remain the same for all solutions so we add it as the first item of our output array sumArray | |
sumArray.push(currentSum) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Instead of passing a callback like we're doing below, showSaveDialog now returns a promise | |
//Electron 6 - 8 | |
dialog.showSaveDialog(mainWindow, | |
{defaultPath:'filename.txt'}, (filepath)=>{ | |
currentPath=filepath | |
if(filepath===undefined)return | |
writeToFile(filepath, data) | |
}) | |