According to the Javascript standard, String.replace
isn’t supposed to modify the string itself. It just returns the modified string. You can refer to the Mozilla Developer Network documentation for more info.
You can always just set the string to the modified value:
variableABC = variableABC.replace('B', 'D')
Edit: The code given above is to only replace the first occurrence.
To replace all occurrences, you could do:
variableABC = variableABC.replace(/B/g, "D");
To replace all occurrences and ignore casing
variableABC = variableABC.replace(/B/gi, "D");
Related Posts:
- I can´t install nodemon globally, “nodemon” not recognized
- How can I update npm itself?
- How to install a previous exact version of a NPM package?
- How to fix ‘Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.’
- What is the file node.exe for?
- Node.js version on the command line? (not the REPL)
- Discord API error when trying to send one command at discord using JavaScript client
- bash: npm: command not found?
- What is “export default” in JavaScript?
- What is Express.js?
- How do I resolve “Cannot find module” error using Node.js?
- npm ERR cb() never called
- What is the difference between __dirname and ./ in node.js?
- How can the default node version be set using NVM?
- env: node: No such file or directory in mac
- Error: unable to verify the first certificate in nodejs
- Heroku + node.js error (Web process failed to bind to $PORT within 60 seconds of launch)
- how to use CryptoJS in javascript
- nodemon not working: -bash: nodemon: command not found
- nodemon not found in npm
- Best way to replace multiple characters in a string?
- Error: No default engine was specified and no extension was provided
- Angular – ng: command not found
- How can I wait In Node.js (JavaScript)? l need to pause for a period of time
- How to downgrade Node version
- How to change to an older version of Node.js
- ExpressJS – throw er Unhandled error event
- npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY
- Why am I getting “Error socket hang up” response?
- What does the ELIFECYCLE Node.js error mean?
- How to Create and Use Enum in Mongoose
- What does the “as” keyword do?
- How to write a .nvmrc file which automatically change node version
- How can I remove a character from a string using JavaScript?
- What Are “npm run dev” and “npm run prod”
- Find the version of an installed npm package
- First Heroku deploy failed `error code=H10`
- node.js: how to use setInterval and clearInterval?
- Git Bash Command on Windows, yarn command not found
- How to get GET (query string) variables in Express.js on Node.js?
- What is Procfile? and Web and Worker
- What is Procfile? and Web and Worker
- Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’
- First Heroku deploy failed `error code=H10`
- (node:63208) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead
- In express how do I redirect a user to an external url?
- Cannot find module ‘internal/util/types’
- ExpressJS – throw er Unhandled error event
- Error “Cannot find module ‘npmlog'” after “npm update -g”
- ExpressJS : res.redirect() not working as expected?
- error: This is probably not a problem with npm. There is likely additional logging output above
- Passport and connect-flash: req.flash is not a function
- Push items into mongo array via mongoose
- Error: Cannot find module ‘webpack’
- npm – “Can’t find Python executable “python”, you can set the PYTHON env variable.”
- E11000 duplicate key error index in mongodb mongoose
- Node.js: Difference between req.query[] and req.params
- sequelize “findbyid” is not a function but apparently “findAll” is
- NodeJS w/Express Error: Cannot GET /
- Mongoose: CastError: Cast to ObjectId failed for value “[object Object]” at path “_id”
- Unable to connect to mongolab, Getting MongoError: auth failed
- Node.js + Nginx – What now?
- What could cause “connect ETIMEDOUT” error when the URL is working in browser?
- jQuery removing ‘-‘ character from string
- How to Reinstall Broken npm
- What is javascript runtime..?
- Block-scoped declarations not yet supported outside strict mode
- ‘gulp’ is not recognized as an internal or external command
- No gulpfile found
- How is req.isAuthenticated() in Passport JS implemented?
- “invalid ELF header” when using the nodejs “ref” module on AWS Lambda
- Entrypoint undefined = index.html using HtmlWebpackPlugin
- `node-pre-gyp install –fallback-to-build` failed during MeanJS installation on OSX
- TypeError: callback is not a function in nodejs
- http-server command not found
- Route.get() requires callback functions but got a “object Undefined”
- How to create a directory if it doesn’t exist using Node.js
- Replace a character at a specific index in a string?
- NPM self_signed_cert_in_chain
- npm WARN package.json: No repository field
- nodejs – first argument must be a string or Buffer – when using response.write with http.request
- npm “failed to parse json”
- How to update a array value in Mongoose
- In Mongoose, how do I sort by date? (node.js)
- Lua String replace
- How to sort a collection by date in MongoDB?
- How can I use an ES6 import in Node.js? [duplicate]
- Standard function to replace character or substring in a char array?
- npm install with error: `gyp` failed with exit code: 1
- How to stop Node.js server?
- npm update check failed
- unexpected strict mode reserved word — yield? Node v0.11, harmony, es6
- Loop through JSON in EJS
- Forwarding port 80 to 8080 using NGINX
- ReferenceError: describe is not defined NodeJs
- Nodejs – Redirect url
- ode.js vs. meteor.js what’s the difference?
- Can pm2 run an ‘npm start’ script
- Cannot access mongodb through browser – It looks like you are trying to access MongoDB over HTTP on the native driver port
- nvm is not compatible with the npm config “prefix” option: