




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. Which command installs Globalize and the CLDR data for English (en) using npm? A) npm install globalize cldr-data en B) npm install globalize cldr-data@latest --save C) npm install globalize cldr-data --save && npm install cldr-data/main/en --save D) npm install globalize cldr-data && npm install cldr-data/main/en Answer: D Explanation: The first part installs the Globalize library and the CLDR data package; the second installs the specific English locale JSON files from the CLDR data package.
Question 2. After loading CLDR JSON data, which method sets the current locale to French (France)? A) Globalize.locale("fr-FR") B) Globalize.setLocale("fr-FR") C) Globalize.use("fr-FR") D) Globalize.currentLocale("fr-FR") Answer: A Explanation: Globalize.locale() is both a getter and a setter; passing a locale string sets the current locale.
Question 3. Why does the Globalize Date module depend on the Number module? A) Dates are internally stored as numbers (milliseconds) that need number formatting. B) Date parsing uses numeric regular expressions from the Number module. C) The Date module re‑exports Number formatting functions. D) It does not depend; they are independent. Answer: A Explanation: Dates are represented as timestamps (numeric values). The Number module provides utilities for formatting these numeric values when needed.
Question 4. Which Globalize core module must be loaded before any other module? A) Globalize/date B) Globalize/number C) Globalize/message D) Globalize Answer: D Explanation: The base globalize module provides the core API and must be loaded first; other modules extend it.
Question 5. Which method loads CLDR JSON data into Globalize?
A) Globalize("de").formatNumber(12345.678, { minimumFractionDigits: 2, maximumFractionDigits: 2 }) B) Globalize("de").formatNumber(12345.678, { style: "decimal", fractionDigits: 2 }) C) Globalize("de").formatNumber(12345.678, { precision: 2 }) D) Globalize("de").formatNumber(12345.678, { pattern: "#,##0.00" }) Answer: A Explanation: The options minimumFractionDigits and maximumFractionDigits control the exact number of decimal places. German uses a comma as the decimal separator, which is applied automatically.
Question 8. What Unicode pattern would you use to format a number as a percent with one decimal place? A) "#,##0%" B) "#,##0.0%" C) "0.0 %" D) "0%" Answer: B Explanation: Adding a decimal digit (0.0) before the percent sign forces one fractional digit.
Question 9. When formatting a number in scientific notation, which pattern produces “1.23E4”? A) "0.###E0" B) "0.00E+00" C) "0.###e0" D) "#,##0E0" Answer: A Explanation: The pattern 0.###E0 formats numbers in scientific notation with up to three fractional digits.
Question 10. Which Globalize method parses a localized numeric string back to a JavaScript number? A) Globalize.parseNumber() B) Globalize.unformatNumber() C) Globalize.toNumber() D) Globalize.convertNumber() Answer: A Explanation: parseNumber takes a locale‑aware string and returns the numeric value.
Question 11. Parsing the string “1 234,56” in French locale returns?
B) Globalize("en").formatNumber(123.45, { round: "up" }) C) Globalize.formatNumber(123.45, { roundingMode: "up" }) D) Globalize("en").formatNumber(123.45, { roundingMode: "ceil" }) Answer: D Explanation: The roundingMode option accepts values like “ceil”, “floor”, “half-even”, etc., and must be passed to the locale‑specific instance.
Question 14. What does the minimumSignificantDigits option control? A) Minimum number of integer digits shown. B) Minimum total digits (integer + fraction) displayed. C) Minimum number of fraction digits. D) Minimum number of digits after rounding. Answer: B Explanation: Significant digits count all digits, not just those after the decimal point.
Question 15. Which Globalize method formats a JavaScript Date object according to a skeleton “yMd”? A) Globalize.formatDate(date, { skeleton: "yMd" }) B) Globalize.dateFormatter({ skeleton: "yMd" })(date)
C) Globalize.format(date, "yMd") D) Globalize.formatDate(date, "yMd") Answer: B Explanation: dateFormatter creates a formatter function based on the skeleton; invoking it with the date produces the formatted string.
Question 16. In the “en-GB” locale, the skeleton “yMd” typically produces which output for new Date(2023, 4, 9)? A) 2023/05/ B) 09/05/ C) 05/09/ D) 9 May 2023 Answer: B Explanation: British English uses day/month/year order with slashes.
Question 17. Which skeleton would you use to display a full month name, day, and year (e.g., “September 15, 2022”) in the US locale? A) "yMMMd" B) "yMMMMd" C) "yMMMdd"
Answer: C Explanation: The dateFormatter can include timeZoneName to produce the localized name.
Question 20. Which option correctly formats a relative time of – 3 days (i.e., three days ago) in Spanish? A) Globalize("es").formatRelativeTime(-3, "day") B) Globalize("es").relativeTimeFormatter(-3, "day") C) Globalize("es").formatRelativeTime({ value: - 3, unit: "day" }) D) Globalize("es").relativeTime(-3, "day") Answer: A Explanation: formatRelativeTime takes a numeric value and a unit; negative values indicate past times.
Question 21. When parsing a date string “12/31/2022” in the “en-US” locale, which method should be used? A) Globalize.parseDate("12/31/2022") B) Globalize.dateParser({ skeleton: "yMd" })("12/31/2022") C) Globalize("en-US").parseDate("12/31/2022") D) Globalize("en-US").dateParser({ skeleton: "yMd" })("12/31/2022")
Answer: D Explanation: dateParser returns a parsing function for a given skeleton; invoking it yields a Date object.
Question 22. Which skeleton will produce a time string with hour (24‑hour), minute, and second, but no period (AM/PM)? A) "Hm" B) "Hms" C) "hhmmss" D) "hms" Answer: B Explanation: “H” denotes 24‑hour clock; “m” and “s” add minute and second.
Question 23. Which of the following is a valid CLDR JSON path for the decimal separator in the “fr” locale? A) main/fr/numbers/symbols-numberSystem-latn/decimal B) main/fr/numbers/symbols/decimal C) main/fr/decimalSeparator D) main/fr/numbers/decimalSymbol
Answer: C Explanation: Japanese locale displays the Yen symbol as “円”.
Question 26. Which option correctly formats 1234.5 as a currency in German locale with the code “EUR” and the “symbol” style? A) Globalize("de").formatCurrency(1234.5, "EUR", { style: "symbol" }) B) Globalize("de").currencyFormatter("EUR", { style: "symbol" })(1234.5) C) Globalize.formatCurrency(1234.5, "EUR", "de", { style: "symbol" }) D) Globalize("de").formatCurrency(1234.5, { currency: "EUR", style: "symbol" }) Answer: B Explanation: currencyFormatter takes the currency code and options, returning a function that formats the amount.
Question 27. When pluralizing a currency label, which plural category does Arabic use for the number 2? A) one B) two C) few D) many Answer: B
Question 28. Which Globalize method formats a measurement unit (e.g., “5 miles”) in long form? A) Globalize.formatUnit(5, "mile", { form: "long" }) B) Globalize.unitFormatter("mile", { form: "long" })(5) C) Globalize.formatUnit(5, "mile", "long") D) Globalize.unitFormatter({ unit: "mile", form: "long" })(5) Answer: B Explanation: unitFormatter creates a function for a given unit and form; calling it with the number yields the formatted string.
Question 29. In the “en-US” locale, what is the short form of “kilometer” when formatting the value 3? A) km B) k C) kil D) kmt Answer: A Explanation: The short form for kilometer is “km”.
Explanation: The ICU plural syntax uses exact-number matches (=0) and categories (one, other). This covers zero, singular, and plural cases.
Question 32. Which Globalize method provides a plural generator function for a given locale? A) Globalize.pluralGenerator() B) Globalize.pluralRule() C) Globalize.plural() D) Globalize.getPluralGenerator() Answer: A Explanation: pluralGenerator returns a function that maps a number to its plural category for the locale.
Question 33. In Russian, which plural category does the number 5 belong to? A) one B) few C) many D) other Answer: C Explanation: Russian uses “many” for numbers ending in 5‑9, 0, or teens (11‑14).
Question 34. Which message pattern selects gender‑specific pronouns in German? A) {gender, select, male{Er} female{Sie} other{Sie}} B) {gender, select, male{Er} female{Er} other{Sie}} C) {gender, plural, male{Er} female{Sie} other{Sie}} D) {gender, select, m{Er} f{Sie} other{Sie}} Answer: A Explanation: The select clause chooses a string based on the value of gender; the keys must match the variable’s possible values.
Question 35. How can you nest a plural inside a select statement in ICU Message Format? A) {type, select, fruit{{count, plural, one{# apple} other{# apples}}} vegetable{{count, plural, one{# carrot} other{# carrots}}}} B) {type, select, fruit{count, plural, one{# apple} other{# apples}}} C) {type, select, fruit{# apple} other{# item}} D) {type, plural, fruit{# apple} vegetable{# carrot}} Answer: A Explanation: Nested braces allow a select to contain a plural block, enabling complex conditional messages.
Question 38. Which runtime‑only module can be used to format numbers without loading the full Globalize library? A) globalize-runtime/number B) globalize/number-runtime C) globalize-runtime/formatter D) globalize/number-lite Answer: A Explanation: The globalize-runtime/number module provides number formatting functions without the full library overhead.
Question 39. What does the error code “E_MISSING_CLDR” indicate? A) The requested locale data was not loaded. B) The CLDR version is incompatible with Globalize. C) The CLDR JSON file is malformed. D) The CLDR data was loaded but the locale is unsupported. Answer: A Explanation: The error is thrown when a formatter is invoked but the necessary CLDR data for the current locale has not been loaded.
Question 40. Which scenario suggests using Globalize instead of the native Intl API? A) The application only runs on modern browsers with full Intl support. B) You need to support locales not yet covered by the browser’s CLDR data. C) You require lightweight formatting of a single number. D) You need to format dates in the browser’s default locale only. Answer: B Explanation: Globalize can load any CLDR version, allowing support for locales missing from the native Intl implementation.
Question 41. Which command installs the Globalize runtime modules for a production build? A) npm install globalize-runtime --save-prod B) npm install globalize --production C) npm install globalize-runtime --save-dev D) npm install globalize-runtime --save Answer: D Explanation: Runtime modules are regular dependencies; --save adds them to dependencies.