fork download
  1. // your code goes here
  2. const xc = [1, 3, 2];
  3. const d = 2;
  4. const soal4 = (array, value) => {
  5. const second = 0;
  6. for (let i = 0; i < array.length; i++) {
  7. if (array[i] === value) {
  8. const temp = array[i];
  9. array[i] = array[second];
  10. array[second] = temp;
  11. }
  12. }
  13. };
  14. console.log(soal4(xc, d));
Success #stdin #stdout 0.05s 16776KB
stdin
Standard input is empty
stdout
undefined