কম্পিউটার টিউটোরিয়াল

জাভাস্ক্রিপ্টে স্পেসকে আন্ডারস্কোর দিয়ে প্রতিস্থাপন করা

ধরি আমাদের নিচের স্ট্রিংটি আছে:

var sentence = "My Name is David Miller I live in AUS";

উপরের স্ট্রিংতে থাকা স্পেসগুলো আন্ডারস্কোর (_) দিয়ে প্রতিস্থাপন করতে split() এবং join() মেথড ব্যবহার করা হয়।

উদাহরণ

নিচের কোডটি অনুসরণ করুন:

var sentence = "My Name is David Miller I live in AUS";
var withUnderscore = sentence.split(' ').join('_');
console.log("The actual result=");
console.log(sentence);
console.log("After replacing the space with underscore=");
console.log(withUnderscore);

প্রোগ্রামটি রান করতে নিচের কমান্ডটি ব্যবহার করুন:

node fileName.js

এখানে ফাইলের নাম হলো demo250.js।

আউটপুট

কনসোলে নিচের আউটপুটটি দেখাবে:

PS C:\Users\Amit\javascript-code> node demo250.js
The actual result= My Name is David Miller I live in AUS
After replacing the space with underscore= My_Name_is_David_Miller_I_live_in_AUS
  1. জাভাস্ক্রিপ্টে অটোকমপ্লিট (Autocomplete) তৈরি করা

  2. জাভাস্ক্রিপ্ট console.log() উদাহরণসহ

  3. জাভাস্ক্রিপ্ট getPrototypeOf() উদাহরণসহ

  4. জাভাস্ক্রিপ্টে ইনহেরিট্যান্স উদাহরণসহ