node log centered
// Center text horizontally
function logXCentered(s) {
console.log(' '.repeat(process.stdout.columns / 2 - s.length / 2) + s);
}
logXCentered('This text is centered horizontally.');
// Center text both, horizontally and vertically
function logCentered(s) {
console.log(
'\n'.repeat(process.stdout.rows / 2) +
' '.repeat(process.stdout.columns / 2 - s.length / 2) +
s +
'\n'.repeat(process.stdout.rows / 2 - 1)
);
}
logCentered('This text is centered.');
Also in JavaScript:
- how to make a rectangle in matter.js
- XML
- js create json array
- vuejs use set to prevent duplicates
- datatables clear table
- reference body js
- queryselector data attribute
- javascript get random floating number
- vuejs my chart load before fetch data
- javascript exercism.io bob solution
- angular vs react vs vue
- place white and black knights on 2x2 chessboard
- create a html table dynamically using javascript
- setting multiple styles in javascript
- how to connect react to backend
- js fill string with n characters
- refresh page on button click jquery
- Javascript get sum of array values
- update object in react hooks
- create node project
- left_field in jsgrid
- how to get code suggestions for react components
- nodejs hashing
- javascript response redirect