how to sepaarte text in object javascript


let data = 'Child 1 First Name: AlinChild 1 Gender: FemalenChild 1 Hair Color: BlondenChild 1 Hair Style: WavynChild 1 Skin Tone: TannChild 2 First Name: Morgan nChild 2 Gender: FemalenChild 2 Hair Color: BrownnChild 2 Hair Style: PonytailnChild 2 Skin Tone: LightnRelationship 1 to 2: BrothernRelationship 2 to 1: Brothern';
let target = {};

data.split('n').forEach((pair) => {
if(pair !== '') {
let splitpair = pair.split(': ');
let key = splitpair[0].charAt(0).toLowerCase() + splitpair[0].slice(1).split(' ').join('');
target[key] = splitpair[1];
}
});

console.dir(target);

www.codegrepper.com
www.stackoverflow.com

how to right plain text format file in node js


var fs = require('fs')
fs.appendFile('log.txt', 'new data', function (err) {
if (err) {
// append failed
} else {
// done
}
})

var fs = require('fs')
var logger = fs.createWriteStream('log.txt', {
flags: 'a' // 'a' means appending (old data will be preserved)
})

logger.write('some data') // append string to your file
logger.write('more data') // again
logger.write('and more') // again

www.codegrepper.com
www.stackoverflow.com

how to remove text style on td in angularjs


var colorSpan = element(by.css('span'));

it('should check ng-style', function() {
expect(colorSpan.getCssValue('color')).toMatch(/rgba(0, 0, 0, 1)|rgb(0, 0, 0)/);
element(by.css('input[value='set color']')).click();
expect(colorSpan.getCssValue('color')).toMatch(/rgba(255, 0, 0, 1)|rgb(255, 0, 0)/);
element(by.css('input[value=clear]')).click();
expect(colorSpan.getCssValue('color')).toMatch(/rgba(0, 0, 0, 1)|rgb(0, 0, 0)/);
});

span {
color: black;
}

<input type="button" value="set color" ng-click="myStyle={color:'red'}">
<input type="button" value="set background" ng-click="myStyle={'background-color':'blue'}">
<input type="button" value="clear" ng-click="myStyle={}">
<br/>
<span ng-style="myStyle">Sample Text</span>
<pre>myStyle={{myStyle}}</pre>

www.codegrepper.com
www.stackoverflow.com