Search This Blog

Friday, April 15, 2022

How to get single array from multiple array in javascript

 

var arr = [

                [ {"c": 1},{"d": 2} ],
                [ {"c": 2},{"d": 3} ]
             ];
             
var newArray = [];

arr.forEach(function(e){
	e.forEach(function(e1){
		newArray.push(e1);
	});
})

console.log(newArray);


comboChange(event) {
  this.filterSearchForm.get('region').value;
  debugger;
  this.currentCities =[];
  this.currentState = [];
  this.regionselection = [];
  this.filterSearchForm.patchValue({
    state : '',
    city : ''
  });
  this.isClose = false;
  if(!event) {
    this.isClose = true;
    console.log('dropdown is closed');
    let arrayregion  = this.filterSearchForm.value.region;

    arrayregion.forEach((element, index) =>
    {
     console.log(element)

      this.regionselection += " " + element.name;

      let array2 = element.states;
       
       array2.forEach((el) =>
       {
        this.currentState.push(el);
       });
   
    });
  }
 
  console.log(this.currentState);
  }

Friday, April 1, 2022

Spilting of an url and put it's part into an array

 function break_address(url_add) {

let data = url_add.split("://"); const protocol = data[0]; data = data[1].split(".com"); const domain = data[0]; data = data[1].split("/"); if(data[1]){ return [protocol,domain,data[1]] } return [protocol,domain] } var url_add = "https://www.w3resource.com/javascript-exercises/" console.log(`Original address: ${url_add}`) console.log(break_address(url_add))


https://codepen.io/w3resource/pen/WKbQXx?editors=1111

Validating to select in sequencial order using angular

    < input type = "checkbox" (change) = "handleSelectTaskItem($event, taskItem)" [checked] = " taskItem . i...