v1
- by nikkypizza 1/19/202200
Setup HTML - click to add setup HTML
disable setup JavaScript
Setup JavaScript
const spacify = (str) => str.replace(/\s/, '').split('').join(' ');
const spacify5 = (str) => str.replaceAll(' ', '').split('').join(' ');

const spacify3 = (str) => {
  let result = '';

  for (let i = 0; i < str.length; i++) {
    if (str[i] !== ' ') {
      result += str[i]
    }

    if (i !== str.length - 1) {
      result += ' '
    }
  }
  return result;
}

const spacify4 = (str) => {
  let result = '';

  for (let i = 0; i < str.length; i++) {
    if (str[i] !== ' ') {
      result += str[i]

      if (i !== str.length - 1) {
        result += ' '
      }
    }
  }
  return result;
}

const spacify6 = (str) => {
  let result = '';

  for (let i = 0; i < str.length; i++) {
    if (str[i] !== ' ') {
      result += str[i] + ' '
    }
  }
  return result.slice(0, -1);
}
delete caserun single casemove downdrag and drop case


ready



spacify4('  t   hi s   t ex t i s spa cifi e d  ');
delete caserun single casemove upmove downdrag and drop case


ready



spacify6('  t   hi s   t ex t i s spa cifi e d  ');
delete caserun single casemove upmove downdrag and drop case


ready



spacify3('  t   hi s   t ex t i s spa cifi e d  ')
delete caserun single casemove upmove downdrag and drop case


ready



spacify('  t   hi s   t ex t i s spa cifi e d  ')
delete caserun single casemove updrag and drop case


ready



spacify5('  t   hi s   t ex t i s spa cifi e d  ');
Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN