Skip to content

Commit 252a7ae

Browse files
ghoullierGregory Houllier
authored and
Gregory Houllier
committedJan 28, 2021
Use Array destructring to swap variables
Array destructuring is a shorter syntax to swap variables instead of create a `tpm` variable.
1 parent 512539b commit 252a7ae

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed
 

‎mod.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ const myers_x = (b: string, a: string) => {
113113

114114
const distance = (a: string, b: string): number => {
115115
if (a.length < b.length) {
116-
const tmp = b;
117-
b = a;
118-
a = tmp;
116+
[b, a] = [a, b];
119117
}
120118
if (b.length === 0) {
121119
return a.length;

0 commit comments

Comments
 (0)
Please sign in to comment.