12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- export function useQuestionTools() {
- function getLetterByIndex(index) {
- let letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
- if (index < 0 || index > 26) {
- return '?';
- }
- return letters.charAt(index);
- }
- // 判断两个数组是否具有相同元素
- function haveSameElements(arr1, arr2) {
- // 如果两个数组的长度不同,它们不可能包含相同的元素
- if (arr1.length !== arr2.length) {
- return false;
- }
- // 对两个数组进行排序
- arr1.sort((a, b) => a - b);
- arr2.sort((a, b) => a - b);
- // 比较排序后的数组是否相同
- for (let i = 0; i < arr1.length; i++) {
- if (arr1[i] != arr2[i]) {
- return false;
- }
- }
- // 如果所有元素都相同,返回 true
- return true;
- }
- function checkDanxuanReply(item) {
- if (item.reply === 0 || item.reply === '0') {
- return true
- }
- if (!item.reply || item.reply === '' || item.reply === [] || item.reply.length === 0) {
- return false;
- } else {
- return true;
- }
- }
- function checkDuoxuanReply(item) {
- if (!item.reply || item.reply === '' || item.reply === [] || item.reply.length === 0) {
- return false;
- } else {
- for (const _item of item.reply) {
- if (_item === '') {
- return false;
- }
- }
- return true;
- }
- }
- function checkPanduanReply(item) {
- if (!item.reply || item.reply === '' || item.reply === [] || item.reply.length === 0) {
- return false;
- } else {
- return true;
- }
- }
- function checkTiankongReply(item) {
- if (!item.reply || item.reply === '' || item.reply === [] || item.reply.length === 0) {
- return false;
- } else {
- for (const _item of item.reply) {
- if (_item === '') {
- return false;
- }
- }
- return true;
- }
- }
- return {
- getLetterByIndex,
- haveSameElements,
- checkDanxuanReply,
- checkDuoxuanReply,
- checkPanduanReply,
- checkTiankongReply
- }
- }
|