let message = "I B C A R L A M T A R G C E S T A C M H O W A A";

const decryptSimple = (msg, key) => {
	let res = "";
  const msgArr = msg.split(' ');
  if(msgArr.length % key !== 0){
  	return "Invalid Message!"
  }
  let colArr = [];
  let offset = 0;
  while(offset < msgArr.length / key) {
    let col = [];
    for(let i = offset; i < msgArr.length; i += (msgArr.length / key)){
      col.push(msgArr[i]);
    }
    colArr.push(col);
    offset++;
  }
  
  let moveDown = true;
  let j = 0;
  for(let i = 0; i < colArr.length; i++){
    res += colArr[i][j];
    if(j === 0){
      moveDown = true;
    }
    if(j === (key - 1)){
      moveDown = false;
    }
    moveDown ? j++ : j--;
  }
  
  return res;
}

decryptSimple(message, 3);
node v9.7.1 linux/amd64