how to split string from position in javascript


<script> 
// JavaScript Program to illustrate split() function 
  
function func() { 
    //Original string 
    var str = 'Geeks for Geeks'
    var array = str.split("for"); 
    document.write(array); 

  
func(); 
</script> 

www.codegrepper.com
www.stackoverflow.com

How to send form data from react to express


const url = localhost:4000/api/users/register;
const usersData= [];

let getData = () => {
axios.get(url)
.then(res => usersData.push(res.data))
.catch(err => console.log(err.data))
}

const reactData = [{ id: 1, name:' Tom'}, { id: 2, name:' Sarah'}];
const url = localhost:4000/api/users/register;

let sendData = () => {
axios.post(url, reactData)
.then(res => console.log('Data send'))
.catch(err => console.log(err.data))
}

www.codegrepper.com
www.stackoverflow.com

how to send information from javascript to flask route


#python route
@app.route('/this-route', methods=['GET', 'POST']):
def thisRoute():
information = request.data
return "1"

#javascript
const URL = '/get-coordinates'
const xhr = new XMLHttpRequest();
sender = JSON.stringify([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
xhr.open('POST', URL);
xhr.send(sender);

www.codegrepper.com
www.stackoverflow.com

how to return multiple values from a function javascript


var values = getValues();
var first = values[0];
var second = values[1];




function getNames() {
// get names from the database or API
let firstName = 'John',
lastName = 'Doe';

// return values
return {
firstName,
lastName
};
}

//function that returns multiple values
function getTopTwoColors() {
return ["blue", "pink"];
}
var topTwoColors=getTopTwoColors();
var firstValue=topTwoColors[0]; //get first return value
var secondValue=topTwoColors[1]; //get second return value

www.codegrepper.com
www.stackoverflow.com