var generateComment = function (array){ var z; var k = []; for (var i = 0; i < array.length; i++) { z = Math.floor(Math.random() * array[i].length); if (array[i][z][array.length - 1] == ',') { k.push(array[i][z]); } else { k.push(array[i][z] + ' '); } }; return k.join(''); }; //console.log(generateComment([['hi,', 'hello,', 'hey,'], ['how are'], ['you', 'ya'], ['doing', 'going'], ['?', '?!', '']]));
- var generateComment = function (array){
- var z;
- var k = [];
- for (var i = 0; i < array.length; i++) {
- z = Math.floor(Math.random() * array[i].length);
k.push( array[i][z]);- if (array[i][z][array.length - 1] == ',') {
- k.push(array[i][z]);
- } else {
- k.push(array[i][z] + ' ');
- }
- };
return k.join(' ');- return k.join('');
- };
generateComment([['hi,', 'hello,', 'hey,'], ['how are'], ['you', 'ya'], ['doing', 'going'], ['?', '?!', '']]);- //console.log(generateComment([['hi,', 'hello,', 'hey,'], ['how are'], ['you', 'ya'], ['doing', 'going'], ['?', '?!', '']]));
// TODO: Replace examples and use TDD development by writing your own tests // These are some CW specific test methods available: //Test.expect(boolean, [optional] message) //Test.assertEquals(actual, expected, [optional] message) //Test.assertSimilar(actual, expected, [optional] message) //Test.assertNotEquals(actual, expected, [optional] message) // NodeJS assert is also automatically required for you. // assert(true) // assert.strictEqual({a: 1}, {a: 1}) // assert.deepEqual({a: [{b: 1}]}, {a: [{b: 1}]}) // You can also use Chai (http://chaijs.com/) by requiring it yourself // var expect = require("chai").expect; // var assert = require("chai").assert; // require("chai").should(); /*describe("Solution", function(){ it("Test for the given arrays", function(){ Test.assertEquals([['hi,', 'hello,', 'hey,'], ['how are'], ['you', 'ya'], ['doing', 'going'], ['?','?!', '']], 'hi, how are you doing?'); }); });*/
- // TODO: Replace examples and use TDD development by writing your own tests
- // These are some CW specific test methods available:
// Test.expect(boolean, [optional] message)// Test.assertEquals(actual, expected, [optional] message)// Test.assertSimilar(actual, expected, [optional] message)// Test.assertNotEquals(actual, expected, [optional] message)- //Test.expect(boolean, [optional] message)
- //Test.assertEquals(actual, expected, [optional] message)
- //Test.assertSimilar(actual, expected, [optional] message)
- //Test.assertNotEquals(actual, expected, [optional] message)
- // NodeJS assert is also automatically required for you.
- // assert(true)
- // assert.strictEqual({a: 1}, {a: 1})
- // assert.deepEqual({a: [{b: 1}]}, {a: [{b: 1}]})
- // You can also use Chai (http://chaijs.com/) by requiring it yourself
- // var expect = require("chai").expect;
- // var assert = require("chai").assert;
- // require("chai").should();
- /*describe("Solution", function(){
- it("Test for the given arrays", function(){
- Test.assertEquals([['hi,', 'hello,', 'hey,'], ['how are'], ['you', 'ya'], ['doing', 'going'], ['?','?!', '']], 'hi, how are you doing?');
- });
- });*/
var generateComment = function (array){ var z; var k = []; for (var i = 0; i < array.length; i++) { z = Math.floor(Math.random() * array[i].length); k.push( array[i][z]); }; return k.join(' '); } console.log(generateComment([['hi,', 'hello,', 'hey,'], ['how are'], ['you', 'ya'], ['doing', 'going'], ['?','?!', '']]));
- var generateComment = function (array){
- var z;
- var k = [];
- for (var i = 0; i < array.length; i++) {
- z = Math.floor(Math.random() * array[i].length);
- k.push( array[i][z]);
- };
- return k.join(' ');
};generateComment([['hi,', 'hello,', 'hey,'], ['how are'], ['you', 'ya'], ['doing', 'going'], ['?', '?!', '']]);- }
- console.log(generateComment([['hi,', 'hello,', 'hey,'], ['how are'], ['you', 'ya'], ['doing', 'going'], ['?','?!', '']]));
var generateComment = function (array){ var z; var k = []; for (var i = 0; i < array.length; i++) { z = Math.floor(Math.random() * array[i].length); k.push( array[i][z]); }; return k.join(' '); }; generateComment([['hi,', 'hello,', 'hey,'], ['how are'], ['you', 'ya'], ['doing', 'going'], ['?', '?!', '']]);
- var generateComment = function (array){
}- var z;
- var k = [];
- for (var i = 0; i < array.length; i++) {
- z = Math.floor(Math.random() * array[i].length);
- k.push( array[i][z]);
- };
- return k.join(' ');
- };
- generateComment([['hi,', 'hello,', 'hey,'], ['how are'], ['you', 'ya'], ['doing', 'going'], ['?', '?!', '']]);
// TODO: Replace examples and use TDD development by writing your own tests // These are some CW specific test methods available: // Test.expect(boolean, [optional] message) // Test.assertEquals(actual, expected, [optional] message) // Test.assertSimilar(actual, expected, [optional] message) // Test.assertNotEquals(actual, expected, [optional] message) // NodeJS assert is also automatically required for you. // assert(true) // assert.strictEqual({a: 1}, {a: 1}) // assert.deepEqual({a: [{b: 1}]}, {a: [{b: 1}]}) // You can also use Chai (http://chaijs.com/) by requiring it yourself // var expect = require("chai").expect; // var assert = require("chai").assert; // require("chai").should(); /*describe("Solution", function(){ it("Test for the given arrays", function(){ Test.assertEquals([['hi,', 'hello,', 'hey,'], ['how are'], ['you', 'ya'], ['doing', 'going'], ['?','?!', '']], 'hi, how are you doing?'); }); });*/
- // TODO: Replace examples and use TDD development by writing your own tests
- // These are some CW specific test methods available:
- // Test.expect(boolean, [optional] message)
- // Test.assertEquals(actual, expected, [optional] message)
- // Test.assertSimilar(actual, expected, [optional] message)
- // Test.assertNotEquals(actual, expected, [optional] message)
- // NodeJS assert is also automatically required for you.
- // assert(true)
- // assert.strictEqual({a: 1}, {a: 1})
- // assert.deepEqual({a: [{b: 1}]}, {a: [{b: 1}]})
- // You can also use Chai (http://chaijs.com/) by requiring it yourself
- // var expect = require("chai").expect;
- // var assert = require("chai").assert;
- // require("chai").should();
describe("Solution", function(){- /*describe("Solution", function(){
- it("Test for the given arrays", function(){
- Test.assertEquals([['hi,', 'hello,', 'hey,'], ['how are'], ['you', 'ya'], ['doing', 'going'], ['?','?!', '']], 'hi, how are you doing?');
- });
});- });*/