Skip to content

Instantly share code, notes, and snippets.

@naufaldi
Created March 29, 2021 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naufaldi/2eb6caef5e81a05597ee97e5eda1ec83 to your computer and use it in GitHub Desktop.
Save naufaldi/2eb6caef5e81a05597ee97e5eda1ec83 to your computer and use it in GitHub Desktop.
Array
let angka = 641573;
let angkaString = angka.toString();
let angkaArray = Array.from(angkaString);
let tempArray = [];
for (let i = 0; i < angkaArray.length; i++) {
console.log('Angka Join ', angkaArray[i] + angkaArray[i + 1]);
let tempAngka = angkaArray[i] + angkaArray[i + 1];
tempArray.push(tempAngka);
console.log('temp array ', tempArray);
}
//1. convert number to string so that it can be looped
//2. ?? how to compare between each iteration??
//3. if 1st iteration < 2nd, 2nd, then go on
//4. if 2nd iteration > 3rd, 2nd. then go on
//5. former iteration's result should be brought up and locked
// before being compared with an if function with the latter one
// yeah but how???
// * put the result of the first iteration into a variable
// * that variable should also be put before r (second iteration)
// console.log(r);
console.log('Angka string ', tempArray);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment