/** * @param words: a list of string * @return: a boolean */ const validWordSquare = function (words) { let colwords = []; let cols = words[0].length; let row = words.length; let offset = 0; for (let i = 1;i<cols;i++){ if (offset == row-1)break; if (words[i-1 + offset][i + offset] !== words[i + offset][i-1 + offset]) returnfalse; if (i == cols){ i = 1; offset++; } } returntrue; }