You fetch remote branches with this command:
git fetch origin
Then the remote branches should show up locally:
git branch -a
You fetch remote branches with this command:
git fetch origin
Then the remote branches should show up locally:
git branch -a
You can apply a replace()
method on your string with a regular expression:
string.replace(/^[ ]+|[ ]+$/g, "");
It will remove any leading/trailing spaces from your string.
Here's how you'd use it:
let string = " Your string. "
string = string.replace(/^[ ]+|[ ]+$/g, "");
// "Your string."
Yes, you can do this via the command line:
npm --version
Which will output the current version number of NPM on your machine:
8.5.1
NPM has a version
command that lists out versions of NPM packages on your machine:
npm version
That will output something similar to this:
{
test: '1.0.0',
npm: '8.5.1',
node: '17.6.0',
v8: '9.6.180.15-node.13',
uv: '1.43.0',
zlib: '1.2.11',
brotli: '1.0.9',
ares: '1.18.1',
modules: '102',
nghttp2: '1.45.1',
napi: '8',
llhttp: '6.0.4',
openssl: '3.0.1+quic',
cldr: '40.0',
icu: '70.1',
tz: '2021a3',
unicode: '14.0',
ngtcp2: '0.1.0-DEV',
nghttp3: '0.1.0-DEV'
}
Another function you could use:
function shuffle(array) {
for (var i = array.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = array[i];
array[i] = array[j];
array[j] = temp;
}
return array
}
It's an implementation of the Durstenfeld Shuffle.