JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
JavaScript
// Code goes here
var translatedWord = "";
currentCharacter = "猫";
translateRequestURL = 'https://translate.googleapis.com/translate_a/single?client=gtx&sl=zh-CN&tl=en&dt=t&q=' + currentCharacter;
$.ajax(translateRequestURL).done(function (data) {
translatedWord = data[0][0][0]; //this is what I need
alert('This works '+translatedWord); //this works
});
alert('this does not '+translatedWord); //this doesn't work