Skip to content

Instantly share code, notes, and snippets.

View awalmubarak's full-sized avatar

Mubarak Awal awalmubarak

View GitHub Profile
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]==='.'){
//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)
//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)
})