Skip to content

Commit db8d8a9

Browse files
committed
Updated JavaScript code of for (let of to for (const of.
1 parent a677174 commit db8d8a9

12 files changed

+30
-30
lines changed

en/1-1000/202-happy-number.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Difficulty: **Easy**
4949
```javascript
5050
let sum = 0
5151

52-
for (let digit of n.toString()) {
52+
for (const digit of n.toString()) {
5353
sum += Math.pow(Number(digit), 2)
5454
}
5555

@@ -64,7 +64,7 @@ var isHappy = function (n, appearedNums) { // 0
6464
appearedNums ||= new Set() // 1
6565
let sum = 0
6666

67-
for (let digit of n.toString()) {
67+
for (const digit of n.toString()) {
6868
sum += Math.pow(Number(digit), 2)
6969
}
7070

@@ -144,7 +144,7 @@ var isHappy = function (n, appearedNums) {
144144
appearedNums ||= new Set()
145145
let sum = 0
146146

147-
for (let digit of n.toString()) {
147+
for (const digit of n.toString()) {
148148
sum += Math.pow(Number(digit), 2)
149149
}
150150

@@ -258,7 +258,7 @@ public class Solution
258258
```javascript
259259
let sum = 0
260260

261-
for (let digit of n.toString()) {
261+
for (const digit of n.toString()) {
262262
sum += Math.pow(Number(digit), 2)
263263
}
264264

@@ -273,7 +273,7 @@ var isHappy = function (n, appearedNums) {
273273
appearedNums ||= new Set() // 1
274274
let sum = 0
275275

276-
for (let digit of n.toString()) {
276+
for (const digit of n.toString()) {
277277
sum += Math.pow(Number(digit), 2)
278278
}
279279

en/1-1000/242-valid-anagram.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ var isAnagram = function (s, t) {
9494
const sCharToCount = new Map()
9595
const tCharToCount = new Map()
9696

97-
for (let char of s) {
97+
for (const char of s) {
9898
sCharToCount.set(char, (sCharToCount.get(char) || 0) + 1)
9999
}
100100

101-
for (let char of t) {
101+
for (const char of t) {
102102
tCharToCount.set(char, (tCharToCount.get(char) || 0) + 1)
103103
}
104104

en/1-1000/349-intersection-of-two-arrays.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ var intersection = function (nums1, nums2) {
9696
let results = new Set()
9797
let num1Set = new Set(nums1)
9898

99-
for (let num of nums2) {
99+
for (const num of nums2) {
100100
if (num1Set.has(num)) {
101101
results.add(num)
102102
}

en/1-1000/383-ransom-note.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ class Solution:
123123
var canConstruct = function (ransomNote, magazine) {
124124
const charToCount = new Map()
125125

126-
for (let character of magazine) {
126+
for (const character of magazine) {
127127
charToCount.set(character, (charToCount.get(character) || 0) + 1)
128128
}
129129

130-
for (let character of ransomNote) {
130+
for (const character of ransomNote) {
131131
charToCount.set(character, (charToCount.get(character) || 0) - 1)
132132

133133
if (charToCount.get(character) < 0) {

en/1-1000/454-4sum-ii.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,16 @@ class Solution:
128128
var fourSumCount = function (nums1, nums2, nums3, nums4) {
129129
const numToCount = new Map()
130130

131-
for (let num1 of nums1) {
132-
for (let num2 of nums2) {
131+
for (const num1 of nums1) {
132+
for (const num2 of nums2) {
133133
numToCount.set(num1 + num2, (numToCount.get(num1 + num2) || 0) + 1)
134134
}
135135
}
136136

137137
let result = 0
138138

139-
for (let num3 of nums3) {
140-
for (let num4 of nums4) {
139+
for (const num3 of nums3) {
140+
for (const num4 of nums4) {
141141
result += numToCount.get(-(num3 + num4)) || 0
142142
}
143143
}

en/1001-2000/1971-find-if-path-exists-in-graph-2.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ var validPath = function (n, edges, source, destination) {
236236
parent.push(i)
237237
}
238238
239-
for (let [a, b] of edges) {
239+
for (const [a, b] of edges) {
240240
unite(a, b)
241241
}
242242

zh/1-1000/202-happy-number.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Difficulty: **Easy**
4949
```javascript
5050
let sum = 0
5151

52-
for (let digit of n.toString()) {
52+
for (const digit of n.toString()) {
5353
sum += Math.pow(Number(digit), 2)
5454
}
5555

@@ -64,7 +64,7 @@ var isHappy = function (n, appearedNums) { // 0
6464
appearedNums ||= new Set() // 1
6565
let sum = 0
6666

67-
for (let digit of n.toString()) {
67+
for (const digit of n.toString()) {
6868
sum += Math.pow(Number(digit), 2)
6969
}
7070

@@ -144,7 +144,7 @@ var isHappy = function (n, appearedNums) {
144144
appearedNums ||= new Set()
145145
let sum = 0
146146

147-
for (let digit of n.toString()) {
147+
for (const digit of n.toString()) {
148148
sum += Math.pow(Number(digit), 2)
149149
}
150150

@@ -258,7 +258,7 @@ public class Solution
258258
```javascript
259259
let sum = 0
260260

261-
for (let digit of n.toString()) {
261+
for (const digit of n.toString()) {
262262
sum += Math.pow(Number(digit), 2)
263263
}
264264

@@ -273,7 +273,7 @@ var isHappy = function (n, appearedNums) {
273273
appearedNums ||= new Set() // 1
274274
let sum = 0
275275

276-
for (let digit of n.toString()) {
276+
for (const digit of n.toString()) {
277277
sum += Math.pow(Number(digit), 2)
278278
}
279279

zh/1-1000/242-valid-anagram.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ var isAnagram = function (s, t) {
9494
const sCharToCount = new Map()
9595
const tCharToCount = new Map()
9696

97-
for (let char of s) {
97+
for (const char of s) {
9898
sCharToCount.set(char, (sCharToCount.get(char) || 0) + 1)
9999
}
100100

101-
for (let char of t) {
101+
for (const char of t) {
102102
tCharToCount.set(char, (tCharToCount.get(char) || 0) + 1)
103103
}
104104

zh/1-1000/349-intersection-of-two-arrays.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ var intersection = function (nums1, nums2) {
9696
let results = new Set()
9797
let num1Set = new Set(nums1)
9898

99-
for (let num of nums2) {
99+
for (const num of nums2) {
100100
if (num1Set.has(num)) {
101101
results.add(num)
102102
}

zh/1-1000/383-ransom-note.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ class Solution:
123123
var canConstruct = function (ransomNote, magazine) {
124124
const charToCount = new Map()
125125

126-
for (let character of magazine) {
126+
for (const character of magazine) {
127127
charToCount.set(character, (charToCount.get(character) || 0) + 1)
128128
}
129129

130-
for (let character of ransomNote) {
130+
for (const character of ransomNote) {
131131
charToCount.set(character, (charToCount.get(character) || 0) - 1)
132132

133133
if (charToCount.get(character) < 0) {

zh/1-1000/454-4sum-ii.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,16 @@ class Solution:
128128
var fourSumCount = function (nums1, nums2, nums3, nums4) {
129129
const numToCount = new Map()
130130

131-
for (let num1 of nums1) {
132-
for (let num2 of nums2) {
131+
for (const num1 of nums1) {
132+
for (const num2 of nums2) {
133133
numToCount.set(num1 + num2, (numToCount.get(num1 + num2) || 0) + 1)
134134
}
135135
}
136136

137137
let result = 0
138138

139-
for (let num3 of nums3) {
140-
for (let num4 of nums4) {
139+
for (const num3 of nums3) {
140+
for (const num4 of nums4) {
141141
result += numToCount.get(-(num3 + num4)) || 0
142142
}
143143
}

zh/1001-2000/1971-find-if-path-exists-in-graph-2.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ var validPath = function (n, edges, source, destination) {
236236
parent.push(i)
237237
}
238238
239-
for (let [a, b] of edges) {
239+
for (const [a, b] of edges) {
240240
unite(a, b)
241241
}
242242

0 commit comments

Comments
 (0)