Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
ComposeWordsGrid
//JavaScript-C24.2.0 (SpiderMonkey) print("Hello, world!") var headingsInput = "_id,_subject,_topic,_questionKey,_gridImage,_gridCells1,_gridCells2,_gridCells3,_gridCells4,_gridCells5,_gridCells6,_gridCells7,_gridCells8,_gridCells9,_gridAnswers"; var valuesInput = "COMPOSEWORDSGRID00001,sub,top,LTRS0021,LTRS0022,LTRS0006*0,LTRS0007*1,LTRS0008*1,LTRS0009*1,LTRS0010*1,LTRS0019*1,LTRS0020*1,LTRS0021*1,LTRS0022*1,LTRS0020*LTRS0021*LTRS0022"; function ComposeWordsGrid(headingsInput, valuesInput) { // Utilities.sleep(1000); var json = {}; if(valuesInput !== undefined && headingsInput !== undefined) { var headingsArray = headingsInput.toString().split(","); var valuesArray = valuesInput.toString().split(","); json[headingsArray[0]] = valuesArray[0]; json[headingsArray[1]] = valuesArray[1]; json[headingsArray[2]] = valuesArray[2]; json[headingsArray[3]] = valuesArray[3]; json[headingsArray[4]] = valuesArray[4]; var _gridCells = []; for(var i = 5; i < valuesArray.length - 1; i++) { var input = valuesArray[i].toString().split("*"); if(input[0] === "") continue; var _gridCell = {}; _gridCell["_gridValue"] = input[0]; _gridCell["_gridValueType"] = parseInt(input[1]); _gridCells.push(_gridCell); } json["_gridCells"] = _gridCells; var _gridCellsAnswers = []; var inputAns = valuesArray[valuesArray.length - 1].toString().split("*"); for(var k = 0; k < inputAns.length; k++) { _gridCellsAnswers.push(inputAns[k]); } json["_gridCellsAnswers"] = _gridCellsAnswers; var finalObj = {}; finalObj[valuesArray[0]] = json; } return JSON.stringify(finalObj); } print(ComposeWordsGrid(headingsInput, valuesInput));
run
|
edit
|
history
|
help
0
Arrays
Star wars ep 3. limit
Javascript Basics
Yes
sortStack
9
fb_series
Dum
H
codeing