Skip to content

Instantly share code, notes, and snippets.

@NhanKhangg98
Created August 28, 2022 09:26
Show Gist options
  • Save NhanKhangg98/fe7c608794b0293822531a606eca453b to your computer and use it in GitHub Desktop.
Save NhanKhangg98/fe7c608794b0293822531a606eca453b to your computer and use it in GitHub Desktop.
const arr = [1, 2, 3, 4, 5, 6];
let rt = 0;
for (let i = 0; i <= arr.length; i++) {
rt += i;
}
console.log(rt)
@QuocCao-dev
Copy link

const arr = [5, 5, 3, 4, 5, 2];
let rt = 0;
for (let i = 0; i < arr.length; i++) {
  console.log(i);
  console.log(arr[i]);
  rt += arr[i];
}

console.log(rt);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment