-
-
Save spddl/086d83909a7b2ab45ce194fd4eb4b106 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 a = [1, 2, 3, 4, 5, 6, 7] | |
var b = ['a', 'b', 'c'] | |
al = a.length | |
bl = b.length | |
console.log(al, bl) // 7 3 | |
if (al < bl) { | |
for (let i = 0, len = (bl - al); i < len; i++) { | |
a.push('') | |
} | |
} else if (al > bl) { | |
for (let i = 0, len = (al - bl); i < len; i++) { | |
b.push('') | |
} | |
} | |
console.log(a) // [1, 2, 3, 4, 5, 6, 7] | |
console.log(b) // ["a", "b", "c", "", "", "", ""] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment